From: Sami Kerola Date: Thu, 10 May 2018 20:02:00 +0000 (+0100) Subject: bash-completion: add swapon specifiers to completion X-Git-Tag: v2.33-rc1~239 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=faa44b6d9aa1449db5f1161930a1d914566b6f61;p=thirdparty%2Futil-linux.git bash-completion: add swapon specifiers to completion No space after device name is not entirely right, but that's better than missing argument completions. Signed-off-by: Sami Kerola --- diff --git a/bash-completion/swapon b/bash-completion/swapon index f5136efd31..a6b6f09211 100644 --- a/bash-completion/swapon +++ b/bash-completion/swapon @@ -25,18 +25,30 @@ _swapon_module() COMPREPLY=( $(compgen -P "$prefix" -W "$OUTPUT" -S ',' -- $realcur) ) return 0 ;; - '-U') + '-U'|'UUID=') local UUIDS UUIDS="$(lsblk -nrp -o FSTYPE,UUID | awk '$1 ~ /swap/ { print $2 }')" COMPREPLY=( $(compgen -W "$UUIDS" -- $cur) ) return 0 ;; - '-L') + '-L'|'LABEL=') local LABELS LABELS="$(lsblk -nrp -o FSTYPE,LABEL | awk '$1 ~ /swap/ { print $2 }')" COMPREPLY=( $(compgen -W "$LABELS" -- $cur) ) return 0 ;; + 'PARTUUID=') + local PARTUUIDS + PARTUUIDS="$(lsblk -nrp -o FSTYPE,PARTUUID | awk '$1 ~ /swap/ { print $2 }')" + COMPREPLY=( $(compgen -W "$PARTUUIDS" -- $cur) ) + return 0 + ;; + 'PARTLABEL=') + local PARTLABELS + PARTLABELS="$(lsblk -nrp -o FSTYPE,PARTLABEL | awk '$1 ~ /swap/ { print $2 }')" + COMPREPLY=( $(compgen -W "$PARTLABELS" -- $cur) ) + return 0 + ;; '-h'|'--help'|'-V'|'--version') return 0 ;; @@ -55,6 +67,8 @@ _swapon_module() --raw --bytes --verbose + -L + -U --help --version" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) @@ -63,7 +77,8 @@ _swapon_module() esac local DEVS DEVS="$(lsblk -nrp -o FSTYPE,NAME | awk '$1 ~ /swap/ { print $2 }')" - COMPREPLY=( $(compgen -W "$DEVS" -- $cur) ) + compopt -o nospace + COMPREPLY=( $(compgen -fW "$DEVS LABEL= UUID= PARTLABEL= PARTUUID=" -- $cur) ) return 0 } complete -F _swapon_module swapon