0

Using the command below, I can log all actions that happened inside that script.

bash -x script.sh

Sadly, the script calls another script, which does not have the -x setting active then, i.e. the setting is not inherited by child scripts.

So, is there a way to activate set -x for all subsequent scripts ?

1 Answer 1

1

If you didn't write the child scripts and have no control over there content, there may be no way to do what you want here. You get insight into the scripts you call directly by calling them with bash -x <scriptname> instead of relying on their executable bit.

If you do have control of the content, consider using an environment variable to indicate when you want the additional tracking and do something like this:

In your environment or .bashrc

export MYAPP_LOGGING="on"

Then at the top of your script add something like:

test "$MYAPP_LOGGING" && set -x

Then any non-null value for MYAPP_LOGGING will turn tracking on. unset MYAPP_LOGGING will turn it off.

Also worth noting: you can turn off the logging with set +x, so this would give you the ability to monitor just parts of your scripts.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .