I'm not entirely sure why I'm getting the error in my .bash_profile
syntax error near unexpected token `('
when I use the keyword grom() for my function. I wanted to create a bash function that will just automatically rebase my master branch with origin
# git status
alias gs='git status'
# git stash list
alias gsl='git stash list'
grom() {
branch_name="$(git symbolic-ref --short -q HEAD)"
git fetch && git rebase origin/master && git checkout master && git rebase origin/master && git checkout $branch_name
}
# git stash apply. must append stash@{num}
alias gsa="git stash apply"
When I change the name of the function, it compiles fine. I couldn't find grom as a keyword so I'm not sure what the issue is. If I rename the function to anything else like git-rom or even something like groms, it compiles fine. Is there some special keywords that do not work? This is on Mac OS X.
bash, you may have better luck declaring it asfunction grom() { … }. Another possibility is that there is an open-parenthesis in the output of your firstgitcommand; trygit checkout "$branch_name"as your last chained command, which may get you agiterror, but at least you'd know what needs fixing. (Sorry, I'm not yet agitguru) – Adam Katz Mar 25 '15 at 21:35functionin front. If you want to add that as an answer, I'd be willing to accept it. I'm still curious why it does this though. Thanks a lot! – aug Mar 25 '15 at 21:56groms()andgit-rom(). – aug Mar 25 '15 at 21:57set -xto see what exactly is executed. – michas Mar 25 '15 at 22:09source ./bash_profileto update my.bash_profile. – aug Mar 25 '15 at 22:30grom()orgs[ail]also defined as alias/functions, right? If you declare a function with the same name as analiasthe alias will expand out to${alias}(){and you'll very likely get the error unexpected token(– mikeserv Mar 25 '15 at 22:33aliasofgrombut not anymore so I didn't think that was the issue. Perhaps it was caching my old.bash_profile? Either way thanks for pointing that out. – aug Mar 25 '15 at 23:31