summaryrefslogtreecommitdiffstats
path: root/bash-completion
diff options
context:
space:
mode:
authorSami Kerola2014-10-26 23:07:09 +0100
committerKarel Zak2014-10-31 10:39:01 +0100
commite3da3b39b5deb72bcff51cc146334ff117588aac (patch)
treee25656766e777f30775016d319b42a69b337f4c9 /bash-completion
parentbash-completion: stop being clever when listing block devices (diff)
downloadkernel-qcow2-util-linux-e3da3b39b5deb72bcff51cc146334ff117588aac.tar.gz
kernel-qcow2-util-linux-e3da3b39b5deb72bcff51cc146334ff117588aac.tar.xz
kernel-qcow2-util-linux-e3da3b39b5deb72bcff51cc146334ff117588aac.zip
bash-completion: use swapon label and uuid listing support
Simplifies the script, and makes swapoff to work for files when get requests by label or uuid. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'bash-completion')
-rw-r--r--bash-completion/swapoff22
-rw-r--r--bash-completion/swapon2
2 files changed, 4 insertions, 20 deletions
diff --git a/bash-completion/swapoff b/bash-completion/swapoff
index 60d85724c..40dcf0569 100644
--- a/bash-completion/swapoff
+++ b/bash-completion/swapoff
@@ -9,25 +9,11 @@ _swapoff_module()
return 0
;;
'-U'|'UUID=')
- # only works for block devices, i.e., not for swap files.
- local SWAPS
- SWAPS="$(swapon --show=TYPE,NAME --raw --noheading | \
- awk '$1 !~ /file/ { print $2 }')"
- [ -z "$SWAPS" ] && return 0
- local UUIDS
- UUIDS="$(lsblk -nrp -o UUID "$SWAPS")"
- COMPREPLY=( $(compgen -W "$UUIDS" -- $cur) )
+ COMPREPLY=( $(compgen -W "$(swapon --show=UUID --noheading)" -- $cur) )
return 0
;;
'-L'|'LABEL=')
- # only works for block devices, i.e., not for swap files.
- local SWAPS
- SWAPS="$(swapon --show=TYPE,NAME --raw --noheading | \
- awk '$1 !~ /file/ { print $2 }')"
- [ -z "$SWAPS" ] && return 0
- local LABELS
- LABELS="$(lsblk -nrp -o LABEL "$SWAPS")"
- COMPREPLY=( $(compgen -W "$LABELS" -- $cur) )
+ COMPREPLY=( $(compgen -W "$(swapon --show=LABEL --noheading)" -- $cur) )
return 0
;;
'-h'|'--help'|'-V'|'--version')
@@ -46,9 +32,7 @@ _swapoff_module()
return 0
;;
esac
- local DEVS
- DEVS="$(swapon --show=NAME --raw --noheading)"
- COMPREPLY=( $(compgen -W "$DEVS" -- $cur) )
+ COMPREPLY=( $(compgen -W "$(swapon --show=NAME --raw --noheading)" -- $cur) )
return 0
}
complete -F _swapoff_module swapoff
diff --git a/bash-completion/swapon b/bash-completion/swapon
index 7656d4efd..f471e079c 100644
--- a/bash-completion/swapon
+++ b/bash-completion/swapon
@@ -14,7 +14,7 @@ _swapon_module()
'--show')
# FIXME: how to append to a string with compgen?
local OUTPUT
- OUTPUT="NAME TYPE SIZE USED PRIO"
+ OUTPUT="NAME TYPE SIZE USED PRIO UUID LABEL"
compopt -o nospace
COMPREPLY=( $(compgen -W "$OUTPUT" -S ',' -- $cur) )
return 0