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: Mon, 1 Jun 2026 11:08:49 +0300

On Sun, May 31, 2026 at 5:32 PM Andreas Schwab <schwab@linux-m68k.org> 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.
>

If this is not a glob, I expect '\' to be stripped (quote removal)
before the result is used in the command.

bash is using unquoted_glob_pattern_p () to check "if STRING has any
unquoted special globbing chars in it". This function treats both
CTLESC and
'\' as quote characters. But subsequent dequote_string () only removes
CTLESC leaving '\' in place.



reply via email to

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