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: Greg Wooledge
Subject: Re: Setting nullglob causes variables containing backslashes to be expanded to an empty string
Date: Tue, 6 Aug 2019 16:00:21 -0400
User-agent: Mutt/1.10.1 (2018-07-13)

On Tue, Aug 06, 2019 at 06:18:27PM +0000, 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:
> 

Also happens in bash 5.0 on Debian GNU/Linux.  It does not happen in
bash 4.4 or earlier (I tried back to 3.2) on the same machine.

For the record,   echo $a   is *not* a sane way to see the contents of
your variable.   printf %s\\n "$a"   is the safest.   echo "$a"   would
be marginally acceptable in some cases.  Unquoted $a is a bad idea, which
may explain why it didn't receive enough testing to uncover whatever
this is.  No sane person would do it.



reply via email to

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