From: Sami Kerola <kerolasa@iki.fi>
To: util-linux@vger.kernel.org
Subject: Re: [PATCH 05/10] bash-completion: misc-utils
Date: Mon, 1 Apr 2013 17:52:46 +0100 [thread overview]
Message-ID: <20130401165133.GB22182@gmail.com> (raw)
In-Reply-To: <20130328014241.GY526@rampage>
On Wed, Mar 27, 2013 at 09:42:41PM -0400, Dave Reisner wrote:
> On Wed, Mar 27, 2013 at 10:07:47PM +0000, Sami Kerola wrote:
> > + local PARTITIONS
> > + PARTITIONS="$(for I in /sys/block/*/*/partition; do IFS='/'; DIR_ARR=($I); echo "/dev/${DIR_ARR[4]}"; done)"
>
> You want the loop *outside* the assignment, rather than exploding the
> contents into the array via echo:
>
> for part in /sys/block/*/*/partition; do
> IFS=/ read -ra a <<< "$part"
> partitions+=("${a[4]}")
> done
That was changed to use 'lsblk' rather than /sys files.
> > + '-N'|'--task')
> > + local TID I
> > + TID="$(for I in /proc/*/mountinfo; do IFS='/'; TID=($I); echo "${TID[2]}"; done)"
>
> Ditto here
Corrected.
> > + COMPREPLY=( $(compgen -W "$TID" -- $cur) )
> > + return 0
> > + ;;
> > + '-O'|'--options')
> > + local MNT_OPTS
> > + MNT_OPTS=$(awk '{ n = split($4, a, ","); for (i = 0; i <= n; i++) { mnt_opts[a[i]]=1 } } END { for (i in mnt_opts) { print i } }' /etc/mtab 2>/dev/null )
>
> I'm not sure you want to get into this game. You're including values
> from key=val pairs (e.g. the 300 in timeout=300). Regardless, no awk
> required here
>
> declare -A mnt_opts
>
> while read _ _ _ optstring _; do
> IFS=, read -ra opts <<< "$optstring"
> for opt in "${opts[@]}"; do
> mnt_opts["${opt%%=*}"]=1
> done
> done </etc/mtab
>
> opts=("${!mnt_opts[@]}")
Something similar to that was done with a small difference to avoid
reading /etc/mtab. Notice that findmnt is using key=val pair when
matching with mount options, not key only.
> > + COMPREPLY=( $(compgen -W "$MNT_OPTS" -- $cur) )
> > + return 0
> > + ;;
> > + '-o'|'--output')
> > + # FIXME: how to append to a string with compgen?
>
> I've been down this road when I wrote some of the systemd completion. I
> don't think you want to go there.
I am not sure if CSV filling with compgen is currently possible. I have
a feeling the whole issue would be easier if after a completetion which
resulted to nospace a word break would be inserted. Is that missing bash
feature, bug, or my misunderstanding how this case would be nicest to
solve. While I do not know belive leaving the FIXME items in place is
correct thing to do.
Thanks for reviews Dave.
--
Sami Kerola
http://www.iki.fi/kerolasa/
next prev parent reply other threads:[~2013-04-01 16:52 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-27 22:07 [PATCH 00/10] [pull] bash-completion Sami Kerola
2013-03-27 22:07 ` [PATCH 01/10] bash-completion: add bash completetion configure option Sami Kerola
2013-03-28 11:22 ` Sami Kerola
2013-03-29 9:42 ` Karel Zak
2013-03-27 22:07 ` [PATCH 02/10] bash-completion: disk-utils Sami Kerola
2013-03-28 1:42 ` Dave Reisner
2013-04-01 15:54 ` Sami Kerola
2013-03-28 9:54 ` Karel Zak
2013-04-01 17:00 ` Sami Kerola
2013-03-27 22:07 ` [PATCH 03/10] bash-completion: fdisks Sami Kerola
2013-03-28 10:01 ` Karel Zak
2013-03-27 22:07 ` [PATCH 04/10] bash-completion: login-utils Sami Kerola
2013-03-28 1:42 ` Dave Reisner
2013-04-01 16:05 ` Sami Kerola
2013-03-28 10:05 ` Karel Zak
2013-04-01 16:06 ` Sami Kerola
2013-03-27 22:07 ` [PATCH 05/10] bash-completion: misc-utils Sami Kerola
2013-03-28 1:42 ` Dave Reisner
2013-04-01 16:52 ` Sami Kerola [this message]
2013-03-27 22:07 ` [PATCH 06/10] bash-completion: schedutils Sami Kerola
2013-03-27 22:07 ` [PATCH 07/10] bash-completion: sys-utils Sami Kerola
2013-03-29 16:33 ` Karel Zak
2013-04-01 16:32 ` Sami Kerola
2013-04-05 14:44 ` Karel Zak
2013-03-27 22:07 ` [PATCH 08/10] bash-completion: term-utils Sami Kerola
2013-03-28 10:06 ` Karel Zak
2013-03-27 22:07 ` [PATCH 09/10] bash-completion: text-utils Sami Kerola
2013-03-27 22:07 ` [PATCH 10/10] bash-completion: add completion files to Makefile.am Sami Kerola
2013-03-28 1:42 ` [PATCH 00/10] [pull] bash-completion Dave Reisner
2013-03-28 9:37 ` Karel Zak
2013-03-31 23:49 ` Sami Kerola
2013-04-01 15:44 ` Sami Kerola
2013-04-05 14:11 ` Karel Zak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130401165133.GB22182@gmail.com \
--to=kerolasa@iki.fi \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.