bbbonthemoon
bbbonthemoon

Reputation: 1778

quotes in unix shell

Trying to prepare simple shell commit script for git, like

git add .
git commit -m $@
git push origin master

to run it in ./script.sh 'commit message' manner

I ran into issue with commit messages containing space. I understand I need to wrap $@ in quotes on string 2, but all my tries have failed so far(I tried straight ', then \', then fancy '\'' I found while researching, still no luck). Please help!

Upvotes: 0

Views: 93

Answers (2)

Chetan Narsude
Chetan Narsude

Reputation: 340

Just replace $@ with "$@". That should do the trick.

Upvotes: 1

Barmar
Barmar

Reputation: 780974

If you're running the script as:

./script.sh 'commit message'

then the commit message is just $1, and your script should contain:

git commit -m "$1"

Upvotes: 1

Related Questions