WestCoastProjects
WestCoastProjects

Reputation: 63062

How to make bash/shell "set -x" sticky across nested calls to shell scripts

I am trying to trace/debug a shell script that in turn includes nested invocations to other shell scripts.

My approach has been:

The second approach does end up showing the executions by the shell for the main script. But the nested scripts seem not to inherit that setting - either from the "set -x" on bash prompt or from the calling shell script.

Any way to achieve the inherited behavior - short of modifying each and every nested script?

Upvotes: 12

Views: 2870

Answers (1)

MrTux
MrTux

Reputation: 34003

You can use the SHELLOPTS environment variable to make the "sub" shell use the same options. You just have to export it before any calls to subshells:

export SHELLOPTS

Upvotes: 18

Related Questions