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
13 func() {
14 echo $1 ${2}
15 }
16 func 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
24 echo 'echo $0' | $SH | grep -o 'sh$'
25 ## stdout: sh
26
27 #### $0 with -i
28 echo 'echo $0' | $SH -i | grep -o 'sh$'
29 ## stdout: sh
30
31 #### $0 with filename
32 s=_tmp/dollar0
33 echo 'echo $0' > $s
34 chmod +x $s
35 $SH $s
36 ## stdout: _tmp/dollar0
37
38 #### $@ with filename
39 s=_tmp/dollar0
40 echo 'echo $@' > $s
41 chmod +x $s
42 $SH $s a b c
43 ## stdout: a b c