1 |
#!/usr/bin/env bash |
2 |
# |
3 |
|
4 |
#### 'exit' in oshrc (regression) |
5 |
cat >$TMP/oshrc <<EOF |
6 |
echo one |
7 |
exit 42 |
8 |
echo two |
9 |
EOF |
10 |
$SH --rcfile $TMP/oshrc -i -c 'echo hello' |
11 |
## status: 42 |
12 |
## STDOUT: |
13 |
one |
14 |
## END |
15 |
## N-I dash status: 2 |
16 |
## N-I dash stdout-json: "" |
17 |
## N-I mksh status: 1 |
18 |
## N-I mksh stdout-json: "" |
19 |
|
20 |
#### fatal errors continue |
21 |
# NOTE: tried here doc, but sys.stdin.isatty() fails. Could we fake it? |
22 |
$SH --rcfile /dev/null -i -c ' |
23 |
echo $(( 1 / 0 )) |
24 |
echo one |
25 |
exit 42 |
26 |
' |
27 |
## status: 42 |
28 |
## STDOUT: |
29 |
one |
30 |
## END |
31 |
## N-I dash status: 2 |
32 |
## N-I dash stdout-json: "" |
33 |
## N-I mksh status: 1 |
34 |
## N-I mksh stdout-json: "" |
35 |
|
36 |
#### interactive shell loads rcfile (when combined with -c) |
37 |
$SH -c 'echo 1' |
38 |
cat >$TMP/rcfile <<EOF |
39 |
echo RCFILE |
40 |
EOF |
41 |
$SH --rcfile $TMP/rcfile -i -c 'echo 2' |
42 |
## STDOUT: |
43 |
1 |
44 |
RCFILE |
45 |
2 |
46 |
## END |
47 |
## N-I dash/mksh STDOUT: |
48 |
1 |
49 |
## END |
50 |
## N-I dash status: 2 |
51 |
## N-I mksh status: 1 |
52 |
|
53 |
#### interactive shell runs PROMPT_COMMAND after each command |
54 |
export PS1='' # OSH prints prompt to stdout |
55 |
|
56 |
case $SH in |
57 |
*bash|*osh) |
58 |
$SH --rcfile /dev/null -i << EOF |
59 |
PROMPT_COMMAND='echo PROMPT' |
60 |
echo one |
61 |
echo two |
62 |
EOF |
63 |
;; |
64 |
esac |
65 |
|
66 |
# Paper over difference with OSH |
67 |
case $SH in *bash) echo '^D';; esac |
68 |
|
69 |
## STDOUT: |
70 |
PROMPT |
71 |
one |
72 |
PROMPT |
73 |
two |
74 |
PROMPT |
75 |
^D |
76 |
## END |
77 |
## N-I dash/mksh stdout-json: "" |
78 |
|
79 |
|
80 |
#### parse error in PROMPT_COMMAND |
81 |
export PS1='' # OSH prints prompt to stdout |
82 |
|
83 |
case $SH in |
84 |
*bash|*osh) |
85 |
$SH --rcfile /dev/null -i << EOF |
86 |
PROMPT_COMMAND=';' |
87 |
echo one |
88 |
echo two |
89 |
EOF |
90 |
;; |
91 |
esac |
92 |
|
93 |
# Paper over difference with OSH |
94 |
case $SH in *bash) echo '^D';; esac |
95 |
|
96 |
## STDOUT: |
97 |
one |
98 |
two |
99 |
^D |
100 |
## END |
101 |
## N-I dash/mksh stdout-json: "" |
102 |
|
103 |
#### runtime error in PROMPT_COMMAND |
104 |
export PS1='' # OSH prints prompt to stdout |
105 |
|
106 |
case $SH in |
107 |
*bash|*osh) |
108 |
$SH --rcfile /dev/null -i << 'EOF' |
109 |
PROMPT_COMMAND='echo PROMPT $(( 1 / 0 ))' |
110 |
echo one |
111 |
echo two |
112 |
EOF |
113 |
;; |
114 |
esac |
115 |
|
116 |
# Paper over difference with OSH |
117 |
case $SH in *bash) echo '^D';; esac |
118 |
|
119 |
## STDOUT: |
120 |
one |
121 |
two |
122 |
^D |
123 |
## END |
124 |
## N-I dash/mksh stdout-json: "" |