I found this while trying to reinforce my scripts for string security:
$ echo '!!' !! $ echo "$(echo '!!')" echo "$(echo 'echo '!!'')"
It seems to me that the innermost quotation, which is single, should not expand anything, a variable, subshell or otherwise, but in this case it expands !! to the last line entered. Looks like he shouldn't do that.
I ask you: is this a bug in Bash, and if you can use the quotation mark extension of a subitem that displays an exclamation point?
(Using Bash 4.1.007 on Linux)
Edit:
If the above is not a mistake, why does it behave as expected?
$ foo='some value' $ echo "$(echo 'neither $foo nor `this subshell` should expand here')" neither $foo nor `this subshell` should expand here
source share