public inbox for util-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: Sami Kerola <kerolasa@iki.fi>
To: util-linux@vger.kernel.org
Cc: kerolasa@iki.fi
Subject: [PATCH 03/14] bash-completion: swapon: add options and fix argument
Date: Mon,  8 Apr 2013 20:32:48 +0100	[thread overview]
Message-ID: <1365449579-13238-4-git-send-email-kerolasa@iki.fi> (raw)
In-Reply-To: <1365449579-13238-1-git-send-email-kerolasa@iki.fi>

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>
---
 bash-completion/swapon | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/bash-completion/swapon b/bash-completion/swapon
index e127153..7656d4e 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
-- 
1.8.2.1


  parent reply	other threads:[~2013-04-08 19:33 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-08 19:32 [PATCH 00/14] [pull] smatch scan, and manual tooling Sami Kerola
2013-04-08 19:32 ` [PATCH 01/14] setarch: clean up usage() Sami Kerola
2013-04-08 19:32 ` [PATCH 02/14] bash-completion: setarch: use correct list for architectures Sami Kerola
2013-04-08 19:32 ` Sami Kerola [this message]
2013-04-08 19:32 ` [PATCH 04/14] various: fix variable and function declarations [smatch scan] Sami Kerola
2013-04-08 19:32 ` [PATCH 05/14] various: fix shadow " Sami Kerola
2013-04-08 19:32 ` [PATCH 06/14] libmount, col: remove redundant null checks " Sami Kerola
2013-04-08 19:32 ` [PATCH 07/14] libblkid: number of functions should not be declared extern " Sami Kerola
2013-04-08 19:32 ` [PATCH 08/14] tools: add checks to manual page test script Sami Kerola
2013-04-08 19:32 ` [PATCH 09/14] docs: mount.8: make propagation flags adjustable [checkmans.sh] Sami Kerola
2013-04-08 19:32 ` [PATCH 10/14] docs: col.1: fix manual page name section [checkmans.sh] Sami Kerola
2013-04-08 19:32 ` [PATCH 11/14] docs: remove repeated words [checkmans.sh] Sami Kerola
2013-04-08 19:32 ` [PATCH 12/14] tools: make checkmans.sh to find missing manuals Sami Kerola
2013-04-08 19:32 ` [PATCH 13/14] docs: add mkfs.cramfs manual page Sami Kerola
2013-04-08 19:32 ` [PATCH 14/14] docs: add fsck.cramfs " Sami Kerola
2013-04-09 10:30 ` [PATCH 00/14] [pull] smatch scan, and manual tooling Karel Zak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1365449579-13238-4-git-send-email-kerolasa@iki.fi \
    --to=kerolasa@iki.fi \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox