Solved after updating 13.3 -> 14.1, root shell sh never reads ~/.profile nor ~/.shrc

Hi there,

I never managed to let root sh shell read ~/.shrc or ~/.profile after updating to 14.1 am I missing something ?

Thanks
 
richardtoohey2, yes i know that, I'm ok with that, my issue is that the SH shell never reads its startup configs. So basically whatever I put in
/root/.shrc or /root/.profile stays completely ignored.
 
Which shell you are using? echo $SHELL

sh(1)

A login shell first reads commands
from the files /etc/profile and then .profile in a user's home direc-
tory, if they exist. If the environment variable ENV is set on entry
to a shell, or is set in the .profile of a login shell, the shell then
subjects its value to parameter expansion and arithmetic expansion and
reads commands from the named file. Therefore, a user should place
commands that are to be executed only at login time in the .profile
file, and commands that are executed for every shell inside the ENV
file. The user can set the ENV variable to some file by placing the
following line in the file .profile in the home directory, substituting
for .shrc the filename desired:

ENV=$HOME/.shrc; export ENV
 
hm ... ok, I will say that one more time. It is "sh", the shell is /bin/sh. The shell for root user is set to /bin/sh.

# echo $SHELL
/bin/sh
# cat /etc/passwd | grep root
root:*:0:0:Charlie &:/root:/bin/sh



# cat ~/.profile
#
HOME=/root
export HOME
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:~/bin
export PATH
TERM=${TERM:-xterm}
export TERM
PAGER=less
export PAGER

# set ENV to a file invoked each time sh is started for interactive use.
ENV=$HOME/.shrc; export ENV

# Query terminal size; useful for serial lines.
if [ -x /usr/bin/resizewin ] ; then /usr/bin/resizewin -z ; fi

# Uncomment to display a random cookie on each login.
# if [ -x /usr/bin/fortune ] ; then /usr/bin/fortune -s ; fi


Notice that ENV is never set, nor other settings in ~/.profile or ~/.shrc

# echo $ENV

# pwd
/root

# readlink -f ~
/root
 
the question is not relevant anymore, I have just rolledback the zfs root partition with update and start a new upgrade. The another machine which has same upgrade working just fine...

thanks
 
/etc/profile and ~/.profile are read only when sh(1) is started as a login shell. If this is not the case, and you want sh(1) to read ~/.shrc at startup, you have to pass it the ENV variable from the outside.
 
/etc/profile and ~/.profile are read only when sh(1) is started as a login shell. If this is not the case, and you want sh(1) to read ~/.shrc at startup, you have to pass it the ENV variable from the outside.
Yep, if you define ENV in user environment variable, it will pass thru and should work in elevated (su) shell, but it didn't somehow. It works as expected on another machine.
 
I understand that on your another machine everything works as expected, I'm just still curious. /usr/src/bin/sh/main.c tells us that reading commands from the file specified in ENV variable is skipped only for non-interactive or privileged (i.e., suid) shells, so the issue is (or was) probably with the environment (e.g., $ ENV=~/.shrc su vs. $ ENV=/root/.shrc su or something like that).
 
I understand that on your another machine everything works as expected, I'm just still curious. /usr/src/bin/sh/main.c tells us that reading commands from the file specified in ENV variable is skipped only for non-interactive or privileged (i.e., suid) shells, so the issue is (or was) probably with the environment (e.g., $ ENV=~/.shrc su vs. $ ENV=/root/.shrc su or something like that).
I have fish shell in my user account. Initially for SH shell functionality I'm adding set -Ux ENV $HOME/.shrc, on all machines other then the one I posed here this variable is stays after elevating su. I have posted earlier that the variable is not propagated in a root shell, nor loaded while logging in as a root from local console.

PS. after rolling back update and upgrading again the shell is working as intended.
 
Back
Top