Chet Ramey wrote: > I can't reproduce this. I get a\ (escaped space), and then listing of > possible completions with subsequent TABs. This is the correct behavior. > Could it have something to do with any completion functions you have > defined?
Yes, it does. When I tested without any completion functions it works as expected. Any tips on how to debug this issue? Setting set -x in .bashrc produces: First TAB: nelch...@nelchael ~$ cat a+ local cur opt ++ _get_cword ++ [[ 1 -eq 0 ]] ++ [[ 5 == \5 ]] ++ printf %s a + cur=a + [[ a == --*=* ]] + [[ a == -* ]] + [[ cat == rmdir ]] + _filedir + local 'IFS= ' xspec + _expand + [[ a == \~*/* ]] + [[ a == \~* ]] + toks=() + local toks tmp + toks=(${to...@]-} $( compgen -d -- "$(quote_readline "$cur")" | { while read -r tmp; do # TODO: I've removed a "[ -n $tmp ] &&" before, # and everything works again. If this bug # suddenly appears again (i.e. "cd /b<TAB>" # becomes "cd /"), remember to check for # other similar conditionals (here and # _filedir_xspec()). --David echo $tmp done } )) +++ quote_readline a +++ local t=a +++ echo ''\''a'\''' ++ compgen -d -- ''\''a'\''' ++ read -r tmp + [[ '' != -d ]] + xspec= + toks=(${to...@]-} $( compgen -f -X "$xspec" -- "$(quote_readline "$cur")" | { while read -r tmp; do [ -n $tmp ] && echo $tmp done } )) +++ quote_readline a +++ local t=a +++ echo ''\''a'\''' ++ compgen -f -X '' -- ''\''a'\''' ++ read -r tmp ++ '[' -n 'a File With spaces' ']' ++ echo 'a File With spaces' ++ read -r tmp ++ '[' -n 'a file with spaces' ']' ++ echo 'a file with spaces' ++ read -r tmp ++ '[' -n 'a File with spaces' ']' ++ echo 'a File with spaces' ++ read -r tmp + COMPREPLY=("${comprep...@]}" "${to...@]}") \ And here's output after hitting TAB again: + local cur opt ++ _get_cword ++ [[ 3 -eq 0 ]] ++ [[ 7 == \7 ]] ++ printf %s 'a\ ' + cur='a\ ' + [[ a\ == --*=* ]] + [[ a\ == -* ]] + [[ cat == rmdir ]] + _filedir + local 'IFS= ' xspec + _expand + [[ a\ == \~*/* ]] + [[ a\ == \~* ]] + toks=() + local toks tmp + toks=(${to...@]-} $( compgen -d -- "$(quote_readline "$cur")" | { while read -r tmp; do # TODO: I've removed a "[ -n $tmp ] &&" before, # and everything works again. If this bug # suddenly appears again (i.e. "cd /b<TAB>" # becomes "cd /"), remember to check for # other similar conditionals (here and # _filedir_xspec()). --David echo $tmp done } )) +++ quote_readline 'a\ ' +++ local 't=a\\ ' +++ echo ''\''a\\ '\''' ++ compgen -d -- ''\''a\\ '\''' ++ read -r tmp + [[ '' != -d ]] + xspec= + toks=(${to...@]-} $( compgen -f -X "$xspec" -- "$(quote_readline "$cur")" | { while read -r tmp; do [ -n $tmp ] && echo $tmp done } )) ++ read -r tmp +++ quote_readline 'a\ ' +++ local 't=a\\ ' +++ echo ''\''a\\ '\''' ++ compgen -f -X '' -- ''\''a\\ '\''' + COMPREPLY=("${comprep...@]}" "${to...@]}") The same function works in 3.2 ok, below is _filedir(): _filedir() { local IFS=$'\t\n' xspec _expand || return 0 local toks=( ) tmp toks=( ${to...@]-} $( compgen -d -- "$(quote_readline "$cur")" | { while read -r tmp; do # TODO: I've removed a "[ -n $tmp ] &&" before, # and everything works again. If this bug # suddenly appears again (i.e. "cd /b<TAB>" # becomes "cd /"), remember to check for # other similar conditionals (here and # _filedir_xspec()). --David echo $tmp done } )) if [[ "$1" != -d ]]; then xspec=${1:+"!*.$1"} toks=( ${to...@]-} $( compgen -f -X "$xspec" -- "$(quote_readline "$cur")" | { while read -r tmp; do [ -n $tmp ] && echo $tmp done } )) fi COMPREPLY=( "${comprep...@]}" "${to...@]}" ) } -- Krzysiek Pawlik <nelchael at gentoo.org> key id: 0xBC555551 desktop-misc, java, apache, ppc, vim, kernel, python...
signature.asc
Description: OpenPGP digital signature