Re: Probably not a bug but I was surprised: $' does not work inside "..." close.
Greg Wooledge writes: > $'...' is a form of quoting, not an expansion. It won't "work" inside > of another type of quoting, just like '...' will not "work" inside "...". Yes, that's true, and makes sense when I think about it. But the manual page doesn't consistently phrase it that way: Words of the form $'string' are treated specially. The word expands to string, ... As you say, it isn't "expand". And, being a quote construct, it's not a word per se, it prevents contained characters from breaking words. On the flip side, it doesn't look like there's a consistent word for "the effective value of a quote construct", although "quote removal" is used in some places. Dale
Re: Probably not a bug but I was surprised: $' does not work inside "..." close.
On Wed, Mar 17, 2021 at 09:11:48PM -0400, Dale R. Worley wrote: > I have it encoded in my head that $ inside "..." is respected. Subtly, > the $'...' construction is not respected inside "...". Bash has 5 types of quoting: '...', "...", $'...', $"..." and backslash. $'...' is a form of quoting, not an expansion. It won't "work" inside of another type of quoting, just like '...' will not "work" inside "...". echo "foo is '$foo'" In this example, $foo is expanded, despite the fact that there are single quotes around it, because the single quotes have no meaning in this context. They're inside a *different* type of quoting, so they are just regular literal characters. The only exception here is backslash, which retains its special powers when inside "..." or $"...".
Probably not a bug but I was surprised: $' does not work inside "..." close.
I have it encoded in my head that $ inside "..." is respected. Subtly, the $'...' construction is not respected inside "...". After reading the manual page carefully, I realized this is because the interpretation of $'...' is not part of parameter expansion (despite its $) but rather it is a special form of quote interpretation, "Words of the form $'string' are treated specially." However, I'm not sure that text is entirely accurate, either, as $ echo xxx$'aa\ta'yyy xxxaa ayyy "Word" is generally used to mean non-space characters (separted by spaces), but the argument of "echo" is only one word, which is not, as a whole, of the form $'...'. Dale