首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >缺少end以平衡此if语句

缺少end以平衡此if语句
EN

Stack Overflow用户
提问于 2016-09-15 02:23:45
回答 2查看 9.5K关注 0票数 12

我尝试将这几行添加到我的.bash-profile中

代码语言:javascript
复制
if [ -f "$(brew --prefix)/opt/bash-git-prompt/share/gitprompt.sh" ];then
 source "$(brew --prefix)/opt/bash-git-prompt/share/gitprompt.sh"
fi

但是我得到了这个错误

代码语言:javascript
复制
Missing end to balance this if statement
.bash_profile (line 2): if [ -f "$(brew --prefix)/opt/bash-git-       prompt/share/gitprompt.sh" ]; then
                    ^
from sourcing file .bash_profile
called on standard input

有谁知道为什么吗?我有这里的代码,https://github.com/magicmonty/bash-git-prompt

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-09-15 02:37:27

尽管链接的存储库包含用于fish的脚本,但自述文件并未提供有关如何使用该脚本的任何说明。几年没用过fish了,我想你想要做的是添加

代码语言:javascript
复制
if status --is-login
  source (brew --prefix)"/opt/bash-git-prompt/share/gitprompt.fish"
end

改为~/.config/fish/config.fish。如果您不是在启动交互式shell,则if status命令可以防止不必要的文件来源。

票数 10
EN

Stack Overflow用户

发布于 2016-09-15 02:34:26

此错误消息:

代码语言:javascript
复制
Missing end to balance this if statement
.bash_profile (line 2): if [ -f "$(brew --prefix)/opt/bash-git-       prompt/share/gitprompt.sh" ]; then
                    ^
from sourcing file .bash_profile
called on standard input

是由fish外壳生成的。

.bash_profile文件只能由bash外壳程序执行(源文件)。fish是一个不同的shell,具有不同的语法;它与bash不兼容。

如果使用fish作为交互式shell,并且希望在启动新shell时自动执行某些命令,则需要将特定于bash的命令转换为fish语法,并将它们添加到fish启动文件中。(使用fish的人不多,所以软件包提供商不太可能以fish语法提供启动命令--但这个包显然提供了;请参阅chepner's answer。)

票数 9
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39497196

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档