public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: cygwin@cygwin.com
Subject: Re: Tab completion adding spurious escape characters
Date: Wed, 05 Sep 2018 15:05:00 -0000	[thread overview]
Message-ID: <72557c18-24dd-d029-bd97-59811c4c6fda@redhat.com> (raw)
In-Reply-To: <5b8f5198.1c69fb81.969c7.a997@mx.google.com>

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

      reply	other threads:[~2018-09-05 15:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-05  3:46 Steven Penny
2018-09-05 15:05 ` Eric Blake [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=72557c18-24dd-d029-bd97-59811c4c6fda@redhat.com \
    --to=eblake@redhat.com \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).