Issue
Let’s say I do set -x
in a script “a.sh”, and it invokes another script “b.sh”.
Is it possible to let “b.sh” inherit the -x
option from “a.sh”?
Solution
export SHELLOPTS
for example:
echo date > b
chmod +x b
without the export, we only see the commands in ./a
when it calls ./b
:
$ echo ./b > a
$ bash -xv a
./a
+ ./b
Sun Dec 29 21:34:14 EST 2013
but if we export SHELLOPTS, we see the commands in ./a
and ./b
$ echo "export SHELLOPTS; ./b" > a
$ bash -xv a
./a
+ ./b date
++ date
Sun Dec 29 21:34:36 EST 2013
Answered By - rgiar