#313514 bash-completion fails with e.g., ls and newlines in file names

#313514#5
Date:
2005-06-14 05:37:41 UTC
From:
To:
anthony@bohr:foo$ touch "$(echo -e 'foo\nbar')"
anthony@bohr:foo$ ls -b
foo\nbar
anthony@bohr:foo$ ls f<tab><tab>
bar  foo

Notice how instead of completing foo?bar (where ? = newline) it offers
to complete either foo or bar.

#313514#10
Date:
2005-11-08 10:29:30 UTC
From:
To:
Hi,

this bug hit me today, too, when I wanted to delete filenames with
newlines.

Completion for mv, rm and ls (haven't tested others) show this bug, even if
you use M-* (insert-completions).

$ rm fo<M-*>

results even to:

$ rm bar foo

It does not fail on e. g. echo:

$ echo fo<tab>

$ echo 'foo
bar'

(M-* works here correctly, too.)

Interesting point is, that it _only_ seems to break on newlines. Doing

$ touch "$(echo -e 'evil filename with\nan LF and other special chars ($bla) : , "')"
$ rm ev<M-*>

results in:

$ rm an\ LF\ and\ other\ special\ chars\ \(\$bla\)\ \:\ \,\ \" evil\ filename\ with

As a little workaround one can either write

$ echo rm ev<tab>

or

$ xrm ev<tab>

then using C-a or Home and deleting "echo " or "x" before execution. The
last one maybe only works if there isn't a xrm file/function/alias or
something. And oh, I just found out, you can even do

$ rm ev<M-/>

(M-/ is by default bound to complete-filename. M-x BTW can be entered as ESC
x, too.)

Greetings,
 Mike

#313514#15
Date:
2006-05-18 11:29:44 UTC
From:
To:
Package: bash
Version: 3.1-4
Followup-For: Bug #313514
$ touch x=y
then
$ ls x<TAB>
completes correctly;
$ ls x=<TAB>
completes (bizarrely) to x=x\=y and
$ x=<TAB>
as expected completes to a list of all filenames in cwd (though if . is
in $PATH maybe it should complete to x=y ?).

Best,
Michael