OILS / spec / ysh-usage.test.sh View on Github | oilshell.org

48 lines, 22 significant
1## our_shell: ysh
2## oils_failures_allowed: 1
3
4#### ysh usage
5
6set +o errexit
7
8$SH --location-str foo.hay --location-start-line 42 -c 'echo ()' 2>err.txt
9
10cat 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";
15echo ()' 2>err.txt
16
17cat err.txt | fgrep -o -- '-- [ stdin ]:11: Unexpected'
18
19## STDOUT:
20-- foo.hay:42: Unexpected
21line 10
22-- [ stdin ]:11: Unexpected
23## END
24
25#### --debug-file
26$SH --debug-file $TMP/debug.txt -c 'true'
27grep 'Oils started with' $TMP/debug.txt >/dev/null && echo yes
28## stdout: yes
29
30#### Filename quoting
31
32echo '(BAD' > no-quoting
33echo '(BAD' > 'with spaces.sh'
34echo '(BAD' > $'bad \xff'
35
36write -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
42egrep --only-matching '^.*:1' err.txt
43
44## STDOUT:
45no-quoting:1
46"with spaces.sh":1
47b'bad \yff':1
48## END