[英]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. 我试图跟踪/调试一个Shell脚本,该脚本又包括对其他Shell脚本的嵌套调用。
My approach has been: 我的方法是:
The second approach does end up showing the executions by the shell for the main script. 第二种方法的确显示了shell对主脚本的执行。 But the nested scripts seem not to inherit that setting - either from the "set -x" on bash prompt or from the calling shell script.
但是嵌套脚本似乎不继承该设置-从bash提示符下的“ set -x”或从调用Shell脚本继承。
Any way to achieve the inherited behavior - short of modifying each and every nested script? 有什么方法可以实现继承的行为-无需修改每个嵌套脚本?
You can use the SHELLOPTS
environment variable to make the "sub" shell use the same options. 您可以使用
SHELLOPTS
环境变量来使“ sub” shell使用相同的选项。 You just have to export it before any calls to subshells: 您只需要在调用子shell之前将其导出即可:
export SHELLOPTS
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.