Imported from ../bash-2.05.tar.gz.
[platform/upstream/bash.git] / tests / dollar-at-star
1 # first, let's start with the basics
2
3 recho "$@"
4 recho "$*"
5
6 recho $@
7 recho $*
8
9 set a b
10
11 recho "$*"
12
13 # If IFS is null, the parameters are joined without separators
14 IFS=''
15 recho "$*"
16
17 # If IFS is unset, the parameters are separated by spaces
18 unset IFS
19 recho "${*}"
20
21 recho "$@"
22 recho $@
23
24 IFS='/'
25 set bob 'tom dick harry' joe
26 set $*
27 recho $#
28 recho $1
29 recho $2
30 recho $3
31
32 set bob 'tom dick harry' joe
33 set ${*}
34 recho $#
35 recho $1
36 recho $2
37 recho $3
38
39 set bob 'tom dick harry' joe
40 set $@
41 recho $#
42 recho $1
43 recho $2
44 recho $3
45
46 set bob 'tom dick harry' joe
47 set ${@}
48 recho $#
49 recho $1
50 recho $2
51 recho $3
52
53 # according to POSIX.2, unquoted $* should expand to multiple words if
54 # $IFS is null, just like unquoted $@
55 IFS=''
56 set bob 'tom dick harry' joe
57 set $*
58 recho $#
59 recho $1
60 recho $2
61 recho $3
62
63 set bob 'tom dick harry' joe
64 set $@
65 recho $#
66 recho $1
67 recho $2
68 recho $3
69
70 # if IFS is unset, the individual positional parameters are split on
71 # " \t\n" if $* or $@ are unquoted
72 unset IFS
73 set bob 'tom dick harry' joe
74 set $*
75 recho $#
76 recho $1
77 recho $2
78 recho $3
79
80 set bob 'tom dick harry' joe
81 set $@  
82 recho $#                                              
83 recho $1
84 recho $2
85 recho $3
86
87 # but not for "$@" or "$*"
88 set bob 'tom dick harry' joe
89 set "$*"
90 recho $#
91 recho $1
92 recho $2
93 recho $3
94
95 set bob 'tom dick harry' joe
96 set "$@"
97 recho $#
98 recho $1
99 recho $2
100 recho $3
101
102 # POSIX.2 says these should both expand the positional parameters
103 # to multiple words
104 set a b c d e
105 IFS=""
106 recho $@
107 recho "$@"
108
109 # this example is straight from the POSIX.2 rationale
110 set foo bar bam
111
112 recho "$@"
113 recho "$*"
114
115 unset IFS
116
117 recho "$@"
118 recho $@
119 recho "$*"
120
121 IFS=:
122
123 # special variables
124 set -- 1 2 3 4 5 6 7 8 9 10
125
126 bar=${*}
127 foo=$*
128 echo foo = "$foo"
129 echo bar = "$bar"
130
131 foo1=$@
132 bar1=${@}
133
134 echo foo1 = "$foo1"
135 echo bar1 = "$bar1"
136
137 foo2="$*"
138 bar2="${*}"
139
140 echo foo2 = "$foo2"
141 echo bar2 = "$bar2"
142
143 eval foo3='$*' bar3='${*}'
144 echo foo3 = "$foo3"
145 echo bar3 = "$bar3"
146
147 case $* in
148 *\:*)   echo ok 1;;
149 *)      echo bad 1;;
150 esac
151
152 case $@ in
153 *\:*)   echo bad 2;;
154 *)      echo ok 2;;
155 esac
156
157 case "$*" in
158 *\:*)   echo ok 3;;
159 *)      echo bad 3;;
160 esac
161
162 case "$@" in
163 *\:*)   echo bad 4;;
164 *)      echo ok 4;;
165 esac
166
167 IFS=$' \t\n'
168
169 bar=${*}
170 foo=$*
171 echo foo = "$foo"
172 echo bar = "$bar"
173
174 foo1=$@
175 bar1=${@}
176
177 echo foo1 = "$foo1"
178 echo bar1 = "$bar1"
179
180 foo2="$*"
181 bar2="${*}"
182
183 echo foo2 = "$foo2"
184 echo bar2 = "$bar2"
185
186 eval foo3='$*' bar3='${*}'
187 echo foo3 = "$foo3"
188 echo bar3 = "$bar3"
189
190 case $* in
191 *\ *)   echo ok 1;;
192 *)      echo bad 1;;
193 esac
194
195 case $@ in
196 *\ *)   echo ok 2;;
197 *)      echo bad 2;;
198 esac
199
200 case "$*" in
201 *\ *)   echo ok 3;;
202 *)      echo bad 3;;
203 esac
204
205 case "$@" in
206 *\ *)   echo ok 4;;
207 *)      echo bad 4;;
208 esac
209
210 exit 0