Re: Inconsistent handling of patterns with backslah (`\`) escaping
From:
Duncan Roe
Subject:
Re: Inconsistent handling of patterns with backslah (`\`) escaping
Date:
Mon, 1 Jun 2026 18:01:46 +1000
On Mon, Jun 01, 2026 at 05:34:21AM +0700, Robert Elz wrote:
> Two other things I should have included in the previous message:
>
> Nothing changes if a word is treated as a glob, and subjected to
> filename expansion, and fails to match (in bash, depending on whatever
> options control the behaviour in that case) - in "standard" mode, the
> original word is retained unchanged.
>
> And second, the best way to write a literal * in a filename, is [*]
> not \* ... there's no question but that [*] is a glob, which matches
> a literal * and nothing else.
>
> kre
>
>
>
There's actually a real bug in here:
| 16:25:38$ bar='\**'
| 16:25:43$ echo $bar
| \**
| 16:25:51$ touch '*'
| 16:26:08$ echo $bar
| *
The behaviour of `echo $bar` changed after `touch '*'`.
The value of bar stays the same:
| 16:46:40$ echo "$bar"
| \**
| 16:47:31$ type echo
| echo is a shell builtin
| 16:48:55$ /usr/bin/echo $bar
| \**
| 16:49:22$ echo $bar
| \**
| 16:49:46$ touch '*'
| 16:50:13$ echo $bar
| *
| 16:50:17$ echo "$bar"
| \**
and now:
| 17:54:41$ /usr/bin/echo $bar
| *
| 17:55:48$ echo "$bar"
| \**
I don't know how to reproduce this reliably. It just comes and goes.
Cheers ... Duncan.