4

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!

Brad.R
  • 41
  • 1
  • 1
  • 2
  • 2
    Posting your code at [shellcheck.net](http://shellcheck.net) will reveal syntax errors. Adding `;` just before the closing `}` of the `precmd` function should fix your issue. If the closing `}` is _on the same line_ as a command, the command must always be `;`-terminated. – mklement0 Jan 23 '17 at 20:40

2 Answers2

7

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}$ "
}
Fred
  • 6,590
  • 9
  • 20
1

You are missed semicolon (;) at line number 27:

precmd () { PS1="${ORANGE}[%~] ${GREEN}$(prompt_ruby_info) ${NORMAL}$ "; }
Ishtiyaq Husain
  • 434
  • 4
  • 11