Reputation: 4181
I run the script below as such
push repo "message"
However if my message has spaces in it the script will break. Obviously the interpreter, see any spaces as indication of a new argument. How can I change the behavior so that I can write a complete commit message with spaces.
push() {
local a=$1 b=$2
if [ $# -eq 0 ]
then
echo "Enter git shortname for first argument"
return
fi
if [ $# -eq 1 ]
then
b=$(timestamp)
fi
build
git add -A .
git commit -m $b
git push $a
echo "push() completed."
}
Upvotes: 2
Views: 75
Reputation: 786091
Use proper quoting inside your function:
push() {
local a="$1" b="$2"
if [ $# -eq 0 ]
then
echo "Enter git shortname for first argument"
return
fi
if [ $# -eq 1 ]
then
b=$(timestamp)
fi
build
git add -A .
git commit -m "$b"
git push "$a"
echo "push() completed."
}
Upvotes: 2