[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Parameter expansion resulting empty treated as if it's not empty
From: |
Stephane Chazelas |
Subject: |
Re: Parameter expansion resulting empty treated as if it's not empty |
Date: |
Wed, 30 Oct 2019 17:24:00 +0000 |
User-agent: |
NeoMutt/20171215 |
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