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