]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
bash-completion: setpriv --securebits argument can be comma separated list
authorSami Kerola <kerolasa@iki.fi>
Thu, 5 Apr 2018 19:56:55 +0000 (20:56 +0100)
committerKarel Zak <kzak@redhat.com>
Fri, 6 Apr 2018 11:03:38 +0000 (13:03 +0200)
Make the option argument suggestion to match with what is allowed.  In same
go tidy shell code a little bit.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
bash-completion/setpriv

index bf4737a3ad679aef9e469a31185db655cc626ef3..1c67f8288ddff824b766272980863b621675c3aa 100644 (file)
@@ -46,10 +46,23 @@ _setpriv_module()
                        return 0
                        ;;
                '--securebits')
-                       local SBITS
-                       SBITS="noroot noroot_locked no_setuid_fixup no_setuid_fixup_locked keep_caps_locked
-                       -noroot -noroot_locked -no_setuid_fixup -no_setuid_fixup_locked -keep_caps_locked"
-                       COMPREPLY=( $(compgen -W "$SBITS" -- $cur) )
+                       local prefix realcur SBITS_ALL SBITS WORD
+                       realcur="${cur##*,}"
+                       prefix="${cur%$realcur}"
+                       SBITS_ALL="
+                               {+,-}keep_caps_locked
+                               {+,-}noroot
+                               {+,-}noroot_locked
+                               {+,-}no_setuid_fixup
+                               {+,-}no_setuid_fixup_locked
+                       "
+                       for WORD in $SBITS_ALL; do
+                               if ! [[ $prefix == *"$WORD"* ]]; then
+                                       SBITS="$WORD ${SBITS:-""}"
+                               fi
+                       done
+                       compopt -o nospace
+                       COMPREPLY=( $(compgen -P "$prefix" -W "$SBITS" -S ',' -- $realcur) )
                        return 0
                        ;;
                '--selinux-label')