All my scripts depend on some env vars & shell functions that effectively form a library.
Is there a system-wide place where such bootstrapping code could be placed so it's included in every shell session, regardless if it's running in a non-interactive script or user-facing shell? Eg I'd like to have following function definition to be globally available to be invoked on-demand:
function bootstrap() {
source "some-library.sh"
}
Minimally this should work for scripts ran by one specific user, but would prefer a solution that also extends to scripts executed by root
.
So far I've tried /etc/profile
& /etc/bash.bashr
but no joy.
both /etc/{profile,bash.bashrc} had something similar:
_inittest_first() {
echo this is imported from /etc/profile;
}
export -f _inittest_first
I presume export is not working due to dash being involved somewhere inbetween, as explained here
root
would also be able to invoke it. OS is debian. – laur Sep 22 '20 at 11:13/etc/profile
and tell us how you tested it. Did you export the function? – terdon Sep 22 '20 at 11:19