Mac OS X 10.4+ 上的 Bash 配置
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/312435/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Bash configuration on Mac OS X 10.4+
提问by cgTobi
When configuring the bash on OSX via ~/.profileit seems to completely ignore it as soon as ~/.bash_profileexists. If this is correct and expected behavior, should I add my extra configuration stuff to ~/.bash_profileas well or use it instead of ~/.profile?
当通过~/.profile它在 OSX 上配置 bash 时,它似乎一存在就完全忽略它~/.bash_profile。如果这是正确的和预期的行为,我应该添加我的额外配置内容~/.bash_profile还是使用它而不是~/.profile?
Thanks in advance.
提前致谢。
回答by The Archetypal Paul
It's expected behaviour. See here
这是预期的行为。看这里
When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable.
当 bash 作为交互式登录 shell 或作为带有 --login 选项的非交互式 shell 调用时,它首先从文件 /etc/profile 读取并执行命令(如果该文件存在)。读取该文件后,它会按顺序查找 ~/.bash_profile、~/.bash_login 和 ~/.profile,然后从第一个存在且可读的命令中读取和执行命令。
So only the first readable one counts.
所以只有第一个可读的才算数。
As for which you should use, it's up to you - unless there are corporate policies or something else that creates a specific one, or relies on a specific one existing.
至于您应该使用哪个,这取决于您 - 除非有公司政策或其他创建特定政策的东西,或者依赖于现有的特定政策。
回答by cgTobi
It would be "source ~/.profile"
这将是“源〜/ .profile”

