Debugging a bash script
Typically when setting variables with in a script and executing the script (% setenv.sh) makes these variables available only within the sub-process that executing the script. Once the script execution is done, these variables are not passed back to the parent shell. In order to achieve this, one has to 'source' it.
Suppose you have a shell script which contains the following line:
% bash -x myscript.shSetting variables like CLASSPATH etc. using a script
Typically when setting variables with in a script and executing the script (% setenv.sh) makes these variables available only within the sub-process that executing the script. Once the script execution is done, these variables are not passed back to the parent shell. In order to achieve this, one has to 'source' it.
Suppose you have a shell script which contains the following line:
CLASSPATH="/opt/jars:/usr/lib/jars" export CLASSPATHIn order for this variable to be available to the parent shell:
% source setenv.shThen the variable will be available in the parent shell
% env | grep -i classpathWill show the set values.
0 comments:
Post a Comment