diff options
author | Leonard Crestez <cdleonard@gmail.com> | 2010-01-24 19:25:16 +0200 |
---|---|---|
committer | Ville Skyttä <ville.skytta@iki.fi> | 2010-01-24 19:27:15 +0200 |
commit | c5951118e906c8937312ff4605a9f47a9cfd108f (patch) | |
tree | 0a2c60c9262fed5cda72703dfaa8423c5c383452 | |
parent | 258736a47bf64f05395a178c36af43e467928362 (diff) | |
download | bash-completion-c5951118e906c8937312ff4605a9f47a9cfd108f.tar.gz |
Fix NFS mounts completion (Alioth: #312285).
-rw-r--r-- | CHANGES | 1 | ||||
-rw-r--r-- | contrib/mount | 6 | ||||
-rw-r--r-- | test/completion/mount.exp | 3 | ||||
-rwxr-xr-x | test/fixtures/mount/bin/showmount | 12 | ||||
-rw-r--r-- | test/lib/completions/mount.exp | 33 |
5 files changed, 52 insertions, 3 deletions
@@ -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 503c5a7e..59bbd268 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 00000000..c1f89ce1 --- /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 00000000..2751c4ba --- /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 00000000..9e40803e --- /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 |