1 | #!/usr/bin/env bash
|
2 | #
|
3 | # Usage:
|
4 | # ./osh-crash.sh <function name>
|
5 |
|
6 | set -o nounset
|
7 | set -o pipefail
|
8 | set -o errexit
|
9 |
|
10 | g() {
|
11 | local g=1
|
12 | echo foo > $bar
|
13 | }
|
14 |
|
15 | f() {
|
16 | shift
|
17 | local flocal=flocal
|
18 | FOO=bar g A B
|
19 | }
|
20 |
|
21 | main() {
|
22 | f a b c
|
23 | }
|
24 |
|
25 | run-with-osh() {
|
26 | OILS_CRASH_DUMP_DIR=_tmp bin/osh $0 main "$@"
|
27 | }
|
28 |
|
29 | _do-subshell() {
|
30 | echo PID=$$
|
31 | ( f a b c )
|
32 | }
|
33 |
|
34 | # Note: we get two difference crash dumps, with two different stacks.
|
35 | #
|
36 | # That's because we call through $0.
|
37 |
|
38 | do-subshell() {
|
39 | # clear environment so it's smaller
|
40 | env -i OILS_CRASH_DUMP_DIR=_tmp \
|
41 | bin/osh $0 _do-subshell "$@"
|
42 | }
|
43 |
|
44 | _pipeline() {
|
45 | # All of these show multiple errors
|
46 |
|
47 | false | wc -l
|
48 |
|
49 | #{ echo 1; false; echo 2; } | wc -l
|
50 |
|
51 | #f() { echo 1; false; echo 2; }
|
52 | #f | tac
|
53 | }
|
54 |
|
55 | do-pipeline() {
|
56 | env -i PATH=$PATH OILS_CRASH_DUMP_DIR=_tmp \
|
57 | bin/osh $0 _pipeline
|
58 | }
|
59 |
|
60 | "$@"
|