I have the following in my .bash_profile:
echo bash_profile
if [ -f $HOME/.bashrc ]; then
echo Sourcing bashrc
source $HOME/.bashrc
echo Sourced bashrc
fi
My .bashrc file is quite long, but at the end I have an echo Path set statement and some exports.
When I execute sudo su - username I get the following output:
bash_profile
Sourcing bashrc
Path set
Sourced bashrc
However, when I execute sudo su - username -c '' I get this:
bash_profile
Sourcing bashrc
Sourced bashrc
Why is it that the source command stops working with the -c flag? I need the changes made to the PATH in .bashrc when executing a command with sudo su - username -c.
.bashrcis checking whether or not the shell is interactive (by looking at the shell options in special variable$-for example) and is not processing the rest of the file in the non-interactive case?