summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSami Kerola2013-04-08 21:32:48 +0200
committerKarel Zak2013-04-09 12:17:15 +0200
commita6f5836264e82b2b9421b671bac6bc7fd841b02d (patch)
tree0b67ba9ee97133c8d878f71105e3874fd39b5e2a
parentbash-completion: setarch: use correct list for architectures (diff)
downloadkernel-qcow2-util-linux-a6f5836264e82b2b9421b671bac6bc7fd841b02d.tar.gz
kernel-qcow2-util-linux-a6f5836264e82b2b9421b671bac6bc7fd841b02d.tar.xz
kernel-qcow2-util-linux-a6f5836264e82b2b9421b671bac6bc7fd841b02d.zip
bash-completion: swapon: add options and fix argument
The initial bash-completion missed swapon options -L and -U. Use of block device was proposed to be more appropriate than a path to a file. Requested-by: Karel Zak <kzak@redhat.com> References: http://marc.info/?l=util-linux-ng&m=136517310727426&w=2 Signed-off-by: Sami Kerola <kerolasa@iki.fi>
-rw-r--r--bash-completion/swapon19
1 files changed, 15 insertions, 4 deletions
diff --git a/bash-completion/swapon b/bash-completion/swapon
index e1271539b..7656d4efd 100644
--- a/bash-completion/swapon
+++ b/bash-completion/swapon
@@ -19,6 +19,18 @@ _swapon_module()
COMPREPLY=( $(compgen -W "$OUTPUT" -S ',' -- $cur) )
return 0
;;
+ '-U')
+ local UUIDS
+ UUIDS="$(lsblk -nrp -o FSTYPE,UUID | awk '$1 ~ /swap/ { print $2 }')"
+ COMPREPLY=( $(compgen -W "$UUIDS" -- $cur) )
+ return 0
+ ;;
+ '-L')
+ local LABELS
+ LABELS="$(lsblk -nrp -o FSTYPE,LABEL | awk '$1 ~ /swap/ { print $2 }')"
+ COMPREPLY=( $(compgen -W "$LABELS" -- $cur) )
+ return 0
+ ;;
'-h'|'--help'|'-V'|'--version')
return 0
;;
@@ -42,10 +54,9 @@ _swapon_module()
return 0
;;
esac
- # FIXME: compgen will split SPEC= from '=' point. The append
- # comma separated value problem is very similar.
- compopt -o filenames
- COMPREPLY=( $(compgen -f -- $cur) )
+ local DEVS
+ DEVS="$(lsblk -nrp -o FSTYPE,NAME | awk '$1 ~ /swap/ { print $2 }')"
+ COMPREPLY=( $(compgen -W "$DEVS" -- $cur) )
return 0
}
complete -F _swapon_module swapon