]> git.ipfire.org Git - thirdparty/util-linux.git/commit
bash-completion: handle comma-separated options
authorBoris Egorov <egorov@linux.com>
Tue, 2 Jun 2015 17:59:01 +0000 (23:59 +0600)
committerKarel Zak <kzak@redhat.com>
Mon, 8 Jun 2015 10:09:48 +0000 (12:09 +0200)
commitb5b80e5a6d85a53c89e8ef1ddb76ae985a1c7f65
treefacd8becf5d26541bc24d67e51fa52652ef09df4
parent6a768b55165f8b09bf95fc018b771261ddf64084
bash-completion: handle comma-separated options

This solution can become messy when you have too many options listed,
because it repeats all of them. For example, after invoking completion
with this input:

    $ partx --output END,SECTORS,SCHEME,START,

You got these completions:

    END,SECTORS,SCHEME,START,FLAGS,  END,SECTORS,SCHEME,START,NR,
    END,SECTORS,SCHEME,START,TYPE,
    END,SECTORS,SCHEME,START,NAME,   END,SECTORS,SCHEME,START,SIZE,
    END,SECTORS,SCHEME,START,UUID,

Nevertheless, it works even with numbers (listed options properly
excluded from completion). Try to invoke completion after
'chcpu --disable ' or 'lsblk --exclude ' to see it in action.

Few issues remained:

    * completion interrupts after encountering ':' in listed option,
    like in 'MAJ:MIN' in lsblk, losetup.
    * lscpu completion is broken: it inserts space after '--extended',
    but lscpu assumes there is no space after this option. It also
    doesn't complete '--parse' option.
    * some completion options are outdated (for example, lscpu MMHZ). We
    need to sync them with code. Fix for lscpu follows.

Signed-off-by: Boris Egorov <egorov@linux.com>
13 files changed:
bash-completion/chcpu
bash-completion/findmnt
bash-completion/losetup
bash-completion/lsblk
bash-completion/lscpu
bash-completion/lslocks
bash-completion/partx
bash-completion/prlimit
bash-completion/setpriv
bash-completion/swapon
bash-completion/taskset
bash-completion/wdctl
bash-completion/zramctl