1 |
## our_shell: ysh
|
2 |
|
3 |
|
4 |
|
5 |
set +o errexit
|
6 |
|
7 |
$[ENV.SH] --location-str foo.hay --location-start-line 42 -c 'echo ()' 2>err.txt
|
8 |
|
9 |
cat err.txt | grep -o -- '-- foo.hay:42: Unexpected'
|
10 |
|
11 |
|
12 |
# common idiom is to use -- to say it came from a file
|
13 |
$[ENV.SH] --location-str '[ stdin ]' --location-start-line 10 -c 'echo "line 10";
|
14 |
echo ()' 2>err.txt
|
15 |
|
16 |
cat err.txt | fgrep -o -- '-- [ stdin ]:11: Unexpected'
|
17 |
|
18 |
## STDOUT:
|
19 |
-- foo.hay:42: Unexpected
|
20 |
line 10
|
21 |
-- [ stdin ]:11: Unexpected
|
22 |
## END
|
23 |
|
24 |
|
25 |
var TMP = ENV.TMP
|
26 |
$[ENV.SH] --debug-file $TMP/debug.txt -c 'true'
|
27 |
grep 'Oils started with' $TMP/debug.txt >/dev/null && echo yes
|
28 |
## stdout: yes
|
29 |
|
30 |
|
31 |
|
32 |
echo '(BAD' > no-quoting
|
33 |
echo '(BAD' > 'with spaces.sh'
|
34 |
echo '(BAD' > $'bad \xff'
|
35 |
|
36 |
write -n '' > err.txt
|
37 |
|
38 |
$[ENV.SH] no-quoting 2>>err.txt || true
|
39 |
$[ENV.SH] 'with spaces.sh' 2>>err.txt || true
|
40 |
$[ENV.SH] $'bad \xff' 2>>err.txt || true
|
41 |
|
42 |
egrep --only-matching '^.*:1' err.txt
|
43 |
|
44 |
## STDOUT:
|
45 |
no-quoting:1
|
46 |
"with spaces.sh":1
|
47 |
b'bad \yff':1
|
48 |
## END
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
try {
|
54 |
$[ENV.SH] -c '/bin/false' 2>on.txt
|
55 |
}
|
56 |
|
57 |
try {
|
58 |
$[ENV.SH] +o verbose_errexit -c '/bin/false' 2>off.txt
|
59 |
}
|
60 |
|
61 |
wc -l on.txt off.txt
|
62 |
#echo
|
63 |
#cat on.txt off.txt
|
64 |
|
65 |
## STDOUT:
|
66 |
3 on.txt
|
67 |
0 off.txt
|
68 |
3 total
|
69 |
## END
|
70 |
|
71 |
|
72 |
|
73 |
$[ENV.SH] -o | egrep 'errexit|pipefail'
|
74 |
|
75 |
## STDOUT:
|
76 |
set -o errexit
|
77 |
set -o pipefail
|
78 |
## END
|