]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
bash-completion: fix few bash set -u issues
authorSami Kerola <kerolasa@iki.fi>
Thu, 5 Apr 2018 19:56:53 +0000 (20:56 +0100)
committerKarel Zak <kzak@redhat.com>
Fri, 6 Apr 2018 11:03:38 +0000 (13:03 +0200)
This is the same fix as in reference commit, and the same reason.  Just
correct few files missed earlier.

Reference: abbcec4fc9c8d7fb835b4eafd1bc9d82acbf0056
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
bash-completion/chcpu
bash-completion/lsblk
bash-completion/lscpu
bash-completion/lslogins
bash-completion/lsns
bash-completion/mount
bash-completion/setpriv
bash-completion/taskset

index 33991f4a82b19699f877b0e98151acfccf288f69..0d96c25321e6cce7f15696460226c46775d79f7d 100644 (file)
@@ -12,7 +12,7 @@ _chcpu_module()
                        CPULIST_ALL=$(sed 's/^/{/; s/-/../g; s/,/} {/g; s/$/}/' /sys/devices/system/cpu/offline)
                        for WORD in $(eval echo $CPULIST_ALL); do
                                if ! [[ $prefix == *"$WORD"* ]]; then
-                                       CPULIST="$WORD $CPULIST"
+                                       CPULIST="$WORD ${CPULIST:-""}"
                                fi
                        done
                        compopt -o nospace
@@ -26,7 +26,7 @@ _chcpu_module()
                        CPULIST_ALL=$(sed 's/^/{/; s/-/../g; s/,/} {/g; s/$/}/' /sys/devices/system/cpu/online)
                        for WORD in $(eval echo $CPULIST_ALL); do
                                if ! [[ $prefix == *"$WORD"* ]]; then
-                                       CPULIST="$WORD $CPULIST"
+                                       CPULIST="$WORD ${CPULIST:-""}"
                                fi
                        done
                        compopt -o nospace
index 4fef8fc846eea49600590f9233007882e874353d..bd86f9f797d6b989885c62215345ea36d56de1bb 100644 (file)
@@ -20,15 +20,15 @@ _lsblk_module()
                        prefix="${cur%$realcur}"
                        for I in /sys/dev/block/*; do
                                J=${I##*/}
-                               MAJOR_ALL="$MAJOR_ALL ${J%%:*}"
+                               MAJOR_ALL="${MAJOR_ALL:-""} ${J%%:*}"
                        done
-                       for WORD in $MAJOR_ALL; do
+                       for WORD in ${MAJOR_ALL:-""}; do
                                if ! [[ $prefix == *"$WORD"* ]]; then
-                                       MAJOR="$WORD $MAJOR"
+                                       MAJOR="$WORD ${MAJOR:-""}"
                                fi
                        done
                        compopt -o nospace
-                       COMPREPLY=( $(compgen -P "$prefix" -W "$MAJOR" -S ',' -- $realcur) )
+                       COMPREPLY=( $(compgen -P "$prefix" -W "${MAJOR:-""}" -S ',' -- $realcur) )
                        return 0
                        ;;
                '-o'|'--output')
@@ -37,7 +37,7 @@ _lsblk_module()
                        prefix="${cur%$realcur}"
                        for WORD in $LSBLK_COLS_ALL; do
                                if ! [[ $prefix == *"$WORD"* ]]; then
-                                       LSBLK_COLS="$WORD $LSBLK_COLS"
+                                       LSBLK_COLS="$WORD ${LSBLK_COLS:-""}"
                                fi
                        done
                        compopt -o nospace
index d16af350f3db0421730bdb02ac414abf1ed52595..69337acef315ec2e25dc5ff391ed62c7fe50aa0a 100644 (file)
@@ -15,7 +15,7 @@ _lscpu_module()
                                CONFIGURED ONLINE MAXMHZ MINMHZ"
                        for WORD in $OPTS_ALL; do
                                if ! [[ $prefix == *"$WORD"* ]]; then
-                                       OPTS="$WORD $OPTS"
+                                       OPTS="$WORD ${OPTS:-""}"
                                fi
                        done
                        compopt -o nospace
index 967b644ca0c67b85f43b56b2929a28178d54383b..795b5d848358a85a5a271bcf3e0bf43e9b0d0b4a 100755 (executable)
@@ -35,7 +35,7 @@ _lslogins_module()
                        prefix="${cur%$realcur}"
                        for WORD in $LSLOGINS_COLS_ALL; do
                                if ! [[ $prefix == *"$WORD"* ]]; then
-                                       LSLOGINS_COLS="$WORD $LSLOGINS_COLS"
+                                       LSLOGINS_COLS="$WORD ${LSLOGINS_COLS:-""}"
                                fi
                        done
                        compopt -o nospace
index 8cf0a31f9a16216dcc1d449ef83c662035956af0..035f43b2a1961a18be3ae6c9e63169b73d763b2f 100644 (file)
@@ -14,7 +14,7 @@ _lsns_module()
                        prefix="${cur%$realcur}"
                        for WORD in $LSNS_COLS_ALL; do
                                if ! [[ $prefix == *"$WORD"* ]]; then
-                                       LSNS_COLS="$WORD $LSNS_COLS"
+                                       LSNS_COLS="$WORD ${LSNS_COLS:-""}"
                                fi
                        done
                        compopt -o nospace
index 9a33913395224663a096766bd3fcab913d103eeb..c7e4bead6c89763e177236f006989a03b70b1726 100644 (file)
@@ -15,7 +15,7 @@ _mount_module()
                        prefix="${cur%$realcur}"
                        for WORD in $TYPES; do
                                if ! [[ $prefix == *"$WORD"* ]]; then
-                                       TYPE_COLS="$WORD $TYPE_COLS"
+                                       TYPE_COLS="$WORD ${TYPE_COLS:-""}"
                                fi
                        done
                        compopt -o nospace
index 8ab9e072251bc1bf50afb50c84f6b4d5aad9924d..bf4737a3ad679aef9e469a31185db655cc626ef3 100644 (file)
@@ -38,7 +38,7 @@ _setpriv_module()
                        GIDS_ALL=$(getent group | awk -F: '{print $3}')
                        for WORD in $GIDS_ALL; do
                                if ! [[ $prefix == *"$WORD"* ]]; then
-                                       GIDS="$WORD $GIDS"
+                                       GIDS="$WORD ${GIDS:-""}"
                                fi
                        done
                        compopt -o nospace
index 453b17b4ae655dde73ae095b36e1a02b1f4d97d4..7c9a7bd546a2a234871e72aa26c698d4abae4047 100644 (file)
@@ -12,7 +12,7 @@ _taskset_module()
                        CPULIST_ALL=$(sed 's/^/{/; s/-/../g; s/,/} {/g; s/$/}/' /sys/devices/system/cpu/online)
                        for WORD in $(eval echo $CPULIST_ALL); do
                                if ! [[ $prefix == *"$WORD"* ]]; then
-                                       CPULIST="$WORD $CPULIST"
+                                       CPULIST="$WORD ${CPULIST:-""}"
                                fi
                        done
                        compopt -o nospace