Bash will source automatic profiles such as .bashrc
. --rcfile
option can be used to override the automatic script. But I need to source additional personalized file (that's the automatic script plus another file) when launching the bash shell without touching ANY files in $HOME
or /etc
directory since $HOME
directory belongs to application run user. The personalized file must not be located in $HOME
directory.
Is this possible?
I tried:
/bin/bash <<EOF
. /a-directory-outside-of-home/vanilla
EOF
but it returned to the current shell.
A file is sourced in two ways. One is either writting as source <fileName> or other is writting as . ./<filename> in the command line. When a file is sourced, the code lines are executed as if they were printed on the command line.
The source Command The built-in bash source command reads and executes the content of a file. If the sourced file is a bash script, the overall effect comes down to running it. We may use this command either in a terminal or inside a bash script.
When a file is sourced (by typing either source filename or . filename at the command line), the lines of code in the file are executed as if they were printed at the command line.
bash --rcfile <(cat rcfile1; cat rcfile2)
works just fine and requires no modifications anywhere.
Okay, so you want to run the user's normal .bashrc
, followed by your own script, and you want to trigger this behavior in the way that bash
is called, correct?
The call:
/bin/bash --rcfile myscript
First line of myscript
:
source $HOME/.bashrc
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With