It isn't just the quote removal that is confusing. The escape character is also not removed and has its special meaning.
and this also confuses me take the following 2 cases echo ${aaaaa:-$'\''} ' echo "${aaaaa:-$'\''}" bash: bad substitution: no closing `}' in "${aaaaa:-'}" and take the following 3 cases echo "${aaaaa:-$(echo $'\'')}" bash: command substitution: line 38: unexpected EOF while looking for matching `'' bash: command substitution: line 39: syntax error: unexpected end of file echo ${aaaaa:-$(echo $'\'')} ' echo "${aaaaa:-$(echo \')}" ' This can not be logical behavior. On 02/29/2012 11:26 PM, Chet Ramey wrote: > On 2/28/12 10:52 AM, John Kearney wrote: >> Actually this is something that still really confuses me as >> well. > > The key is that bash doesn't do quote removal on the `string' part > of the "${param/pat/string}" expansion. The double quotes are key; > quote removal happens when the expansion is unquoted. > > Double quotes are supposed to inhibit quote removal, but bash's > hybrid behavior of allowing quotes to escape characters but not > removing them is biting us here. >