OILS / test / bugs.sh View on Github | oilshell.org

79 lines, 43 significant
1#!/usr/bin/env bash
2#
3# Junk drawer of repros for bugs
4#
5# Usage:
6# test/bugs.sh <function name>
7
8set -o nounset
9set -o pipefail
10set -o errexit
11
12# bugs:
13# echo | tr
14# echo | cat
15# history | less
16
17esrch-code-1() {
18 local n=$1
19 for i in $(seq $n); do
20 echo 'echo hi | tr a-z A-Z'
21 #echo 'echo hi | cat'
22 done
23}
24
25esrch-code-2() {
26 local n=$1
27 for i in $(seq $n); do
28 echo 'history | less'
29 done
30}
31
32esrch-test() {
33 # I think
34
35 local osh=bin/osh
36
37 local osh=_bin/cxx-opt/osh
38 ninja $osh
39
40 esrch-code-1 1000 | $osh -i
41}
42
43#
44# Bug #1853 - trap and fork optimizations - also hit by Samuel
45#
46
47trap-1() {
48 local sh=${1:-bin/osh}
49 set +o errexit
50
51 # This fails to run the trap
52 $sh -x -c 'trap "echo int" INT; sleep 5'
53}
54
55# Run with bin/ysh -x to show fork opts
56trap-2() {
57 local sh=${1:-bin/osh}
58 set +o errexit
59
60 # This runs it
61 $sh -x -c 'trap "echo int" INT; sleep 5; echo last'
62}
63
64trap-line() {
65 echo outer line=$LINENO
66 trap 'echo "trap line=$LINENO"' INT # shows line 1
67 sleep 5
68 echo hi
69}
70
71bug-1853() {
72 local sh=${1:-bin/osh}
73
74 $sh -c 'trap "echo hi" EXIT; $(which true)'
75 echo --
76 $sh -c 'trap "echo hi" EXIT; $(which true); echo last'
77}
78
79"$@"