Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
856 views
in Technique[技术] by (71.8m points)

bash - .bash_profile syntax error: unexpected end of file

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!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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}$ "
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...