bug-bash
[Top][All Lists]
Advanced

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

Re: Inconsistent handling of patterns with backslah (`\`) escaping


From: Andrei Borzenkov
Subject: Re: Inconsistent handling of patterns with backslah (`\`) escaping
Date: Tue, 2 Jun 2026 16:04:16 +0300

On Mon, Jun 1, 2026 at 6:07 PM Chet Ramey <chet.ramey@case.edu> wrote:
>
> On 5/31/26 10:32 AM, Andreas Schwab wrote:
> > On Mai 31 2026, Andrei Borzenkov wrote:
> >
> >> $ bar='\*'
> >> $ ls $bar
> >> ls: cannot access '\*': No such file or directory
> >> $
> >>
> >> Oops. Why it suddenly attempts to match *two* characters "\*" instead of
> >> just one literal "*"?
> >
> > Because '\*' is not a glob, so filename expansion is not performed.
>
> The rationale in the POSIX standard (yes, I realize it's not normative) says:
>
> "Patterns are matched against existing filenames and pathnames only when
> the pattern contains a '*', '?' or '[' character that will be treated as
> special. This prevents accidental removal of <backslash> characters in
> variable expansions where generating a list of matching files is not
> intended and a (usually oddly named) file with a matching name happens to
> exist."
>
> https://pubs.opengroup.org/onlinepubs/9799919799/xrat/V4_xcu_chap01.html#tag_23_02_14_04
>

I see. Thank you! Sorry for the noise.



reply via email to

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