2016-10-05 33 views
0

在Linux機器上,我試圖按照https://cloud.google.com/storage/docs/gsutil_install上的說明安裝gsutil。在安裝過程中,我對所有內容都回答「是」,並將其設置爲默認值。安裝gsutil後.bashrc中的語法錯誤

但是現在,如果我打開一個新的終端將其與一個bash錯誤開始:

bash: /home/kurt/.bashrc: line 119: syntax error near unexpected token `fi' 
bash: /home/kurt/.bashrc: line 119: `fi' 
[email protected]:~$ 

的線都包含在我的.bashrc文件的以下片斷違規:

# enable programmable completion features (you don't need to enable 
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile 
# sources /etc/bash.bashrc). 
if ! shopt -oq posix; then 
    if [ -f /usr/share/bash-completion/bash_completion ]; then 
    . /usr/share/bash-completion/bash_completion 
    elif [ -f /etc/bash_completion ]; then 
    . /etc/bash_completion 
    fi 
fi 
    source '/home/kurt/Downloads/google-cloud-sdk/path.bash.inc' 
fi 
    source '/home/kurt/Downloads/google-cloud-sdk/completion.bash.inc' 
fi 

錯誤發生在倒數第二個fi聲明中。的確,看起來最後兩個fi s沒有與任何if匹配。我只能評論最後三行,但我不確定是否會打破功能。有什麼建議?

+0

爲什麼最後3條線沒有任何邏輯? – Inian

+0

這讓我感到困惑。 Google似乎不太可能會發送帶有語法錯誤的代碼,但這些行似乎已被安裝程序添加。 –

回答

1

從查看您的.bashrc摘要中,您不會因刪除最後兩個fi關鍵字而破壞任何功能。有可能在文件的前面有一個對應的if關鍵字,但是前面的塊的縮進和內容(配置bash完成)依然存在,我對此表示懷疑。

我猜失蹤線檢查中存在的兩個文件(並讀取)試圖source他們面前:

if [ -r '/home/kurt/Downloads/google-cloud-sdk/path.bash.inc' ]; then 
    source '/home/kurt/Downloads/google-cloud-sdk/path.bash.inc' 
fi 

if [ -r '/home/kurt/Downloads/google-cloud-sdk/completion.bash.inc' ]; then 
    source '/home/kurt/Downloads/google-cloud-sdk/completion.bash.inc' 
fi 

看起來存在這樣生成的安裝程序中的錯誤線。爲了安全起見,我會重新下載軟件包並再次運行安裝程序。