Comment 1 for bug 239561

Revision history for this message
Jilles Tjoelker (jilles) wrote :

This has been discussed at the Austin Group (POSIX fixing/development) recently, but no definitive interpretation has been issued yet. The current standard is rather vague to allow various implementations to comply.

I agree that bash's behaviour is better here, but it is possible that the interpretation will be such that dash's behaviour is also compliant.

In other cases such as echo "${foo+'ab}", I think bash interpreted the current standard incorrectly (it requires matching quotes, but if you give "${foo+'ab'}" it does not remove them), while dash has more sensible behaviour. In both cases, ksh93 (the real Korn shell from AT&T, probably packaged as "ksh") behaves sensibly, by distinguishing between +-=? and #% expansions.

Workarounds for this are to put the expansion in a lone assignment (so it does not need double-quotes around it) or otherwise add indirection through variables (e.g. q=\' then use $q instead of a single-quote).