Skip to contentSkip to conversation

pull: couple bash-completion fixes

PATCH Applied Sami Kerola 2 participants 6 messages Apr 5, 2018 – Apr 6, 2018 Util-Linux package

lore
Share & tools
lore
#0 lore raw

cover pull: couple bash-completion fixes

Hello Karel and other,

It would have been better to get these in before relese v2.32 got out, so sorry for missing that. I'm sure these fairly trivial corrections are welcome to be part of the next releaese, so perhaps missing one is not great misfortune at the end.

----------------------------------------------------------------
The following changes since commit 6963338ca586bef3370e189f13785b4b6b63bbdb:
dmesg: fix raw output (2018-04-05 15:59:59 +0200)
are available in the Git repository at:
git://github.com/kerolasa/lelux-utiliteetit.git bash-comp
for you to fetch changes up to 1ea4305b1c541333a2c9e4434dc7c3ca05cf188d:
bash-completion: fix typo in blockdev file (2018-04-05 20:49:27 +0100)
----------------------------------------------------------------

Sami Kerola (4):
bash-completion: fix few bash set -u issues
bash-completion: do not print eject --cdspeed error messages
bash-completion: setpriv --securebits argument can be comma separated list
bash-completion: fix typo in blockdev file

 bash-completion/blockdev |  2 +-
 bash-completion/chcpu    |  4 ++--
 bash-completion/eject    |  2 +-
 bash-completion/lsblk    | 10 +++++-----
 bash-completion/lscpu    |  2 +-
 bash-completion/lslogins |  2 +-
 bash-completion/lsns     |  2 +-
 bash-completion/mount    |  2 +-
 bash-completion/setpriv  | 23 ++++++++++++++++++-----
 bash-completion/taskset  |  2 +-
 10 files changed, 32 insertions(+), 19 deletions(-)
Signature · 1 line
2.17.0
#1 lore raw

PATCH 1/4 bash-completion: fix few bash set -u issues

This is the same fix as in reference commit, and the same reason. Just correct few files missed earlier.

Reference: abbcec4fc9c8d7fb835b4eafd1bc9d82acbf0056

---
 bash-completion/chcpu    |  4 ++--
 bash-completion/lsblk    | 10 +++++-----
 bash-completion/lscpu    |  2 +-
 bash-completion/lslogins |  2 +-
 bash-completion/lsns     |  2 +-
 bash-completion/mount    |  2 +-
 bash-completion/setpriv  |  2 +-
 bash-completion/taskset  |  2 +-
 8 files changed, 13 insertions(+), 13 deletions(-)
bash-completion/chcpu +2 -2
index 33991f4a8..0d96c2532 100644
@@ -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
bash-completion/lsblk +5 -5
index 4fef8fc84..bd86f9f79 100644
@@ -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
bash-completion/lscpu +1 -1
index d16af350f..69337acef 100644
@@ -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
bash-completion/lslogins +1 -1
index 967b644ca..795b5d848 100755
@@ -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
bash-completion/lsns +1 -1
index 8cf0a31f9..035f43b2a 100644
@@ -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
bash-completion/mount +1 -1
index 9a3391339..c7e4bead6 100644
@@ -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
bash-completion/setpriv +1 -1
index 8ab9e0722..bf4737a3a 100644
@@ -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
bash-completion/taskset +1 -1
index 453b17b4a..7c9a7bd54 100644
@@ -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
Signature · 1 line
2.17.0
#2 lore raw

PATCH 2/4 bash-completion: do not print eject --cdspeed error messages

In reply to Sami Kerola

Bash completion is proposing --cdspeed option argument from 'eject --listspeed /dev/cdrom' output. Nowadays it is common not to have such device, and this results to an unwanted error message to stderr merely messing up command line. Lets stop that.

---
 bash-completion/eject | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
bash-completion/eject +1 -1
index 123829ea2..327ef1b71 100644
@@ -15,7 +15,7 @@ _eject_module()
 			return 0
 			;;
 		'-x'|'--cdspeed')
-			COMPREPLY=( $(compgen -W "$($1 -X)" -- $cur) )
+			COMPREPLY=( $(compgen -W "$(eject --listspeed 2>/dev/null)" -- $cur) )
 			return 0
 			;;
 		'-h'|'--help'|'-V'|'--version')
Signature · 1 line
2.17.0
#3 lore raw

PATCH 3/4 bash-completion: setpriv --securebits argument can be comma separated list

In reply to Sami Kerola

Make the option argument suggestion to match with what is allowed. In same go tidy shell code a little bit.

---
 bash-completion/setpriv | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)
bash-completion/setpriv +17 -4
index bf4737a3a..1c67f8288 100644
@@ -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')
Signature · 1 line
2.17.0
#4 lore raw

PATCH 4/4 bash-completion: fix typo in blockdev file

In reply to Sami Kerola
---
 bash-completion/blockdev | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
bash-completion/blockdev +1 -1
index 8050c0f83..e7aca26de 100644
@@ -33,7 +33,7 @@ _blockdev_module()
 			COMPREPLY=( $(compgen -W "bytes" -- $cur) )
 			return 0
 			;;
-		'--setbsz'|'--setfra')
+		'--setra'|'--setfra')
 			COMPREPLY=( $(compgen -W "sectors" -- $cur) )
 			return 0
 			;;
Signature · 1 line
2.17.0
maintainer Applied
#5 lore raw
In reply to Sami Kerola
Quoted 11 lines · Sami Kerola
 bash-completion/blockdev |  2 +-
 bash-completion/chcpu    |  4 ++--
 bash-completion/eject    |  2 +-
 bash-completion/lsblk    | 10 +++++-----
 bash-completion/lscpu    |  2 +-
 bash-completion/lslogins |  2 +-
 bash-completion/lsns     |  2 +-
 bash-completion/mount    |  2 +-
 bash-completion/setpriv  | 23 ++++++++++++++++++-----
 bash-completion/taskset  |  2 +-
 10 files changed, 32 insertions(+), 19 deletions(-)

Applied, thanks.

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com