微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

linux – bash -i中可用的命令无法在bash -l中访问

我不知道如何描述它.它恰好发生在我使用vim并设置shell = bash -l时.然后我发现一个名为mm的命令可以在终端中执行,不能在vim中执行.
我还发现,当我在run.sh中编写此命令并执行此脚本时.它仍然报告找不到命令.我认为我的$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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐