Saturday 8 December 2018

bash - Use of apostrophe (single-quote) in a Git commit message via command line




I am trying to take this one step further. How could this work in a standard Bash shell?




git commit -m 'cracked enigma's code'


Could this simply be done with backslash-escaping like the following?



git commit -m 'cracked enigma\'s code'


Further, how could double-quotes be used? Also by backslash-escaping? Would that be the best way? Are there any good alternative ways?




git commit -m 'cracked the "real" enigma's code'

Answer



Use double quotes:



git commit -m "cracked enigma's code"


Or, if your message contains other special characters, use double quotes or backslash only for the single quote:




git commit -m 'cracked $enigma'"'"'s code'
git commit -m 'cracked $enigma'\''s code'

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...