bug-bash
[Top][All Lists]
Advanced

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

Re: Setting nullglob causes variables containing backslashes to be expan


From: Chet Ramey
Subject: Re: Setting nullglob causes variables containing backslashes to be expanded to an empty string
Date: Wed, 7 Aug 2019 09:13:06 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.8.0

On 8/6/19 2:18 PM, Mohamed Akram wrote:
> Bash version: GNU bash, version 5.0.7(1)-release (x86_64-apple-darwin18.5.0)
> 
> Example:
> 
> shopt -s nullglob
> a='\x30'
> echo $a
> 
> Expected output:
> 
> \x30
> 
> Actual output:

Yes. Bash-5.0 changed so that backslashes in patterns are special
characters. This is what POSIX requires. There's more of an explanation
here:

https://lists.gnu.org/archive/html/bug-bash/2019-02/msg00151.html

So if patterns containing backslashes are patterns to be expanded (e.g.,
if the pattern is \x30 and there is a file named `x30' in the current
directory, the pattern should expand to `x30'), a failed pattern expansion
should be subject to the nullglob setting.

There is currently a ferocious -- well, it's mostly died down, but still
going on -- discussion on the POSIX mailing list about what POSIX *should*
say, but the current bash behavior is more-or-less -- POSIX doesn't have a
`nullglob' option -- what the POSIX shell group says should happen. I
assume there will be an interpretation for

http://austingroupbugs.net/view.php?id=1234

and I'll change bash to align with it.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/



reply via email to

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