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


Groups > gnu.bash.bug > #15540 > unrolled thread

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

Started byStephane Chazelas <stephane.chazelas@gmail.com>
First post2019-10-30 17:24 +0000
Last post2019-10-30 17:24 +0000
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

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

FromStephane Chazelas <stephane.chazelas@gmail.com>
Date2019-10-30 17:24 +0000
SubjectRe: Parameter expansion resulting empty treated as if it's not empty
Message-ID<mailman.1.1572456318.3687.bug-bash@gnu.org>
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

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web