OILS / demo / osh-crash.sh View on Github | oilshell.org

60 lines, 33 significant
1#!/usr/bin/env bash
2#
3# Usage:
4# ./osh-crash.sh <function name>
5
6set -o nounset
7set -o pipefail
8set -o errexit
9
10g() {
11 local g=1
12 echo foo > $bar
13}
14
15f() {
16 shift
17 local flocal=flocal
18 FOO=bar g A B
19}
20
21main() {
22 f a b c
23}
24
25run-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
38do-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
55do-pipeline() {
56 env -i PATH=$PATH OILS_CRASH_DUMP_DIR=_tmp \
57 bin/osh $0 _pipeline
58}
59
60"$@"