I have a bash script that I run using source because I want to be left in the
environment that the script sets up after running the script. The script
takes a few arguments and sets up an environment for me that includes
library paths, classpaths, JAVA_HOME, appends to the PATH, creates and
populates a local workspace etc. I call the script in the following manner
source setup_env -o -w testdir
The -o argument is to wipe out the workspace if it already exists
(unconditionally) and the -w provides the name of the workspace to setup.
The first time I run the script it runs just fine and all the arguments work
as expected, the environment is all setup etc.
However, if I immediately run the command again all the arguments are
completely ignored
source setup_env -o -w testdir
The script runs but fails because it's not reading in the args for some
reason. As a matter of fact, if I give an argument that doesn't even make
sense (-garbage) , the script runs but again the arguments are ignored so it
ultimately fails.
I searched the forum but did not find a related post. If I don't source the
script and run it from the command line, it works both times, but then my
environment is not mantained after the script runs so that's not a good idea
What in my environment, post-script-run is making the second source not
"see" the command line arguments?