[Bug 10821] ash: bash dollar not expanding inside quoted braced parameter expansion

bugzilla at busybox.net bugzilla at busybox.net
Sun Mar 4 23:00:05 UTC 2018


https://bugs.busybox.net/show_bug.cgi?id=10821

--- Comment #5 from avih <avihpit at yahoo.com> ---
>> pattern in ${param#pattern} should be considered unquoted regardless if the whole expansion is or isn't quoted

>> Well, it does not look like it works that way in bash:

Not sure how bash is related. This is a POSIX thing, which says the following
about ${param#pattern}:

> Enclosing the full parameter expansion string in double-quotes shall not cause
> the following four varieties of pattern characters to be quoted, whereas
> quoting characters within the braces shall have this effect.

Regardless though, I also don't think your examples demonstrate that bash
disagrees with this posix definition. My main argument is that quoting the
entire expansion doesn't change the result.

However, I do think bash exhibits incorrect behavior at _${x#[a\]]}_ -> _]_

I believe bash interprets the pattern _${x#[a\]]}_ as if it was _${x#[]a]}_ 
i.e. only character class pattern of the char ']' or the letter 'a' . i.e. it
takes \] as a literal char to be matched in the class.

But this is incorrect by posix. The bracket pattern spec clearly says that \
loses its special meaning inside the brackets, and ] can only be in a character
class as the first char.

Therefore the pattern _${x#[a\]]}_ should mean (in posix): first char which is
the letter 'a' or backslash, followed by ], which does match the whole of x,
therefore as far as I can tell, it should have resulted in __ .

This is a bash bug IMO, but not related to interpreting the pattern quoted or
unquoted. As far as I can tell, and in your examples and mine, bash interprets
it always unquoted.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the busybox-cvs mailing list