问题
OS: macOS Sierra v10.12.2
I was trying to get R working from the command line and ran into this problem, probably because I am relatively new to coding and messed with something I should not have.
Upon opening new terminal:
-bash: /Users/Brad/.bash_profile: line 33: syntax error: unexpected end of file
When I inspect the profile it looks like this:
# Setting PATH for Python 2.7
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH
# Setting PATH for Python 3.5
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.5/bin:${PATH}"
export PATH
export PATH="$HOME/.bin:$PATH"
eval "$(hub alias -s)"
prompt_ruby_info() {
if [ -f ".ruby-version" ]; then
cat .ruby-version
fi
}
GREEN=$(tput setaf 65)
ORANGE=$(tput setaf 166)
NORMAL=$(tput sgr0)
precmd () { PS1="${ORANGE}[%~] ${GREEN}$(prompt_ruby_info) ${NORMAL}$ " }
export CLICOLOR=1;
export LSCOLORS=Gxfxcxdxbxegedabagacad;
Any information on how to resolve this issue would be much appreciated; I don't want to keep messing around and making it worse!
Thank You!
回答1:
This line :
precmd () { PS1="${ORANGE}[%~] ${GREEN}$(prompt_ruby_info) ${NORMAL}$ " }
Misses a semi-colon at the end :
precmd () { PS1="${ORANGE}[%~] ${GREEN}$(prompt_ruby_info) ${NORMAL}$ " ; }
From the Bash reference manual :
{ list; }
Placing a list of commands between curly braces causes the list to be executed in the current shell context. No subshell is created. The semicolon (or newline) following list is required.
This means you could also write :
precmd ()
{
PS1="${ORANGE}[%~] ${GREEN}$(prompt_ruby_info) ${NORMAL}$ "
}
回答2:
You are missed semicolon (;) at line number 27:
precmd () { PS1="${ORANGE}[%~] ${GREEN}$(prompt_ruby_info) ${NORMAL}$ "; }
来源:https://stackoverflow.com/questions/41815171/bash-profile-syntax-error-unexpected-end-of-file