OILS / spec / var-num.test.sh View on Github | oilshell.org

43 lines, 16 significant
1# Test $0 $1 $2
2
3## tags: interactive
4## compare_shells: bash dash mksh
5
6# ignored comment
7
8#### Normal and braced
9$SH -c 'echo $0 $1 ${2}' a b c d
10## stdout: a b c
11
12#### In function
13myfunc() {
14 echo $1 ${2}
15}
16myfunc a b c d
17## stdout: a b
18
19#### $0 with -c
20$SH -c 'echo $0' | grep -o 'sh$'
21## stdout: sh
22
23#### $0 with stdin
24echo 'echo $0' | $SH | grep -o 'sh$'
25## stdout: sh
26
27#### $0 with -i
28echo 'echo $0' | $SH -i | grep -o 'sh$'
29## stdout: sh
30
31#### $0 with filename
32s=_tmp/dollar0
33echo 'echo $0' > $s
34chmod +x $s
35$SH $s
36## stdout: _tmp/dollar0
37
38#### $@ with filename
39s=_tmp/dollar0
40echo 'echo $@' > $s
41chmod +x $s
42$SH $s a b c
43## stdout: a b c