2
I'm trying to send a string that contains "!!" in it. However, every time I execute it on zsh, zsh replaces !! with the last command entered. How can I get zsh to not interpret "!!"? I have also confirmed the same thing happens when I just use sh.
2
I'm trying to send a string that contains "!!" in it. However, every time I execute it on zsh, zsh replaces !! with the last command entered. How can I get zsh to not interpret "!!"? I have also confirmed the same thing happens when I just use sh.
1
Have you tried quoting your string with single quotes instead of double quotes?
bbbco (04:45 PM) ~/ $ echo "Exclamation!!"
echo "Exclamationecho "Exclamationecho 'Exclamation!!'""
Exclamationecho Exclamationecho Exclamation!!
bbbco (04:43 PM) ~/ $ echo 'Exclamation!!'
Exclamation!!
2
Have you tried one backslash for every character?
\!\!
Preceding characters with backslash (one backslash per one character) should give in effect exactly this character, not replaced (it is not interpreted then).
2to aid googling for the OP, it's called 'escaping'. – Sirex – 2013-10-23T20:48:10.287
0
As mentioned by others, quoting or escaping helps to prevent the history expansion in the current command line.
But, you can also use
unsetopt BANG_HIST
to disable the special treatment the character !
completely. (Put this is your ~/.zshrc
to make it permanent.)
2use single quotes '!!' – suspectus – 2013-10-23T20:42:52.757