Spakman / urchin

A Unix shell for Ruby programmers.
http://spakman.github.com/urchin/
GNU General Public License v3.0
36 stars 1 forks source link

Tab completion of unquoted filenames with spaces are not escaped #2

Closed Spakman closed 13 years ago

Spakman commented 13 years ago

For example:

touch "/tmp/hello Spakman"
ls /tmp/hel<tab><tab>  -->  ls /tmp/hello Spakman

(it should produce --> ls /tmp/hello\ Spakman)

Spakman commented 13 years ago

I have already sunk many hours into trying to solve this; what I expected to be a trivial problem. At this stage I wanted to avoid getting too heavily invested in Readline, but since this problem is currently my biggest annoyance with Urchin it seems unavoidable!

Reluctantly, I'm starting to wonder if this is even actually possible with the default Ruby 1.8 Readline binding.

If anyone knows the magic incantations of:

Readline.basic_quote_characters
Readline.basic_word_break_characters
Readline.completer_quote_characters
Readline.completer_word_break_characters
Readline.filename_quote_characters

Please let me know!

Spakman commented 13 years ago

It is possible to get around the issue posted here with some hackery. A more complicated example that I have not managed to solve is:

mkdir -p /tmp/completion/aaa\ bbb/123\ 456/
touch /tmp/completion/aaa\ bbb/123\ 456/a\ file

Then ls /tmp/completion and start tabbing away...

Spakman commented 13 years ago

Another, perhaps temporary, solution might be to detect spaces in filenames, quote (") the entire filepath and make file completion quoting aware.

It might at least allow us to use some nasty hacks to get example above to "work".

Spakman commented 13 years ago

Finally, finally, finally fixed this bug. Quite easily the longest time I've ever spent on a single problem - hundreds of hours of work. I'm very happy it's over!

In case you missed it in the commit notes, this fix relies on the quote-dequote branch of rb-readline[1]. Hopefully this will be merged into master for the next release.

1 - https://github.com/luislavena/rb-readline/tree/quote-dequote

Spakman commented 12 years ago

This bug was solved by these commits in rb-readline: