shellscape
shellscape

Reputation: 885

git commit exclamation results in zsh: illegal modifier:

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.

Upvotes: 14

Views: 3637

Answers (1)

chepner
chepner

Reputation: 530833

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

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

Upvotes: 25

Related Questions