From ecfb5b267c46f4425abcdbec203447fa5e147bf2 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Thu, 5 Apr 2018 20:56:55 +0100 Subject: [PATCH] bash-completion: setpriv --securebits argument can be comma separated list 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 --- bash-completion/setpriv | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/bash-completion/setpriv b/bash-completion/setpriv index bf4737a3ad..1c67f8288d 100644 --- a/bash-completion/setpriv +++ b/bash-completion/setpriv @@ -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') -- 2.47.3