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
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.