bug-bash
[Top][All Lists]
Advanced

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

Re: your mail


From: Andreas Kähäri
Subject: Re: your mail
Date: Sat, 25 Oct 2025 19:56:20 +0200

On Sat, Oct 25, 2025 at 01:38:51PM -0400, Greg Wooledge wrote:
> On Sat, Oct 25, 2025 at 11:52:25 -0500, Maksym Telychko wrote:
> >     Following code produces unexpected results:
> > 
> >     pat='\*'
> >     echo $pat
> 
> echo "$pat"
> 
> Or even better: printf '%s\n' "$pat"
> 
> The double quotes are NOT optional.  They are 100% required.

I believe that they are intentionally leaving the expansion unquoted
to have the shell perform pathname expansion on the variable contents.
The issue is that the backslash is preventing the asterisk from being
treated as a wildcard, so the user is confused about why the expected
expansion (and matching of the file called \*123) is not happening.

What they probably want is:

        echo "$p"*

or

        printf '%s\n' "$p"*

-- 
Matti Andreas Kähäri
Uppsala, Sweden

.



reply via email to

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