.bash_profile syntax error: unexpected end of file

笑着哭i 提交于 2019-11-27 04:51:35

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!