1 ## our_shell: ysh
2 ## oils_failures_allowed: 1
3
4 #### ysh usage
5
6 set +o errexit
7
8 $SH --location-str foo.hay --location-start-line 42 -c 'echo ()' 2>err.txt
9
10 cat err.txt | grep -o -- '-- foo.hay:42: Unexpected'
11
12
13 # common idiom is to use -- to say it came from a file
14 $SH --location-str '[ stdin ]' --location-start-line 10 -c 'echo "line 10";
15 echo ()' 2>err.txt
16
17 cat err.txt | fgrep -o -- '-- [ stdin ]:11: Unexpected'
18
19 ## STDOUT:
20 -- foo.hay:42: Unexpected
21 line 10
22 -- [ stdin ]:11: Unexpected
23 ## END
24
25 #### --debug-file
26 $SH --debug-file $TMP/debug.txt -c 'true'
27 grep 'OSH started with' $TMP/debug.txt >/dev/null && echo yes
28 ## stdout: yes
29
30 #### Filename quoting
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 $SH no-quoting 2>>err.txt || true
39 $SH 'with spaces.sh' 2>>err.txt || true
40 $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