Tab completion adding spurious escape characters

Eric Blake eblake@redhat.com
Wed Sep 5 15:05:00 GMT 2018


On 09/04/2018 10:46 PM, Steven Penny wrote:
> If you create this file:
> 
>     touch -- \''-#%.!$&(),;@[]^`{}=_~+9zZ'
> 
> Then enter "touch", "Tab", "Tab", you get this:
> 
>     touch \'-#%.\!\$\&\(\)\,\;\@\[\]\^\`\{\}\=_~+9zZ
> 
> So the shell is saying that these characters need to be escaped:
> 
>     ' ! $ & ( ) , ; @ [ ] ^ ` { } =
> 
> but they dont, not all of them:
> 
>     $ (set -x; true \' \! \$ \& \( \) \, \; \@ \[ \] \^ \` \{ \} \=)
>     + true \' '!' '$' '&' '(' ')' , ';' @ '[' ']' '^' '`' '{' '}' =
> 
> Notice carefully that the shell removes escaping for these:
> 
>     , @ =
> 
> but tab completion is adding it. Is this an issue of Readline or Cygwin?

Not cygwin specific, because you get the same behavior on Linux. 
Therefore, it is is an upstream readline/bash decision on what to escape 
during tab completion.  (And since tab completion is a readline feature, 
and readline is implemented by the author of bash, there really is no 
reason to assume it would be an issue specific to Cygwin).

Also, whether or not those characters are escaped does not generally 
change the actual command line you are executing, and it is a lot less 
code to just blindly escape things than to figure out a minimal output, 
so I see no reason to bother changing things.  (Actually, there ARE 
cases where = and \= behave differently, but not in what you typed. For 
a demonstration:

$ echo 'echo hi' > ./a=b
$ chmod +x a=b
$ a=c
$ echo $a
c
$ (PATH=:$PATH; a\=b; echo $a)
hi
c
$ (PATH=:$PATH; a=b; echo $a)
b

As for , and @, they are never special to the shell, but as I argued 
above, it's easier to write tab completion code that doesn't have to 
special case things than to worry about what is or is not special)

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list