Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #15540 > unrolled thread
| Started by | Stephane Chazelas <stephane.chazelas@gmail.com> |
|---|---|
| First post | 2019-10-30 17:24 +0000 |
| Last post | 2019-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.
Re: Parameter expansion resulting empty treated as if it's not empty Stephane Chazelas <stephane.chazelas@gmail.com> - 2019-10-30 17:24 +0000
| From | Stephane Chazelas <stephane.chazelas@gmail.com> |
|---|---|
| Date | 2019-10-30 17:24 +0000 |
| Subject | Re: 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
Back to top | Article view | gnu.bash.bug
csiph-web