public inbox for util-linux@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/10] [pull] bash-completion
@ 2013-03-27 22:07 Sami Kerola
  2013-03-27 22:07 ` [PATCH 01/10] bash-completion: add bash completetion configure option Sami Kerola
                   ` (12 more replies)
  0 siblings, 13 replies; 33+ messages in thread
From: Sami Kerola @ 2013-03-27 22:07 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Hello,

Here is a pull request, which does two things; an introduction of bash
completetion to util-linux, and most FIXME items ever sent to review in
single batch (26).

Most of the brokenness in this batch series has got to do with a comma
separate value list, e.g., 'value1,another,foobar', which one would
expect to continue filling with 'value1,<tab>' but that does not work.  I
am almost sure that one might achieve continue the list by setting comma
to COMP_WORDBREAKS, and check if $prev is in known words list, but I
simply did not get that to work (I suspect PEBKAC).

Some FIXME's are slightly more difficult to fix.  For example I do not
know how to get list of possible TERM values distribution agnostic way. 
And with 'wdctl' I have no how to determine flags.  Same goes for SELinux
labels & Apparmor provilles for setpriv.  Anyhow, if someone wants to
help, give hints, or even directly fix something feel free to reply the
later patches what could be done to an instance of a problem.

Of course any other sort of feedback is also welcome.


The following changes since commit 4cd271adc1dd3231e705c9e074491a7f49a721b8:

  libmount: make mnt_table_find_* more robust [coverity scan] (2013-03-27 16:47:46 +0100)

are available in the git repository at:

  git://github.com/kerolasa/lelux-utiliteetit.git shell-completion

for you to fetch changes up to e8b90f9baffd36a95bab408a3859b04543577a1b:

  bash-completion: add completion files to Makefile.am (2013-03-27 21:31:25 +0000)

----------------------------------------------------------------
Sami Kerola (10):
      bash-completion: add bash completetion configure option
      bash-completion: disk-utils
      bash-completion: fdisks
      bash-completion: login-utils
      bash-completion: misc-utils
      bash-completion: schedutils
      bash-completion: sys-utils
      bash-completion: term-utils
      bash-completion: text-utils
      bash-completion: add completion files to Makefile.am

 Documentation/TODO             |   6 -
 Makefile.am                    |   5 +
 configure.ac                   |  13 +++
 shell-completion/Makemodule.am | 260 +++++++++++++++++++++++++++++++++++++++++
 shell-completion/addpart       |  25 ++++
 shell-completion/agetty        |  70 +++++++++++
 shell-completion/blkdiscard    |  25 ++++
 shell-completion/blkid         |  62 ++++++++++
 shell-completion/blockdev      |  44 +++++++
 shell-completion/cal           |  15 +++
 shell-completion/cfdisk        |  31 +++++
 shell-completion/chcpu         |  44 +++++++
 shell-completion/chfn          |  31 +++++
 shell-completion/chrt          |  32 +++++
 shell-completion/chsh          |  23 ++++
 shell-completion/col           |  24 ++++
 shell-completion/colcrt        |  20 ++++
 shell-completion/colrm         |  23 ++++
 shell-completion/column        |  34 ++++++
 shell-completion/ctrlaltdel    |  11 ++
 shell-completion/cytune        |  37 ++++++
 shell-completion/delpart       |  19 +++
 shell-completion/dmesg         |  53 +++++++++
 shell-completion/eject         |  61 ++++++++++
 shell-completion/fallocate     |  24 ++++
 shell-completion/fdformat      |  11 ++
 shell-completion/fdisk         |  41 +++++++
 shell-completion/findmnt       | 114 ++++++++++++++++++
 shell-completion/flock         |  42 +++++++
 shell-completion/fsck          |  36 ++++++
 shell-completion/fsck.cramfs   |  18 +++
 shell-completion/fsck.minix    |  11 ++
 shell-completion/fsfreeze      |  18 +++
 shell-completion/fstrim        |  25 ++++
 shell-completion/getopt        |  34 ++++++
 shell-completion/hexdump       |  32 +++++
 shell-completion/hwclock       |  53 +++++++++
 shell-completion/ionice        |  34 ++++++
 shell-completion/ipcrm         |  52 +++++++++
 shell-completion/ipcs          |  30 +++++
 shell-completion/isosize       |  17 +++
 shell-completion/last          |  38 ++++++
 shell-completion/ldattach      |  54 +++++++++
 shell-completion/logger        |  43 +++++++
 shell-completion/login         |  27 +++++
 shell-completion/look          |  24 ++++
 shell-completion/losetup       |  64 ++++++++++
 shell-completion/lsblk         |  60 ++++++++++
 shell-completion/lscpu         |  39 +++++++
 shell-completion/lslocks       |  43 +++++++
 shell-completion/mcookie       |  23 ++++
 shell-completion/mesg          |  16 +++
 shell-completion/mkfs          |  25 ++++
 shell-completion/mkfs.bfs      |  28 +++++
 shell-completion/mkfs.cramfs   |  40 +++++++
 shell-completion/mkfs.minix    |  33 ++++++
 shell-completion/mkswap        |  36 ++++++
 shell-completion/more          |  22 ++++
 shell-completion/mountpoint    |  24 ++++
 shell-completion/namei         |  17 +++
 shell-completion/newgrp        |  16 +++
 shell-completion/nsenter       |  47 ++++++++
 shell-completion/partx         |  37 ++++++
 shell-completion/pg            |  29 +++++
 shell-completion/pivot_root    |  14 +++
 shell-completion/prlimit       |  55 +++++++++
 shell-completion/raw           |  17 +++
 shell-completion/readprofile   |  33 ++++++
 shell-completion/rename        |  27 +++++
 shell-completion/renice        |  38 ++++++
 shell-completion/resizepart    |  22 ++++
 shell-completion/rev           |  17 +++
 shell-completion/rtcwake       |  40 +++++++
 shell-completion/script        |  38 ++++++
 shell-completion/scriptreplay  |  28 +++++
 shell-completion/setarch       |  42 +++++++
 shell-completion/setpriv       |  82 +++++++++++++
 shell-completion/setsid        |  17 +++
 shell-completion/setterm       | 109 +++++++++++++++++
 shell-completion/sfdisk        |  72 ++++++++++++
 shell-completion/su            |  45 +++++++
 shell-completion/sulogin       |  24 ++++
 shell-completion/swaplabel     |  28 +++++
 shell-completion/swapon        |  48 ++++++++
 shell-completion/tailf         |  24 ++++
 shell-completion/taskset       |  38 ++++++
 shell-completion/tunelp        |  48 ++++++++
 shell-completion/ul            |  25 ++++
 shell-completion/unshare       |  24 ++++
 shell-completion/utmpdump      |  17 +++
 shell-completion/uuidd         |  33 ++++++
 shell-completion/uuidgen       |  15 +++
 shell-completion/wall          |  24 ++++
 shell-completion/wdctl         |  48 ++++++++
 shell-completion/whereis       |  24 ++++
 shell-completion/wipefs        |  38 ++++++
 shell-completion/write         |  19 +++
 97 files changed, 3512 insertions(+), 6 deletions(-)
 create mode 100644 shell-completion/Makemodule.am
 create mode 100644 shell-completion/addpart
 create mode 100644 shell-completion/agetty
 create mode 100644 shell-completion/blkdiscard
 create mode 100644 shell-completion/blkid
 create mode 100644 shell-completion/blockdev
 create mode 100644 shell-completion/cal
 create mode 100644 shell-completion/cfdisk
 create mode 100644 shell-completion/chcpu
 create mode 100644 shell-completion/chfn
 create mode 100644 shell-completion/chrt
 create mode 100644 shell-completion/chsh
 create mode 100644 shell-completion/col
 create mode 100644 shell-completion/colcrt
 create mode 100644 shell-completion/colrm
 create mode 100644 shell-completion/column
 create mode 100644 shell-completion/ctrlaltdel
 create mode 100644 shell-completion/cytune
 create mode 100644 shell-completion/delpart
 create mode 100644 shell-completion/dmesg
 create mode 100644 shell-completion/eject
 create mode 100644 shell-completion/fallocate
 create mode 100644 shell-completion/fdformat
 create mode 100644 shell-completion/fdisk
 create mode 100644 shell-completion/findmnt
 create mode 100644 shell-completion/flock
 create mode 100644 shell-completion/fsck
 create mode 100644 shell-completion/fsck.cramfs
 create mode 100644 shell-completion/fsck.minix
 create mode 100644 shell-completion/fsfreeze
 create mode 100644 shell-completion/fstrim
 create mode 100644 shell-completion/getopt
 create mode 100644 shell-completion/hexdump
 create mode 100644 shell-completion/hwclock
 create mode 100644 shell-completion/ionice
 create mode 100644 shell-completion/ipcrm
 create mode 100644 shell-completion/ipcs
 create mode 100644 shell-completion/isosize
 create mode 100644 shell-completion/last
 create mode 100644 shell-completion/ldattach
 create mode 100644 shell-completion/logger
 create mode 100644 shell-completion/login
 create mode 100644 shell-completion/look
 create mode 100644 shell-completion/losetup
 create mode 100644 shell-completion/lsblk
 create mode 100644 shell-completion/lscpu
 create mode 100644 shell-completion/lslocks
 create mode 100644 shell-completion/mcookie
 create mode 100644 shell-completion/mesg
 create mode 100644 shell-completion/mkfs
 create mode 100644 shell-completion/mkfs.bfs
 create mode 100644 shell-completion/mkfs.cramfs
 create mode 100644 shell-completion/mkfs.minix
 create mode 100644 shell-completion/mkswap
 create mode 100644 shell-completion/more
 create mode 100644 shell-completion/mountpoint
 create mode 100644 shell-completion/namei
 create mode 100644 shell-completion/newgrp
 create mode 100644 shell-completion/nsenter
 create mode 100644 shell-completion/partx
 create mode 100644 shell-completion/pg
 create mode 100644 shell-completion/pivot_root
 create mode 100644 shell-completion/prlimit
 create mode 100644 shell-completion/raw
 create mode 100644 shell-completion/readprofile
 create mode 100644 shell-completion/rename
 create mode 100644 shell-completion/renice
 create mode 100644 shell-completion/resizepart
 create mode 100644 shell-completion/rev
 create mode 100644 shell-completion/rtcwake
 create mode 100644 shell-completion/script
 create mode 100644 shell-completion/scriptreplay
 create mode 100644 shell-completion/setarch
 create mode 100644 shell-completion/setpriv
 create mode 100644 shell-completion/setsid
 create mode 100644 shell-completion/setterm
 create mode 100644 shell-completion/sfdisk
 create mode 100644 shell-completion/su
 create mode 100644 shell-completion/sulogin
 create mode 100644 shell-completion/swaplabel
 create mode 100644 shell-completion/swapon
 create mode 100644 shell-completion/tailf
 create mode 100644 shell-completion/taskset
 create mode 100644 shell-completion/tunelp
 create mode 100644 shell-completion/ul
 create mode 100644 shell-completion/unshare
 create mode 100644 shell-completion/utmpdump
 create mode 100644 shell-completion/uuidd
 create mode 100644 shell-completion/uuidgen
 create mode 100644 shell-completion/wall
 create mode 100644 shell-completion/wdctl
 create mode 100644 shell-completion/whereis
 create mode 100644 shell-completion/wipefs
 create mode 100644 shell-completion/write



^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 01/10] bash-completion: add bash completetion configure option
  2013-03-27 22:07 [PATCH 00/10] [pull] bash-completion Sami Kerola
@ 2013-03-27 22:07 ` Sami Kerola
  2013-03-28 11:22   ` Sami Kerola
  2013-03-27 22:07 ` [PATCH 02/10] bash-completion: disk-utils Sami Kerola
                   ` (11 subsequent siblings)
  12 siblings, 1 reply; 33+ messages in thread
From: Sami Kerola @ 2013-03-27 22:07 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 Makefile.am                    |  5 +++++
 configure.ac                   | 13 +++++++++++++
 shell-completion/Makemodule.am |  1 +
 3 files changed, 19 insertions(+)
 create mode 100644 shell-completion/Makemodule.am

diff --git a/Makefile.am b/Makefile.am
index 3afcad1..b963af9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -27,6 +27,8 @@ ul_libfdisk_incdir  = $(top_srcdir)/libfdisk/src
 
 pkgconfigdir = $(usrlib_execdir)/pkgconfig
 
+bashcompletiondir = @bashcompletiondir@
+
 dist_noinst_HEADERS =
 noinst_PROGRAMS =
 noinst_LTLIBRARIES =
@@ -87,6 +89,8 @@ include misc-utils/Makemodule.am
 include disk-utils/Makemodule.am
 include fdisks/Makemodule.am
 
+include shell-completion/Makemodule.am
+
 include tests/Makemodule.am
 
 #
@@ -158,6 +162,7 @@ checkdecl:
 ENABLE_ALL = --enable-static-programs --enable-most-builds
 DISTCHECK_CONFIGURE_FLAGS = --disable-use-tty-group \
 			    --disable-silent-rules $(ENABLE_ALL) \
+			    --with-bashcompletiondir=$$dc_install_base/$(bashcompletiondir) \
 			    --with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir)
 
 
diff --git a/configure.ac b/configure.ac
index 92a5a3b..cd4e826 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1342,6 +1342,18 @@ fi
 AM_CONDITIONAL(HAVE_SYSTEMD, [test -n "$with_systemdsystemunitdir" -a "x$with_systemdsystemunitdir" != "xno" ])
 
 
+AC_ARG_WITH([bashcompletiondir],
+  AS_HELP_STRING([--with-bashcompletiondir=DIR], [Bash completions directory]),
+  [],
+  [AS_IF([$($PKG_CONFIG --exists bash-completion)], [
+    with_bashcompletiondir=$($PKG_CONFIG --variable=completionsdir bash-completion)
+  ], [
+    with_bashcompletiondir=${datadir}/bash-completion/completions
+  ])
+])
+AC_SUBST([bashcompletiondir], [$with_bashcompletiondir])
+
+
 AC_ARG_ENABLE([pg-bell],
   AS_HELP_STRING([--disable-pg-bell], [let pg not ring the bell on invalid keys]),
   [], enable_pg_bell=yes
@@ -1463,6 +1475,7 @@ AC_MSG_RESULT([
 	suid cflags:       ${SUID_CFLAGS}
 	ldflags:           ${LDFLAGS}
 	suid ldflags:      ${SUID_LDFLAGS}
+	Bash completions dir: ${with_bashcompletiondir}
 
 	warnings:
 
diff --git a/shell-completion/Makemodule.am b/shell-completion/Makemodule.am
new file mode 100644
index 0000000..b784ec7
--- /dev/null
+++ b/shell-completion/Makemodule.am
@@ -0,0 +1 @@
+dist_bashcompletion_DATA =
-- 
1.8.2


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 02/10] bash-completion: disk-utils
  2013-03-27 22:07 [PATCH 00/10] [pull] bash-completion Sami Kerola
  2013-03-27 22:07 ` [PATCH 01/10] bash-completion: add bash completetion configure option Sami Kerola
@ 2013-03-27 22:07 ` Sami Kerola
  2013-03-28  1:42   ` Dave Reisner
  2013-03-28  9:54   ` Karel Zak
  2013-03-27 22:07 ` [PATCH 03/10] bash-completion: fdisks Sami Kerola
                   ` (10 subsequent siblings)
  12 siblings, 2 replies; 33+ messages in thread
From: Sami Kerola @ 2013-03-27 22:07 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 shell-completion/addpart     | 25 +++++++++++++++++++++++++
 shell-completion/blockdev    | 44 ++++++++++++++++++++++++++++++++++++++++++++
 shell-completion/delpart     | 19 +++++++++++++++++++
 shell-completion/fdformat    | 11 +++++++++++
 shell-completion/fsck        | 36 ++++++++++++++++++++++++++++++++++++
 shell-completion/fsck.cramfs | 18 ++++++++++++++++++
 shell-completion/fsck.minix  | 11 +++++++++++
 shell-completion/isosize     | 17 +++++++++++++++++
 shell-completion/mkfs        | 25 +++++++++++++++++++++++++
 shell-completion/mkfs.bfs    | 28 ++++++++++++++++++++++++++++
 shell-completion/mkfs.cramfs | 40 ++++++++++++++++++++++++++++++++++++++++
 shell-completion/mkfs.minix  | 33 +++++++++++++++++++++++++++++++++
 shell-completion/mkswap      | 36 ++++++++++++++++++++++++++++++++++++
 shell-completion/partx       | 37 +++++++++++++++++++++++++++++++++++++
 shell-completion/raw         | 17 +++++++++++++++++
 shell-completion/resizepart  | 22 ++++++++++++++++++++++
 shell-completion/swaplabel   | 28 ++++++++++++++++++++++++++++
 17 files changed, 447 insertions(+)
 create mode 100644 shell-completion/addpart
 create mode 100644 shell-completion/blockdev
 create mode 100644 shell-completion/delpart
 create mode 100644 shell-completion/fdformat
 create mode 100644 shell-completion/fsck
 create mode 100644 shell-completion/fsck.cramfs
 create mode 100644 shell-completion/fsck.minix
 create mode 100644 shell-completion/isosize
 create mode 100644 shell-completion/mkfs
 create mode 100644 shell-completion/mkfs.bfs
 create mode 100644 shell-completion/mkfs.cramfs
 create mode 100644 shell-completion/mkfs.minix
 create mode 100644 shell-completion/mkswap
 create mode 100644 shell-completion/partx
 create mode 100644 shell-completion/raw
 create mode 100644 shell-completion/resizepart
 create mode 100644 shell-completion/swaplabel

diff --git a/shell-completion/addpart b/shell-completion/addpart
new file mode 100644
index 0000000..07ebf5e
--- /dev/null
+++ b/shell-completion/addpart
@@ -0,0 +1,25 @@
+_addpart_module()
+{
+	local cur
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	case $COMP_CWORD in
+		1)
+			local DEVS
+			DEVS="$(lsblk -o NAME -n -r)"
+			OPTS="-h --help -V --version $DEVS"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			;;
+		2)
+			COMPREPLY=( $(compgen -W "$((1 + $(ls $prev?* 2>/dev/null | wc -l)))" -- $cur) )
+			;;
+		3)
+			COMPREPLY=( $(compgen -W "start" -- $cur) )
+			;;
+		4)
+			COMPREPLY=( $(compgen -W "length" -- $cur) )
+			;;
+	esac
+	return 0
+}
+complete -F _addpart_module addpart
diff --git a/shell-completion/blockdev b/shell-completion/blockdev
new file mode 100644
index 0000000..82ac6c1
--- /dev/null
+++ b/shell-completion/blockdev
@@ -0,0 +1,44 @@
+_blockdev_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	DEVS="$(lsblk -o NAME -n -r)"
+	OPTS="-h -V -q
+		--report
+		--getsz
+		--setro
+		--setrw
+		--getro
+		--getdiscardzeroes
+		--getss
+		--getpbsz
+		--getiomin
+		--getioopt
+		--getalignoff
+		--getmaxsect
+		--getbsz
+		--setbsz
+		--getsize64
+		--setra
+		--getra
+		--setfra
+		--getfra
+		--flushbufs
+		--rereadpt
+		$DEVS"
+	case $prev in
+		'--setbsz')
+			COMPREPLY=( $(compgen -W "bytes" -- $cur) )
+			return 0
+			;;
+		'--setbsz'|'--setfra')
+			COMPREPLY=( $(compgen -W "sectors" -- $cur) )
+			return 0
+			;;
+	esac
+	COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+	return 0
+}
+complete -F _blockdev_module blockdev
diff --git a/shell-completion/delpart b/shell-completion/delpart
new file mode 100644
index 0000000..849c018
--- /dev/null
+++ b/shell-completion/delpart
@@ -0,0 +1,19 @@
+_delpart_module()
+{
+	local cur OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	case $COMP_CWORD in
+		1)
+			local DEVS
+			DEVS="$(lsblk -o NAME,TYPE -n -r | awk '$2 ~ /disk/ {print "/dev/" $1}')"
+			OPTS="-h --help -V --version $DEVS"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			;;
+		2)
+			COMPREPLY=( $(compgen -W "$(cat /sys/block/${prev##*/}/*/partition 2>/dev/null)" -- $cur) )
+			;;
+	esac
+	return 0
+}
+complete -F _delpart_module delpart
diff --git a/shell-completion/fdformat b/shell-completion/fdformat
new file mode 100644
index 0000000..f7d6a8e
--- /dev/null
+++ b/shell-completion/fdformat
@@ -0,0 +1,11 @@
+_fdformat_module()
+{
+	local cur OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	DEVS=$(ls /dev/fd[0-9]* 2>/dev/null)
+	OPTS="-n --no-verify -h --help -V --version $DEVS"
+	COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+	return 0
+}
+complete -F _fdformat_module fdformat
diff --git a/shell-completion/fsck b/shell-completion/fsck
new file mode 100644
index 0000000..c3da5f5
--- /dev/null
+++ b/shell-completion/fsck
@@ -0,0 +1,36 @@
+_fsck_module()
+{
+	local cur prev OPTS DEVS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-b')
+			COMPREPLY=( $(compgen -W "superblock" -- $cur) )
+			return 0
+			;;
+		'-B')
+			COMPREPLY=( $(compgen -W "blocksize" -- $cur) )
+			return 0
+			;;
+		'-j')
+			COMPREPLY=( $(compgen -W "external_journal" -- $cur) )
+			return 0
+			;;
+		'-l'|'-L')
+			COMPREPLY=( $(compgen -W "bad_blocks_file" -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-p -n -y -c -f -v -b -B -j -l -L"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	DEVS="$(lsblk -o NAME -n -r | awk '{print "/dev/" $1}')"
+	COMPREPLY=( $(compgen -W "$DEVS" -- $cur) )
+	return 0
+}
+complete -F _fsck_module fsck
diff --git a/shell-completion/fsck.cramfs b/shell-completion/fsck.cramfs
new file mode 100644
index 0000000..410b084
--- /dev/null
+++ b/shell-completion/fsck.cramfs
@@ -0,0 +1,18 @@
+_fsck.cramfs_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	OPTS='-v --verbose -x --destination -h --help -V --version file'
+	case $prev in
+		'-x'|'--destination')
+			compopt -o filenames
+			COMPREPLY=( $(compgen -o dirnames -- ${cur:-"/"}) )
+			return 0
+			;;
+	esac
+	COMPREPLY=( $(compgen -W "${OPTS[*]}" -S ' ' -- $cur) )
+	return 0
+}
+complete -F _fsck.cramfs_module fsck.cramfs
diff --git a/shell-completion/fsck.minix b/shell-completion/fsck.minix
new file mode 100644
index 0000000..f01626a
--- /dev/null
+++ b/shell-completion/fsck.minix
@@ -0,0 +1,11 @@
+_fsck.minix_module()
+{
+	local cur OPTS DEVS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	DEVS="$(lsblk -o NAME -n -r | awk '{print "/dev/" $1}')"
+	OPTS="-l -a -r -v -s -m -f -V --version"
+	COMPREPLY=( $(compgen -W "${OPTS[*]} $DEVS" -- $cur) )
+	return 0
+}
+complete -F _fsck.minix_module fsck.minix
diff --git a/shell-completion/isosize b/shell-completion/isosize
new file mode 100644
index 0000000..2b4a499
--- /dev/null
+++ b/shell-completion/isosize
@@ -0,0 +1,17 @@
+_isosize_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	OPTS='-d --divisor -x --sectors -h --help -V --version'
+	case $prev in
+		'-d'|'--divisor')
+			COMPREPLY=( $(compgen -W "number" -- $cur) )
+			return 0
+			;;
+	esac
+	COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+	return 0
+}
+complete -F _isosize_module isosize
diff --git a/shell-completion/mkfs b/shell-completion/mkfs
new file mode 100644
index 0000000..ee6a26b
--- /dev/null
+++ b/shell-completion/mkfs
@@ -0,0 +1,25 @@
+_mkfs_module()
+{
+	local cur prev OPTS DEVS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-t'|'--type')
+			FSTYPES=$(for I in $(\ls /sbin/mkfs.* /usr/sbin/mkfs.* 2>/dev/null); do echo ${I##*mkfs.}; done)
+			COMPREPLY=( $(compgen -W "$FSTYPES" -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS='-t --type --verbose -h --help -V --version'
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	DEVS="$(lsblk -o NAME -n -r | awk '{print "/dev/" $1}')"
+	COMPREPLY=( $(compgen -W "$DEVS /path/to/file" -- $cur) )
+	return 0
+}
+complete -F _mkfs_module mkfs
diff --git a/shell-completion/mkfs.bfs b/shell-completion/mkfs.bfs
new file mode 100644
index 0000000..b1a226a
--- /dev/null
+++ b/shell-completion/mkfs.bfs
@@ -0,0 +1,28 @@
+_bfs_module()
+{
+	local cur prev OPTS DEVS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-N'|'--inodes')
+			COMPREPLY=( $(compgen -W "number" -- $cur) )
+			return 0
+			;;
+		'-V'|'--vname'|'-F'|'--fname')
+			COMPREPLY=( $(compgen -W "name" -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS='-N --inodes --vname --fname -v --verbose -h --help -V --version'
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	DEVS="$(lsblk -o NAME -n -r | awk '{print "/dev/" $1}')"
+	COMPREPLY=( $(compgen -W "$DEVS /path/to/file" -- $cur) )
+	return 0
+}
+complete -F _bfs_module bfs
diff --git a/shell-completion/mkfs.cramfs b/shell-completion/mkfs.cramfs
new file mode 100644
index 0000000..65ee988
--- /dev/null
+++ b/shell-completion/mkfs.cramfs
@@ -0,0 +1,40 @@
+_mkfs.cramfs_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-b')
+			COMPREPLY=( $(compgen -W "blksize" -- $cur) )
+			return 0
+			;;
+		'-e')
+			COMPREPLY=( $(compgen -W "edition" -- $cur) )
+			return 0
+			;;
+		'-N')
+			COMPREPLY=( $(compgen -W "big little host" -- $cur) )
+			return 0
+			;;
+		'-i')
+			COMPREPLY=( $(compgen -f -- $cur) )
+			return 0
+			;;
+		'-n')
+			COMPREPLY=( $(compgen -W "name" -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-h -v -E -b -e -N -i -n -p -s -z"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	compopt -o filenames
+	COMPREPLY=( $(compgen -f -- $cur) )
+	return 0
+}
+complete -F _mkfs.cramfs_module mkfs.cramfs
diff --git a/shell-completion/mkfs.minix b/shell-completion/mkfs.minix
new file mode 100644
index 0000000..c717b3c
--- /dev/null
+++ b/shell-completion/mkfs.minix
@@ -0,0 +1,33 @@
+_mkfs.minix_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-i')
+			COMPREPLY=( $(compgen -W "inodes" -- $cur) )
+			return 0
+			;;
+		'-l')
+			COMPREPLY=( $(compgen -W "badblocks-file" -- $cur) )
+			return 0
+			;;
+		'-n')
+			COMPREPLY=( $(compgen -W "14 30" -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-c -i -l -n -1 -2 -3"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	local DEVS
+	DEVS="$(lsblk -o NAME -n -r | awk '{print "/dev/" $1}')"
+	COMPREPLY=( $(compgen -W "$DEVS" -- $cur) )
+	return 0
+}
+complete -F _mkfs.minix_module mkfs.minix
diff --git a/shell-completion/mkswap b/shell-completion/mkswap
new file mode 100644
index 0000000..c847aa9
--- /dev/null
+++ b/shell-completion/mkswap
@@ -0,0 +1,36 @@
+_mkswap_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-p'|'--pagesize')
+			COMPREPLY=( $(compgen -W "bytes" -- $cur) )
+			return 0
+			;;
+		'-L'|'--label')
+			COMPREPLY=( $(compgen -W "label" -- $cur) )
+			return 0
+			;;
+		'-v'|'--swapversion')
+			COMPREPLY=( $(compgen -W "1" -- $cur) )
+			return 0
+			;;
+		'-U'|--uuid)
+			COMPREPLY=( $(compgen -W "$(lsblk -n --output uuid)" -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-c --check -f --force -p --pagesize -L  --label -v --swapversion -U --uuid -V --version -h --help"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	compopt -o filenames
+	COMPREPLY=( $(compgen -f -- $cur) )
+	return 0
+}
+complete -F _mkswap_module mkswap
diff --git a/shell-completion/partx b/shell-completion/partx
new file mode 100644
index 0000000..c558d36
--- /dev/null
+++ b/shell-completion/partx
@@ -0,0 +1,37 @@
+_partx_module()
+{
+	local cur prev OPTS OUTPUT
+	COMPREPLY=()
+	OUTPUT="NR START END SECTORS SIZE NAME UUID TYPE FLAGS SCHEME"
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-n'|'--nr')
+			COMPREPLY=( $(compgen -W "$(lsblk -o NAME,TYPE -n -r | awk '$2 ~ /part/ {print "/dev/" $1}')" -- $cur) )
+			return 0
+			;;
+		'-o'|'--output')
+			# FIXME: how to append to a string with compgen?
+			compopt -o nospace
+			COMPREPLY=( $(compgen -W "$OUTPUT" -S ',' -- $cur) )
+			return 0
+			;;
+		'-t'|'--type')
+			# FIXME: some command should list type libblkid knows.
+			COMPREPLY=( $(compgen -W "aix bsd dos gpt mac minix sgi solaris_x86 sun ultrix unixware" -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-a --add -d --delete -s --show -u --update -b --bytes -g --noheadings -n --nr -o --output -P --pairs -r --raw -t --type -v --verbose -h --help -V --version"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	local DEVS
+	DEVS="$(sblk -o NAME,TYPE -n -r | awk '$2 ~ /disk/ {print "/dev/" $1}')"
+	COMPREPLY=( $(compgen -W "$DEVS" -- $cur) )
+	return 0
+}
+complete -F _partx_module partx
diff --git a/shell-completion/raw b/shell-completion/raw
new file mode 100644
index 0000000..41e03f2
--- /dev/null
+++ b/shell-completion/raw
@@ -0,0 +1,17 @@
+_raw_module()
+{
+	local cur
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	case $cur in
+		-*)
+			local OPTS
+			OPTS="-q --query -a --all -h --help -V --version"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	COMPREPLY=( $(compgen -W "$(ls 2>/dev/null /dev/raw/*)" -- $cur) )
+	return 0
+}
+complete -F _raw_module raw
diff --git a/shell-completion/resizepart b/shell-completion/resizepart
new file mode 100644
index 0000000..827638a
--- /dev/null
+++ b/shell-completion/resizepart
@@ -0,0 +1,22 @@
+_resizepart_module()
+{
+	local cur OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	case $COMP_CWORD in
+		1)
+			local DEVS
+			DEVS="$(lsblk -o NAME,TYPE -n -r | awk '$2 ~ /disk/ {print "/dev/" $1}')"
+			OPTS="-h --help -V --version $DEVS"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			;;
+		2)
+			COMPREPLY=( $(compgen -W "$(cat /sys/block/${prev##*/}/*/partition 2>/dev/null)" -- $cur) )
+			;;
+		3)
+			COMPREPLY="length"
+			;;
+	esac
+	return 0
+}
+complete -F _resizepart_module resizepart
diff --git a/shell-completion/swaplabel b/shell-completion/swaplabel
new file mode 100644
index 0000000..c857d15
--- /dev/null
+++ b/shell-completion/swaplabel
@@ -0,0 +1,28 @@
+_swaplabel_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-L'|'--label')
+			COMPREPLY=( $(compgen -W "label" -- $cur) )
+			return 0
+			;;
+		'-U'|'--uuid')
+			COMPREPLY=( $(compgen -W '$(uuidgen)' -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-L --label -U --uuid -h --help -V --version"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	compopt -o filenames
+	COMPREPLY=( $(compgen -f -- $cur) )
+	return 0
+}
+complete -F _swaplabel_module swaplabel
-- 
1.8.2


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 03/10] bash-completion: fdisks
  2013-03-27 22:07 [PATCH 00/10] [pull] bash-completion Sami Kerola
  2013-03-27 22:07 ` [PATCH 01/10] bash-completion: add bash completetion configure option Sami Kerola
  2013-03-27 22:07 ` [PATCH 02/10] bash-completion: disk-utils Sami Kerola
@ 2013-03-27 22:07 ` Sami Kerola
  2013-03-28 10:01   ` Karel Zak
  2013-03-27 22:07 ` [PATCH 04/10] bash-completion: login-utils Sami Kerola
                   ` (9 subsequent siblings)
  12 siblings, 1 reply; 33+ messages in thread
From: Sami Kerola @ 2013-03-27 22:07 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 shell-completion/cfdisk | 31 +++++++++++++++++++++
 shell-completion/fdisk  | 41 ++++++++++++++++++++++++++++
 shell-completion/sfdisk | 72 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 144 insertions(+)
 create mode 100644 shell-completion/cfdisk
 create mode 100644 shell-completion/fdisk
 create mode 100644 shell-completion/sfdisk

diff --git a/shell-completion/cfdisk b/shell-completion/cfdisk
new file mode 100644
index 0000000..8da32fd
--- /dev/null
+++ b/shell-completion/cfdisk
@@ -0,0 +1,31 @@
+_cfdisk_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-c')
+			COMPREPLY=( $(compgen -W "cylinders" -- $cur) )
+			return 0
+			;;
+		'-h')
+			COMPREPLY=( $(compgen -W "heads" -- $cur) )
+			return 0
+			;;
+		'-s')
+			COMPREPLY=( $(compgen -W "sectors" -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-a -z -c -h -s"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	COMPREPLY=( $(compgen -W "$(lsblk -o NAME,TYPE -n -r | awk '$2 ~ /disk/ {print "/dev/" $1}')" -- $cur) )
+	return 0
+}
+complete -F _cfdisk_module cfdisk
diff --git a/shell-completion/fdisk b/shell-completion/fdisk
new file mode 100644
index 0000000..ccf2015
--- /dev/null
+++ b/shell-completion/fdisk
@@ -0,0 +1,41 @@
+_fdisk_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-s')
+			local PARTITIONS
+			PARTITIONS="$(for I in /sys/block/*/*/partition; do IFS='/'; DIR_ARR=($I); echo "/dev/${DIR_ARR[4]}"; done)"
+			COMPREPLY=( $(compgen -W "$PARTITIONS" -- $cur) )
+			return 0
+			;;
+		'-b')
+			COMPREPLY=( $(compgen -W "512 1024 2048 4096" -- $cur) )
+			return 0
+			;;
+		'-c')
+			COMPREPLY=( $(compgen -W "dos nondos" -- $cur) )
+			return 0
+			;;
+		'-u')
+			COMPREPLY=( $(compgen -W "cylinders sectors" -- $cur) )
+			return 0
+			;;
+		'-C'|'-H'|'-S')
+			COMPREPLY=( $(compgen -W "number" -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-l -s -b -c -h -u -v -C -H -S"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	COMPREPLY=( $(compgen -W "$(lsblk -o NAME,TYPE -n -r | awk '$2 ~ /disk/ {print "/dev/" $1}')" -- $cur) )
+	return 0
+}
+complete -F _fdisk_module fdisk
diff --git a/shell-completion/sfdisk b/shell-completion/sfdisk
new file mode 100644
index 0000000..041ce55
--- /dev/null
+++ b/shell-completion/sfdisk
@@ -0,0 +1,72 @@
+_sfdisk_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-u'|'--unit')
+			COMPREPLY=( $(compgen -W "S C B M" -- $cur) )
+			return 0
+			;;
+		'-n'|'-C'|'--cylinders'|'-H'|'--heads'|'-S'|'--sectors')
+			COMPREPLY=( $(compgen -W "number" -- $cur) )
+			return 0
+			;;
+		'-O'|'-I')
+			compopt -o filenames
+			COMPREPLY=( $(compgen -f -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-s --show-size
+				-c --id
+				--change-id
+				--print-id
+				-l --list
+				-d --dump
+				-i --increment
+				-u --unit
+				-1 --one-only
+				-T --list-types
+				-D --DOS
+				-E --DOS-extended
+				-R --re-read
+				-N
+				-n
+				-O
+				-I
+				-V --verify
+				-v --version
+				-h --help
+				-f --force
+				--no-reread
+				-q --quiet
+				-L --Linux
+				-g --show-geometry
+				-G --show-pt-geometry
+				-A --activate
+				-U --unhide
+				-x --show-extended
+				--leave-last
+				--IBM
+				--in-order
+				--not-in-order
+				--inside-outer
+				--not-inside-outer
+				--nested
+				--chained
+				--onesector
+				-C --cylinders
+				-H --heads
+				-S --sectors"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	COMPREPLY=( $(compgen -W "$(lsblk -o NAME,TYPE -n -r | awk '$2 ~ /disk/ {print "/dev/" $1}')" -- $cur) )
+	return 0
+}
+complete -F _sfdisk_module sfdisk
-- 
1.8.2


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 04/10] bash-completion: login-utils
  2013-03-27 22:07 [PATCH 00/10] [pull] bash-completion Sami Kerola
                   ` (2 preceding siblings ...)
  2013-03-27 22:07 ` [PATCH 03/10] bash-completion: fdisks Sami Kerola
@ 2013-03-27 22:07 ` Sami Kerola
  2013-03-28  1:42   ` Dave Reisner
  2013-03-28 10:05   ` Karel Zak
  2013-03-27 22:07 ` [PATCH 05/10] bash-completion: misc-utils Sami Kerola
                   ` (8 subsequent siblings)
  12 siblings, 2 replies; 33+ messages in thread
From: Sami Kerola @ 2013-03-27 22:07 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 shell-completion/chfn     | 31 +++++++++++++++++++++++++++++++
 shell-completion/chsh     | 23 +++++++++++++++++++++++
 shell-completion/last     | 38 ++++++++++++++++++++++++++++++++++++++
 shell-completion/login    | 27 +++++++++++++++++++++++++++
 shell-completion/newgrp   | 16 ++++++++++++++++
 shell-completion/su       | 45 +++++++++++++++++++++++++++++++++++++++++++++
 shell-completion/sulogin  | 24 ++++++++++++++++++++++++
 shell-completion/utmpdump | 17 +++++++++++++++++
 8 files changed, 221 insertions(+)
 create mode 100644 shell-completion/chfn
 create mode 100644 shell-completion/chsh
 create mode 100644 shell-completion/last
 create mode 100644 shell-completion/login
 create mode 100644 shell-completion/newgrp
 create mode 100644 shell-completion/su
 create mode 100644 shell-completion/sulogin
 create mode 100644 shell-completion/utmpdump

diff --git a/shell-completion/chfn b/shell-completion/chfn
new file mode 100644
index 0000000..1c5167a
--- /dev/null
+++ b/shell-completion/chfn
@@ -0,0 +1,31 @@
+_chfn_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-f'|'--full-name')
+			COMPREPLY=( $(compgen -W "name" -- $cur) )
+			return 0
+			;;
+		'-o'|'--office')
+			COMPREPLY=( $(compgen -W "office" -- $cur) )
+			return 0
+			;;
+		'-p'|'--office-phone'|'-h'|'--home-phone')
+			COMPREPLY=( $(compgen -W "phone-nr" -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-f --full-name -o --office -p --office-phone -h --home-phone -u --help -v --version"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	COMPREPLY=( $(compgen -u -- $cur) )
+	return 0
+}
+complete -F _chfn_module chfn
diff --git a/shell-completion/chsh b/shell-completion/chsh
new file mode 100644
index 0000000..c0a194c
--- /dev/null
+++ b/shell-completion/chsh
@@ -0,0 +1,23 @@
+_chsh_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-s'|'--shell')
+			COMPREPLY=( $(compgen -W "$(chsh -l)" -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-s --shell -l --list-shells -V --version -u --help"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	COMPREPLY=( $(compgen -u -- $cur) )
+	return 0
+}
+complete -F _chsh_module chsh
diff --git a/shell-completion/last b/shell-completion/last
new file mode 100644
index 0000000..493051e
--- /dev/null
+++ b/shell-completion/last
@@ -0,0 +1,38 @@
+_last_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-f')
+			compopt -o filenames
+			COMPREPLY=( $(compgen -f -- $cur) )
+			return 0
+			;;
+		'-h')
+			COMPREPLY=( $(compgen -A hostname -- $cur) )
+			return 0
+			;;
+		'-i')
+			COMPREPLY=( $(compgen -W "ipaddr" -- $cur) )
+			return 0
+			;;
+		'-t')
+			local TTYS
+			TTYS=$(cd /sys/devices/virtual/tty && echo *)
+			COMPREPLY=( $(compgen -W "$TTYS" -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-f -h -i -l -t -y"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	COMPREPLY=( $(compgen -u -- $cur) )
+	return 0
+}
+complete -F _last_module last
diff --git a/shell-completion/login b/shell-completion/login
new file mode 100644
index 0000000..c075f64
--- /dev/null
+++ b/shell-completion/login
@@ -0,0 +1,27 @@
+_login_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-f')
+			COMPREPLY=( $(compgen -u -- $cur) )
+			return 0
+			;;
+		'-h')
+			COMPREPLY=( $(compgen -A hostname -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-p -f -h -H -V"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	COMPREPLY=( $(compgen -u -- $cur) )
+	return 0
+}
+complete -F _login_module login
diff --git a/shell-completion/newgrp b/shell-completion/newgrp
new file mode 100644
index 0000000..567c08c
--- /dev/null
+++ b/shell-completion/newgrp
@@ -0,0 +1,16 @@
+_newgrp_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	case $cur in
+		-*)
+			OPTS="-V --version -h --help"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	COMPREPLY=( $(compgen -g -- $cur) )
+	return 0
+}
+complete -F _newgrp_module newgrp
diff --git a/shell-completion/su b/shell-completion/su
new file mode 100644
index 0000000..ded4b7b
--- /dev/null
+++ b/shell-completion/su
@@ -0,0 +1,45 @@
+_su_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-'|'-u'|'--user')
+			COMPREPLY=( $(compgen -u -- $cur) )
+			return 0
+			;;
+		'-g'|'--group'|'-G'|'--supp-group')
+			COMPREPLY=( $(compgen -g -- $cur) )
+			return 0
+			;;
+		'-s'|'--shell')
+			COMPREPLY=( $(compgen -W "$(chsh -l)" -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="	-u --user
+				-m -p --preserve-environment
+				-g --group
+				-G --supp-group
+				- -l --login
+				-c --command
+				- -c
+				--session-command
+				-- -c
+				-f --fast
+				-s --shell
+				-h --help
+				-V --version"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	compopt -o filenames
+	COMPREPLY=( $(compgen -f -- $cur) )
+	return 0
+}
+complete -F _su_module su
+complete -F _su_module runuser
diff --git a/shell-completion/sulogin b/shell-completion/sulogin
new file mode 100644
index 0000000..9fdc20e
--- /dev/null
+++ b/shell-completion/sulogin
@@ -0,0 +1,24 @@
+_sulogin_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-t'|'--timeout')
+			COMPREPLY=( $(compgen -W "seconds" -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-p --login-shell -t --timeout -V --version -h --help"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	compopt -o filenames
+	COMPREPLY=( $(compgen -f -- ${cur:-"/dev/tty"}) )
+	return 0
+}
+complete -F _sulogin_module sulogin
diff --git a/shell-completion/utmpdump b/shell-completion/utmpdump
new file mode 100644
index 0000000..e306ef8
--- /dev/null
+++ b/shell-completion/utmpdump
@@ -0,0 +1,17 @@
+_utmpdump_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	case $cur in
+		-*)
+			OPTS="-f --follow -r --reverse -V --version -h --help"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	compopt -o filenames
+	COMPREPLY=( $(compgen -f -- $cur) )
+	return 0
+}
+complete -F _utmpdump_module utmpdump
-- 
1.8.2


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 05/10] bash-completion: misc-utils
  2013-03-27 22:07 [PATCH 00/10] [pull] bash-completion Sami Kerola
                   ` (3 preceding siblings ...)
  2013-03-27 22:07 ` [PATCH 04/10] bash-completion: login-utils Sami Kerola
@ 2013-03-27 22:07 ` Sami Kerola
  2013-03-28  1:42   ` Dave Reisner
  2013-03-27 22:07 ` [PATCH 06/10] bash-completion: schedutils Sami Kerola
                   ` (7 subsequent siblings)
  12 siblings, 1 reply; 33+ messages in thread
From: Sami Kerola @ 2013-03-27 22:07 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 shell-completion/blkid   |  62 ++++++++++++++++++++++++++
 shell-completion/cal     |  15 +++++++
 shell-completion/findmnt | 114 +++++++++++++++++++++++++++++++++++++++++++++++
 shell-completion/getopt  |  34 ++++++++++++++
 shell-completion/logger  |  43 ++++++++++++++++++
 shell-completion/look    |  24 ++++++++++
 shell-completion/lsblk   |  60 +++++++++++++++++++++++++
 shell-completion/lslocks |  43 ++++++++++++++++++
 shell-completion/mcookie |  23 ++++++++++
 shell-completion/namei   |  17 +++++++
 shell-completion/rename  |  27 +++++++++++
 shell-completion/uuidd   |  33 ++++++++++++++
 shell-completion/uuidgen |  15 +++++++
 shell-completion/whereis |  24 ++++++++++
 shell-completion/wipefs  |  38 ++++++++++++++++
 15 files changed, 572 insertions(+)
 create mode 100644 shell-completion/blkid
 create mode 100644 shell-completion/cal
 create mode 100644 shell-completion/findmnt
 create mode 100644 shell-completion/getopt
 create mode 100644 shell-completion/logger
 create mode 100644 shell-completion/look
 create mode 100644 shell-completion/lsblk
 create mode 100644 shell-completion/lslocks
 create mode 100644 shell-completion/mcookie
 create mode 100644 shell-completion/namei
 create mode 100644 shell-completion/rename
 create mode 100644 shell-completion/uuidd
 create mode 100644 shell-completion/uuidgen
 create mode 100644 shell-completion/whereis
 create mode 100644 shell-completion/wipefs

diff --git a/shell-completion/blkid b/shell-completion/blkid
new file mode 100644
index 0000000..dce41e0
--- /dev/null
+++ b/shell-completion/blkid
@@ -0,0 +1,62 @@
+_blkid_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-c')
+			compopt -o filenames
+			COMPREPLY=( $(compgen -f -- $cur) )
+			return 0
+			;;
+		'-o')
+			COMPREPLY=( $(compgen -W "value device export full" -- $cur) )
+			return 0
+			;;
+		'-s')
+			COMPREPLY=( $(compgen -W "tag" -- $cur) )
+			return 0
+			;;
+		'-t')
+			COMPREPLY=( $(compgen -W "token" -- $cur) )
+			return 0
+			;;
+		'-L')
+			COMPREPLY=( $(compgen -W "$(\ls /dev/disk/by-label/ 2>/dev/null)" -- $cur) )
+			return 0
+			;;
+		'-U')
+			COMPREPLY=( $(compgen -W "$(\ls /dev/disk/by-uuid/ 2>/dev/null)" -- $cur) )
+			return 0
+			;;
+		'-s')
+			COMPREPLY=( $(compgen -W "size" -- $cur) )
+			return 0
+			;;
+		'-O')
+			COMPREPLY=( $(compgen -W "offset" -- $cur) )
+			return 0
+			;;
+		'-u')
+			COMPREPLY=( $(compgen -W "filesystem raid crypto other nofilesystem noraid nocrypto noother" -- $cur) )
+			return 0
+			;;
+		'-n')
+			COMPREPLY=( $(compgen -W "$(awk '{print $NF}' /proc/filesystems)" -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-c -d -h -g -o -k -s -t -l -L -U -V -p -i -S -O -u -n"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	local PARTITIONS
+	PARTITIONS="$(for I in /sys/block/*/*/partition; do IFS='/'; DIR_ARR=($I); echo "/dev/${DIR_ARR[4]}"; done)"
+	COMPREPLY=( $(compgen -W "$PARTITIONS" -- $cur) )
+	return 0
+}
+complete -F _blkid_module blkid
diff --git a/shell-completion/cal b/shell-completion/cal
new file mode 100644
index 0000000..d50c8bb
--- /dev/null
+++ b/shell-completion/cal
@@ -0,0 +1,15 @@
+_cal_module()
+{
+	local cur OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	case $cur in
+		-*)
+			OPTS="-1 --one -3 --three -s --sunday -m --monday -j --julian -y --year -V --version -h --help"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	return 0
+}
+complete -F _cal_module cal
diff --git a/shell-completion/findmnt b/shell-completion/findmnt
new file mode 100644
index 0000000..5207b97
--- /dev/null
+++ b/shell-completion/findmnt
@@ -0,0 +1,114 @@
+_findmnt_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-p'|'--poll')
+			COMPREPLY=( $(compgen -W "=list" -- $cur) )
+			return 0
+			;;
+		'-w'|'--timeout')
+			COMPREPLY=( $(compgen -W "timeout" -- $cur) )
+			return 0
+			;;
+		'-d'|'--direction')
+			COMPREPLY=( $(compgen -W "forward backward" -- $cur) )
+			return 0
+			;;
+		'-F'|'--tab-file')
+			compopt -o filenames
+			COMPREPLY=( $(compgen -f -- $cur) )
+			return 0
+			;;
+		'-N'|'--task')
+			local TID I
+			TID="$(for I in /proc/*/mountinfo; do IFS='/'; TID=($I); echo "${TID[2]}"; done)"
+			COMPREPLY=( $(compgen -W "$TID" -- $cur) )
+			return 0
+			;;
+		'-O'|'--options')
+			local MNT_OPTS
+			MNT_OPTS=$(awk '{ n = split($4, a, ","); for (i = 0; i <= n; i++) { mnt_opts[a[i]]=1 } } END { for (i in mnt_opts) { print i } }' /etc/mtab 2>/dev/null )
+			COMPREPLY=( $(compgen -W "$MNT_OPTS" -- $cur) )
+			return 0
+			;;
+		'-o'|'--output')
+			# FIXME: how to append to a string with compgen?
+			local OUTPUT
+			OUTPUT="SOURCE TARGET FSTYPE OPTIONS VFS-OPTIONS
+				FS-OPTIONS LABEL UUID PARTLABEL PARTUUID
+				MAJ\:MIN ACTION OLD-TARGET OLD-OPTIONS
+				SIZE AVAIL USED USE% FSROOT TID ID
+				OPT-FIELDS PROPAGATION FREQ PASSNO"
+			compopt -o nospace
+			COMPREPLY=( $(compgen -W "$OUTPUT" -S ',' -- $cur) )
+			return 0
+			;;
+		'-t'|'--types')
+			local TYPES
+			TYPES="adfs affs autofs cifs coda coherent cramfs
+				debugfs devpts efs ext ext2 ext3 ext4 hfs
+				hfsplus hpfs iso9660 jfs minix msdos
+				ncpfs nfs nfs4 ntfs proc qnx4 ramfs
+				reiserfs romfs squashfs smbfs sysv tmpfs
+				ubifs udf ufs umsdos usbfs vfat xenix xfs
+				xiafs"
+			COMPREPLY=( $(compgen -W "$TYPES" -- $cur) )
+			return 0
+			;;
+		'-S'|'--source')
+			local DEV_MPOINT
+			DEV_MPOINT=$(awk '{ print $1 }' /etc/mtab 2>/dev/null)
+			COMPREPLY=( $(compgen -W "$DEV_MPOINT" -- $cur) )
+			return 0
+			;;
+		'-T'|'--target')
+			local DEV_MPOINT
+			DEV_MPOINT=$(awk '{ print $2 }' /etc/mtab 2>/dev/null)
+			COMPREPLY=( $(compgen -W "$DEV_MPOINT" -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-s --fstab
+				-m --mtab
+				-k --kernel
+				-p --poll
+				-w --timeout
+				-A --all
+				-a --ascii
+				-c --canonicalize
+				-D --df
+				-d --direction
+				-e --evaluate
+				-F --tab-file
+				-f --first-only
+				-i --invert
+				-l --list
+				-N --task
+				-n --noheadings
+				-u --notruncate
+				-O --options
+				-o --output
+				-P --pairs
+				-r --raw
+				-t --types
+				-v --nofsroot
+				-R --submounts
+				-S --source
+				-T --target
+				-h --help
+				-V --version"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	local DEV_MPOINT
+	DEV_MPOINT=$(awk '{ print $1, $2 }' /etc/mtab 2>/dev/null)
+	COMPREPLY=( $(compgen -W "$DEV_MPOINT" -- $cur) )
+	return 0
+}
+complete -F _findmnt_module findmnt
diff --git a/shell-completion/getopt b/shell-completion/getopt
new file mode 100644
index 0000000..ea8c8e2
--- /dev/null
+++ b/shell-completion/getopt
@@ -0,0 +1,34 @@
+_getopt_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-l'|'--longoptions')
+			COMPREPLY=( $(compgen -W "longopts" -- $cur) )
+			return 0
+			;;
+		'-n'|'--name')
+			COMPREPLY=( $(compgen -W "name" -- $cur) )
+			return 0
+			;;
+		'-o'|'--options')
+			COMPREPLY=( $(compgen -W "optstring" -- $cur) )
+			return 0
+			;;
+		'-s'|'--shell')
+			COMPREPLY=( $(compgen -W "sh bash csh tcsh" -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-a --alternative -h --help -l --longoptions -n --name -o --options -q --quiet -Q --quiet-output -s --shell -T --test -u --unquote -V --version"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	return 0
+}
+complete -F _getopt_module getopt
diff --git a/shell-completion/logger b/shell-completion/logger
new file mode 100644
index 0000000..f572302
--- /dev/null
+++ b/shell-completion/logger
@@ -0,0 +1,43 @@
+_logger_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-f'|'--file')
+			compopt -o filenames
+			COMPREPLY=( $(compgen -f -- $cur) )
+			return 0
+			;;
+		'-n'|'--server')
+			COMPREPLY=( $(compgen -A hostname -- $cur) )
+			return 0
+			;;
+		'-P'|'--port')
+			COMPREPLY=( $(compgen -W "$(awk '$1 ~ /^syslog$/  {split($2, a, "/"); print a[1]}' /etc/services)" -- $cur) )
+			return 0
+			;;
+		'-p'|'--priority')
+			COMPREPLY=( $(compgen -W "$(echo {auth,authpriv,cron,daemon,ftp,lpr,mail,news,security}.{alert,crit,debug,emerg,err,error})" -- $cur) )
+			return 0
+			;;
+		'-t'|'--tag')
+			COMPREPLY=( $(compgen -W "tag" -- $cur) )
+			return 0
+			;;
+		'-u'|'--socket')
+			COMPREPLY=( $(compgen -W "$(awk '$NF ~ /^\// {print $NF}' /proc/net/unix)" -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-d --udp -i --id -f --file -h --help -n --server -P --port -p --priority -s --stderr -t --tag -u --socket -V --version"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	return 0
+}
+complete -F _logger_module logger
diff --git a/shell-completion/look b/shell-completion/look
new file mode 100644
index 0000000..68cea56
--- /dev/null
+++ b/shell-completion/look
@@ -0,0 +1,24 @@
+_look_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-t'|'--terminate')
+			COMPREPLY=( $(compgen -W "char" -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-a --alternative -d --alphanum -f --ignore-case -t --terminate -V --version -h --help"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	compopt -o filenames
+	COMPREPLY=( $(compgen -f -- $cur) )
+	return 0
+}
+complete -F _look_module look
diff --git a/shell-completion/lsblk b/shell-completion/lsblk
new file mode 100644
index 0000000..521cead
--- /dev/null
+++ b/shell-completion/lsblk
@@ -0,0 +1,60 @@
+_lsblk_module()
+{
+	local cur prev OPTS MAJOR
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-e'|'--exclude'|'-I'|'--include')
+			MAJOR=$(\ls /sys/dev/block/ | sed 's/:.*//')
+			# FIXME: how to append to a string with compgen?
+			compopt -o nospace
+			COMPREPLY=( $(compgen -W "$MAJOR" -S ',' -- $cur) )
+			return 0
+			;;
+		'-o'|'--output')
+			# FIXME: how to append to a string with compgen?
+			OUTPUT="NAME KNAME MAJ:MIN FSTYPE MOUNTPOINT
+				LABEL UUID PARTLABEL PARTUUID RA RO RM
+				MODEL SIZE STATE OWNER GROUP MODE
+				ALIGNMENT MIN-IO OPT-IO PHY-SEC LOG-SEC
+				ROTA SCHED RQ-SIZE TYPE DISC-ALN
+				DISC-GRAN DISC-MAX DISC-ZERO WSAME WWN
+				RAND PKNAME HCTL TRAN REV VENDOR"
+			compopt -o nospace
+			COMPREPLY=( $(compgen -W "$OUTPUT" -S ',' -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-a --all
+				-b --bytes
+				-d --nodeps
+				-D --discard
+				-e --exclude
+				-I --include
+				-f --fs
+				-h --help
+				-i --ascii
+				-m --perms
+				-l --list
+				-n --noheadings
+				-o --output
+				-P --pairs
+				-r --raw
+				-s --inverse
+				-t --topology
+				-S --scsi
+				-h --help
+				-V --version"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	local DEVS
+	DEVS="$(\ls -d /sys/class/block/* | sed 's|/sys/class/block/|/dev/|g')"
+	COMPREPLY=( $(compgen -W "$DEVS" -- $cur) )
+	return 0
+}
+complete -F _lsblk_module lsblk
diff --git a/shell-completion/lslocks b/shell-completion/lslocks
new file mode 100644
index 0000000..f55c17e
--- /dev/null
+++ b/shell-completion/lslocks
@@ -0,0 +1,43 @@
+_lslocks_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-p'|'--pid')
+			local PIDS
+			# /proc/locks can have 8 to 9 fields, see commit
+			# 55c0d16bab8cc84b72bf11cb2fdd8aa6205ac608
+			PIDS="$(awk '{print $(NF-3)}' /proc/locks)"
+			COMPREPLY=( $(compgen -W "$PIDS" -- $cur) )
+			return 0
+			;;
+		'-o'|'--output')
+			# FIXME: how to append to a string with compgen?
+			local OUTPUT
+			OUTPUT="COMMAND PID TYPE SIZE MODE M START END PATH BLOCKER"
+			compopt -o nospace
+			COMPREPLY=( $(compgen -W "$OUTPUT" -S ',' -- $cur) )
+			return 0
+			;;
+
+	esac
+	case $cur in
+		-*)
+			OPTS="-p --pid
+				-o --output
+				-n --noheadings
+				-r --raw
+				-u --notruncate
+				-h --help
+				-V --version"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	compopt -o filenames
+	COMPREPLY=( $(compgen -f -- $cur) )
+	return 0
+}
+complete -F _lslocks_module lslocks
diff --git a/shell-completion/mcookie b/shell-completion/mcookie
new file mode 100644
index 0000000..1c01a55
--- /dev/null
+++ b/shell-completion/mcookie
@@ -0,0 +1,23 @@
+_mcookie_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-f'|'--file')
+			compopt -o filenames
+			COMPREPLY=( $(compgen -f -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-f --file -v --verbose -V --version -h --help"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	return 0
+}
+complete -F _mcookie_module mcookie
diff --git a/shell-completion/namei b/shell-completion/namei
new file mode 100644
index 0000000..c44821c
--- /dev/null
+++ b/shell-completion/namei
@@ -0,0 +1,17 @@
+_namei_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	case $cur in
+		-*)
+			OPTS="-h --help -V --version -x --mountpoints -m --modes -o --owners -l --long -n --nosymlinks -v --vertical"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	compopt -o filenames
+	COMPREPLY=( $(compgen -f -- $cur) )
+	return 0
+}
+complete -F _namei_module namei
diff --git a/shell-completion/rename b/shell-completion/rename
new file mode 100644
index 0000000..0fe4cc6
--- /dev/null
+++ b/shell-completion/rename
@@ -0,0 +1,27 @@
+_rename_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	case $cur in
+		-*)
+			OPTS="-v --verbose -s --symlink  -h --help -V --version"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	case $COMP_CWORD in
+		1)
+			COMPREPLY=( $(compgen -W "expression" -- $cur) )
+			;;
+		2)
+			COMPREPLY=( $(compgen -W "replacement" -- $cur) )
+			;;
+		*)
+			compopt -o filenames
+			COMPREPLY=( $(compgen -f -- $cur) )
+			;;
+	esac
+	return 0
+}
+complete -F _rename_module rename
diff --git a/shell-completion/uuidd b/shell-completion/uuidd
new file mode 100644
index 0000000..23c1a49
--- /dev/null
+++ b/shell-completion/uuidd
@@ -0,0 +1,33 @@
+_uuidd_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-p'|'--pid'|'-s'|'--socket')
+			compopt -o filenames
+			COMPREPLY=( $(compgen -f -- $cur) )
+			return 0
+			;;
+		'-T'|'--timeout')
+			compopt -o filenames
+			COMPREPLY=( $(compgen -W "timeout" -- $cur) )
+			return 0
+			;;
+		'-n'|'--uuids')
+			compopt -o filenames
+			COMPREPLY=( $(compgen -W "number" -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-p --pid -s --socket -T --timeout -k --kill -r --random -t --time -n --uuids -P --no-pid -F --no-fork -S --socket-activation -d --debug -q --quiet -V --version -h --help"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	return 0
+}
+complete -F _uuidd_module uuidd
diff --git a/shell-completion/uuidgen b/shell-completion/uuidgen
new file mode 100644
index 0000000..d9edde9
--- /dev/null
+++ b/shell-completion/uuidgen
@@ -0,0 +1,15 @@
+_uuidgen_module()
+{
+	local cur OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	case $cur in
+		-*)
+			OPTS="-r --random -t --time -V --version -h --help"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	return 0
+}
+complete -F _uuidgen_module uuidgen
diff --git a/shell-completion/whereis b/shell-completion/whereis
new file mode 100644
index 0000000..96e4117
--- /dev/null
+++ b/shell-completion/whereis
@@ -0,0 +1,24 @@
+_whereis_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-B'|'-M'|'-S')
+			compopt -o filenames
+			COMPREPLY=( $(compgen -o dirnames -- ${cur:-"/"}) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-b -B -m -M -s -S -f -u -l"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	COMPREPLY=( $(compgen -W "file" -- $cur) )
+	return 0
+}
+complete -F _whereis_module whereis
diff --git a/shell-completion/wipefs b/shell-completion/wipefs
new file mode 100644
index 0000000..427f47b
--- /dev/null
+++ b/shell-completion/wipefs
@@ -0,0 +1,38 @@
+_wipefs_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-o'|'--offset')
+			COMPREPLY=( $(compgen -W "offset" -- $cur) )
+			return 0
+			;;
+		'-t'|'--types')
+			local TYPES
+			TYPES="adfs affs autofs cifs coda coherent cramfs
+				debugfs devpts efs ext ext2 ext3 ext4 hfs
+				hfsplus hpfs iso9660 jfs minix msdos
+				ncpfs nfs nfs4 ntfs proc qnx4 ramfs
+				reiserfs romfs squashfs smbfs sysv tmpfs
+				ubifs udf ufs umsdos usbfs vfat xenix xfs
+				xiafs"
+			COMPREPLY=( $(compgen -W "$TYPES" -- $cur) )
+			return 0
+			;;
+
+	esac
+	case $cur in
+		-*)
+			OPTS="-a --all -f --force -h --help -n --no-actn -o --offset -p --parsable -q --quiet -t --types -V --version"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	local DEVS
+	DEVS="$(\ls -d /sys/class/block/* | sed 's|/sys/class/block/|/dev/|g')"
+	COMPREPLY=( $(compgen -W "$DEVS" -- $cur) )
+	return 0
+}
+complete -F _wipefs_module wipefs
-- 
1.8.2


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 06/10] bash-completion: schedutils
  2013-03-27 22:07 [PATCH 00/10] [pull] bash-completion Sami Kerola
                   ` (4 preceding siblings ...)
  2013-03-27 22:07 ` [PATCH 05/10] bash-completion: misc-utils Sami Kerola
@ 2013-03-27 22:07 ` Sami Kerola
  2013-03-27 22:07 ` [PATCH 07/10] bash-completion: sys-utils Sami Kerola
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 33+ messages in thread
From: Sami Kerola @ 2013-03-27 22:07 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 shell-completion/chrt    | 32 ++++++++++++++++++++++++++++++++
 shell-completion/ionice  | 34 ++++++++++++++++++++++++++++++++++
 shell-completion/taskset | 38 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 104 insertions(+)
 create mode 100644 shell-completion/chrt
 create mode 100644 shell-completion/ionice
 create mode 100644 shell-completion/taskset

diff --git a/shell-completion/chrt b/shell-completion/chrt
new file mode 100644
index 0000000..08912c9
--- /dev/null
+++ b/shell-completion/chrt
@@ -0,0 +1,32 @@
+_chrt_module()
+{
+	local cur OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	# FIXME: -p is ambiguous, it takes either pid or priority as an
+	# argument depending on whether user wanted to get or set the
+	# values.  Perhaps the command interface should be reconsidered.
+	case $cur in
+		-*)
+			OPTS="-b --batch
+				-f --fifo
+				-i --idle
+				-o --other
+				-r --rr
+				-R --reset-on-fork
+				-a --all-tasks
+				-h --help
+				-m --max
+				-p --pid
+				-v --verbose
+				-V --version"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	local PIDS
+	PIDS=$(\ls -d /proc/[0-9]* | sed 's|/proc/||')
+	COMPREPLY=( $(compgen -W "$PIDS" -- $cur) )
+	return 0
+}
+complete -F _chrt_module chrt
diff --git a/shell-completion/ionice b/shell-completion/ionice
new file mode 100644
index 0000000..3087c4a
--- /dev/null
+++ b/shell-completion/ionice
@@ -0,0 +1,34 @@
+_ionice_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-c'|'--class')
+			COMPREPLY=( $(compgen -W "$(echo {0..3}) none realtime best-effort idle" -- $cur) )
+			return 0
+			;;
+		'-n'|'--classdata')
+			COMPREPLY=( $(compgen -W "$(echo {0..7})" -- $cur) )
+			return 0
+			;;
+		'-p'|'--pid')
+			local PIDS
+			PIDS=$(\ls -d /proc/[0-9]* | sed 's|/proc/||')
+			COMPREPLY=( $(compgen -W "$PIDS" -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-c --class -n --classdata -p --pid -t --ignore -V --version -h --help"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	compopt -o filenames
+	COMPREPLY=( $(compgen -f -- $cur) )
+	return 0
+}
+complete -F _ionice_module ionice
diff --git a/shell-completion/taskset b/shell-completion/taskset
new file mode 100644
index 0000000..81247cd
--- /dev/null
+++ b/shell-completion/taskset
@@ -0,0 +1,38 @@
+_taskset_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-c'|'--cpu-list')
+			local CPULIST
+			# FIXME: will propose only binding to a cpu.
+			# Maybe this should add comma, and continue?
+			CPULIST=$(sed 's/^/{/; s/-/../g; s/,/} {/g; s/$/}/' /sys/devices/system/cpu/online)
+			COMPREPLY=( $(compgen -W "$(eval echo $CPULIST)" -- $cur) )
+			return 0
+			;;
+		'-p'|'--pid')
+			local PIDS
+			# FIXME: the pid argument is ambiguous.  When
+			# setting an affinity the optarg has to be cpu
+			# mask.  The following is good only for getting
+			# affinity.
+			PIDS=$(\ls -d /proc/[0-9]* | sed 's|/proc/||')
+			COMPREPLY=( $(compgen -W "$PIDS" -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-a --all-tasks -p --pid -c --cpu-list -h --help -V --version"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	compopt -o bashdefault
+	COMPREPLY=( $(compgen -c -- $cur) )
+	return 0
+}
+complete -F _taskset_module taskset
-- 
1.8.2


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 07/10] bash-completion: sys-utils
  2013-03-27 22:07 [PATCH 00/10] [pull] bash-completion Sami Kerola
                   ` (5 preceding siblings ...)
  2013-03-27 22:07 ` [PATCH 06/10] bash-completion: schedutils Sami Kerola
@ 2013-03-27 22:07 ` Sami Kerola
  2013-03-29 16:33   ` Karel Zak
  2013-04-05 14:44   ` Karel Zak
  2013-03-27 22:07 ` [PATCH 08/10] bash-completion: term-utils Sami Kerola
                   ` (5 subsequent siblings)
  12 siblings, 2 replies; 33+ messages in thread
From: Sami Kerola @ 2013-03-27 22:07 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 shell-completion/blkdiscard  | 25 ++++++++++++++
 shell-completion/chcpu       | 44 ++++++++++++++++++++++++
 shell-completion/ctrlaltdel  | 11 ++++++
 shell-completion/cytune      | 37 ++++++++++++++++++++
 shell-completion/dmesg       | 53 ++++++++++++++++++++++++++++
 shell-completion/eject       | 61 ++++++++++++++++++++++++++++++++
 shell-completion/fallocate   | 24 +++++++++++++
 shell-completion/flock       | 42 +++++++++++++++++++++++
 shell-completion/fsfreeze    | 18 ++++++++++
 shell-completion/fstrim      | 25 ++++++++++++++
 shell-completion/hwclock     | 53 ++++++++++++++++++++++++++++
 shell-completion/ipcrm       | 52 ++++++++++++++++++++++++++++
 shell-completion/ipcs        | 30 ++++++++++++++++
 shell-completion/ldattach    | 54 +++++++++++++++++++++++++++++
 shell-completion/losetup     | 64 ++++++++++++++++++++++++++++++++++
 shell-completion/lscpu       | 39 +++++++++++++++++++++
 shell-completion/mountpoint  | 24 +++++++++++++
 shell-completion/nsenter     | 47 +++++++++++++++++++++++++
 shell-completion/pivot_root  | 14 ++++++++
 shell-completion/prlimit     | 55 +++++++++++++++++++++++++++++
 shell-completion/readprofile | 33 ++++++++++++++++++
 shell-completion/renice      | 38 ++++++++++++++++++++
 shell-completion/rtcwake     | 40 +++++++++++++++++++++
 shell-completion/setarch     | 42 +++++++++++++++++++++++
 shell-completion/setpriv     | 82 ++++++++++++++++++++++++++++++++++++++++++++
 shell-completion/setsid      | 17 +++++++++
 shell-completion/swapon      | 48 ++++++++++++++++++++++++++
 shell-completion/tunelp      | 48 ++++++++++++++++++++++++++
 shell-completion/unshare     | 24 +++++++++++++
 shell-completion/wdctl       | 48 ++++++++++++++++++++++++++
 30 files changed, 1192 insertions(+)
 create mode 100644 shell-completion/blkdiscard
 create mode 100644 shell-completion/chcpu
 create mode 100644 shell-completion/ctrlaltdel
 create mode 100644 shell-completion/cytune
 create mode 100644 shell-completion/dmesg
 create mode 100644 shell-completion/eject
 create mode 100644 shell-completion/fallocate
 create mode 100644 shell-completion/flock
 create mode 100644 shell-completion/fsfreeze
 create mode 100644 shell-completion/fstrim
 create mode 100644 shell-completion/hwclock
 create mode 100644 shell-completion/ipcrm
 create mode 100644 shell-completion/ipcs
 create mode 100644 shell-completion/ldattach
 create mode 100644 shell-completion/losetup
 create mode 100644 shell-completion/lscpu
 create mode 100644 shell-completion/mountpoint
 create mode 100644 shell-completion/nsenter
 create mode 100644 shell-completion/pivot_root
 create mode 100644 shell-completion/prlimit
 create mode 100644 shell-completion/readprofile
 create mode 100644 shell-completion/renice
 create mode 100644 shell-completion/rtcwake
 create mode 100644 shell-completion/setarch
 create mode 100644 shell-completion/setpriv
 create mode 100644 shell-completion/setsid
 create mode 100644 shell-completion/swapon
 create mode 100644 shell-completion/tunelp
 create mode 100644 shell-completion/unshare
 create mode 100644 shell-completion/wdctl

diff --git a/shell-completion/blkdiscard b/shell-completion/blkdiscard
new file mode 100644
index 0000000..e907a1b
--- /dev/null
+++ b/shell-completion/blkdiscard
@@ -0,0 +1,25 @@
+_blkdiscard_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-o'|'--offset'|'-l'|'--length')
+			COMPREPLY=( $(compgen -W "num" -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-o --offset -l --length -s --secure -v --verbose -h --help -V --version"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	local DEVS
+	DEVS="$(\ls -d /sys/class/block/* | sed 's|/sys/class/block/|/dev/|g')"
+	COMPREPLY=( $(compgen -W "$DEVS" -- $cur) )
+	return 0
+}
+complete -F _blkdiscard_module blkdiscard
diff --git a/shell-completion/chcpu b/shell-completion/chcpu
new file mode 100644
index 0000000..19386e2
--- /dev/null
+++ b/shell-completion/chcpu
@@ -0,0 +1,44 @@
+_chcpu_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-e'|'--enable')
+			local CPULIST
+			# FIXME: will propose only binding to a cpu.
+			# Maybe this should add comma, and continue?
+			CPULIST=$(sed 's/^/{/; s/-/../g; s/,/} {/g; s/$/}/' /sys/devices/system/cpu/offline)
+			COMPREPLY=( $(compgen -W "$(eval echo $CPULIST)" -- $cur) )
+			return 0
+			;;
+		'-d'|'--disable')
+			local CPULIST
+			# FIXME: will propose only binding to a cpu.
+			# Maybe this should add comma, and continue?
+			CPULIST=$(sed 's/^/{/; s/-/../g; s/,/} {/g; s/$/}/' /sys/devices/system/cpu/online)
+			COMPREPLY=( $(compgen -W "$(eval echo $CPULIST)" -- $cur) )
+			return 0
+			;;
+		'-c'|'--configure'|'-g'|'--deconfigure')
+			COMPREPLY=( $(compgen -W "cpu-list" -- $cur) )
+			return 0
+			;;
+		'-p'|'--dispatch')
+			COMPREPLY=( $(compgen -W "horizontal vertical" -- $cur) )
+			return 0
+			;;
+	esac
+	OPTS="-h --help
+		-e --enable
+		-d --disable
+		-c --configure
+		-g --deconfigure
+		-p --dispatch
+		-r --rescan
+		-V --version"
+	COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+	return 0
+}
+complete -F _chcpu_module chcpu
diff --git a/shell-completion/ctrlaltdel b/shell-completion/ctrlaltdel
new file mode 100644
index 0000000..e725752
--- /dev/null
+++ b/shell-completion/ctrlaltdel
@@ -0,0 +1,11 @@
+_ctrlaltdel_module()
+{
+	local cur
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	COMPREPLY=()
+	if [ $COMP_CWORD -eq 1 ]; then
+		COMPREPLY=( $(compgen -W "hard soft" -- $cur) )
+	fi
+	return 0
+}
+complete -F _ctrlaltdel_module ctrlaltdel
diff --git a/shell-completion/cytune b/shell-completion/cytune
new file mode 100644
index 0000000..9a90d34
--- /dev/null
+++ b/shell-completion/cytune
@@ -0,0 +1,37 @@
+_cytune_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-s'|'--set-threshold'|'-S'|'--set-default-threshold'|'-t'|'--set-flush'|'-T'|'--set-default-flush')
+			COMPREPLY=( $(compgen -W "num" -- $cur) )
+			return 0
+			;;
+		'-i'|'--interval')
+			COMPREPLY=( $(compgen -W "seconds" -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-s --set-threshold
+				-g --get-threshold
+				-S --set-default-threshold
+				-t --set-flush
+				-G --get-glush
+				-T --set-default-flush
+				-q --stats
+				-i --interval
+				-h --help
+				-V --version"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	compopt -o filenames
+	COMPREPLY=( $(compgen -f -- ${cur:-"/dev/tty"}) )
+	return 0
+}
+complete -F _cytune_module cytune
diff --git a/shell-completion/dmesg b/shell-completion/dmesg
new file mode 100644
index 0000000..18ee59f
--- /dev/null
+++ b/shell-completion/dmesg
@@ -0,0 +1,53 @@
+_dmesg_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-F'|'--file')
+			compopt -o filenames
+			COMPREPLY=( $(compgen -f -- $cur) )
+			return 0
+			;;
+		'-f'|'--facility')
+			COMPREPLY=( $(compgen -W "kern user mail daemon auth syslog lpr news" -- $cur) )
+			return 0
+			;;
+		'-l'|'--level'|'-n'|'--console-level')
+			COMPREPLY=( $(compgen -W "emerg alert crit err warn notice info debug" -- $cur) )
+			return 0
+			;;
+		'-s'|'--buffer-size')
+			COMPREPLY=( $(compgen -W "size" -- $cur) )
+			return 0
+			;;
+	esac
+	OPTS="-C --clear
+		-c --read-clear
+		-D --console-off
+		-d --show-delta
+		-e --reltime
+		-E --console-on
+		-F --file
+		-f --facility
+		-H --human
+		-k --kernel
+		-L --color
+		-l --level
+		-n --console-level
+		-P --nopager
+		-r --raw
+		-S --syslog
+		-s --buffer-size
+		-T --ctime
+		-t --notime
+		-u --userspace
+		-w --follow
+		-x --decode
+		-h --help
+		-V --version"
+	COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+	return 0
+}
+complete -F _dmesg_module dmesg
diff --git a/shell-completion/eject b/shell-completion/eject
new file mode 100644
index 0000000..b767e81
--- /dev/null
+++ b/shell-completion/eject
@@ -0,0 +1,61 @@
+_eject_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-a'|'--auto'|'-i'|'--manualeject')
+			COMPREPLY=( $(compgen -W "off on" -- $cur) )
+			return 0
+			;;
+		'-c'|'--changerslot')
+			# FIXME: there must be way to determine slots
+			COMPREPLY=( $(compgen -W "slot" -- $cur) )
+			return 0
+			;;
+		'-x'|'--cdspeed')
+			COMPREPLY=( $(compgen -W "$(eject -X)" -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-a --auto
+			-c --changerslot
+			-d --default
+			-f --floppy
+			-F --force
+			-i --manualeject
+			-m --no-unmount
+			-M --no-partitions-unmount
+			-n --noop
+			-p --proc
+			-q --tape
+			-r --cdrom
+			-s --scsi
+			-t --trayclose
+			-T --traytoggle
+			-v --verbose
+			-x --cdspeed
+			-X --listspeed
+			-h --help
+			-V --version"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	local DEVS
+	DEVS="$(for I in /sys/class/block/*/removable; do
+		if [ $(cat $I) -ne 0 ]; then
+			OLD_IFS=$IFS
+			IFS='/';
+			ARR=($I)
+			echo "/dev/${ARR[4]}"
+			IFS=$OLD_IFS
+		fi
+	done)"
+	COMPREPLY=( $(compgen -W "$DEVS" $cur) )
+	return 0
+}
+complete -F _eject_module eject
diff --git a/shell-completion/fallocate b/shell-completion/fallocate
new file mode 100644
index 0000000..132858c
--- /dev/null
+++ b/shell-completion/fallocate
@@ -0,0 +1,24 @@
+_fallocate_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-o'|'--offset'|'-l'|'--length')
+			COMPREPLY=( $(compgen -W "bytes" -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-n --keep-size -p --punch-hole -o --offset -l --length -h --help -V --version"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	compopt -o filenames
+	COMPREPLY=( $(compgen -f -- $cur) )
+	return 0
+}
+complete -F _fallocate_module fallocate
diff --git a/shell-completion/flock b/shell-completion/flock
new file mode 100644
index 0000000..cfa9b66
--- /dev/null
+++ b/shell-completion/flock
@@ -0,0 +1,42 @@
+_flock_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-w'|'--timeout')
+			COMPREPLY=( $(compgen -W "seconds" -- $cur) )
+			return 0
+			;;
+		'-E'|'--conflict-exit-code')
+			COMPREPLY=( $(compgen -W "$(echo {0..255})" -- $cur) )
+			return 0
+			;;
+		'-c'|'--command')
+			compopt -o bashdefault
+			COMPREPLY=( $(compgen -c -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-s --shared
+				-x --exclusive
+				-u --unlock
+				-n --nonblock
+				-w --timeout
+				-E --conflict-exit-code
+				-o --close
+				-c --command
+				-h --help
+				-V --version"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	compopt -o filenames
+	COMPREPLY=( $(compgen -f -- ${cur:-"/"}) )
+	return 0
+}
+complete -F _flock_module flock
diff --git a/shell-completion/fsfreeze b/shell-completion/fsfreeze
new file mode 100644
index 0000000..7933c15
--- /dev/null
+++ b/shell-completion/fsfreeze
@@ -0,0 +1,18 @@
+_fsfreeze_module()
+{
+	local cur OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	case $cur in
+		-*)
+			OPTS="-f --freeze -u --unfreeze -h --help -V --version"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	local MPOINT
+	MPOINT="$(findmnt -t ext2,ext3,ext4,reiserfs,jfs,xfs -o TARGET -n -r)"
+	COMPREPLY=( $(compgen -W "$MPOINT" -- $cur) )
+	return 0
+}
+complete -F _fsfreeze_module fsfreeze
diff --git a/shell-completion/fstrim b/shell-completion/fstrim
new file mode 100644
index 0000000..87cb050
--- /dev/null
+++ b/shell-completion/fstrim
@@ -0,0 +1,25 @@
+_fstrim_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-o'|'--offset'|'-l'|'--length'|'-m'|'--minimum')
+			COMPREPLY=( $(compgen -W "num" -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-o --offset -l --length -m --minimum -v --verbose -h --help -V --version"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	local MPOINTS
+	MPOINTS=$(awk '{if ($1 ~ /^\//){print $2}}' /etc/mtab 2>/dev/null)
+	COMPREPLY=( $(compgen -W "$MPOINTS" -- $cur) )
+	return 0
+}
+complete -F _fstrim_module fstrim
diff --git a/shell-completion/hwclock b/shell-completion/hwclock
new file mode 100644
index 0000000..855e885
--- /dev/null
+++ b/shell-completion/hwclock
@@ -0,0 +1,53 @@
+_hwclock_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-f'|'--rtc'|'--adjfile')
+			compopt -o filenames
+			COMPREPLY=( $(compgen -f -- $cur) )
+			return 0
+			;;
+		'--date')
+			COMPREPLY=( $(compgen -W "date" -- $cur) )
+			return 0
+			;;
+		'--epoch')
+			COMPREPLY=( $(compgen -W "year" -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-h --help
+				-r --show
+				   --set
+				-s --hctosys
+				-w --systohc
+				   --systz
+				   --adjust
+				-c --compare
+				   --getepoch
+				   --setepoch
+				   --predict
+				-V --version
+				-u --utc
+				   --localtime
+				-f --rtc
+				   --directisa
+				   --badyear
+				   --date
+				   --epoch
+				   --noadjfile
+				   --adjfile
+				   --test
+				-D --debug"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	return 0
+}
+complete -F _hwclock_module hwclock
diff --git a/shell-completion/ipcrm b/shell-completion/ipcrm
new file mode 100644
index 0000000..4b1024f
--- /dev/null
+++ b/shell-completion/ipcrm
@@ -0,0 +1,52 @@
+_ipcrm_module()
+{
+	local cur prev OPTS KEYIDS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-m'|'--shmem-id')
+			KEYIDS="$(ipcs -m | awk '{if (3 < NR) {print $2}}')"
+			COMPREPLY=( $(compgen -W "$KEYIDS" -- $cur) )
+			return 0
+			;;
+		'-M'|'--shmem-key')
+			KEYIDS="$(ipcs -m | awk '{if (3 < NR) {print $1}}')"
+			COMPREPLY=( $(compgen -W "$KEYIDS" -- $cur) )
+			return 0
+			;;
+		'-q'|'--queue-id')
+			KEYIDS="$(ipcs -q | awk '{if (3 < NR) {print $2}}')"
+			COMPREPLY=( $(compgen -W "$KEYIDS" -- $cur) )
+			return 0
+			;;
+		'-Q'|'--queue-key')
+			KEYIDS="$(ipcs -q | awk '{if (3 < NR) {print $1}}')"
+			COMPREPLY=( $(compgen -W "$KEYIDS" -- $cur) )
+			return 0
+			;;
+		'-s'|'--semaphore-id')
+			KEYIDS="$(ipcs -s | awk '{if (3 < NR) {print $2}}')"
+			COMPREPLY=( $(compgen -W "$KEYIDS" -- $cur) )
+			return 0
+			;;
+		'-S'|'--semaphore-key')
+			KEYIDS="$(ipcs -s | awk '{if (3 < NR) {print $1}}')"
+			COMPREPLY=( $(compgen -W "$KEYIDS" -- $cur) )
+			return 0
+			;;
+	esac
+	OPTS="	-m --shmem-id
+		-M --shmem-key
+		-q --queue-id
+		-Q --queue-key
+		-s --semaphore-id
+		-S --semaphore-key
+		-a --all
+		-v --verbose
+		-h --help
+		-V --version"
+	COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+	return 0
+}
+complete -F _ipcrm_module ipcrm
diff --git a/shell-completion/ipcs b/shell-completion/ipcs
new file mode 100644
index 0000000..51502bb
--- /dev/null
+++ b/shell-completion/ipcs
@@ -0,0 +1,30 @@
+_ipcs_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-i'|'--id')
+			COMPREPLY=( $(compgen -W "id" -- $cur) )
+			return 0
+			;;
+	esac
+	OPTS="-i --id
+		-h --help
+		-V --version
+		-m --shmems
+		-q --queues
+		-s --semaphores
+		-a --all
+		-t --time
+		-p --pid
+		-c --creator
+		-l --limits
+		-u --summary
+		   --human
+		-b --bytes"
+	COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+	return 0
+}
+complete -F _ipcs_module ipcs
diff --git a/shell-completion/ldattach b/shell-completion/ldattach
new file mode 100644
index 0000000..dc83dfc
--- /dev/null
+++ b/shell-completion/ldattach
@@ -0,0 +1,54 @@
+_ldattach_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-s'|'--speed')
+			COMPREPLY=( $(compgen -W "speed" -- $cur) )
+			return 0
+			;;
+		'-i'|'--iflag')
+			local IFLAGS
+			IFLAGS="BRKINT ICRNL IGNBRK IGNCR IGNPAR IMAXBEL
+				INLCR INPCK ISTRIP IUCLC IUTF8 IXANY
+				IXOFF IXON PARMRK
+				-BRKINT -ICRNL -IGNBRK -IGNCR -IGNPAR -IMAXBEL
+				-INLCR -INPCK -ISTRIP -IUCLC -IUTF8 -IXANY
+				-IXOFF -IXON -PARMRK"
+			COMPREPLY=( $(compgen -W "$IFLAGS" -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-d --debug
+				-s --speed
+				-7 --sevenbits
+				-8 --eightbits
+				-n --noparity
+				-e --evenparity
+				-o --oddparity
+				-1 --onestopbit
+				-2 --twostopbits
+				-i --iflag
+				-h --help
+				-V --version"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+		/*)
+			compopt -o filenames
+			COMPREPLY=( $(compgen -f -- $cur) )
+			return 0
+			;;
+	esac
+	local LDISC_DEVICE
+	LDISC_DEVICE="6PACK AX25 GIGASET GIGASET_M101 HCI HDLC IRDA M101
+			MOUSE PPP PPS R3964 SLIP STRIP SYNCPPP SYNC_PPP
+			TTY X25 /dev/"
+	COMPREPLY=( $(compgen -W "$LDISC_DEVICE" -- $cur) )
+	return 0
+}
+complete -F _ldattach_module ldattach
diff --git a/shell-completion/losetup b/shell-completion/losetup
new file mode 100644
index 0000000..b21f05d
--- /dev/null
+++ b/shell-completion/losetup
@@ -0,0 +1,64 @@
+_losetup_module()
+{
+	local cur prev OPTS ARG
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-d'|'--detach')
+			ARG="$(losetup --output NAME | awk '{if (1 < NR) {print}}')"
+			COMPREPLY=( $(compgen -W "$ARG" -- $cur) )
+			return 0
+			;;
+		'-j'|'--associated')
+			ARG="$(losetup --output BACK-FILE | awk '{if (1 < NR) {print}}')"
+			COMPREPLY=( $(compgen -W "$ARG" -- $cur) )
+			return 0
+			;;
+		'-c'|'--set-capacity')
+			ARG="$(\ls /dev/loop[0-9]* 2>/dev/null)"
+			COMPREPLY=( $(compgen -W "$ARG" -- $cur) )
+			return 0
+			;;
+		'-o'|'--offset'|'--sizelimit')
+			COMPREPLY=( $(compgen -W "number" -- $cur) )
+			return 0
+			;;
+		'-O'|'--output')
+			# FIXME: how to append to a string with compgen?
+			local OUTPUT
+			OUTPUT="NAME AUTOCLEAR BACK-FILE BACK-INO
+				BACK-MAJ:MIN MAJ:MIN OFFSET PARTSCAN RO
+				SIZELIMIT"
+			compopt -o nospace
+			COMPREPLY=( $(compgen -W "$OUTPUT" -S ',' -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-a --all
+				-d --detach
+				-D --detach-all
+				-f --find
+				-c --set-capacity
+				-j --associated
+				-l --list
+				-o --offset
+				-O --output
+				   --sizelimit
+				-P --partscan
+				-r --read-only
+				   --show
+				-v --verbose
+				-h --help
+				-V --version"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	compopt -o filenames
+	COMPREPLY=( $(compgen -f -- $cur) )
+	return 0
+}
+complete -F _losetup_module losetup
diff --git a/shell-completion/lscpu b/shell-completion/lscpu
new file mode 100644
index 0000000..bb76d4c
--- /dev/null
+++ b/shell-completion/lscpu
@@ -0,0 +1,39 @@
+_lscpu_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-e'|'--extended'|'-p'|'--parse')
+			# FIXME: how to append to a string with compgen?
+			# FIXME: space in between option and argument is
+			# 	 a problem.
+			local OUTPUT
+			OUTPUT="CPU CORE SOCKET NODE BOOK CACHE
+				POLARIZATION ADDRESS CONFIGURED ONLINE"
+			compopt -o nospace
+			COMPREPLY=( $(compgen -W "$OUTPUT" -S ',' -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-a --all
+				-b --online
+				-c --offline
+				-e --extended
+				-p --parse
+				-s --sysroot
+				-x --hex
+				-h --help
+				-V --version"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	compopt -o filenames
+	COMPREPLY=( $(compgen -f -- $cur) )
+	return 0
+}
+complete -F _lscpu_module lscpu
diff --git a/shell-completion/mountpoint b/shell-completion/mountpoint
new file mode 100644
index 0000000..e2f1d56
--- /dev/null
+++ b/shell-completion/mountpoint
@@ -0,0 +1,24 @@
+_mountpoint_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-f'|'--fixme')
+			COMPREPLY=( $(compgen -W "fixme" -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-q --quiet -d --fs-devno -x --devno -h --help -V --version"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	compopt -o filenames
+	COMPREPLY=( $(compgen -f -- ${cur:-"/"}) )
+	return 0
+}
+complete -F _mountpoint_module mountpoint
diff --git a/shell-completion/nsenter b/shell-completion/nsenter
new file mode 100644
index 0000000..f15a7f1
--- /dev/null
+++ b/shell-completion/nsenter
@@ -0,0 +1,47 @@
+_nsenter_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-t'|'--target')
+			local PIDS
+			PIDS=$(\ls -d /proc/[0-9]* | sed 's|/proc/||')
+			COMPREPLY=( $(compgen -W "$PIDS" -- $cur) )
+			return 0
+			;;
+		'-m'|'--mount'|'-u'|'--uts'|'-i'|'--net'|'-n'|'--net'|'-p'|'--pid'|'-U'|'--user')
+			compopt -o filenames
+			COMPREPLY=( $(compgen -f -- $cur) )
+			return 0
+			;;
+		'-r'|'--root'|'-w'|'--wd')
+			compopt -o filenames
+			COMPREPLY=( $(compgen -o dirnames -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-t --target
+				-m --mount
+				-u --uts
+				-i --ipc
+				-n --net
+				-p --pid
+				-U --user
+				-r --root
+				-w --wd
+				-F --no-fork
+				-h --help
+				-V --version"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	compopt -o filenames
+	COMPREPLY=( $(compgen -f -- $cur) )
+	return 0
+}
+complete -F _nsenter_module nsenter
diff --git a/shell-completion/pivot_root b/shell-completion/pivot_root
new file mode 100644
index 0000000..54f1734
--- /dev/null
+++ b/shell-completion/pivot_root
@@ -0,0 +1,14 @@
+_pivot_root_module()
+{
+	local cur
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	case $COMP_CWORD in
+		1|2)
+			compopt -o filenames
+			COMPREPLY=( $(compgen -o dirnames -- ${cur:-"/"}) )
+			;;
+	esac
+	return 0
+}
+complete -F _pivot_root_module pivot_root
diff --git a/shell-completion/prlimit b/shell-completion/prlimit
new file mode 100644
index 0000000..ee49b79
--- /dev/null
+++ b/shell-completion/prlimit
@@ -0,0 +1,55 @@
+_prlimit_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-p'|'--pid')
+			PIDS=$(\ls -d /proc/[0-9]* | sed 's|/proc/||')
+			COMPREPLY=( $(compgen -W "$PIDS" -- $cur) )
+			return 0
+			;;
+		'-o'|'--output')
+			# FIXME: how to append to a string with compgen?
+			local OUTPUT
+			OUTPUT="DESCRIPTION RESOURCE SOFT HARD UNITS"
+			compopt -o nospace
+			COMPREPLY=( $(compgen -W "$OUTPUT" -S ',' -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-p --pid
+				-o --output
+				   --noheadings
+				   --raw
+				   --verbose
+				-h --help
+				-V --version
+				-c --core
+				-d --data
+				-e --nice
+				-f --fsize
+				-i --sigpending
+				-l --memlock
+				-m --rss
+				-n --nofile
+				-q --msgqueue
+				-r --rtprio
+				-s --stack
+				-t --cpu
+				-u --nproc
+				-v --as
+				-x --locks
+				-y --rttime"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	compopt -o bashdefault
+	COMPREPLY=( $(compgen -c -- $cur) )
+	return 0
+}
+complete -F _prlimit_module prlimit
diff --git a/shell-completion/readprofile b/shell-completion/readprofile
new file mode 100644
index 0000000..c1eb514
--- /dev/null
+++ b/shell-completion/readprofile
@@ -0,0 +1,33 @@
+_readprofile_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-m'|'--mapfile'|'-p'|'--profile')
+			compopt -o filenames
+			COMPREPLY=( $(compgen -f -- $cur) )
+			return 0
+			;;
+		'-M'|'--multiplier')
+			COMPREPLY=( $(compgen -W "multiplier" -- $cur) )
+			return 0
+			;;
+	esac
+	OPTS="-m --mapfile
+		-p --profile
+		-M --multiplier
+		-i --info
+		-v --verbose
+		-a --all
+		-b --histbin
+		-s --counters
+		-r --reset
+		-n --no-auto
+		-h --help
+		-V --version"
+	COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+	return 0
+}
+complete -F _readprofile_module readprofile
diff --git a/shell-completion/renice b/shell-completion/renice
new file mode 100644
index 0000000..bc80dac
--- /dev/null
+++ b/shell-completion/renice
@@ -0,0 +1,38 @@
+_renice_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-g'|'--pgrp')
+			local PGRP
+			PGRP=$(ps -ax -opgrp | sed '1d')
+			COMPREPLY=( $(compgen -W "$PGRP" -- $cur) )
+			return 0
+			;;
+		'-n'|'--priority')
+			COMPREPLY=( $(compgen -W "$(echo {-20..20})" -- $cur) )
+			return 0
+			;;
+		'-p'|'--pid')
+			local PIDS
+			PIDS=$(\ls -d /proc/[0-9]* | sed 's|/proc/||')
+			COMPREPLY=( $(compgen -W "$PIDS" -- $cur) )
+			return 0
+			;;
+		'-u'|'--user')
+			COMPREPLY=( $(compgen -u -- $cur) )
+			return 0
+			;;
+	esac
+	OPTS="-g --pgrp
+		-n --priority
+		-p --pid
+		-u --user
+		-h --help
+		-V --version"
+	COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+	return 0
+}
+complete -F _renice_module renice
diff --git a/shell-completion/rtcwake b/shell-completion/rtcwake
new file mode 100644
index 0000000..2010a52
--- /dev/null
+++ b/shell-completion/rtcwake
@@ -0,0 +1,40 @@
+_rtcwake_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-d'|'--device')
+			local RTC_DEVS
+			RTC_DEVS=$(\ls /sys/class/rtc/ 2>/dev/null)
+			COMPREPLY=( $(compgen -W "$RTC_DEVS" -- $cur) )
+			return 0
+			;;
+		'-m'|'--mode')
+			COMPREPLY=( $(compgen -W "standby mem disk off no on disable show" -- $cur) )
+			return 0
+			;;
+		'-s'|'--seconds')
+			COMPREPLY=( $(compgen -W "seconds" -- $cur) )
+			return 0
+			;;
+		'-t'|'--time')
+			COMPREPLY=( $(compgen -W "time_t" -- $cur) )
+			return 0
+			;;
+	esac
+	OPTS="-d --device
+		-n --dry-run
+		-l --local
+		-m --mode
+		-s --seconds
+		-t --time
+		-u --utc
+		-v --verbose
+		-h --help
+		-V --version"
+	COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+	return 0
+}
+complete -F _rtcwake_module rtcwake
diff --git a/shell-completion/setarch b/shell-completion/setarch
new file mode 100644
index 0000000..b84d399
--- /dev/null
+++ b/shell-completion/setarch
@@ -0,0 +1,42 @@
+_setarch_module()
+{
+	local cur OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	if [ $COMP_CWORD -eq 1 ]; then
+		COMPREPLY=( $(compgen -W "linux32 linux64 ppc32 ppc ppc64
+					  ppc64pseries ppc64iseries i386
+					  i486 i586 i686 athlon x86_64
+					  ia64 parisc32 parisc parisc64
+					  s390 s390x sparc sparc32bash
+					  sparc32 sparc64 mips32 mips
+					  mips64 alpha alphaev5 alphaev56
+					  alphaev6 alphaev67" -- $cur) )
+		return 0
+	fi
+	case $cur in
+		-*)
+			OPTS="-v, --verbose
+				-R, --addr-no-randomize
+				-F, --fdpic-funcptrs
+				-Z, --mmap-page-zero
+				-L, --addr-compat-layout
+				-X, --read-implies-exec
+				-B, --32bit
+				-I, --short-inode
+				-S, --whole-seconds
+				-T, --sticky-timeouts
+				-3, --3gb
+				    --4gb
+				    --uname-2.6
+				-h, --help
+				-V, --version"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	compopt -o bashdefault
+	COMPREPLY=( $(compgen -c -- $cur) )
+	return 0
+}
+complete -F _setarch_module setarch
diff --git a/shell-completion/setpriv b/shell-completion/setpriv
new file mode 100644
index 0000000..b05affe
--- /dev/null
+++ b/shell-completion/setpriv
@@ -0,0 +1,82 @@
+_setpriv_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'--inh-caps'|'--bounding-set')
+			# FIXME: how to append to a string with compgen?
+			local INHERIT
+			INHERIT=$(setpriv --list-caps| awk '{print $1, "-" $1}')
+			compopt -o nospace
+			COMPREPLY=( $(compgen -W "all $INHERIT" -S ',' -- $cur) )
+			return 0
+			;;
+		'--ruid'|'--euid'|'--reuid')
+			local UIDS
+			UIDS=$(getent passwd | awk -F: '{print $3}')
+			COMPREPLY=( $(compgen -W "$UIDS" -- $cur) )
+			return 0
+			;;
+		'--rgid'|'--egid'|'--regid')
+			local GIDS
+			GIDS=$(getent group | awk -F: '{print $3}')
+			COMPREPLY=( $(compgen -W "$GIDS" -- $cur) )
+			return 0
+			;;
+		'--groups')
+			# FIXME: how to append to a string with compgen?
+			local GIDS
+			GIDS=$(getent group | awk -F: '{print $3}')
+			compopt -o nospace
+			COMPREPLY=( $(compgen -W "$GIDS" -S ',' -- $cur) )
+			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) )
+			return 0
+			;;
+		'--selinux-label')
+			# FIXME: how to list selinux labels?
+			COMPREPLY=( $(compgen -W "label" -- $cur) )
+			return 0
+			;;
+		'--apparmor-profile')
+			# FIXME: how to list apparmor profiles?
+			COMPREPLY=( $(compgen -W "profile" -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-d --dump
+				--nnp --no-new-privs
+				--inh-caps
+				--bounding-set
+				--ruid
+				--euid
+				--rgid
+				--egid
+				--reuid
+				--regid
+				--clear-groupsclear
+				--keep-groupskeep
+				--groups
+				--securebits
+				--selinux-label
+				--apparmor-profile
+				-h --help
+				-V --version"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	compopt -o bashdefault
+	COMPREPLY=( $(compgen -c -- $cur) )
+	return 0
+}
+complete -F _setpriv_module setpriv
diff --git a/shell-completion/setsid b/shell-completion/setsid
new file mode 100644
index 0000000..dcefc2f
--- /dev/null
+++ b/shell-completion/setsid
@@ -0,0 +1,17 @@
+_setsid_module()
+{
+	local cur OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	case $cur in
+		-*)
+			OPTS="-c --ctty -h --help -V --version"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	compopt -o bashdefault
+	COMPREPLY=( $(compgen -c -- $cur) )
+	return 0
+}
+complete -F _setsid_module setsid
diff --git a/shell-completion/swapon b/shell-completion/swapon
new file mode 100644
index 0000000..83e7e24
--- /dev/null
+++ b/shell-completion/swapon
@@ -0,0 +1,48 @@
+_swapon_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-p'|'--priority')
+			# Priority range is -1 to 32767.  Perhaps these
+			# few are enough.
+			COMPREPLY=( $(compgen -W "$(echo {-1..9} 32767)" -- $cur) )
+			return 0
+			;;
+		'--show')
+			# FIXME: how to append to a string with compgen?
+			local OUTPUT
+			OUTPUT="NAME TYPE SIZE USED PRIO"
+			compopt -o nospace
+			COMPREPLY=( $(compgen -W "$OUTPUT" -S ',' -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-a --all
+				-d --discard
+				-e --ifexists
+				-f --fixpgsz
+				-p --priority
+				-s --summary
+				   --show
+				   --noheadings
+				   --raw
+				   --bytes
+				-v --verbose
+				-h --help
+				-V --version"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			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) )
+	return 0
+}
+complete -F _swapon_module swapon
diff --git a/shell-completion/tunelp b/shell-completion/tunelp
new file mode 100644
index 0000000..0f04842
--- /dev/null
+++ b/shell-completion/tunelp
@@ -0,0 +1,48 @@
+_tunelp_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-i'|'--irq'|'-c'|'--chars')
+			COMPREPLY=( $(compgen -W "number" -- $cur) )
+			return 0
+			;;
+		'-t'|'--time')
+			COMPREPLY=( $(compgen -W "milliseconds" -- $cur) )
+			return 0
+			;;
+		'-w'|'--wait')
+			COMPREPLY=( $(compgen -W "microseconds" -- $cur) )
+			return 0
+			;;
+		'-a'|'--abort'|'-o'|'--check-status'|'-C'|'--careful'|'-T'|'--trust-irq'|'-q'|'--print-irq')
+			COMPREPLY=( $(compgen -W "off on" -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-i --irq
+				-t --time
+				-c --chars
+				-w --wait
+				-a --abort
+				-o --check-status
+				-C --careful
+				-s --status
+				-T --trust-irq
+				-r --reset
+				-q --print-irq
+				-h --help
+				-V --version"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	compopt -o filenames
+	COMPREPLY=( $(compgen -f -- ${cur:-"/dev/lp"}) )
+	return 0
+}
+complete -F _tunelp_module tunelp
diff --git a/shell-completion/unshare b/shell-completion/unshare
new file mode 100644
index 0000000..295d02f
--- /dev/null
+++ b/shell-completion/unshare
@@ -0,0 +1,24 @@
+_unshare_module()
+{
+	local cur OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	case $cur in
+		-*)
+			OPTS="-m --mount
+				-u --uts
+				-i --ipc
+				-n --net
+				-p --pid
+				-U --user
+				-h --help
+				-V --version"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	compopt -o bashdefault
+	COMPREPLY=( $(compgen -c -- $cur) )
+	return 0
+}
+complete -F _unshare_module unshare
diff --git a/shell-completion/wdctl b/shell-completion/wdctl
new file mode 100644
index 0000000..6a85e0a
--- /dev/null
+++ b/shell-completion/wdctl
@@ -0,0 +1,48 @@
+_wdctl_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-f'|'--flags')
+			# FIXME: how to get flag list?
+			COMPREPLY=( $(compgen -W "flags" -- $cur) )
+			return 0
+			;;
+		'-o'|'--output')
+			# FIXME: how to append to a string with compgen?
+			local OUTPUT
+			OUTPUT="FLAG DESCRIPTION STATUS BOOT-STATUS DEVICE"
+			compopt -o nospace
+			COMPREPLY=( $(compgen -W "$OUTPUT" -S ',' -- $cur) )
+			return 0
+			;;
+		'-s'|'--settimeout')
+			COMPREPLY=( $(compgen -W "seconds" -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-f --flags
+				-F --noflags
+				-I --noident
+				-n --noheadings
+				-O --oneline
+				-o --output
+				-r --raw
+				-T --notimeouts
+				-s --settimeout
+				-x --flags-only
+				-h --help
+				-V --version"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	compopt -o filenames
+	COMPREPLY=( $(compgen -f -- ${cur:-"/dev/"}) )
+	return 0
+}
+complete -F _wdctl_module wdctl
-- 
1.8.2


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 08/10] bash-completion: term-utils
  2013-03-27 22:07 [PATCH 00/10] [pull] bash-completion Sami Kerola
                   ` (6 preceding siblings ...)
  2013-03-27 22:07 ` [PATCH 07/10] bash-completion: sys-utils Sami Kerola
@ 2013-03-27 22:07 ` Sami Kerola
  2013-03-28 10:06   ` Karel Zak
  2013-03-27 22:07 ` [PATCH 09/10] bash-completion: text-utils Sami Kerola
                   ` (4 subsequent siblings)
  12 siblings, 1 reply; 33+ messages in thread
From: Sami Kerola @ 2013-03-27 22:07 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 shell-completion/agetty       |  70 +++++++++++++++++++++++++++
 shell-completion/mesg         |  16 +++++++
 shell-completion/script       |  38 +++++++++++++++
 shell-completion/scriptreplay |  28 +++++++++++
 shell-completion/setterm      | 109 ++++++++++++++++++++++++++++++++++++++++++
 shell-completion/wall         |  24 ++++++++++
 shell-completion/write        |  19 ++++++++
 7 files changed, 304 insertions(+)
 create mode 100644 shell-completion/agetty
 create mode 100644 shell-completion/mesg
 create mode 100644 shell-completion/script
 create mode 100644 shell-completion/scriptreplay
 create mode 100644 shell-completion/setterm
 create mode 100644 shell-completion/wall
 create mode 100644 shell-completion/write

diff --git a/shell-completion/agetty b/shell-completion/agetty
new file mode 100644
index 0000000..dc37a68
--- /dev/null
+++ b/shell-completion/agetty
@@ -0,0 +1,70 @@
+_agetty_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-a'|'--autologin')
+			COMPREPLY=( $(compgen -u -- $cur) )
+			return 0
+			;;
+		'-o'|'--issue-file'|'-I'|'--login-program')
+			compopt -o filenames
+			COMPREPLY=( $(compgen -f -- $cur) )
+			return 0
+			;;
+		'-I'|'--init-string'|'--erase-chars'|'--kill-chars')
+			compopt -o filenames
+			COMPREPLY=( $(compgen -W "string" -- $cur) )
+			return 0
+			;;
+		'-o'|'--login-options')
+			COMPREPLY=( $(compgen -W "login-options" -- $cur) )
+			return 0
+			;;
+		'-t'|'--timeout')
+			COMPREPLY=( $(compgen -W "seconds" -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-8 --8bits
+				-a --autologin
+				-c --noreset
+				-f --issue-file
+				-h --flow-control
+				-H --host
+				-i --noissue
+				-I --init-string
+				-l --login-program
+				-L --local-line
+				-m --extract-baud
+				-n --skip-login
+				-o --login-options
+				-p --loginpause
+				-R --hangup
+				-s --keep-baud
+				-t --timeout
+				-U --detect-case
+				-w --wait-cr
+				   --nocleardo
+				   --nohintsdo
+				   --nonewlinedo
+				   --no-hostnameno
+				   --long-hostnameshow
+				   --erase-chars
+				   --kill-chars
+				-h --help
+				-V --version"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	local BAUD_RATES
+	BAUD_RATES="75 110 300 1200 2400 4800 9600 19200 38400 57600 115200"
+	COMPREPLY=( $(compgen -W "$BAUD_RATES $(echo /dev/tty*)" -- $cur) )
+	return 0
+}
+complete -F _agetty_module agetty
diff --git a/shell-completion/mesg b/shell-completion/mesg
new file mode 100644
index 0000000..62c98ca
--- /dev/null
+++ b/shell-completion/mesg
@@ -0,0 +1,16 @@
+_mesg_module()
+{
+	local cur OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	case $cur in
+		-*)
+			OPTS="-v --verbose -V --version -h --help"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	COMPREPLY=( $(compgen -W "y n" -- $cur) )
+	return 0
+}
+complete -F _mesg_module mesg
diff --git a/shell-completion/script b/shell-completion/script
new file mode 100644
index 0000000..fb6c106
--- /dev/null
+++ b/shell-completion/script
@@ -0,0 +1,38 @@
+_script_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-c'|'--command')
+			compopt -o bashdefault
+			COMPREPLY=( $(compgen -c -- $cur) )
+			return 0
+			;;
+		'-t'|'--timing')
+			compopt -o filenames
+			COMPREPLY=( $(compgen -f -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-a --append
+				-c --command
+				-e --return
+				-f --flush
+				   --force
+				-q --quiet
+				-t --timing
+				-V --version
+				-h --help"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	compopt -o filenames
+	COMPREPLY=( $(compgen -f -- $cur) )
+	return 0
+}
+complete -F _script_module script
diff --git a/shell-completion/scriptreplay b/shell-completion/scriptreplay
new file mode 100644
index 0000000..78e5b23
--- /dev/null
+++ b/shell-completion/scriptreplay
@@ -0,0 +1,28 @@
+_scriptreplay_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-d'|'--divisor')
+			COMPREPLY=( $(compgen -W "digit" -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-t --timing
+				-s --typescript
+				-d --divisor
+				-V --version
+				-h --help"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	compopt -o filenames
+	COMPREPLY=( $(compgen -f -- $cur) )
+	return 0
+}
+complete -F _scriptreplay_module scriptreplay
diff --git a/shell-completion/setterm b/shell-completion/setterm
new file mode 100644
index 0000000..a0dff44
--- /dev/null
+++ b/shell-completion/setterm
@@ -0,0 +1,109 @@
+_setterm_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-term')
+			# FIXME: terminal type list would be nice
+			COMPREPLY=( $(compgen -W "vt100 xterm linux screen etc" -- $cur) )
+			return 0
+			;;
+		'-foreground'|'-background'|'-ulcolor'|'-hbcolor')
+			COMPREPLY=( $(compgen -W "default black blue cyan green magenta red white yellow" -- $cur) )
+			return 0
+			;;
+		'-cursor'|'-repeat'|'-appcursorkeys'|'-linewrap'|'-inversescreen'|'-bold'|'-half-bright'|'-blink'|'-reverse'|'-underline'|'-msg')
+			COMPREPLY=( $(compgen -W "off on" -- $cur) )
+			return 0
+			;;
+		'-clear')
+			COMPREPLY=( $(compgen -W "all rest" -- $cur) )
+			return 0
+			;;
+		'-tabs'|'-clrtabs')
+			COMPREPLY=( $(compgen -W "tab1 tab2 tab3 tab160" -- $cur) )
+			return 0
+			;;
+		'-regtabs')
+			COMPREPLY=( $(compgen -W "$(echo {1..160})" -- $cur) )
+			return 0
+			;;
+		'-blank')
+			COMPREPLY=( $(compgen -W "$(echo {0..60}) force poke" -- $cur) )
+			return 0
+			;;
+		'-dump'|'-append')
+			local NUM_CONS
+			NUM_CONS=$(ls /sys/class/tty | wc -l)
+			COMPREPLY=( $(compgen -W "$(echo {1..$NUM_CONS})" -- $cur) )
+			return 0
+			;;
+		'-file')
+			compopt -o filenames
+			COMPREPLY=( $(compgen -f -- $cur) )
+			return 0
+			;;
+		'-msglevel')
+			COMPREPLY=( $(compgen -W "$(echo {1..8})" -- $cur) )
+			return 0
+			;;
+		'-powersave')
+			COMPREPLY=( $(compgen -W "on vsync hsync powerdown off" -- $cur) )
+			return 0
+			;;
+		'-powerdown')
+			COMPREPLY=( $(compgen -W "$(echo {0..60})" -- $cur) )
+			return 0
+			;;
+		'-blength')
+			COMPREPLY=( $(compgen -W "0-2000" -- $cur) )
+			return 0
+			;;
+		'-bfreq')
+			COMPREPLY=( $(compgen -W "freqnumber" -- $cur) )
+			return 0
+			;;
+	esac
+	OPTS="	-term
+		-reset
+		-initialize
+		-cursor
+		-repeat
+		-appcursorkeys
+		-linewrap
+		-default
+		-foreground
+		-background
+		-ulcolor
+		-hbcolor
+		-ulcolor
+		-hbcolor
+		-inversescreen
+		-bold
+		-half-bright
+		-blink
+		-reverse
+		-underline
+		-store
+		-clear
+		-tabs
+		-clrtabs
+		-regtabs
+		-blank
+		-dump
+		-append
+		-file
+		-msg
+		-msglevel
+		-powersave
+		-powerdown
+		-blength
+		-bfreq
+		-version
+		-help"
+	COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+	return 0
+}
+complete -F _setterm_module setterm
diff --git a/shell-completion/wall b/shell-completion/wall
new file mode 100644
index 0000000..d3cbbd5
--- /dev/null
+++ b/shell-completion/wall
@@ -0,0 +1,24 @@
+_wall_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-t'|'--timeout')
+			COMPREPLY=( $(compgen -W "seconds" -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-n --nobanner -t --timeout -V --version -h --help"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	compopt -o filenames
+	COMPREPLY=( $(compgen -f -- $cur) )
+	return 0
+}
+complete -F _wall_module wall
diff --git a/shell-completion/write b/shell-completion/write
new file mode 100644
index 0000000..ba67569
--- /dev/null
+++ b/shell-completion/write
@@ -0,0 +1,19 @@
+_write_module()
+{
+	local cur
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	case $COMP_CWORD in
+		1)
+			COMPREPLY=( $(compgen -u -- $cur) )
+			return 0
+			;;
+		2)
+			local TERMS=$(for I in $(\ls /sys/class/tty 2>/dev/null); do echo "/dev/$I"; done)
+			COMPREPLY=( $(compgen -W "$TERMS" -- $cur) )
+			return 0
+			;;
+	esac
+	return 0
+}
+complete -F _write_module write
-- 
1.8.2


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 09/10] bash-completion: text-utils
  2013-03-27 22:07 [PATCH 00/10] [pull] bash-completion Sami Kerola
                   ` (7 preceding siblings ...)
  2013-03-27 22:07 ` [PATCH 08/10] bash-completion: term-utils Sami Kerola
@ 2013-03-27 22:07 ` Sami Kerola
  2013-03-27 22:07 ` [PATCH 10/10] bash-completion: add completion files to Makefile.am Sami Kerola
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 33+ messages in thread
From: Sami Kerola @ 2013-03-27 22:07 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 shell-completion/col     | 24 ++++++++++++++++++++++++
 shell-completion/colcrt  | 20 ++++++++++++++++++++
 shell-completion/colrm   | 23 +++++++++++++++++++++++
 shell-completion/column  | 34 ++++++++++++++++++++++++++++++++++
 shell-completion/hexdump | 32 ++++++++++++++++++++++++++++++++
 shell-completion/more    | 22 ++++++++++++++++++++++
 shell-completion/pg      | 29 +++++++++++++++++++++++++++++
 shell-completion/rev     | 17 +++++++++++++++++
 shell-completion/tailf   | 24 ++++++++++++++++++++++++
 shell-completion/ul      | 25 +++++++++++++++++++++++++
 10 files changed, 250 insertions(+)
 create mode 100644 shell-completion/col
 create mode 100644 shell-completion/colcrt
 create mode 100644 shell-completion/colrm
 create mode 100644 shell-completion/column
 create mode 100644 shell-completion/hexdump
 create mode 100644 shell-completion/more
 create mode 100644 shell-completion/pg
 create mode 100644 shell-completion/rev
 create mode 100644 shell-completion/tailf
 create mode 100644 shell-completion/ul

diff --git a/shell-completion/col b/shell-completion/col
new file mode 100644
index 0000000..9ad3a67
--- /dev/null
+++ b/shell-completion/col
@@ -0,0 +1,24 @@
+_col_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-l'|'--lines')
+			COMPREPLY=( $(compgen -W "number" -- $cur) )
+			return 0
+			;;
+	esac
+	OPTS="-b --no-backspaces
+		-f --fine
+		-p --pass
+		-h --tabs
+		-x --spaces
+		-l --lines
+		-V --version
+		-H --help"
+	COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+	return 0
+}
+complete -F _col_module col
diff --git a/shell-completion/colcrt b/shell-completion/colcrt
new file mode 100644
index 0000000..628416e
--- /dev/null
+++ b/shell-completion/colcrt
@@ -0,0 +1,20 @@
+_colcrt_module()
+{
+	local cur OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	case $cur in
+		-*)
+			OPTS="	-  --no-underlining
+				-2 --half-lines
+				-V --version
+				-h --help"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	compopt -o filenames
+	COMPREPLY=( $(compgen -f -- $cur) )
+	return 0
+}
+complete -F _colcrt_module colcrt
diff --git a/shell-completion/colrm b/shell-completion/colrm
new file mode 100644
index 0000000..aa57c02
--- /dev/null
+++ b/shell-completion/colrm
@@ -0,0 +1,23 @@
+_colrm_module()
+{
+	local cur OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	case $cur in
+		-*)
+			OPTS="-V --version -h --help"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	case $COMP_CWORD in
+		1)
+			COMPREPLY=( $(compgen -W "startcol" -- $cur) )
+			;;
+		2)
+			COMPREPLY=( $(compgen -W "endcol" -- $cur) )
+			;;
+	esac
+	return 0
+}
+complete -F _colrm_module colrm
diff --git a/shell-completion/column b/shell-completion/column
new file mode 100644
index 0000000..94e1a51
--- /dev/null
+++ b/shell-completion/column
@@ -0,0 +1,34 @@
+_column_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-c'|'--columns')
+			COMPREPLY=( $(compgen -W "number" -- $cur) )
+			return 0
+			;;
+		'-s'|'--separator'|'-o'|'--output-separator')
+			COMPREPLY=( $(compgen -W "string" -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-c --columns
+				-t --table
+				-s --separator
+				-o --output-separator
+				-x --fillrows
+				-h --help
+				-V --version"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	compopt -o filenames
+	COMPREPLY=( $(compgen -f -- $cur) )
+	return 0
+}
+complete -F _column_module column
diff --git a/shell-completion/hexdump b/shell-completion/hexdump
new file mode 100644
index 0000000..1a6786b
--- /dev/null
+++ b/shell-completion/hexdump
@@ -0,0 +1,32 @@
+_hexdump_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-e')
+			COMPREPLY=( $(compgen -W "format" -- $cur) )
+			return 0
+			;;
+		'-n')
+			COMPREPLY=( $(compgen -W "length" -- $cur) )
+			return 0
+			;;
+		'-s')
+			COMPREPLY=( $(compgen -W "offset" -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-b -c -C -d -o -x -e -f -n -s -v -V"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	compopt -o filenames
+	COMPREPLY=( $(compgen -f -- $cur) )
+	return 0
+}
+complete -F _hexdump_module hexdump
diff --git a/shell-completion/more b/shell-completion/more
new file mode 100644
index 0000000..f32770d
--- /dev/null
+++ b/shell-completion/more
@@ -0,0 +1,22 @@
+_more_module()
+{
+	local cur OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	case $cur in
+		-*)
+			OPTS="-d -f -l -p -c -u -s -number -V"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+		+*)
+			OPTS="+number +/string"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	compopt -o filenames
+	COMPREPLY=( $(compgen -f -- $cur) )
+	return 0
+}
+complete -F _more_module more
diff --git a/shell-completion/pg b/shell-completion/pg
new file mode 100644
index 0000000..4ae8887
--- /dev/null
+++ b/shell-completion/pg
@@ -0,0 +1,29 @@
+_pg_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-p')
+			COMPREPLY=( $(compgen -W "prompt" -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-number -c -e -f -n -p -r -s -h -V"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+		+*)
+			OPTS="+number +/pattern/"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	compopt -o filenames
+	COMPREPLY=( $(compgen -f -- $cur) )
+	return 0
+}
+complete -F _pg_module pg
diff --git a/shell-completion/rev b/shell-completion/rev
new file mode 100644
index 0000000..f891f19
--- /dev/null
+++ b/shell-completion/rev
@@ -0,0 +1,17 @@
+_rev_module()
+{
+	local cur OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	case $cur in
+		-*)
+			OPTS="-V --version -h --help"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	compopt -o filenames
+	COMPREPLY=( $(compgen -f -- $cur) )
+	return 0
+}
+complete -F _rev_module rev
diff --git a/shell-completion/tailf b/shell-completion/tailf
new file mode 100644
index 0000000..29c5bed
--- /dev/null
+++ b/shell-completion/tailf
@@ -0,0 +1,24 @@
+_tailf_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-n'|'--lines')
+			COMPREPLY=( $(compgen -W "number" -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-n --lines -number -V --version -h --help"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	compopt -o filenames
+	COMPREPLY=( $(compgen -f -- $cur) )
+	return 0
+}
+complete -F _tailf_module tailf
diff --git a/shell-completion/ul b/shell-completion/ul
new file mode 100644
index 0000000..89e2800
--- /dev/null
+++ b/shell-completion/ul
@@ -0,0 +1,25 @@
+_ul_module()
+{
+	local cur prev OPTS
+	COMPREPLY=()
+	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
+	case $prev in
+		'-t'|'--terminal')
+			# FIXME: terminal type list would be nice
+			COMPREPLY=( $(compgen -W "vt100 xterm linux screen etc" -- $cur) )
+			return 0
+			;;
+	esac
+	case $cur in
+		-*)
+			OPTS="-t --terminal -i --indicated -V --version -h --help"
+			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+			return 0
+			;;
+	esac
+	compopt -o filenames
+	COMPREPLY=( $(compgen -f -- $cur) )
+	return 0
+}
+complete -F _ul_module ul
-- 
1.8.2


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 10/10] bash-completion: add completion files to Makefile.am
  2013-03-27 22:07 [PATCH 00/10] [pull] bash-completion Sami Kerola
                   ` (8 preceding siblings ...)
  2013-03-27 22:07 ` [PATCH 09/10] bash-completion: text-utils Sami Kerola
@ 2013-03-27 22:07 ` Sami Kerola
  2013-03-28  1:42 ` [PATCH 00/10] [pull] bash-completion Dave Reisner
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 33+ messages in thread
From: Sami Kerola @ 2013-03-27 22:07 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

And remove shell completion TODO item.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 Documentation/TODO             |   6 -
 shell-completion/Makemodule.am | 261 ++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 260 insertions(+), 7 deletions(-)

diff --git a/Documentation/TODO b/Documentation/TODO
index b4139d3..4adf05d 100644
--- a/Documentation/TODO
+++ b/Documentation/TODO
@@ -8,12 +8,6 @@ hwlock
  - the /var/lib/hwclock/drift should be implemented backwardly compatible,
    it means use the file only if exists, otherwise follow /etc/adjtime 
 
-bash completion
----------------
- - file per command in shel-completion/bash/
- - use $(pkg-config --variable=completionsdir bash-completion)/util-linux/
-   as a destination install directory
-
 wipefs
 ------
  - generate /root/wipefs-<devname>-<offset>.bak with wiped bytes, so after 
diff --git a/shell-completion/Makemodule.am b/shell-completion/Makemodule.am
index b784ec7..0bb8652 100644
--- a/shell-completion/Makemodule.am
+++ b/shell-completion/Makemodule.am
@@ -1 +1,260 @@
-dist_bashcompletion_DATA =
+dist_bashcompletion_DATA = \
+	shell-completion/blkid \
+	shell-completion/cal \
+	shell-completion/col \
+	shell-completion/colcrt \
+	shell-completion/colrm \
+	shell-completion/column \
+	shell-completion/findmnt \
+	shell-completion/flock \
+	shell-completion/fsck.minix \
+	shell-completion/getopt \
+	shell-completion/hexdump \
+	shell-completion/ipcrm \
+	shell-completion/ipcs \
+	shell-completion/isosize \
+	shell-completion/logger \
+	shell-completion/look \
+	shell-completion/mcookie \
+	shell-completion/mkfs \
+	shell-completion/mkfs.bfs \
+	shell-completion/mkfs.minix \
+	shell-completion/mkswap \
+	shell-completion/namei \
+	shell-completion/prlimit \
+	shell-completion/readprofile \
+	shell-completion/renice \
+	shell-completion/rev \
+	shell-completion/script \
+	shell-completion/scriptreplay \
+	shell-completion/setsid \
+	shell-completion/tailf \
+	shell-completion/wall \
+	shell-completion/whereis \
+	shell-completion/wipefs
+
+# disk-utils...
+if BUILD_CRAMFS
+dist_bashcompletion_DATA += \
+	shell-completion/fsck.cramfs \
+	shell-completion/mkfs.cramfs
+endif
+if BUILD_FSCK
+dist_bashcompletion_DATA += \
+	shell-completion/fsck
+endif
+if BUILD_PARTX
+dist_bashcompletion_DATA += \
+	shell-completion/addpart \
+	shell-completion/delpart \
+	shell-completion/resizepart \
+	shell-completion/partx
+endif
+if BUILD_RAW
+dist_bashcompletion_DATA += \
+	shell-completion/raw
+endif
+if BUILD_SWAPLABEL
+dist_bashcompletion_DATA += \
+	shell-completion/swaplabel
+endif
+if LINUX
+dist_bashcompletion_DATA += \
+	shell-completion/blockdev \
+	shell-completion/fdformat
+endif
+# ...disk-utils
+
+# fdisks...
+if !ARCH_M68K
+dist_bashcompletion_DATA += \
+	shell-completion/fdisk
+if !ARCH_SPARC
+dist_bashcompletion_DATA += \
+	shell-completion/sfdisk
+if BUILD_CFDISK
+dist_bashcompletion_DATA += \
+	shell-completion/cfdisk
+endif
+endif # !ARCH_SPARC
+endif # !ARCH_M68
+# ...fdisks
+
+# login-utils...
+if BUILD_CHFN_CHSH
+dist_bashcompletion_DATA += \
+	shell-completion/chfn \
+	shell-completion/chsh
+endif
+if BUILD_LAST
+dist_bashcompletion_DATA += \
+	shell-completion/last
+endif
+if BUILD_LOGIN
+dist_bashcompletion_DATA += \
+	shell-completion/login
+endif
+if BUILD_NEWGRP
+dist_bashcompletion_DATA += \
+	shell-completion/newgrp
+endif
+if BUILD_SU
+dist_bashcompletion_DATA += \
+	shell-completion/su
+endif
+if BUILD_SULOGIN
+dist_bashcompletion_DATA += \
+	shell-completion/sulogin
+endif
+if BUILD_UTMPDUMP
+dist_bashcompletion_DATA += \
+	shell-completion/utmpdump
+endif
+# ...login-utils
+
+# misc-utils...
+if BUILD_LIBUUID
+dist_bashcompletion_DATA += \
+	shell-completion/uuidgen
+endif
+if BUILD_UUIDD
+dist_bashcompletion_DATA += \
+	shell-completion/uuidd
+endif
+if BUILD_LSBLK
+dist_bashcompletion_DATA += \
+	shell-completion/lsblk
+endif
+if BUILD_LSLOCKS
+dist_bashcompletion_DATA += \
+	shell-completion/lslocks
+endif
+if BUILD_RENAME
+dist_bashcompletion_DATA += \
+	shell-completion/rename
+endif
+# ...misc-utils
+
+# schedutils...
+if BUILD_SCHEDUTILS
+dist_bashcompletion_DATA += \
+	shell-completion/chrt
+if BUILD_IONICE
+dist_bashcompletion_DATA += \
+	shell-completion/ionice
+endif
+if BUILD_TASKSET
+dist_bashcompletion_DATA += \
+	shell-completion/taskset
+endif
+endif # BUILD_SCHEDUTILS
+# ...schedutils
+
+# sys-utils...
+if BUILD_CHCPU
+dist_bashcompletion_DATA += \
+	shell-completion/chcpu
+endif
+if BUILD_EJECT
+dist_bashcompletion_DATA += \
+	shell-completion/eject
+endif
+if BUILD_FALLOCATE
+dist_bashcompletion_DATA += \
+	shell-completion/fallocate
+endif
+if BUILD_HWCLOCK
+dist_bashcompletion_DATA += \
+	shell-completion/hwclock
+endif
+if BUILD_TUNELP
+dist_bashcompletion_DATA += \
+	shell-completion/tunelp
+endif
+if BUILD_LSCPU
+dist_bashcompletion_DATA += \
+	shell-completion/lscpu
+endif
+if BUILD_LOSETUP
+dist_bashcompletion_DATA += \
+	shell-completion/losetup
+endif
+if BUILD_MOUNTPOINT
+dist_bashcompletion_DATA += \
+	shell-completion/mountpoint
+endif
+if BUILD_NSENTER
+dist_bashcompletion_DATA += \
+	shell-completion/nsenter
+endif
+if BUILD_PIVOT_ROOT
+dist_bashcompletion_DATA += \
+	shell-completion/pivot_root
+endif
+if BUILD_SETPRIV
+dist_bashcompletion_DATA += \
+	shell-completion/setpriv
+endif
+if BUILD_SWAPON
+dist_bashcompletion_DATA += \
+	shell-completion/swapon
+endif
+if BUILD_UNSHARE
+dist_bashcompletion_DATA += \
+	shell-completion/unshare
+endif
+if BUILD_WDCTL
+dist_bashcompletion_DATA += \
+	shell-completion/wdctl
+endif
+if LINUX
+dist_bashcompletion_DATA += \
+	shell-completion/blkdiscard \
+	shell-completion/ctrlaltdel \
+	shell-completion/cytune \
+	shell-completion/dmesg \
+	shell-completion/fsfreeze \
+	shell-completion/fstrim \
+	shell-completion/ldattach \
+	shell-completion/rtcwake \
+	shell-completion/setarch
+endif
+# ...sys-utils
+
+# term-utils...
+if BUILD_AGETTY
+dist_bashcompletion_DATA += \
+	shell-completion/agetty
+endif
+if BUILD_MESG
+dist_bashcompletion_DATA += \
+	shell-completion/mesg
+endif
+if BUILD_WALL
+dist_bashcompletion_DATA += \
+	shell-completion/wall
+endif
+if BUILD_WRITE
+dist_bashcompletion_DATA += \
+	shell-completion/write
+endif
+if LINUX
+dist_bashcompletion_DATA += \
+	shell-completion/setterm
+endif
+# ...term-utils
+
+# text-utils...
+if BUILD_MORE
+dist_bashcompletion_DATA += \
+	shell-completion/more
+endif
+if BUILD_PG
+dist_bashcompletion_DATA += \
+	shell-completion/pg
+endif
+if BUILD_UL
+dist_bashcompletion_DATA += \
+	shell-completion/ul
+endif
+# ...text-utils
-- 
1.8.2


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* Re: [PATCH 00/10] [pull] bash-completion
  2013-03-27 22:07 [PATCH 00/10] [pull] bash-completion Sami Kerola
                   ` (9 preceding siblings ...)
  2013-03-27 22:07 ` [PATCH 10/10] bash-completion: add completion files to Makefile.am Sami Kerola
@ 2013-03-28  1:42 ` Dave Reisner
  2013-03-28  9:37 ` Karel Zak
  2013-04-05 14:11 ` Karel Zak
  12 siblings, 0 replies; 33+ messages in thread
From: Dave Reisner @ 2013-03-28  1:42 UTC (permalink / raw)
  To: Sami Kerola; +Cc: util-linux

On Wed, Mar 27, 2013 at 10:07:42PM +0000, Sami Kerola wrote:
> Hello,
> 
> Here is a pull request, which does two things; an introduction of bash
> completetion to util-linux, and most FIXME items ever sent to review in
> single batch (26).
> 
> Most of the brokenness in this batch series has got to do with a comma
> separate value list, e.g., 'value1,another,foobar', which one would
> expect to continue filling with 'value1,<tab>' but that does not work.  I
> am almost sure that one might achieve continue the list by setting comma
> to COMP_WORDBREAKS, and check if $prev is in known words list, but I
> simply did not get that to work (I suspect PEBKAC).
> 
> Some FIXME's are slightly more difficult to fix.  For example I do not
> know how to get list of possible TERM values distribution agnostic way. 
> And with 'wdctl' I have no how to determine flags.  Same goes for SELinux
> labels & Apparmor provilles for setpriv.  Anyhow, if someone wants to
> help, give hints, or even directly fix something feel free to reply the
> later patches what could be done to an instance of a problem.
> 
> Of course any other sort of feedback is also welcome.

Hi Sami,

I think this is a great start. I've commented on a few of your patches
and pointed out where I think there's room for improvement. I haven't
commented on everything, but I think you'll be able to apply some of the
advice in a general sense (if you're so inclined).

> 
> The following changes since commit 4cd271adc1dd3231e705c9e074491a7f49a721b8:
> 
>   libmount: make mnt_table_find_* more robust [coverity scan] (2013-03-27 16:47:46 +0100)
> 
> are available in the git repository at:
> 
>   git://github.com/kerolasa/lelux-utiliteetit.git shell-completion
> 
> for you to fetch changes up to e8b90f9baffd36a95bab408a3859b04543577a1b:
> 
>   bash-completion: add completion files to Makefile.am (2013-03-27 21:31:25 +0000)
> 
> ----------------------------------------------------------------
> Sami Kerola (10):
>       bash-completion: add bash completetion configure option
>       bash-completion: disk-utils
>       bash-completion: fdisks
>       bash-completion: login-utils
>       bash-completion: misc-utils
>       bash-completion: schedutils
>       bash-completion: sys-utils
>       bash-completion: term-utils
>       bash-completion: text-utils
>       bash-completion: add completion files to Makefile.am
> 
>  Documentation/TODO             |   6 -
>  Makefile.am                    |   5 +
>  configure.ac                   |  13 +++
>  shell-completion/Makemodule.am | 260 +++++++++++++++++++++++++++++++++++++++++
>  shell-completion/addpart       |  25 ++++
>  shell-completion/agetty        |  70 +++++++++++
>  shell-completion/blkdiscard    |  25 ++++
>  shell-completion/blkid         |  62 ++++++++++
>  shell-completion/blockdev      |  44 +++++++
>  shell-completion/cal           |  15 +++
>  shell-completion/cfdisk        |  31 +++++
>  shell-completion/chcpu         |  44 +++++++
>  shell-completion/chfn          |  31 +++++
>  shell-completion/chrt          |  32 +++++
>  shell-completion/chsh          |  23 ++++
>  shell-completion/col           |  24 ++++
>  shell-completion/colcrt        |  20 ++++
>  shell-completion/colrm         |  23 ++++
>  shell-completion/column        |  34 ++++++
>  shell-completion/ctrlaltdel    |  11 ++
>  shell-completion/cytune        |  37 ++++++
>  shell-completion/delpart       |  19 +++
>  shell-completion/dmesg         |  53 +++++++++
>  shell-completion/eject         |  61 ++++++++++
>  shell-completion/fallocate     |  24 ++++
>  shell-completion/fdformat      |  11 ++
>  shell-completion/fdisk         |  41 +++++++
>  shell-completion/findmnt       | 114 ++++++++++++++++++
>  shell-completion/flock         |  42 +++++++
>  shell-completion/fsck          |  36 ++++++
>  shell-completion/fsck.cramfs   |  18 +++
>  shell-completion/fsck.minix    |  11 ++
>  shell-completion/fsfreeze      |  18 +++
>  shell-completion/fstrim        |  25 ++++
>  shell-completion/getopt        |  34 ++++++
>  shell-completion/hexdump       |  32 +++++
>  shell-completion/hwclock       |  53 +++++++++
>  shell-completion/ionice        |  34 ++++++
>  shell-completion/ipcrm         |  52 +++++++++
>  shell-completion/ipcs          |  30 +++++
>  shell-completion/isosize       |  17 +++
>  shell-completion/last          |  38 ++++++
>  shell-completion/ldattach      |  54 +++++++++
>  shell-completion/logger        |  43 +++++++
>  shell-completion/login         |  27 +++++
>  shell-completion/look          |  24 ++++
>  shell-completion/losetup       |  64 ++++++++++
>  shell-completion/lsblk         |  60 ++++++++++
>  shell-completion/lscpu         |  39 +++++++
>  shell-completion/lslocks       |  43 +++++++
>  shell-completion/mcookie       |  23 ++++
>  shell-completion/mesg          |  16 +++
>  shell-completion/mkfs          |  25 ++++
>  shell-completion/mkfs.bfs      |  28 +++++
>  shell-completion/mkfs.cramfs   |  40 +++++++
>  shell-completion/mkfs.minix    |  33 ++++++
>  shell-completion/mkswap        |  36 ++++++
>  shell-completion/more          |  22 ++++
>  shell-completion/mountpoint    |  24 ++++
>  shell-completion/namei         |  17 +++
>  shell-completion/newgrp        |  16 +++
>  shell-completion/nsenter       |  47 ++++++++
>  shell-completion/partx         |  37 ++++++
>  shell-completion/pg            |  29 +++++
>  shell-completion/pivot_root    |  14 +++
>  shell-completion/prlimit       |  55 +++++++++
>  shell-completion/raw           |  17 +++
>  shell-completion/readprofile   |  33 ++++++
>  shell-completion/rename        |  27 +++++
>  shell-completion/renice        |  38 ++++++
>  shell-completion/resizepart    |  22 ++++
>  shell-completion/rev           |  17 +++
>  shell-completion/rtcwake       |  40 +++++++
>  shell-completion/script        |  38 ++++++
>  shell-completion/scriptreplay  |  28 +++++
>  shell-completion/setarch       |  42 +++++++
>  shell-completion/setpriv       |  82 +++++++++++++
>  shell-completion/setsid        |  17 +++
>  shell-completion/setterm       | 109 +++++++++++++++++
>  shell-completion/sfdisk        |  72 ++++++++++++
>  shell-completion/su            |  45 +++++++
>  shell-completion/sulogin       |  24 ++++
>  shell-completion/swaplabel     |  28 +++++
>  shell-completion/swapon        |  48 ++++++++
>  shell-completion/tailf         |  24 ++++
>  shell-completion/taskset       |  38 ++++++
>  shell-completion/tunelp        |  48 ++++++++
>  shell-completion/ul            |  25 ++++
>  shell-completion/unshare       |  24 ++++
>  shell-completion/utmpdump      |  17 +++
>  shell-completion/uuidd         |  33 ++++++
>  shell-completion/uuidgen       |  15 +++
>  shell-completion/wall          |  24 ++++
>  shell-completion/wdctl         |  48 ++++++++
>  shell-completion/whereis       |  24 ++++
>  shell-completion/wipefs        |  38 ++++++
>  shell-completion/write         |  19 +++
>  97 files changed, 3512 insertions(+), 6 deletions(-)
>  create mode 100644 shell-completion/Makemodule.am
>  create mode 100644 shell-completion/addpart
>  create mode 100644 shell-completion/agetty
>  create mode 100644 shell-completion/blkdiscard
>  create mode 100644 shell-completion/blkid
>  create mode 100644 shell-completion/blockdev
>  create mode 100644 shell-completion/cal
>  create mode 100644 shell-completion/cfdisk
>  create mode 100644 shell-completion/chcpu
>  create mode 100644 shell-completion/chfn
>  create mode 100644 shell-completion/chrt
>  create mode 100644 shell-completion/chsh
>  create mode 100644 shell-completion/col
>  create mode 100644 shell-completion/colcrt
>  create mode 100644 shell-completion/colrm
>  create mode 100644 shell-completion/column
>  create mode 100644 shell-completion/ctrlaltdel
>  create mode 100644 shell-completion/cytune
>  create mode 100644 shell-completion/delpart
>  create mode 100644 shell-completion/dmesg
>  create mode 100644 shell-completion/eject
>  create mode 100644 shell-completion/fallocate
>  create mode 100644 shell-completion/fdformat
>  create mode 100644 shell-completion/fdisk
>  create mode 100644 shell-completion/findmnt
>  create mode 100644 shell-completion/flock
>  create mode 100644 shell-completion/fsck
>  create mode 100644 shell-completion/fsck.cramfs
>  create mode 100644 shell-completion/fsck.minix
>  create mode 100644 shell-completion/fsfreeze
>  create mode 100644 shell-completion/fstrim
>  create mode 100644 shell-completion/getopt
>  create mode 100644 shell-completion/hexdump
>  create mode 100644 shell-completion/hwclock
>  create mode 100644 shell-completion/ionice
>  create mode 100644 shell-completion/ipcrm
>  create mode 100644 shell-completion/ipcs
>  create mode 100644 shell-completion/isosize
>  create mode 100644 shell-completion/last
>  create mode 100644 shell-completion/ldattach
>  create mode 100644 shell-completion/logger
>  create mode 100644 shell-completion/login
>  create mode 100644 shell-completion/look
>  create mode 100644 shell-completion/losetup
>  create mode 100644 shell-completion/lsblk
>  create mode 100644 shell-completion/lscpu
>  create mode 100644 shell-completion/lslocks
>  create mode 100644 shell-completion/mcookie
>  create mode 100644 shell-completion/mesg
>  create mode 100644 shell-completion/mkfs
>  create mode 100644 shell-completion/mkfs.bfs
>  create mode 100644 shell-completion/mkfs.cramfs
>  create mode 100644 shell-completion/mkfs.minix
>  create mode 100644 shell-completion/mkswap
>  create mode 100644 shell-completion/more
>  create mode 100644 shell-completion/mountpoint
>  create mode 100644 shell-completion/namei
>  create mode 100644 shell-completion/newgrp
>  create mode 100644 shell-completion/nsenter
>  create mode 100644 shell-completion/partx
>  create mode 100644 shell-completion/pg
>  create mode 100644 shell-completion/pivot_root
>  create mode 100644 shell-completion/prlimit
>  create mode 100644 shell-completion/raw
>  create mode 100644 shell-completion/readprofile
>  create mode 100644 shell-completion/rename
>  create mode 100644 shell-completion/renice
>  create mode 100644 shell-completion/resizepart
>  create mode 100644 shell-completion/rev
>  create mode 100644 shell-completion/rtcwake
>  create mode 100644 shell-completion/script
>  create mode 100644 shell-completion/scriptreplay
>  create mode 100644 shell-completion/setarch
>  create mode 100644 shell-completion/setpriv
>  create mode 100644 shell-completion/setsid
>  create mode 100644 shell-completion/setterm
>  create mode 100644 shell-completion/sfdisk
>  create mode 100644 shell-completion/su
>  create mode 100644 shell-completion/sulogin
>  create mode 100644 shell-completion/swaplabel
>  create mode 100644 shell-completion/swapon
>  create mode 100644 shell-completion/tailf
>  create mode 100644 shell-completion/taskset
>  create mode 100644 shell-completion/tunelp
>  create mode 100644 shell-completion/ul
>  create mode 100644 shell-completion/unshare
>  create mode 100644 shell-completion/utmpdump
>  create mode 100644 shell-completion/uuidd
>  create mode 100644 shell-completion/uuidgen
>  create mode 100644 shell-completion/wall
>  create mode 100644 shell-completion/wdctl
>  create mode 100644 shell-completion/whereis
>  create mode 100644 shell-completion/wipefs
>  create mode 100644 shell-completion/write
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe util-linux" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 02/10] bash-completion: disk-utils
  2013-03-27 22:07 ` [PATCH 02/10] bash-completion: disk-utils Sami Kerola
@ 2013-03-28  1:42   ` Dave Reisner
  2013-04-01 15:54     ` Sami Kerola
  2013-03-28  9:54   ` Karel Zak
  1 sibling, 1 reply; 33+ messages in thread
From: Dave Reisner @ 2013-03-28  1:42 UTC (permalink / raw)
  To: Sami Kerola; +Cc: util-linux

On Wed, Mar 27, 2013 at 10:07:44PM +0000, Sami Kerola wrote:
> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
> ---
>  shell-completion/addpart     | 25 +++++++++++++++++++++++++
>  shell-completion/blockdev    | 44 ++++++++++++++++++++++++++++++++++++++++++++
>  shell-completion/delpart     | 19 +++++++++++++++++++
>  shell-completion/fdformat    | 11 +++++++++++
>  shell-completion/fsck        | 36 ++++++++++++++++++++++++++++++++++++
>  shell-completion/fsck.cramfs | 18 ++++++++++++++++++
>  shell-completion/fsck.minix  | 11 +++++++++++
>  shell-completion/isosize     | 17 +++++++++++++++++
>  shell-completion/mkfs        | 25 +++++++++++++++++++++++++
>  shell-completion/mkfs.bfs    | 28 ++++++++++++++++++++++++++++
>  shell-completion/mkfs.cramfs | 40 ++++++++++++++++++++++++++++++++++++++++
>  shell-completion/mkfs.minix  | 33 +++++++++++++++++++++++++++++++++
>  shell-completion/mkswap      | 36 ++++++++++++++++++++++++++++++++++++
>  shell-completion/partx       | 37 +++++++++++++++++++++++++++++++++++++
>  shell-completion/raw         | 17 +++++++++++++++++
>  shell-completion/resizepart  | 22 ++++++++++++++++++++++
>  shell-completion/swaplabel   | 28 ++++++++++++++++++++++++++++
>  17 files changed, 447 insertions(+)
>  create mode 100644 shell-completion/addpart
>  create mode 100644 shell-completion/blockdev
>  create mode 100644 shell-completion/delpart
>  create mode 100644 shell-completion/fdformat
>  create mode 100644 shell-completion/fsck
>  create mode 100644 shell-completion/fsck.cramfs
>  create mode 100644 shell-completion/fsck.minix
>  create mode 100644 shell-completion/isosize
>  create mode 100644 shell-completion/mkfs
>  create mode 100644 shell-completion/mkfs.bfs
>  create mode 100644 shell-completion/mkfs.cramfs
>  create mode 100644 shell-completion/mkfs.minix
>  create mode 100644 shell-completion/mkswap
>  create mode 100644 shell-completion/partx
>  create mode 100644 shell-completion/raw
>  create mode 100644 shell-completion/resizepart
>  create mode 100644 shell-completion/swaplabel
> 
> diff --git a/shell-completion/addpart b/shell-completion/addpart
> new file mode 100644
> index 0000000..07ebf5e
> --- /dev/null
> +++ b/shell-completion/addpart
> @@ -0,0 +1,25 @@
> +_addpart_module()
> +{
> +	local cur
> +	COMPREPLY=()
> +	cur="${COMP_WORDS[COMP_CWORD]}"
> +	case $COMP_CWORD in
> +		1)
> +			local DEVS
> +			DEVS="$(lsblk -o NAME -n -r)"
> +			OPTS="-h --help -V --version $DEVS"
> +			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )

You've defined OPTS as a simple string variable and then you're
expanding it as an array. Make sure to localize any variables you might
define in the completion function as well, or else they leak to the
user's environment (DEVS, OPTS). In general, I'd recommend *against*
using all capitalized variable names, particularly for local variables.

> +			;;
> +		2)
> +			COMPREPLY=( $(compgen -W "$((1 + $(ls $prev?* 2>/dev/null | wc -l)))" -- $cur) )

Please don't use ls to count items in a directory. It's slightly longer
winded, but bash does this just fine without forking:

 filecount=0
 files=("$prev"?*)
 [[ -e ${files[0]} ]] && filecount=${#files[*]}

This advice and the above apply to a bunch of your patches.

> +			;;
> +		3)
> +			COMPREPLY=( $(compgen -W "start" -- $cur) )
> +			;;
> +		4)
> +			COMPREPLY=( $(compgen -W "length" -- $cur) )
> +			;;
> +	esac
> +	return 0
> +}
> +complete -F _addpart_module addpart
> diff --git a/shell-completion/blockdev b/shell-completion/blockdev
> new file mode 100644
> index 0000000..82ac6c1
> --- /dev/null
> +++ b/shell-completion/blockdev
> @@ -0,0 +1,44 @@
> +_blockdev_module()
> +{
> +	local cur prev OPTS
> +	COMPREPLY=()
> +	cur="${COMP_WORDS[COMP_CWORD]}"
> +	prev="${COMP_WORDS[COMP_CWORD-1]}"
> +	DEVS="$(lsblk -o NAME -n -r)"
> +	OPTS="-h -V -q
> +		--report
> +		--getsz
> +		--setro
> +		--setrw
> +		--getro
> +		--getdiscardzeroes
> +		--getss
> +		--getpbsz
> +		--getiomin
> +		--getioopt
> +		--getalignoff
> +		--getmaxsect
> +		--getbsz
> +		--setbsz
> +		--getsize64
> +		--setra
> +		--getra
> +		--setfra
> +		--getfra
> +		--flushbufs
> +		--rereadpt
> +		$DEVS"
> +	case $prev in
> +		'--setbsz')
> +			COMPREPLY=( $(compgen -W "bytes" -- $cur) )
> +			return 0
> +			;;
> +		'--setbsz'|'--setfra')
> +			COMPREPLY=( $(compgen -W "sectors" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
> +	return 0
> +}
> +complete -F _blockdev_module blockdev
> diff --git a/shell-completion/delpart b/shell-completion/delpart
> new file mode 100644
> index 0000000..849c018
> --- /dev/null
> +++ b/shell-completion/delpart
> @@ -0,0 +1,19 @@
> +_delpart_module()
> +{
> +	local cur OPTS
> +	COMPREPLY=()
> +	cur="${COMP_WORDS[COMP_CWORD]}"
> +	case $COMP_CWORD in
> +		1)
> +			local DEVS
> +			DEVS="$(lsblk -o NAME,TYPE -n -r | awk '$2 ~ /disk/ {print "/dev/" $1}')"

  local dev typ
  while read dev typ; do
    [[ $dev = 'disk' ]] && devices+=("/dev/$dev")
  done < <(lsblk -nro name,type)

> +			OPTS="-h --help -V --version $DEVS"
> +			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
> +			;;
> +		2)
> +			COMPREPLY=( $(compgen -W "$(cat /sys/block/${prev##*/}/*/partition 2>/dev/null)" -- $cur) )

Bash has a builtin "cat" which uses mmap instead of direct reads, and is
far more efficient:

  COMPREPLY=( $(compgen -W "$(</sys/block/"${prev##*/}"/*/partition 2>/dev/null)" -- $cur) )

> +			;;
> +	esac
> +	return 0
> +}
> +complete -F _delpart_module delpart
> diff --git a/shell-completion/fdformat b/shell-completion/fdformat
> new file mode 100644
> index 0000000..f7d6a8e
> --- /dev/null
> +++ b/shell-completion/fdformat
> @@ -0,0 +1,11 @@
> +_fdformat_module()
> +{
> +	local cur OPTS
> +	COMPREPLY=()
> +	cur="${COMP_WORDS[COMP_CWORD]}"
> +	DEVS=$(ls /dev/fd[0-9]* 2>/dev/null)
> +	OPTS="-n --no-verify -h --help -V --version $DEVS"
> +	COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
> +	return 0
> +}
> +complete -F _fdformat_module fdformat
> diff --git a/shell-completion/fsck b/shell-completion/fsck
> new file mode 100644
> index 0000000..c3da5f5
> --- /dev/null
> +++ b/shell-completion/fsck
> @@ -0,0 +1,36 @@
> +_fsck_module()
> +{
> +	local cur prev OPTS DEVS
> +	COMPREPLY=()
> +	cur="${COMP_WORDS[COMP_CWORD]}"
> +	prev="${COMP_WORDS[COMP_CWORD-1]}"
> +	case $prev in
> +		'-b')
> +			COMPREPLY=( $(compgen -W "superblock" -- $cur) )
> +			return 0
> +			;;
> +		'-B')
> +			COMPREPLY=( $(compgen -W "blocksize" -- $cur) )
> +			return 0
> +			;;
> +		'-j')
> +			COMPREPLY=( $(compgen -W "external_journal" -- $cur) )
> +			return 0
> +			;;
> +		'-l'|'-L')
> +			COMPREPLY=( $(compgen -W "bad_blocks_file" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	case $cur in
> +		-*)
> +			OPTS="-p -n -y -c -f -v -b -B -j -l -L"
> +			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	DEVS="$(lsblk -o NAME -n -r | awk '{print "/dev/" $1}')"
> +	COMPREPLY=( $(compgen -W "$DEVS" -- $cur) )
> +	return 0
> +}
> +complete -F _fsck_module fsck
> diff --git a/shell-completion/fsck.cramfs b/shell-completion/fsck.cramfs
> new file mode 100644
> index 0000000..410b084
> --- /dev/null
> +++ b/shell-completion/fsck.cramfs
> @@ -0,0 +1,18 @@
> +_fsck.cramfs_module()
> +{
> +	local cur prev OPTS
> +	COMPREPLY=()
> +	cur="${COMP_WORDS[COMP_CWORD]}"
> +	prev="${COMP_WORDS[COMP_CWORD-1]}"
> +	OPTS='-v --verbose -x --destination -h --help -V --version file'
> +	case $prev in
> +		'-x'|'--destination')
> +			compopt -o filenames
> +			COMPREPLY=( $(compgen -o dirnames -- ${cur:-"/"}) )
> +			return 0
> +			;;
> +	esac
> +	COMPREPLY=( $(compgen -W "${OPTS[*]}" -S ' ' -- $cur) )
> +	return 0
> +}
> +complete -F _fsck.cramfs_module fsck.cramfs
> diff --git a/shell-completion/fsck.minix b/shell-completion/fsck.minix
> new file mode 100644
> index 0000000..f01626a
> --- /dev/null
> +++ b/shell-completion/fsck.minix
> @@ -0,0 +1,11 @@
> +_fsck.minix_module()
> +{
> +	local cur OPTS DEVS
> +	COMPREPLY=()
> +	cur="${COMP_WORDS[COMP_CWORD]}"
> +	DEVS="$(lsblk -o NAME -n -r | awk '{print "/dev/" $1}')"
> +	OPTS="-l -a -r -v -s -m -f -V --version"
> +	COMPREPLY=( $(compgen -W "${OPTS[*]} $DEVS" -- $cur) )
> +	return 0
> +}
> +complete -F _fsck.minix_module fsck.minix
> diff --git a/shell-completion/isosize b/shell-completion/isosize
> new file mode 100644
> index 0000000..2b4a499
> --- /dev/null
> +++ b/shell-completion/isosize
> @@ -0,0 +1,17 @@
> +_isosize_module()
> +{
> +	local cur prev OPTS
> +	COMPREPLY=()
> +	cur="${COMP_WORDS[COMP_CWORD]}"
> +	prev="${COMP_WORDS[COMP_CWORD-1]}"
> +	OPTS='-d --divisor -x --sectors -h --help -V --version'
> +	case $prev in
> +		'-d'|'--divisor')
> +			COMPREPLY=( $(compgen -W "number" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
> +	return 0
> +}
> +complete -F _isosize_module isosize
> diff --git a/shell-completion/mkfs b/shell-completion/mkfs
> new file mode 100644
> index 0000000..ee6a26b
> --- /dev/null
> +++ b/shell-completion/mkfs
> @@ -0,0 +1,25 @@
> +_mkfs_module()
> +{
> +	local cur prev OPTS DEVS
> +	COMPREPLY=()
> +	cur="${COMP_WORDS[COMP_CWORD]}"
> +	prev="${COMP_WORDS[COMP_CWORD-1]}"
> +	case $prev in
> +		'-t'|'--type')
> +			FSTYPES=$(for I in $(\ls /sbin/mkfs.* /usr/sbin/mkfs.* 2>/dev/null); do echo ${I##*mkfs.}; done)
> +			COMPREPLY=( $(compgen -W "$FSTYPES" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	case $cur in
> +		-*)
> +			OPTS='-t --type --verbose -h --help -V --version'
> +			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	DEVS="$(lsblk -o NAME -n -r | awk '{print "/dev/" $1}')"
> +	COMPREPLY=( $(compgen -W "$DEVS /path/to/file" -- $cur) )
> +	return 0
> +}
> +complete -F _mkfs_module mkfs
> diff --git a/shell-completion/mkfs.bfs b/shell-completion/mkfs.bfs
> new file mode 100644
> index 0000000..b1a226a
> --- /dev/null
> +++ b/shell-completion/mkfs.bfs
> @@ -0,0 +1,28 @@
> +_bfs_module()
> +{
> +	local cur prev OPTS DEVS
> +	COMPREPLY=()
> +	cur="${COMP_WORDS[COMP_CWORD]}"
> +	prev="${COMP_WORDS[COMP_CWORD-1]}"
> +	case $prev in
> +		'-N'|'--inodes')
> +			COMPREPLY=( $(compgen -W "number" -- $cur) )
> +			return 0
> +			;;
> +		'-V'|'--vname'|'-F'|'--fname')
> +			COMPREPLY=( $(compgen -W "name" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	case $cur in
> +		-*)
> +			OPTS='-N --inodes --vname --fname -v --verbose -h --help -V --version'
> +			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	DEVS="$(lsblk -o NAME -n -r | awk '{print "/dev/" $1}')"
> +	COMPREPLY=( $(compgen -W "$DEVS /path/to/file" -- $cur) )
> +	return 0
> +}
> +complete -F _bfs_module bfs
> diff --git a/shell-completion/mkfs.cramfs b/shell-completion/mkfs.cramfs
> new file mode 100644
> index 0000000..65ee988
> --- /dev/null
> +++ b/shell-completion/mkfs.cramfs
> @@ -0,0 +1,40 @@
> +_mkfs.cramfs_module()
> +{
> +	local cur prev OPTS
> +	COMPREPLY=()
> +	cur="${COMP_WORDS[COMP_CWORD]}"
> +	prev="${COMP_WORDS[COMP_CWORD-1]}"
> +	case $prev in
> +		'-b')
> +			COMPREPLY=( $(compgen -W "blksize" -- $cur) )
> +			return 0
> +			;;
> +		'-e')
> +			COMPREPLY=( $(compgen -W "edition" -- $cur) )
> +			return 0
> +			;;
> +		'-N')
> +			COMPREPLY=( $(compgen -W "big little host" -- $cur) )
> +			return 0
> +			;;
> +		'-i')
> +			COMPREPLY=( $(compgen -f -- $cur) )
> +			return 0
> +			;;
> +		'-n')
> +			COMPREPLY=( $(compgen -W "name" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	case $cur in
> +		-*)
> +			OPTS="-h -v -E -b -e -N -i -n -p -s -z"
> +			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	compopt -o filenames
> +	COMPREPLY=( $(compgen -f -- $cur) )
> +	return 0
> +}
> +complete -F _mkfs.cramfs_module mkfs.cramfs
> diff --git a/shell-completion/mkfs.minix b/shell-completion/mkfs.minix
> new file mode 100644
> index 0000000..c717b3c
> --- /dev/null
> +++ b/shell-completion/mkfs.minix
> @@ -0,0 +1,33 @@
> +_mkfs.minix_module()
> +{
> +	local cur prev OPTS
> +	COMPREPLY=()
> +	cur="${COMP_WORDS[COMP_CWORD]}"
> +	prev="${COMP_WORDS[COMP_CWORD-1]}"
> +	case $prev in
> +		'-i')
> +			COMPREPLY=( $(compgen -W "inodes" -- $cur) )
> +			return 0
> +			;;
> +		'-l')
> +			COMPREPLY=( $(compgen -W "badblocks-file" -- $cur) )
> +			return 0
> +			;;
> +		'-n')
> +			COMPREPLY=( $(compgen -W "14 30" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	case $cur in
> +		-*)
> +			OPTS="-c -i -l -n -1 -2 -3"
> +			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	local DEVS
> +	DEVS="$(lsblk -o NAME -n -r | awk '{print "/dev/" $1}')"
> +	COMPREPLY=( $(compgen -W "$DEVS" -- $cur) )
> +	return 0
> +}
> +complete -F _mkfs.minix_module mkfs.minix
> diff --git a/shell-completion/mkswap b/shell-completion/mkswap
> new file mode 100644
> index 0000000..c847aa9
> --- /dev/null
> +++ b/shell-completion/mkswap
> @@ -0,0 +1,36 @@
> +_mkswap_module()
> +{
> +	local cur prev OPTS
> +	COMPREPLY=()
> +	cur="${COMP_WORDS[COMP_CWORD]}"
> +	prev="${COMP_WORDS[COMP_CWORD-1]}"
> +	case $prev in
> +		'-p'|'--pagesize')
> +			COMPREPLY=( $(compgen -W "bytes" -- $cur) )
> +			return 0
> +			;;
> +		'-L'|'--label')
> +			COMPREPLY=( $(compgen -W "label" -- $cur) )
> +			return 0
> +			;;
> +		'-v'|'--swapversion')
> +			COMPREPLY=( $(compgen -W "1" -- $cur) )
> +			return 0
> +			;;
> +		'-U'|--uuid)
> +			COMPREPLY=( $(compgen -W "$(lsblk -n --output uuid)" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	case $cur in
> +		-*)
> +			OPTS="-c --check -f --force -p --pagesize -L  --label -v --swapversion -U --uuid -V --version -h --help"
> +			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	compopt -o filenames
> +	COMPREPLY=( $(compgen -f -- $cur) )
> +	return 0
> +}
> +complete -F _mkswap_module mkswap
> diff --git a/shell-completion/partx b/shell-completion/partx
> new file mode 100644
> index 0000000..c558d36
> --- /dev/null
> +++ b/shell-completion/partx
> @@ -0,0 +1,37 @@
> +_partx_module()
> +{
> +	local cur prev OPTS OUTPUT
> +	COMPREPLY=()
> +	OUTPUT="NR START END SECTORS SIZE NAME UUID TYPE FLAGS SCHEME"
> +	cur="${COMP_WORDS[COMP_CWORD]}"
> +	prev="${COMP_WORDS[COMP_CWORD-1]}"
> +	case $prev in
> +		'-n'|'--nr')
> +			COMPREPLY=( $(compgen -W "$(lsblk -o NAME,TYPE -n -r | awk '$2 ~ /part/ {print "/dev/" $1}')" -- $cur) )
> +			return 0
> +			;;
> +		'-o'|'--output')
> +			# FIXME: how to append to a string with compgen?
> +			compopt -o nospace
> +			COMPREPLY=( $(compgen -W "$OUTPUT" -S ',' -- $cur) )
> +			return 0
> +			;;
> +		'-t'|'--type')
> +			# FIXME: some command should list type libblkid knows.
> +			COMPREPLY=( $(compgen -W "aix bsd dos gpt mac minix sgi solaris_x86 sun ultrix unixware" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	case $cur in
> +		-*)
> +			OPTS="-a --add -d --delete -s --show -u --update -b --bytes -g --noheadings -n --nr -o --output -P --pairs -r --raw -t --type -v --verbose -h --help -V --version"
> +			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	local DEVS
> +	DEVS="$(sblk -o NAME,TYPE -n -r | awk '$2 ~ /disk/ {print "/dev/" $1}')"
> +	COMPREPLY=( $(compgen -W "$DEVS" -- $cur) )
> +	return 0
> +}
> +complete -F _partx_module partx
> diff --git a/shell-completion/raw b/shell-completion/raw
> new file mode 100644
> index 0000000..41e03f2
> --- /dev/null
> +++ b/shell-completion/raw
> @@ -0,0 +1,17 @@
> +_raw_module()
> +{
> +	local cur
> +	COMPREPLY=()
> +	cur="${COMP_WORDS[COMP_CWORD]}"
> +	case $cur in
> +		-*)
> +			local OPTS
> +			OPTS="-q --query -a --all -h --help -V --version"
> +			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	COMPREPLY=( $(compgen -W "$(ls 2>/dev/null /dev/raw/*)" -- $cur) )
> +	return 0
> +}
> +complete -F _raw_module raw
> diff --git a/shell-completion/resizepart b/shell-completion/resizepart
> new file mode 100644
> index 0000000..827638a
> --- /dev/null
> +++ b/shell-completion/resizepart
> @@ -0,0 +1,22 @@
> +_resizepart_module()
> +{
> +	local cur OPTS
> +	COMPREPLY=()
> +	cur="${COMP_WORDS[COMP_CWORD]}"
> +	case $COMP_CWORD in
> +		1)
> +			local DEVS
> +			DEVS="$(lsblk -o NAME,TYPE -n -r | awk '$2 ~ /disk/ {print "/dev/" $1}')"
> +			OPTS="-h --help -V --version $DEVS"
> +			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
> +			;;
> +		2)
> +			COMPREPLY=( $(compgen -W "$(cat /sys/block/${prev##*/}/*/partition 2>/dev/null)" -- $cur) )
> +			;;
> +		3)
> +			COMPREPLY="length"
> +			;;
> +	esac
> +	return 0
> +}
> +complete -F _resizepart_module resizepart
> diff --git a/shell-completion/swaplabel b/shell-completion/swaplabel
> new file mode 100644
> index 0000000..c857d15
> --- /dev/null
> +++ b/shell-completion/swaplabel
> @@ -0,0 +1,28 @@
> +_swaplabel_module()
> +{
> +	local cur prev OPTS
> +	COMPREPLY=()
> +	cur="${COMP_WORDS[COMP_CWORD]}"
> +	prev="${COMP_WORDS[COMP_CWORD-1]}"
> +	case $prev in
> +		'-L'|'--label')
> +			COMPREPLY=( $(compgen -W "label" -- $cur) )
> +			return 0
> +			;;
> +		'-U'|'--uuid')
> +			COMPREPLY=( $(compgen -W '$(uuidgen)' -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	case $cur in
> +		-*)
> +			OPTS="-L --label -U --uuid -h --help -V --version"
> +			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	compopt -o filenames
> +	COMPREPLY=( $(compgen -f -- $cur) )
> +	return 0
> +}
> +complete -F _swaplabel_module swaplabel
> -- 
> 1.8.2
> 
> --
> To unsubscribe from this list: send the line "unsubscribe util-linux" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 04/10] bash-completion: login-utils
  2013-03-27 22:07 ` [PATCH 04/10] bash-completion: login-utils Sami Kerola
@ 2013-03-28  1:42   ` Dave Reisner
  2013-04-01 16:05     ` Sami Kerola
  2013-03-28 10:05   ` Karel Zak
  1 sibling, 1 reply; 33+ messages in thread
From: Dave Reisner @ 2013-03-28  1:42 UTC (permalink / raw)
  To: Sami Kerola; +Cc: util-linux

On Wed, Mar 27, 2013 at 10:07:46PM +0000, Sami Kerola wrote:
> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
> ---
>  shell-completion/chfn     | 31 +++++++++++++++++++++++++++++++
>  shell-completion/chsh     | 23 +++++++++++++++++++++++
>  shell-completion/last     | 38 ++++++++++++++++++++++++++++++++++++++
>  shell-completion/login    | 27 +++++++++++++++++++++++++++
>  shell-completion/newgrp   | 16 ++++++++++++++++
>  shell-completion/su       | 45 +++++++++++++++++++++++++++++++++++++++++++++
>  shell-completion/sulogin  | 24 ++++++++++++++++++++++++
>  shell-completion/utmpdump | 17 +++++++++++++++++
>  8 files changed, 221 insertions(+)
>  create mode 100644 shell-completion/chfn
>  create mode 100644 shell-completion/chsh
>  create mode 100644 shell-completion/last
>  create mode 100644 shell-completion/login
>  create mode 100644 shell-completion/newgrp
>  create mode 100644 shell-completion/su
>  create mode 100644 shell-completion/sulogin
>  create mode 100644 shell-completion/utmpdump
> 
> diff --git a/shell-completion/chfn b/shell-completion/chfn
> new file mode 100644
> index 0000000..1c5167a
> --- /dev/null
> +++ b/shell-completion/chfn
> @@ -0,0 +1,31 @@
> +_chfn_module()
> +{
> +	local cur prev OPTS
> +	COMPREPLY=()
> +	cur="${COMP_WORDS[COMP_CWORD]}"
> +	prev="${COMP_WORDS[COMP_CWORD-1]}"
> +	case $prev in
> +		'-f'|'--full-name')
> +			COMPREPLY=( $(compgen -W "name" -- $cur) )
> +			return 0
> +			;;
> +		'-o'|'--office')
> +			COMPREPLY=( $(compgen -W "office" -- $cur) )
> +			return 0
> +			;;
> +		'-p'|'--office-phone'|'-h'|'--home-phone')
> +			COMPREPLY=( $(compgen -W "phone-nr" -- $cur) )
> +			return 0
> +			;;

I don't understand these. Given the previous argument being one of the
found flags, you're completing staticly defined strings. Why complete
anything at all?

> +	esac
> +	case $cur in
> +		-*)
> +			OPTS="-f --full-name -o --office -p --office-phone -h --home-phone -u --help -v --version"
> +			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	COMPREPLY=( $(compgen -u -- $cur) )
> +	return 0
> +}
> +complete -F _chfn_module chfn
> diff --git a/shell-completion/chsh b/shell-completion/chsh
> new file mode 100644
> index 0000000..c0a194c
> --- /dev/null
> +++ b/shell-completion/chsh
> @@ -0,0 +1,23 @@
> +_chsh_module()
> +{
> +	local cur prev OPTS
> +	COMPREPLY=()
> +	cur="${COMP_WORDS[COMP_CWORD]}"
> +	prev="${COMP_WORDS[COMP_CWORD-1]}"
> +	case $prev in
> +		'-s'|'--shell')
> +			COMPREPLY=( $(compgen -W "$(chsh -l)" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	case $cur in
> +		-*)
> +			OPTS="-s --shell -l --list-shells -V --version -u --help"
> +			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	COMPREPLY=( $(compgen -u -- $cur) )
> +	return 0
> +}
> +complete -F _chsh_module chsh
> diff --git a/shell-completion/last b/shell-completion/last
> new file mode 100644
> index 0000000..493051e
> --- /dev/null
> +++ b/shell-completion/last
> @@ -0,0 +1,38 @@
> +_last_module()
> +{
> +	local cur prev OPTS
> +	COMPREPLY=()
> +	cur="${COMP_WORDS[COMP_CWORD]}"
> +	prev="${COMP_WORDS[COMP_CWORD-1]}"
> +	case $prev in
> +		'-f')
> +			compopt -o filenames
> +			COMPREPLY=( $(compgen -f -- $cur) )
> +			return 0
> +			;;
> +		'-h')
> +			COMPREPLY=( $(compgen -A hostname -- $cur) )
> +			return 0
> +			;;
> +		'-i')
> +			COMPREPLY=( $(compgen -W "ipaddr" -- $cur) )
> +			return 0
> +			;;
> +		'-t')
> +			local TTYS
> +			TTYS=$(cd /sys/devices/virtual/tty && echo *)
> +			COMPREPLY=( $(compgen -W "$TTYS" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	case $cur in
> +		-*)
> +			OPTS="-f -h -i -l -t -y"
> +			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	COMPREPLY=( $(compgen -u -- $cur) )
> +	return 0
> +}
> +complete -F _last_module last
> diff --git a/shell-completion/login b/shell-completion/login
> new file mode 100644
> index 0000000..c075f64
> --- /dev/null
> +++ b/shell-completion/login
> @@ -0,0 +1,27 @@
> +_login_module()
> +{
> +	local cur prev OPTS
> +	COMPREPLY=()
> +	cur="${COMP_WORDS[COMP_CWORD]}"
> +	prev="${COMP_WORDS[COMP_CWORD-1]}"
> +	case $prev in
> +		'-f')
> +			COMPREPLY=( $(compgen -u -- $cur) )
> +			return 0
> +			;;
> +		'-h')
> +			COMPREPLY=( $(compgen -A hostname -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	case $cur in
> +		-*)
> +			OPTS="-p -f -h -H -V"
> +			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	COMPREPLY=( $(compgen -u -- $cur) )
> +	return 0
> +}
> +complete -F _login_module login
> diff --git a/shell-completion/newgrp b/shell-completion/newgrp
> new file mode 100644
> index 0000000..567c08c
> --- /dev/null
> +++ b/shell-completion/newgrp
> @@ -0,0 +1,16 @@
> +_newgrp_module()
> +{
> +	local cur prev OPTS
> +	COMPREPLY=()
> +	cur="${COMP_WORDS[COMP_CWORD]}"
> +	case $cur in
> +		-*)
> +			OPTS="-V --version -h --help"
> +			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	COMPREPLY=( $(compgen -g -- $cur) )
> +	return 0
> +}
> +complete -F _newgrp_module newgrp
> diff --git a/shell-completion/su b/shell-completion/su
> new file mode 100644
> index 0000000..ded4b7b
> --- /dev/null
> +++ b/shell-completion/su
> @@ -0,0 +1,45 @@
> +_su_module()
> +{
> +	local cur prev OPTS
> +	COMPREPLY=()
> +	cur="${COMP_WORDS[COMP_CWORD]}"
> +	prev="${COMP_WORDS[COMP_CWORD-1]}"
> +	case $prev in
> +		'-'|'-u'|'--user')
> +			COMPREPLY=( $(compgen -u -- $cur) )
> +			return 0
> +			;;
> +		'-g'|'--group'|'-G'|'--supp-group')
> +			COMPREPLY=( $(compgen -g -- $cur) )
> +			return 0
> +			;;
> +		'-s'|'--shell')
> +			COMPREPLY=( $(compgen -W "$(chsh -l)" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	case $cur in
> +		-*)
> +			OPTS="	-u --user
> +				-m -p --preserve-environment
> +				-g --group
> +				-G --supp-group
> +				- -l --login
> +				-c --command
> +				- -c
> +				--session-command
> +				-- -c

Please don't include the end of options marker in here. You appear to
have duplicated -c as well.

> +				-f --fast
> +				-s --shell
> +				-h --help
> +				-V --version"
> +			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	compopt -o filenames
> +	COMPREPLY=( $(compgen -f -- $cur) )
> +	return 0
> +}
> +complete -F _su_module su
> +complete -F _su_module runuser
> diff --git a/shell-completion/sulogin b/shell-completion/sulogin
> new file mode 100644
> index 0000000..9fdc20e
> --- /dev/null
> +++ b/shell-completion/sulogin
> @@ -0,0 +1,24 @@
> +_sulogin_module()
> +{
> +	local cur prev OPTS
> +	COMPREPLY=()
> +	cur="${COMP_WORDS[COMP_CWORD]}"
> +	prev="${COMP_WORDS[COMP_CWORD-1]}"
> +	case $prev in
> +		'-t'|'--timeout')
> +			COMPREPLY=( $(compgen -W "seconds" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	case $cur in
> +		-*)
> +			OPTS="-p --login-shell -t --timeout -V --version -h --help"
> +			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	compopt -o filenames
> +	COMPREPLY=( $(compgen -f -- ${cur:-"/dev/tty"}) )
> +	return 0
> +}
> +complete -F _sulogin_module sulogin
> diff --git a/shell-completion/utmpdump b/shell-completion/utmpdump
> new file mode 100644
> index 0000000..e306ef8
> --- /dev/null
> +++ b/shell-completion/utmpdump
> @@ -0,0 +1,17 @@
> +_utmpdump_module()
> +{
> +	local cur prev OPTS
> +	COMPREPLY=()
> +	cur="${COMP_WORDS[COMP_CWORD]}"
> +	case $cur in
> +		-*)
> +			OPTS="-f --follow -r --reverse -V --version -h --help"
> +			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	compopt -o filenames
> +	COMPREPLY=( $(compgen -f -- $cur) )
> +	return 0
> +}
> +complete -F _utmpdump_module utmpdump
> -- 
> 1.8.2
> 
> --
> To unsubscribe from this list: send the line "unsubscribe util-linux" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 05/10] bash-completion: misc-utils
  2013-03-27 22:07 ` [PATCH 05/10] bash-completion: misc-utils Sami Kerola
@ 2013-03-28  1:42   ` Dave Reisner
  2013-04-01 16:52     ` Sami Kerola
  0 siblings, 1 reply; 33+ messages in thread
From: Dave Reisner @ 2013-03-28  1:42 UTC (permalink / raw)
  To: Sami Kerola; +Cc: util-linux

On Wed, Mar 27, 2013 at 10:07:47PM +0000, Sami Kerola wrote:
> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
> ---
>  shell-completion/blkid   |  62 ++++++++++++++++++++++++++
>  shell-completion/cal     |  15 +++++++
>  shell-completion/findmnt | 114 +++++++++++++++++++++++++++++++++++++++++++++++
>  shell-completion/getopt  |  34 ++++++++++++++
>  shell-completion/logger  |  43 ++++++++++++++++++
>  shell-completion/look    |  24 ++++++++++
>  shell-completion/lsblk   |  60 +++++++++++++++++++++++++
>  shell-completion/lslocks |  43 ++++++++++++++++++
>  shell-completion/mcookie |  23 ++++++++++
>  shell-completion/namei   |  17 +++++++
>  shell-completion/rename  |  27 +++++++++++
>  shell-completion/uuidd   |  33 ++++++++++++++
>  shell-completion/uuidgen |  15 +++++++
>  shell-completion/whereis |  24 ++++++++++
>  shell-completion/wipefs  |  38 ++++++++++++++++
>  15 files changed, 572 insertions(+)
>  create mode 100644 shell-completion/blkid
>  create mode 100644 shell-completion/cal
>  create mode 100644 shell-completion/findmnt
>  create mode 100644 shell-completion/getopt
>  create mode 100644 shell-completion/logger
>  create mode 100644 shell-completion/look
>  create mode 100644 shell-completion/lsblk
>  create mode 100644 shell-completion/lslocks
>  create mode 100644 shell-completion/mcookie
>  create mode 100644 shell-completion/namei
>  create mode 100644 shell-completion/rename
>  create mode 100644 shell-completion/uuidd
>  create mode 100644 shell-completion/uuidgen
>  create mode 100644 shell-completion/whereis
>  create mode 100644 shell-completion/wipefs
> 
> diff --git a/shell-completion/blkid b/shell-completion/blkid
> new file mode 100644
> index 0000000..dce41e0
> --- /dev/null
> +++ b/shell-completion/blkid
> @@ -0,0 +1,62 @@
> +_blkid_module()
> +{
> +	local cur prev OPTS
> +	COMPREPLY=()
> +	cur="${COMP_WORDS[COMP_CWORD]}"
> +	prev="${COMP_WORDS[COMP_CWORD-1]}"
> +	case $prev in
> +		'-c')
> +			compopt -o filenames
> +			COMPREPLY=( $(compgen -f -- $cur) )
> +			return 0
> +			;;
> +		'-o')
> +			COMPREPLY=( $(compgen -W "value device export full" -- $cur) )
> +			return 0
> +			;;
> +		'-s')
> +			COMPREPLY=( $(compgen -W "tag" -- $cur) )
> +			return 0
> +			;;
> +		'-t')
> +			COMPREPLY=( $(compgen -W "token" -- $cur) )
> +			return 0
> +			;;
> +		'-L')
> +			COMPREPLY=( $(compgen -W "$(\ls /dev/disk/by-label/ 2>/dev/null)" -- $cur) )
> +			return 0
> +			;;
> +		'-U')
> +			COMPREPLY=( $(compgen -W "$(\ls /dev/disk/by-uuid/ 2>/dev/null)" -- $cur) )
> +			return 0
> +			;;
> +		'-s')
> +			COMPREPLY=( $(compgen -W "size" -- $cur) )
> +			return 0
> +			;;
> +		'-O')
> +			COMPREPLY=( $(compgen -W "offset" -- $cur) )
> +			return 0
> +			;;
> +		'-u')
> +			COMPREPLY=( $(compgen -W "filesystem raid crypto other nofilesystem noraid nocrypto noother" -- $cur) )
> +			return 0
> +			;;
> +		'-n')
> +			COMPREPLY=( $(compgen -W "$(awk '{print $NF}' /proc/filesystems)" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	case $cur in
> +		-*)
> +			OPTS="-c -d -h -g -o -k -s -t -l -L -U -V -p -i -S -O -u -n"
> +			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	local PARTITIONS
> +	PARTITIONS="$(for I in /sys/block/*/*/partition; do IFS='/'; DIR_ARR=($I); echo "/dev/${DIR_ARR[4]}"; done)"

You want the loop *outside* the assignment, rather than exploding the
contents into the array via echo:

  for part in /sys/block/*/*/partition; do
    IFS=/ read -ra a <<< "$part"
    partitions+=("${a[4]}")
  done

> +	COMPREPLY=( $(compgen -W "$PARTITIONS" -- $cur) )
> +	return 0
> +}
> +complete -F _blkid_module blkid
> diff --git a/shell-completion/cal b/shell-completion/cal
> new file mode 100644
> index 0000000..d50c8bb
> --- /dev/null
> +++ b/shell-completion/cal
> @@ -0,0 +1,15 @@
> +_cal_module()
> +{
> +	local cur OPTS
> +	COMPREPLY=()
> +	cur="${COMP_WORDS[COMP_CWORD]}"
> +	case $cur in
> +		-*)
> +			OPTS="-1 --one -3 --three -s --sunday -m --monday -j --julian -y --year -V --version -h --help"
> +			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	return 0
> +}
> +complete -F _cal_module cal
> diff --git a/shell-completion/findmnt b/shell-completion/findmnt
> new file mode 100644
> index 0000000..5207b97
> --- /dev/null
> +++ b/shell-completion/findmnt
> @@ -0,0 +1,114 @@
> +_findmnt_module()
> +{
> +	local cur prev OPTS
> +	COMPREPLY=()
> +	cur="${COMP_WORDS[COMP_CWORD]}"
> +	prev="${COMP_WORDS[COMP_CWORD-1]}"
> +	case $prev in
> +		'-p'|'--poll')
> +			COMPREPLY=( $(compgen -W "=list" -- $cur) )
> +			return 0
> +			;;
> +		'-w'|'--timeout')
> +			COMPREPLY=( $(compgen -W "timeout" -- $cur) )
> +			return 0
> +			;;
> +		'-d'|'--direction')
> +			COMPREPLY=( $(compgen -W "forward backward" -- $cur) )
> +			return 0
> +			;;
> +		'-F'|'--tab-file')
> +			compopt -o filenames
> +			COMPREPLY=( $(compgen -f -- $cur) )
> +			return 0
> +			;;
> +		'-N'|'--task')
> +			local TID I
> +			TID="$(for I in /proc/*/mountinfo; do IFS='/'; TID=($I); echo "${TID[2]}"; done)"

Ditto here

> +			COMPREPLY=( $(compgen -W "$TID" -- $cur) )
> +			return 0
> +			;;
> +		'-O'|'--options')
> +			local MNT_OPTS
> +			MNT_OPTS=$(awk '{ n = split($4, a, ","); for (i = 0; i <= n; i++) { mnt_opts[a[i]]=1 } } END { for (i in mnt_opts) { print i } }' /etc/mtab 2>/dev/null )

I'm not sure you want to get into this game. You're including values
from key=val pairs (e.g. the 300 in timeout=300). Regardless, no awk
required here

  declare -A mnt_opts

  while read _ _ _ optstring _; do
    IFS=, read -ra opts <<< "$optstring"
    for opt in "${opts[@]}"; do
      mnt_opts["${opt%%=*}"]=1
    done
  done </etc/mtab

  opts=("${!mnt_opts[@]}")

> +			COMPREPLY=( $(compgen -W "$MNT_OPTS" -- $cur) )
> +			return 0
> +			;;
> +		'-o'|'--output')
> +			# FIXME: how to append to a string with compgen?

I've been down this road when I wrote some of the systemd completion. I
don't think you want to go there.

> +			local OUTPUT
> +			OUTPUT="SOURCE TARGET FSTYPE OPTIONS VFS-OPTIONS
> +				FS-OPTIONS LABEL UUID PARTLABEL PARTUUID
> +				MAJ\:MIN ACTION OLD-TARGET OLD-OPTIONS
> +				SIZE AVAIL USED USE% FSROOT TID ID
> +				OPT-FIELDS PROPAGATION FREQ PASSNO"
> +			compopt -o nospace
> +			COMPREPLY=( $(compgen -W "$OUTPUT" -S ',' -- $cur) )
> +			return 0
> +			;;
> +		'-t'|'--types')
> +			local TYPES
> +			TYPES="adfs affs autofs cifs coda coherent cramfs
> +				debugfs devpts efs ext ext2 ext3 ext4 hfs
> +				hfsplus hpfs iso9660 jfs minix msdos
> +				ncpfs nfs nfs4 ntfs proc qnx4 ramfs
> +				reiserfs romfs squashfs smbfs sysv tmpfs
> +				ubifs udf ufs umsdos usbfs vfat xenix xfs
> +				xiafs"
> +			COMPREPLY=( $(compgen -W "$TYPES" -- $cur) )
> +			return 0
> +			;;
> +		'-S'|'--source')
> +			local DEV_MPOINT
> +			DEV_MPOINT=$(awk '{ print $1 }' /etc/mtab 2>/dev/null)
> +			COMPREPLY=( $(compgen -W "$DEV_MPOINT" -- $cur) )
> +			return 0
> +			;;
> +		'-T'|'--target')
> +			local DEV_MPOINT
> +			DEV_MPOINT=$(awk '{ print $2 }' /etc/mtab 2>/dev/null)
> +			COMPREPLY=( $(compgen -W "$DEV_MPOINT" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	case $cur in
> +		-*)
> +			OPTS="-s --fstab
> +				-m --mtab
> +				-k --kernel
> +				-p --poll
> +				-w --timeout
> +				-A --all
> +				-a --ascii
> +				-c --canonicalize
> +				-D --df
> +				-d --direction
> +				-e --evaluate
> +				-F --tab-file
> +				-f --first-only
> +				-i --invert
> +				-l --list
> +				-N --task
> +				-n --noheadings
> +				-u --notruncate
> +				-O --options
> +				-o --output
> +				-P --pairs
> +				-r --raw
> +				-t --types
> +				-v --nofsroot
> +				-R --submounts
> +				-S --source
> +				-T --target
> +				-h --help
> +				-V --version"
> +			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	local DEV_MPOINT
> +	DEV_MPOINT=$(awk '{ print $1, $2 }' /etc/mtab 2>/dev/null)
> +	COMPREPLY=( $(compgen -W "$DEV_MPOINT" -- $cur) )
> +	return 0
> +}
> +complete -F _findmnt_module findmnt
> diff --git a/shell-completion/getopt b/shell-completion/getopt
> new file mode 100644
> index 0000000..ea8c8e2
> --- /dev/null
> +++ b/shell-completion/getopt
> @@ -0,0 +1,34 @@
> +_getopt_module()
> +{
> +	local cur prev OPTS
> +	COMPREPLY=()
> +	cur="${COMP_WORDS[COMP_CWORD]}"
> +	prev="${COMP_WORDS[COMP_CWORD-1]}"
> +	case $prev in
> +		'-l'|'--longoptions')
> +			COMPREPLY=( $(compgen -W "longopts" -- $cur) )
> +			return 0
> +			;;
> +		'-n'|'--name')
> +			COMPREPLY=( $(compgen -W "name" -- $cur) )
> +			return 0
> +			;;
> +		'-o'|'--options')
> +			COMPREPLY=( $(compgen -W "optstring" -- $cur) )
> +			return 0
> +			;;
> +		'-s'|'--shell')
> +			COMPREPLY=( $(compgen -W "sh bash csh tcsh" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	case $cur in
> +		-*)
> +			OPTS="-a --alternative -h --help -l --longoptions -n --name -o --options -q --quiet -Q --quiet-output -s --shell -T --test -u --unquote -V --version"
> +			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	return 0
> +}
> +complete -F _getopt_module getopt
> diff --git a/shell-completion/logger b/shell-completion/logger
> new file mode 100644
> index 0000000..f572302
> --- /dev/null
> +++ b/shell-completion/logger
> @@ -0,0 +1,43 @@
> +_logger_module()
> +{
> +	local cur prev OPTS
> +	COMPREPLY=()
> +	cur="${COMP_WORDS[COMP_CWORD]}"
> +	prev="${COMP_WORDS[COMP_CWORD-1]}"
> +	case $prev in
> +		'-f'|'--file')
> +			compopt -o filenames
> +			COMPREPLY=( $(compgen -f -- $cur) )
> +			return 0
> +			;;
> +		'-n'|'--server')
> +			COMPREPLY=( $(compgen -A hostname -- $cur) )
> +			return 0
> +			;;
> +		'-P'|'--port')
> +			COMPREPLY=( $(compgen -W "$(awk '$1 ~ /^syslog$/  {split($2, a, "/"); print a[1]}' /etc/services)" -- $cur) )
> +			return 0
> +			;;
> +		'-p'|'--priority')
> +			COMPREPLY=( $(compgen -W "$(echo {auth,authpriv,cron,daemon,ftp,lpr,mail,news,security}.{alert,crit,debug,emerg,err,error})" -- $cur) )
> +			return 0
> +			;;
> +		'-t'|'--tag')
> +			COMPREPLY=( $(compgen -W "tag" -- $cur) )
> +			return 0
> +			;;
> +		'-u'|'--socket')
> +			COMPREPLY=( $(compgen -W "$(awk '$NF ~ /^\// {print $NF}' /proc/net/unix)" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	case $cur in
> +		-*)
> +			OPTS="-d --udp -i --id -f --file -h --help -n --server -P --port -p --priority -s --stderr -t --tag -u --socket -V --version"
> +			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	return 0
> +}
> +complete -F _logger_module logger
> diff --git a/shell-completion/look b/shell-completion/look
> new file mode 100644
> index 0000000..68cea56
> --- /dev/null
> +++ b/shell-completion/look
> @@ -0,0 +1,24 @@
> +_look_module()
> +{
> +	local cur prev OPTS
> +	COMPREPLY=()
> +	cur="${COMP_WORDS[COMP_CWORD]}"
> +	prev="${COMP_WORDS[COMP_CWORD-1]}"
> +	case $prev in
> +		'-t'|'--terminate')
> +			COMPREPLY=( $(compgen -W "char" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	case $cur in
> +		-*)
> +			OPTS="-a --alternative -d --alphanum -f --ignore-case -t --terminate -V --version -h --help"
> +			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	compopt -o filenames
> +	COMPREPLY=( $(compgen -f -- $cur) )
> +	return 0
> +}
> +complete -F _look_module look
> diff --git a/shell-completion/lsblk b/shell-completion/lsblk
> new file mode 100644
> index 0000000..521cead
> --- /dev/null
> +++ b/shell-completion/lsblk
> @@ -0,0 +1,60 @@
> +_lsblk_module()
> +{
> +	local cur prev OPTS MAJOR
> +	COMPREPLY=()
> +	cur="${COMP_WORDS[COMP_CWORD]}"
> +	prev="${COMP_WORDS[COMP_CWORD-1]}"
> +	case $prev in
> +		'-e'|'--exclude'|'-I'|'--include')
> +			MAJOR=$(\ls /sys/dev/block/ | sed 's/:.*//')
> +			# FIXME: how to append to a string with compgen?
> +			compopt -o nospace
> +			COMPREPLY=( $(compgen -W "$MAJOR" -S ',' -- $cur) )
> +			return 0
> +			;;
> +		'-o'|'--output')
> +			# FIXME: how to append to a string with compgen?
> +			OUTPUT="NAME KNAME MAJ:MIN FSTYPE MOUNTPOINT
> +				LABEL UUID PARTLABEL PARTUUID RA RO RM
> +				MODEL SIZE STATE OWNER GROUP MODE
> +				ALIGNMENT MIN-IO OPT-IO PHY-SEC LOG-SEC
> +				ROTA SCHED RQ-SIZE TYPE DISC-ALN
> +				DISC-GRAN DISC-MAX DISC-ZERO WSAME WWN
> +				RAND PKNAME HCTL TRAN REV VENDOR"
> +			compopt -o nospace
> +			COMPREPLY=( $(compgen -W "$OUTPUT" -S ',' -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	case $cur in
> +		-*)
> +			OPTS="-a --all
> +				-b --bytes
> +				-d --nodeps
> +				-D --discard
> +				-e --exclude
> +				-I --include
> +				-f --fs
> +				-h --help
> +				-i --ascii
> +				-m --perms
> +				-l --list
> +				-n --noheadings
> +				-o --output
> +				-P --pairs
> +				-r --raw
> +				-s --inverse
> +				-t --topology
> +				-S --scsi
> +				-h --help
> +				-V --version"
> +			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	local DEVS
> +	DEVS="$(\ls -d /sys/class/block/* | sed 's|/sys/class/block/|/dev/|g')"
> +	COMPREPLY=( $(compgen -W "$DEVS" -- $cur) )
> +	return 0
> +}
> +complete -F _lsblk_module lsblk
> diff --git a/shell-completion/lslocks b/shell-completion/lslocks
> new file mode 100644
> index 0000000..f55c17e
> --- /dev/null
> +++ b/shell-completion/lslocks
> @@ -0,0 +1,43 @@
> +_lslocks_module()
> +{
> +	local cur prev OPTS
> +	COMPREPLY=()
> +	cur="${COMP_WORDS[COMP_CWORD]}"
> +	prev="${COMP_WORDS[COMP_CWORD-1]}"
> +	case $prev in
> +		'-p'|'--pid')
> +			local PIDS
> +			# /proc/locks can have 8 to 9 fields, see commit
> +			# 55c0d16bab8cc84b72bf11cb2fdd8aa6205ac608
> +			PIDS="$(awk '{print $(NF-3)}' /proc/locks)"
> +			COMPREPLY=( $(compgen -W "$PIDS" -- $cur) )
> +			return 0
> +			;;
> +		'-o'|'--output')
> +			# FIXME: how to append to a string with compgen?
> +			local OUTPUT
> +			OUTPUT="COMMAND PID TYPE SIZE MODE M START END PATH BLOCKER"
> +			compopt -o nospace
> +			COMPREPLY=( $(compgen -W "$OUTPUT" -S ',' -- $cur) )
> +			return 0
> +			;;
> +
> +	esac
> +	case $cur in
> +		-*)
> +			OPTS="-p --pid
> +				-o --output
> +				-n --noheadings
> +				-r --raw
> +				-u --notruncate
> +				-h --help
> +				-V --version"
> +			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	compopt -o filenames
> +	COMPREPLY=( $(compgen -f -- $cur) )
> +	return 0
> +}
> +complete -F _lslocks_module lslocks
> diff --git a/shell-completion/mcookie b/shell-completion/mcookie
> new file mode 100644
> index 0000000..1c01a55
> --- /dev/null
> +++ b/shell-completion/mcookie
> @@ -0,0 +1,23 @@
> +_mcookie_module()
> +{
> +	local cur prev OPTS
> +	COMPREPLY=()
> +	cur="${COMP_WORDS[COMP_CWORD]}"
> +	prev="${COMP_WORDS[COMP_CWORD-1]}"
> +	case $prev in
> +		'-f'|'--file')
> +			compopt -o filenames
> +			COMPREPLY=( $(compgen -f -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	case $cur in
> +		-*)
> +			OPTS="-f --file -v --verbose -V --version -h --help"
> +			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	return 0
> +}
> +complete -F _mcookie_module mcookie
> diff --git a/shell-completion/namei b/shell-completion/namei
> new file mode 100644
> index 0000000..c44821c
> --- /dev/null
> +++ b/shell-completion/namei
> @@ -0,0 +1,17 @@
> +_namei_module()
> +{
> +	local cur prev OPTS
> +	COMPREPLY=()
> +	cur="${COMP_WORDS[COMP_CWORD]}"
> +	case $cur in
> +		-*)
> +			OPTS="-h --help -V --version -x --mountpoints -m --modes -o --owners -l --long -n --nosymlinks -v --vertical"
> +			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	compopt -o filenames
> +	COMPREPLY=( $(compgen -f -- $cur) )
> +	return 0
> +}
> +complete -F _namei_module namei
> diff --git a/shell-completion/rename b/shell-completion/rename
> new file mode 100644
> index 0000000..0fe4cc6
> --- /dev/null
> +++ b/shell-completion/rename
> @@ -0,0 +1,27 @@
> +_rename_module()
> +{
> +	local cur prev OPTS
> +	COMPREPLY=()
> +	cur="${COMP_WORDS[COMP_CWORD]}"
> +	case $cur in
> +		-*)
> +			OPTS="-v --verbose -s --symlink  -h --help -V --version"
> +			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	case $COMP_CWORD in
> +		1)
> +			COMPREPLY=( $(compgen -W "expression" -- $cur) )
> +			;;
> +		2)
> +			COMPREPLY=( $(compgen -W "replacement" -- $cur) )
> +			;;
> +		*)
> +			compopt -o filenames
> +			COMPREPLY=( $(compgen -f -- $cur) )
> +			;;
> +	esac
> +	return 0
> +}
> +complete -F _rename_module rename
> diff --git a/shell-completion/uuidd b/shell-completion/uuidd
> new file mode 100644
> index 0000000..23c1a49
> --- /dev/null
> +++ b/shell-completion/uuidd
> @@ -0,0 +1,33 @@
> +_uuidd_module()
> +{
> +	local cur prev OPTS
> +	COMPREPLY=()
> +	cur="${COMP_WORDS[COMP_CWORD]}"
> +	prev="${COMP_WORDS[COMP_CWORD-1]}"
> +	case $prev in
> +		'-p'|'--pid'|'-s'|'--socket')
> +			compopt -o filenames
> +			COMPREPLY=( $(compgen -f -- $cur) )
> +			return 0
> +			;;
> +		'-T'|'--timeout')
> +			compopt -o filenames
> +			COMPREPLY=( $(compgen -W "timeout" -- $cur) )
> +			return 0
> +			;;
> +		'-n'|'--uuids')
> +			compopt -o filenames
> +			COMPREPLY=( $(compgen -W "number" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	case $cur in
> +		-*)
> +			OPTS="-p --pid -s --socket -T --timeout -k --kill -r --random -t --time -n --uuids -P --no-pid -F --no-fork -S --socket-activation -d --debug -q --quiet -V --version -h --help"
> +			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	return 0
> +}
> +complete -F _uuidd_module uuidd
> diff --git a/shell-completion/uuidgen b/shell-completion/uuidgen
> new file mode 100644
> index 0000000..d9edde9
> --- /dev/null
> +++ b/shell-completion/uuidgen
> @@ -0,0 +1,15 @@
> +_uuidgen_module()
> +{
> +	local cur OPTS
> +	COMPREPLY=()
> +	cur="${COMP_WORDS[COMP_CWORD]}"
> +	case $cur in
> +		-*)
> +			OPTS="-r --random -t --time -V --version -h --help"
> +			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	return 0
> +}
> +complete -F _uuidgen_module uuidgen
> diff --git a/shell-completion/whereis b/shell-completion/whereis
> new file mode 100644
> index 0000000..96e4117
> --- /dev/null
> +++ b/shell-completion/whereis
> @@ -0,0 +1,24 @@
> +_whereis_module()
> +{
> +	local cur prev OPTS
> +	COMPREPLY=()
> +	cur="${COMP_WORDS[COMP_CWORD]}"
> +	prev="${COMP_WORDS[COMP_CWORD-1]}"
> +	case $prev in
> +		'-B'|'-M'|'-S')
> +			compopt -o filenames
> +			COMPREPLY=( $(compgen -o dirnames -- ${cur:-"/"}) )
> +			return 0
> +			;;
> +	esac
> +	case $cur in
> +		-*)
> +			OPTS="-b -B -m -M -s -S -f -u -l"
> +			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	COMPREPLY=( $(compgen -W "file" -- $cur) )
> +	return 0
> +}
> +complete -F _whereis_module whereis
> diff --git a/shell-completion/wipefs b/shell-completion/wipefs
> new file mode 100644
> index 0000000..427f47b
> --- /dev/null
> +++ b/shell-completion/wipefs
> @@ -0,0 +1,38 @@
> +_wipefs_module()
> +{
> +	local cur prev OPTS
> +	COMPREPLY=()
> +	cur="${COMP_WORDS[COMP_CWORD]}"
> +	prev="${COMP_WORDS[COMP_CWORD-1]}"
> +	case $prev in
> +		'-o'|'--offset')
> +			COMPREPLY=( $(compgen -W "offset" -- $cur) )
> +			return 0
> +			;;
> +		'-t'|'--types')
> +			local TYPES
> +			TYPES="adfs affs autofs cifs coda coherent cramfs
> +				debugfs devpts efs ext ext2 ext3 ext4 hfs
> +				hfsplus hpfs iso9660 jfs minix msdos
> +				ncpfs nfs nfs4 ntfs proc qnx4 ramfs
> +				reiserfs romfs squashfs smbfs sysv tmpfs
> +				ubifs udf ufs umsdos usbfs vfat xenix xfs
> +				xiafs"
> +			COMPREPLY=( $(compgen -W "$TYPES" -- $cur) )
> +			return 0
> +			;;
> +
> +	esac
> +	case $cur in
> +		-*)
> +			OPTS="-a --all -f --force -h --help -n --no-actn -o --offset -p --parsable -q --quiet -t --types -V --version"
> +			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	local DEVS
> +	DEVS="$(\ls -d /sys/class/block/* | sed 's|/sys/class/block/|/dev/|g')"
> +	COMPREPLY=( $(compgen -W "$DEVS" -- $cur) )
> +	return 0
> +}
> +complete -F _wipefs_module wipefs
> -- 
> 1.8.2
> 
> --
> To unsubscribe from this list: send the line "unsubscribe util-linux" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 00/10] [pull] bash-completion
  2013-03-27 22:07 [PATCH 00/10] [pull] bash-completion Sami Kerola
                   ` (10 preceding siblings ...)
  2013-03-28  1:42 ` [PATCH 00/10] [pull] bash-completion Dave Reisner
@ 2013-03-28  9:37 ` Karel Zak
  2013-03-31 23:49   ` Sami Kerola
  2013-04-01 15:44   ` Sami Kerola
  2013-04-05 14:11 ` Karel Zak
  12 siblings, 2 replies; 33+ messages in thread
From: Karel Zak @ 2013-03-28  9:37 UTC (permalink / raw)
  To: Sami Kerola; +Cc: util-linux

On Wed, Mar 27, 2013 at 10:07:42PM +0000, Sami Kerola wrote:
> > Some FIXME's are slightly more difficult to fix.  For example I do not
> > know how to get list of possible TERM values distribution agnostic way. 

 Well, I think we can start with some nice hardcoded list..

> > And with 'wdctl' I have no how to determine flags.  Same goes for SELinux

    wdctl --flags-only -o FLAG 
    
 returns currently supported flags (by the device), the complete list of 
 the flags is:

	CARDRESET
	EXTERN1
	EXTERN2
	FANFAULT
	KEEPALIVEPING
	MAGICCLOSE
	OVERHEAT
	POWEROVER
	POWERUNDER
	PRETIMEOUT
	SETTIMEOUT
	ALARMONLY

I think it's fine to use this hardcoded list.

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 02/10] bash-completion: disk-utils
  2013-03-27 22:07 ` [PATCH 02/10] bash-completion: disk-utils Sami Kerola
  2013-03-28  1:42   ` Dave Reisner
@ 2013-03-28  9:54   ` Karel Zak
  2013-04-01 17:00     ` Sami Kerola
  1 sibling, 1 reply; 33+ messages in thread
From: Karel Zak @ 2013-03-28  9:54 UTC (permalink / raw)
  To: Sami Kerola; +Cc: util-linux

On Wed, Mar 27, 2013 at 10:07:44PM +0000, Sami Kerola wrote:
> diff --git a/shell-completion/mkfs b/shell-completion/mkfs
> new file mode 100644
> index 0000000..ee6a26b
> --- /dev/null
> +++ b/shell-completion/mkfs
> @@ -0,0 +1,25 @@
> +_mkfs_module()
> +{
> +	local cur prev OPTS DEVS
> +	COMPREPLY=()
> +	cur="${COMP_WORDS[COMP_CWORD]}"
> +	prev="${COMP_WORDS[COMP_CWORD-1]}"
> +	case $prev in
> +		'-t'|'--type')
> +			FSTYPES=$(for I in $(\ls /sbin/mkfs.* /usr/sbin/mkfs.* 2>/dev/null); do echo ${I##*mkfs.}; done)

The /sbin and /usr/sbin are the same directories on many systems, so you
need to de-duplicate the list or use only one directory (I suggest /sbin).

> diff --git a/shell-completion/mkswap b/shell-completion/mkswap
> new file mode 100644
> index 0000000..c847aa9
> --- /dev/null
> +++ b/shell-completion/mkswap
> @@ -0,0 +1,36 @@
> +_mkswap_module()
> +{
> +	local cur prev OPTS
> +	COMPREPLY=()
> +	cur="${COMP_WORDS[COMP_CWORD]}"
> +	prev="${COMP_WORDS[COMP_CWORD-1]}"
> +	case $prev in
> +		'-p'|'--pagesize')
> +			COMPREPLY=( $(compgen -W "bytes" -- $cur) )
> +			return 0
> +			;;
> +		'-L'|'--label')
> +			COMPREPLY=( $(compgen -W "label" -- $cur) )
> +			return 0
> +			;;
> +		'-v'|'--swapversion')
> +			COMPREPLY=( $(compgen -W "1" -- $cur) )
> +			return 0
> +			;;
> +		'-U'|--uuid)
> +			COMPREPLY=( $(compgen -W "$(lsblk -n --output uuid)" -- $cur) )

 The -U|--uuid is not a device identifier here, it's UUID you want to
 use for the new swap superblock. So ask lsblk does not make sense. 
 (It will generate duplicate UUIDS.)

 If you do not specify -U then mkswap will generate a new. 

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 03/10] bash-completion: fdisks
  2013-03-27 22:07 ` [PATCH 03/10] bash-completion: fdisks Sami Kerola
@ 2013-03-28 10:01   ` Karel Zak
  0 siblings, 0 replies; 33+ messages in thread
From: Karel Zak @ 2013-03-28 10:01 UTC (permalink / raw)
  To: Sami Kerola; +Cc: util-linux

On Wed, Mar 27, 2013 at 10:07:45PM +0000, Sami Kerola wrote:
> +++ b/shell-completion/fdisk
> @@ -0,0 +1,41 @@
> +_fdisk_module()
> +{
> +	local cur prev OPTS
> +	COMPREPLY=()
> +	cur="${COMP_WORDS[COMP_CWORD]}"
> +	prev="${COMP_WORDS[COMP_CWORD-1]}"
> +	case $prev in
> +		'-s')
> +			local PARTITIONS
> +			PARTITIONS="$(for I in /sys/block/*/*/partition; do IFS='/'; DIR_ARR=($I); echo "/dev/${DIR_ARR[4]}"; done)"
> +			COMPREPLY=( $(compgen -W "$PARTITIONS" -- $cur) )
> +			return 0
> +			;;
> +		'-b')
> +			COMPREPLY=( $(compgen -W "512 1024 2048 4096" -- $cur) )
> +			return 0
> +			;;
> +		'-c')
> +			COMPREPLY=( $(compgen -W "dos nondos" -- $cur) )

 optional arguments, it means the result has to be "-c=dos" or
 "-c=nondos" and no blank spaces.

 I guess you need to use -o nospace for compgen or so.

> +			return 0
> +			;;
> +		'-u')
> +			COMPREPLY=( $(compgen -W "cylinders sectors" -- $cur) )
> +			return 0

 the same situation, -u=

> +			;;
> +		'-C'|'-H'|'-S')
> +			COMPREPLY=( $(compgen -W "number" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	case $cur in
> +		-*)
> +			OPTS="-l -s -b -c -h -u -v -C -H -S"
> +			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	COMPREPLY=( $(compgen -W "$(lsblk -o NAME,TYPE -n -r | awk '$2 ~ /disk/ {print "/dev/" $1}')" -- $cur) )
> +	return 0
> +}

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 04/10] bash-completion: login-utils
  2013-03-27 22:07 ` [PATCH 04/10] bash-completion: login-utils Sami Kerola
  2013-03-28  1:42   ` Dave Reisner
@ 2013-03-28 10:05   ` Karel Zak
  2013-04-01 16:06     ` Sami Kerola
  1 sibling, 1 reply; 33+ messages in thread
From: Karel Zak @ 2013-03-28 10:05 UTC (permalink / raw)
  To: Sami Kerola; +Cc: util-linux

On Wed, Mar 27, 2013 at 10:07:46PM +0000, Sami Kerola wrote:
> +++ b/shell-completion/login
> @@ -0,0 +1,27 @@
> +_login_module()

 Unnecessary module, nobody calls login(1) from command line, it does
 not work, it's not supported :-)

> +++ b/shell-completion/sulogin
> @@ -0,0 +1,24 @@
> +_sulogin_module()

 the same thing, unnecessary

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 08/10] bash-completion: term-utils
  2013-03-27 22:07 ` [PATCH 08/10] bash-completion: term-utils Sami Kerola
@ 2013-03-28 10:06   ` Karel Zak
  0 siblings, 0 replies; 33+ messages in thread
From: Karel Zak @ 2013-03-28 10:06 UTC (permalink / raw)
  To: Sami Kerola; +Cc: util-linux

On Wed, Mar 27, 2013 at 10:07:50PM +0000, Sami Kerola wrote:
> +++ b/shell-completion/agetty
> @@ -0,0 +1,70 @@
> +_agetty_module()

 You don't want to use agetty from command line :-)

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 01/10] bash-completion: add bash completetion configure option
  2013-03-27 22:07 ` [PATCH 01/10] bash-completion: add bash completetion configure option Sami Kerola
@ 2013-03-28 11:22   ` Sami Kerola
  2013-03-29  9:42     ` Karel Zak
  0 siblings, 1 reply; 33+ messages in thread
From: Sami Kerola @ 2013-03-28 11:22 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

On Wed, Mar 27, 2013 at 10:07 PM, Sami Kerola <kerolasa@iki.fi> wrote:
> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
> ---
>  Makefile.am                    |  5 +++++
>  configure.ac                   | 13 +++++++++++++
>  shell-completion/Makemodule.am |  1 +
>  3 files changed, 19 insertions(+)
>  create mode 100644 shell-completion/Makemodule.am

Do we need './configure
--disable-overwriting-bash-compilation-package-files'? I realized some
of the files I wrote will conflicting with the

http://anonscm.debian.org/gitweb/?p=bash-completion/bash-completion.git;a=tree;f=completions

-- 
   Sami Kerola
   http://www.iki.fi/kerolasa/

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 01/10] bash-completion: add bash completetion configure option
  2013-03-28 11:22   ` Sami Kerola
@ 2013-03-29  9:42     ` Karel Zak
  0 siblings, 0 replies; 33+ messages in thread
From: Karel Zak @ 2013-03-29  9:42 UTC (permalink / raw)
  To: kerolasa; +Cc: util-linux, kerolasa, bash-completion-devel

On Thu, Mar 28, 2013 at 11:22:46AM +0000, Sami Kerola wrote:
> On Wed, Mar 27, 2013 at 10:07 PM, Sami Kerola <kerolasa@iki.fi> wrote:
> > Signed-off-by: Sami Kerola <kerolasa@iki.fi>
> > ---
> >  Makefile.am                    |  5 +++++
> >  configure.ac                   | 13 +++++++++++++
> >  shell-completion/Makemodule.am |  1 +
> >  3 files changed, 19 insertions(+)
> >  create mode 100644 shell-completion/Makemodule.am
> 
> Do we need './configure
> --disable-overwriting-bash-compilation-package-files'?

 Hmm... not sure, it's distro specific decision/policy.

 Maybe we need --disable-bash-completion, it should enough.

> I realized some of the files I wrote will conflicting with the

 Which files? We can add some info to ReleaseNotes to make it easy for
 distros.

> http://anonscm.debian.org/gitweb/?p=bash-completion/bash-completion.git;a=tree;f=completions

 What about to use .ul (or .util-linux) suffix for the conflicting
 files and in the bash-completion package check for these files and use
 it if exists? See for example:

  http://anonscm.debian.org/gitweb/?p=bash-completion/bash-completion.git;a=blob;f=completions/umount

 CC: to bash-completion-devel@lists.alioth.debian.org, maybe they
 already have any idea how to resolve the conflicts between packages.

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 07/10] bash-completion: sys-utils
  2013-03-27 22:07 ` [PATCH 07/10] bash-completion: sys-utils Sami Kerola
@ 2013-03-29 16:33   ` Karel Zak
  2013-04-01 16:32     ` Sami Kerola
  2013-04-05 14:44   ` Karel Zak
  1 sibling, 1 reply; 33+ messages in thread
From: Karel Zak @ 2013-03-29 16:33 UTC (permalink / raw)
  To: Sami Kerola; +Cc: util-linux

On Wed, Mar 27, 2013 at 10:07:49PM +0000, Sami Kerola wrote:
> @@ -0,0 +1,25 @@
> +_blkdiscard_module()
> +{
> +	local cur prev OPTS
> +	COMPREPLY=()
> +	cur="${COMP_WORDS[COMP_CWORD]}"
> +	prev="${COMP_WORDS[COMP_CWORD-1]}"
> +	case $prev in
> +		'-o'|'--offset'|'-l'|'--length')
> +			COMPREPLY=( $(compgen -W "num" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	case $cur in
> +		-*)
> +			OPTS="-o --offset -l --length -s --secure -v --verbose -h --help -V --version"
> +			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	local DEVS
> +	DEVS="$(\ls -d /sys/class/block/* | sed 's|/sys/class/block/|/dev/|g')"

It does not look like the right way how to generate the paths, because
/sys/class/block/ contains also paths to unassociated loop devices and
all the paths are based on kernel device names (e.g. dm-X).

I have add --paths to lsblk(8), so now you can use:

 lsblk -p -o NAME -n -l

to list the paths, for exmaple:
 
 /dev/sda
 /dev/sda1
 /dev/sda2
 /dev/sda3
 /dev/sda4
 /dev/sda5
 /dev/sda6
 /dev/mapper/luks-10d813de-fa82-4f67-a86c-23d5d0e7c30e
 /dev/sdb
 /dev/sr0

it would be nice to use this solution everywhere.

> +_eject_module()
> +{
 ....
> +	DEVS="$(for I in /sys/class/block/*/removable; do
> +		if [ $(cat $I) -ne 0 ]; then
> +			OLD_IFS=$IFS
> +			IFS='/';
> +			ARR=($I)
> +			echo "/dev/${ARR[4]}"
> +			IFS=$OLD_IFS
> +		fi
> +	done)"

 lsblk -rpn -o RM,NAME | awk '/^1/ { print $2 }'

 The common rule is to not read data from /sys if possible.

> diff --git a/shell-completion/fstrim b/shell-completion/fstrim
> new file mode 100644
> index 0000000..87cb050
> --- /dev/null
> +++ b/shell-completion/fstrim
> @@ -0,0 +1,25 @@
> +_fstrim_module()
> +{
> +	local cur prev OPTS
> +	COMPREPLY=()
> +	cur="${COMP_WORDS[COMP_CWORD]}"
> +	prev="${COMP_WORDS[COMP_CWORD-1]}"
> +	case $prev in
> +		'-o'|'--offset'|'-l'|'--length'|'-m'|'--minimum')
> +			COMPREPLY=( $(compgen -W "num" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	case $cur in
> +		-*)
> +			OPTS="-o --offset -l --length -m --minimum -v --verbose -h --help -V --version"
> +			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
> +			return 0
> +			;;
> +	esac
> +	local MPOINTS
> +	MPOINTS=$(awk '{if ($1 ~ /^\//){print $2}}' /etc/mtab 2>/dev/null)

 The same problem, don't read mtab directly (for example because
 some chars could be escaped...). Use:

   findmnt -rno SOURCE | grep '/dev'

    Karel
 

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 00/10] [pull] bash-completion
  2013-03-28  9:37 ` Karel Zak
@ 2013-03-31 23:49   ` Sami Kerola
  2013-04-01 15:44   ` Sami Kerola
  1 sibling, 0 replies; 33+ messages in thread
From: Sami Kerola @ 2013-03-31 23:49 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux

[-- Attachment #1: Type: text/plain, Size: 28327 bytes --]

On 28 March 2013 09:37, Karel Zak <kzak@redhat.com> wrote:

> On Wed, Mar 27, 2013 at 10:07:42PM +0000, Sami Kerola wrote:
> > > Some FIXME's are slightly more difficult to fix.  For example I do not
> > > know how to get list of possible TERM values distribution agnostic way.
>
>  Well, I think we can start with some nice hardcoded list..
>
> > > And with 'wdctl' I have no how to determine flags.  Same goes for
> SELinux
>
>     wdctl --flags-only -o FLAG
>
>  returns currently supported flags (by the device), the complete list of
>  the flags is:
>
>         CARDRESET
>         EXTERN1
>         EXTERN2
>         FANFAULT
>         KEEPALIVEPING
>         MAGICCLOSE
>         OVERHEAT
>         POWEROVER
>         POWERUNDER
>         PRETIMEOUT
>         SETTIMEOUT
>         ALARMONLY
>
> I think it's fine to use this hardcoded list.
>

Hello,

I did something to some of the stuff that was mentioned by Dave & Karel.
The following changes can be found from git://
github.com/kerolasa/lelux-utiliteetit.git shell-completion.

diff --git a/shell-completion/Makemodule.am b/shell-completion/Makemodule.am
index 0bb8652..b657604 100644
--- a/shell-completion/Makemodule.am
+++ b/shell-completion/Makemodule.am
@@ -90,10 +90,6 @@ if BUILD_LAST
 dist_bashcompletion_DATA += \
 	shell-completion/last
 endif
-if BUILD_LOGIN
-dist_bashcompletion_DATA += \
-	shell-completion/login
-endif
 if BUILD_NEWGRP
 dist_bashcompletion_DATA += \
 	shell-completion/newgrp
@@ -102,10 +98,6 @@ if BUILD_SU
 dist_bashcompletion_DATA += \
 	shell-completion/su
 endif
-if BUILD_SULOGIN
-dist_bashcompletion_DATA += \
-	shell-completion/sulogin
-endif
 if BUILD_UTMPDUMP
 dist_bashcompletion_DATA += \
 	shell-completion/utmpdump
@@ -222,10 +214,6 @@ endif
 # ...sys-utils

 # term-utils...
-if BUILD_AGETTY
-dist_bashcompletion_DATA += \
-	shell-completion/agetty
-endif
 if BUILD_MESG
 dist_bashcompletion_DATA += \
 	shell-completion/mesg
diff --git a/shell-completion/addpart b/shell-completion/addpart
index 07ebf5e..1fa34a7 100644
--- a/shell-completion/addpart
+++ b/shell-completion/addpart
@@ -1,6 +1,6 @@
 _addpart_module()
 {
-	local cur
+	local cur prev
 	COMPREPLY=()
 	cur="${COMP_WORDS[COMP_CWORD]}"
 	case $COMP_CWORD in
@@ -11,7 +11,7 @@ _addpart_module()
 			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
 			;;
 		2)
-			COMPREPLY=( $(compgen -W "$((1 + $(ls $prev?* 2>/dev/null | wc
-l)))" -- $cur) )
+			# FIXME: how to determine next free partition number
 			;;
 		3)
 			COMPREPLY=( $(compgen -W "start" -- $cur) )
diff --git a/shell-completion/agetty b/shell-completion/agetty
deleted file mode 100644
index dc37a68..0000000
--- a/shell-completion/agetty
+++ /dev/null
@@ -1,70 +0,0 @@
-_agetty_module()
-{
-	local cur prev OPTS
-	COMPREPLY=()
-	cur="${COMP_WORDS[COMP_CWORD]}"
-	prev="${COMP_WORDS[COMP_CWORD-1]}"
-	case $prev in
-		'-a'|'--autologin')
-			COMPREPLY=( $(compgen -u -- $cur) )
-			return 0
-			;;
-		'-o'|'--issue-file'|'-I'|'--login-program')
-			compopt -o filenames
-			COMPREPLY=( $(compgen -f -- $cur) )
-			return 0
-			;;
-		'-I'|'--init-string'|'--erase-chars'|'--kill-chars')
-			compopt -o filenames
-			COMPREPLY=( $(compgen -W "string" -- $cur) )
-			return 0
-			;;
-		'-o'|'--login-options')
-			COMPREPLY=( $(compgen -W "login-options" -- $cur) )
-			return 0
-			;;
-		'-t'|'--timeout')
-			COMPREPLY=( $(compgen -W "seconds" -- $cur) )
-			return 0
-			;;
-	esac
-	case $cur in
-		-*)
-			OPTS="-8 --8bits
-				-a --autologin
-				-c --noreset
-				-f --issue-file
-				-h --flow-control
-				-H --host
-				-i --noissue
-				-I --init-string
-				-l --login-program
-				-L --local-line
-				-m --extract-baud
-				-n --skip-login
-				-o --login-options
-				-p --loginpause
-				-R --hangup
-				-s --keep-baud
-				-t --timeout
-				-U --detect-case
-				-w --wait-cr
-				   --nocleardo
-				   --nohintsdo
-				   --nonewlinedo
-				   --no-hostnameno
-				   --long-hostnameshow
-				   --erase-chars
-				   --kill-chars
-				-h --help
-				-V --version"
-			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
-			return 0
-			;;
-	esac
-	local BAUD_RATES
-	BAUD_RATES="75 110 300 1200 2400 4800 9600 19200 38400 57600 115200"
-	COMPREPLY=( $(compgen -W "$BAUD_RATES $(echo /dev/tty*)" -- $cur) )
-	return 0
-}
-complete -F _agetty_module agetty
diff --git a/shell-completion/blkdiscard b/shell-completion/blkdiscard
index e907a1b..7d85bce 100644
--- a/shell-completion/blkdiscard
+++ b/shell-completion/blkdiscard
@@ -18,7 +18,7 @@ _blkdiscard_module()
 			;;
 	esac
 	local DEVS
-	DEVS="$(\ls -d /sys/class/block/* | sed 's|/sys/class/block/|/dev/|g')"
+	DEVS="$(lsblk -o NAME -n -r -p)"
 	COMPREPLY=( $(compgen -W "$DEVS" -- $cur) )
 	return 0
 }
diff --git a/shell-completion/blkid b/shell-completion/blkid
index dce41e0..05e337b 100644
--- a/shell-completion/blkid
+++ b/shell-completion/blkid
@@ -23,11 +23,11 @@ _blkid_module()
 			return 0
 			;;
 		'-L')
-			COMPREPLY=( $(compgen -W "$(\ls /dev/disk/by-label/ 2>/dev/null)" -- $cur) )
+			COMPREPLY=( $(compgen -W "$(cd /dev/disk/by-label/ 2>/dev/null &&
echo *)" -- $cur) )
 			return 0
 			;;
 		'-U')
-			COMPREPLY=( $(compgen -W "$(\ls /dev/disk/by-uuid/ 2>/dev/null)" -- $cur) )
+			COMPREPLY=( $(compgen -W "$(cd /dev/disk/by-uuid/ 2>/dev/null &&
echo *)" -- $cur) )
 			return 0
 			;;
 		'-s')
@@ -55,7 +55,7 @@ _blkid_module()
 			;;
 	esac
 	local PARTITIONS
-	PARTITIONS="$(for I in /sys/block/*/*/partition; do IFS='/';
DIR_ARR=($I); echo "/dev/${DIR_ARR[4]}"; done)"
+	PARTITIONS="$(lsblk -o NAME,TYPE -n -r -p | awk '$2 ~ /part/ {print $1}')"
 	COMPREPLY=( $(compgen -W "$PARTITIONS" -- $cur) )
 	return 0
 }
diff --git a/shell-completion/cfdisk b/shell-completion/cfdisk
index 8da32fd..3725645 100644
--- a/shell-completion/cfdisk
+++ b/shell-completion/cfdisk
@@ -25,7 +25,7 @@ _cfdisk_module()
 			return 0
 			;;
 	esac
-	COMPREPLY=( $(compgen -W "$(lsblk -o NAME,TYPE -n -r | awk '$2 ~
/disk/ {print "/dev/" $1}')" -- $cur) )
+	COMPREPLY=( $(compgen -W "$(lsblk -o NAME,TYPE -n -r -p | awk '$2 ~
/disk/ {print $1}')" -- $cur) )
 	return 0
 }
 complete -F _cfdisk_module cfdisk
diff --git a/shell-completion/chfn b/shell-completion/chfn
index 1c5167a..a8eaee5 100644
--- a/shell-completion/chfn
+++ b/shell-completion/chfn
@@ -1,23 +1,8 @@
 _chfn_module()
 {
-	local cur prev OPTS
+	local cur OPTS
 	COMPREPLY=()
 	cur="${COMP_WORDS[COMP_CWORD]}"
-	prev="${COMP_WORDS[COMP_CWORD-1]}"
-	case $prev in
-		'-f'|'--full-name')
-			COMPREPLY=( $(compgen -W "name" -- $cur) )
-			return 0
-			;;
-		'-o'|'--office')
-			COMPREPLY=( $(compgen -W "office" -- $cur) )
-			return 0
-			;;
-		'-p'|'--office-phone'|'-h'|'--home-phone')
-			COMPREPLY=( $(compgen -W "phone-nr" -- $cur) )
-			return 0
-			;;
-	esac
 	case $cur in
 		-*)
 			OPTS="-f --full-name -o --office -p --office-phone -h --home-phone
-u --help -v --version"
diff --git a/shell-completion/chrt b/shell-completion/chrt
index 08912c9..b85775a 100644
--- a/shell-completion/chrt
+++ b/shell-completion/chrt
@@ -25,7 +25,7 @@ _chrt_module()
 			;;
 	esac
 	local PIDS
-	PIDS=$(\ls -d /proc/[0-9]* | sed 's|/proc/||')
+	PIDS=$(for I in /proc/[0-9]*; do echo ${I##"/proc/"}; done)
 	COMPREPLY=( $(compgen -W "$PIDS" -- $cur) )
 	return 0
 }
diff --git a/shell-completion/delpart b/shell-completion/delpart
index 849c018..a9cd3b7 100644
--- a/shell-completion/delpart
+++ b/shell-completion/delpart
@@ -1,16 +1,17 @@
 _delpart_module()
 {
-	local cur OPTS
+	local cur prev OPTS
 	COMPREPLY=()
 	cur="${COMP_WORDS[COMP_CWORD]}"
 	case $COMP_CWORD in
 		1)
 			local DEVS
-			DEVS="$(lsblk -o NAME,TYPE -n -r | awk '$2 ~ /disk/ {print "/dev/" $1}')"
+			DEVS="$(lsblk -o NAME,TYPE -n -p -r | awk '$2 ~ /disk/ {print $1}')"
 			OPTS="-h --help -V --version $DEVS"
 			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
 			;;
 		2)
+			prev="${COMP_WORDS[COMP_CWORD-1]}"
 			COMPREPLY=( $(compgen -W "$(cat /sys/block/${prev##*/}/*/partition
2>/dev/null)" -- $cur) )
 			;;
 	esac
diff --git a/shell-completion/fdformat b/shell-completion/fdformat
index f7d6a8e..4ad1c3d 100644
--- a/shell-completion/fdformat
+++ b/shell-completion/fdformat
@@ -3,7 +3,7 @@ _fdformat_module()
 	local cur OPTS
 	COMPREPLY=()
 	cur="${COMP_WORDS[COMP_CWORD]}"
-	DEVS=$(ls /dev/fd[0-9]* 2>/dev/null)
+	DEVS=$(for I in echo /dev/fd*; do if [ -e $I ]; then echo $I; fi; done)
 	OPTS="-n --no-verify -h --help -V --version $DEVS"
 	COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
 	return 0
diff --git a/shell-completion/fdisk b/shell-completion/fdisk
index ccf2015..a8a2a37 100644
--- a/shell-completion/fdisk
+++ b/shell-completion/fdisk
@@ -7,7 +7,7 @@ _fdisk_module()
 	case $prev in
 		'-s')
 			local PARTITIONS
-			PARTITIONS="$(for I in /sys/block/*/*/partition; do IFS='/';
DIR_ARR=($I); echo "/dev/${DIR_ARR[4]}"; done)"
+			PARTITIONS="$(lsblk -o NAME,TYPE -n -r -p | awk '$2 ~ /part/ {print $1}')"
 			COMPREPLY=( $(compgen -W "$PARTITIONS" -- $cur) )
 			return 0
 			;;
@@ -35,7 +35,7 @@ _fdisk_module()
 			return 0
 			;;
 	esac
-	COMPREPLY=( $(compgen -W "$(lsblk -o NAME,TYPE -n -r | awk '$2 ~
/disk/ {print "/dev/" $1}')" -- $cur) )
+	COMPREPLY=( $(compgen -W "$(lsblk -o NAME,TYPE -n -r -p | awk '$2 ~
/disk/ {print $1}')" -- $cur) )
 	return 0
 }
 complete -F _fdisk_module fdisk
diff --git a/shell-completion/findmnt b/shell-completion/findmnt
index 5207b97..413d36a 100644
--- a/shell-completion/findmnt
+++ b/shell-completion/findmnt
@@ -29,9 +29,16 @@ _findmnt_module()
 			return 0
 			;;
 		'-O'|'--options')
-			local MNT_OPTS
-			MNT_OPTS=$(awk '{ n = split($4, a, ","); for (i = 0; i <= n; i++)
{ mnt_opts[a[i]]=1 } } END { for (i in mnt_opts) { print i } }'
/etc/mtab 2>/dev/null )
-			COMPREPLY=( $(compgen -W "$MNT_OPTS" -- $cur) )
+			local MTAB_3RD I
+			declare -a TMP_ARR
+			declare -A MNT_OPTS
+			while read _ _ _ MTAB_3RD _; do
+				IFS=',' read -ra TMP_ARR <<<"$MTAB_3RD"
+				for I in ${TMP_ARR[@]}; do
+					MNT_OPTS[$I]='1'
+				done
+			done </etc/mtab
+			COMPREPLY=( $(compgen -W "$(echo ${!MNT_OPTS[@]})" -- $cur) )
 			return 0
 			;;
 		'-o'|'--output')
diff --git a/shell-completion/fsck b/shell-completion/fsck
index c3da5f5..a8f054f 100644
--- a/shell-completion/fsck
+++ b/shell-completion/fsck
@@ -29,7 +29,7 @@ _fsck_module()
 			return 0
 			;;
 	esac
-	DEVS="$(lsblk -o NAME -n -r | awk '{print "/dev/" $1}')"
+	DEVS="$(lsblk -o NAME -n -r -p)"
 	COMPREPLY=( $(compgen -W "$DEVS" -- $cur) )
 	return 0
 }
diff --git a/shell-completion/fsck.minix b/shell-completion/fsck.minix
index f01626a..69ac714 100644
--- a/shell-completion/fsck.minix
+++ b/shell-completion/fsck.minix
@@ -3,7 +3,7 @@ _fsck.minix_module()
 	local cur OPTS DEVS
 	COMPREPLY=()
 	cur="${COMP_WORDS[COMP_CWORD]}"
-	DEVS="$(lsblk -o NAME -n -r | awk '{print "/dev/" $1}')"
+	DEVS="$(lsblk -o NAME -n -r -p)"
 	OPTS="-l -a -r -v -s -m -f -V --version"
 	COMPREPLY=( $(compgen -W "${OPTS[*]} $DEVS" -- $cur) )
 	return 0
diff --git a/shell-completion/ionice b/shell-completion/ionice
index 3087c4a..2180718 100644
--- a/shell-completion/ionice
+++ b/shell-completion/ionice
@@ -15,7 +15,7 @@ _ionice_module()
 			;;
 		'-p'|'--pid')
 			local PIDS
-			PIDS=$(\ls -d /proc/[0-9]* | sed 's|/proc/||')
+			PIDS=$(for I in /proc/[0-9]*; do echo ${I##"/proc/"}; done)
 			COMPREPLY=( $(compgen -W "$PIDS" -- $cur) )
 			return 0
 			;;
diff --git a/shell-completion/ipcrm b/shell-completion/ipcrm
index 4b1024f..da9f783 100644
--- a/shell-completion/ipcrm
+++ b/shell-completion/ipcrm
@@ -36,13 +36,20 @@ _ipcrm_module()
 			return 0
 			;;
 	esac
+	case $cur in
+		'=')
+			cur=${cur#=}
+			COMPREPLY=( $(compgen -W "shm msg sem" -- $cur) )
+			return 0
+			;;
+	esac
 	OPTS="	-m --shmem-id
 		-M --shmem-key
 		-q --queue-id
 		-Q --queue-key
 		-s --semaphore-id
 		-S --semaphore-key
-		-a --all
+		-a --all=
 		-v --verbose
 		-h --help
 		-V --version"
diff --git a/shell-completion/login b/shell-completion/login
deleted file mode 100644
index c075f64..0000000
--- a/shell-completion/login
+++ /dev/null
@@ -1,27 +0,0 @@
-_login_module()
-{
-	local cur prev OPTS
-	COMPREPLY=()
-	cur="${COMP_WORDS[COMP_CWORD]}"
-	prev="${COMP_WORDS[COMP_CWORD-1]}"
-	case $prev in
-		'-f')
-			COMPREPLY=( $(compgen -u -- $cur) )
-			return 0
-			;;
-		'-h')
-			COMPREPLY=( $(compgen -A hostname -- $cur) )
-			return 0
-			;;
-	esac
-	case $cur in
-		-*)
-			OPTS="-p -f -h -H -V"
-			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
-			return 0
-			;;
-	esac
-	COMPREPLY=( $(compgen -u -- $cur) )
-	return 0
-}
-complete -F _login_module login
diff --git a/shell-completion/losetup b/shell-completion/losetup
index b21f05d..329bb05 100644
--- a/shell-completion/losetup
+++ b/shell-completion/losetup
@@ -16,7 +16,7 @@ _losetup_module()
 			return 0
 			;;
 		'-c'|'--set-capacity')
-			ARG="$(\ls /dev/loop[0-9]* 2>/dev/null)"
+			ARG="$(for I in /dev/loop[0-9]*; do if [ -e $I ]; then echo $I; fi; done)"
 			COMPREPLY=( $(compgen -W "$ARG" -- $cur) )
 			return 0
 			;;
diff --git a/shell-completion/lsblk b/shell-completion/lsblk
index 521cead..4b5973d 100644
--- a/shell-completion/lsblk
+++ b/shell-completion/lsblk
@@ -1,12 +1,17 @@
 _lsblk_module()
 {
-	local cur prev OPTS MAJOR
+	local cur prev OPTS
 	COMPREPLY=()
 	cur="${COMP_WORDS[COMP_CWORD]}"
 	prev="${COMP_WORDS[COMP_CWORD-1]}"
 	case $prev in
 		'-e'|'--exclude'|'-I'|'--include')
-			MAJOR=$(\ls /sys/dev/block/ | sed 's/:.*//')
+			local MAJOR I J
+			MAJOR=''
+			for I in /sys/dev/block/*; do
+				J=${I##*/}
+				MAJOR="$MAJOR ${J%%:*}"
+			done
 			# FIXME: how to append to a string with compgen?
 			compopt -o nospace
 			COMPREPLY=( $(compgen -W "$MAJOR" -S ',' -- $cur) )
@@ -53,7 +58,7 @@ _lsblk_module()
 			;;
 	esac
 	local DEVS
-	DEVS="$(\ls -d /sys/class/block/* | sed 's|/sys/class/block/|/dev/|g')"
+	DEVS="$(lsblk -o NAME -n -r -p)"
 	COMPREPLY=( $(compgen -W "$DEVS" -- $cur) )
 	return 0
 }
diff --git a/shell-completion/lscpu b/shell-completion/lscpu
index bb76d4c..38ef07b 100644
--- a/shell-completion/lscpu
+++ b/shell-completion/lscpu
@@ -1,19 +1,25 @@
 _lscpu_module()
 {
-	local cur prev OPTS
+	local cur OPTS
 	COMPREPLY=()
 	cur="${COMP_WORDS[COMP_CWORD]}"
 	prev="${COMP_WORDS[COMP_CWORD-1]}"
 	case $prev in
-		'-e'|'--extended'|'-p'|'--parse')
+		'--extended'|'=')
+			cur=${cur#=}
 			# FIXME: how to append to a string with compgen?
-			# FIXME: space in between option and argument is
-			# 	 a problem.
-			local OUTPUT
-			OUTPUT="CPU CORE SOCKET NODE BOOK CACHE
-				POLARIZATION ADDRESS CONFIGURED ONLINE"
+			OPTS="CPU,
+				CORE,
+				SOCKET,
+				NODE,
+				BOOK,
+				CACHE,
+				POLARIZATION,
+				ADDRESS,
+				CONFIGURED,
+				ONLINE,"
 			compopt -o nospace
-			COMPREPLY=( $(compgen -W "$OUTPUT" -S ',' -- $cur) )
+			COMPREPLY=( $(compgen -W "$OPTS" -- $cur) )
 			return 0
 			;;
 	esac
@@ -22,8 +28,8 @@ _lscpu_module()
 			OPTS="-a --all
 				-b --online
 				-c --offline
-				-e --extended
-				-p --parse
+				-e --extended=
+				-p --parse=
 				-s --sysroot
 				-x --hex
 				-h --help
diff --git a/shell-completion/mkfs b/shell-completion/mkfs
index ee6a26b..ac56841 100644
--- a/shell-completion/mkfs
+++ b/shell-completion/mkfs
@@ -6,7 +6,7 @@ _mkfs_module()
 	prev="${COMP_WORDS[COMP_CWORD-1]}"
 	case $prev in
 		'-t'|'--type')
-			FSTYPES=$(for I in $(\ls /sbin/mkfs.* /usr/sbin/mkfs.*
2>/dev/null); do echo ${I##*mkfs.}; done)
+			FSTYPES=$(for I in /sbin/mkfs.* /usr/sbin/mkfs.*; do if [ -e $I ];
then echo ${I##*mkfs.}; fi; done)
 			COMPREPLY=( $(compgen -W "$FSTYPES" -- $cur) )
 			return 0
 			;;
@@ -18,7 +18,7 @@ _mkfs_module()
 			return 0
 			;;
 	esac
-	DEVS="$(lsblk -o NAME -n -r | awk '{print "/dev/" $1}')"
+	DEVS="$(lsblk -o NAME -n -r -p)"
 	COMPREPLY=( $(compgen -W "$DEVS /path/to/file" -- $cur) )
 	return 0
 }
diff --git a/shell-completion/mkfs.bfs b/shell-completion/mkfs.bfs
index b1a226a..2d8e796 100644
--- a/shell-completion/mkfs.bfs
+++ b/shell-completion/mkfs.bfs
@@ -21,7 +21,7 @@ _bfs_module()
 			return 0
 			;;
 	esac
-	DEVS="$(lsblk -o NAME -n -r | awk '{print "/dev/" $1}')"
+	DEVS="$(lsblk -o NAME -n -r -p)"
 	COMPREPLY=( $(compgen -W "$DEVS /path/to/file" -- $cur) )
 	return 0
 }
diff --git a/shell-completion/mkfs.minix b/shell-completion/mkfs.minix
index c717b3c..884a09b 100644
--- a/shell-completion/mkfs.minix
+++ b/shell-completion/mkfs.minix
@@ -26,7 +26,7 @@ _mkfs.minix_module()
 			;;
 	esac
 	local DEVS
-	DEVS="$(lsblk -o NAME -n -r | awk '{print "/dev/" $1}')"
+	DEVS="$(lsblk -o NAME -n -r -p)"
 	COMPREPLY=( $(compgen -W "$DEVS" -- $cur) )
 	return 0
 }
diff --git a/shell-completion/nsenter b/shell-completion/nsenter
index f15a7f1..168f740 100644
--- a/shell-completion/nsenter
+++ b/shell-completion/nsenter
@@ -7,32 +7,29 @@ _nsenter_module()
 	case $prev in
 		'-t'|'--target')
 			local PIDS
-			PIDS=$(\ls -d /proc/[0-9]* | sed 's|/proc/||')
+			PIDS=$(for I in /proc/[0-9]*; do echo ${I##"/proc/"}; done)
 			COMPREPLY=( $(compgen -W "$PIDS" -- $cur) )
 			return 0
 			;;
-		'-m'|'--mount'|'-u'|'--uts'|'-i'|'--net'|'-n'|'--net'|'-p'|'--pid'|'-U'|'--user')
-			compopt -o filenames
-			COMPREPLY=( $(compgen -f -- $cur) )
-			return 0
-			;;
-		'-r'|'--root'|'-w'|'--wd')
-			compopt -o filenames
-			COMPREPLY=( $(compgen -o dirnames -- $cur) )
-			return 0
-			;;
 	esac
 	case $cur in
+		'=')
+			# FIXME: --root and --wd should use get only
+			# directories as compgen output.  If $cur is
+			# overwrote the same way as below in case segment
+			# for $prev the command-line will get mangled.
+			cur=${cur#=}
+			;;
 		-*)
 			OPTS="-t --target
-				-m --mount
-				-u --uts
-				-i --ipc
-				-n --net
-				-p --pid
-				-U --user
-				-r --root
-				-w --wd
+				-m --mount=
+				-u --uts=
+				-i --ipc=
+				-n --net=
+				-p --pid=
+				-U --user=
+				-r --root=
+				-w --wd=
 				-F --no-fork
 				-h --help
 				-V --version"
diff --git a/shell-completion/partx b/shell-completion/partx
index c558d36..8187965 100644
--- a/shell-completion/partx
+++ b/shell-completion/partx
@@ -7,7 +7,7 @@ _partx_module()
 	prev="${COMP_WORDS[COMP_CWORD-1]}"
 	case $prev in
 		'-n'|'--nr')
-			COMPREPLY=( $(compgen -W "$(lsblk -o NAME,TYPE -n -r | awk '$2 ~
/part/ {print "/dev/" $1}')" -- $cur) )
+			COMPREPLY=( $(compgen -W "$(lsblk -o NAME,TYPE -n -r -p | awk '$2
~ /part/ {print $1}')" -- $cur) )
 			return 0
 			;;
 		'-o'|'--output')
diff --git a/shell-completion/prlimit b/shell-completion/prlimit
index ee49b79..55bd13f 100644
--- a/shell-completion/prlimit
+++ b/shell-completion/prlimit
@@ -6,7 +6,7 @@ _prlimit_module()
 	prev="${COMP_WORDS[COMP_CWORD-1]}"
 	case $prev in
 		'-p'|'--pid')
-			PIDS=$(\ls -d /proc/[0-9]* | sed 's|/proc/||')
+			PIDS=$(for I in /proc/[0-9]*; do echo ${I##"/proc/"}; done)
 			COMPREPLY=( $(compgen -W "$PIDS" -- $cur) )
 			return 0
 			;;
@@ -20,6 +20,11 @@ _prlimit_module()
 			;;
 	esac
 	case $cur in
+		'=')
+			cur=${cur#=}
+			# FIXME: is there anything what could be printed
+			# as limit value(s)
+			;;
 		-*)
 			OPTS="-p --pid
 				-o --output
@@ -28,21 +33,21 @@ _prlimit_module()
 				   --verbose
 				-h --help
 				-V --version
-				-c --core
-				-d --data
-				-e --nice
-				-f --fsize
-				-i --sigpending
-				-l --memlock
-				-m --rss
-				-n --nofile
-				-q --msgqueue
-				-r --rtprio
-				-s --stack
-				-t --cpu
-				-u --nproc
-				-v --as
-				-x --locks
+				-c --core=
+				-d --data=
+				-e --nice=
+				-f --fsize=
+				-i --sigpending=
+				-l --memlock=
+				-m --rss=
+				-n --nofile=
+				-q --msgqueue=
+				-r --rtprio=
+				-s --stack=
+				-t --cpu=
+				-u --nproc=
+				-v --as=
+				-x --locks=
 				-y --rttime"
 			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
 			return 0
diff --git a/shell-completion/raw b/shell-completion/raw
index 41e03f2..27f0354 100644
--- a/shell-completion/raw
+++ b/shell-completion/raw
@@ -11,7 +11,7 @@ _raw_module()
 			return 0
 			;;
 	esac
-	COMPREPLY=( $(compgen -W "$(ls 2>/dev/null /dev/raw/*)" -- $cur) )
+	COMPREPLY=( $(compgen -W "$(for I in /dev/raw/*; do if [ -e $I ];
then echo $I; fi; done)" -- $cur) )
 	return 0
 }
 complete -F _raw_module raw
diff --git a/shell-completion/renice b/shell-completion/renice
index bc80dac..aba00d7 100644
--- a/shell-completion/renice
+++ b/shell-completion/renice
@@ -17,7 +17,7 @@ _renice_module()
 			;;
 		'-p'|'--pid')
 			local PIDS
-			PIDS=$(\ls -d /proc/[0-9]* | sed 's|/proc/||')
+			PIDS=$(for I in /proc/[0-9]*; do echo ${I##"/proc/"}; done)
 			COMPREPLY=( $(compgen -W "$PIDS" -- $cur) )
 			return 0
 			;;
diff --git a/shell-completion/resizepart b/shell-completion/resizepart
index 827638a..cdd76d0 100644
--- a/shell-completion/resizepart
+++ b/shell-completion/resizepart
@@ -1,16 +1,17 @@
 _resizepart_module()
 {
-	local cur OPTS
+	local cur prev OPTS
 	COMPREPLY=()
 	cur="${COMP_WORDS[COMP_CWORD]}"
 	case $COMP_CWORD in
 		1)
 			local DEVS
-			DEVS="$(lsblk -o NAME,TYPE -n -r | awk '$2 ~ /disk/ {print "/dev/" $1}')"
+			DEVS="$(lsblk -o NAME,TYPE -n -r -p | awk '$2 ~ /disk/ {print $1}')"
 			OPTS="-h --help -V --version $DEVS"
 			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
 			;;
 		2)
+			prev="${COMP_WORDS[COMP_CWORD-1]}"
 			COMPREPLY=( $(compgen -W "$(cat /sys/block/${prev##*/}/*/partition
2>/dev/null)" -- $cur) )
 			;;
 		3)
diff --git a/shell-completion/rtcwake b/shell-completion/rtcwake
index 2010a52..1f38df8 100644
--- a/shell-completion/rtcwake
+++ b/shell-completion/rtcwake
@@ -7,7 +7,7 @@ _rtcwake_module()
 	case $prev in
 		'-d'|'--device')
 			local RTC_DEVS
-			RTC_DEVS=$(\ls /sys/class/rtc/ 2>/dev/null)
+			RTC_DEVS=$(cd /sys/class/rtc/ && echo *)
 			COMPREPLY=( $(compgen -W "$RTC_DEVS" -- $cur) )
 			return 0
 			;;
diff --git a/shell-completion/script b/shell-completion/script
index fb6c106..e58dbd8 100644
--- a/shell-completion/script
+++ b/shell-completion/script
@@ -10,13 +10,11 @@ _script_module()
 			COMPREPLY=( $(compgen -c -- $cur) )
 			return 0
 			;;
-		'-t'|'--timing')
-			compopt -o filenames
-			COMPREPLY=( $(compgen -f -- $cur) )
-			return 0
-			;;
 	esac
 	case $cur in
+		'=')
+			cur=${cur#=}
+			;;
 		-*)
 			OPTS="-a --append
 				-c --command
@@ -24,7 +22,7 @@ _script_module()
 				-f --flush
 				   --force
 				-q --quiet
-				-t --timing
+				-t --timing=
 				-V --version
 				-h --help"
 			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
diff --git a/shell-completion/setterm b/shell-completion/setterm
index a0dff44..33d2e56 100644
--- a/shell-completion/setterm
+++ b/shell-completion/setterm
@@ -6,8 +6,12 @@ _setterm_module()
 	prev="${COMP_WORDS[COMP_CWORD-1]}"
 	case $prev in
 		'-term')
-			# FIXME: terminal type list would be nice
-			COMPREPLY=( $(compgen -W "vt100 xterm linux screen etc" -- $cur) )
+			local TERM_LIST I
+			TERM_LIST=''
+			for I in /usr/share/terminfo/?/*; do
+				TERM_LIST+="${I##*/} "
+			done
+			COMPREPLY=( $(compgen -W "$TERM_LIST" -- $cur) )
 			return 0
 			;;
 		'-foreground'|'-background'|'-ulcolor'|'-hbcolor')
@@ -36,8 +40,8 @@ _setterm_module()
 			;;
 		'-dump'|'-append')
 			local NUM_CONS
-			NUM_CONS=$(ls /sys/class/tty | wc -l)
-			COMPREPLY=( $(compgen -W "$(echo {1..$NUM_CONS})" -- $cur) )
+			NUM_CONS=(/sys/class/tty/*)
+			COMPREPLY=( $(compgen -W "$(echo {1..${#NUM_CONS[*]}})" -- $cur) )
 			return 0
 			;;
 		'-file')
diff --git a/shell-completion/sfdisk b/shell-completion/sfdisk
index 041ce55..835ecd2 100644
--- a/shell-completion/sfdisk
+++ b/shell-completion/sfdisk
@@ -20,6 +20,9 @@ _sfdisk_module()
 			;;
 	esac
 	case $cur in
+		'=')
+			cur=${cur#=}
+			;;
 		-*)
 			OPTS="-s --show-size
 				-c --id
@@ -47,8 +50,8 @@ _sfdisk_module()
 				-L --Linux
 				-g --show-geometry
 				-G --show-pt-geometry
-				-A --activate
-				-U --unhide
+				-A --activate=
+				-U --unhide=
 				-x --show-extended
 				--leave-last
 				--IBM
@@ -66,7 +69,7 @@ _sfdisk_module()
 			return 0
 			;;
 	esac
-	COMPREPLY=( $(compgen -W "$(lsblk -o NAME,TYPE -n -r | awk '$2 ~
/disk/ {print "/dev/" $1}')" -- $cur) )
+	COMPREPLY=( $(compgen -W "$(lsblk -o NAME,TYPE -n -r -p | awk '$2 ~
/disk/ {print $1}')" -- $cur) )
 	return 0
 }
 complete -F _sfdisk_module sfdisk
diff --git a/shell-completion/su b/shell-completion/su
index ded4b7b..c5aa81e 100644
--- a/shell-completion/su
+++ b/shell-completion/su
@@ -20,15 +20,16 @@ _su_module()
 	esac
 	case $cur in
 		-*)
-			OPTS="	-u --user
+			OPTS="	-
+				-u --user
 				-m -p --preserve-environment
 				-g --group
 				-G --supp-group
-				- -l --login
+				-l --login
 				-c --command
-				- -c
+				-c
 				--session-command
-				-- -c
+				-c
 				-f --fast
 				-s --shell
 				-h --help
diff --git a/shell-completion/sulogin b/shell-completion/sulogin
deleted file mode 100644
index 9fdc20e..0000000
--- a/shell-completion/sulogin
+++ /dev/null
@@ -1,24 +0,0 @@
-_sulogin_module()
-{
-	local cur prev OPTS
-	COMPREPLY=()
-	cur="${COMP_WORDS[COMP_CWORD]}"
-	prev="${COMP_WORDS[COMP_CWORD-1]}"
-	case $prev in
-		'-t'|'--timeout')
-			COMPREPLY=( $(compgen -W "seconds" -- $cur) )
-			return 0
-			;;
-	esac
-	case $cur in
-		-*)
-			OPTS="-p --login-shell -t --timeout -V --version -h --help"
-			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
-			return 0
-			;;
-	esac
-	compopt -o filenames
-	COMPREPLY=( $(compgen -f -- ${cur:-"/dev/tty"}) )
-	return 0
-}
-complete -F _sulogin_module sulogin
diff --git a/shell-completion/taskset b/shell-completion/taskset
index 81247cd..5311316 100644
--- a/shell-completion/taskset
+++ b/shell-completion/taskset
@@ -19,7 +19,7 @@ _taskset_module()
 			# setting an affinity the optarg has to be cpu
 			# mask.  The following is good only for getting
 			# affinity.
-			PIDS=$(\ls -d /proc/[0-9]* | sed 's|/proc/||')
+			PIDS=$(for I in /proc/[0-9]*; do echo ${I##"/proc/"}; done)
 			COMPREPLY=( $(compgen -W "$PIDS" -- $cur) )
 			return 0
 			;;
diff --git a/shell-completion/ul b/shell-completion/ul
index 89e2800..07d0731 100644
--- a/shell-completion/ul
+++ b/shell-completion/ul
@@ -6,8 +6,12 @@ _ul_module()
 	prev="${COMP_WORDS[COMP_CWORD-1]}"
 	case $prev in
 		'-t'|'--terminal')
-			# FIXME: terminal type list would be nice
-			COMPREPLY=( $(compgen -W "vt100 xterm linux screen etc" -- $cur) )
+			local TERM_LIST I
+			TERM_LIST=''
+			for I in /usr/share/terminfo/?/*; do
+				TERM_LIST+="${I##*/} "
+			done
+			COMPREPLY=( $(compgen -W "$TERM_LIST" -- $cur) )
 			return 0
 			;;
 	esac
diff --git a/shell-completion/wdctl b/shell-completion/wdctl
index 6a85e0a..42889ac 100644
--- a/shell-completion/wdctl
+++ b/shell-completion/wdctl
@@ -6,8 +6,20 @@ _wdctl_module()
 	prev="${COMP_WORDS[COMP_CWORD-1]}"
 	case $prev in
 		'-f'|'--flags')
-			# FIXME: how to get flag list?
-			COMPREPLY=( $(compgen -W "flags" -- $cur) )
+			local FLAGS
+			FLAGS="ALARMONLY
+				CARDRESET
+				EXTERN1
+				EXTERN2
+				FANFAULT
+				KEEPALIVEPING
+				MAGICCLOSE
+				OVERHEAT
+				POWEROVER
+				POWERUNDER
+				PRETIMEOUT
+				SETTIMEOUT"
+			COMPREPLY=( $(compgen -W "$FLAGS" -- $cur) )
 			return 0
 			;;
 		'-o'|'--output')
diff --git a/shell-completion/wipefs b/shell-completion/wipefs
index 427f47b..52c25b4 100644
--- a/shell-completion/wipefs
+++ b/shell-completion/wipefs
@@ -11,13 +11,7 @@ _wipefs_module()
 			;;
 		'-t'|'--types')
 			local TYPES
-			TYPES="adfs affs autofs cifs coda coherent cramfs
-				debugfs devpts efs ext ext2 ext3 ext4 hfs
-				hfsplus hpfs iso9660 jfs minix msdos
-				ncpfs nfs nfs4 ntfs proc qnx4 ramfs
-				reiserfs romfs squashfs smbfs sysv tmpfs
-				ubifs udf ufs umsdos usbfs vfat xenix xfs
-				xiafs"
+			TYPES="$(blkid -k)"
 			COMPREPLY=( $(compgen -W "$TYPES" -- $cur) )
 			return 0
 			;;
@@ -31,7 +25,7 @@ _wipefs_module()
 			;;
 	esac
 	local DEVS
-	DEVS="$(\ls -d /sys/class/block/* | sed 's|/sys/class/block/|/dev/|g')"
+	DEVS="$(lsblk-o NAME -n -r -p)"
 	COMPREPLY=( $(compgen -W "$DEVS" -- $cur) )
 	return 0
 }
diff --git a/shell-completion/write b/shell-completion/write
index ba67569..d41159b 100644
--- a/shell-completion/write
+++ b/shell-completion/write
@@ -9,7 +9,10 @@ _write_module()
 			return 0
 			;;
 		2)
-			local TERMS=$(for I in $(\ls /sys/class/tty 2>/dev/null); do echo
"/dev/$I"; done)
+			local I TERMS=''
+			for I in /sys/class/tty/*; do
+				TERMS+="/dev${I##/sys/class/tty} "
+			done
 			COMPREPLY=( $(compgen -W "$TERMS" -- $cur) )
 			return 0
 			;;

-- 
   Sami Kerola
   http://www.iki.fi/kerolasa/

[-- Attachment #2: Type: text/html, Size: 32960 bytes --]

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* Re: [PATCH 00/10] [pull] bash-completion
  2013-03-28  9:37 ` Karel Zak
  2013-03-31 23:49   ` Sami Kerola
@ 2013-04-01 15:44   ` Sami Kerola
  1 sibling, 0 replies; 33+ messages in thread
From: Sami Kerola @ 2013-04-01 15:44 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux

On Thu, Mar 28, 2013 at 10:37:54AM +0100, Karel Zak wrote:
> On Wed, Mar 27, 2013 at 10:07:42PM +0000, Sami Kerola wrote:
> > > Some FIXME's are slightly more difficult to fix.  For example I do not
> > > know how to get list of possible TERM values distribution agnostic way. 
> 
>  Well, I think we can start with some nice hardcoded list..
> 
> > > And with 'wdctl' I have no how to determine flags.  Same goes for SELinux
> 
>     wdctl --flags-only -o FLAG 
>     
>  returns currently supported flags (by the device), the complete list of 
>  the flags is:
> 
> 	CARDRESET
> 	EXTERN1
> 	EXTERN2
> 	FANFAULT
> 	KEEPALIVEPING
> 	MAGICCLOSE
> 	OVERHEAT
> 	POWEROVER
> 	POWERUNDER
> 	PRETIMEOUT
> 	SETTIMEOUT
> 	ALARMONLY
> 
> I think it's fine to use this hardcoded list.

Hard coded list is in use for wdctl, and I have done few other changes
which are collectively in my remote repository.

git://github.com/kerolasa/lelux-utiliteetit.git shell-completion

To be a bit less vague here are the changes since the previous
submission.


diff --git a/shell-completion/Makemodule.am b/shell-completion/Makemodule.am
index 0bb8652..b657604 100644
--- a/shell-completion/Makemodule.am
+++ b/shell-completion/Makemodule.am
@@ -90,10 +90,6 @@ if BUILD_LAST
 dist_bashcompletion_DATA += \
 	shell-completion/last
 endif
-if BUILD_LOGIN
-dist_bashcompletion_DATA += \
-	shell-completion/login
-endif
 if BUILD_NEWGRP
 dist_bashcompletion_DATA += \
 	shell-completion/newgrp
@@ -102,10 +98,6 @@ if BUILD_SU
 dist_bashcompletion_DATA += \
 	shell-completion/su
 endif
-if BUILD_SULOGIN
-dist_bashcompletion_DATA += \
-	shell-completion/sulogin
-endif
 if BUILD_UTMPDUMP
 dist_bashcompletion_DATA += \
 	shell-completion/utmpdump
@@ -222,10 +214,6 @@ endif
 # ...sys-utils
 
 # term-utils...
-if BUILD_AGETTY
-dist_bashcompletion_DATA += \
-	shell-completion/agetty
-endif
 if BUILD_MESG
 dist_bashcompletion_DATA += \
 	shell-completion/mesg
diff --git a/shell-completion/addpart b/shell-completion/addpart
index 07ebf5e..b6f119a 100644
--- a/shell-completion/addpart
+++ b/shell-completion/addpart
@@ -1,17 +1,17 @@
 _addpart_module()
 {
-	local cur
+	local cur prev
 	COMPREPLY=()
 	cur="${COMP_WORDS[COMP_CWORD]}"
 	case $COMP_CWORD in
 		1)
-			local DEVS
-			DEVS="$(lsblk -o NAME -n -r)"
+			local DEVS=''
+			while read dev; do DEVS+="$dev " ; done < <(lsblk -pnro name)
 			OPTS="-h --help -V --version $DEVS"
 			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
 			;;
 		2)
-			COMPREPLY=( $(compgen -W "$((1 + $(ls $prev?* 2>/dev/null | wc -l)))" -- $cur) )
+			# FIXME: how to determine next free partition number
 			;;
 		3)
 			COMPREPLY=( $(compgen -W "start" -- $cur) )
diff --git a/shell-completion/agetty b/shell-completion/agetty
deleted file mode 100644
index dc37a68..0000000
--- a/shell-completion/agetty
+++ /dev/null
@@ -1,70 +0,0 @@
-_agetty_module()
-{
-	local cur prev OPTS
-	COMPREPLY=()
-	cur="${COMP_WORDS[COMP_CWORD]}"
-	prev="${COMP_WORDS[COMP_CWORD-1]}"
-	case $prev in
-		'-a'|'--autologin')
-			COMPREPLY=( $(compgen -u -- $cur) )
-			return 0
-			;;
-		'-o'|'--issue-file'|'-I'|'--login-program')
-			compopt -o filenames
-			COMPREPLY=( $(compgen -f -- $cur) )
-			return 0
-			;;
-		'-I'|'--init-string'|'--erase-chars'|'--kill-chars')
-			compopt -o filenames
-			COMPREPLY=( $(compgen -W "string" -- $cur) )
-			return 0
-			;;
-		'-o'|'--login-options')
-			COMPREPLY=( $(compgen -W "login-options" -- $cur) )
-			return 0
-			;;
-		'-t'|'--timeout')
-			COMPREPLY=( $(compgen -W "seconds" -- $cur) )
-			return 0
-			;;
-	esac
-	case $cur in
-		-*)
-			OPTS="-8 --8bits
-				-a --autologin
-				-c --noreset
-				-f --issue-file
-				-h --flow-control
-				-H --host
-				-i --noissue
-				-I --init-string
-				-l --login-program
-				-L --local-line
-				-m --extract-baud
-				-n --skip-login
-				-o --login-options
-				-p --loginpause
-				-R --hangup
-				-s --keep-baud
-				-t --timeout
-				-U --detect-case
-				-w --wait-cr
-				   --nocleardo
-				   --nohintsdo
-				   --nonewlinedo
-				   --no-hostnameno
-				   --long-hostnameshow
-				   --erase-chars
-				   --kill-chars
-				-h --help
-				-V --version"
-			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
-			return 0
-			;;
-	esac
-	local BAUD_RATES
-	BAUD_RATES="75 110 300 1200 2400 4800 9600 19200 38400 57600 115200"
-	COMPREPLY=( $(compgen -W "$BAUD_RATES $(echo /dev/tty*)" -- $cur) )
-	return 0
-}
-complete -F _agetty_module agetty
diff --git a/shell-completion/blkdiscard b/shell-completion/blkdiscard
index e907a1b..757480c 100644
--- a/shell-completion/blkdiscard
+++ b/shell-completion/blkdiscard
@@ -18,7 +18,7 @@ _blkdiscard_module()
 			;;
 	esac
 	local DEVS
-	DEVS="$(\ls -d /sys/class/block/* | sed 's|/sys/class/block/|/dev/|g')"
+	DEVS=''; while read dev; do DEVS+="$dev " ; done < <(lsblk -pnro name)
 	COMPREPLY=( $(compgen -W "$DEVS" -- $cur) )
 	return 0
 }
diff --git a/shell-completion/blkid b/shell-completion/blkid
index dce41e0..14222a4 100644
--- a/shell-completion/blkid
+++ b/shell-completion/blkid
@@ -23,11 +23,11 @@ _blkid_module()
 			return 0
 			;;
 		'-L')
-			COMPREPLY=( $(compgen -W "$(\ls /dev/disk/by-label/ 2>/dev/null)" -- $cur) )
+			COMPREPLY=( $(compgen -W "$(cd /dev/disk/by-label/ 2>/dev/null && echo *)" -- $cur) )
 			return 0
 			;;
 		'-U')
-			COMPREPLY=( $(compgen -W "$(\ls /dev/disk/by-uuid/ 2>/dev/null)" -- $cur) )
+			COMPREPLY=( $(compgen -W "$(cd /dev/disk/by-uuid/ 2>/dev/null && echo *)" -- $cur) )
 			return 0
 			;;
 		'-s')
@@ -54,9 +54,11 @@ _blkid_module()
 			return 0
 			;;
 	esac
-	local PARTITIONS
-	PARTITIONS="$(for I in /sys/block/*/*/partition; do IFS='/'; DIR_ARR=($I); echo "/dev/${DIR_ARR[4]}"; done)"
-	COMPREPLY=( $(compgen -W "$PARTITIONS" -- $cur) )
+	local DEV TYPE DEVICES=''
+	while read DEV TYPE; do
+		[ $TYPE = 'part' ] && DEVICES+="$DEV "
+	done < <(lsblk -pnro name,type)
+	COMPREPLY=( $(compgen -W "$DEVICES" -- $cur) )
 	return 0
 }
 complete -F _blkid_module blkid
diff --git a/shell-completion/blockdev b/shell-completion/blockdev
index 82ac6c1..ce986cb 100644
--- a/shell-completion/blockdev
+++ b/shell-completion/blockdev
@@ -4,7 +4,7 @@ _blockdev_module()
 	COMPREPLY=()
 	cur="${COMP_WORDS[COMP_CWORD]}"
 	prev="${COMP_WORDS[COMP_CWORD-1]}"
-	DEVS="$(lsblk -o NAME -n -r)"
+	while read dev; do DEVS+="$dev " ; done < <(lsblk -pnro name)
 	OPTS="-h -V -q
 		--report
 		--getsz
diff --git a/shell-completion/cfdisk b/shell-completion/cfdisk
index 8da32fd..4be5186 100644
--- a/shell-completion/cfdisk
+++ b/shell-completion/cfdisk
@@ -25,7 +25,11 @@ _cfdisk_module()
 			return 0
 			;;
 	esac
-	COMPREPLY=( $(compgen -W "$(lsblk -o NAME,TYPE -n -r | awk '$2 ~ /disk/ {print "/dev/" $1}')" -- $cur) )
+	local DEV TYPE DEVICES=''
+	while read DEV TYPE; do
+		[ $TYPE = 'disk' ] && DEVICES+="$DEV "
+	done < <(lsblk -pnro name,type)
+	COMPREPLY=( $(compgen -W "$DEVICES" -- $cur) )
 	return 0
 }
 complete -F _cfdisk_module cfdisk
diff --git a/shell-completion/chfn b/shell-completion/chfn
index 1c5167a..a8eaee5 100644
--- a/shell-completion/chfn
+++ b/shell-completion/chfn
@@ -1,23 +1,8 @@
 _chfn_module()
 {
-	local cur prev OPTS
+	local cur OPTS
 	COMPREPLY=()
 	cur="${COMP_WORDS[COMP_CWORD]}"
-	prev="${COMP_WORDS[COMP_CWORD-1]}"
-	case $prev in
-		'-f'|'--full-name')
-			COMPREPLY=( $(compgen -W "name" -- $cur) )
-			return 0
-			;;
-		'-o'|'--office')
-			COMPREPLY=( $(compgen -W "office" -- $cur) )
-			return 0
-			;;
-		'-p'|'--office-phone'|'-h'|'--home-phone')
-			COMPREPLY=( $(compgen -W "phone-nr" -- $cur) )
-			return 0
-			;;
-	esac
 	case $cur in
 		-*)
 			OPTS="-f --full-name -o --office -p --office-phone -h --home-phone -u --help -v --version"
diff --git a/shell-completion/chrt b/shell-completion/chrt
index 08912c9..b85775a 100644
--- a/shell-completion/chrt
+++ b/shell-completion/chrt
@@ -25,7 +25,7 @@ _chrt_module()
 			;;
 	esac
 	local PIDS
-	PIDS=$(\ls -d /proc/[0-9]* | sed 's|/proc/||')
+	PIDS=$(for I in /proc/[0-9]*; do echo ${I##"/proc/"}; done)
 	COMPREPLY=( $(compgen -W "$PIDS" -- $cur) )
 	return 0
 }
diff --git a/shell-completion/delpart b/shell-completion/delpart
index 849c018..e3ee406 100644
--- a/shell-completion/delpart
+++ b/shell-completion/delpart
@@ -1,16 +1,20 @@
 _delpart_module()
 {
-	local cur OPTS
+	local cur prev OPTS
 	COMPREPLY=()
 	cur="${COMP_WORDS[COMP_CWORD]}"
+	prev="${COMP_WORDS[COMP_CWORD-1]}"
 	case $COMP_CWORD in
 		1)
-			local DEVS
-			DEVS="$(lsblk -o NAME,TYPE -n -r | awk '$2 ~ /disk/ {print "/dev/" $1}')"
-			OPTS="-h --help -V --version $DEVS"
+			local DEV TYPE DEVICES=''
+			while read DEV TYPE; do
+				[ $TYPE = 'disk' ] && DEVICES+="$DEV "
+			done < <(lsblk -pnro name,type)
+			OPTS="-h --help -V --version $DEVICES"
 			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
 			;;
 		2)
+			prev="${COMP_WORDS[COMP_CWORD-1]}"
 			COMPREPLY=( $(compgen -W "$(cat /sys/block/${prev##*/}/*/partition 2>/dev/null)" -- $cur) )
 			;;
 	esac
diff --git a/shell-completion/fdformat b/shell-completion/fdformat
index f7d6a8e..4ad1c3d 100644
--- a/shell-completion/fdformat
+++ b/shell-completion/fdformat
@@ -3,7 +3,7 @@ _fdformat_module()
 	local cur OPTS
 	COMPREPLY=()
 	cur="${COMP_WORDS[COMP_CWORD]}"
-	DEVS=$(ls /dev/fd[0-9]* 2>/dev/null)
+	DEVS=$(for I in echo /dev/fd*; do if [ -e $I ]; then echo $I; fi; done)
 	OPTS="-n --no-verify -h --help -V --version $DEVS"
 	COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
 	return 0
diff --git a/shell-completion/fdisk b/shell-completion/fdisk
index ccf2015..ae94f10 100644
--- a/shell-completion/fdisk
+++ b/shell-completion/fdisk
@@ -6,9 +6,11 @@ _fdisk_module()
 	prev="${COMP_WORDS[COMP_CWORD-1]}"
 	case $prev in
 		'-s')
-			local PARTITIONS
-			PARTITIONS="$(for I in /sys/block/*/*/partition; do IFS='/'; DIR_ARR=($I); echo "/dev/${DIR_ARR[4]}"; done)"
-			COMPREPLY=( $(compgen -W "$PARTITIONS" -- $cur) )
+			local DEV TYPE DEVICES=''
+			while read DEV TYPE; do
+				[ $TYPE = 'part' ] && DEVICES+="$DEV "
+			done < <(lsblk -pnro name,type)
+			COMPREPLY=( $(compgen -W "$DEVICES" -- $cur) )
 			return 0
 			;;
 		'-b')
@@ -35,7 +37,11 @@ _fdisk_module()
 			return 0
 			;;
 	esac
-	COMPREPLY=( $(compgen -W "$(lsblk -o NAME,TYPE -n -r | awk '$2 ~ /disk/ {print "/dev/" $1}')" -- $cur) )
+	local DEV TYPE DEVICES=''
+	while read DEV TYPE; do
+		[ $TYPE = 'disk' ] && DEVICES+="$DEV "
+	done < <(lsblk -pnro name,type)
+	COMPREPLY=( $(compgen -W "$DEVICES" -- $cur) )
 	return 0
 }
 complete -F _fdisk_module fdisk
diff --git a/shell-completion/findmnt b/shell-completion/findmnt
index 5207b97..413d36a 100644
--- a/shell-completion/findmnt
+++ b/shell-completion/findmnt
@@ -29,9 +29,16 @@ _findmnt_module()
 			return 0
 			;;
 		'-O'|'--options')
-			local MNT_OPTS
-			MNT_OPTS=$(awk '{ n = split($4, a, ","); for (i = 0; i <= n; i++) { mnt_opts[a[i]]=1 } } END { for (i in mnt_opts) { print i } }' /etc/mtab 2>/dev/null )
-			COMPREPLY=( $(compgen -W "$MNT_OPTS" -- $cur) )
+			local MTAB_3RD I
+			declare -a TMP_ARR
+			declare -A MNT_OPTS
+			while read _ _ _ MTAB_3RD _; do
+				IFS=',' read -ra TMP_ARR <<<"$MTAB_3RD"
+				for I in ${TMP_ARR[@]}; do
+					MNT_OPTS[$I]='1'
+				done
+			done </etc/mtab
+			COMPREPLY=( $(compgen -W "$(echo ${!MNT_OPTS[@]})" -- $cur) )
 			return 0
 			;;
 		'-o'|'--output')
diff --git a/shell-completion/fsck b/shell-completion/fsck
index c3da5f5..40b9a13 100644
--- a/shell-completion/fsck
+++ b/shell-completion/fsck
@@ -29,7 +29,7 @@ _fsck_module()
 			return 0
 			;;
 	esac
-	DEVS="$(lsblk -o NAME -n -r | awk '{print "/dev/" $1}')"
+	while read dev; do DEVS+="$dev " ; done < <(lsblk -pnro name)
 	COMPREPLY=( $(compgen -W "$DEVS" -- $cur) )
 	return 0
 }
diff --git a/shell-completion/fsck.minix b/shell-completion/fsck.minix
index f01626a..6239ae4 100644
--- a/shell-completion/fsck.minix
+++ b/shell-completion/fsck.minix
@@ -3,7 +3,7 @@ _fsck.minix_module()
 	local cur OPTS DEVS
 	COMPREPLY=()
 	cur="${COMP_WORDS[COMP_CWORD]}"
-	DEVS="$(lsblk -o NAME -n -r | awk '{print "/dev/" $1}')"
+	while read dev; do DEVS+="$dev " ; done < <(lsblk -pnro name)
 	OPTS="-l -a -r -v -s -m -f -V --version"
 	COMPREPLY=( $(compgen -W "${OPTS[*]} $DEVS" -- $cur) )
 	return 0
diff --git a/shell-completion/ionice b/shell-completion/ionice
index 3087c4a..2180718 100644
--- a/shell-completion/ionice
+++ b/shell-completion/ionice
@@ -15,7 +15,7 @@ _ionice_module()
 			;;
 		'-p'|'--pid')
 			local PIDS
-			PIDS=$(\ls -d /proc/[0-9]* | sed 's|/proc/||')
+			PIDS=$(for I in /proc/[0-9]*; do echo ${I##"/proc/"}; done)
 			COMPREPLY=( $(compgen -W "$PIDS" -- $cur) )
 			return 0
 			;;
diff --git a/shell-completion/ipcrm b/shell-completion/ipcrm
index 4b1024f..fd85091 100644
--- a/shell-completion/ipcrm
+++ b/shell-completion/ipcrm
@@ -36,13 +36,20 @@ _ipcrm_module()
 			return 0
 			;;
 	esac
+	case $cur in
+		'=')
+			cur=${cur#=}
+			COMPREPLY=( $(compgen -W "shm msg sem" -- $cur) )
+			return 0
+			;;
+	esac
 	OPTS="	-m --shmem-id
 		-M --shmem-key
 		-q --queue-id
 		-Q --queue-key
 		-s --semaphore-id
 		-S --semaphore-key
-		-a --all
+		-a= --all=
 		-v --verbose
 		-h --help
 		-V --version"
diff --git a/shell-completion/login b/shell-completion/login
deleted file mode 100644
index c075f64..0000000
--- a/shell-completion/login
+++ /dev/null
@@ -1,27 +0,0 @@
-_login_module()
-{
-	local cur prev OPTS
-	COMPREPLY=()
-	cur="${COMP_WORDS[COMP_CWORD]}"
-	prev="${COMP_WORDS[COMP_CWORD-1]}"
-	case $prev in
-		'-f')
-			COMPREPLY=( $(compgen -u -- $cur) )
-			return 0
-			;;
-		'-h')
-			COMPREPLY=( $(compgen -A hostname -- $cur) )
-			return 0
-			;;
-	esac
-	case $cur in
-		-*)
-			OPTS="-p -f -h -H -V"
-			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
-			return 0
-			;;
-	esac
-	COMPREPLY=( $(compgen -u -- $cur) )
-	return 0
-}
-complete -F _login_module login
diff --git a/shell-completion/losetup b/shell-completion/losetup
index b21f05d..329bb05 100644
--- a/shell-completion/losetup
+++ b/shell-completion/losetup
@@ -16,7 +16,7 @@ _losetup_module()
 			return 0
 			;;
 		'-c'|'--set-capacity')
-			ARG="$(\ls /dev/loop[0-9]* 2>/dev/null)"
+			ARG="$(for I in /dev/loop[0-9]*; do if [ -e $I ]; then echo $I; fi; done)"
 			COMPREPLY=( $(compgen -W "$ARG" -- $cur) )
 			return 0
 			;;
diff --git a/shell-completion/lsblk b/shell-completion/lsblk
index 521cead..5498199 100644
--- a/shell-completion/lsblk
+++ b/shell-completion/lsblk
@@ -1,12 +1,17 @@
 _lsblk_module()
 {
-	local cur prev OPTS MAJOR
+	local cur prev OPTS
 	COMPREPLY=()
 	cur="${COMP_WORDS[COMP_CWORD]}"
 	prev="${COMP_WORDS[COMP_CWORD-1]}"
 	case $prev in
 		'-e'|'--exclude'|'-I'|'--include')
-			MAJOR=$(\ls /sys/dev/block/ | sed 's/:.*//')
+			local MAJOR I J
+			MAJOR=''
+			for I in /sys/dev/block/*; do
+				J=${I##*/}
+				MAJOR="$MAJOR ${J%%:*}"
+			done
 			# FIXME: how to append to a string with compgen?
 			compopt -o nospace
 			COMPREPLY=( $(compgen -W "$MAJOR" -S ',' -- $cur) )
@@ -53,7 +58,7 @@ _lsblk_module()
 			;;
 	esac
 	local DEVS
-	DEVS="$(\ls -d /sys/class/block/* | sed 's|/sys/class/block/|/dev/|g')"
+	DEVS=''; while read dev; do DEVS+="$dev " ; done < <(lsblk -pnro name)
 	COMPREPLY=( $(compgen -W "$DEVS" -- $cur) )
 	return 0
 }
diff --git a/shell-completion/lscpu b/shell-completion/lscpu
index bb76d4c..14926ec 100644
--- a/shell-completion/lscpu
+++ b/shell-completion/lscpu
@@ -1,19 +1,25 @@
 _lscpu_module()
 {
-	local cur prev OPTS
+	local cur OPTS
 	COMPREPLY=()
 	cur="${COMP_WORDS[COMP_CWORD]}"
 	prev="${COMP_WORDS[COMP_CWORD-1]}"
 	case $prev in
-		'-e'|'--extended'|'-p'|'--parse')
+		'--extended'|'=')
+			cur=${cur#=}
 			# FIXME: how to append to a string with compgen?
-			# FIXME: space in between option and argument is
-			# 	 a problem.
-			local OUTPUT
-			OUTPUT="CPU CORE SOCKET NODE BOOK CACHE
-				POLARIZATION ADDRESS CONFIGURED ONLINE"
+			OPTS="CPU,
+				CORE,
+				SOCKET,
+				NODE,
+				BOOK,
+				CACHE,
+				POLARIZATION,
+				ADDRESS,
+				CONFIGURED,
+				ONLINE,"
 			compopt -o nospace
-			COMPREPLY=( $(compgen -W "$OUTPUT" -S ',' -- $cur) )
+			COMPREPLY=( $(compgen -W "$OPTS" -- $cur) )
 			return 0
 			;;
 	esac
@@ -22,8 +28,8 @@ _lscpu_module()
 			OPTS="-a --all
 				-b --online
 				-c --offline
-				-e --extended
-				-p --parse
+				-e= --extended=
+				-p= --parse=
 				-s --sysroot
 				-x --hex
 				-h --help
diff --git a/shell-completion/mkfs b/shell-completion/mkfs
index ee6a26b..1947119 100644
--- a/shell-completion/mkfs
+++ b/shell-completion/mkfs
@@ -6,7 +6,7 @@ _mkfs_module()
 	prev="${COMP_WORDS[COMP_CWORD-1]}"
 	case $prev in
 		'-t'|'--type')
-			FSTYPES=$(for I in $(\ls /sbin/mkfs.* /usr/sbin/mkfs.* 2>/dev/null); do echo ${I##*mkfs.}; done)
+			FSTYPES=$(for I in /sbin/mkfs.* /usr/sbin/mkfs.*; do if [ -e $I ]; then echo ${I##*mkfs.}; fi; done)
 			COMPREPLY=( $(compgen -W "$FSTYPES" -- $cur) )
 			return 0
 			;;
@@ -18,7 +18,7 @@ _mkfs_module()
 			return 0
 			;;
 	esac
-	DEVS="$(lsblk -o NAME -n -r | awk '{print "/dev/" $1}')"
+	while read dev; do DEVS+="$dev " ; done < <(lsblk -pnro name)
 	COMPREPLY=( $(compgen -W "$DEVS /path/to/file" -- $cur) )
 	return 0
 }
diff --git a/shell-completion/mkfs.bfs b/shell-completion/mkfs.bfs
index b1a226a..7a47a76 100644
--- a/shell-completion/mkfs.bfs
+++ b/shell-completion/mkfs.bfs
@@ -21,7 +21,7 @@ _bfs_module()
 			return 0
 			;;
 	esac
-	DEVS="$(lsblk -o NAME -n -r | awk '{print "/dev/" $1}')"
+	while read dev; do DEVS+="$dev " ; done < <(lsblk -pnro name)
 	COMPREPLY=( $(compgen -W "$DEVS /path/to/file" -- $cur) )
 	return 0
 }
diff --git a/shell-completion/mkfs.minix b/shell-completion/mkfs.minix
index c717b3c..085a058 100644
--- a/shell-completion/mkfs.minix
+++ b/shell-completion/mkfs.minix
@@ -26,7 +26,7 @@ _mkfs.minix_module()
 			;;
 	esac
 	local DEVS
-	DEVS="$(lsblk -o NAME -n -r | awk '{print "/dev/" $1}')"
+	while read dev; do DEVS+="$dev " ; done < <(lsblk -pnro name)
 	COMPREPLY=( $(compgen -W "$DEVS" -- $cur) )
 	return 0
 }
diff --git a/shell-completion/mkswap b/shell-completion/mkswap
index c847aa9..30d517c 100644
--- a/shell-completion/mkswap
+++ b/shell-completion/mkswap
@@ -18,7 +18,6 @@ _mkswap_module()
 			return 0
 			;;
 		'-U'|--uuid)
-			COMPREPLY=( $(compgen -W "$(lsblk -n --output uuid)" -- $cur) )
 			return 0
 			;;
 	esac
diff --git a/shell-completion/nsenter b/shell-completion/nsenter
index f15a7f1..b8296b6 100644
--- a/shell-completion/nsenter
+++ b/shell-completion/nsenter
@@ -7,32 +7,29 @@ _nsenter_module()
 	case $prev in
 		'-t'|'--target')
 			local PIDS
-			PIDS=$(\ls -d /proc/[0-9]* | sed 's|/proc/||')
+			PIDS=$(for I in /proc/[0-9]*; do echo ${I##"/proc/"}; done)
 			COMPREPLY=( $(compgen -W "$PIDS" -- $cur) )
 			return 0
 			;;
-		'-m'|'--mount'|'-u'|'--uts'|'-i'|'--net'|'-n'|'--net'|'-p'|'--pid'|'-U'|'--user')
-			compopt -o filenames
-			COMPREPLY=( $(compgen -f -- $cur) )
-			return 0
-			;;
-		'-r'|'--root'|'-w'|'--wd')
-			compopt -o filenames
-			COMPREPLY=( $(compgen -o dirnames -- $cur) )
-			return 0
-			;;
 	esac
 	case $cur in
+		'=')
+			# FIXME: --root and --wd should use get only
+			# directories as compgen output.  If $cur is
+			# overwrote the same way as below in case segment
+			# for $prev the command-line will get mangled.
+			cur=${cur#=}
+			;;
 		-*)
 			OPTS="-t --target
-				-m --mount
-				-u --uts
-				-i --ipc
-				-n --net
-				-p --pid
-				-U --user
-				-r --root
-				-w --wd
+				-m= --mount=
+				-u= --uts=
+				-i= --ipc=
+				-n= --net=
+				-p= --pid=
+				-U= --user=
+				-r= --root=
+				-w= --wd=
 				-F --no-fork
 				-h --help
 				-V --version"
diff --git a/shell-completion/partx b/shell-completion/partx
index c558d36..db2eded 100644
--- a/shell-completion/partx
+++ b/shell-completion/partx
@@ -7,7 +7,6 @@ _partx_module()
 	prev="${COMP_WORDS[COMP_CWORD-1]}"
 	case $prev in
 		'-n'|'--nr')
-			COMPREPLY=( $(compgen -W "$(lsblk -o NAME,TYPE -n -r | awk '$2 ~ /part/ {print "/dev/" $1}')" -- $cur) )
 			return 0
 			;;
 		'-o'|'--output')
@@ -29,9 +28,11 @@ _partx_module()
 			return 0
 			;;
 	esac
-	local DEVS
-	DEVS="$(sblk -o NAME,TYPE -n -r | awk '$2 ~ /disk/ {print "/dev/" $1}')"
-	COMPREPLY=( $(compgen -W "$DEVS" -- $cur) )
+	local DEV TYPE DEVICES=''
+	while read DEV TYPE; do
+		[ $TYPE = 'disk' ] && DEVICES+="$DEV "
+	done < <(lsblk -pnro name,type)
+	COMPREPLY=( $(compgen -W "$DEVICES" -- $cur) )
 	return 0
 }
 complete -F _partx_module partx
diff --git a/shell-completion/prlimit b/shell-completion/prlimit
index ee49b79..bf5ff2f 100644
--- a/shell-completion/prlimit
+++ b/shell-completion/prlimit
@@ -6,7 +6,7 @@ _prlimit_module()
 	prev="${COMP_WORDS[COMP_CWORD-1]}"
 	case $prev in
 		'-p'|'--pid')
-			PIDS=$(\ls -d /proc/[0-9]* | sed 's|/proc/||')
+			PIDS=$(for I in /proc/[0-9]*; do echo ${I##"/proc/"}; done)
 			COMPREPLY=( $(compgen -W "$PIDS" -- $cur) )
 			return 0
 			;;
@@ -20,6 +20,11 @@ _prlimit_module()
 			;;
 	esac
 	case $cur in
+		'=')
+			cur=${cur#=}
+			# FIXME: is there anything what could be printed
+			# as limit value(s)
+			;;
 		-*)
 			OPTS="-p --pid
 				-o --output
@@ -28,21 +33,21 @@ _prlimit_module()
 				   --verbose
 				-h --help
 				-V --version
-				-c --core
-				-d --data
-				-e --nice
-				-f --fsize
-				-i --sigpending
-				-l --memlock
-				-m --rss
-				-n --nofile
-				-q --msgqueue
-				-r --rtprio
-				-s --stack
-				-t --cpu
-				-u --nproc
-				-v --as
-				-x --locks
+				-c= --core=
+				-d= --data=
+				-e= --nice=
+				-f= --fsize=
+				-i= --sigpending=
+				-l= --memlock=
+				-m= --rss=
+				-n= --nofile=
+				-q= --msgqueue=
+				-r= --rtprio=
+				-s= --stack=
+				-t= --cpu=
+				-u= --nproc=
+				-v= --as=
+				-x= --locks=
 				-y --rttime"
 			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
 			return 0
diff --git a/shell-completion/raw b/shell-completion/raw
index 41e03f2..27f0354 100644
--- a/shell-completion/raw
+++ b/shell-completion/raw
@@ -11,7 +11,7 @@ _raw_module()
 			return 0
 			;;
 	esac
-	COMPREPLY=( $(compgen -W "$(ls 2>/dev/null /dev/raw/*)" -- $cur) )
+	COMPREPLY=( $(compgen -W "$(for I in /dev/raw/*; do if [ -e $I ]; then echo $I; fi; done)" -- $cur) )
 	return 0
 }
 complete -F _raw_module raw
diff --git a/shell-completion/renice b/shell-completion/renice
index bc80dac..aba00d7 100644
--- a/shell-completion/renice
+++ b/shell-completion/renice
@@ -17,7 +17,7 @@ _renice_module()
 			;;
 		'-p'|'--pid')
 			local PIDS
-			PIDS=$(\ls -d /proc/[0-9]* | sed 's|/proc/||')
+			PIDS=$(for I in /proc/[0-9]*; do echo ${I##"/proc/"}; done)
 			COMPREPLY=( $(compgen -W "$PIDS" -- $cur) )
 			return 0
 			;;
diff --git a/shell-completion/resizepart b/shell-completion/resizepart
index 827638a..b178b52 100644
--- a/shell-completion/resizepart
+++ b/shell-completion/resizepart
@@ -1,16 +1,19 @@
 _resizepart_module()
 {
-	local cur OPTS
+	local cur prev OPTS
 	COMPREPLY=()
 	cur="${COMP_WORDS[COMP_CWORD]}"
 	case $COMP_CWORD in
 		1)
-			local DEVS
-			DEVS="$(lsblk -o NAME,TYPE -n -r | awk '$2 ~ /disk/ {print "/dev/" $1}')"
-			OPTS="-h --help -V --version $DEVS"
+			local DEV TYPE DEVICES=''
+			while read DEV TYPE; do
+				[ $TYPE = 'disk' ] && DEVICES+="$DEV "
+			done < <(lsblk -pnro name,type)
+			OPTS="-h --help -V --version $DEVICES"
 			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
 			;;
 		2)
+			prev="${COMP_WORDS[COMP_CWORD-1]}"
 			COMPREPLY=( $(compgen -W "$(cat /sys/block/${prev##*/}/*/partition 2>/dev/null)" -- $cur) )
 			;;
 		3)
diff --git a/shell-completion/rtcwake b/shell-completion/rtcwake
index 2010a52..1f38df8 100644
--- a/shell-completion/rtcwake
+++ b/shell-completion/rtcwake
@@ -7,7 +7,7 @@ _rtcwake_module()
 	case $prev in
 		'-d'|'--device')
 			local RTC_DEVS
-			RTC_DEVS=$(\ls /sys/class/rtc/ 2>/dev/null)
+			RTC_DEVS=$(cd /sys/class/rtc/ && echo *)
 			COMPREPLY=( $(compgen -W "$RTC_DEVS" -- $cur) )
 			return 0
 			;;
diff --git a/shell-completion/script b/shell-completion/script
index fb6c106..48f50c3 100644
--- a/shell-completion/script
+++ b/shell-completion/script
@@ -10,13 +10,11 @@ _script_module()
 			COMPREPLY=( $(compgen -c -- $cur) )
 			return 0
 			;;
-		'-t'|'--timing')
-			compopt -o filenames
-			COMPREPLY=( $(compgen -f -- $cur) )
-			return 0
-			;;
 	esac
 	case $cur in
+		'=')
+			cur=${cur#=}
+			;;
 		-*)
 			OPTS="-a --append
 				-c --command
@@ -24,7 +22,7 @@ _script_module()
 				-f --flush
 				   --force
 				-q --quiet
-				-t --timing
+				-t= --timing=
 				-V --version
 				-h --help"
 			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
diff --git a/shell-completion/setterm b/shell-completion/setterm
index a0dff44..33d2e56 100644
--- a/shell-completion/setterm
+++ b/shell-completion/setterm
@@ -6,8 +6,12 @@ _setterm_module()
 	prev="${COMP_WORDS[COMP_CWORD-1]}"
 	case $prev in
 		'-term')
-			# FIXME: terminal type list would be nice
-			COMPREPLY=( $(compgen -W "vt100 xterm linux screen etc" -- $cur) )
+			local TERM_LIST I
+			TERM_LIST=''
+			for I in /usr/share/terminfo/?/*; do
+				TERM_LIST+="${I##*/} "
+			done
+			COMPREPLY=( $(compgen -W "$TERM_LIST" -- $cur) )
 			return 0
 			;;
 		'-foreground'|'-background'|'-ulcolor'|'-hbcolor')
@@ -36,8 +40,8 @@ _setterm_module()
 			;;
 		'-dump'|'-append')
 			local NUM_CONS
-			NUM_CONS=$(ls /sys/class/tty | wc -l)
-			COMPREPLY=( $(compgen -W "$(echo {1..$NUM_CONS})" -- $cur) )
+			NUM_CONS=(/sys/class/tty/*)
+			COMPREPLY=( $(compgen -W "$(echo {1..${#NUM_CONS[*]}})" -- $cur) )
 			return 0
 			;;
 		'-file')
diff --git a/shell-completion/sfdisk b/shell-completion/sfdisk
index 041ce55..5498b0e 100644
--- a/shell-completion/sfdisk
+++ b/shell-completion/sfdisk
@@ -20,6 +20,9 @@ _sfdisk_module()
 			;;
 	esac
 	case $cur in
+		'=')
+			cur=${cur#=}
+			;;
 		-*)
 			OPTS="-s --show-size
 				-c --id
@@ -47,8 +50,8 @@ _sfdisk_module()
 				-L --Linux
 				-g --show-geometry
 				-G --show-pt-geometry
-				-A --activate
-				-U --unhide
+				-A= --activate=
+				-U= --unhide=
 				-x --show-extended
 				--leave-last
 				--IBM
@@ -66,7 +69,11 @@ _sfdisk_module()
 			return 0
 			;;
 	esac
-	COMPREPLY=( $(compgen -W "$(lsblk -o NAME,TYPE -n -r | awk '$2 ~ /disk/ {print "/dev/" $1}')" -- $cur) )
+	local DEV TYPE DEVICES=''
+	while read DEV TYPE; do
+		[ $TYPE = 'disk' ] && DEVICES+="$DEV "
+	done < <(lsblk -pnro name,type)
+	COMPREPLY=( $(compgen -W "$DEVICES" -- $cur) )
 	return 0
 }
 complete -F _sfdisk_module sfdisk
diff --git a/shell-completion/su b/shell-completion/su
index ded4b7b..c5aa81e 100644
--- a/shell-completion/su
+++ b/shell-completion/su
@@ -20,15 +20,16 @@ _su_module()
 	esac
 	case $cur in
 		-*)
-			OPTS="	-u --user
+			OPTS="	-
+				-u --user
 				-m -p --preserve-environment
 				-g --group
 				-G --supp-group
-				- -l --login
+				-l --login
 				-c --command
-				- -c
+				-c
 				--session-command
-				-- -c
+				-c
 				-f --fast
 				-s --shell
 				-h --help
diff --git a/shell-completion/sulogin b/shell-completion/sulogin
deleted file mode 100644
index 9fdc20e..0000000
--- a/shell-completion/sulogin
+++ /dev/null
@@ -1,24 +0,0 @@
-_sulogin_module()
-{
-	local cur prev OPTS
-	COMPREPLY=()
-	cur="${COMP_WORDS[COMP_CWORD]}"
-	prev="${COMP_WORDS[COMP_CWORD-1]}"
-	case $prev in
-		'-t'|'--timeout')
-			COMPREPLY=( $(compgen -W "seconds" -- $cur) )
-			return 0
-			;;
-	esac
-	case $cur in
-		-*)
-			OPTS="-p --login-shell -t --timeout -V --version -h --help"
-			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
-			return 0
-			;;
-	esac
-	compopt -o filenames
-	COMPREPLY=( $(compgen -f -- ${cur:-"/dev/tty"}) )
-	return 0
-}
-complete -F _sulogin_module sulogin
diff --git a/shell-completion/taskset b/shell-completion/taskset
index 81247cd..5311316 100644
--- a/shell-completion/taskset
+++ b/shell-completion/taskset
@@ -19,7 +19,7 @@ _taskset_module()
 			# setting an affinity the optarg has to be cpu
 			# mask.  The following is good only for getting
 			# affinity.
-			PIDS=$(\ls -d /proc/[0-9]* | sed 's|/proc/||')
+			PIDS=$(for I in /proc/[0-9]*; do echo ${I##"/proc/"}; done)
 			COMPREPLY=( $(compgen -W "$PIDS" -- $cur) )
 			return 0
 			;;
diff --git a/shell-completion/ul b/shell-completion/ul
index 89e2800..07d0731 100644
--- a/shell-completion/ul
+++ b/shell-completion/ul
@@ -6,8 +6,12 @@ _ul_module()
 	prev="${COMP_WORDS[COMP_CWORD-1]}"
 	case $prev in
 		'-t'|'--terminal')
-			# FIXME: terminal type list would be nice
-			COMPREPLY=( $(compgen -W "vt100 xterm linux screen etc" -- $cur) )
+			local TERM_LIST I
+			TERM_LIST=''
+			for I in /usr/share/terminfo/?/*; do
+				TERM_LIST+="${I##*/} "
+			done
+			COMPREPLY=( $(compgen -W "$TERM_LIST" -- $cur) )
 			return 0
 			;;
 	esac
diff --git a/shell-completion/wdctl b/shell-completion/wdctl
index 6a85e0a..42889ac 100644
--- a/shell-completion/wdctl
+++ b/shell-completion/wdctl
@@ -6,8 +6,20 @@ _wdctl_module()
 	prev="${COMP_WORDS[COMP_CWORD-1]}"
 	case $prev in
 		'-f'|'--flags')
-			# FIXME: how to get flag list?
-			COMPREPLY=( $(compgen -W "flags" -- $cur) )
+			local FLAGS
+			FLAGS="ALARMONLY
+				CARDRESET
+				EXTERN1
+				EXTERN2
+				FANFAULT
+				KEEPALIVEPING
+				MAGICCLOSE
+				OVERHEAT
+				POWEROVER
+				POWERUNDER
+				PRETIMEOUT
+				SETTIMEOUT"
+			COMPREPLY=( $(compgen -W "$FLAGS" -- $cur) )
 			return 0
 			;;
 		'-o'|'--output')
diff --git a/shell-completion/wipefs b/shell-completion/wipefs
index 427f47b..db9426e 100644
--- a/shell-completion/wipefs
+++ b/shell-completion/wipefs
@@ -11,13 +11,7 @@ _wipefs_module()
 			;;
 		'-t'|'--types')
 			local TYPES
-			TYPES="adfs affs autofs cifs coda coherent cramfs
-				debugfs devpts efs ext ext2 ext3 ext4 hfs
-				hfsplus hpfs iso9660 jfs minix msdos
-				ncpfs nfs nfs4 ntfs proc qnx4 ramfs
-				reiserfs romfs squashfs smbfs sysv tmpfs
-				ubifs udf ufs umsdos usbfs vfat xenix xfs
-				xiafs"
+			TYPES="$(blkid -k)"
 			COMPREPLY=( $(compgen -W "$TYPES" -- $cur) )
 			return 0
 			;;
@@ -31,7 +25,7 @@ _wipefs_module()
 			;;
 	esac
 	local DEVS
-	DEVS="$(\ls -d /sys/class/block/* | sed 's|/sys/class/block/|/dev/|g')"
+	DEVS=''; while read dev; do DEVS+="$dev " ; done < <(lsblk -pnro name)
 	COMPREPLY=( $(compgen -W "$DEVS" -- $cur) )
 	return 0
 }
diff --git a/shell-completion/write b/shell-completion/write
index ba67569..d41159b 100644
--- a/shell-completion/write
+++ b/shell-completion/write
@@ -9,7 +9,10 @@ _write_module()
 			return 0
 			;;
 		2)
-			local TERMS=$(for I in $(\ls /sys/class/tty 2>/dev/null); do echo "/dev/$I"; done)
+			local I TERMS=''
+			for I in /sys/class/tty/*; do
+				TERMS+="/dev${I##/sys/class/tty} "
+			done
 			COMPREPLY=( $(compgen -W "$TERMS" -- $cur) )
 			return 0
 			;;


-- 
   Sami Kerola
   http://www.iki.fi/kerolasa/

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* Re: [PATCH 02/10] bash-completion: disk-utils
  2013-03-28  1:42   ` Dave Reisner
@ 2013-04-01 15:54     ` Sami Kerola
  0 siblings, 0 replies; 33+ messages in thread
From: Sami Kerola @ 2013-04-01 15:54 UTC (permalink / raw)
  To: util-linux

On Wed, Mar 27, 2013 at 09:42:15PM -0400, Dave Reisner wrote:
> On Wed, Mar 27, 2013 at 10:07:44PM +0000, Sami Kerola wrote:
> > +			local DEVS
> > +			DEVS="$(lsblk -o NAME -n -r)"
> > +			OPTS="-h --help -V --version $DEVS"
> > +			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
> 
> You've defined OPTS as a simple string variable and then you're
> expanding it as an array. Make sure to localize any variables you might
> define in the completion function as well, or else they leak to the
> user's environment (DEVS, OPTS). In general, I'd recommend *against*
> using all capitalized variable names, particularly for local variables.

I made attempt to find non-localized variables, and correct them.  It
could be that there are still some left.

> > +			;;
> > +		2)
> > +			COMPREPLY=( $(compgen -W "$((1 + $(ls $prev?* 2>/dev/null | wc -l)))" -- $cur) )
> 
> Please don't use ls to count items in a directory. It's slightly longer
> winded, but bash does this just fine without forking:
> 
>  filecount=0
>  files=("$prev"?*)
>  [[ -e ${files[0]} ]] && filecount=${#files[*]}
> 
> This advice and the above apply to a bunch of your patches.

All instances of 'ls' execution are gone.

> > +_delpart_module()
> > +{
> > +	local cur OPTS
> > +	COMPREPLY=()
> > +	cur="${COMP_WORDS[COMP_CWORD]}"
> > +	case $COMP_CWORD in
> > +		1)
> > +			local DEVS
> > +			DEVS="$(lsblk -o NAME,TYPE -n -r | awk '$2 ~ /disk/ {print "/dev/" $1}')"
> 
>   local dev typ
>   while read dev typ; do
>     [[ $dev = 'disk' ]] && devices+=("/dev/$dev")
>   done < <(lsblk -nro name,type)

Changed to version you proposed.

> > +			OPTS="-h --help -V --version $DEVS"
> > +			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
> > +			;;
> > +		2)
> > +			COMPREPLY=( $(compgen -W "$(cat /sys/block/${prev##*/}/*/partition 2>/dev/null)" -- $cur) )
> 
> Bash has a builtin "cat" which uses mmap instead of direct reads, and is
> far more efficient:
> 
>   COMPREPLY=( $(compgen -W "$(</sys/block/"${prev##*/}"/*/partition 2>/dev/null)" -- $cur) )

I left that as-is.  Reading from a bunch of files would require a loop,
which and I don't think avoiding cat is worth of the mess.

Thank you for advice Dave.

-- 
   Sami Kerola
   http://www.iki.fi/kerolasa/

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 04/10] bash-completion: login-utils
  2013-03-28  1:42   ` Dave Reisner
@ 2013-04-01 16:05     ` Sami Kerola
  0 siblings, 0 replies; 33+ messages in thread
From: Sami Kerola @ 2013-04-01 16:05 UTC (permalink / raw)
  To: util-linux

On Wed, Mar 27, 2013 at 09:42:23PM -0400, Dave Reisner wrote:
> On Wed, Mar 27, 2013 at 10:07:46PM +0000, Sami Kerola wrote:
> > +++ b/shell-completion/chfn
> > @@ -0,0 +1,31 @@
> > +_chfn_module()
> > +{
> > +	local cur prev OPTS
> > +	COMPREPLY=()
> > +	cur="${COMP_WORDS[COMP_CWORD]}"
> > +	prev="${COMP_WORDS[COMP_CWORD-1]}"
> > +	case $prev in
> > +		'-f'|'--full-name')
> > +			COMPREPLY=( $(compgen -W "name" -- $cur) )
> > +			return 0
> > +			;;
> > +		'-o'|'--office')
> > +			COMPREPLY=( $(compgen -W "office" -- $cur) )
> > +			return 0
> > +			;;
> > +		'-p'|'--office-phone'|'-h'|'--home-phone')
> > +			COMPREPLY=( $(compgen -W "phone-nr" -- $cur) )
> > +			return 0
> > +			;;
> 
> I don't understand these. Given the previous argument being one of the
> found flags, you're completing staticly defined strings. Why complete
> anything at all?

I thought giving a textual hint to user is good idea.  The hint is now
gone.  Some of the commands are giving similar hints, other are not.  Let
see what is found to be more preferred by users and adjust accordingly.

> > +			OPTS="	-u --user
> > +				-m -p --preserve-environment
> > +				-g --group
> > +				-G --supp-group
> > +				- -l --login
> > +				-c --command
> > +				- -c
> > +				--session-command
> > +				-- -c
> 
> Please don't include the end of options marker in here. You appear to
> have duplicated -c as well.

Good catch, end of options marker is removed.  While writing this reply I
realized that the duplicates are still in my git.  Hold on I'll do rebase
fix to that.

-- 
   Sami Kerola
   http://www.iki.fi/kerolasa/

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 04/10] bash-completion: login-utils
  2013-03-28 10:05   ` Karel Zak
@ 2013-04-01 16:06     ` Sami Kerola
  0 siblings, 0 replies; 33+ messages in thread
From: Sami Kerola @ 2013-04-01 16:06 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux

On Thu, Mar 28, 2013 at 11:05:43AM +0100, Karel Zak wrote:
> On Wed, Mar 27, 2013 at 10:07:46PM +0000, Sami Kerola wrote:
> > +++ b/shell-completion/login
> > @@ -0,0 +1,27 @@
> > +_login_module()
> 
>  Unnecessary module, nobody calls login(1) from command line, it does
>  not work, it's not supported :-)
> 
> > +++ b/shell-completion/sulogin
> > @@ -0,0 +1,24 @@
> > +_sulogin_module()
> 
>  the same thing, unnecessary

Both are removed, and the agetty as well which is mentioned in later message.

-- 
   Sami Kerola
   http://www.iki.fi/kerolasa/

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 07/10] bash-completion: sys-utils
  2013-03-29 16:33   ` Karel Zak
@ 2013-04-01 16:32     ` Sami Kerola
  0 siblings, 0 replies; 33+ messages in thread
From: Sami Kerola @ 2013-04-01 16:32 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux

On Fri, Mar 29, 2013 at 05:33:35PM +0100, Karel Zak wrote:
> On Wed, Mar 27, 2013 at 10:07:49PM +0000, Sami Kerola wrote:
> > @@ -0,0 +1,25 @@
> > +_blkdiscard_module()
> > +{
> > +	local cur prev OPTS
> > +	COMPREPLY=()
> > +	cur="${COMP_WORDS[COMP_CWORD]}"
> > +	prev="${COMP_WORDS[COMP_CWORD-1]}"
> > +	case $prev in
> > +		'-o'|'--offset'|'-l'|'--length')
> > +			COMPREPLY=( $(compgen -W "num" -- $cur) )
> > +			return 0
> > +			;;
> > +	esac
> > +	case $cur in
> > +		-*)
> > +			OPTS="-o --offset -l --length -s --secure -v --verbose -h --help -V --version"
> > +			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
> > +			return 0
> > +			;;
> > +	esac
> > +	local DEVS
> > +	DEVS="$(\ls -d /sys/class/block/* | sed 's|/sys/class/block/|/dev/|g')"
> 
> It does not look like the right way how to generate the paths, because
> /sys/class/block/ contains also paths to unassociated loop devices and
> all the paths are based on kernel device names (e.g. dm-X).
> 
> I have add --paths to lsblk(8), so now you can use:
> 
>  lsblk -p -o NAME -n -l
> 
> to list the paths, for exmaple:
>  
>  /dev/sda
>  /dev/sda1
>  /dev/sda2
>  /dev/sda3
>  /dev/sda4
>  /dev/sda5
>  /dev/sda6
>  /dev/mapper/luks-10d813de-fa82-4f67-a86c-23d5d0e7c30e
>  /dev/sdb
>  /dev/sr0
> 
> it would be nice to use this solution everywhere.

I think I found all references to block devices, and replaced them with
lsblk which is using Dave's while loop.

> > +_eject_module()
> > +{
>  ....
> > +	DEVS="$(for I in /sys/class/block/*/removable; do
> > +		if [ $(cat $I) -ne 0 ]; then
> > +			OLD_IFS=$IFS
> > +			IFS='/';
> > +			ARR=($I)
> > +			echo "/dev/${ARR[4]}"
> > +			IFS=$OLD_IFS
> > +		fi
> > +	done)"
> 
>  lsblk -rpn -o RM,NAME | awk '/^1/ { print $2 }'
> 
>  The common rule is to not read data from /sys if possible.
> 
> > diff --git a/shell-completion/fstrim b/shell-completion/fstrim
> > new file mode 100644
> > index 0000000..87cb050
> > --- /dev/null
> > +++ b/shell-completion/fstrim
> > @@ -0,0 +1,25 @@
> > +_fstrim_module()
> > +{
> > +	local cur prev OPTS
> > +	COMPREPLY=()
> > +	cur="${COMP_WORDS[COMP_CWORD]}"
> > +	prev="${COMP_WORDS[COMP_CWORD-1]}"
> > +	case $prev in
> > +		'-o'|'--offset'|'-l'|'--length'|'-m'|'--minimum')
> > +			COMPREPLY=( $(compgen -W "num" -- $cur) )
> > +			return 0
> > +			;;
> > +	esac
> > +	case $cur in
> > +		-*)
> > +			OPTS="-o --offset -l --length -m --minimum -v --verbose -h --help -V --version"
> > +			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
> > +			return 0
> > +			;;
> > +	esac
> > +	local MPOINTS
> > +	MPOINTS=$(awk '{if ($1 ~ /^\//){print $2}}' /etc/mtab 2>/dev/null)
> 
>  The same problem, don't read mtab directly (for example because
>  some chars could be escaped...). Use:
> 
>    findmnt -rno SOURCE | grep '/dev'

With this I had a small whoops.  The diff I sent moment ago did not have
findmnt v.s. /etc/mtab fixes, which are now in my git.

What comes to principle of using helper commands rather than /sys or
/proc files I fully agree this is better.

-- 
   Sami Kerola
   http://www.iki.fi/kerolasa/

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 05/10] bash-completion: misc-utils
  2013-03-28  1:42   ` Dave Reisner
@ 2013-04-01 16:52     ` Sami Kerola
  0 siblings, 0 replies; 33+ messages in thread
From: Sami Kerola @ 2013-04-01 16:52 UTC (permalink / raw)
  To: util-linux

On Wed, Mar 27, 2013 at 09:42:41PM -0400, Dave Reisner wrote:
> On Wed, Mar 27, 2013 at 10:07:47PM +0000, Sami Kerola wrote:
> > +	local PARTITIONS
> > +	PARTITIONS="$(for I in /sys/block/*/*/partition; do IFS='/'; DIR_ARR=($I); echo "/dev/${DIR_ARR[4]}"; done)"
> 
> You want the loop *outside* the assignment, rather than exploding the
> contents into the array via echo:
> 
>   for part in /sys/block/*/*/partition; do
>     IFS=/ read -ra a <<< "$part"
>     partitions+=("${a[4]}")
>   done

That was changed to use 'lsblk' rather than /sys files.

> > +		'-N'|'--task')
> > +			local TID I
> > +			TID="$(for I in /proc/*/mountinfo; do IFS='/'; TID=($I); echo "${TID[2]}"; done)"
> 
> Ditto here

Corrected.

> > +			COMPREPLY=( $(compgen -W "$TID" -- $cur) )
> > +			return 0
> > +			;;
> > +		'-O'|'--options')
> > +			local MNT_OPTS
> > +			MNT_OPTS=$(awk '{ n = split($4, a, ","); for (i = 0; i <= n; i++) { mnt_opts[a[i]]=1 } } END { for (i in mnt_opts) { print i } }' /etc/mtab 2>/dev/null )
> 
> I'm not sure you want to get into this game. You're including values
> from key=val pairs (e.g. the 300 in timeout=300). Regardless, no awk
> required here
> 
>   declare -A mnt_opts
> 
>   while read _ _ _ optstring _; do
>     IFS=, read -ra opts <<< "$optstring"
>     for opt in "${opts[@]}"; do
>       mnt_opts["${opt%%=*}"]=1
>     done
>   done </etc/mtab
> 
>   opts=("${!mnt_opts[@]}")

Something similar to that was done with a small difference to avoid
reading /etc/mtab.  Notice that findmnt is using key=val pair when
matching with mount options, not key only.

> > +			COMPREPLY=( $(compgen -W "$MNT_OPTS" -- $cur) )
> > +			return 0
> > +			;;
> > +		'-o'|'--output')
> > +			# FIXME: how to append to a string with compgen?
> 
> I've been down this road when I wrote some of the systemd completion. I
> don't think you want to go there.

I am not sure if CSV filling with compgen is currently possible.  I have
a feeling the whole issue would be easier if after a completetion which
resulted to nospace a word break would be inserted.  Is that missing bash
feature, bug, or my misunderstanding how this case would be nicest to
solve.  While I do not know belive leaving the FIXME items in place is
correct thing to do.

Thanks for reviews Dave.

-- 
   Sami Kerola
   http://www.iki.fi/kerolasa/

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 02/10] bash-completion: disk-utils
  2013-03-28  9:54   ` Karel Zak
@ 2013-04-01 17:00     ` Sami Kerola
  0 siblings, 0 replies; 33+ messages in thread
From: Sami Kerola @ 2013-04-01 17:00 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux

On Thu, Mar 28, 2013 at 10:54:14AM +0100, Karel Zak wrote:
> On Wed, Mar 27, 2013 at 10:07:44PM +0000, Sami Kerola wrote:
> > diff --git a/shell-completion/mkfs b/shell-completion/mkfs
> > new file mode 100644
> > index 0000000..ee6a26b
> > --- /dev/null
> > +++ b/shell-completion/mkfs
> > @@ -0,0 +1,25 @@
> > +_mkfs_module()
> > +{
> > +	local cur prev OPTS DEVS
> > +	COMPREPLY=()
> > +	cur="${COMP_WORDS[COMP_CWORD]}"
> > +	prev="${COMP_WORDS[COMP_CWORD-1]}"
> > +	case $prev in
> > +		'-t'|'--type')
> > +			FSTYPES=$(for I in $(\ls /sbin/mkfs.* /usr/sbin/mkfs.* 2>/dev/null); do echo ${I##*mkfs.}; done)
> 
> The /sbin and /usr/sbin are the same directories on many systems, so you
> need to de-duplicate the list or use only one directory (I suggest /sbin).

The compgen will remove duplicates.  Perhaps most systems now a days has
/sbin -> /usr/sbin symlink, but because that cannot be guaranteed I would
rather let the later command to sort out duplicates than being over
clever about what is necessary.

> > diff --git a/shell-completion/mkswap b/shell-completion/mkswap
> > new file mode 100644
> > index 0000000..c847aa9
> > --- /dev/null
> > +++ b/shell-completion/mkswap
> > @@ -0,0 +1,36 @@
> > +_mkswap_module()
> > +{
> > +	local cur prev OPTS
> > +	COMPREPLY=()
> > +	cur="${COMP_WORDS[COMP_CWORD]}"
> > +	prev="${COMP_WORDS[COMP_CWORD-1]}"
> > +	case $prev in
> > +		'-p'|'--pagesize')
> > +			COMPREPLY=( $(compgen -W "bytes" -- $cur) )
> > +			return 0
> > +			;;
> > +		'-L'|'--label')
> > +			COMPREPLY=( $(compgen -W "label" -- $cur) )
> > +			return 0
> > +			;;
> > +		'-v'|'--swapversion')
> > +			COMPREPLY=( $(compgen -W "1" -- $cur) )
> > +			return 0
> > +			;;
> > +		'-U'|--uuid)
> > +			COMPREPLY=( $(compgen -W "$(lsblk -n --output uuid)" -- $cur) )
> 
>  The -U|--uuid is not a device identifier here, it's UUID you want to
>  use for the new swap superblock. So ask lsblk does not make sense. 
>  (It will generate duplicate UUIDS.)
> 
>  If you do not specify -U then mkswap will generate a new. 

Fixed.

-- 
   Sami Kerola
   http://www.iki.fi/kerolasa/

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 00/10] [pull] bash-completion
  2013-03-27 22:07 [PATCH 00/10] [pull] bash-completion Sami Kerola
                   ` (11 preceding siblings ...)
  2013-03-28  9:37 ` Karel Zak
@ 2013-04-05 14:11 ` Karel Zak
  12 siblings, 0 replies; 33+ messages in thread
From: Karel Zak @ 2013-04-05 14:11 UTC (permalink / raw)
  To: Sami Kerola; +Cc: util-linux

On Wed, Mar 27, 2013 at 10:07:42PM +0000, Sami Kerola wrote:
>   git://github.com/kerolasa/lelux-utiliteetit.git shell-completion

 Merged, thanks!

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 07/10] bash-completion: sys-utils
  2013-03-27 22:07 ` [PATCH 07/10] bash-completion: sys-utils Sami Kerola
  2013-03-29 16:33   ` Karel Zak
@ 2013-04-05 14:44   ` Karel Zak
  1 sibling, 0 replies; 33+ messages in thread
From: Karel Zak @ 2013-04-05 14:44 UTC (permalink / raw)
  To: Sami Kerola; +Cc: util-linux

On Wed, Mar 27, 2013 at 10:07:49PM +0000, Sami Kerola wrote:
> diff --git a/shell-completion/swapon b/shell-completion/swapon
> new file mode 100644
> index 0000000..83e7e24
> --- /dev/null
> +++ b/shell-completion/swapon
> @@ -0,0 +1,48 @@
> +_swapon_module()
> +{
> +	local cur prev OPTS
> +	COMPREPLY=()
> +	cur="${COMP_WORDS[COMP_CWORD]}"
> +	prev="${COMP_WORDS[COMP_CWORD-1]}"
> +	case $prev in
> +		'-p'|'--priority')
> +			# Priority range is -1 to 32767.  Perhaps these
> +			# few are enough.
> +			COMPREPLY=( $(compgen -W "$(echo {-1..9} 32767)" -- $cur) )
> +			return 0
> +			;;
> +		'--show')
> +			# FIXME: how to append to a string with compgen?
> +			local OUTPUT
> +			OUTPUT="NAME TYPE SIZE USED PRIO"
> +			compopt -o nospace
> +			COMPREPLY=( $(compgen -W "$OUTPUT" -S ',' -- $cur) )
> +			return 0
> +			;;

What about to -L <label> and -U <uuid>? For example:

  lsblk -nrp -o FSTYPE,UUID | awk '$1 ~ /swap/ { print $2 }'

returns all swaps UUIDs

> +	esac
> +	case $cur in
> +		-*)
> +			OPTS="-a --all
> +				-d --discard
> +				-e --ifexists
> +				-f --fixpgsz
> +				-p --priority
> +				-s --summary
> +				   --show
> +				   --noheadings
> +				   --raw
> +				   --bytes
> +				-v --verbose
> +				-h --help
> +				-V --version"
> +			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
> +			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) )
> +	return 0
> +}

 Would be better to offer list of block devices where is swap header?

   lsblk -nrp -o FSTYPE,NAME | awk '$1 ~ /swap/ { print $2 }'

 rather than list of files? I think that swap to files is unusual.

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2013-04-05 14:45 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-27 22:07 [PATCH 00/10] [pull] bash-completion Sami Kerola
2013-03-27 22:07 ` [PATCH 01/10] bash-completion: add bash completetion configure option Sami Kerola
2013-03-28 11:22   ` Sami Kerola
2013-03-29  9:42     ` Karel Zak
2013-03-27 22:07 ` [PATCH 02/10] bash-completion: disk-utils Sami Kerola
2013-03-28  1:42   ` Dave Reisner
2013-04-01 15:54     ` Sami Kerola
2013-03-28  9:54   ` Karel Zak
2013-04-01 17:00     ` Sami Kerola
2013-03-27 22:07 ` [PATCH 03/10] bash-completion: fdisks Sami Kerola
2013-03-28 10:01   ` Karel Zak
2013-03-27 22:07 ` [PATCH 04/10] bash-completion: login-utils Sami Kerola
2013-03-28  1:42   ` Dave Reisner
2013-04-01 16:05     ` Sami Kerola
2013-03-28 10:05   ` Karel Zak
2013-04-01 16:06     ` Sami Kerola
2013-03-27 22:07 ` [PATCH 05/10] bash-completion: misc-utils Sami Kerola
2013-03-28  1:42   ` Dave Reisner
2013-04-01 16:52     ` Sami Kerola
2013-03-27 22:07 ` [PATCH 06/10] bash-completion: schedutils Sami Kerola
2013-03-27 22:07 ` [PATCH 07/10] bash-completion: sys-utils Sami Kerola
2013-03-29 16:33   ` Karel Zak
2013-04-01 16:32     ` Sami Kerola
2013-04-05 14:44   ` Karel Zak
2013-03-27 22:07 ` [PATCH 08/10] bash-completion: term-utils Sami Kerola
2013-03-28 10:06   ` Karel Zak
2013-03-27 22:07 ` [PATCH 09/10] bash-completion: text-utils Sami Kerola
2013-03-27 22:07 ` [PATCH 10/10] bash-completion: add completion files to Makefile.am Sami Kerola
2013-03-28  1:42 ` [PATCH 00/10] [pull] bash-completion Dave Reisner
2013-03-28  9:37 ` Karel Zak
2013-03-31 23:49   ` Sami Kerola
2013-04-01 15:44   ` Sami Kerola
2013-04-05 14:11 ` Karel Zak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox