Frank Cheng
Frank Cheng

Reputation: 6186

Commands available in bash -i can't access in bash -l

I don't know how to describe it. It just happens when i use vim and set shell=bash -l. Then i found that a command called mm which can execute in terminal can't execute in vim .

And i also found that when i write this command in run.sh and execute this script. It still report command not found. I think there must be something wrong with my $HOME/.bash* files and $HOME/.profile. And i am sure that .profile are almost the same with .bashrc.

Upvotes: 4

Views: 1640

Answers (1)

romainl
romainl

Reputation: 196576

From $ 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.

and

When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists.

So:

shell   | files loaded    
--------+-----------------
bash -l | /etc/profile    
        | ~/.bash_profile 
        | ~/.bash_login
        | ~/.profile     
--------+-----------------
bash -i | ~/.bashrc

Upvotes: 6

Related Questions