In bash, how do I escape an exclamation mark?
Since you do not depend on bash to expand variables in your commit message you could use single quotes instead. Strings in single quotes are not expanded by bash.
bzr commit -m 'This does work!'
Here is another method if you want double quotes as well as the exclamation:
echo "It's broken"'!'
This works even if the !
is not at the end of the line.
For instance:
echo "hello there"'!'" and goodbye"
Bonus: A similar technique can be used to escape any text in Sh or Bash (with the help of sed): see the first option in this answer. Further, if you have bash-completion
installed, you likely have the quote()
function available already.