不知道怎么形容。它只是在我使用 vim 和 set shell=bash -l
时发生。然后我发现一个叫mm
的命令可以在terminal中执行,但是在vim中却无法执行。
而且我还发现,当我在 run.sh
中编写此命令并执行此脚本时。它仍然报告 command not found
。我认为我的 $HOME/.bash*
文件和 $HOME/.profile
一定有问题。我确信 .profile
与 .bashrc
几乎相同。
最佳答案
来自 $ man bash
:
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.
和
When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists.
所以:
shell | files loaded
--------+-----------------
bash -l | /etc/profile
| ~/.bash_profile
| ~/.bash_login
| ~/.profile
--------+-----------------
bash -i | ~/.bashrc
关于linux - bash -i 中可用的命令无法在 bash -l 中访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9716849/