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


Groups > gnu.bash.bug > #15540

Re: Parameter expansion resulting empty treated as if it's not empty

From Stephane Chazelas <stephane.chazelas@gmail.com>
Newsgroups gnu.bash.bug
Subject Re: Parameter expansion resulting empty treated as if it's not empty
Date 2019-10-30 17:24 +0000
Message-ID <mailman.1.1572456318.3687.bug-bash@gnu.org> (permalink)
References <CAH7i3Lp79s5Kpe+kg6thQtqpaVai19HMoDW1SXNF9Ae71p7HGQ@mail.gmail.com> <20191030172400.pom6dbi7afqpzxtu@chaz.gmail.com>

Show all headers | View raw


2019-10-30 14:12:41 +0300, Oğuz:
[...]
> I was expecting
> 
> bash -c '${1##*"${1##*}"}' _ foo
> 
> to print an empty line too, but instead it prints foo.
[...]
> Is this a bug?

Yes,

In gdb, we see the ${1##*} expands to \177 (CTLNUL) as a result
of quote_string(). And that's used as is in the outer pattern.

It looks like an "unquoting" may be missing in that case.

See also:

$ bash -c 'printf %s "${2%%"${1##*}"*}"' bash foo $'x\177foo' | hd
00000000  78                                                |x|
00000001

It seems it's a regression, introduced in 4.0.

-- 
Stephane

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


Thread

Re: Parameter expansion resulting empty treated as if it's not empty Stephane Chazelas <stephane.chazelas@gmail.com> - 2019-10-30 17:24 +0000

csiph-web