Is there an alternative for .bashrc for /bin/sh?

In Arch, /bin/sh is a symlink to /bin/bash, which has quite a few rules about startup scripts, with special cases when called sh :

If bash is invoked with the name sh, it tries to mimic the startup
behavior of historical versions of sh as closely as possible, …

If you start it from the console, without any command, i.e. as an interactive, non-login shell, you should use the ENV variable :

export ENV=~/.profile
sh

or

ENV=~/.profile sh 

When invoked as an interactive [non login] shell with the name sh, bash looks for the variable ENV, expands its value if it is defined, and uses the expanded value as the name of a file to read and execute.

Alternatively you can use the --login option to make it behave like a login shell, and read the .profile file.

sh --login

When invoked as an interactive login shell [with the name sh], or a
non-interactive shell with the –login option, it first attempts to
read and execute commands from /etc/profile and ~/.profile, in that
order

Leave a Comment

tech