1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
|
OIFS="$IFS"
foo=' ,foo'
set -- "$foo"
if [[ $foo = ,* ]]; then echo bad 1; else echo ok 1; fi
if [[ $@ = ,* ]]; then echo bad 2; else echo ok 2; fi
if [[ $* = ,* ]]; then echo bad 3; else echo ok 3; fi
if [[ ${@} = ,* ]]; then echo bad 4; else echo ok 4; fi
if [[ ${*} = ,* ]]; then echo bad 5; else echo ok 5; fi
if [[ $1 = ,* ]]; then echo bad 6; else echo ok 6; fi
set -- ' ,foo'
if [[ $foo = ,* ]]; then echo bad 7; else echo ok 7; fi
if [[ $@ = ,* ]]; then echo bad 8; else echo ok 8; fi
if [[ $* = ,* ]]; then echo bad 9; else echo ok 9; fi
if [[ ${@} = ,* ]]; then echo bad 10; else echo ok 10; fi
if [[ ${*} = ,* ]]; then echo bad 11; else echo ok 11; fi
if [[ $1 = ,* ]]; then echo bad 12; else echo ok 12; fi
IFS=
if [[ $@ = ,* ]]; then echo bad 13; else echo ok 13; fi
if [[ $* = ,* ]]; then echo bad 14; else echo ok 14; fi
IFS="$OIFS"
foo=' ,foo'
set -- ' ' ',foo'
if [[ $@ = ,* ]]; then echo bad at 1; else echo ok at 1; fi
if [[ ${@} = ,* ]]; then echo bad at 2; else echo ok at 2; fi
if [[ $* = ,* ]]; then echo bad star 1; else echo ok star 1; fi
if [[ ${*} = ,* ]]; then echo bad star 2; else echo ok star 2; fi
foo=' ,foo'
set -- "$foo"
# expand_string_for_rhs
foo2=$@
echo "$foo2"
foo2=$*
echo "$foo2"
foo2="$@"
echo "$foo2"
foo2="$*"
echo "$foo2"
# expand_word_unsplit
case $@ in
$foo2) echo ok at 1 ;;
*) echo bad at 1 ;;
esac
# also uses expand_word_leave_quoted
case $@ in
$@) echo ok at 2;;
*) echo bad at 2;;
esac
case $@ in
$foo) echo ok at 3 ;;
*) echo bad at 3;;
esac
# expand_word_unsplit
case $* in
$foo2) echo ok star 1 ;;
*) echo bad star 1 ;;
esac
# also uses expand_word_leave_quoted
case $* in
$*) echo ok star 2;;
*) echo bad star 2;;
esac
case $* in
$foo) echo ok star 3 ;;
*) echo bad star 3;;
esac
case $@ in
$*) echo ok at-star 1;;
*) echo bad at-star 1;;
esac
case $* in
$@) echo ok at-star 2;;
*) echo bad at-star 2;;
esac
foo='a b c'
set -- $foo
# expand_string_for_rhs
IFS='|'
foo2=$@
echo "$foo2"
foo2=$*
echo "$foo2"
foo2="$@"
echo "$foo2"
foo2="$*"
echo "$foo2"
foo="a b c"
set -- $foo
if [[ $@ = $foo ]]; then echo ok at 1; else echo bad at 1; fi
if [[ $foo = $@ ]]; then echo ok at 2; else echo bad at 2; fi
case $@ in
$@) echo ok at 3 ;;
*) echo bad at 3 ;;
esac
case $@ in
$foo) echo ok at 4;;
*) echo bad at 4;;
esac
case $foo in
$@) echo ok at 5;;
*) echo bad at 5;;
esac
IFS="$OIFS"
foo="a b c"
set -- $foo
IFS=:
if [[ $@ = $foo ]]; then echo ok at 1; else echo bad at 1; fi
if [[ $foo = $@ ]]; then echo ok at 2; else echo bad at 2; fi
case $@ in
$@) echo ok at 3 ;;
*) echo bad at 3 ;;
esac
case $@ in
$foo) echo ok at 4;;
*) echo bad at 4;;
esac
case $foo in
$@) echo ok at 5;;
*) echo bad at 5;;
esac
IFS="$OIFS"
foo="a b c"
set -- $foo
IFS='|'
foo2=$@
case $@ in
$@) echo ok at 1 ;;
*) echo bad at 1 ;;
esac
case $foo2 in
$foo) echo ok at 2;;
*) echo bad at 2;;
esac
case $foo in
$foo2) echo ok at 3;;
*) echo bad at 3;;
esac
case $foo in
$foo) echo ok at 4;;
*) echo bad at 4;;
esac
case $foo2 in
$foo2) echo ok at 5;;
*) echo bad at 5;;
esac
case $foo2 in
$@) echo ok at 6;;
*) echo bad at 6;;
esac
case $@ in
$foo2) echo ok at 7;;
*) echo bad at 7;;
esac
case $foo in
$@) echo ok at 8;;
*) echo bad at 8;;
esac
case $@ in
$foo) echo ok at 9;;
*) echo bad at 9;;
esac
IFS="$OIFS"
|