Fix NFS mounts completion (Alioth: #312285).
This commit is contained in:
parent
258736a47b
commit
c5951118e9
1
CHANGES
1
CHANGES
@ -66,6 +66,7 @@ bash-completion (2.x)
|
|||||||
|
|
||||||
[ Leonard Crestez ]
|
[ Leonard Crestez ]
|
||||||
* Improve ssh -o suboption completion (Alioth: #312122).
|
* Improve ssh -o suboption completion (Alioth: #312122).
|
||||||
|
* Fix NFS mounts completion (Alioth: #312285).
|
||||||
|
|
||||||
[ Raphaël Droz ]
|
[ Raphaël Droz ]
|
||||||
* Add xsltproc completion (Alioth: #311843).
|
* Add xsltproc completion (Alioth: #311843).
|
||||||
|
@ -12,9 +12,9 @@ _mount()
|
|||||||
local cur i sm host prev
|
local cur i sm host prev
|
||||||
|
|
||||||
COMPREPLY=()
|
COMPREPLY=()
|
||||||
cur=`_get_cword`
|
cur=`_get_cword ':'`
|
||||||
|
prev=`_get_pword ':'`
|
||||||
[[ "$cur" == \\ ]] && cur="/"
|
[[ "$cur" == \\ ]] && cur="/"
|
||||||
prev=${COMP_WORDS[COMP_CWORD-1]}
|
|
||||||
|
|
||||||
for i in $(type -P showmount) {,/usr}/{,s}bin/showmount; do
|
for i in $(type -P showmount) {,/usr}/{,s}bin/showmount; do
|
||||||
[ -x $i ] && sm=$i && break
|
[ -x $i ] && sm=$i && break
|
||||||
@ -22,7 +22,7 @@ _mount()
|
|||||||
|
|
||||||
if [[ -n "$sm" && "$cur" == *:* ]]; then
|
if [[ -n "$sm" && "$cur" == *:* ]]; then
|
||||||
COMPREPLY=( $( compgen -W "$( $sm -e ${cur%%:*} | \
|
COMPREPLY=( $( compgen -W "$( $sm -e ${cur%%:*} | \
|
||||||
awk 'NR>1 {print $1}' )" -- "$cur" ) )
|
awk 'NR>1 {print $1}' )" -- "${cur#*:}" ) )
|
||||||
elif [[ "$cur" == //* ]]; then
|
elif [[ "$cur" == //* ]]; then
|
||||||
host=${cur#//}
|
host=${cur#//}
|
||||||
host=${host%%/*}
|
host=${host%%/*}
|
||||||
|
3
test/completion/mount.exp
Normal file
3
test/completion/mount.exp
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
if {[assert_bash_type mount]} {
|
||||||
|
source "lib/completions/mount.exp"
|
||||||
|
}; # if
|
12
test/fixtures/mount/bin/showmount
vendored
Executable file
12
test/fixtures/mount/bin/showmount
vendored
Executable file
@ -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
|
33
test/lib/completions/mount.exp
Normal file
33
test/lib/completions/mount.exp
Normal file
@ -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
|
Loading…
x
Reference in New Issue
Block a user