bash-completion: Invoke actual commands to be completed, not basenames

Addresses partially: http://bugs.debian.org/769462
Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>
This commit is contained in:
Ville Skyttä 2014-11-15 22:36:04 +02:00 committed by Karel Zak
parent 8596f63914
commit 396a6d7df5
7 changed files with 11 additions and 11 deletions

View file

@ -6,7 +6,7 @@ _chsh_module()
prev="${COMP_WORDS[COMP_CWORD-1]}" prev="${COMP_WORDS[COMP_CWORD-1]}"
case $prev in case $prev in
'-s'|'--shell') '-s'|'--shell')
COMPREPLY=( $(compgen -W "$(chsh -l)" -- $cur) ) COMPREPLY=( $(compgen -W "$($1 -l)" -- $cur) )
return 0 return 0
;; ;;
'-u'|'--help'|'-v'|'--version') '-u'|'--help'|'-v'|'--version')

View file

@ -15,7 +15,7 @@ _eject_module()
return 0 return 0
;; ;;
'-x'|'--cdspeed') '-x'|'--cdspeed')
COMPREPLY=( $(compgen -W "$(eject -X)" -- $cur) ) COMPREPLY=( $(compgen -W "$($1 -X)" -- $cur) )
return 0 return 0
;; ;;
'-h'|'--help'|'-V'|'--version') '-h'|'--help'|'-V'|'--version')

View file

@ -38,7 +38,7 @@ _findmnt_module()
for I in ${TMP_ARR[@]}; do for I in ${TMP_ARR[@]}; do
MNT_OPTS[$I]='1' MNT_OPTS[$I]='1'
done done
done < <(findmnt -rno OPTIONS) done < <($1 -rno OPTIONS)
COMPREPLY=( $(compgen -W "${!MNT_OPTS[@]}" -- $cur) ) COMPREPLY=( $(compgen -W "${!MNT_OPTS[@]}" -- $cur) )
return 0 return 0
;; ;;
@ -67,13 +67,13 @@ _findmnt_module()
;; ;;
'-S'|'--source') '-S'|'--source')
local DEV_MPOINT local DEV_MPOINT
DEV_MPOINT=$(findmnt -rno SOURCE | grep ^/dev) DEV_MPOINT=$($1 -rno SOURCE | grep ^/dev)
COMPREPLY=( $(compgen -W "$DEV_MPOINT" -- $cur) ) COMPREPLY=( $(compgen -W "$DEV_MPOINT" -- $cur) )
return 0 return 0
;; ;;
'-T'|'--target') '-T'|'--target')
local DEV_MPOINT local DEV_MPOINT
DEV_MPOINT=$(findmnt -rno TARGET) DEV_MPOINT=$($1 -rno TARGET)
COMPREPLY=( $(compgen -W "$DEV_MPOINT" -- $cur) ) COMPREPLY=( $(compgen -W "$DEV_MPOINT" -- $cur) )
return 0 return 0
;; ;;
@ -117,7 +117,7 @@ _findmnt_module()
;; ;;
esac esac
local DEV_MPOINT local DEV_MPOINT
DEV_MPOINT=$(findmnt -rno TARGET,SOURCE) DEV_MPOINT=$($1 -rno TARGET,SOURCE)
COMPREPLY=( $(compgen -W "$DEV_MPOINT" -- $cur) ) COMPREPLY=( $(compgen -W "$DEV_MPOINT" -- $cur) )
return 0 return 0
} }

View file

@ -6,12 +6,12 @@ _losetup_module()
prev="${COMP_WORDS[COMP_CWORD-1]}" prev="${COMP_WORDS[COMP_CWORD-1]}"
case $prev in case $prev in
'-d'|'--detach') '-d'|'--detach')
ARG="$(losetup --output NAME | awk '{if (1 < NR) {print}}')" ARG="$($1 --output NAME | awk '{if (1 < NR) {print}}')"
COMPREPLY=( $(compgen -W "$ARG" -- $cur) ) COMPREPLY=( $(compgen -W "$ARG" -- $cur) )
return 0 return 0
;; ;;
'-j'|'--associated') '-j'|'--associated')
ARG="$(losetup --output BACK-FILE | awk '{if (1 < NR) {print}}')" ARG="$($1 --output BACK-FILE | awk '{if (1 < NR) {print}}')"
COMPREPLY=( $(compgen -W "$ARG" -- $cur) ) COMPREPLY=( $(compgen -W "$ARG" -- $cur) )
return 0 return 0
;; ;;

View file

@ -70,7 +70,7 @@ _lsblk_module()
;; ;;
esac esac
local DEVS local DEVS
COMPREPLY=( $(compgen -W "$(lsblk -pnro name)" -- $cur) ) COMPREPLY=( $(compgen -W "$($1 -pnro name)" -- $cur) )
return 0 return 0
} }
complete -F _lsblk_module lsblk complete -F _lsblk_module lsblk

View file

@ -10,7 +10,7 @@ _setarch_module()
;; ;;
esac esac
if [ $COMP_CWORD -eq 1 ]; then if [ $COMP_CWORD -eq 1 ]; then
COMPREPLY=( $(compgen -W "$(setarch --list)" -- $cur) ) COMPREPLY=( $(compgen -W "$($1 --list)" -- $cur) )
return 0 return 0
fi fi
case $cur in case $cur in

View file

@ -8,7 +8,7 @@ _setpriv_module()
'--inh-caps'|'--bounding-set') '--inh-caps'|'--bounding-set')
# FIXME: how to append to a string with compgen? # FIXME: how to append to a string with compgen?
local INHERIT local INHERIT
INHERIT=$(setpriv --list-caps| awk '{print $1, "-" $1}') INHERIT=$($1 --list-caps| awk '{print $1, "-" $1}')
compopt -o nospace compopt -o nospace
COMPREPLY=( $(compgen -W "all $INHERIT" -S ',' -- $cur) ) COMPREPLY=( $(compgen -W "all $INHERIT" -S ',' -- $cur) )
return 0 return 0