_filedir: Fix overquoted argument to compgen -d (RedHat: #1171396)

master
Ville Skyttä 2015-02-19 22:04:38 +02:00
parent d423969756
commit d2920b7e79
2 changed files with 17 additions and 4 deletions

View File

@ -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"

View File

@ -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