[Bash-completion-commits] [bash-completion] 01/01: _filedir: Fix overquoted argument to compgen -d (RedHat: #1171396)

Ville Skyttä scop-guest at moszumanska.debian.org
Thu Feb 19 20:19:25 UTC 2015


This is an automated email from the git hooks/post-receive script.

scop-guest pushed a commit to branch master
in repository bash-completion.

commit d2920b7e79e5f347fed064b2a5aa952ef200e615
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Thu Feb 19 22:04:38 2015 +0200

    _filedir: Fix overquoted argument to compgen -d (RedHat: #1171396)
---
 bash_completion        |  2 +-
 test/unit/_filedir.exp | 19 ++++++++++++++++---
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/bash_completion b/bash_completion
index 24b6aa6..6eca58c 100644
--- a/bash_completion
+++ b/bash_completion
@@ -568,7 +568,7 @@ _filedir()
     local quoted x tmp
 
     _quote_readline_by_ref "$cur" quoted
-    x=$( compgen -d -- "$quoted" ) &&
+    x=$( compgen -d -- "$cur" ) &&
     while read -r tmp; do
         toks+=( "$tmp" )
     done <<< "$x"
diff --git a/test/unit/_filedir.exp b/test/unit/_filedir.exp
index a736e6e..f4e7136 100644
--- a/test/unit/_filedir.exp
+++ b/test/unit/_filedir.exp
@@ -1,6 +1,6 @@
 proc setup {} {
     assert_bash_exec {unset COMPREPLY cur}
-    assert_bash_exec {unset -f _f}
+    assert_bash_exec {unset -f _f _fd}
     save_env
     # Declare bash completion function `_f'
     assert_bash_exec { \
@@ -16,6 +16,11 @@ proc setup {} {
         _g() { local cur=$(_get_cword); unset COMPREPLY; _filedir e1; }; \
         complete -F _g g \
     }
+    # Declare bash completion function `_fd' to complete on dirs
+    assert_bash_exec { \
+        _fd() { local cur=$(_get_cword); unset COMPREPLY; _filedir -d; }; \
+        complete -F _fd fd \
+    }
     # Create directories `a*b' and `a\b' only when not running on Cygwin/Windows;
     # directories containing `*' or `\' aren't allowed on Cygwin/Windows
     if {! [is_cygwin]} {
@@ -33,8 +38,8 @@ proc teardown {} {
         assert_bash_exec {(cd $TESTDIR/tmp && rm -- a\*b/j && rmdir a\*b/ || true)}
     }
     assert_bash_exec {unset COMPREPLY cur}
-    assert_bash_exec {unset -f _f _g}
-    assert_bash_exec {complete -r f g}
+    assert_bash_exec {unset -f _f _g _fd}
+    assert_bash_exec {complete -r f g fd}
     assert_env_unmodified {
         /OLDPWD/d
         /OLD_CTYPE/d
@@ -260,4 +265,12 @@ if {
 sync_after_int
 
 
+set test "completing fd a\\  should return a\\ b/"
+set cmd "fd a\\ "
+assert_complete_dir "a\\ b/" $cmd "$::srcdir/fixtures/_filedir" $test -nospace
+
+
+sync_after_int
+
+
 teardown

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/bash-completion/bash-completion.git



More information about the Bash-completion-commits mailing list