bash recursive xtrace

后端 未结 2 608
轮回少年
轮回少年 2020-12-10 11:40

Is there any way to run bash script X so that if X call executable bash script Y then Y starts by \'sh -eux\'?

X.sh:

./Y.sh

Y.sh:

2条回答
  •  渐次进展
    2020-12-10 12:40

    So i've got tool to debug shell scripts:

      #!/bin/sh
    
      # this tool allows to get full xtrace of any shell script execution
      # only argument is script name
    
    
      out=out.$1
      err=err.$1
      tmp=tmp.$1
    
      echo "export SHELLOPTS; sh $@ 1>> $out 2>> $err" > $tmp
      sh -eux $tmp &> /dev/null
      rm $tmp
    

提交回复
热议问题