2017-01-23 9 views
2

OS: macOS Sierra v10.12.2Bash_profile Syntaxfehler: unerwartetes Ende der Datei

ich versuche, R zu erhalten von der Kommandozeile arbeiten und in dieses Problem lief, wahrscheinlich, weil ich relativ neu bin Codierung und verwirrte mit etwas, was ich nicht haben sollte.

Bei neuen Terminal zu öffnen:

-bash: /Users/Brad/.bash_profile: line 33: syntax error: unexpected end of file 

Als ich das Profil überprüfen sieht es wie folgt aus:

# 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; 

Alle Informationen darüber, wie das Problem zu lösen wäre sehr geschätzt; Ich möchte nicht weiter herumrennen und es noch schlimmer machen!

Vielen Dank!

+2

Code Veröffentlichung an [shellcheck.net] (http://shellcheck.net) wird Syntaxfehler aufzudecken. Das Hinzufügen von ';' kurz vor dem Schließen '}' der Funktion 'precmd' sollte Ihr Problem beheben. Wenn das schließende '}' _in derselben Zeile_ ist wie ein Befehl, muss der Befehl immer ';' -terminiert sein. – mklement0

Antwort

4

Diese Zeile:

precmd() { PS1="${ORANGE}[%~] ${GREEN}$(prompt_ruby_info) ${NORMAL}$ " } 

Misses ein Semikolon am Ende:

precmd() { PS1="${ORANGE}[%~] ${GREEN}$(prompt_ruby_info) ${NORMAL}$ " ; } 

Von der Bash-Referenzhandbuch:

{ 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.

Das bedeutet, schreiben Sie könnten auch:

precmd() 
{ 
    PS1="${ORANGE}[%~] ${GREEN}$(prompt_ruby_info) ${NORMAL}$ " 
} 
1

Du verpasst Semikolon (;) am Zeilennummer 27:

precmd() { PS1="${ORANGE}[%~] ${GREEN}$(prompt_ruby_info) ${NORMAL}$ "; } 
Verwandte Themen