echo $SHELL
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
# 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
# echo $ENV
# pwd
/root
# readlink -f ~
/root
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.
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 addingI 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 inENV
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).
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.
Done![]()
Hint: how to edit the title (subject line) of a topic (thread), or add the 'Solved' prefix
A number of topics are solved, but not marked as such. There seems to be no guideline. Please, can one be added? With a screenshot, or two, to make XenForo less ambiguous. https://forums.freebsd.org/forums/forum-rules-and-guidelines-required-reading.49/ Thanksforums.freebsd.org