在 Mac 上,当我打开终端时,我的 PATH 是:
在 /opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
其中包括一些 mac 端口工具所在的文件夹,但是当我打开新终端时,只要我创建一个 ~/.bash_profile(即使它是空白的),我的 PATH 就会变成:
在 /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
为什么 ~/.bash_profile 的存在会改变我的 PATH?
答案1
从bash 手册页:
When bash is invoked as an interactive login shell, or as a non-inter-
active shell with the --login option, it first reads and executes com-
mands 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. The --noprofile option may be used when the
shell is started to inhibit this behavior.
因此,其他 PATH 条目可能来自其他配置文件之一。