In section 3.1.2.3 titled Double Quotes, the Bash manual says:
Enclosing characters in double quotes (‘"’) preserves the literal value of all characters within the quotes, with the exception of ‘$’, ‘`’, ‘\’, and, when history expansion is enabled, ‘!’.
At the moment I am concerned with the single quote('
).
It's special meaning, described in the preceding section, section 3.1.2.2 is:
Enclosing characters in single quotes (
'
) preserves the literal value of each character within the quotes. A single quote may not occur between single quotes, even when preceded by a backslash.
Combining the two expositions,
echo "'$a'"
where variable a
is not defined (hence $a
= null string), should print $a
on the screen, as ''
, having it's special meaning inside, would shield $
from the special interpretation. Instead, it prints ''
. Why so?