]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
bash-completion: Invoke actual commands to be completed, not basenames
authorVille Skyttä <ville.skytta@iki.fi>
Sat, 15 Nov 2014 20:36:04 +0000 (22:36 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 18 Nov 2014 12:58:21 +0000 (13:58 +0100)
Addresses partially: http://bugs.debian.org/769462
Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>
bash-completion/chsh
bash-completion/eject
bash-completion/findmnt
bash-completion/losetup
bash-completion/lsblk
bash-completion/setarch
bash-completion/setpriv

index 70641947cae1687b55438565b2f0b322c3b84c50..fbf8add885e3bfbb82cdb9743f8c6b8c0ecb7c0d 100644 (file)
@@ -6,7 +6,7 @@ _chsh_module()
        prev="${COMP_WORDS[COMP_CWORD-1]}"
        case $prev in
                '-s'|'--shell')
-                       COMPREPLY=( $(compgen -W "$(chsh -l)" -- $cur) )
+                       COMPREPLY=( $(compgen -W "$($1 -l)" -- $cur) )
                        return 0
                        ;;
                '-u'|'--help'|'-v'|'--version')
index bb7187f0422c9fc75dc22c3c95123f13eb523cb4..123829ea25bc74c141c765842a6c09e41c23a868 100644 (file)
@@ -15,7 +15,7 @@ _eject_module()
                        return 0
                        ;;
                '-x'|'--cdspeed')
-                       COMPREPLY=( $(compgen -W "$(eject -X)" -- $cur) )
+                       COMPREPLY=( $(compgen -W "$($1 -X)" -- $cur) )
                        return 0
                        ;;
                '-h'|'--help'|'-V'|'--version')
index a7df4a0ed710b0091d893b03d368398fcad37bdb..cf66565c137dce7506da88d4bb823b9f51fbe4cf 100644 (file)
@@ -38,7 +38,7 @@ _findmnt_module()
                                for I in ${TMP_ARR[@]}; do
                                        MNT_OPTS[$I]='1'
                                done
-                       done < <(findmnt -rno OPTIONS)
+                       done < <($1 -rno OPTIONS)
                        COMPREPLY=( $(compgen -W "${!MNT_OPTS[@]}" -- $cur) )
                        return 0
                        ;;
@@ -67,13 +67,13 @@ _findmnt_module()
                        ;;
                '-S'|'--source')
                        local DEV_MPOINT
-                       DEV_MPOINT=$(findmnt -rno SOURCE | grep ^/dev)
+                       DEV_MPOINT=$($1 -rno SOURCE | grep ^/dev)
                        COMPREPLY=( $(compgen -W "$DEV_MPOINT" -- $cur) )
                        return 0
                        ;;
                '-T'|'--target')
                        local DEV_MPOINT
-                       DEV_MPOINT=$(findmnt -rno TARGET)
+                       DEV_MPOINT=$($1 -rno TARGET)
                        COMPREPLY=( $(compgen -W "$DEV_MPOINT" -- $cur) )
                        return 0
                        ;;
@@ -117,7 +117,7 @@ _findmnt_module()
                        ;;
        esac
        local DEV_MPOINT
-       DEV_MPOINT=$(findmnt -rno TARGET,SOURCE)
+       DEV_MPOINT=$($1 -rno TARGET,SOURCE)
        COMPREPLY=( $(compgen -W "$DEV_MPOINT" -- $cur) )
        return 0
 }
index 874c549ae3bbb1dbac695159dc252a31b37019e1..d2b74184ffb3bb4f356454c29f018ce28dda4711 100644 (file)
@@ -6,12 +6,12 @@ _losetup_module()
        prev="${COMP_WORDS[COMP_CWORD-1]}"
        case $prev in
                '-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) )
                        return 0
                        ;;
                '-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) )
                        return 0
                        ;;
index b5dcb400cc02cd42e00552e2134fa436caa42e33..af8b9ad65d24335cbad94ddfaa054193a65965e6 100644 (file)
@@ -70,7 +70,7 @@ _lsblk_module()
                        ;;
        esac
        local DEVS
-       COMPREPLY=( $(compgen -W "$(lsblk -pnro name)" -- $cur) )
+       COMPREPLY=( $(compgen -W "$($1 -pnro name)" -- $cur) )
        return 0
 }
 complete -F _lsblk_module lsblk
index b2c6a074b05e299044b9852fa79dc6b60d3cefe4..771de98d84f8e0d2df393d118ffc39a14edf4ce8 100644 (file)
@@ -10,7 +10,7 @@ _setarch_module()
                        ;;
        esac
        if [ $COMP_CWORD -eq 1 ]; then
-               COMPREPLY=( $(compgen -W "$(setarch --list)" -- $cur) )
+               COMPREPLY=( $(compgen -W "$($1 --list)" -- $cur) )
                return 0
        fi
        case $cur in
index 3be5ccd702a7ffb4658e3ffad628c92d32bd5276..7c21deefa315e8faa08dcb7de34861dd538635df 100644 (file)
@@ -8,7 +8,7 @@ _setpriv_module()
                '--inh-caps'|'--bounding-set')
                        # FIXME: how to append to a string with compgen?
                        local INHERIT
-                       INHERIT=$(setpriv --list-caps| awk '{print $1, "-" $1}')
+                       INHERIT=$($1 --list-caps| awk '{print $1, "-" $1}')
                        compopt -o nospace
                        COMPREPLY=( $(compgen -W "all $INHERIT" -S ',' -- $cur) )
                        return 0