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