forked from MirBSD/mksh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check.t
14429 lines (14355 loc) · 300 KB
/
check.t
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# $MirOS: src/bin/mksh/check.t,v 1.918 2024/07/26 18:39:05 tg Exp $
# -*- mode: sh -*-
#-
# Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
# 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018,
# 2019, 2020, 2021, 2022, 2023, 2024
# mirabilos <[email protected]>
#
# Provided that these terms and disclaimer and all copyright notices
# are retained or reproduced in an accompanying document, permission
# is granted to deal in this work without restriction, including unâ€
# limited rights to use, publicly perform, distribute, sell, modify,
# merge, give away, or sublicence.
#
# This work is provided “AS IS†and WITHOUT WARRANTY of any kind, to
# the utmost extent permitted by applicable law, neither express nor
# implied; without malicious intent or gross negligence. In no event
# may a licensor, author or contributor be held liable for indirect,
# direct, other damage, loss, or other issues arising in any way out
# of dealing in the work, even if advised of the possibility of such
# damage or existence of a defect, except proven that it results out
# of said person’s immediate fault when using the work as intended.
#-
# You may also want to test IFS with the script at
# http://www.research.att.com/~gsf/public/ifs.sh
#
# More testsuites at:
# http://svnweb.freebsd.org/base/head/bin/test/tests/legacy_test.sh?view=co&content-type=text%2Fplain
#
# Integrated testsuites from:
# (2013/12/02 20:39:44) http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/regress/bin/ksh/?sortby=date
expected-stdout:
KSH R59 2024/07/26
description:
Check base version of full shell
stdin:
vsn=${KSH_VERSION%%' +'*}
echo "${vsn#* }"
name: KSH_VERSION
---
expected-stdout:
@(#)MIRBSD
description:
Check this identifies as legacy shell
stdin:
echo "${KSH_VERSION%% *}"
name: KSH_VERSION-modern
category: !shell:legacy-yes
---
expected-stdout:
@(#)LEGACY
description:
Check this identifies as legacy shell
stdin:
echo "${KSH_VERSION%% *}"
name: KSH_VERSION-legacy
category: !shell:legacy-no
---
name: KSH_VERSION-ascii
description:
Check that the shell version tag does not include EBCDIC
category: !shell:ebcdic-yes
stdin:
set -o noglob
for x in $KSH_VERSION; do
[[ $x = '+EBCDIC' ]] && exit 1
done
exit 0
---
name: KSH_VERSION-ebcdic
description:
Check that the shell version tag includes EBCDIC
category: !shell:ebcdic-no
stdin:
set -o noglob
for x in $KSH_VERSION; do
[[ $x = '+EBCDIC' ]] && exit 0
done
exit 1
---
name: KSH_VERSION-binmode
description:
Check that the shell version tag does not include TEXTMODE
category: !shell:textmode-yes
stdin:
set -o noglob
for x in $KSH_VERSION; do
[[ $x = '+TEXTMODE' ]] && exit 1
done
exit 0
---
name: KSH_VERSION-textmode
description:
Check that the shell version tag includes TEXTMODE
category: !shell:textmode-no
stdin:
set -o noglob
for x in $KSH_VERSION; do
[[ $x = '+TEXTMODE' ]] && exit 0
done
exit 1
---
name: selftest-1
description:
Regression test self-testing
stdin:
echo ${foo:-baz}
expected-stdout:
baz
---
name: selftest-2
description:
Regression test self-testing
env-setup: !foo=bar!
stdin:
echo ${foo:-baz}
expected-stdout:
bar
---
name: selftest-3
description:
Regression test self-testing
env-setup: !ENV=fnord!
stdin:
echo "<$ENV>"
expected-stdout:
<fnord>
---
name: selftest-exec
description:
Ensure that the test run directory (default /tmp but can be changed
with check.pl flag -T or test.sh $TMPDIR) is not mounted noexec, as
we execute scripts from the scratch directory during several tests.
stdin:
print '#!'"$__progname"'\necho tf' >lq
chmod +x lq
./lq
echo = $?
expected-stdout:
tf
= 0
---
name: selftest-exec-perl
description:
Ensure we can run perl scriptlets in tests as well
stdin:
print '#!'"$__perlname"'\nprint 3x"3"."\\n";' >lq
chmod +x lq
./lq
echo = $?
expected-stdout:
333
= 0
---
name: selftest-exec-a
description:
Ensure using 'exec -a' to change argv[0] works
file-setup: file 644 "pass"
print -r -- "fail, args:"
i=-1
for x in "$0" "$@"; do
print -r -- "$((++i))<$x>"
done
stdin:
exec -a -print "$__progname" pass '\u20AC'
expected-stdout:
pass €
---
name: selftest-env
description:
Just output the environment variables set (always fails)
category: disabled
stdin:
set
---
name: selftest-direct-builtin-call
description:
Check that direct builtin calls work
stdin:
ln -s "$__progname" echo 2>/dev/null || cp "$__progname" echo
./echo -c 'echo foo'
expected-stdout:
-c echo foo
---
name: selftest-pathsep-unix
description:
Check that $PATHSEP is set correctly.
category: !os:os2
stdin:
PATHSEP=.; export PATHSEP
"$__progname" -c 'print -r -- $PATHSEP'
expected-stdout:
:
---
name: selftest-pathsep-dospath
description:
Check that $PATHSEP is set correctly.
category: os:os2
stdin:
PATHSEP=.; export PATHSEP
"$__progname" -c 'print -r -- $PATHSEP'
expected-stdout:
;
---
name: selftest-tools
description:
Check that relevant tools work as expected. If not, e.g. on SerenityOS,
install better tools from ports and prepend /usr/local/bin to $PATH.
stdin:
echo foobarbaz | grep bar
echo = $?
echo abc | sed y/ac/AC/
echo = $?
echo abc | tr ac AC
echo = $?
expected-stdout:
foobarbaz
= 0
AbC
= 0
AbC
= 0
---
name: selftest-tty-absent
description:
Check that a controlling tty is not present as regress:no-ctty was used
(if this test fails for you DO NOT PASS regress:no-ctty and fix every
other test that fails: why u use it if u haz ctty?)
category: regress:no-ctty
env-setup: !ENV=./envf!
file-setup: file 644 "envf"
PS1=X
arguments: !-i!
stdin:
echo ok
expected-stdout:
ok
expected-stderr-pattern:
/^W: .*find tty fd.*\nW: .*have full job control\nXX$/
---
name: selftest-tty-present
description:
Check that a controlling tty is present as regress:no-ctty was not used
need-ctty: yes
env-setup: !ENV=./envf!
file-setup: file 644 "envf"
PS1=X
arguments: !-i!
stdin:
echo ok
expected-stdout:
ok
expected-stderr: !
XX
---
name: alias-1
description:
Check that recursion is detected/avoided in aliases.
stdin:
alias fooBar=fooBar
fooBar
exit 0
expected-stderr-pattern:
/fooBar.*not found.*/
---
name: alias-2
description:
Check that recursion is detected/avoided in aliases.
stdin:
alias fooBar=barFoo
alias barFoo=fooBar
fooBar
barFoo
exit 0
expected-stderr-pattern:
/fooBar.*not found.*\n.*barFoo.*not found/
---
name: alias-3
description:
Check that recursion is detected/avoided in aliases.
stdin:
alias Echo='echo '
alias fooBar=barFoo
alias barFoo=fooBar
Echo fooBar
unalias barFoo
Echo fooBar
expected-stdout:
fooBar
barFoo
---
name: alias-4
description:
Check that alias expansion isn't done on keywords (in keyword
postitions).
stdin:
alias Echo='echo '
alias while=While
while false; do echo hi ; done
Echo while
expected-stdout:
While
---
name: alias-5
description:
Check that alias expansion done after alias with trailing space.
stdin:
alias Echo='echo '
alias foo='bar stuff '
alias bar='Bar1 Bar2 '
alias stuff='Stuff'
alias blah='Blah'
Echo foo blah
expected-stdout:
Bar1 Bar2 Stuff Blah
---
name: alias-6
description:
Check that alias expansion done after alias with trailing space.
stdin:
alias Echo='echo '
alias foo='bar bar'
alias bar='Bar '
alias blah=Blah
Echo foo blah
expected-stdout:
Bar Bar Blah
---
name: alias-7
description:
Check that alias expansion done after alias with trailing space
after a keyword.
stdin:
alias X='case '
alias Y=Z
X Y in 'Y') echo is y ;; Z) echo is z ;; esac
expected-stdout:
is z
---
name: alias-8
description:
Check that newlines in an alias don't cause the command to be lost.
stdin:
alias foo='
echo hi
echo there
'
foo
expected-stdout:
hi
there
---
name: alias-9
description:
Check that recursion is detected/avoided in aliases.
This check fails for slow machines or Cygwin, raise
the time-limit clause (e.g. to 7) if this occurs.
time-limit: 3
stdin:
print '#!'"$__progname"'\necho tf' >lq
chmod +x lq
PATH=$PWD$PATHSEP$PATH
alias lq=lq
lq
echo = now
i=`lq`
print -r -- $i
echo = out
exit 0
expected-stdout:
tf
= now
tf
= out
---
name: alias-10
description:
Check that recursion is detected/avoided in aliases.
Regression, introduced during an old bugfix.
stdin:
alias foo='print hello '
alias bar='foo world'
echo $(bar)
expected-stdout:
hello world
---
name: alias-11
description:
Check that special argument handling still applies with escaped aliases
stdin:
alias local1='\typeset'
alias local2='\\builtin typeset'
function fooa {
local1 x=$1 y=z
print -r -- "$x,$y"
}
function foob {
local2 x=$1 y=z
print -r -- "$x,$y"
}
x=1 y=2; fooa 'bar - baz'
x=1 y=2; foob 'bar - baz'
expected-stdout:
bar - baz,z
bar - baz,z
---
name: alias-12
description:
Something weird from Martijn Dekker
stdin:
alias echo=print
x() { echo a; (echo b); x=$(echo c); }
typeset -f x
alias OPEN='{' CLOSE='};'
{ OPEN echo hi1; CLOSE }
var=`{ OPEN echo hi2; CLOSE }` && echo "$var"
var=$({ OPEN echo hi3; CLOSE }) && echo "$var"
expected-stdout:
x() {
\print a
( \print b )
x=$(\print c )
}
hi1
hi2
hi3
---
name: arith-compound
description:
Check that arithmetic expressions are compound constructs
stdin:
{ ! (( 0$(cat >&2) )) <<<1; } <<<2
expected-stderr:
1
---
name: arith-divnull
description:
Check what happens if dividing by 0
stdin:
echo 1 $((0 ? 2/0 : 666)) .
echo 2 $?
echo 3 $((1 ? 2/0 : 666)) .
echo 4 $?
expected-stdout:
1 666 .
2 0
expected-exit: e != 0
expected-stderr-pattern:
/^[^\n]*: zero divisor$/
---
name: arith-lazy-1
description:
Check that only one side of ternary operator is evaluated
stdin:
x=i+=2
y=j+=2
typeset -i i=1 j=1
echo $((1 ? 20 : (x+=2)))
echo $i,$x
echo $((0 ? (y+=2) : 30))
echo $j,$y
expected-stdout:
20
1,i+=2
30
1,j+=2
---
name: arith-lazy-2
description:
Check that assignments not done on non-evaluated side of ternary
operator
stdin:
x=i+=2
y=j+=2
typeset -i i=1 j=1
echo $((1 ? 20 : (x+=2)))
echo $i,$x
echo $((0 ? (y+=2) : 30))
echo $i,$y
expected-stdout:
20
1,i+=2
30
1,j+=2
---
name: arith-lazy-3
description:
Check that assignments not done on non-evaluated side of ternary
operator and this construct is parsed correctly (Debian #445651)
stdin:
x=4
y=$((0 ? x=1 : 2))
echo = $x $y =
expected-stdout:
= 4 2 =
---
name: arith-lazy-4
description:
Check that preun/postun not done on non-evaluated side of ternary
operator
stdin:
(( m = n = 0, 1 ? n++ : m++ ? 2 : 3 ))
echo "($n, $m)"
m=0; echo $(( 0 ? ++m : 2 )); echo $m
m=0; echo $(( 0 ? m++ : 2 )); echo $m
expected-stdout:
(1, 0)
2
0
2
0
---
name: arith-lazy-5-arr-n
description: Check lazy evaluation with side effects
stdin:
a=0; echo "$((0&&b[a++],a))"
expected-stdout:
0
---
name: arith-lazy-5-arr-p
description: Check lazy evaluation with side effects
stdin:
a=0; echo "$((0&&(b[a++]),a))"
expected-stdout:
0
---
name: arith-lazy-5-str-n
description: Check lazy evaluation with side effects
stdin:
a=0 b=a++; ((0&&b)); echo $a
expected-stdout:
0
---
name: arith-lazy-5-str-p
description: Check lazy evaluation with side effects
stdin:
a=0 b=a++; ((0&&(b))); echo $a
expected-stdout:
0
---
name: arith-lazy-5-tern-l-n
description: Check lazy evaluation with side effects
stdin:
a=0; echo "$((0?b[a++]:999,a))"
expected-stdout:
0
---
name: arith-lazy-5-tern-l-p
description: Check lazy evaluation with side effects
stdin:
a=0; echo "$((0?(b[a++]):999,a))"
expected-stdout:
0
---
name: arith-lazy-5-tern-r-n
description: Check lazy evaluation with side effects
stdin:
a=0; echo "$((1?999:b[a++],a))"
expected-stdout:
0
---
name: arith-lazy-5-tern-r-p
description: Check lazy evaluation with side effects
stdin:
a=0; echo "$((1?999:(b[a++]),a))"
expected-stdout:
0
---
name: arith-ternary-prec-1
description:
Check precedence of ternary operator vs assignment
stdin:
typeset -i x=2
y=$((1 ? 20 : x+=2))
expected-exit: e != 0
expected-stderr-pattern:
/.*:.*1 \? 20 : x\+=2.*lvalue.*\n$/
---
name: arith-ternary-prec-2
description:
Check precedence of ternary operator vs assignment
stdin:
typeset -i x=2
echo $((0 ? x+=2 : 20))
expected-stdout:
20
---
name: arith-prec-1
description:
Prove arithmetic expressions with embedded parameter
substitutions cannot be parsed ahead of time
stdin:
a='3 + 4'
print 1 $((2 * a)) .
print 2 $((2 * $a)) .
expected-stdout:
1 14 .
2 10 .
---
name: arith-div-assoc-1
description:
Check associativity of division operator
stdin:
echo $((20 / 2 / 2))
expected-stdout:
5
---
name: arith-div-byzero
description:
Check division by zero errors out
stdin:
x=$(echo $((1 / 0)))
echo =$?:$x.
expected-stdout:
=1:.
expected-stderr-pattern:
/.*divisor/
---
name: arith-div-intmin-by-minusone
description:
Check division overflow wraps around silently
category: shell:legacy-no
stdin:
echo signed:$((-2147483648 / -1))r$((-2147483648 % -1)).
echo unsigned:$((# -2147483648 / -1))r$((# -2147483648 % -1)).
expected-stdout:
signed:-2147483648r0.
unsigned:0r2147483648.
---
name: arith-assop-assoc-1
description:
Check associativity of assignment-operator operator
stdin:
typeset -i i=1 j=2 k=3
echo $((i += j += k))
echo $i,$j,$k
expected-stdout:
6
6,5,3
---
name: arith-mandatory
description:
Passing of this test is *mandatory* for a valid mksh executable!
category: shell:legacy-no
stdin:
typeset -i sari=0
typeset -Ui uari=0
typeset -i x=0
print -r -- $((x++)):$sari=$uari. #0
let --sari --uari
print -r -- $((x++)):$sari=$uari. #1
sari=2147483647 uari=2147483647
print -r -- $((x++)):$sari=$uari. #2
let ++sari ++uari
print -r -- $((x++)):$sari=$uari. #3
let --sari --uari
let 'sari *= 2' 'uari *= 2'
let ++sari ++uari
print -r -- $((x++)):$sari=$uari. #4
let ++sari ++uari
print -r -- $((x++)):$sari=$uari. #5
sari=-2147483648 uari=-2147483648
print -r -- $((x++)):$sari=$uari. #6
let --sari --uari
print -r -- $((x++)):$sari=$uari. #7
(( sari = -5 >> 1 ))
((# uari = -5 >> 1 ))
print -r -- $((x++)):$sari=$uari. #8
(( sari = -2 ))
((# uari = sari ))
print -r -- $((x++)):$sari=$uari. #9
expected-stdout:
0:0=0.
1:-1=4294967295.
2:2147483647=2147483647.
3:-2147483648=2147483648.
4:-1=4294967295.
5:0=0.
6:-2147483648=2147483648.
7:2147483647=2147483647.
8:-3=2147483645.
9:-2=4294967294.
---
name: arith-unsigned-1
description:
Check if unsigned arithmetics work
category: int:32
stdin:
# signed vs unsigned
echo x1 $((-1)) $((#-1))
# calculating
typeset -i vs
typeset -Ui vu
vs=4123456789; vu=4123456789
echo x2 $vs $vu
(( vs %= 2147483647 ))
(( vu %= 2147483647 ))
echo x3 $vs $vu
vs=4123456789; vu=4123456789
(( # vs %= 2147483647 ))
(( # vu %= 2147483647 ))
echo x4 $vs $vu
# make sure the calculation does not change unsigned flag
vs=4123456789; vu=4123456789
echo x5 $vs $vu
# short form
echo x6 $((# vs % 2147483647)) $((# vu % 2147483647))
# array refs
set -A va
va[1975973142]=right
va[4123456789]=wrong
echo x7 ${va[#4123456789%2147483647]}
# make sure multiple calculations don't interfere with each other
let '# mca = -4 % -2' ' mcb = -4 % -2'
echo x8 $mca $mcb
expected-stdout:
x1 -1 4294967295
x2 -171510507 4123456789
x3 -171510507 4123456789
x4 1975973142 1975973142
x5 -171510507 4123456789
x6 1975973142 1975973142
x7 right
x8 -4 0
---
name: arith-limit32-1
description:
Check if arithmetics are 32 bit
category: int:32
stdin:
# signed vs unsigned
echo x1 $((-1)) $((#-1))
# calculating
typeset -i vs
typeset -Ui vu
vs=2147483647; vu=2147483647
echo x2 $vs $vu
let vs++ vu++
echo x3 $vs $vu
vs=4294967295; vu=4294967295
echo x4 $vs $vu
let vs++ vu++
echo x5 $vs $vu
let vs++ vu++
echo x6 $vs $vu
expected-stdout:
x1 -1 4294967295
x2 2147483647 2147483647
x3 -2147483648 2147483648
x4 -1 4294967295
x5 0 0
x6 1 1
---
name: arith-limit64-1
description:
Check if arithmetics are 64 bit
category: int:64
stdin:
# signed vs unsigned
echo x1 $((-1)) $((#-1))
# calculating
typeset -i vs
typeset -Ui vu
vs=9223372036854775807; vu=9223372036854775807
echo x2 $vs $vu
let vs++ vu++
echo x3 $vs $vu
vs=18446744073709551615; vu=18446744073709551615
echo x4 $vs $vu
let vs++ vu++
echo x5 $vs $vu
let vs++ vu++
echo x6 $vs $vu
expected-stdout:
x1 -1 18446744073709551615
x2 9223372036854775807 9223372036854775807
x3 -9223372036854775808 9223372036854775808
x4 -1 18446744073709551615
x5 0 0
x6 1 1
---
name: bksl-nl-ign-1
description:
Check that \newline is not collapsed after #
stdin:
echo hi #there \
echo folks
expected-stdout:
hi
folks
---
name: bksl-nl-ign-2
description:
Check that \newline is not collapsed inside single quotes
stdin:
echo 'hi \
there'
echo folks
expected-stdout:
hi \
there
folks
---
name: bksl-nl-ign-3
description:
Check that \newline is not collapsed inside single quotes
stdin:
cat << \EOF
hi \
there
EOF
expected-stdout:
hi \
there
---
name: bksl-nl-ign-4
description:
Check interaction of aliases, single quotes and here-documents
with backslash-newline
(don't know what POSIX has to say about this)
stdin:
a=2
alias x='echo hi
cat << "EOF"
foo\
bar
some'
x
more\
stuff$a
EOF
expected-stdout:
hi
foo\
bar
some
more\
stuff$a
---
name: bksl-nl-ign-5
description:
Check what happens with backslash at end of input
(the old Bourne shell trashes them; so do we)
stdin: !
echo `echo foo\\`bar
echo hi\
expected-stdout:
foobar
hi
---
#
# Places \newline should be collapsed
#
name: bksl-nl-1
description:
Check that \newline is collapsed before, in the middle of, and
after words
stdin:
\
echo hi\
There, \
folks
expected-stdout:
hiThere, folks
---
name: bksl-nl-2
description:
Check that \newline is collapsed in $ sequences
(ksh93 fails this)
stdin:
a=12
ab=19
echo $\
a
echo $a\
b
echo $\
{a}
echo ${a\
b}
echo ${ab\
}
expected-stdout:
12
19
12
19
19
---
name: bksl-nl-3
description:
Check that \newline is collapsed in $(..) and `...` sequences
(ksh93 fails this)
stdin:
echo $\
(echo foobar1)
echo $(\
echo foobar2)
echo $(echo foo\
bar3)
echo $(echo foobar4\
)
echo `
echo stuff1`
echo `echo st\
uff2`
expected-stdout:
foobar1
foobar2
foobar3
foobar4
stuff1
stuff2
---
name: bksl-nl-4
description:
Check that \newline is collapsed in $((..)) sequences
(ksh93 fails this)
stdin:
echo $\
((1+2))
echo $(\
(1+2+3))
echo $((\
1+2+3+4))
echo $((1+\
2+3+4+5))
echo $((1+2+3+4+5+6)\
)
expected-stdout:
3
6
10
15
21
---
name: bksl-nl-5
description:
Check that \newline is collapsed in double quoted strings
stdin:
echo "\
hi"
echo "foo\
bar"
echo "folks\
"
expected-stdout:
hi
foobar
folks
---
name: bksl-nl-6
description:
Check that \newline is collapsed in here document delimiters
(ksh93 fails second part of this)
stdin:
a=12
cat << EO\
F
a=$a
foo\
bar
EOF
cat << E_O_F
foo
E_O_\
F
echo done
expected-stdout:
a=12
foobar
foo
done
---
name: bksl-nl-7
description:
Check that \newline is collapsed in double-quoted here-document
delimiter.
stdin:
a=12
cat << "EO\
F"
a=$a
foo\
bar
EOF
echo done
expected-stdout:
a=$a
foo\
bar
done