[Bash-completion-commits] [SCM] bash-completion branch, master, updated. c5951118e906c8937312ff4605a9f47a9cfd108f

Ville Skyttä ville.skytta at iki.fi
Sun Jan 24 17:28:16 UTC 2010


The following commit has been merged in the master branch:
commit c5951118e906c8937312ff4605a9f47a9cfd108f
Author: Leonard Crestez <cdleonard at gmail.com>
Date:   Sun Jan 24 19:25:16 2010 +0200

    Fix NFS mounts completion (Alioth: #312285).

diff --git a/CHANGES b/CHANGES
index 0c3cdb7..dc626b1 100644
--- a/CHANGES
+++ b/CHANGES
@@ -66,6 +66,7 @@ bash-completion (2.x)
 
   [ Leonard Crestez ]
   * Improve ssh -o suboption completion (Alioth: #312122).
+  * Fix NFS mounts completion (Alioth: #312285).
 
   [ Raphaël Droz ]
   * Add xsltproc completion (Alioth: #311843).
diff --git a/contrib/mount b/contrib/mount
index 503c5a7..59bbd26 100644
--- a/contrib/mount
+++ b/contrib/mount
@@ -12,9 +12,9 @@ _mount()
     local cur i sm host prev
 
     COMPREPLY=()
-    cur=`_get_cword`
+    cur=`_get_cword ':'`
+    prev=`_get_pword ':'`
     [[ "$cur" == \\ ]] && cur="/"
-    prev=${COMP_WORDS[COMP_CWORD-1]}
 
     for i in $(type -P showmount) {,/usr}/{,s}bin/showmount; do
         [ -x $i ] && sm=$i && break
@@ -22,7 +22,7 @@ _mount()
 
     if [[ -n "$sm" && "$cur" == *:* ]]; then
         COMPREPLY=( $( compgen -W "$( $sm -e ${cur%%:*} | \
-            awk 'NR>1 {print $1}' )" -- "$cur" ) )
+            awk 'NR>1 {print $1}' )" -- "${cur#*:}" ) )
     elif [[ "$cur" == //* ]]; then
         host=${cur#//}
         host=${host%%/*}
diff --git a/test/completion/mount.exp b/test/completion/mount.exp
new file mode 100644
index 0000000..c1f89ce
--- /dev/null
+++ b/test/completion/mount.exp
@@ -0,0 +1,3 @@
+if {[assert_bash_type mount]} {
+    source "lib/completions/mount.exp"
+}; # if
diff --git a/test/fixtures/mount/bin/showmount b/test/fixtures/mount/bin/showmount
new file mode 100755
index 0000000..2751c4b
--- /dev/null
+++ b/test/fixtures/mount/bin/showmount
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+if [ "$1" = -e ] && [ "$2" = mocksrv ]; then
+    echo "Header line"
+    echo "/test/path"
+    echo "/test/path2"
+    echo "/second/path"
+    exit 0
+fi
+
+echo "Usage: 'showmount -e mocksrv'; nothing else works."
+exit 1
diff --git a/test/lib/completions/mount.exp b/test/lib/completions/mount.exp
new file mode 100644
index 0000000..9e40803
--- /dev/null
+++ b/test/lib/completions/mount.exp
@@ -0,0 +1,33 @@
+proc setup {} {
+    save_env
+};
+
+
+proc teardown {} {
+    assert_env_unmodified
+};
+
+
+setup
+
+
+assert_complete_any "mount "
+
+
+sync_after_int
+
+
+set test "Check completing nfs mounts"
+set expected [list /test/path /test/path2 /second/path]
+set cmd "mount mocksrv:/"
+assert_bash_exec {OLDPATH="$PATH"; PATH="$TESTDIR/fixtures/mount/bin:$PATH";}
+# This needs an explicit cword param or will output "unresolved".
+assert_complete $expected $cmd $test "/@" 20 "/"
+sync_after_int
+assert_bash_exec {PATH="$OLDPATH"; unset -v OLDPATH}
+
+
+sync_after_int
+
+
+teardown

-- 
bash-completion



More information about the Bash-completion-commits mailing list