Date:        Thu, 12 Oct 2023 16:11:09 -0700
    From:        Grisha Levit <grishale...@gmail.com>
    Message-ID:  
<CAMu=Brph8cCNr1aOFxnbfb-3CmQ1ts=iizzL7qbXjq=o=nc...@mail.gmail.com>

  | If we want to preserve the behavior of unquoted backslash
  | causing a following
  | quoted character to become unquoted after quote_string_for_globbing:

Please don't.   Something explicity quoted in the shell input
(regardless of what quoting mechanism was used) should be treated
literally (never as magic) whatever else happens to appear
adjacent to it as the result of an expansion.  Anything else
is insanity.

That some other shell is also broken here is irrelevant.

The \ that appears from expanding $B in the example could be
(and probably should be) treated as it were escaping any other
char in the pattern for which the escape changes nothing in
interpretation like if we had

        $Bx    or    $B"x"

or could (perhaps) be treated like a trailing \ -- one with
no work to do -- but never as undoing something literally
in the input.

What $B$B should do is less clear, but treating that as an escaped
\ is probably the most reasonable, but whatever falls out of
the rest of the impl would be OK.   It is only important that
a \ that appears from an unquoted expansion escapes an otherwise
magic char from the same expansion, as that's where this is needed
so

        X='\**'

used as $X will match files/strings starting with a '*' just
as if we had written \** explicitly in the script.  What happens
from $B$X  (using the B as has been used in this thread, and
X as above) or if A='**' what $B$A matches are less important,
as those aren't nearly as likely to be used.

But, anything quoted in the command line under consideration
must remain literal while processing that command.

kre

Reply via email to