How do I propagate bash tracing (set -x
) to all child scripts without modifying the main script code? Is there such a way? Maybe an hidden environment variable?
Let's assume I have:
main.sh
#!/bin/bash
echo "Main script"
./child.sh
child.sh
#!/bin/bash
echo "child script"
I want to call main.sh
with some flag/environment variable/whatever that will cause child.sh
to run with set -e
without changing any code
CodePudding user response:
I accomplished this task by creating a file $HOME/.bash_env
like:
set -x
Then I added
export BASH_ENV=$HOME/.bash_env
to .bash_rc
.
So, each scripts will get bash tracing enabled.