Thread (7 messages) 7 messages, 3 authors, 2013-07-30
STALE4702d

[PATCH 2/3] shell-completion: Add kmod static-nodes

From: Lucas De Marchi <hidden>
Date: 2013-07-30 06:48:10
Subsystem: the rest · Maintainer: Linus Torvalds

From: Lucas De Marchi <redacted>

---
 shell-completion/bash/kmod | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
diff --git a/shell-completion/bash/kmod b/shell-completion/bash/kmod
index 81dbf46..2409eda 100644
--- a/shell-completion/bash/kmod
+++ b/shell-completion/bash/kmod
@@ -24,6 +24,28 @@ __contains_word () {
     return 1
 }
 
+_kmod_static_nodes () {
+    local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
+    local opts='-o --output -f --format -h --help'
+
+    echo "cur='$cur' prev='$prev'" >> /tmp/a.txt
+    case $prev in
+	'-o' | '--output')
+	    compopt -o filenames
+	    COMPREPLY=( $(compgen -f -- "$cur") )
+	    ;;
+	'-f' | '--format')
+	    COMPREPLY=( $(compgen -W 'human tmpfiles devname' -- "$cur") )
+	    ;;
+	'-'*)
+	    COMPREPLY=()
+	    ;;
+	*)
+	    COMPREPLY=( $(compgen -W "$opts" -- "$cur") )
+	    ;;
+    esac
+}
+
 _kmod() {
     local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
     local verb comps
@@ -44,6 +66,11 @@ _kmod() {
 
     if [[ -z $verb ]]; then
 	comps=${VERBS[*]}
+    elif __contains_word "$verb" ${VERBS[STATIC-NODES]}; then
+	_kmod_static_nodes
+	return 0
+    else
+	comps=''
     fi
 
     COMPREPLY=( $(compgen -W '$comps' -- "$cur" ) )
-- 
1.8.3.4
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help