[Bash-completion-devel] [bash-completion-Bugs][312285] nfs mount completion broken
bash-completion-bugs at alioth.debian.org
bash-completion-bugs at alioth.debian.org
Mon Jan 25 04:43:03 UTC 2010
Bugs item #312285, was changed at 23.01.2010 01:03 by Ildar Mulyukov
You can respond by visiting:
https://alioth.debian.org/tracker/?func=detail&atid=413095&aid=312285&group_id=100114
Status: Closed
Priority: 3
Submitted By: Leonard Crestez (cdleonard-guest)
Assigned to: Nobody (None)
Summary: nfs mount completion broken
Distribution: None
Originally reported in: None
Milestone: 2.0
Status: Fix Committed
Original bug number:
Initial Comment:
Original report by "Ildar Mulyukov <ildar at users.sourceforge.net>" to the bash-completion-devel list.
"""
hi! I checked current GIT. This completes wrong:
$ mount nfsserver:/<TAB>
bin/ etc/ lost+found/ opt/ sbin/ tmp/
boot/ home/ media/ proc/ srv/ usr/
dev/ lib/ mnt/ root/ sys/ var/
I couldn't debug it myself, sorry :-(
Best regards,
"""
It's very likely that this is because COMP_WORDBREAKS now contains a colon. I don't use NFS; could somebody else test the following tiny patch?
diff --git a/contrib/mount b/contrib/mount
index 0474df0..99e77b4 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 {,/usr}/{,s}bin/showmount; do [ -x $i ] && sm=$i && break; done
----------------------------------------------------------------------
Comment By: Ildar Mulyukov (ildar-guest)
Date: 25.01.2010 10:43
Message:
Hi, Leonard!
Thanks a lot, it's working!
Regards, Ildar
----------------------------------------------------------------------
Comment By: Ville Skyttä (scop-guest)
Date: 24.01.2010 23:38
Message:
Thanks! Applied in git with some changes:
* This hunk seems unrelated and a no-op so skipped:
- [ -x $i ] && sm=$i && break
+ [[ -x $i ]] && sm="$i" && break;
* Portability fixes to the mock showmount
* Added CHANGES entry
http://git.debian.org/?p=bash-completion/bash-completion.git;a=commitdiff;h=c5951118e906c8937312ff4605a9f47a9cfd108f
To make committers' job easier in the future, see also:
http://git.debian.org/?p=bash-completion/bash-completion.git;a=commitdiff;h=5c5d804696ad715c4d8516b061564d0ab5115ab6
...and consider submitting the patches as attachments instead of inlining them.
----------------------------------------------------------------------
Comment By: Leonard Crestez (cdleonard-guest)
Date: 24.01.2010 22:00
Message:
Here is a new patch against latest HEAD. It should work this time.
The patch contains an automated test. There's a fake showmount in fixtures/mount/bin.
diff --git a/contrib/mount b/contrib/mount
index 503c5a7..302ad98 100644
--- a/contrib/mount
+++ b/contrib/mount
@@ -12,17 +12,17 @@ _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
+ [[ -x $i ]] && sm="$i" && break;
done
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..dfc54f1
--- /dev/null
+++ b/test/fixtures/mount/bin/showmount
@@ -0,0 +1,12 @@
+#! /bin/bash
+
+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
----------------------------------------------------------------------
Comment By: Ildar Mulyukov (ildar-guest)
Date: 23.01.2010 10:56
Message:
Hi, Leonard!
Thanks for opening this bug.
Unfortunately your patch doesn't fix the problem.
While you don't use NFS, you can fake it with a simple script. Name it showmount and put in PATHs before /usr/sbin:
#!/bin/sh
echo /1
echo /1/2
echo /3
----------------------------------------------------------------------
You can respond by visiting:
https://alioth.debian.org/tracker/?func=detail&atid=413095&aid=312285&group_id=100114
More information about the Bash-completion-devel
mailing list