3

I can not seem to get dash to look at $HOME/.profile:

pedz@Peace:s001 ~[S:hatred] % docker exec -it hatred-web-1 dash -i
# cat $HOME/.profile
PROOF=true; export PROOF
PATH=/hatred/bin:$PATH; export PATH
# env | sort
BUNDLE_APP_CONFIG=/usr/local/bundle
BUNDLE_SILENCE_ROOT_WARNING=1
GEM_HOME=/usr/local/bundle
HOME=/root
HOSTNAME=hatred
LANG=C.UTF-8
PATH=/usr/local/bundle/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/hatred
RUBY_DOWNLOAD_SHA256=ca10d017f8a1b6d247556622c841fc56b90c03b1803f87198da1e4fd3ec3bf2a
RUBY_MAJOR=3.1
RUBY_VERSION=3.1.2
TERM=xterm
# ps -ef
UID        PID  PPID  C STIME TTY          TIME CMD
root         1     0  0 14:28 ?        00:00:01 puma 5.6.5 (tcp://0.0.0.0:3000) [hatred]
root       152     0  0 14:54 pts/0    00:00:00 dash -i
root       161   152  0 14:54 pts/0    00:00:00 ps -ef
# set
BUNDLE_APP_CONFIG='/usr/local/bundle'
BUNDLE_SILENCE_ROOT_WARNING='1'
GEM_HOME='/usr/local/bundle'
HOME='/root'
HOSTNAME='hatred'
IFS='   
'
LANG='C.UTF-8'
OPTIND='1'
PATH='/usr/local/bundle/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
PPID='0'
PS1='# '
PS2='> '
PS4='+ '
PWD='/hatred'
RUBY_DOWNLOAD_SHA256='ca10d017f8a1b6d247556622c841fc56b90c03b1803f87198da1e4fd3ec3bf2a'
RUBY_MAJOR='3.1'
RUBY_VERSION='3.1.2'
TERM='xterm'
_='-ef'
# lsb_release -c
Codename:   bullseye
# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
# 

Note that PROOF is not in env's output and PATH does not have /hatred/bin prepended to it.

2
  • Shells typically only read .profile as a login shell. Shells started by docker exec are not considered login shells. If you docker exec ... dash -l it will run your .profile.
    – larsks
    Sep 23 at 16:37
  • Hmm... Ok. That seems to be correct. The dash documentation says to use -i in the Invocation part of the man page to make it "interactive". Curiously, if -l is used, then the PATH to /usr/local/bundler/bin which I guess was set by one of the parent images is lost. Thank you.
    – pedz
    Sep 23 at 17:06

1 Answer 1

1

I sent this question to the Debian users mailing list. It was pointed out to me that the text does describe the behavior correctly. Here are a few things that tripped me up:

The text says "When first starting, the shell inspects argument 0, and if it begins with a dash ‘-’, the shell is also considered a login shell." (emphasis added by me).

I misunderstood the reason for the also. And, indeed, it isn't clear why it is there.

To me, it would be much clearer if that sentence started a new paragraph because the topic has changed from an interactive shell to a login shell. It would be clearer to leave out the also, and it would be clearer to mention the -l option at that point.

All this to say, as the comments pointed out, to read $HOME/.profile, you need to either specify the -l option or make $0 begin with a dash.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.