So the bottom line here is that I am trying to have one go-to script work to set environment variables (let's call it
setenv.sh) that will be used in subsequent scripts. In Windows (I know, that is a 4-letter word here...) I can use a batch file to set a environment variable for after the batch file is over. I am looking for that same effect.
However, I have just learned, through perusing the internet, that environment variables set in a script (aka a shell) only persist in child shells, and do not affect the parent shells. Okay whatever, well now what I want to know is can I run a script inline in another script? By inline, I am talking about something analogous to C/C++'s
#include directive. I want this because if I can call a script as if it were running in the current script, my environment variables would at least persist through the duration of my desired script.
For example, something like this:
cat ~/install/setenv.sh | /bin/bash echo "JBoss home directory is set to $JBOSS_HOME"
But I realize even that won't quite work, and I am starting a child shell with a call to
/bin/bash. I am fine if I have to call this
setenv.sh for each script I want it to run inline with.