Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/cmd/ksh93/tests/heredoc.sh
1810 views
1
########################################################################
2
# #
3
# This software is part of the ast package #
4
# Copyright (c) 1982-2012 AT&T Intellectual Property #
5
# and is licensed under the #
6
# Eclipse Public License, Version 1.0 #
7
# by AT&T Intellectual Property #
8
# #
9
# A copy of the License is available at #
10
# http://www.eclipse.org/org/documents/epl-v10.html #
11
# (with md5 checksum b35adb5213ca9657e911e9befb180842) #
12
# #
13
# Information and Software Systems Research #
14
# AT&T Research #
15
# Florham Park NJ #
16
# #
17
# David Korn <[email protected]> #
18
# #
19
########################################################################
20
function err_exit
21
{
22
print -u2 -n "\t"
23
print -u2 -r ${Command}[$1]: "${@:2}"
24
let Errors+=1
25
}
26
alias err_exit='err_exit $LINENO'
27
28
Command=${0##*/}
29
integer Errors=0
30
31
tmp=$(mktemp -dt) || { err_exit mktemp -dt failed; exit 1; }
32
trap "cd /; rm -rf $tmp" EXIT
33
34
f=$tmp/here1
35
g=$tmp/here2
36
cat > $f <<!
37
hello world
38
!
39
if [[ $(<$f) != 'hello world' ]]
40
then err_exit "'hello world' here doc not working"
41
fi
42
cat > $g <<\!
43
hello world
44
!
45
cmp $f $g 2> /dev/null || err_exit "'hello world' quoted here doc not working"
46
cat > $g <<- !
47
hello world
48
!
49
cmp $f $g 2> /dev/null || err_exit "'hello world' tabbed here doc not working"
50
cat > $g <<- \!
51
hello world
52
!
53
cmp $f $g 2> /dev/null || err_exit "'hello world' quoted tabbed here doc not working"
54
x=hello
55
cat > $g <<!
56
$x world
57
!
58
cmp $f $g 2> /dev/null || err_exit "'$x world' here doc not working"
59
cat > $g <<!
60
$(print hello) world
61
!
62
cmp $f $g 2> /dev/null || err_exit "'$(print hello) world' here doc not working"
63
cat > $f <<\!!
64
!@#$%%^^&*()_+~"::~;'`<>?/.,{}[]
65
!!
66
if [[ $(<$f) != '!@#$%%^^&*()_+~"::~;'\''`<>?/.,{}[]' ]]
67
then err_exit "'hello world' here doc not working"
68
fi
69
cat > $g <<!!
70
!@#\$%%^^&*()_+~"::~;'\`<>?/.,{}[]
71
!!
72
cmp $f $g 2> /dev/null || err_exit "unquoted here doc not working"
73
exec 3<<!
74
foo
75
!
76
if [[ $(<&3) != ' foo' ]]
77
then err_exit "leading tabs stripped with <<!"
78
fi
79
$SHELL -c "
80
eval `echo 'cat <<x'` "|| err_exit "eval `echo 'cat <<x'` core dumps"
81
cat > /dev/null <<EOF # comments should not cause core dumps
82
abc
83
EOF
84
cat >$g << :
85
:
86
:
87
cmp /dev/null $g 2> /dev/null || err_exit "empty here doc not working"
88
x=$(print $( cat <<HUP
89
hello
90
HUP
91
)
92
)
93
if [[ $x != hello ]]
94
then err_exit "here doc inside command sub not working"
95
fi
96
y=$(cat <<!
97
${x:+${x}}
98
!
99
)
100
if [[ $y != "${x:+${x}}" ]]
101
then err_exit '${x:+${x}} not working in here document'
102
fi
103
$SHELL -c '
104
x=0
105
while (( x < 100 ))
106
do ((x = x+1))
107
cat << EOF
108
EOF
109
done
110
' 2> /dev/null || err_exit '100 empty here docs fails'
111
{
112
print 'builtin -d cat
113
cat <<- EOF'
114
for ((i=0; i < 100; i++))
115
do print XXXXXXXXXXXXXXXXXXXX
116
done
117
print ' XXX$(date)XXXX
118
EOF'
119
} > $f
120
chmod +x "$f"
121
$SHELL "$f" > /dev/null || err_exit "large here-doc with command substitution fails"
122
x=$(/bin/cat <<!
123
$0
124
!
125
)
126
[[ "$x" == "$0" ]] || err_exit '$0 not correct inside here documents'
127
$SHELL -c 'x=$(
128
cat << EOF
129
EOF)' 2> /dev/null || err_exit 'here-doc cannot be terminated by )'
130
if [[ $( IFS=:;cat <<-!
131
$IFS$(print hi)$IFS
132
!) != :hi: ]]
133
then err_exit '$IFS unset by command substitution in here docs'
134
fi
135
if x=$($SHELL -c 'cat <<< "hello world"' 2> /dev/null)
136
then [[ $x == 'hello world' ]] || err_exit '<<< documents not working'
137
x=$($SHELL -c 'v="hello world";cat <<< $v' 2> /dev/null)
138
[[ $x == 'hello world' ]] || err_exit '<<< documents with $x not working'
139
x=$($SHELL -c 'v="hello world";cat <<< "$v"' 2> /dev/null)
140
[[ $x == 'hello world' ]] || err_exit '<<< documents with $x not working'
141
else err_exit '<<< syntax not supported'
142
fi
143
if [[ $(cat << EOF #testing
144
#abc
145
abc
146
EOF) != $'#abc\nabc' ]]
147
then err_exit 'comments not preserved in here-documents'
148
fi
149
cat > "$f" <<- '!!!!'
150
builtin cat
151
: << EOF
152
$PWD
153
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
154
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
155
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
156
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
157
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
158
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
159
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
160
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
161
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
162
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
163
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
164
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
165
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
166
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
167
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
168
EOF
169
command exec 3>&- 4>&- 5>&- 6>&- 7>&- 8>&- 9>&-
170
x=abc
171
cat << EOF
172
$x
173
EOF
174
!!!!
175
chmod 755 "$f"
176
if [[ $($SHELL "$f") != abc ]]
177
then err_exit 'here document descritor was closed'
178
fi
179
cat > "$f" <<- '!!!!'
180
exec 0<&-
181
foobar()
182
{
183
/bin/cat <<- !
184
foobar
185
!
186
}
187
: << EOF
188
$PWD
189
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
190
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
191
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
192
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
193
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
194
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
195
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
196
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
197
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
198
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
199
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
200
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
201
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
202
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
203
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
204
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
205
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
206
EOF
207
print -r -- "$(foobar)"
208
!!!!
209
if [[ $($SHELL "$f") != foobar ]]
210
then err_exit 'here document with stdin closed failed'
211
fi
212
printf $'cat <<# \\!!!\n\thello\n\t\tworld\n!!!' > $f
213
[[ $($SHELL "$f") == $'hello\n\tworld' ]] || err_exit "<<# not working for quoted here documents"
214
printf $'w=world;cat <<# !!!\n\thello\n\t\t$w\n!!!' > $f
215
[[ $($SHELL "$f") == $'hello\n\tworld' ]] || err_exit "<<# not working for non-quoted here documents"
216
[[ $( $SHELL <<- \++++
217
S=( typeset a )
218
function S.a.get
219
{
220
.sh.value=$__a
221
}
222
__a=1234
223
cat <<-EOF
224
${S.a}
225
EOF
226
++++
227
) == 1234 ]] 2> /dev/null || err_exit 'here document with get discipline failed'
228
[[ $($SHELL -c 'g(){ print ok;}; cat <<- EOF
229
${ g;}
230
EOF
231
' 2> /dev/null) == ok ]] || err_exit '${ command;} not working in heredoc'
232
script=$f
233
{
234
for ((i=0; i < 406; i++))
235
do print ': 23456789012345678'
236
done
237
print : 123456789123
238
cat <<- \EOF
239
eval "$(
240
{ cat ; } <<MARKER
241
print hello
242
MARKER
243
)"
244
EOF
245
} > $script
246
chmod +x $script
247
[[ $($SHELL $script) == hello ]] 2> /dev/null || err_exit 'heredoc embeded in command substitution fails at buffer boundary'
248
249
got=$( cat << EOF
250
\
251
abc
252
EOF)
253
[[ $got == abc ]] || err_exit 'line continuation at start of buffer not working'
254
255
tmpfile1=$tmp/file1
256
tmpfile2=$tmp/file2
257
function gendata
258
{
259
typeset -RZ3 i
260
for ((i=0; i < 500; i++))
261
do print -r -- "=====================This is line $i============="
262
done
263
}
264
265
cat > $tmpfile1 <<- +++
266
function foobar
267
{
268
cat << XXX
269
$(gendata)
270
XXX
271
}
272
cat > $tmpfile2 <<- EOF
273
\$(foobar)
274
$(gendata)
275
EOF
276
+++
277
chmod +x $tmpfile1
278
$SHELL $tmpfile1
279
set -- $(wc < $tmpfile2)
280
(( $1 == 1000 )) || err_exit "heredoc $1 lines, should be 1000 lines"
281
(( $2 == 4000 )) || err_exit "heredoc $2 words, should be 4000 words"
282
283
# comment with here document looses line number count
284
integer line=$((LINENO+5))
285
function tst
286
{
287
[[ $1 == $2 ]] || echo expected $1, got $2
288
}
289
tst $line $LINENO <<"!" # this comment affects LINENO #
290
1
291
!
292
(( (line+=3) == LINENO )) || err_exit "line number=$LINENO should be $line"
293
294
[[ $($SHELL -c 'wc -c <<< ""' 2> /dev/null) == *1 ]] || err_exit '<<< with empty string not working'
295
296
mkdir $tmp/functions
297
cat > $tmp/functions/t2 <<\!!!
298
function t2
299
{
300
cat <<EOF | sed 's/1234567890/qwertyuiopasdfghj/'
301
${1}
302
EOF
303
}
304
!!!
305
306
FPATH=$tmp/functions
307
foo=${
308
cat <<EOF
309
1 34567890 $(t2 1234567890 ) 0123456789012345678901234567890123
310
111111111111111111111111111111111111111111111111111111111111111
311
111111111111111111111111111111111111111111111111111111111111111
312
111111111111111111111111111111111111111111111111111111111111111
313
111111111111111111111111111111111111111111111111111111111111111
314
111111111111111111111111111111111111111111111111111111111111111
315
111111111111111111111111111111111111111111111111111111111111111
316
111111111111111111111111111111111111111111111111111111111111111
317
111111111111111111111111111111111111111111111111111111111111111
318
111111111111111111111111111111111111111111111111111111111111111
319
111111111111111111111111111111111111111111111111111111111111111
320
111111111111111111111111111111111111111111111111111111111111111
321
111111111111111111111111111111111111111111111111111111111111111
322
111111111111111111111111111111111111111111111111111111111111111
323
111111111111111111111111111111111111111111111111111111111111111
324
111111111111111111111111111111111111111111111111111111111111 1
325
326
2 34567890 $(t2 1234567890 ) 0123456789012345678901234567890123
327
222222222222222222222222222222222222222222222222222222222222222
328
222222222222222222222222222222222222222222222222222222222222222
329
222222222222222222222222222222222222222222222222222222222222222
330
222222222222222222222222222222222222222222222222222222222222222
331
222222222222222222222222222222222222222222222222222222222222222
332
222222222222222222222222222222222222222222222222222222222222222
333
222222222222222222222222222222222222222222222222222222222222222
334
222222222222222222222222222222222222222222222222222222222222222
335
222222222222222222222222222222222222222222222222222222222222222
336
222222222222222222222222222222222222222222222222222222222222222
337
222222222222222222222222222222222222222222222222222222222222222
338
222222222222222222222222222222222222222222222222222222222222222
339
222222222222222222222222222222222222222222222222222222222222222
340
222222222222222222222222222222222222222222222222222222222222222
341
222222222222222222222222222222222222222222222222222222222222 2
342
343
3 34567890 $(t2 1234567890 ) 0123456789012345678901234567890123
344
333333333333333333333333333333333333333333333333333333333333333
345
333333333333333333333333333333333333333333333333333333333333333
346
333333333333333333333333333333333333333333333333333333333333333
347
333333333333333333333333333333333333333333333333333333333333333
348
333333333333333333333333333333333333333333333333333333333333333
349
333333333333333333333333333333333333333333333333333333333333333
350
333333333333333333333333333333333333333333333333333333333333333
351
333333333333333333333333333333333333333333333333333333333333333
352
333333333333333333333333333333333333333333333333333333333333333
353
333333333333333333333333333333333333333333333333333333333333333
354
333333333333333333333333333333333333333333333333333333333333333
355
333333333333333333333333333333333333333333333333333333333333333
356
333333333333333333333333333333333333333333333333333333333333333
357
333333333333333333333333333333333333333333333333333333333333333
358
333333333333333333333333333333333333333333333333333333333333 3
359
360
4 34567890 $(t2 1234567890 ) 0123456789012345678901234567890123
361
444444444444444444444444444444444444444444444444444444444444444
362
444444444444444444444444444444444444444444444444444444444444444
363
444444444444444444444444444444444444444444444444444444444444444
364
444444444444444444444444444444444444444444444444444444444444444
365
444444444444444444444444444444444444444444444444444444444444444
366
444444444444444444444444444444444444444444444444444444444444444
367
444444444444444444444444444444444444444444444444444444444444444
368
444444444444444444444444444444444444444444444444444444444444444
369
444444444444444444444444444444444444444444444444444444444444444
370
444444444444444444444444444444444444444444444444444444444444444
371
444444444444444444444444444444444444444444444444444444444444444
372
444444444444444444444444444444444444444444444444444444444444444
373
444444444444444444444444444444444444444444444444444444444444444
374
444444444444444444444444444444444444444444444444444444444444444
375
444444444444444444444444444444444444444444444444444444444444 4
376
377
5 34567890 $(t2 1234567890 ) 0123456789012345678901234567890123
378
555555555555555555555555555555555555555555555555555555555555555
379
555555555555555555555555555555555555555555555555555555555555555
380
555555555555555555555555555555555555555555555555555555555555555
381
555555555555555555555555555555555555555555555555555555555555555
382
555555555555555555555555555555555555555555555555555555555555555
383
555555555555555555555555555555555555555555555555555555555555555
384
555555555555555555555555555555555555555555555555555555555555555
385
555555555555555555555555555555555555555555555555555555555555555
386
555555555555555555555555555555555555555555555555555555555555555
387
555555555555555555555555555555555555555555555555555555555555555
388
555555555555555555555555555555555555555555555555555555555555555
389
555555555555555555555555555555555555555555555555555555555555555
390
555555555555555555555555555555555555555555555555555555555555555
391
555555555555555555555555555555555555555555555555555555555555555
392
555555555555555555555555555555555555555555555555555555555555 5
393
394
6 34567890 $(t2 1234567890 ) 0123456789012345678901234567890123
395
666666666666666666666666666666666666666666666666666666666666666
396
666666666666666666666666666666666666666666666666666666666666666
397
666666666666666666666666666666666666666666666666666666666666666
398
666666666666666666666666666666666666666666666666666666666666666
399
666666666666666666666666666666666666666666666666666666666666666
400
666666666666666666666666666666666666666666666666666666666666666
401
666666666666666666666666666666666666666666666666666666666666666
402
666666666666666666666666666666666666666666666666666666666666666
403
666666666666666666666666666666666666666666666666666666666666666
404
666666666666666666666666666666666666666666666666666666666666666
405
666666666666666666666666666666666666666666666666666666666666666
406
666666666666666666666666666666666666666666666666666666666666666
407
666666666666666666666666666666666666666666666666666666666666666
408
666666666666666666666666666666666666666666666666666666666666666
409
666666666666666666666666666666666666666666666666666666666666 6
410
411
7 34567890 $(t2 1234567890 ) 0123456789012345678901234567890123
412
777777777777777777777777777777777777777777777777777777777777777
413
777777777777777777777777777777777777777777777777777777777777777
414
777777777777777777777777777777777777777777777777777777777777777
415
777777777777777777777777777777777777777777777777777777777777777
416
777777777777777777777777777777777777777777777777777777777777777
417
777777777777777777777777777777777777777777777777777777777777777
418
777777777777777777777777777777777777777777777777777777777777777
419
777777777777777777777777777777777777777777777777777777777777777
420
777777777777777777777777777777777777777777777777777777777777777
421
777777777777777777777777777777777777777777777777777777777777777
422
777777777777777777777777777777777777777777777777777777777777777
423
777777777777777777777777777777777777777777777777777777777777777
424
777777777777777777777777777777777777777777777777777777777777777
425
777777777777777777777777777777777777777777777777777777777777777
426
777777777777777777777777777777777777777777777777777777777777 7
427
428
8 34567890 $(t2 1234567890 ) 0123456789012345678901234567890123
429
888888888888888888888888888888888888888888888888888888888888888
430
888888888888888888888888888888888888888888888888888888888888888
431
888888888888888888888888888888888888888888888888888888888888888
432
888888888888888888888888888888888888888888888888888888888888888
433
888888888888888888888888888888888888888888888888888888888888888
434
888888888888888888888888888888888888888888888888888888888888888
435
888888888888888888888888888888888888888888888888888888888888888
436
888888888888888888888888888888888888888888888888888888888888888
437
888888888888888888888888888888888888888888888888888888888888888
438
888888888888888888888888888888888888888888888888888888888888888
439
888888888888888888888888888888888888888888888888888888888888888
440
888888888888888888888888888888888888888888888888888888888888888
441
888888888888888888888888888888888888888888888888888888888888888
442
888888888888888888888888888888888888888888888888888888888888888
443
888888888888888888888888888888888888888888888888888888888888 8
444
445
9 34567890 $(t2 1234567890 ) 0123456789012345678901234567890123
446
999999999999999999999999999999999999999999999999999999999999999
447
999999999999999999999999999999999999999999999999999999999999999
448
999999999999999999999999999999999999999999999999999999999999999
449
999999999999999999999999999999999999999999999999999999999999999
450
999999999999999999999999999999999999999999999999999999999999999
451
999999999999999999999999999999999999999999999999999999999999999
452
999999999999999999999999999999999999999999999999999999999999999
453
999999999999999999999999999999999999999999999999999999999999999
454
999999999999999999999999999999999999999999999999999999999999999
455
999999999999999999999999999999999999999999999999999999999999999
456
999999999999999999999999999999999999999999999999999999999999999
457
999999999999999999999999999999999999999999999999999999999999999
458
999999999999999999999999999999999999999999999999999999999999999
459
999999999999999999999999999999999999999999999999999999999999999
460
999999999999999999999999999999999999999999999999999999999999 9
461
462
10 4567890 $(t2 1234567890 ) 0123456789012345678901234567890123
463
101010101010101010101010101010101010101010101010101010101010103
464
101010101010101010101010101010101010101010101010101010101010103
465
101010101010101010101010101010101010101010101010101010101010103
466
101010101010101010101010101010101010101010101010101010101010103
467
101010101010101010101010101010101010101010101010101010101010103
468
101010101010101010101010101010101010101010101010101010101010103
469
101010101010101010101010101010101010101010101010101010101010103
470
101010101010101010101010101010101010101010101010101010101010103
471
101010101010101010101010101010101010101010101010101010101010103
472
101010101010101010101010101010101010101010101010101010101010103
473
101010101010101010101010101010101010101010101010101010101010103
474
101010101010101010101010101010101010101010101010101010101010103
475
101010101010101010101010101010101010101010101010101010101010103
476
101010101010101010101010101010101010101010101010101010101010103
477
1010101010101010101010101010101010101010101010101010101010 END
478
479
EOF
480
}
481
[[ ${#foo} == 10238 ]] || err_exit 'large here docs containing command subs of dynamically loaded functions fails'
482
483
{
484
print $'FOO=1\nBAR=foobarbaz'
485
print -- 'cat <<#EOF'
486
integer i
487
for ((i=0; i < 50000; i++))
488
do print -r -- ' $(($FOO + 1))'
489
print -r -- ' $BAR meep'
490
done
491
print EOF
492
} > $f
493
$SHELL $f > $g
494
[[ $(grep meep $g | grep -v foobar) != '' ]] && err_exit 'here-doc loosing $var expansions on boundaries in rare cases'
495
496
print foo > $tmp/foofile
497
x=$( $SHELL 2> /dev/null 'read <<< $(<'"$tmp"'/foofile) 2> /dev/null;print -r "$REPLY"')
498
[[ $x == foo ]] || err_exit '<<< $(<file) not working'
499
500
exit $((Errors<125?Errors:125))
501
502