2017-01-23 59 views
2

OS意外的結束:MacOS的塞拉利昂v10.12.2.bash_profile中語法錯誤:文件

我試圖讓[R命令行工作,就遇到了這個問題,可能是因爲我是比較新的編碼和混亂與我不應該有的東西。

一旦打開新的終端:

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

當我檢查輪廓看起來是這樣的:

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

如何解決這個問題將是非常讚賞的任何信息;我不想亂搞,讓事情變得更糟!

謝謝!

+2

發佈你在[shellcheck.net]代碼(http://shellcheck.net)將揭示語法錯誤。在'precmd'函數關閉'}'之前加'''應該可以解決你的問題。如果關閉'}'在同一行上作爲一個命令,則該命令必須始終爲';' - 終止。 – mklement0

回答

4

這條線:

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

未命中分號結尾:

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

從擊參考手冊:

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

這意味着你也可以寫:

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

你錯過了分號(;)行號27:

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