Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #15307

Re: Setting nullglob causes variables containing backslashes to be expanded to an empty string

From Chet Ramey <chet.ramey@case.edu>
Newsgroups gnu.bash.bug
Subject Re: Setting nullglob causes variables containing backslashes to be expanded to an empty string
Date 2019-08-07 09:13 -0400
Message-ID <mailman.990.1565183594.1985.bug-bash@gnu.org> (permalink)
References <5202404D-4B1E-4627-9FDE-2E0C5608A5B7@outlook.com> <55e44b7d-7690-9e84-c37f-0485d3259fbc@case.edu>

Show all headers | View raw


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/

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Re: Setting nullglob causes variables containing backslashes to be expanded to an empty string Chet Ramey <chet.ramey@case.edu> - 2019-08-07 09:13 -0400

csiph-web