bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: PATCH] unquoted_glob_pattern_p: better recognition


From: Robert Elz
Subject: Re: PATCH] unquoted_glob_pattern_p: better recognition
Date: Fri, 13 Oct 2023 12:38:49 +0700

    Date:        Thu, 12 Oct 2023 16:11:09 -0700
    From:        Grisha Levit <grishalevit@gmail.com>
    Message-ID:  
<CAMu=Brph8cCNr1aOFxnbfb-3CmQ1ts=iizzL7qbXjq=o=nCmwA@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

[Prev in Thread] Current Thread [Next in Thread]