I use the default shell (busybox ash) as my daily driver.
This is in base system's /etc/skel/.profile:
if [ -f "$HOME/.ashrc" ]; then
export ENV="$HOME/.ashrc"
. "$HOME/.ashrc"
fi
After I'm logged in and run a GUI terminal emulator, ash runs the commands in .ashrc as expected, but it seems counterintuitive that ash has already inherited everything in .ashrc due to the login shell's sourcing of .ashrc
To see what I mean, here is a little experiment. If I add this to .ashrc:
echo "123 $TEST 123"
export TEST="hello world"
echo "123 $TEST 123"
I think the expected output after I reboot and launch a terminal emulator is this:
123 123
123 hello world 123
but what I get is this (because login shell already ran .ashrc and passed its environment on to my GUI session):
123 hello world 123
123 hello world 123
My understanding of POSIX and ash is that commands in .profile are for login shells, while commands in the ENV config file (.ashrc in our case) are for interactive shells. I think not sourcing .ashrc in .profile would be clearer, like this:
if [ -f "$HOME/.ashrc" ]; then
export ENV="$HOME/.ashrc"
fiAll the different shell configuration files are already confusing enough as it is. I know that a shell can be both "login" and "interactive" at the same time (ugh), but wouldn't it be more conceptually clear if .profile refrained from sourcing .ashrc?