Include evaluation of $HOME/.bashrc in shinit

Hi folks,
i love bash and use it like my default shell if present; i use it in openwrt too (actually working on an HA cluster composed by 2 raspberry 3B+). After installed bash on my system i pushed my custom .bashrc in $HOME (/root) and i noticed that it's not evaluated.
I suppose that these are the steps after logon with ssh:

  1. /etc/profile (if not failsafe eval: /etc/profile.d/*.sh)
  2. in case of bash package installed -> /etc/profile.d/sys_bashrc.sh
  3. /etc/profile.d/sys_bashrc.sh -> if the shell is bash then -> /etc/bash.bashrc (common system bash conf)
  4. if interactive session -> /etc/shinit
  5. /etc/shinit evaluation (some alias, customizations and rc for ksh)

My proposal is to add this line at the end of /etc/shinit:

[ -z "$BASH" -o \! -s "$HOME/.bashrc" ] || . "$HOME/.bashrc"

here: https://github.com/openwrt/openwrt/blob/main/package/base-files/files/etc/shinit

@hauke @feckert sounds good?

Of course just successfully tested on my [OpenWrt 24.10.0 (r28427-6df0e3d02a)] env.

Ty

POSIX session startup is ~/.profile , if you google you can find ways to discriminate interactive sessions without bash-izing whole system.

1 Like

Preferences aside, it is not a good idea to switch the login shell away from busybox ash (feel free to manually start bash from the ash session, if you like). Doing so will get you into a quite 'interesting' situation for the next sysupgrade (/etc/passwd remains, bash not preinstalled, root no longer has a valid shell and can't log in).

2 Likes

ty for this warning...but...i prefer to upgrade my system preserving any additional package with:

i'll try to use bash without changing passwd and the default shell.

Regards.

F.

That wipes your scripts for good. There will be no bash zsh tcsh in base system. You can script it from user esp there is just one on a normal OpenWrt