bash recursive xtrace -
is there way run bash script x if x call executable bash script y y starts 'sh -eux'?
x.sh:
./y.sh
y.sh:
#!/bin/sh echo ok
it possible make subshell run using same shell options set in parent exporting shellopts
environment variable.
in case x.sh
, y.sh
cannot edited, i'd create wrapper script exports shellopts
before calling x.sh
.
example:
#!/bin/sh # example x.sh calls y.sh ./y.sh
.
#!/bin/sh # example y.sh needs called using sh -eux echo $shellopts
.
#!/bin/sh -eux # wrapper.sh sets options sub shells export shellopts ./x.sh
calling x.sh
directly shows -eux
options not set in y.sh
[lsc@aphek]$ ./x.sh braceexpand:hashall:interactive-comments:posix
calling via wrapper.sh
shows options have propagated subshells.
[lsc@aphek]$ ./wrapper.sh + export shellopts + ./x.sh + ./y.sh + echo braceexpand:errexit:hashall:interactive-comments:nounset:posix:xtrace braceexpand:errexit:hashall:interactive-comments:nounset:posix:xtrace
tested on gnu bash, version 3.00.15(1)-release. ymmv.
Comments
Post a Comment