1 # This program is free software: you can redistribute it and/or modify
2 # it under the terms of the GNU General Public License as published by
3 # the Free Software Foundation, either version 3 of the License, or
4 # (at your option) any later version.
6 # This program is distributed in the hope that it will be useful,
7 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 # GNU General Public License for more details.
11 # You should have received a copy of the GNU General Public License
12 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15 # first, let's start with the basics
44 # If IFS is null, the parameters are joined without separators
48 # If IFS is unset, the parameters are separated by spaces
56 set bob 'tom dick harry' joe
63 set bob 'tom dick harry' joe
70 set bob 'tom dick harry' joe
77 set bob 'tom dick harry' joe
84 # according to POSIX.2, unquoted $* should expand to multiple words if
85 # $IFS is null, just like unquoted $@
87 set bob 'tom dick harry' joe
94 set bob 'tom dick harry' joe
101 # if IFS is unset, the individual positional parameters are split on
102 # " \t\n" if $* or $@ are unquoted
104 set bob 'tom dick harry' joe
111 set bob 'tom dick harry' joe
118 # but not for "$@" or "$*"
119 set bob 'tom dick harry' joe
126 set bob 'tom dick harry' joe
133 # POSIX.2 says these should both expand the positional parameters
140 # this example is straight from the POSIX.2 rationale
155 set -- 1 2 3 4 5 6 7 8 9 10
174 eval foo3='$*' bar3='${*}'
217 eval foo3='$*' bar3='${*}'
241 # tests for the effect of quoting $* and $@ in an assignment context (plus
242 # arrays) -- bugs through bash 4.2
243 ${THIS_SH} ./dollar-at-star1.sub
245 # more tests for expanding $@ and $* in a context where there is no word
247 ${THIS_SH} ./dollar-at-star2.sub
248 ${THIS_SH} ./dollar-at-star3.sub
249 ${THIS_SH} ./dollar-at-star4.sub
250 ${THIS_SH} ./dollar-at-star5.sub
251 ${THIS_SH} ./dollar-at-star6.sub
252 ${THIS_SH} ./dollar-at-star7.sub
254 # tests for expansions of $@ and ${a[@]} (vs. $* and ${a[*]}) on the RHS of
255 # assignment statements with non-default IFS: $@ expands to args or array
256 # members separated by spaces
257 ${THIS_SH} ./dollar-at-star8.sub
259 # more tests of the expansions of $@ and $* (and their array equivalents)
260 # with different values for IFS
261 ${THIS_SH} ./dollar-at-star9.sub
263 # tests for expansions of "$*" and "$@" and their array equivalents when $1 == ''
264 # and we're using the POSIX word expansions
265 ${THIS_SH} ./dollar-at-star10.sub
266 ${THIS_SH} ./dollar-at-star11.sub
268 # tests for special expansion of "$*" and "${array[*]}" when used with other
269 # expansions -- bugs through bash-2.05b
270 ${THIS_SH} ./dollar-star1.sub
272 # tests for expansion of "$@" on rhs of things like ${param:+word}. Bugs
274 ${THIS_SH} ./dollar-at1.sub
276 # tests for expansion of other variables in double-quoted strings containing
277 # $@. Bugs through bash-2.05b
278 ${THIS_SH} ./dollar-at2.sub
280 # tests for various expansions of $* in different contexts -- word split,
281 # no splitting, etc. when $IFS is NUL
282 ${THIS_SH} ./dollar-star2.sub
284 # tests for expansions of "${array[*]}" and "${array[@]}" when $IFS is not the
285 # default and the array contains null elements
286 ${THIS_SH} ./dollar-star3.sub
288 # test for set -u and expansions of $@ when there are no positional parameters
289 ${THIS_SH} ./dollar-at3.sub
290 # test for set -u and expansions of $* when there are no positional parameters
291 ${THIS_SH} ./dollar-star4.sub
293 # tests for expansions of $* when IFS is null
294 ${THIS_SH} ./dollar-star5.sub
296 # tests for inappropriate word splitting through bash-4.2
297 ${THIS_SH} ./dollar-at4.sub
299 # tests for problems with "$@" preceded and followed by other quoted expansions
301 ${THIS_SH} ./dollar-at5.sub
303 # tests for problems with "${@:1}" and other expansions with null entries
304 # in positional parameters
305 ${THIS_SH} ./dollar-at6.sub
307 # tests for expansions of $* when $1 == ""; problem through bash-4.2
308 ${THIS_SH} ./dollar-star6.sub
310 # tests for expansions of $* (unquoted) when IFS changes (e.g., ${IFS:=-})
311 # problem through bash-4.2
312 ${THIS_SH} ./dollar-star7.sub
314 # tests for expansions of $* (unquoted) when IFS is null and word splitting is
315 # not going to be performed.
316 # problem through bash-4.4 in some parameter expansion contexts
317 ${THIS_SH} ./dollar-star8.sub
319 # tests for expansions of "$@" when there are no positional parameter or when
320 # $1 == '' and the expansion is preceded by something that results in a quoted
322 ${THIS_SH} ./dollar-at7.sub
324 # tests for expansions of $* when in an assignment context (no splitting) and
326 ${THIS_SH} ./dollar-star9.sub
328 # more tests for expansions of $* when not splitting with IFS set or unset and
329 # null strings as the positional parameters
330 ${THIS_SH} ./dollar-star10.sub