Permalink
Please sign in to comment.
Browse files
Start a spec test for xtrace.
OSH quick ref: - Document more environment variables. The [Call Stack] section is relevant to tracing. So are PS4 and SHELLOPTS. - Document traps. There are four traps relevant to debugging.
- Loading branch information...
Showing
with
68 additions
and 24 deletions.
- +2 −2 build/quick_ref.py
- +7 −3 core/cmd_exec.py
- +8 −6 core/state.py
- +15 −4 doc/osh-quick-ref-toc.txt
- +0 −8 spec/sh-options.test.sh
- +30 −0 spec/xtrace.test.sh
- +6 −1 test/spec.sh
| @@ -0,0 +1,30 @@ | ||
| #!/usr/bin/env bash | ||
| # | ||
| # xtrace test. Test PS4 and line numbers, etc. | ||
| # | ||
| # TODO: need multiline test format | ||
| ### basic xtrace | ||
| set -x | ||
| echo one >&2 | ||
| echo two >&2 | ||
| # stdout-json: "" | ||
| # stderr-json: "+ echo one\none\n+ echo two\ntwo\n" | ||
| ### xtrace | ||
| echo 1 | ||
| set -o xtrace | ||
| echo 2 | ||
| # stdout-json: "1\n2\n" | ||
| # stderr: + echo 2 | ||
| ### PS4 is scoped | ||
| set -x | ||
| echo one | ||
| f() { | ||
| local PS4='- ' | ||
| echo func; | ||
| } | ||
| f | ||
| echo two | ||
| # stderr-json: "+ echo one\n+ f\n+ local 'PS4=- '\n- echo func\n+ echo two\n" |
0 comments on commit
ffab9a4