cc-test.sh, nail.1: add simple test for -e, -H and -L; improve doc
[s-mailx.git] / cc-test.sh
blob186fea002791f1fa6239c4b28d429357a5d02318
1 #!/bin/mksh -
2 #@ Usage: ./cc-test.sh [--check-only [s-nail-binary]]
4 ARGS='-:/ -# -Sdotlock-ignore-error -Sencoding=quoted-printable -Sstealthmua'
5 ARGS="${ARGS}"' -Snosave -Sexpandaddr=restrict'
6 ARGS="${ARGS}"' -Slog-prefix=classico:'
7 CONF=./make.rc
8 BODY=./.cc-body.txt
9 MBOX=./.cc-test.mbox
10 MAIL=/dev/null
11 #UTF8_LOCALE= autodetected unless set
13 if ( command -v command ) >/dev/null 2>&1; then :; else
14 command() {
15 shift
16 which "${@}"
20 MAKE="${MAKE:-`command -v make`}"
21 awk=${awk:-`command -v awk`}
22 cat=${cat:-`command -v cat`}
23 cksum=${cksum:-`command -v cksum`}
24 rm=${rm:-`command -v rm`}
25 sed=${sed:-`command -v sed`}
26 grep=${grep:-`command -v grep`}
28 ## -- >8 -- 8< -- ##
30 export SNAIL ARGS CONF BODY MBOX MAIL MAKE awk cat cksum rm sed grep
32 LC_ALL=C LANG=C ADDARG_UNI=-Sttycharset=UTF-8
33 TZ=UTC
34 # Wed Oct 2 01:50:07 UTC 1996
35 SOURCE_DATE_EPOCH=844221007
37 export LC_ALL LANG ADDARG_UNI TZ SOURCE_DATE_EPOCH
38 unset POSIXLY_CORRECT
40 # Problem: force $SHELL to be a real shell. It seems some testing environments
41 # use nologin(?), but we need a real shell for command execution
42 if { echo ${SHELL} | ${grep} nologin; } >/dev/null 2>&1; then
43 echo >&2 '$SHELL seems to be nologin, overwriting to /bin/sh!'
44 SHELL=/bin/sh
45 export SHELL
48 if [ -z "${UTF8_LOCALE}" ]; then
49 UTF8_LOCALE=
50 if command -v locale >/dev/null 2>&1; then
51 UTF8_LOCALE=`locale -a | { m=
52 while read n; do
53 if { echo ${n} | ${grep} -i 'utf-\{0,1\}8'; } >/dev/null 2>&1; then
54 m=${n}
55 if { echo ${n} | ${grep} -e POSIX -e en_EN -e en_US; }; then
56 exit 0
59 m=${n}
60 done
61 echo ${m}
66 ESTAT=0
68 usage() {
69 echo >&2 "Usage: ./cc-test.sh [--check-only [s-nail-binary]]"
70 exit 1
73 CHECK_ONLY=
74 [ ${#} -gt 0 ] && {
75 [ "${1}" = --check-only ] || usage
76 [ ${#} -gt 2 ] && usage
77 [ ${#} -eq 2 ] && SNAIL="${2}"
78 [ -x "${SNAIL}" ] || usage
79 CHECK_ONLY=1
82 TRAP_EXIT_ADDONS=
83 trap "${rm} -rf \"${BODY}\" \"${MBOX}\" \${TRAP_EXIT_ADDONS}" EXIT
84 trap "exit 1" HUP INT TERM
86 # cc_all_configs()
87 # Test all configs TODO doesn't cover all *combinations*, stupid!
88 cc_all_configs() {
89 < ${CONF} ${awk} '
90 BEGIN {
91 NOTME["OPT_AUTOCC"] = 1
92 NOTME["OPT_DEBUG"] = 1
93 NOTME["OPT_DEVEL"] = 1
94 NOTME["OPT_NOEXTMD5"] = 1
95 NOTME["OPT_NOMEMDBG"] = 1
96 NOTME["OPT_NYD2"] = 1
97 i = 0
99 /^[[:space:]]*OPT_/ {
100 sub(/^[[:space:]]*/, "")
101 # This bails for UnixWare 7.1.4 awk(1), but preceeding = with \
102 # does not seem to be a compliant escape for =
103 #sub(/=.*$/, "")
104 $1 = substr($1, 1, index($1, "=") - 1)
105 if (NOTME[$1])
106 next
107 data[i++] = $1
109 END {
110 # Doing this completely sequentially and not doing make distclean in
111 # between runs should effectively result in lesser compilations.
112 # It is completely dumb nonetheless... TODO
113 for (j = 1; j < i; ++j) {
114 for (k = 1; k < j; ++k)
115 printf data[k] "=1 "
116 for (k = j; k < i; ++k)
117 printf data[k] "=0 "
118 printf "OPT_AUTOCC=1\n"
120 for (j = 1; j < i; ++j) {
121 for (k = 1; k < j; ++k)
122 printf data[k] "=0 "
123 for (k = j; k < i; ++k)
124 printf data[k] "=1 "
125 printf "OPT_AUTOCC=1\n"
127 # With debug
128 for (j = 1; j < i; ++j) {
129 for (k = 1; k < j; ++k)
130 printf data[k] "=1 "
131 for (k = j; k < i; ++k)
132 printf data[k] "=0 "
133 printf "OPT_AUTOCC=1\n"
134 printf "OPT_DEBUG=1\n"
136 for (j = 1; j < i; ++j) {
137 for (k = 1; k < j; ++k)
138 printf data[k] "=0 "
139 for (k = j; k < i; ++k)
140 printf data[k] "=1 "
141 printf "OPT_AUTOCC=1\n"
142 printf "OPT_DEBUG=1\n"
145 printf "CONFIG=NULL OPT_AUTOCC=0\n"
146 printf "CONFIG=NULL OPT_AUTOCC=1\n"
147 printf "CONFIG=NULLI OPT_AUTOCC=0\n"
148 printf "CONFIG=NULLI OPT_AUTOCC=1\n"
149 printf "CONFIG=MINIMAL OPT_AUTOCC=0\n"
150 printf "CONFIG=MINIMAL OPT_AUTOCC=1\n"
151 printf "CONFIG=MEDIUM OPT_AUTOCC=0\n"
152 printf "CONFIG=MEDIUM OPT_AUTOCC=1\n"
153 printf "CONFIG=NETSEND OPT_AUTOCC=0\n"
154 printf "CONFIG=NETSEND OPT_AUTOCC=1\n"
155 printf "CONFIG=MAXIMAL OPT_AUTOCC=0\n"
156 printf "CONFIG=MAXIMAL OPT_AUTOCC=1\n"
157 printf "CONFIG=DEVEL OPT_AUTOCC=0\n"
158 printf "CONFIG=DEVEL OPT_AUTOCC=1\n"
159 printf "CONFIG=ODEVEL OPT_AUTOCC=0\n"
160 printf "CONFIG=ODEVEL OPT_AUTOCC=1\n"
162 ' | while read c; do
163 printf "\n\n##########\n$c\n"
164 printf "\n\n##########\n$c\n" >&2
165 sh -c "${MAKE} ${c}"
166 t_all
167 done
168 ${MAKE} distclean
171 # cksum_test()
172 # Read mailbox $2, strip non-constant headers and MIME boundaries, query the
173 # cksum(1) of the resulting data and compare against the checksum $3
174 cksum_test() {
175 tid=${1} f=${2} s=${3}
176 printf "${tid}: "
177 csum="`${sed} -e '/^From /d' \
178 -e '/^ boundary=/d' -e '/^--=-=/d' < \"${f}\" \
179 -e '/^\[-- Message/d' | ${cksum}`";
180 if [ "${csum}" = "${s}" ]; then
181 printf 'ok\n'
182 else
183 ESTAT=1
184 printf 'error: checksum mismatch (got %s)\n' "${csum}"
188 have_feat() {
189 ( "${SNAIL}" ${ARGS} -X'echo $features' -Xx | ${grep} +${1} ) >/dev/null 2>&1
192 # t_behave()
193 # Basic (easily testable) behaviour tests
194 t_behave() {
195 t_behave_X_opt_input_command_stack
196 t_behave_wysh
197 t_behave_input_inject_semicolon_seq
198 t_behave_commandalias
199 t_behave_ifelse
200 t_behave_localopts
201 t_behave_macro_param_shift
202 t_behave_addrcodec
203 t_behave_vexpr
204 t_behave_xcall
206 # FIXME t_behave_alias
208 # FIXME t_behave_mlist
210 have_feat smime && t_behave_smime
212 t_behave_e_H_L_opts
213 t_behave_compose_hooks
216 t_behave_X_opt_input_command_stack() {
217 ${cat} <<- '__EOT' > "${BODY}"
218 echo 1
219 define mac0 {
220 echo mac0-1 via1 $0
222 call mac0
223 echo 2
224 source '\
225 echo "define mac1 {";\
226 echo " echo mac1-1 via1 \$0";\
227 echo " call mac0";\
228 echo " echo mac1-2";\
229 echo " call mac2";\
230 echo " echo mac1-3";\
231 echo "}";\
232 echo "echo 1-1";\
233 echo "define mac2 {";\
234 echo " echo mac2-1 via1 \$0";\
235 echo " call mac0";\
236 echo " echo mac2-2";\
237 echo "}";\
238 echo "echo 1-2";\
239 echo "call mac1";\
240 echo "echo 1-3";\
241 echo "source \"\
242 echo echo 1-1-1 via1 \$0;\
243 echo call mac0;\
244 echo echo 1-1-2;\
245 | \"";\
246 echo "echo 1-4";\
248 echo 3
249 call mac2
250 echo 4
251 undefine *
252 __EOT
254 # The -X option supports multiline arguments, and those can internally use
255 # reverse solidus newline escaping. And all -X options are joined...
256 APO=\'
257 < "${BODY}" "${SNAIL}" ${ARGS} \
258 -X 'e\' \
259 -X ' c\' \
260 -X ' h\' \
261 -X ' o \' \
262 -X 1 \
264 define mac0 {
265 echo mac0-1 via2 $0
267 call mac0
268 echo 2
271 source '${APO}'\
272 echo "define mac1 {";\
273 echo " echo mac1-1 via2 \$0";\
274 echo " call mac0";\
275 echo " echo mac1-2";\
276 echo " call mac2";\
277 echo " echo mac1-3";\
278 echo "}";\
279 echo "echo 1-1";\
280 echo "define mac2 {";\
281 echo " echo mac2-1 via2 \$0";\
282 echo " call mac0";\
283 echo " echo mac2-2";\
284 echo "}";\
285 echo "echo 1-2";\
286 echo "call mac1";\
287 echo "echo 1-3";\
288 echo "source \"\
289 echo echo 1-1-1 via2 \$0;\
290 echo call mac0;\
291 echo echo 1-1-2;\
292 | \"";\
293 echo "echo 1-4";\
294 | '${APO}'
295 echo 3
298 call mac2
299 echo 4
300 undefine *
301 ' > "${MBOX}" 2>/dev/null
303 #mac0-1 via2
305 #1-1
306 #1-2
307 #mac1-1 via2
308 #mac0-1 via2 mac1
309 #mac1-2
310 #mac2-1 via2 mac1
311 #mac0-1 via2 mac2
312 #mac2-2
313 #mac1-3
314 #1-3
315 #1-1-1 via2
316 #mac0-1 via2
317 #1-1-2
318 #1-4
320 #mac2-1 via2
321 #mac0-1 via2 mac2
322 #mac2-2
325 #mac0-1 via1
327 #1-1
328 #1-2
329 #mac1-1 via1
330 #mac0-1 via1 mac1
331 #mac1-2
332 #mac2-1 via1 mac1
333 #mac0-1 via1 mac2
334 #mac2-2
335 #mac1-3
336 #1-3
337 #1-1-1 via1
338 #mac0-1 via1
339 #1-1-2
340 #1-4
342 #mac2-1 via1
343 #mac0-1 via1 mac2
344 #mac2-2
346 cksum_test behave:x_opt_input_command_stack "${MBOX}" '1391275936 378'
349 t_behave_xcall() {
350 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} -Snomemdebug > "${MBOX}" 2>&1
351 define work {
352 echon "$1 "
353 vput vexpr i + $1 1
354 if [ $i -le 1111 ]
355 vput vexpr j '&' $i 7
356 if [ $j -eq 7 ]
357 echo .
359 \xcall work $i
361 echo ! The end for $1
363 define xwork {
364 \xcall work 0
366 call work 0
367 echo ?=$?
368 call xwork
369 echo ?=$?
370 xcall xwork
371 echo ?=$?
372 __EOT
373 cksum_test behave:xcall "${MBOX}" '3660556233 9556'
376 t_behave_wysh() {
377 ${cat} <<- '__EOT' > "${BODY}"
379 echo abcd
380 echo a'b'c'd'
381 echo a"b"c"d"
382 echo a$'b'c$'d'
383 echo 'abcd'
384 echo "abcd"
385 echo $'abcd'
386 echo a\ b\ c\ d
387 echo a 'b c' d
388 echo a "b c" d
389 echo a $'b c' d
391 echo 'a$`"\'
392 echo "a\$\`'\"\\"
393 echo $'a\$`\'\"\\'
394 echo $'a\$`\'"\\'
395 # DIET=CURD TIED=
396 echo 'a${DIET}b${TIED}c\${DIET}d\${TIED}e' # COMMENT
397 echo "a${DIET}b${TIED}c\${DIET}d\${TIED}e"
398 echo $'a${DIET}b${TIED}c\${DIET}d\${TIED}e'
400 echo a$'\101\0101\x41\u0041\u41\U00000041\U41'c
401 echo a$'\u0041\u41\u0C1\U00000041\U41'c
402 echo a$'\377'c
403 echo a$'\0377'c
404 echo a$'\400'c
405 echo a$'\0400'c
406 echo a$'\U1100001'c
408 echo a$'b\0c'd
409 echo a$'b\00c'de
410 echo a$'b\000c'df
411 echo a$'b\0000c'dg
412 echo a$'b\x0c'dh
413 echo a$'b\x00c'di
414 echo a$'b\u0'dj
415 echo a$'b\u00'dk
416 echo a$'b\u000'dl
417 echo a$'b\u0000'dm
418 echo a$'b\U0'dn
419 echo a$'b\U00'do
420 echo a$'b\U000'dp
421 echo a$'b\U0000'dq
422 echo a$'b\U00000'dr
423 echo a$'b\U000000'ds
424 echo a$'b\U0000000'dt
425 echo a$'b\U00000000'du
427 echo a$'\cI'b
428 echo a$'\011'b
429 echo a$'\x9'b
430 echo a$'\u9'b
431 echo a$'\U9'b
432 echo a$'\c@'b c d
433 __EOT
435 if [ -z "${UTF8_LOCALE}" ]; then
436 echo 'Skip behave:wysh_unicode, no UTF8_LOCALE'
437 else
438 < "${BODY}" DIET=CURD TIED= \
439 LC_ALL=${UTF8_LOCALE} "${SNAIL}" ${ARGS} 2>/dev/null > "${MBOX}"
440 #abcd
441 #abcd
442 #abcd
443 #abcd
444 #abcd
445 #abcd
446 #abcd
447 #a b c d
448 #a b c d
449 #a b c d
450 #a b c d
451 #a$`"\
452 #a$`'"\
453 #a$`'"\
454 #a$`'"\
455 #a${DIET}b${TIED}c\${DIET}d\${TIED}e
456 #aCURDbc${DIET}d${TIED}e
457 #a${DIET}b${TIED}cCURDde
458 #aAAAAAAAc
459 #aAAÁAAc
460 #aÿc
461 #aÿc
462 #abd
463 #abde
464 #abdf
465 #abdg
466 #ab\fdh
467 #abdi
468 #abdj
469 #abdk
470 #abdl
471 #abdm
472 #abdn
473 #abdo
474 #abdp
475 #abdq
476 #abdr
477 #abds
478 #abdt
479 #abdu
480 #a b
481 #a b
482 #a b
483 #a b
484 #a b
486 cksum_test behave:wysh_unicode "${MBOX}" '475805847 317'
489 < "${BODY}" DIET=CURD TIED= "${SNAIL}" ${ARGS} > "${MBOX}" 2>/dev/null
490 #abcd
491 #abcd
492 #abcd
493 #abcd
494 #abcd
495 #abcd
496 #abcd
497 #a b c d
498 #a b c d
499 #a b c d
500 #a b c d
501 #a$`"\
502 #a$`'"\
503 #a$`'"\
504 #a$`'"\
505 #a${DIET}b${TIED}c\${DIET}d\${TIED}e
506 #aCURDbc${DIET}d${TIED}e
507 #a${DIET}b${TIED}cCURDde
508 #aAAAAAAAc
509 #aAA\u0C1AAc
510 #aÿc
511 #aÿc
512 #abd
513 #abde
514 #abdf
515 #abdg
516 #ab\fdh
517 #abdi
518 #abdj
519 #abdk
520 #abdl
521 #abdm
522 #abdn
523 #abdo
524 #abdp
525 #abdq
526 #abdr
527 #abds
528 #abdt
529 #abdu
530 #a b
531 #a b
532 #a b
533 #a b
534 #a b
536 cksum_test behave:wysh_c "${MBOX}" '1473887148 321'
539 t_behave_input_inject_semicolon_seq() {
540 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}"
541 define mydeepmac {
542 echon '(mydeepmac)';
544 define mymac {
545 echon this_is_mymac;call mydeepmac;echon ';';
547 echon one';';~mymac;echon two";";call mymac;echo three$';';
548 define mymac {
549 echon this_is_mymac;call mydeepmac;echon ,TOO'!;';
551 echon one';';~mymac;echon two";";call mymac;echo three$';';
552 __EOT
553 #one;this_is_mymac(mydeepmac);two;this_is_mymac(mydeepmac);three;
554 #one;this_is_mymac(mydeepmac),TOO!;two;this_is_mymac(mydeepmac),TOO!;three;
555 cksum_test behave:input_inject_semicolon_seq "${MBOX}" '512117110 140'
558 t_behave_commandalias() {
559 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}"
560 commandalias echo echo hoho
561 echo stop.
562 commandalias X Xx
563 commandalias Xx XxX
564 commandalias XxX XxXx
565 commandalias XxXx XxXxX
566 commandalias XxXxX XxXxXx
567 commandalias XxXxXx echo huhu
568 commandalias XxXxXxX echo huhu
570 commandalias XxXxXx XxXxXxX
572 uncommandalias echo
573 commandalias XxXxXx echo huhu
575 __EOT
576 #hoho stop.
577 #hoho huhu
578 #huhu
579 #huhu
580 cksum_test behave:commandalias "${MBOX}" '3694143612 31'
583 t_behave_ifelse() {
584 # Nestable conditions test
585 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}"
586 if 0
587 echo 1.err
588 else
589 echo 1.ok
590 endif
591 if 1
592 echo 2.ok
593 else
594 echo 2.err
595 endif
596 if $dietcurd
597 echo 3.err
598 else
599 echo 3.ok
600 endif
601 set dietcurd=yoho
602 if $dietcurd
603 echo 4.ok
604 else
605 echo 4.err
606 endif
607 if $dietcurd == 'yoho'
608 echo 5.ok
609 else
610 echo 5.err
611 endif
612 if $dietcurd != 'yoho'
613 echo 6.err
614 else
615 echo 6.ok
616 endif
617 # Nesting
618 if faLse
619 echo 7.err1
620 if tRue
621 echo 7.err2
622 if yEs
623 echo 7.err3
624 else
625 echo 7.err4
626 endif
627 echo 7.err5
628 endif
629 echo 7.err6
630 else
631 echo 7.ok7
632 if YeS
633 echo 7.ok8
634 if No
635 echo 7.err9
636 else
637 echo 7.ok9
638 endif
639 echo 7.ok10
640 else
641 echo 7.err11
642 if yeS
643 echo 7.err12
644 else
645 echo 7.err13
646 endif
647 endif
648 echo 7.ok14
649 endif
650 if r
651 echo 8.ok1
652 if R
653 echo 8.ok2
654 else
655 echo 8.err2
656 endif
657 echo 8.ok3
658 else
659 echo 8.err1
660 endif
661 if s
662 echo 9.err1
663 else
664 echo 9.ok1
665 if S
666 echo 9.err2
667 else
668 echo 9.ok2
669 endif
670 echo 9.ok3
671 endif
672 # `elif'
673 if $dietcurd == 'yohu'
674 echo 10.err1
675 elif $dietcurd == 'yoha'
676 echo 10.err2
677 elif $dietcurd == 'yohe'
678 echo 10.err3
679 elif $dietcurd == 'yoho'
680 echo 10.ok1
681 if $dietcurd == 'yohu'
682 echo 10.err4
683 elif $dietcurd == 'yoha'
684 echo 10.err5
685 elif $dietcurd == 'yohe'
686 echo 10.err6
687 elif $dietcurd == 'yoho'
688 echo 10.ok2
689 if $dietcurd == 'yohu'
690 echo 10.err7
691 elif $dietcurd == 'yoha'
692 echo 10.err8
693 elif $dietcurd == 'yohe'
694 echo 10.err9
695 elif $dietcurd == 'yoho'
696 echo 10.ok3
697 else
698 echo 10.err10
699 endif
700 else
701 echo 10.err11
702 endif
703 else
704 echo 10.err12
705 endif
706 # integer conversion, <..>..
707 set dietcurd=10
708 if $dietcurd -lt 11
709 echo 11.ok1
710 if $dietcurd -gt 9
711 echo 11.ok2
712 else
713 echo 11.err2
714 endif
715 if $dietcurd -eq 10
716 echo 11.ok3
717 else
718 echo 11.err3
719 endif
720 if $dietcurd -ge 10
721 echo 11.ok4
722 else
723 echo 11.err4
724 endif
725 if $dietcurd -le 10
726 echo 11.ok5
727 else
728 echo 11.err5
729 endif
730 if $dietcurd -ge 11
731 echo 11.err6
732 else
733 echo 11.ok6
734 endif
735 if $dietcurd -le 9
736 echo 11.err7
737 else
738 echo 11.ok7
739 endif
740 else
741 echo 11.err1
742 endif
743 set dietcurd=Abc
744 if $dietcurd < aBd
745 echo 12.ok1
746 if $dietcurd > abB
747 echo 12.ok2
748 else
749 echo 12.err2
750 endif
751 if $dietcurd == aBC
752 echo 12.ok3
753 else
754 echo 12.err3
755 endif
756 if $dietcurd >= AbC
757 echo 12.ok4
758 else
759 echo 12.err4
760 endif
761 if $dietcurd <= ABc
762 echo 12.ok5
763 else
764 echo 12.err5
765 endif
766 if $dietcurd >= abd
767 echo 12.err6
768 else
769 echo 12.ok6
770 endif
771 if $dietcurd <= abb
772 echo 12.err7
773 else
774 echo 12.ok7
775 endif
776 else
777 echo 12.err1
778 endif
779 if $dietcurd =@ aB
780 echo 13.ok
781 else
782 echo 13.err
783 endif
784 if $dietcurd =@ bC
785 echo 14.ok
786 else
787 echo 14.err
788 endif
789 if $dietcurd !@ aB
790 echo 15.err
791 else
792 echo 15.ok
793 endif
794 if $dietcurd !@ bC
795 echo 15.err
796 else
797 echo 15.ok
798 endif
799 if $dietcurd =@ Cd
800 echo 16.err
801 else
802 echo 16.ok
803 endif
804 if $dietcurd !@ Cd
805 echo 17.ok
806 else
807 echo 17.err
808 endif
809 set diet=abc curd=abc
810 if $diet == $curd
811 echo 18.ok
812 else
813 echo 18.err
814 endif
815 set diet=abc curd=abcd
816 if $diet != $curd
817 echo 19.ok
818 else
819 echo 19.err
820 endif
821 # 1. Shitty grouping capabilities as of today
822 unset diet curd ndefined
823 if [ [ false ] || [ false ] || [ true ] ] && [ [ false ] || [ true ] ] && \
824 [ yes ]
825 echo 20.ok
826 else
827 echo 20.err
828 endif
829 if [ [ [ [ 0 ] || [ 1 ] ] && [ [ 1 ] || [ 0 ] ] ] && [ 1 ] ] && [ yes ]
830 echo 21.ok
831 else
832 echo 21.err
833 endif
834 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] ]
835 echo 22.ok
836 else
837 echo 22.err
838 endif
839 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] ]
840 echo 23.ok
841 else
842 echo 23.err
843 endif
844 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] && [ no ]
845 echo 24.err
846 else
847 echo 24.ok
848 endif
849 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] \
850 && [ no ] || [ yes ]
851 echo 25.ok
852 else
853 echo 25.err
854 endif
855 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
856 echo 26.ok
857 else
858 echo 26.err
859 endif
860 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 0 ] ]
861 echo 27.err
862 else
863 echo 27.ok
864 endif
865 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 0 ] ] && [ 1 ] ] ] && [ 1 ] ]
866 echo 28.err
867 else
868 echo 28.ok
869 endif
870 if [ [ [ [ [ [ [ 0 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
871 echo 29.err
872 else
873 echo 29.ok
874 endif
875 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 0 ]
876 echo 30.err
877 else
878 echo 30.ok
879 endif
880 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 1 ]
881 echo 31.ok
882 else
883 echo 31.err
884 endif
885 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ]
886 echo 32.err
887 else
888 echo 32.ok
889 endif
890 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 1 ]
891 echo 33.ok
892 else
893 echo 33.err
894 endif
895 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 0 ]
896 echo 34.err
897 else
898 echo 34.ok
899 endif
900 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 1 ]
901 echo 35.ok
902 else
903 echo 35.err
904 endif
905 set diet=yo curd=ho
906 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
907 echo 36.err
908 else
909 echo 36.ok
910 endif
911 set ndefined
912 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
913 echo 37.ok
914 else
915 echo 37.err
916 endif
917 # 2. Shitty grouping capabilities as of today
918 unset diet curd ndefined
919 if [ false || false || true ] && [ false || true ] && yes
920 echo 40.ok
921 else
922 echo 40.err
923 endif
924 if [ [ [ 0 || 1 ] && [ 1 || 0 ] ] && 1 ] && [ yes ]
925 echo 41.ok
926 else
927 echo 41.err
928 endif
929 if [ 1 || 0 || 0 || 0 ]
930 echo 42.ok
931 else
932 echo 42.err
933 endif
934 if [ 1 || 0 || 0 || 0 || [ 1 ] ]
935 echo 43.ok
936 else
937 echo 43.err
938 endif
939 if [ 1 || 0 || 0 || 0 || [ 1 ] || 1 ] && no
940 echo 44.err
941 else
942 echo 44.ok
943 endif
944 if [ 1 || 0 || 0 || 0 || 1 || [ 1 ] ] && no || [ yes ]
945 echo 45.ok
946 else
947 echo 45.err
948 endif
949 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && 1 ] ] && [ 1 ] ]
950 echo 46.ok
951 else
952 echo 46.err
953 endif
954 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && [ 1 ] ] ] && 0 ]
955 echo 47.err
956 else
957 echo 47.ok
958 endif
959 if [ [ [ [ [ [ [ 1 ] ] && 1 ] && 0 ] && [ 1 ] ] ] && 1 ]
960 echo 48.err
961 else
962 echo 48.ok
963 endif
964 if [ [ [ [ [ [ 0 ] && 1 ] && 1 ] && 1 ] ] && 1 ]
965 echo 49.err
966 else
967 echo 49.ok
968 endif
969 if 1 || 0 || 0 || 0 && 0
970 echo 50.err
971 else
972 echo 50.ok
973 endif
974 if 1 || 0 || 0 || 0 && 1
975 echo 51.ok
976 else
977 echo 51.err
978 endif
979 if 0 || 0 || 0 || 1 && 0
980 echo 52.err
981 else
982 echo 52.ok
983 endif
984 if 0 || 0 || 0 || 1 && 1
985 echo 53.ok
986 else
987 echo 53.err
988 endif
989 if 0 || 0 || 0 || 1 && 0 || 1 && 0
990 echo 54.err
991 else
992 echo 54.ok
993 endif
994 if 0 || 0 || 0 || 1 && 0 || 1 && 1
995 echo 55.ok
996 else
997 echo 55.err
998 endif
999 set diet=yo curd=ho
1000 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
1001 echo 56.err
1002 else
1003 echo 56.ok
1004 endif
1005 if $diet == 'yo' && $curd == 'ho' && $ndefined
1006 echo 57.err
1007 else
1008 echo 57.ok
1009 endif
1010 set ndefined
1011 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
1012 echo 57.ok
1013 else
1014 echo 57.err
1015 endif
1016 if $diet == 'yo' && $curd == 'ho' && $ndefined
1017 echo 58.ok
1018 else
1019 echo 58.err
1020 endif
1021 if [ [ [ [ [ [ $diet == 'yo' && $curd == 'ho' && $ndefined ] ] ] ] ] ]
1022 echo 59.ok
1023 else
1024 echo 59.err
1025 endif
1026 # Some more en-braced variables
1027 set diet=yo curd=ho
1028 if ${diet} == ${curd}
1029 echo 70.err
1030 else
1031 echo 70.ok
1032 endif
1033 if ${diet} != ${curd}
1034 echo 71.ok
1035 else
1036 echo 71.err
1037 endif
1038 if $diet == ${curd}
1039 echo 72.err
1040 else
1041 echo 72.ok
1042 endif
1043 if ${diet} == $curd
1044 echo 73.err
1045 else
1046 echo 73.ok
1047 endif
1048 # Unary !
1049 if ! 0 && ! ! 1 && ! ! ! ! 2 && 3
1050 echo 80.ok
1051 else
1052 echo 80.err
1053 endif
1054 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ ! 2 ] ] ] && 3
1055 echo 81.ok
1056 else
1057 echo 81.err
1058 endif
1059 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1060 echo 82.ok
1061 else
1062 echo 82.err
1063 endif
1064 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
1065 echo 83.err
1066 else
1067 echo 83.ok
1068 endif
1069 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
1070 echo 84.err
1071 else
1072 echo 84.ok
1073 endif
1074 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1075 echo 85.err
1076 else
1077 echo 85.ok
1078 endif
1079 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1080 echo 86.err
1081 else
1082 echo 86.ok
1083 endif
1084 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] || 3
1085 echo 87.ok
1086 else
1087 echo 87.err
1088 endif
1089 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! ! [ 2 ] ] ] ] ]
1090 echo 88.ok
1091 else
1092 echo 88.err
1093 endif
1094 # Unary !, odd
1095 if ! 0 && ! ! 1 && ! ! ! 0 && 3
1096 echo 90.ok
1097 else
1098 echo 90.err
1099 endif
1100 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ 0 ] ] ] && 3
1101 echo 91.ok
1102 else
1103 echo 91.err
1104 endif
1105 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ [ 0 ] ] ] ] ] && 3
1106 echo 92.ok
1107 else
1108 echo 92.err
1109 endif
1110 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! ! [ ! [ ! 0 ] ] ] ] && ! 3
1111 echo 93.err
1112 else
1113 echo 93.ok
1114 endif
1115 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ ! [ ! [ ! [ ! 0 ] ] ] ] && 3
1116 echo 94.ok
1117 else
1118 echo 94.err
1119 endif
1120 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! ! [ ! [ ! [ ! [ 0 ] ] ] ] ] && 3
1121 echo 95.err
1122 else
1123 echo 95.ok
1124 endif
1125 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! ! 0 ] ] ] ] && 3
1126 echo 96.err
1127 else
1128 echo 96.ok
1129 endif
1130 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ ! 0 ] ] ] ] ] || 3
1131 echo 97.ok
1132 else
1133 echo 97.err
1134 endif
1135 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! [ 0 ] ] ] ] ]
1136 echo 98.ok
1137 else
1138 echo 98.err
1139 endif
1140 __EOT
1141 cksum_test behave:if-normal "${MBOX}" '557629289 631'
1143 if have_feat regex; then
1144 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}"
1145 set dietcurd=yoho
1146 if $dietcurd =~ '^yo.*'
1147 echo 1.ok
1148 else
1149 echo 1.err
1150 endif
1151 if $dietcurd =~ '^yoho.+'
1152 echo 2.err
1153 else
1154 echo 2.ok
1155 endif
1156 if $dietcurd !~ '.*ho$'
1157 echo 3.err
1158 else
1159 echo 3.ok
1160 endif
1161 if $dietcurd !~ '.+yoho$'
1162 echo 4.ok
1163 else
1164 echo 4.err
1165 endif
1166 if [ $dietcurd !~ '.+yoho$' ]
1167 echo 5.ok
1168 else
1169 echo 5.err
1170 endif
1171 if ! [ $dietcurd =~ '.+yoho$' ]
1172 echo 6.ok
1173 else
1174 echo 6.err
1175 endif
1176 if ! ! [ $dietcurd !~ '.+yoho$' ]
1177 echo 7.ok
1178 else
1179 echo 7.err
1180 endif
1181 if ! [ ! [ $dietcurd !~ '.+yoho$' ] ]
1182 echo 8.ok
1183 else
1184 echo 8.err
1185 endif
1186 if [ ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
1187 echo 9.ok
1188 else
1189 echo 9.err
1190 endif
1191 if ! [ ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
1192 echo 10.err
1193 else
1194 echo 10.ok
1195 endif
1196 if ! ! ! $dietcurd !~ '.+yoho$'
1197 echo 11.err
1198 else
1199 echo 11.ok
1200 endif
1201 if ! ! ! $dietcurd =~ '.+yoho$'
1202 echo 12.ok
1203 else
1204 echo 12.err
1205 endif
1206 if ! [ ! ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
1207 echo 13.ok
1208 else
1209 echo 13.err
1210 endif
1211 set diet=abc curd='^abc$'
1212 if $diet =~ $curd
1213 echo 14.ok
1214 else
1215 echo 14.err
1216 endif
1217 set diet=abc curd='^abcd$'
1218 if $diet !~ $curd
1219 echo 15.ok
1220 else
1221 echo 15.err
1222 endif
1223 __EOT
1224 cksum_test behave:if-regex "${MBOX}" '439960016 81'
1228 t_behave_localopts() {
1229 # Nestable conditions test
1230 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}"
1231 define t2 {
1232 echo in: t2
1233 set t2=t2
1234 echo $t2
1236 define t1 {
1237 echo in: t1
1238 set gv1=gv1
1239 localopts on
1240 set lv1=lv1 lv2=lv2
1241 set lv3=lv3
1242 call t2
1243 localopts off
1244 set gv2=gv2
1245 echo $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2
1247 define t0 {
1248 echo in: t0
1249 call t1
1250 echo $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2
1251 echo "$gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2"
1253 account trouble {
1254 echo in: trouble
1255 call t0
1257 call t0
1258 unset gv1 gv2
1259 account trouble
1260 echo active trouble: $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t3
1261 account null
1262 echo active null: $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t3
1263 __EOT
1264 #in: t0
1265 #in: t1
1266 #in: t2
1268 #gv1 lv1 lv2 lv3 gv2, t2
1269 #gv1 gv2,
1270 #gv1 gv2,
1271 #in: trouble
1272 #in: t0
1273 #in: t1
1274 #in: t2
1276 #gv1 lv1 lv2 lv3 gv2, t2
1277 #gv1 gv2,
1278 #gv1 gv2,
1279 #active trouble: gv1 gv2,
1280 #active null: ,
1281 cksum_test behave:localopts "${MBOX}" '1936527193 192'
1284 t_behave_macro_param_shift() {
1285 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}" 2>/dev/null
1286 define t2 {
1287 echo in: t2
1288 echo t2.0 has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1289 localopts on
1290 wysh set ignerr=$1
1291 shift
1292 localopts off
1293 echo t2.1 has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1294 if [ $# > 1 ] || [ $ignerr == '' ]
1295 shift 2
1296 else
1297 ignerr shift 2
1298 endif
1299 echo t2.2:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1300 shift 0
1301 echo t2.3:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1302 if [ $# > 0 ]
1303 shift
1304 endif
1305 echo t2.4:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1307 define t1 {
1308 set errexit
1309 echo in: t1
1310 call t2 1 you get four args
1311 echo t1.1: $?';' ignerr ($ignerr) should not exist
1312 call t2 1 you get 'three args'
1313 echo t1.2: $?';' ignerr ($ignerr) should not exist
1314 call t2 1 you 'get two args'
1315 echo t1.3: $?';' ignerr ($ignerr) should not exist
1316 call t2 1 'you get one arg'
1317 echo t1.4: $?';' ignerr ($ignerr) should not exist
1318 ignerr call t2 '' 'you get one arg'
1319 echo t1.5: $?';' ignerr ($ignerr) should not exist
1321 call t1
1322 __EOT
1323 #in: t1
1324 #in: t2
1325 #t2.0 has 5/5 parameters: 1,you,get (1 you get four args) [1 you get four args]
1326 #t2.1 has 4/4 parameters: you,get,four (you get four args) [you get four args]
1327 #t2.2:0 has 2/2 parameters: four,args, (four args) [four args]
1328 #t2.3:0 has 2/2 parameters: four,args, (four args) [four args]
1329 #t2.4:0 has 1/1 parameters: args,, (args) [args]
1330 #t1.1: 0; ignerr () should not exist
1331 #in: t2
1332 #t2.0 has 4/4 parameters: 1,you,get (1 you get three args) [1 you get three args]
1333 #t2.1 has 3/3 parameters: you,get,three args (you get three args) [you get three args]
1334 #t2.2:0 has 1/1 parameters: three args,, (three args) [three args]
1335 #t2.3:0 has 1/1 parameters: three args,, (three args) [three args]
1336 #t2.4:0 has 0/0 parameters: ,, () []
1337 #t1.2: 0; ignerr () should not exist
1338 #in: t2
1339 #t2.0 has 3/3 parameters: 1,you,get two args (1 you get two args) [1 you get two args]
1340 #t2.1 has 2/2 parameters: you,get two args, (you get two args) [you get two args]
1341 #t2.2:0 has 0/0 parameters: ,, () []
1342 #t2.3:0 has 0/0 parameters: ,, () []
1343 #t2.4:0 has 0/0 parameters: ,, () []
1344 #t1.3: 0; ignerr () should not exist
1345 #in: t2
1346 #t2.0 has 2/2 parameters: 1,you get one arg, (1 you get one arg) [1 you get one arg]
1347 #t2.1 has 1/1 parameters: you get one arg,, (you get one arg) [you get one arg]
1348 #t2.2:0 has 1/1 parameters: you get one arg,, (you get one arg) [you get one arg]
1349 #t2.3:0 has 1/1 parameters: you get one arg,, (you get one arg) [you get one arg]
1350 #t2.4:0 has 0/0 parameters: ,, () []
1351 #t1.4: 0; ignerr () should not exist
1352 #in: t2
1353 #t2.0 has 2/2 parameters: ,you get one arg, ( you get one arg) [ you get one arg]
1354 #t2.1 has 1/1 parameters: you get one arg,, (you get one arg) [you get one arg]
1355 #t1.5: 1; ignerr () should not exist
1356 cksum_test behave:macro_param_shift "${MBOX}" '1402489146 1682'
1359 t_behave_addrcodec() {
1360 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}"
1361 vput addrcodec res e 1 <doog@def>
1362 echo $?/$^ERRNAME $res
1363 eval vput addrcodec res d $res
1364 echo $?/$^ERRNAME $res
1365 vput addrcodec res e 2 . <doog@def>
1366 echo $?/$^ERRNAME $res
1367 eval vput addrcodec res d $res
1368 echo $?/$^ERRNAME $res
1369 vput addrcodec res e 3 Sauer Dr. <doog@def>
1370 echo $?/$^ERRNAME $res
1371 eval vput addrcodec res d $res
1372 echo $?/$^ERRNAME $res
1373 vput addrcodec res e 3.50 Sauer (Ma) Dr. <doog@def>
1374 echo $?/$^ERRNAME $res
1375 eval vput addrcodec res d $res
1376 echo $?/$^ERRNAME $res
1377 vput addrcodec res e 3.51 Sauer (Ma) "Dr." <doog@def>
1378 echo $?/$^ERRNAME $res
1379 eval vput addrcodec res d $res
1380 echo $?/$^ERRNAME $res
1382 vput addrcodec res +e 4 Sauer (Ma) Dr. <doog@def>
1383 echo $?/$^ERRNAME $res
1384 eval vput addrcodec res d $res
1385 echo $?/$^ERRNAME $res
1386 vput addrcodec res +e 5 Sauer (Ma) Braten Dr. <doog@def>
1387 echo $?/$^ERRNAME $res
1388 eval vput addrcodec res d $res
1389 echo $?/$^ERRNAME $res
1390 vput addrcodec res +e 6 Sauer (Ma) Braten Dr. (Heu) <doog@def>
1391 echo $?/$^ERRNAME $res
1392 eval vput addrcodec res d $res
1393 echo $?/$^ERRNAME $res
1394 vput addrcodec res +e 7 Sauer (Ma) Braten Dr. (Heu) <doog@def> (bu)
1395 echo $?/$^ERRNAME $res
1396 eval vput addrcodec res d $res
1397 echo $?/$^ERRNAME $res
1398 vput addrcodec res +e 8 \
1399 Dr. Sauer (Ma) Braten Dr. (Heu) <doog@def> (bu) Boom. Boom
1400 echo $?/$^ERRNAME $res
1401 eval vput addrcodec res d $res
1402 echo $?/$^ERRNAME $res
1403 vput addrcodec res +e 9 Dr.Sauer(Ma)Braten Dr. (Heu) <doog@def>
1404 echo $?/$^ERRNAME $res
1405 eval vput addrcodec res d $res
1406 echo $?/$^ERRNAME $res
1407 vput addrcodec res +e 10 (Ma)Braten Dr. (Heu) <doog@def>
1408 echo $?/$^ERRNAME $res
1409 eval vput addrcodec res d $res
1410 echo $?/$^ERRNAME $res
1411 vput addrcodec res +e 11 (Ma)Braten Dr"." (Heu) <doog@def>
1412 echo $?/$^ERRNAME $res
1413 eval vput addrcodec res d $res
1414 echo $?/$^ERRNAME $res
1415 vput addrcodec res +e 12 Dr. Sauer (Ma) Braten Dr. (u) <doog@def>
1416 echo $?/$^ERRNAME $res
1417 eval vput addrcodec res d $res
1418 echo $?/$^ERRNAME $res
1419 vput addrcodec res +e 13(Ma)Braten Dr. (Heu) <doog@def>
1420 echo $?/$^ERRNAME $res
1421 eval vput addrcodec res d $res
1422 echo $?/$^ERRNAME $res
1423 vput addrcodec res +e 14 Hey, Du <doog@def> Wie() findet Dr. das? ()
1424 echo $?/$^ERRNAME $res
1425 eval vput addrcodec res d $res
1426 echo $?/$^ERRNAME $res
1427 vput addrcodec res +e 15 \
1428 Hey, Du <doog@def> Wie() findet "" Dr. "" das? ()
1429 echo $?/$^ERRNAME $res
1430 eval vput addrcodec res d $res
1431 echo $?/$^ERRNAME $res
1432 vput addrcodec res +e 16 \
1433 "Hey," "Du" <doog@def> "Wie()" findet "" Dr. "" das? ()
1434 echo $?/$^ERRNAME $res
1435 eval vput addrcodec res d $res
1436 echo $?/$^ERRNAME $res
1437 vput addrcodec res +e 17 \
1438 "Hey" Du <doog@def> "Wie() findet " " Dr. """ das? ()
1439 echo $?/$^ERRNAME $res
1440 eval vput addrcodec res d $res
1441 echo $?/$^ERRNAME $res
1442 vput addrcodec res +e 18 \
1443 <doog@def> "Hey" Du "Wie() findet " " Dr. """ das? ()
1444 echo $?/$^ERRNAME $res
1445 eval vput addrcodec res d $res
1446 echo $?/$^ERRNAME $res
1447 vput addrcodec res +e 19 Hey\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1448 echo $?/$^ERRNAME $res
1449 eval vput addrcodec res d $res
1450 echo $?/$^ERRNAME $res
1452 vput addrcodec res ++e 20 Hey\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1453 echo $?/$^ERRNAME $res
1454 vput addrcodec res ++e 21 Hey\,\"" <doog@def> "Wie()" findet \" Dr. \" das?
1455 echo $?/$^ERRNAME $res
1456 eval vput addrcodec res d $res
1457 echo $?/$^ERRNAME $res
1459 vput addrcodec res +++e 22 Hey\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1460 echo $?/$^ERRNAME $res
1461 eval vput addrcodec res d $res
1462 echo $?/$^ERRNAME $res
1464 vput addrcodec res s \
1465 "23 Hey\\,\\\" \"Wie" () "\" findet \\\" Dr. \\\" das?" <doog@def>
1466 echo $?/$^ERRNAME $res
1467 __EOT
1468 #0/NONE 1 <doog@def>
1469 #0/NONE 1 <doog@def>
1470 #0/NONE "2 ." <doog@def>
1471 #0/NONE 2 . <doog@def>
1472 #0/NONE "3 Sauer Dr." <doog@def>
1473 #0/NONE 3 Sauer Dr. <doog@def>
1474 #0/NONE 3.50 "Sauer \(Ma\) Dr." <doog@def>
1475 #0/NONE 3.50 Sauer (Ma) Dr. <doog@def>
1476 #0/NONE 3.51 "Sauer \(Ma\) \"Dr.\"" <doog@def>
1477 #0/NONE 3.51 Sauer (Ma) "Dr." <doog@def>
1478 #0/NONE 4 Sauer (Ma) "Dr." <doog@def>
1479 #0/NONE 4 Sauer (Ma) Dr. <doog@def>
1480 #0/NONE 5 Sauer (Ma) "Braten Dr." <doog@def>
1481 #0/NONE 5 Sauer (Ma) Braten Dr. <doog@def>
1482 #0/NONE 6 Sauer (Ma) "Braten Dr." (Heu) <doog@def>
1483 #0/NONE 6 Sauer (Ma) Braten Dr. (Heu) <doog@def>
1484 #0/NONE 7 Sauer (Ma) "Braten Dr." (Heu bu) <doog@def>
1485 #0/NONE 7 Sauer (Ma) Braten Dr. (Heu bu) <doog@def>
1486 #0/NONE "8 Dr. Sauer" (Ma) "Braten Dr." (Heu bu) "Boom. Boom" <doog@def>
1487 #0/NONE 8 Dr. Sauer (Ma) Braten Dr. (Heu bu) Boom. Boom <doog@def>
1488 #0/NONE "9 Dr.Sauer" (Ma) "Braten Dr." (Heu) <doog@def>
1489 #0/NONE 9 Dr.Sauer (Ma) Braten Dr. (Heu) <doog@def>
1490 #0/NONE 10 (Ma) "Braten Dr." (Heu) <doog@def>
1491 #0/NONE 10 (Ma) Braten Dr. (Heu) <doog@def>
1492 #0/NONE 11 (Ma) "Braten Dr\".\"" (Heu) <doog@def>
1493 #0/NONE 11 (Ma) Braten Dr"." (Heu) <doog@def>
1494 #0/NONE "12 Dr. Sauer" (Ma) "Braten Dr." (u) <doog@def>
1495 #0/NONE 12 Dr. Sauer (Ma) Braten Dr. (u) <doog@def>
1496 #0/NONE 13 (Ma) "Braten Dr." (Heu) <doog@def>
1497 #0/NONE 13 (Ma) Braten Dr. (Heu) <doog@def>
1498 #0/NONE "14 Hey, Du Wie" () "findet Dr. das?" () <doog@def>
1499 #0/NONE 14 Hey, Du Wie () findet Dr. das? () <doog@def>
1500 #0/NONE "15 Hey, Du Wie" () "findet \"\" Dr. \"\" das?" () <doog@def>
1501 #0/NONE 15 Hey, Du Wie () findet "" Dr. "" das? () <doog@def>
1502 #0/NONE "16 \"Hey,\" \"Du\" \"Wie" () "\" findet \"\" Dr. \"\" das?" () <doog@def>
1503 #0/NONE 16 "Hey," "Du" "Wie () " findet "" Dr. "" das? () <doog@def>
1504 #0/NONE "17 \"Hey\" Du \"Wie" () "findet \" \" Dr. \"\"\" das?" () <doog@def>
1505 #0/NONE 17 "Hey" Du "Wie () findet " " Dr. """ das? () <doog@def>
1506 #0/NONE "18 \"Hey\" Du \"Wie" () "findet \" \" Dr. \"\"\" das?" () <doog@def>
1507 #0/NONE 18 "Hey" Du "Wie () findet " " Dr. """ das? () <doog@def>
1508 #0/NONE "19 Hey\\,\\\" \"Wie" () "\" findet \\\" Dr. \\\" das?" <doog@def>
1509 #0/NONE 19 Hey\,\" "Wie () " findet \" Dr. \" das? <doog@def>
1510 #1/INVAL 20 Hey\\,\\" <doog@def> "Wie()" findet \\" Dr. \\" das?
1511 #0/NONE "21 Hey\\,\\ Wie() findet \\ Dr. \\ das?" <doog@def>
1512 #0/NONE 21 Hey\,\ Wie() findet \ Dr. \ das? <doog@def>
1513 #0/NONE "22 Hey\,\" Wie() findet \" Dr. \" das?" <doog@def>
1514 #0/NONE 22 Hey," Wie() findet " Dr. " das? <doog@def>
1515 #0/NONE doog@def
1516 cksum_test behave:addrcodec "${MBOX}" '3907388894 2416'
1519 t_behave_vexpr() {
1520 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}" 2>/dev/null
1521 vput vexpr res = 9223372036854775807
1522 echo $?/$^ERRNAME $res
1523 vput vexpr res = 9223372036854775808
1524 echo $?/$^ERRNAME $res
1525 vput vexpr res =@ 9223372036854775808
1526 echo $?/$^ERRNAME $res
1527 vput vexpr res = -9223372036854775808
1528 echo $?/$^ERRNAME $res
1529 vput vexpr res = -9223372036854775809
1530 echo $?/$^ERRNAME $res
1531 vput vexpr res =@ -9223372036854775809
1532 echo $?/$^ERRNAME $res
1533 echo ' #1'
1534 vput vexpr res ~ 0
1535 echo $?/$^ERRNAME $res
1536 vput vexpr res ~ 1
1537 echo $?/$^ERRNAME $res
1538 vput vexpr res ~ -1
1539 echo $?/$^ERRNAME $res
1540 echo ' #2'
1541 vput vexpr res + 0 0
1542 echo $?/$^ERRNAME $res
1543 vput vexpr res + 0 1
1544 echo $?/$^ERRNAME $res
1545 vput vexpr res + 1 1
1546 echo $?/$^ERRNAME $res
1547 echo ' #3'
1548 vput vexpr res + 9223372036854775807 0
1549 echo $?/$^ERRNAME $res
1550 vput vexpr res + 9223372036854775807 1
1551 echo $?/$^ERRNAME $res
1552 vput vexpr res +@ 9223372036854775807 1
1553 echo $?/$^ERRNAME $res
1554 vput vexpr res + 0 9223372036854775807
1555 echo $?/$^ERRNAME $res
1556 vput vexpr res + 1 9223372036854775807
1557 echo $?/$^ERRNAME $res
1558 vput vexpr res +@ 1 9223372036854775807
1559 echo $?/$^ERRNAME $res
1560 echo ' #4'
1561 vput vexpr res + -9223372036854775808 0
1562 echo $?/$^ERRNAME $res
1563 vput vexpr res + -9223372036854775808 -1
1564 echo $?/$^ERRNAME $res
1565 vput vexpr res +@ -9223372036854775808 -1
1566 echo $?/$^ERRNAME $res
1567 vput vexpr res + 0 -9223372036854775808
1568 echo $?/$^ERRNAME $res
1569 vput vexpr res + -1 -9223372036854775808
1570 echo $?/$^ERRNAME $res
1571 vput vexpr res +@ -1 -9223372036854775808
1572 echo $?/$^ERRNAME $res
1573 echo ' #5'
1574 vput vexpr res - 0 0
1575 echo $?/$^ERRNAME $res
1576 vput vexpr res - 0 1
1577 echo $?/$^ERRNAME $res
1578 vput vexpr res - 1 1
1579 echo $?/$^ERRNAME $res
1580 echo ' #6'
1581 vput vexpr res - 9223372036854775807 0
1582 echo $?/$^ERRNAME $res
1583 vput vexpr res - 9223372036854775807 -1
1584 echo $?/$^ERRNAME $res
1585 vput vexpr res -@ 9223372036854775807 -1
1586 echo $?/$^ERRNAME $res
1587 vput vexpr res - 0 9223372036854775807
1588 echo $?/$^ERRNAME $res
1589 vput vexpr res - -1 9223372036854775807
1590 echo $?/$^ERRNAME $res
1591 vput vexpr res - -2 9223372036854775807
1592 echo $?/$^ERRNAME $res
1593 vput vexpr res -@ -2 9223372036854775807
1594 echo $?/$^ERRNAME $res
1595 echo ' #7'
1596 vput vexpr res - -9223372036854775808 +0
1597 echo $?/$^ERRNAME $res
1598 vput vexpr res - -9223372036854775808 +1
1599 echo $?/$^ERRNAME $res
1600 vput vexpr res -@ -9223372036854775808 +1
1601 echo $?/$^ERRNAME $res
1602 vput vexpr res - 0 -9223372036854775808
1603 echo $?/$^ERRNAME $res
1604 vput vexpr res - +1 -9223372036854775808
1605 echo $?/$^ERRNAME $res
1606 vput vexpr res -@ +1 -9223372036854775808
1607 echo $?/$^ERRNAME $res
1608 echo ' #8'
1609 vput vexpr res + -13 -2
1610 echo $?/$^ERRNAME $res
1611 vput vexpr res - 0 0
1612 echo $?/$^ERRNAME $res
1613 vput vexpr res - 0 1
1614 echo $?/$^ERRNAME $res
1615 vput vexpr res - 1 1
1616 echo $?/$^ERRNAME $res
1617 vput vexpr res - -13 -2
1618 echo $?/$^ERRNAME $res
1619 echo ' #9'
1620 vput vexpr res * 0 0
1621 echo $?/$^ERRNAME $res
1622 vput vexpr res * 0 1
1623 echo $?/$^ERRNAME $res
1624 vput vexpr res * 1 1
1625 echo $?/$^ERRNAME $res
1626 vput vexpr res * -13 -2
1627 echo $?/$^ERRNAME $res
1628 echo ' #10'
1629 vput vexpr res / 0 0
1630 echo $?/$^ERRNAME $res
1631 vput vexpr res / 0 1
1632 echo $?/$^ERRNAME $res
1633 vput vexpr res / 1 1
1634 echo $?/$^ERRNAME $res
1635 vput vexpr res / -13 -2
1636 echo $?/$^ERRNAME $res
1637 echo ' #11'
1638 vput vexpr res % 0 0
1639 echo $?/$^ERRNAME $res
1640 vput vexpr res % 0 1
1641 echo $?/$^ERRNAME $res
1642 vput vexpr res % 1 1
1643 echo $?/$^ERRNAME $res
1644 vput vexpr res % -13 -2
1645 echo $?/$^ERRNAME $res
1646 __EOT
1647 #0/NONE 9223372036854775807
1648 #1/RANGE -1
1649 #0/OVERFLOW 9223372036854775807
1650 #0/NONE -9223372036854775808
1651 #1/RANGE -1
1652 #0/OVERFLOW -9223372036854775808
1653 # #1
1654 #0/NONE -1
1655 #0/NONE -2
1656 #0/NONE 0
1657 # #2
1658 #0/NONE 0
1659 #0/NONE 1
1660 #0/NONE 2
1661 # #3
1662 #0/NONE 9223372036854775807
1663 #1/OVERFLOW -1
1664 #0/OVERFLOW 9223372036854775807
1665 #0/NONE 9223372036854775807
1666 #1/OVERFLOW -1
1667 #0/OVERFLOW 9223372036854775807
1668 # #4
1669 #0/NONE -9223372036854775808
1670 #1/OVERFLOW -1
1671 #0/OVERFLOW -9223372036854775808
1672 #0/NONE -9223372036854775808
1673 #1/OVERFLOW -1
1674 #0/OVERFLOW -9223372036854775808
1675 # #5
1676 #0/NONE 0
1677 #0/NONE -1
1678 #0/NONE 0
1679 # #6
1680 #0/NONE 9223372036854775807
1681 #1/OVERFLOW -1
1682 #0/OVERFLOW 9223372036854775807
1683 #0/NONE -9223372036854775807
1684 #0/NONE -9223372036854775808
1685 #1/OVERFLOW -1
1686 #0/OVERFLOW -9223372036854775808
1687 # #7
1688 #0/NONE -9223372036854775808
1689 #1/OVERFLOW -1
1690 #0/OVERFLOW -9223372036854775808
1691 #0/NONE -9223372036854775808
1692 #1/OVERFLOW -1
1693 #0/OVERFLOW -9223372036854775808
1694 # #8
1695 #0/NONE -15
1696 #0/NONE 0
1697 #0/NONE -1
1698 #0/NONE 0
1699 #0/NONE -11
1700 # #9
1701 #0/NONE 0
1702 #0/NONE 0
1703 #0/NONE 1
1704 #0/NONE 26
1705 # #10
1706 #1/RANGE -1
1707 #0/NONE 0
1708 #0/NONE 1
1709 #0/NONE 6
1710 # #11
1711 #1/RANGE -1
1712 #0/NONE 0
1713 #0/NONE 0
1714 #0/NONE -1
1715 cksum_test behave:vexpr-numeric "${MBOX}" '1723609217 1048'
1717 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}" #2>/dev/null
1718 vput vexpr res find 'bananarama' 'nana'
1719 echo $?/$^ERRNAME :$res:
1720 vput vexpr res find 'bananarama' 'bana'
1721 echo $?/$^ERRNAME :$res:
1722 vput vexpr res find 'bananarama' 'Bana'
1723 echo $?/$^ERRNAME :$res:
1724 vput vexpr res find 'bananarama' 'rama'
1725 echo $?/$^ERRNAME :$res:
1726 echo ' #1'
1727 vput vexpr res ifind 'bananarama' 'nana'
1728 echo $?/$^ERRNAME :$res:
1729 vput vexpr res ifind 'bananarama' 'bana'
1730 echo $?/$^ERRNAME :$res:
1731 vput vexpr res ifind 'bananarama' 'Bana'
1732 echo $?/$^ERRNAME :$res:
1733 vput vexpr res ifind 'bananarama' 'rama'
1734 echo $?/$^ERRNAME :$res:
1735 echo ' #2'
1736 vput vexpr res substring 'bananarama' 1
1737 echo $?/$^ERRNAME :$res:
1738 vput vexpr res substring 'bananarama' 3
1739 echo $?/$^ERRNAME :$res:
1740 vput vexpr res substring 'bananarama' 5
1741 echo $?/$^ERRNAME :$res:
1742 vput vexpr res substring 'bananarama' 7
1743 echo $?/$^ERRNAME :$res:
1744 vput vexpr res substring 'bananarama' 9
1745 echo $?/$^ERRNAME :$res:
1746 vput vexpr res substring 'bananarama' 10
1747 echo $?/$^ERRNAME :$res:
1748 vput vexpr res substring 'bananarama' 1 3
1749 echo $?/$^ERRNAME :$res:
1750 vput vexpr res substring 'bananarama' 3 3
1751 echo $?/$^ERRNAME :$res:
1752 vput vexpr res substring 'bananarama' 5 3
1753 echo $?/$^ERRNAME :$res:
1754 vput vexpr res substring 'bananarama' 7 3
1755 echo $?/$^ERRNAME :$res:
1756 vput vexpr res substring 'bananarama' 9 3
1757 echo $?/$^ERRNAME :$res:
1758 vput vexpr res substring 'bananarama' 10 3
1759 echo $?/$^ERRNAME :$res:
1760 echo ' #3'
1761 __EOT
1762 #0/NONE :2:
1763 #0/NONE :0:
1764 #1/NODATA ::
1765 #0/NONE :6:
1766 # #1
1767 #0/NONE :2:
1768 #0/NONE :0:
1769 #0/NONE :0:
1770 #0/NONE :6:
1771 # #2
1772 #0/NONE :ananarama:
1773 #0/NONE :anarama:
1774 #0/NONE :arama:
1775 #0/NONE :ama:
1776 #0/NONE :a:
1777 #0/NONE ::
1778 #0/NONE :ana:
1779 #0/NONE :ana:
1780 #0/NONE :ara:
1781 #0/NONE :ama:
1782 #0/OVERFLOW :a:
1783 #0/OVERFLOW ::
1784 # #3
1785 cksum_test behave:vexpr-string "${MBOX}" '265398700 267'
1787 if have_feat regex; then
1788 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}" #2>/dev/null
1789 vput vexpr res regex 'bananarama' 'nana'
1790 echo $?/$^ERRNAME :$res:
1791 vput vexpr res regex 'bananarama' 'bana'
1792 echo $?/$^ERRNAME :$res:
1793 vput vexpr res regex 'bananarama' 'Bana'
1794 echo $?/$^ERRNAME :$res:
1795 vput vexpr res regex 'bananarama' 'rama'
1796 echo $?/$^ERRNAME :$res:
1797 echo ' #1'
1798 vput vexpr res iregex 'bananarama' 'nana'
1799 echo $?/$^ERRNAME :$res:
1800 vput vexpr res iregex 'bananarama' 'bana'
1801 echo $?/$^ERRNAME :$res:
1802 vput vexpr res iregex 'bananarama' 'Bana'
1803 echo $?/$^ERRNAME :$res:
1804 vput vexpr res iregex 'bananarama' 'rama'
1805 echo $?/$^ERRNAME :$res:
1806 echo ' #2'
1807 vput vexpr res regex 'bananarama' '(.*)nana(.*)' '\${1}a\${0}u{\$2}'
1808 echo $?/$^ERRNAME :$res:
1809 vput vexpr res regex 'bananarama' '(.*)bana(.*)' '\${1}a\${0}u\$2'
1810 echo $?/$^ERRNAME :$res:
1811 vput vexpr res regex 'bananarama' 'Bana(.+)' '\$1\$0'
1812 echo $?/$^ERRNAME :$res:
1813 vput vexpr res regex 'bananarama' '(.+)rama' '\$1\$0'
1814 echo $?/$^ERRNAME :$res:
1815 echo ' #3'
1816 vput vexpr res iregex 'bananarama' '(.*)nana(.*)' '\${1}a\${0}u{\$2}'
1817 echo $?/$^ERRNAME :$res:
1818 vput vexpr res iregex 'bananarama' '(.*)bana(.*)' '\${1}a\${0}u\$2'
1819 echo $?/$^ERRNAME :$res:
1820 vput vexpr res iregex 'bananarama' 'Bana(.+)' '\$1\$0'
1821 echo $?/$^ERRNAME :$res:
1822 vput vexpr res iregex 'bananarama' '(.+)rama' '\$1\$0'
1823 echo $?/$^ERRNAME :$res:
1824 echo ' #4'
1825 __EOT
1826 #0/NONE :2:
1827 #0/NONE :0:
1828 #1/NODATA ::
1829 #0/NONE :6:
1830 # #1
1831 #0/NONE :2:
1832 #0/NONE :0:
1833 #0/NONE :0:
1834 #0/NONE :6:
1835 # #2
1836 #0/NONE :baabananaramau{rama}:
1837 #0/NONE :abananaramaunarama:
1838 #1/NODATA ::
1839 #0/NONE :bananabananarama:
1840 # #3
1841 #0/NONE :baabananaramau{rama}:
1842 #0/NONE :abananaramaunarama:
1843 #0/NONE :naramabananarama:
1844 #0/NONE :bananabananarama:
1845 # #4
1846 cksum_test behave:vexpr-regex "${MBOX}" '3270360157 311'
1850 t_behave_e_H_L_opts() {
1851 TRAP_EXIT_ADDONS="./.tsendmail.sh ./.t.mbox"
1853 touch ./.t.mbox
1854 "${SNAIL}" ${ARGS} -ef ./.t.mbox
1855 echo ${?} > "${MBOX}"
1857 ${cat} <<-_EOT > ./.tsendmail.sh
1858 #!/bin/sh -
1859 (echo 'From Alchemilla Wed Apr 07 17:03:33 2017' && ${cat} && echo
1860 ) >> "./.t.mbox"
1861 _EOT
1862 chmod 0755 ./.tsendmail.sh
1863 printf 'm me@exam.ple\nLine 1.\nHello.\n~.\n' |
1864 "${SNAIL}" ${ARGS} -Smta=./.tsendmail.sh
1865 printf 'm you@exam.ple\nLine 1.\nBye.\n~.\n' |
1866 "${SNAIL}" ${ARGS} -Smta=./.tsendmail.sh
1868 "${SNAIL}" ${ARGS} -ef ./.t.mbox
1869 echo ${?} >> "${MBOX}"
1870 "${SNAIL}" ${ARGS} -efL @t@me ./.t.mbox
1871 echo ${?} >> "${MBOX}"
1872 "${SNAIL}" ${ARGS} -efL @t@you ./.t.mbox
1873 echo ${?} >> "${MBOX}"
1874 "${SNAIL}" ${ARGS} -efL '@>@Line 1' ./.t.mbox
1875 echo ${?} >> "${MBOX}"
1876 "${SNAIL}" ${ARGS} -efL '@>@Hello.' ./.t.mbox
1877 echo ${?} >> "${MBOX}"
1878 "${SNAIL}" ${ARGS} -efL '@>@Bye.' ./.t.mbox
1879 echo ${?} >> "${MBOX}"
1880 "${SNAIL}" ${ARGS} -efL '@>@Good bye.' ./.t.mbox
1881 echo ${?} >> "${MBOX}"
1883 "${SNAIL}" ${ARGS} -fH ./.t.mbox >> "${MBOX}"
1884 echo ${?} >> "${MBOX}"
1885 "${SNAIL}" ${ARGS} -fL @t@me ./.t.mbox >> "${MBOX}"
1886 echo ${?} >> "${MBOX}"
1887 "${SNAIL}" ${ARGS} -fL @t@you ./.t.mbox >> "${MBOX}"
1888 echo ${?} >> "${MBOX}"
1889 "${SNAIL}" ${ARGS} -fL '@>@Line 1' ./.t.mbox >> "${MBOX}"
1890 echo ${?} >> "${MBOX}"
1891 "${SNAIL}" ${ARGS} -fL '@>@Hello.' ./.t.mbox >> "${MBOX}"
1892 echo ${?} >> "${MBOX}"
1893 "${SNAIL}" ${ARGS} -fL '@>@Bye.' ./.t.mbox >> "${MBOX}"
1894 echo ${?} >> "${MBOX}"
1895 "${SNAIL}" ${ARGS} -fL '@>@Good bye.' ./.t.mbox >> "${MBOX}" 2>/dev/null
1896 echo ${?} >> "${MBOX}"
1898 ${rm} -f ${TRAP_EXIT_ADDONS}
1899 TRAP_EXIT_ADDONS=
1909 #>N 1 Alchemilla 1996-10-02 01:50 7/112
1910 # N 2 Alchemilla 1996-10-02 01:50 7/111
1912 #>N 1 Alchemilla 1996-10-02 01:50 7/112
1914 # N 2 Alchemilla 1996-10-02 01:50 7/111
1916 #>N 1 Alchemilla 1996-10-02 01:50 7/112
1917 # N 2 Alchemilla 1996-10-02 01:50 7/111
1919 #>N 1 Alchemilla 1996-10-02 01:50 7/112
1921 # N 2 Alchemilla 1996-10-02 01:50 7/111
1924 cksum_test behave:e_H_L_opts "${MBOX}" '1708955574 678'
1927 t_behave_compose_hooks() {
1928 TRAP_EXIT_ADDONS="./.tsendmail.sh ./.tnotes"
1930 ${cat} <<-_EOT > ./.tsendmail.sh
1931 #!/bin/sh -
1932 ${rm} -f "${MBOX}"
1933 (echo 'From PrimulaVeris Wed Apr 10 22:59:00 2017' && ${cat}) > "${MBOX}"
1934 _EOT
1935 chmod 0755 ./.tsendmail.sh
1937 printf 'm hook-test@exam.ple\nbody\n~.\nvar t_oce t_ocs t_ocs_shell t_ocl' |
1938 "${SNAIL}" ${ARGS} \
1939 -Smta=./.tsendmail.sh \
1941 define t_ocs {
1942 read ver
1943 echo t_ocs
1944 echo "~^header list"; read hl; vput vexpr es substr "$hl" 0 1
1945 if [ "$es" != 2 ]
1946 echoerr "Failed to header list, aborting send"; echo "~x"
1947 endif
1948 echo "~^header insert cc splicy diet <splice@exam.ple> spliced";\
1949 read es; vput vexpr es substr "$es" 0 1
1950 if [ "$es" != 2 ]
1951 echoerr "Failed to be diet, aborting send"; echo "~x"
1952 endif
1953 echo "~^header insert bcc juicy juice <juice@exam.ple> spliced";\
1954 read es; vput vexpr es substr "$es" 0 1
1955 if [ "$es" != 2 ]
1956 echoerr "Failed to be juicy, aborting send"; echo "~x"
1957 endif
1958 echo "~:set t_ocs"
1960 define t_oce {
1961 set t_oce autobcc=oce@exam.ple
1963 define t_ocl {
1964 set t_ocl autocc=ocl@exam.ple
1966 wysh set on-compose-splice=t_ocs \
1967 on-compose-splice-shell="read ver;printf \"t_ocs-shell\\n\
1968 ~t shell@exam.ple\\n~:set t_ocs_shell\\n\"" \
1969 on-compose-enter=t_oce on-compose-leave=t_ocl
1970 ' > ./.tnotes
1971 ${cat} ./.tnotes >> "${MBOX}"
1973 ${rm} -f ${TRAP_EXIT_ADDONS}
1974 TRAP_EXIT_ADDONS=
1976 #From PrimulaVeris Wed Apr 10 22:59:00 2017
1977 #Date: Wed, 02 Oct 1996 01:50:07 +0000
1978 #To: hook-test@exam.ple, shell@exam.ple
1979 #Cc: ocl@exam.ple, splicy diet spliced <splice@exam.ple>
1980 #Bcc: juicy juice spliced <juice@exam.ple>, oce@exam.ple
1982 #body
1983 #t_ocs-shell
1984 #t_ocs
1985 ##variable not set: t_oce
1986 ##variable not set: t_ocs
1987 ##variable not set: t_ocs_shell
1988 ##variable not set: t_ocl
1989 cksum_test behave:compose_hooks "${MBOX}" '3240856112 319'
1992 t_behave_smime() { # FIXME add test/ dir, unroll tests therein
1993 TRAP_EXIT_ADDONS="./.t.conf ./.tkey.pem ./.tcert.pem ./.tpair.pem"
1994 TRAP_EXIT_ADDONS="${TRAP_EXIT_ADDONS} ./.VERIFY ./.DECRYPT ./.ENCRYPT"
1995 TRAP_EXIT_ADDONS="${TRAP_EXIT_ADDONS} ./.tsendmail.sh"
1997 printf 'behave:s/mime: .. generating test key and certificate ..\n'
1998 ${cat} <<-_EOT > ./.t.conf
1999 [ req ]
2000 default_bits = 1024
2001 default_keyfile = keyfile.pem
2002 distinguished_name = req_distinguished_name
2003 attributes = req_attributes
2004 prompt = no
2005 output_password =
2007 [ req_distinguished_name ]
2008 C = GB
2009 ST = Over the
2010 L = rainbow
2011 O = S-nail
2012 OU = S-nail.smime
2013 CN = S-nail.test
2014 emailAddress = test@localhost
2016 [ req_attributes ]
2017 challengePassword =
2018 _EOT
2019 openssl req -x509 -nodes -days 3650 -config ./.t.conf \
2020 -newkey rsa:1024 -keyout ./.tkey.pem -out ./.tcert.pem >/dev/null 2>&1
2021 ${cat} ./.tkey.pem ./.tcert.pem > ./.tpair.pem
2023 printf "behave:s/mime:sign/verify: "
2024 echo bla | "${SNAIL}" ${ARGS} \
2025 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
2026 -Ssmime-sign -Sfrom=test@localhost \
2027 -s 'S/MIME test' ./.VERIFY
2028 printf 'verify\nx\n' |
2029 "${SNAIL}" ${ARGS} \
2030 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
2031 -Ssmime-sign -Sfrom=test@localhost \
2032 -Serrexit -R \
2033 -f ./.VERIFY >/dev/null 2>&1
2034 if [ $? -eq 0 ]; then
2035 printf 'ok\n'
2036 else
2037 printf 'error: verification failed\n'
2038 ESTAT=1
2039 ${rm} -f ${TRAP_EXIT_ADDONS}
2040 TRAP_EXIT_ADDONS=
2041 return
2043 printf ' .. disproof via openssl smime(1): '
2044 if openssl smime -verify -CAfile ./.tcert.pem \
2045 -in ./.VERIFY >/dev/null 2>&1; then
2046 printf 'ok\n'
2047 else
2048 printf 'failed\n'
2049 ESTAT=1
2050 ${rm} -f ${TRAP_EXIT_ADDONS}
2051 TRAP_EXIT_ADDONS=
2052 return
2055 # (signing +) encryption / decryption
2056 ${cat} <<-_EOT > ./.tsendmail.sh
2057 #!/bin/sh -
2058 ${rm} -f ./.ENCRYPT
2059 (echo 'From S-Postman Thu May 10 20:40:54 2012' && ${cat}) > ./.ENCRYPT
2060 _EOT
2061 chmod 0755 ./.tsendmail.sh
2063 printf "behave:s/mime:encrypt+sign/decrypt+verify: "
2064 echo bla |
2065 "${SNAIL}" ${ARGS} \
2066 -Ssmime-force-encryption \
2067 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
2068 -Smta=./.tsendmail.sh \
2069 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
2070 -Ssmime-sign -Sfrom=test@localhost \
2071 -s 'S/MIME test' recei@ver.com
2072 # TODO CHECK
2073 printf 'decrypt ./.DECRYPT\nfi ./.DECRYPT\nverify\nx\n' |
2074 "${SNAIL}" ${ARGS} \
2075 -Ssmime-force-encryption \
2076 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
2077 -Smta=./.tsendmail.sh \
2078 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
2079 -Ssmime-sign -Sfrom=test@localhost \
2080 -Serrexit -R \
2081 -f ./.ENCRYPT >/dev/null 2>&1
2082 if [ $? -eq 0 ]; then
2083 printf 'ok\n'
2084 else
2085 ESTAT=1
2086 printf 'error: decryption+verification failed\n'
2088 printf ' ..disproof via openssl smime(1): '
2089 if (openssl smime -decrypt -inkey ./.tkey.pem -in ./.ENCRYPT |
2090 openssl smime -verify -CAfile ./.tcert.pem) >/dev/null 2>&1; then
2091 printf 'ok\n'
2092 else
2093 printf 'failed\n'
2094 ESTAT=1
2096 ${sed} -e '/^Date:/d' -e '/^X-Decoding-Date/d' \
2097 -e \
2098 '/^Content-Disposition: attachment; filename="smime.p7s"/,/^-- /d' \
2099 < ./.DECRYPT > ./.ENCRYPT
2100 cksum_test ".. checksum of decrypted content" "./.ENCRYPT" '3090916509 510'
2102 printf "behave:s/mime:encrypt/decrypt: "
2103 ${rm} -f ./.DECRYPT
2104 echo bla | "${SNAIL}" ${ARGS} \
2105 -Ssmime-force-encryption \
2106 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
2107 -Smta=./.tsendmail.sh \
2108 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
2109 -Sfrom=test@localhost \
2110 -s 'S/MIME test' recei@ver.com
2111 printf 'decrypt ./.DECRYPT\nx\n' | "${SNAIL}" ${ARGS} \
2112 -Ssmime-force-encryption \
2113 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
2114 -Smta=./.tsendmail.sh \
2115 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
2116 -Sfrom=test@localhost \
2117 -Serrexit -R \
2118 -f ./.ENCRYPT >/dev/null 2>&1
2119 if [ $? -eq 0 ]; then
2120 printf 'ok\n'
2121 else
2122 ESTAT=1
2123 printf 'error: decryption failed\n'
2125 printf '.. disproof via openssl smime(1): '
2126 if openssl smime -decrypt -inkey ./.tkey.pem \
2127 -in ./.ENCRYPT >/dev/null 2>&1; then
2128 printf 'ok\n'
2129 else
2130 printf 'failed\n'
2131 ESTAT=1
2133 ${sed} -e '/^Date:/d' -e '/^X-Decoding-Date/d' \
2134 < ./.DECRYPT > ./.ENCRYPT
2135 cksum_test ".. checksum of decrypted content" ./.ENCRYPT '999887248 295'
2137 ${rm} -f ${TRAP_EXIT_ADDONS}
2138 TRAP_EXIT_ADDONS=
2141 # t_content()
2142 # Some basic tests regarding correct sending of mails, via STDIN / -t / -q,
2143 # including basic MIME Content-Transfer-Encoding correctness (quoted-printable)
2144 # Note we unfortunately need to place some statements without proper
2145 # indentation because of continuation problems
2146 t_content() {
2147 # MIME encoding (QP) stress message body
2148 printf \
2149 'Ich bin eine DÖS-Datäi mit sehr langen Zeilen und auch '\
2150 'sonst bin ich ganz schön am Schleudern, da kannste denke '\
2151 "wasde willst, gelle, gelle, gelle, gelle, gelle.\r\n"\
2152 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst \r\n"\
2153 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1\r\n"\
2154 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12\r\n"\
2155 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123\r\n"\
2156 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1234\r\n"\
2157 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12345\r\n"\
2158 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123456\r\n"\
2159 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1234567\r\n"\
2160 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12345678\r\n"\
2161 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123456789\r\n"\
2162 "Unn ausserdem habe ich trailing SP/HT/SP/HT whitespace \r\n"\
2163 "Unn ausserdem habe ich trailing HT/SP/HT/SP whitespace \r\n"\
2164 "auf den zeilen vorher.\r\n"\
2165 "From am Zeilenbeginn und From der Mitte gibt es auch.\r\n"\
2166 ".\r\n"\
2167 "Die letzte Zeile war nur ein Punkt.\r\n"\
2168 "..\r\n"\
2169 "Das waren deren zwei.\r\n"\
2170 " \r\n"\
2171 "Die letzte Zeile war ein Leerschritt.\n"\
2172 "=VIER = EQUAL SIGNS=ON A LINE=\r\n"\
2173 "Prösterchen.\r\n"\
2174 ".\n"\
2175 "Die letzte Zeile war nur ein Punkt, mit Unix Zeilenende.\n"\
2176 "..\n"\
2177 "Das waren deren zwei. ditto.\n"\
2178 "Prösterchen.\n"\
2179 "Unn ausseerdem habe ich trailing SP/HT/SP/HT whitespace \n"\
2180 "Unn ausseerdem habe ich trailing HT/SP/HT/SP whitespace \n"\
2181 "auf den zeilen vorher.\n"\
2182 "ditto.\n"\
2183 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.\n"\
2184 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.1"\
2185 "\n"\
2186 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
2187 "\n"\
2188 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
2189 "3\n"\
2190 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
2191 "34\n"\
2192 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
2193 "345\n"\
2194 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
2195 "3456\n"\
2196 "QP am Zeilenende über soft-nl hinweg\n"\
2197 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
2198 "ö123\n"\
2199 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
2200 "1ö23\n"\
2201 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
2202 "12ö3\n"\
2203 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
2204 "123ö\n"\
2205 "=VIER = EQUAL SIGNS=ON A LINE=\n"\
2206 " \n"\
2207 "Die letzte Zeile war ein Leerschritt.\n"\
2208 ' '\
2209 > "${BODY}"
2211 # MIME encoding (QP) stress message subject
2212 SUB="Äbrä Kä?dä=brö Fü?di=bus? \
2213 adadaddsssssssddddddddddddddddddddd\
2214 ddddddddddddddddddddddddddddddddddd\
2215 ddddddddddddddddddddddddddddddddddd\
2216 dddddddddddddddddddd Hallelulja? Od\
2217 er?? eeeeeeeeeeeeeeeeeeeeeeeeeeeeee\
2218 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\
2219 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee f\
2220 fffffffffffffffffffffffffffffffffff\
2221 fffffffffffffffffffff ggggggggggggg\
2222 ggggggggggggggggggggggggggggggggggg\
2223 ggggggggggggggggggggggggggggggggggg\
2224 ggggggggggggggggggggggggggggggggggg\
2225 gggggggggggggggg"
2227 # Three tests for MIME encodign and (a bit) content classification.
2228 # At the same time testing -q FILE, < FILE and -t FILE
2230 ${rm} -f "${MBOX}"
2231 < "${BODY}" "${SNAIL}" ${ARGS} ${ADDARG_UNI} \
2232 -a "${BODY}" -s "${SUB}" "${MBOX}"
2233 cksum_test content:001 "${MBOX}" '2356108758 6413'
2235 ${rm} -f "${MBOX}"
2236 < /dev/null "${SNAIL}" ${ARGS} ${ADDARG_UNI} \
2237 -a "${BODY}" -s "${SUB}" -q "${BODY}" "${MBOX}"
2238 cksum_test content:002 "${MBOX}" '2356108758 6413'
2240 ${rm} -f "${MBOX}"
2241 ( echo "To: ${MBOX}" && echo "Subject: ${SUB}" && echo &&
2242 ${cat} "${BODY}"
2243 ) | "${SNAIL}" ${ARGS} ${ADDARG_UNI} -Snodot -a "${BODY}" -t
2244 cksum_test content:003 "${MBOX}" '2356108758 6413'
2246 # Test for [260e19d] (Juergen Daubert)
2247 ${rm} -f "${MBOX}"
2248 echo body | "${SNAIL}" ${ARGS} "${MBOX}"
2249 cksum_test content:004 "${MBOX}" '4004005686 49'
2251 # Sending of multiple mails in a single invocation
2252 ${rm} -f "${MBOX}"
2253 ( printf "m ${MBOX}\n~s subject1\nE-Mail Körper 1\n~.\n" &&
2254 printf "m ${MBOX}\n~s subject2\nEmail body 2\n~.\n" &&
2255 echo x
2256 ) | "${SNAIL}" ${ARGS} ${ADDARG_UNI}
2257 cksum_test content:005 "${MBOX}" '2157252578 260'
2259 ## $BODY CHANGED
2261 # "Test for" [d6f316a] (Gavin Troy)
2262 ${rm} -f "${MBOX}"
2263 printf "m ${MBOX}\n~s subject1\nEmail body\n~.\nfi ${MBOX}\np\nx\n" |
2264 "${SNAIL}" ${ARGS} ${ADDARG_UNI} -Spipe-text/plain="${cat}" > "${BODY}"
2265 ${sed} -e 1d < "${BODY}" > "${MBOX}"
2266 cksum_test content:006 "${MBOX}" '2273863401 83'
2268 # "Test for" [c299c45] (Peter Hofmann) TODO shouldn't end up QP-encoded?
2269 ${rm} -f "${MBOX}"
2270 ${awk} 'BEGIN{
2271 for(i = 0; i < 10000; ++i)
2272 printf "\xC3\xBC"
2273 #printf "\xF0\x90\x87\x90"
2274 }' | "${SNAIL}" ${ARGS} ${ADDARG_UNI} -s TestSubject "${MBOX}"
2275 cksum_test content:007 "${MBOX}" '1754234717 61767'
2277 ## Test some more corner cases for header bodies (as good as we can today) ##
2280 ${rm} -f "${MBOX}"
2281 echo | "${SNAIL}" ${ARGS} ${ADDARG_UNI} \
2282 -s 'a̲b̲c̲d̲e̲f̲h̲i̲k̲l̲m̲n̲o̲r̲s̲t̲u̲v̲w̲x̲z̲a̲b̲c̲d̲e̲f̲h̲i̲k̲l̲m̲n̲o̲r̲s̲t̲u̲v̲w̲x̲z̲' \
2283 "${MBOX}"
2284 cksum_test content:008 "${MBOX}" '1563381297 326'
2286 # Single word (overlong line split -- bad standard! Requires injection of
2287 # artificial data!! Bad can be prevented by using RFC 2047 encoding)
2288 ${rm} -f "${MBOX}"
2289 i=`${awk} 'BEGIN{for(i=0; i<92; ++i) printf "0123456789_"}'`
2290 echo | "${SNAIL}" ${ARGS} -s "${i}" "${MBOX}"
2291 cksum_test content:009 "${MBOX}" '1996714851 1669'
2293 # Combination of encoded words, space and tabs of varying sort
2294 ${rm} -f "${MBOX}"
2295 echo | "${SNAIL}" ${ARGS} ${ADDARG_UNI} \
2296 -s "1Abrä Kaspas1 2Abra Katä b_kaspas2 \
2297 3Abrä Kaspas3 4Abrä Kaspas4 5Abrä Kaspas5 \
2298 6Abra Kaspas6 7Abrä Kaspas7 8Abra Kaspas8 \
2299 9Abra Kaspastäb4-3 10Abra Kaspas1 _ 11Abra Katäb1 \
2300 12Abra Kadabrä1 After Tab after Täb this is NUTS" \
2301 "${MBOX}"
2302 cksum_test content:010 "${MBOX}" '2956039469 542'
2304 # Overlong multibyte sequence that must be forcefully split
2305 # todo This works even before v15.0, but only by accident
2306 ${rm} -f "${MBOX}"
2307 echo | "${SNAIL}" ${ARGS} ${ADDARG_UNI} \
2308 -s "✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
2309 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
2310 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄" \
2311 "${MBOX}"
2312 cksum_test content:011 "${MBOX}" '454973928 610'
2314 # Trailing WS
2315 ${rm} -f "${MBOX}"
2316 echo | "${SNAIL}" ${ARGS} \
2317 -s "1-1 B2 B3 B4 B5 B6 B\
2318 1-2 B2 B3 B4 B5 B6 B\
2319 1-3 B2 B3 B4 B5 B6 B\
2320 1-4 B2 B3 B4 B5 B6 B\
2321 1-5 B2 B3 B4 B5 B6 B\
2322 1-6 B2 B3 B4 B5 B6 " \
2323 "${MBOX}"
2324 cksum_test content:012 "${MBOX}" '1014122962 248'
2326 # Leading and trailing WS
2327 ${rm} -f "${MBOX}"
2328 echo | "${SNAIL}" ${ARGS} \
2329 -s " 2-1 B2 B3 B4 B5 B6 B\
2330 1-2 B2 B3 B4 B5 B6 B\
2331 1-3 B2 B3 B4 B5 B6 B\
2332 1-4 B2 B3 B4 B5 B6 " \
2333 "${MBOX}"
2334 cksum_test content:013 "${MBOX}" '3212167908 187'
2336 # Quick'n dirty RFC 2231 test; i had more when implementing it, but until we
2337 # have a (better) test framework materialize a quick shot
2338 ${rm} -f "${MBOX}"
2339 TRAP_EXIT_ADDONS=./.ttt
2341 mkdir ./.ttt || exit 1
2342 cd ./.ttt || exit 2
2343 : > "ma'ger.txt"
2344 : > "mä'ger.txt"
2345 : > 'diet\ is \curd.txt'
2346 : > 'diet "is" curd.txt'
2347 : > höde-tröge.txt
2348 : > höde__tröge__müde__dätte__hätte__vülle__gülle__äse__äße__säuerliche__kräuter__österliche__grüße__mäh.txt
2349 : > höde__tröge__müde__dätte__hätte__vuelle__guelle__aese__aesse__sauerliche__kräuter__österliche__grüße__mäh.txt
2350 : > hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt
2351 : > ✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt
2353 echo bla | "${SNAIL}" ${ARGS} ${ADDARG_UNI} \
2354 -a "./.ttt/ma'ger.txt" -a "./.ttt/mä'ger.txt" \
2355 -a './.ttt/diet\ is \curd.txt' -a './.ttt/diet "is" curd.txt' \
2356 -a ./.ttt/höde-tröge.txt \
2357 -a ./.ttt/höde__tröge__müde__dätte__hätte__vülle__gülle__äse__äße__säuerliche__kräuter__österliche__grüße__mäh.txt \
2358 -a ./.ttt/höde__tröge__müde__dätte__hätte__vuelle__guelle__aese__aesse__sauerliche__kräuter__österliche__grüße__mäh.txt \
2359 -a ./.ttt/hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt \
2360 -a ./.ttt/✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt \
2361 "${MBOX}"
2362 ${rm} -rf ./.ttt
2363 cksum_test content:14 "${MBOX}" '589846634 2491'
2364 # `resend' test
2365 printf "Resend ${BODY}\nx\n" | "${SNAIL}" ${ARGS} -f "${MBOX}"
2366 cksum_test content:14-2 "${MBOX}" '589846634 2491'
2369 t_all() {
2370 if have_feat devel; then
2371 ARGS="${ARGS} -Smemdebug"
2372 export ARGS
2374 t_behave
2375 t_content
2378 if [ -z "${CHECK_ONLY}" ]; then
2379 cc_all_configs
2380 else
2381 t_all
2384 [ ${ESTAT} -eq 0 ] && echo Ok || echo >&2 'Errors occurred'
2386 exit ${ESTAT}
2387 # s-sh-mode