2

На Mac, когда я открываю терминал, мой PATH:

/ Опт / местные / бен:/ OPT / местные / SBIN:/ USR / бен:/ бен:/ USR / SBIN:/ SBIN:/ USR / местные / бен

К ним относятся некоторые папки, в которых находятся инструменты для портов Mac, но как только я создаю ~/.bash_profile (даже если он пустой), когда я открываю новый терминал, мой PATH становится:

/ USR / бен:/ бен:/ USR / SBIN:/ SBIN:/ USR / местные / бен

Почему существование ~/.bash_profile изменяет мой PATH?

1 ответ1

2

Из раздела INVOCATION на странице руководства 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, вероятно, взяты из одного из этих других файлов профиля.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками .