public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Tab completion adding spurious escape characters
@ 2018-09-05  3:46 Steven Penny
  2018-09-05 15:05 ` Eric Blake
  0 siblings, 1 reply; 2+ messages in thread
From: Steven Penny @ 2018-09-05  3:46 UTC (permalink / raw)
  To: cygwin

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?


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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Tab completion adding spurious escape characters
  2018-09-05  3:46 Tab completion adding spurious escape characters Steven Penny
@ 2018-09-05 15:05 ` Eric Blake
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Blake @ 2018-09-05 15:05 UTC (permalink / raw)
  To: cygwin

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-09-05 15:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-05  3:46 Tab completion adding spurious escape characters Steven Penny
2018-09-05 15:05 ` Eric Blake

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).