blob: ab534c8ead23a121490897e1bfc84f593d039bbd [file] [log] [blame]
Chet Ramey8868eda2020-12-06 15:51:17 -05001# 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#
14n() { echo $#; }
15
16set --
17
18n "$@"
19
20# should be 1
21n "$@"''
22n ''"$@"
23n ''"$@"''
24
25set -- ''
26
27n "$@"
28# should be 1
29n "$@"''
30n ''"$@"
31n ''"$@"''
32
33set -- '' ''
34
35n "$@"
36# should be 2
37n ''"$@"
38# should be 2
39n "$@"''
40# should be 2
41n ''"$@"''
42
43x=x
44
45set --
46
47n ${x+"$@"}
48
49# should be 1
50n ${x+"$@"''}
51n ${x+''"$@"}
52n ${x+''"$@"''}
53
54set -- ''
55
56n ${x+"$@"}
57# should be 1
58n ${x+"$@"''}
59n ${x+''"$@"}
60n ${x+''"$@"''}
61
62set -- '' ''
63
64n ${x+"$@"}
65# should be 2
66n ${x+''"$@"}
67# should be 2
68n ${x+"$@"''}
69# should be 2
70n ${x+''"$@"''}
71
72
73set --
74
75n "$@" "$@"
76n "$@""$@"
77
78n ${x+"$@" "$@"}
79
80set -- ''
81
82n ${x+"$@" "$@"}
83n "$@" "$@"
84
85set -- '' ''
86
87n ${x+"$@" "$@"}
88n "$@" "$@"
89n "$@""$@"
90
91# new tests
92unset -v x
93v=$'\177'
94
95recho ''$'\177'''
96recho $'\177'''
97recho ''$'\177'
98
99recho ''$v''
100recho ''$v
101recho $v''