blob: 2bfb72ccca01fe2858c6ea39643ee7c7db945f3c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
name: IFS-space-1
description:
Simple test, default IFS
stdin:
showargs() { for i; do echo -n " <$i>"; done; echo; }
set -- A B C
showargs 1 $*
showargs 2 "$*"
showargs 3 $@
showargs 4 "$@"
expected-stdout:
<1> <A> <B> <C>
<2> <A B C>
<3> <A> <B> <C>
<4> <A> <B> <C>
---
name: IFS-colon-1
description:
Simple test, IFS=:
stdin:
showargs() { for i; do echo -n " <$i>"; done; echo; }
IFS=:
set -- A B C
showargs 1 $*
showargs 2 "$*"
showargs 3 $@
showargs 4 "$@"
expected-stdout:
<1> <A> <B> <C>
<2> <A:B:C>
<3> <A> <B> <C>
<4> <A> <B> <C>
---
name: IFS-null-1
description:
Simple test, IFS=""
stdin:
showargs() { for i; do echo -n " <$i>"; done; echo; }
IFS=""
set -- A B C
showargs 1 $*
showargs 2 "$*"
showargs 3 $@
showargs 4 "$@"
expected-stdout:
<1> <A B C>
<2> <ABC>
<3> <A B C>
<4> <A B C>
---
name: IFS-space-colon-1
description:
Simple test, IFS=<white-space>:
stdin:
showargs() { for i; do echo -n " <$i>"; done; echo; }
IFS="$IFS:"
set --
showargs 1 $*
showargs 2 "$*"
showargs 3 $@
showargs 4 "$@"
showargs 5 : "$@"
expected-stdout:
<1>
<2> <>
<3>
<4>
<5> <:>
---
name: IFS-space-colon-2
description:
Simple test, IFS=<white-space>:
At&t ksh fails this, POSIX says the test is correct.
stdin:
showargs() { for i; do echo -n " <$i>"; done; echo; }
IFS="$IFS:"
set --
showargs :"$@"
expected-stdout:
<:>
---
name: IFS-space-colon-3
description:
Simple test, IFS=<white-space>:
pdksh fails both of these tests
stdin:
showargs() { for i; do echo -n " <$i>"; done; echo; }
IFS="$IFS:"
x=
set --
showargs "$x$@"
showargs "$@$x"
expected-fail: yes
expected-stdout:
<>
<>
---
name: IFS-space-colon-4
description:
Simple test, IFS=<white-space>:
stdin:
showargs() { for i; do echo -n " <$i>"; done; echo; }
IFS="$IFS:"
set --
showargs "$@$@"
expected-stdout:
---
name: IFS-space-colon-5
description:
Simple test, IFS=<white-space>:
Don't know what POSIX thinks of this. at&t ksh does not do this.
stdin:
showargs() { for i; do echo -n " <$i>"; done; echo; }
IFS="$IFS:"
set --
showargs "${@:-}"
expected-stdout:
<>
---
name: IFS-subst-1
description:
Simple test, IFS=<white-space>:
stdin:
showargs() { for i; do echo -n " <$i>"; done; echo; }
IFS="$IFS:"
x=":b: :"
echo -n '1:'; for i in $x ; do echo -n " [$i]" ; done ; echo
echo -n '2:'; for i in :b:: ; do echo -n " [$i]" ; done ; echo
showargs 3 $x
showargs 4 :b::
x="a:b:"
echo -n '5:'; for i in $x ; do echo -n " [$i]" ; done ; echo
showargs 6 $x
x="a::c"
echo -n '7:'; for i in $x ; do echo -n " [$i]" ; done ; echo
showargs 8 $x
echo -n '9:'; for i in ${FOO-`echo -n h:i`th:ere} ; do echo -n " [$i]" ; done ; echo
showargs 10 ${FOO-`echo -n h:i`th:ere}
showargs 11 "${FOO-`echo -n h:i`th:ere}"
x=" A : B::D"
echo -n '12:'; for i in $x ; do echo -n " [$i]" ; done ; echo
showargs 13 $x
expected-stdout:
1: [] [b] []
2: [:b::]
<3> <> <b> <>
<4> <:b::>
5: [a] [b]
<6> <a> <b>
7: [a] [] [c]
<8> <a> <> <c>
9: [h] [ith] [ere]
<10> <h> <ith> <ere>
<11> <h:ith:ere>
12: [A] [B] [] [D]
<13> <A> <B> <> <D>
---
|