14

I'm running the latest available stable version of Zsh and am running into an error using a ! exclamation mark in a git commit message, following conventional commit style. https://www.conventionalcommits.org/en/v1.0.0/

→ zsh --version
zsh 5.8 (x86_64-apple-darwin19.3.0)

And the zsh-offending commit message:

→ git commit -am "chore(foo)!: bar"    
zsh: illegal modifier:

I've tried the same command in Bash, Fish, and Hyper and all succeed without issue. So this appears to be another wonky Zsh nuance. Does anyone have a fix for zsh? I'd really like to be able to use the -am shorthand rather than having to go into the full git commit interactive editor.

1 Answer 1

24

zsh interprets the ! as the beginning of a history expansion. Just use single quotes instead of double quotes.

git commit -am 'chore(foo)!: bar'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.