I'm trying to set up a sane/usable environment in a barebones OpenSolaris-derivative (OmniOS, a distribution of Illumos/OpenIndiana).  I have all the plumbing code I need in .profile, .inputrc, and .bashrc files ready to promote to system-wide use, but no system-wide scripts are being sourced for non-login shells.  Bash attempts to load the user's .bashrc file on su, but $HOME (and any other environment variables) remains configured for the previous user.Output from a direct (SSH) login:login as: myuserUsing keyboard-interactive authentication.Password:/etc/profile runmyuser's .bashrc runmyuser's .profile runmyuser@Helios:~$ echo ~/home/myusermyuser@Helios:~$Output switching user:root@Helios:/etc# su myuserbash: /root/.bashrc: Permission deniedbash-4.2$ iduid=1001(myuser) gid=100(users) groups=100(users),27(sudo)bash-4.2$ echo ~/rootbash-4.2$Note in particular the attempt to source root's .bashrc instead of myuser's .bashrc.su (without additional arguments) has always worked seamlessly in Ubuntu, Fedora, etc. and I intend to replicate that experience, but what can I do when no system-wide scripts run and the user's scripts cannot be found?  I'm inclined to blame OmniOS's version of bash and/or su for missing something, but what exactly is the correct behavior?  Can I configure/access/script additional plumbing somewhere which addresses the failure to update $HOME and other envvars?Further notes:there is no man bash in OmniOS (at least not using MANPATH=/opt/omni/share/man:/opt/mysql55/man:/opt/gcc-4.4.4/man:/usr/gnu/share/man:/usr/local/man:/usr/local/share/man:/usr/man:/usr/share/man)/etc/bashrc and /etc/bash.bashrc never get sourced (which is expected as this is apparently a distribution-specific convention, but Ubuntu does appear to be loading these without reference from .bashrc)
How to source correct startup scripts on interactive, non-login shell
environment variables;su;home;illumos;omnios
The su command does not change the HOME environment variable under Solaris. That's just how it works. Under Linux and *BSD, su does reset HOME, I think it's a BSD/SysV difference. Bash is behaving perfectly normally: it tries to load ~/.bashrc, and since HOME is still /root, that's /root/.bashrc.The idea is that when you su to root, the shell you start and other programs will still look for your configuration files in your home directory. If you wanted the environment of the target user, you'd run su -.If you want to set HOME but otherwise leave the environment unchanged, set it explicitly.HOME=~myuser su myuserWhether bash loads a system-wide file is a compile-time option. That option is enabled on Ubuntu but disabled on OmniOS.