.bash_profile和终端 [英] .bash_profile and terminal

查看:120
本文介绍了.bash_profile和终端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的.bash_profile看起来是这样的:

my .bash_profile looks this way :

打开终端后,我会看到以下三行内容:

When I open my terminal I get this three lines :

-bash:导出:Workbooks.app/Contents/SharedSupport/path-bin': not a valid identifier -bash: export: Workbooks.app/Contents/SharedSupport/path-bin':不是有效的标识符 -bash:导出:Workbooks.app/Contents/SharedSupport/path-bin': not a valid identifier -bash: export: Workbooks.app/Contents/SharedSupport/path-bin':无效的标识符

-bash: export: Workbooks.app/Contents/SharedSupport/path-bin': not a valid identifier -bash: export:Workbooks.app/Contents/SharedSupport/path-bin': not a valid identifier -bash: export: Workbooks.app/Contents/SharedSupport/path-bin': not a valid identifier -bash: export:Workbooks.app/Contents/SharedSupport/path-bin': not a valid identifier

我应该从我的.bash_profile中删除哪些内容以摆脱它?

What should I remove from my .bash_profile to get rid of this ?

推荐答案

此处存在多个错误,但是您要问的一个错误是因为Xamarin Workbooks中的空格需要转义或引用.另请参见何时将引号括在shell变量周围?

There are multiple errors here, but the one you are asking about is because the space in Xamarin Workbooks needs to be escaped or quoted. See also When to wrap quotes around a shell variable?

重复的片段当然也是错误的;重复的代码只能出现一次.我猜您多次运行了一些错误的安装程序,并且它一开始就盲目添加了包含错误的内容,如果已经存在,绝对不应再次添加.如果您可以识别此安装程序,则可以向其维护者提交错误报告.

The repeated fragments are certainly erroneous as well; the repeated code should only be present once. I'm guessing you ran some buggy installer multiple times, and it blindly added stuff which contained errors in the first place, and definitely should not be added again if it was already present. If you can identify this installer, maybe submit a bug report to its maintainer.

硬编码复杂的PATH通常也是错误的.通常,正确的行为是保留以前的PATH,并且仅在旧值之前或之后添加单个附加目录,例如

Hardcoding a complex PATH is also usually wrong. Generally, the correct behavior is to preserve your previous PATH, and only add a single additional directory before or after the old value, like

PATH=/new/stuff:$PATH

PATH=$PATH:/new/stuff

其中/new/stuff是添加的目录,而$PATH调用该变量的先前值.

where /new/stuff is the added directory, and $PATH recalls the variable's previous value.

如果某些内容以编程方式盲目地覆盖了您的语言环境设置,那也是一个错误,并且如果您的实际语言环境设置正确且有用的话,那就完全是敌对的.无论如何,使用LC_ALL很可能会造成严重的过大杀伤力.如果特定的应用程序要求您覆盖特定的语言环境设置,则应仅覆盖所需的特定语言环境,而不是所有内容.但实际上,即使如此,它也没有根据您的个人喜好编写这些内容的事情.

If something blindly overrides your locale settings programmatically, that's also a bug, and outright hostile if your real locale settings were correct and useful. Using LC_ALL is quite likely severe overkill in any event; if a particular application requires you to override a particular locale setting, it should only override the specific one(s) it needs, not everything. But really, even then, it has no business writing this stuff to your personal preferences.

Conda片段还包含一个不良实践的示例(有人称其为反模式);另请参见为什么是测试"$?"看看命令是否成功,反模式?

The Conda fragment also contains an example of poor practice (some would call it an antipattern); see also Why is testing "$?" to see if a command succeeded or not, an anti-pattern?

export PATH完全没有必要,尽管不必要地指定它本身 并删除了shell的系统级启动文件已将其导出的假设.但是,在同一脚本中多次导出同一变量只是愚蠢的事情.

export PATH should not be necessary at all, though specifying it needlessly is harmless per se, and removes the assumption that the shell's system-wide startup files have already exported it. Exporting the same variable multiple times in the same script is just silly, though.

这篇关于.bash_profile和终端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆