我通过我的bash命令安装了Google Cloud,并且当我尝试重新启动我的shell
时遇到此错误bash:/users/emm/.bash_profile:第15行:语法错误: 文件的意外结束
这是我在
中输入的命令exec -l $SHELL
这是我的.bash_profile
# Setting PATH for Python 3.7
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"
export PATH
# added by Anaconda3 5.2.0 installer
export PATH="/Users/emm/anaconda3/bin:$PATH"
# The next line updates PATH for the Google Cloud SDK.
if [ -f '/Users/emm/my_app/googlecloud/google-cloud-sdk/path.bash.inc' ]; then . '/Users/emm/my_app/googlecloud/google-cloud-sdk/path.bash.inc'; fi
# The next line enables shell command completion for gcloud.
if [ -f '/Users/emm/my_app/googlecloud/google-cloud-sdk/completion.bash.inc' ]; then . '/Users/emm/my_app/googlecloud/google-cloud-sdk/completion.bash.inc';
您的.bash_profile
最后缺少fi
。每个if
都需要关闭fi
。
修复错误运行echo fi >> /Users/emm/.bash_profile
一次。
顺便说一句:
您可以使用变量来改善.bash_profile
。而不是重复每条路径两次…
if [ -f 'longPath1' ]; then . 'longPath1'; fi
if [ -f 'longPath2' ]; then . 'longPath2'; fi
...
…您可以写...
for p in 'longPath1' 'longPath2'; do
[ -f "$p" ] && .p
done
在您的特定情况下,您甚至可以使用Brace扩展
for p in /Users/emm/my_app/googlecloud/google-cloud-sdk/{path,completion}.bash.inc; do
[ -f "$p" ] && .p
done