]> git.ipfire.org Git - thirdparty/bash.git/blob - tests/dollar-at-star5.sub
bash-5.1 distribution sources and documentation
[thirdparty/bash.git] / tests / dollar-at-star5.sub
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.
5 #
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.
10 #
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/>.
13 #
14 # testing various combinations of quoted and unquoted expansions of $@, and
15 # whether they generate empty words after expansion
16
17 n() { echo "$#"; }
18
19 n "$@"
20 n ${foo-"$@"}
21 n "${foo-$@}"
22
23 n ""$@
24 n """$@"
25
26 n $(true)$@
27 n "$(true)$@"
28 n "$(true)$@"
29 n "$(true)""$@"
30
31 n $xxx$@
32 n "$xxx$@"
33 n $xxx"$@"
34 n "$xxx""$@"
35
36 recho $xxx"$@"
37 echo after 1
38
39 recho "$xxx$@"
40 echo after 2
41
42 recho ${foo:-$xxx"$@"}
43 echo after 3
44
45 # this is where these things start to differ
46 echo same as 1
47 recho "${foo:-$xxx"$@"}"
48 echo same as 2
49 recho "${foo:-$xxx$@}"
50
51 echo null fields
52 recho ""$@
53 recho """$@"
54
55 echo null fields in rhs
56 echo null string with unquoted '$@'
57 recho ${foo:-""$@}
58 echo null string with quoted '$@'
59 recho ${foo:-"""$@"}
60
61 echo assignment
62 recho "${foo=$@}"
63 echo variable
64 recho "$foo"
65 echo dollar-at
66 recho "${@}"