cc-test.sh: add t_behave_mass_recipients
[s-mailx.git] / cc-test.sh
blob96b351698f0d475370fac55ce5c3a2427585a382
1 #!/bin/sh -
2 #@ Usage: ./cc-test.sh [--check-only] s-mailx-binary
3 #@ TODO _All_ the tests should happen in a temporary subdir.
4 # Public Domain
6 # We need *stealthmua* regardless of $SOURCE_DATE_EPOCH, the program name as
7 # such is a compile-time variable
8 ARGS='-:/ -# -Sdotlock-ignore-error -Sencoding=quoted-printable -Sstealthmua'
9 ARGS="${ARGS}"' -Snosave -Sexpandaddr=restrict'
10 ADDARG_UNI=-Sttycharset=UTF-8
11 CONF=./make.rc
12 BODY=./.cc-body.txt
13 MBOX=./.cc-test.mbox
14 MAIL=/dev/null
15 #UTF8_LOCALE= autodetected unless set
17 MEMTESTER=
18 #MEMTESTER='valgrind --leak-check=full --log-file=.vl-%p '
20 if ( command -v command ) >/dev/null 2>&1; then :; else
21 command() {
22 shift
23 which "${@}"
27 MAKE="${MAKE:-`command -v make`}"
28 awk=${awk:-`command -v awk`}
29 cat=${cat:-`command -v cat`}
30 cksum=${cksum:-`command -v cksum`}
31 rm=${rm:-`command -v rm`}
32 sed=${sed:-`command -v sed`}
33 grep=${grep:-`command -v grep`}
35 # Problem: force $SHELL to be a real shell. It seems some testing environments
36 # use nologin(?), but we need a real shell for command execution
37 if { echo ${SHELL} | ${grep} nologin; } >/dev/null 2>&1; then
38 echo >&2 '$SHELL seems to be nologin, overwriting to /bin/sh!'
39 SHELL=/bin/sh
40 export SHELL
43 # We sometimes "fake" sendmail(1) a.k.a. *mta* with a shell wrapper, and it
44 # happens that /bin/sh is often terribly slow
45 if command -v dash >/dev/null 2>&1; then
46 MYSHELL="`command -v dash`"
47 elif command -v mksh >/dev/null 2>&1; then
48 MYSHELL="`command -v mksh`"
49 else
50 MYSHELL="${SHELL}"
53 ## -- >8 -- 8< -- ##
55 export ARGS ADDARG_UNI CONF BODY MBOX MAIL MAKE awk cat cksum rm sed grep
57 LC_ALL=C LANG=C
58 TZ=UTC
59 # Wed Oct 2 01:50:07 UTC 1996
60 SOURCE_DATE_EPOCH=844221007
62 export LC_ALL LANG TZ SOURCE_DATE_EPOCH
63 unset POSIXLY_CORRECT
65 usage() {
66 echo >&2 "Usage: ./cc-test.sh [--check-only] s-mailx-binary"
67 exit 1
70 CHECK_ONLY= MAILX=
71 while [ $# -gt 0 ]; do
72 if [ "${1}" = --check-only ]; then
73 CHECK_ONLY=1
74 else
75 MAILX=${1}
77 shift
78 done
79 [ -x "${MAILX}" ] || usage
80 RAWMAILX=${MAILX}
81 MAILX="${MEMTESTER}${MAILX}"
82 export RAWMAILX MAILX
84 if [ -z "${UTF8_LOCALE}" ]; then
85 # Try ourselfs for nl_langinfo(CODESET) output first (requires a new version)
86 i=`LC_ALL=C.utf8 "${RAWMAILX}" ${ARGS} -X '
87 \define cset_test {
88 \if [ "${ttycharset}" @i=% utf ]
89 \echo $LC_ALL
90 \xit 0
91 \end
92 \if [ "${#}" -gt 0 ]
93 \wysh set LC_ALL="${1}.utf8"
94 \shift
95 \eval xcall cset_test "${@}"
96 \end
97 \xit 1
99 \call cset_test POSIX en_EN en_US
101 [ $? -eq 0 ] && UTF8_LOCALE=$i
103 if [ -z "${UTF8_LOCALE}" ] && command -v locale >/dev/null 2>&1; then
104 UTF8_LOCALE=`locale -a | { m=
105 while read n; do
106 if { echo ${n} | ${grep} -i 'utf-\{0,1\}8'; } >/dev/null 2>&1; then
107 m=${n}
108 if { echo ${n} | ${grep} -e POSIX -e en_EN -e en_US; }; then
109 exit 0
112 m=${n}
113 done
114 echo ${m}
119 ESTAT=0
121 TRAP_EXIT_ADDONS=
122 trap "${rm} -rf \"${BODY}\" \"${MBOX}\" \${TRAP_EXIT_ADDONS}" EXIT
123 trap "exit 1" HUP INT TERM
125 # cc_all_configs()
126 # Test all configs TODO doesn't cover all *combinations*, stupid!
127 cc_all_configs() {
128 < ${CONF} ${awk} '
129 BEGIN {
130 NOTME["OPT_AUTOCC"] = 1
131 NOTME["OPT_DEBUG"] = 1
132 NOTME["OPT_DEVEL"] = 1
133 NOTME["OPT_NOEXTMD5"] = 1
134 NOTME["OPT_NOMEMDBG"] = 1
135 NOTME["OPT_NYD2"] = 1
136 i = 0
138 /^[[:space:]]*OPT_/ {
139 sub(/^[[:space:]]*/, "")
140 # This bails for UnixWare 7.1.4 awk(1), but preceeding = with \
141 # does not seem to be a compliant escape for =
142 #sub(/=.*$/, "")
143 $1 = substr($1, 1, index($1, "=") - 1)
144 if (NOTME[$1])
145 next
146 data[i++] = $1
148 END {
149 # Doing this completely sequentially and not doing make distclean in
150 # between runs should effectively result in lesser compilations.
151 # It is completely dumb nonetheless... TODO
152 for (j = 1; j < i; ++j) {
153 for (k = 1; k < j; ++k)
154 printf data[k] "=1 "
155 for (k = j; k < i; ++k)
156 printf data[k] "=0 "
157 printf "OPT_AUTOCC=1\n"
159 for (j = 1; j < i; ++j) {
160 for (k = 1; k < j; ++k)
161 printf data[k] "=0 "
162 for (k = j; k < i; ++k)
163 printf data[k] "=1 "
164 printf "OPT_AUTOCC=1\n"
166 # With debug
167 for (j = 1; j < i; ++j) {
168 for (k = 1; k < j; ++k)
169 printf data[k] "=1 "
170 for (k = j; k < i; ++k)
171 printf data[k] "=0 "
172 printf "OPT_AUTOCC=1\n"
173 printf "OPT_DEBUG=1\n"
175 for (j = 1; j < i; ++j) {
176 for (k = 1; k < j; ++k)
177 printf data[k] "=0 "
178 for (k = j; k < i; ++k)
179 printf data[k] "=1 "
180 printf "OPT_AUTOCC=1\n"
181 printf "OPT_DEBUG=1\n"
184 printf "CONFIG=NULL OPT_AUTOCC=0\n"
185 printf "CONFIG=NULL OPT_AUTOCC=1\n"
186 printf "CONFIG=NULLI OPT_AUTOCC=0\n"
187 printf "CONFIG=NULLI OPT_AUTOCC=1\n"
188 printf "CONFIG=MINIMAL OPT_AUTOCC=0\n"
189 printf "CONFIG=MINIMAL OPT_AUTOCC=1\n"
190 printf "CONFIG=MEDIUM OPT_AUTOCC=0\n"
191 printf "CONFIG=MEDIUM OPT_AUTOCC=1\n"
192 printf "CONFIG=NETSEND OPT_AUTOCC=0\n"
193 printf "CONFIG=NETSEND OPT_AUTOCC=1\n"
194 printf "CONFIG=MAXIMAL OPT_AUTOCC=0\n"
195 printf "CONFIG=MAXIMAL OPT_AUTOCC=1\n"
196 printf "CONFIG=DEVEL OPT_AUTOCC=0\n"
197 printf "CONFIG=DEVEL OPT_AUTOCC=1\n"
198 printf "CONFIG=ODEVEL OPT_AUTOCC=0\n"
199 printf "CONFIG=ODEVEL OPT_AUTOCC=1\n"
201 ' | while read c; do
202 printf "\n\n##########\n$c\n"
203 printf "\n\n##########\n$c\n" >&2
204 sh -c "${MAKE} ${c}"
205 t_all
206 done
207 ${MAKE} distclean
210 have_feat() {
211 ( "${RAWMAILX}" ${ARGS} -X'echo $features' -Xx |
212 ${grep} +${1} ) >/dev/null 2>&1
215 t_prolog() {
216 ${rm} -rf "${BODY}" "${MBOX}" ${TRAP_EXIT_ADDONS}
217 TRAP_EXIT_ADDONS=
219 t_epilog() {
220 t_prolog
223 check() {
224 restat=${?} tid=${1} eestat=${2} f=${3} s=${4}
225 #x=`echo ${tid} | tr "/:=" "__-"`
226 #cp -f "${f}" "${TMPDIR}/${x}"
227 [ "${eestat}" != - ] && [ "${restat}" != "${eestat}" ] &&
228 err "${tid}" 'unexpected exit status: '"${restat} != ${eestat}"
229 csum="`${cksum} < ${f}`"
230 if [ "${csum}" = "${s}" ]; then
231 printf '%s: ok\n' "${tid}"
232 else
233 ESTAT=1
234 printf '%s: error: checksum mismatch (got %s)\n' "${tid}" "${csum}"
238 err() {
239 ESTAT=1
240 printf '%s: error: %s\n' ${1} "${2}"
243 ex0_test() {
244 [ $? -ne 0 ] && err $1 'unexpected non-0 exit status'
247 exn0_test() {
248 [ $? -eq 0 ] && err $1 'unexpected 0 exit status'
251 if ( [ "$((1 + 1))" = 2 ] ) >/dev/null 2>&1; then
252 add() {
253 echo "$((${1} + ${2}))"
255 elif command -v expr >/dev/null 2>&1; then
256 add() {
257 echo `expr ${1} + ${2}`
259 else
260 add() {
261 echo `${awk} 'BEGIN{print '${1}' + '${2}'}'`
265 if ( [ "$((2 % 3))" = 2 ] ) >/dev/null 2>&1; then
266 modulo() {
267 echo "$((${1} % ${2}))"
269 elif command -v expr >/dev/null 2>&1; then
270 modulo() {
271 echo `expr ${1} % ${2}`
273 else
274 modulo() {
275 echo `${awk} 'BEGIN{print '${1}' % '${2}'}'`
279 # t_behave()
280 # Basic (easily testable) behaviour tests
281 t_behave() {
282 t_behave_X_opt_input_command_stack
283 t_behave_X_errexit
284 t_behave_wysh
285 t_behave_input_inject_semicolon_seq
286 t_behave_commandalias
287 t_behave_ifelse
288 t_behave_localopts
289 t_behave_macro_param_shift
290 t_behave_addrcodec
291 t_behave_vexpr
292 t_behave_call_ret
293 t_behave_xcall
294 t_behave_vpospar
296 t_behave_mbox
298 t_behave_alternates
299 t_behave_alias
300 # FIXME t_behave_mlist
301 t_behave_filetype
303 t_behave_record_a_resend
305 t_behave_e_H_L_opts
306 t_behave_compose_hooks
307 t_behave_message_injections
308 t_behave_mime_types_load_control
310 t_behave_smime
312 t_behave_maildir
313 t_behave_mass_recipients
316 t_behave_X_opt_input_command_stack() {
317 t_prolog
319 ${cat} <<- '__EOT' > "${BODY}"
320 echo 1
321 define mac0 {
322 echo mac0-1 via1 $0
324 call mac0
325 echo 2
326 source '\
327 echo "define mac1 {";\
328 echo " echo mac1-1 via1 \$0";\
329 echo " call mac0";\
330 echo " echo mac1-2";\
331 echo " call mac2";\
332 echo " echo mac1-3";\
333 echo "}";\
334 echo "echo 1-1";\
335 echo "define mac2 {";\
336 echo " echo mac2-1 via1 \$0";\
337 echo " call mac0";\
338 echo " echo mac2-2";\
339 echo "}";\
340 echo "echo 1-2";\
341 echo "call mac1";\
342 echo "echo 1-3";\
343 echo "source \"\
344 echo echo 1-1-1 via1 \$0;\
345 echo call mac0;\
346 echo echo 1-1-2;\
347 | \"";\
348 echo "echo 1-4";\
350 echo 3
351 call mac2
352 echo 4
353 undefine *
354 __EOT
356 # The -X option supports multiline arguments, and those can internally use
357 # reverse solidus newline escaping. And all -X options are joined...
358 APO=\'
359 < "${BODY}" ${MAILX} ${ARGS} \
360 -X 'e\' \
361 -X ' c\' \
362 -X ' h\' \
363 -X ' o \' \
364 -X 1 \
366 define mac0 {
367 echo mac0-1 via2 $0
369 call mac0
370 echo 2
373 source '${APO}'\
374 echo "define mac1 {";\
375 echo " echo mac1-1 via2 \$0";\
376 echo " call mac0";\
377 echo " echo mac1-2";\
378 echo " call mac2";\
379 echo " echo mac1-3";\
380 echo "}";\
381 echo "echo 1-1";\
382 echo "define mac2 {";\
383 echo " echo mac2-1 via2 \$0";\
384 echo " call mac0";\
385 echo " echo mac2-2";\
386 echo "}";\
387 echo "echo 1-2";\
388 echo "call mac1";\
389 echo "echo 1-3";\
390 echo "source \"\
391 echo echo 1-1-1 via2 \$0;\
392 echo call mac0;\
393 echo echo 1-1-2;\
394 | \"";\
395 echo "echo 1-4";\
396 | '${APO}'
397 echo 3
400 call mac2
401 echo 4
402 undefine *
403 ' > "${MBOX}"
405 check behave:x_opt_input_command_stack 0 "${MBOX}" '1786542668 416'
407 t_epilog
410 t_behave_X_errexit() {
411 t_prolog
413 ${cat} <<- '__EOT' > "${BODY}"
414 echo one
415 echos nono
416 echo two
417 __EOT
419 </dev/null ${MAILX} ${ARGS} -Snomemdebug \
420 -X'echo one' -X' echos nono ' -X'echo two' \
421 > "${MBOX}" 2>&1
422 check behave:x_errexit-1 0 "${MBOX}" '916157812 53'
424 </dev/null ${MAILX} ${ARGS} -X'source '"${BODY}" -Snomemdebug \
425 > "${MBOX}" 2>&1
426 check behave:x_errexit-2 0 "${MBOX}" '916157812 53'
428 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Snomemdebug \
429 > "${MBOX}" 2>&1
430 check behave:x_errexit-3 0 "${MBOX}" '916157812 53'
434 </dev/null ${MAILX} ${ARGS} -Serrexit -Snomemdebug \
435 -X'echo one' -X' echos nono ' -X'echo two' \
436 > "${MBOX}" 2>&1
437 check behave:x_errexit-4 1 "${MBOX}" '2118430867 49'
439 </dev/null ${MAILX} ${ARGS} -X'source '"${BODY}" -Serrexit -Snomemdebug \
440 > "${MBOX}" 2>&1
441 check behave:x_errexit-5 1 "${MBOX}" '2118430867 49'
443 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Serrexit -Snomemdebug \
444 > "${MBOX}" 2>&1
445 check behave:x_errexit-6 1 "${MBOX}" '12955965 172'
447 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Sposix -Snomemdebug \
448 > "${MBOX}" 2>&1
449 check behave:x_errexit-7 1 "${MBOX}" '12955965 172'
451 ## Repeat 4-7 with ignerr set
453 ${sed} -e 's/^echos /ignerr echos /' < "${BODY}" > "${MBOX}"
455 </dev/null ${MAILX} ${ARGS} -Serrexit -Snomemdebug \
456 -X'echo one' -X'ignerr echos nono ' -X'echo two' \
457 > "${BODY}" 2>&1
458 check behave:x_errexit-8 0 "${BODY}" '916157812 53'
460 </dev/null ${MAILX} ${ARGS} -X'source '"${MBOX}" -Serrexit -Snomemdebug \
461 > "${BODY}" 2>&1
462 check behave:x_errexit-9 0 "${BODY}" '916157812 53'
464 </dev/null MAILRC="${MBOX}" ${MAILX} ${ARGS} -:u -Serrexit -Snomemdebug \
465 > "${BODY}" 2>&1
466 check behave:x_errexit-10 0 "${BODY}" '916157812 53'
468 </dev/null MAILRC="${MBOX}" ${MAILX} ${ARGS} -:u -Sposix -Snomemdebug \
469 > "${BODY}" 2>&1
470 check behave:x_errexit-11 0 "${BODY}" '916157812 53'
472 t_epilog
475 t_behave_wysh() {
476 t_prolog
478 ${cat} <<- '__EOT' > "${BODY}"
480 echo abcd
481 echo a'b'c'd'
482 echo a"b"c"d"
483 echo a$'b'c$'d'
484 echo 'abcd'
485 echo "abcd"
486 echo $'abcd'
487 echo a\ b\ c\ d
488 echo a 'b c' d
489 echo a "b c" d
490 echo a $'b c' d
492 echo 'a$`"\'
493 echo "a\$\`'\"\\"
494 echo $'a\$`\'\"\\'
495 echo $'a\$`\'"\\'
496 # DIET=CURD TIED=
497 echo 'a${DIET}b${TIED}c\${DIET}d\${TIED}e' # COMMENT
498 echo "a${DIET}b${TIED}c\${DIET}d\${TIED}e"
499 echo $'a${DIET}b${TIED}c\${DIET}d\${TIED}e'
501 echo a$'\101\0101\x41\u0041\u41\U00000041\U41'c
502 echo a$'\u0041\u41\u0C1\U00000041\U41'c
503 echo a$'\377'c
504 echo a$'\0377'c
505 echo a$'\400'c
506 echo a$'\0400'c
507 echo a$'\U1100001'c
509 echo a$'b\0c'd
510 echo a$'b\00c'de
511 echo a$'b\000c'df
512 echo a$'b\0000c'dg
513 echo a$'b\x0c'dh
514 echo a$'b\x00c'di
515 echo a$'b\u0'dj
516 echo a$'b\u00'dk
517 echo a$'b\u000'dl
518 echo a$'b\u0000'dm
519 echo a$'b\U0'dn
520 echo a$'b\U00'do
521 echo a$'b\U000'dp
522 echo a$'b\U0000'dq
523 echo a$'b\U00000'dr
524 echo a$'b\U000000'ds
525 echo a$'b\U0000000'dt
526 echo a$'b\U00000000'du
528 echo a$'\cI'b
529 echo a$'\011'b
530 echo a$'\x9'b
531 echo a$'\u9'b
532 echo a$'\U9'b
533 echo a$'\c@'b c d
534 __EOT
536 if [ -z "${UTF8_LOCALE}" ]; then
537 echo 'Skip behave:wysh_unicode, no UTF8_LOCALE'
538 else
539 < "${BODY}" DIET=CURD TIED= \
540 LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} 2>/dev/null > "${MBOX}"
541 check behave:wysh_unicode 0 "${MBOX}" '475805847 317'
544 < "${BODY}" DIET=CURD TIED= ${MAILX} ${ARGS} > "${MBOX}" 2>/dev/null
545 check behave:wysh_c 0 "${MBOX}" '1473887148 321'
547 t_epilog
550 t_behave_input_inject_semicolon_seq() {
551 t_prolog
553 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
554 define mydeepmac {
555 echon '(mydeepmac)';
557 define mymac {
558 echon this_is_mymac;call mydeepmac;echon ';';
560 echon one';';call mymac;echon two";";call mymac;echo three$';';
561 define mymac {
562 echon this_is_mymac;call mydeepmac;echon ,TOO'!;';
564 echon one';';call mymac;echon two";";call mymac;echo three$';';
565 __EOT
567 check behave:input_inject_semicolon_seq 0 "${MBOX}" '512117110 140'
569 t_epilog
572 t_behave_commandalias() {
573 t_prolog
575 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
576 commandalias echo echo hoho
577 echo stop.
578 commandalias X Xx
579 commandalias Xx XxX
580 commandalias XxX XxXx
581 commandalias XxXx XxXxX
582 commandalias XxXxX XxXxXx
583 commandalias XxXxXx echo huhu
584 commandalias XxXxXxX echo huhu
586 commandalias XxXxXx XxXxXxX
588 uncommandalias echo
589 commandalias XxXxXx echo huhu
591 __EOT
593 check behave:commandalias 0 "${MBOX}" '3694143612 31'
595 t_epilog
598 t_behave_ifelse() {
599 t_prolog
601 # Nestable conditions test
602 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
603 if 0
604 echo 1.err
605 else
606 echo 1.ok
607 endif
608 if 1
609 echo 2.ok
610 else
611 echo 2.err
612 endif
613 if $dietcurd
614 echo 3.err
615 else
616 echo 3.ok
617 endif
618 set dietcurd=yoho
619 if $dietcurd
620 echo 4.ok
621 else
622 echo 4.err
623 endif
624 if $dietcurd == 'yoho'
625 echo 5.ok
626 else
627 echo 5.err
628 endif
629 if $dietcurd @== 'Yoho'
630 echo 5-1.ok
631 else
632 echo 5-1.err
633 endif
634 if $dietcurd == 'Yoho'
635 echo 5-2.err
636 else
637 echo 5-2.ok
638 endif
639 if $dietcurd != 'yoho'
640 echo 6.err
641 else
642 echo 6.ok
643 endif
644 if $dietcurd @!= 'Yoho'
645 echo 6-1.err
646 else
647 echo 6-1.ok
648 endif
649 if $dietcurd != 'Yoho'
650 echo 6-2.ok
651 else
652 echo 6-2.err
653 endif
654 # Nesting
655 if faLse
656 echo 7.err1
657 if tRue
658 echo 7.err2
659 if yEs
660 echo 7.err3
661 else
662 echo 7.err4
663 endif
664 echo 7.err5
665 endif
666 echo 7.err6
667 else
668 echo 7.ok7
669 if YeS
670 echo 7.ok8
671 if No
672 echo 7.err9
673 else
674 echo 7.ok9
675 endif
676 echo 7.ok10
677 else
678 echo 7.err11
679 if yeS
680 echo 7.err12
681 else
682 echo 7.err13
683 endif
684 endif
685 echo 7.ok14
686 endif
687 if r
688 echo 8.ok1
689 if R
690 echo 8.ok2
691 else
692 echo 8.err2
693 endif
694 echo 8.ok3
695 else
696 echo 8.err1
697 endif
698 if s
699 echo 9.err1
700 else
701 echo 9.ok1
702 if S
703 echo 9.err2
704 else
705 echo 9.ok2
706 endif
707 echo 9.ok3
708 endif
709 # `elif'
710 if $dietcurd == 'yohu'
711 echo 10.err1
712 elif $dietcurd == 'yoha'
713 echo 10.err2
714 elif $dietcurd == 'yohe'
715 echo 10.err3
716 elif $dietcurd == 'yoho'
717 echo 10.ok1
718 if $dietcurd == 'yohu'
719 echo 10.err4
720 elif $dietcurd == 'yoha'
721 echo 10.err5
722 elif $dietcurd == 'yohe'
723 echo 10.err6
724 elif $dietcurd == 'yoho'
725 echo 10.ok2
726 if $dietcurd == 'yohu'
727 echo 10.err7
728 elif $dietcurd == 'yoha'
729 echo 10.err8
730 elif $dietcurd == 'yohe'
731 echo 10.err9
732 elif $dietcurd == 'yoho'
733 echo 10.ok3
734 else
735 echo 10.err10
736 endif
737 else
738 echo 10.err11
739 endif
740 else
741 echo 10.err12
742 endif
743 # integer
744 set dietcurd=10
745 if $dietcurd -lt 11
746 echo 11.ok1
747 if $dietcurd -gt 9
748 echo 11.ok2
749 else
750 echo 11.err2
751 endif
752 if $dietcurd -eq 10
753 echo 11.ok3
754 else
755 echo 11.err3
756 endif
757 if $dietcurd -ge 10
758 echo 11.ok4
759 else
760 echo 11.err4
761 endif
762 if $dietcurd -le 10
763 echo 11.ok5
764 else
765 echo 11.err5
766 endif
767 if $dietcurd -ge 11
768 echo 11.err6
769 else
770 echo 11.ok6
771 endif
772 if $dietcurd -le 9
773 echo 11.err7
774 else
775 echo 11.ok7
776 endif
777 else
778 echo 11.err1
779 endif
780 set dietcurd=Abc
781 if $dietcurd < aBd
782 echo 12.ok1
783 if $dietcurd @> abB
784 echo 12.ok2
785 else
786 echo 12.err2
787 endif
788 if $dietcurd @== aBC
789 echo 12.ok3
790 else
791 echo 12.err3
792 endif
793 if $dietcurd @>= AbC
794 echo 12.ok4
795 else
796 echo 12.err4
797 endif
798 if $dietcurd @<= ABc
799 echo 12.ok5
800 else
801 echo 12.err5
802 endif
803 if $dietcurd @>= abd
804 echo 12.err6
805 else
806 echo 12.ok6
807 endif
808 if $dietcurd @<= abb
809 echo 12.err7
810 else
811 echo 12.ok7
812 endif
813 else
814 echo 12.err1
815 endif
816 if $dietcurd < aBc
817 echo 12-1.ok
818 else
819 echo 12-1.err
820 endif
821 if $dietcurd @< aBc
822 echo 12-2.err
823 else
824 echo 12-2.ok
825 endif
826 if $dietcurd > ABc
827 echo 12-3.ok
828 else
829 echo 12-3.err
830 endif
831 if $dietcurd @> ABc
832 echo 12-3.err
833 else
834 echo 12-3.ok
835 endif
836 if $dietcurd @i=% aB
837 echo 13.ok
838 else
839 echo 13.err
840 endif
841 if $dietcurd =% aB
842 echo 13-1.err
843 else
844 echo 13-1.ok
845 endif
846 if $dietcurd @=% bC
847 echo 14.ok
848 else
849 echo 14.err
850 endif
851 if $dietcurd !% aB
852 echo 15-1.ok
853 else
854 echo 15-1.err
855 endif
856 if $dietcurd @!% aB
857 echo 15-2.err
858 else
859 echo 15-2.ok
860 endif
861 if $dietcurd !% bC
862 echo 15-3.ok
863 else
864 echo 15-3.err
865 endif
866 if $dietcurd @!% bC
867 echo 15-4.err
868 else
869 echo 15-4.ok
870 endif
871 if $dietcurd =% Cd
872 echo 16.err
873 else
874 echo 16.ok
875 endif
876 if $dietcurd !% Cd
877 echo 17.ok
878 else
879 echo 17.err
880 endif
881 set diet=abc curd=abc
882 if $diet == $curd
883 echo 18.ok
884 else
885 echo 18.err
886 endif
887 set diet=abc curd=abcd
888 if $diet != $curd
889 echo 19.ok
890 else
891 echo 19.err
892 endif
893 # 1. Shitty grouping capabilities as of today
894 unset diet curd ndefined
895 if [ [ false ] || [ false ] || [ true ] ] && [ [ false ] || [ true ] ] && \
896 [ yes ]
897 echo 20.ok
898 else
899 echo 20.err
900 endif
901 if [ [ [ [ 0 ] || [ 1 ] ] && [ [ 1 ] || [ 0 ] ] ] && [ 1 ] ] && [ yes ]
902 echo 21.ok
903 else
904 echo 21.err
905 endif
906 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] ]
907 echo 22.ok
908 else
909 echo 22.err
910 endif
911 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] ]
912 echo 23.ok
913 else
914 echo 23.err
915 endif
916 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] && [ no ]
917 echo 24.err
918 else
919 echo 24.ok
920 endif
921 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] \
922 && [ no ] || [ yes ]
923 echo 25.ok
924 else
925 echo 25.err
926 endif
927 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
928 echo 26.ok
929 else
930 echo 26.err
931 endif
932 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 0 ] ]
933 echo 27.err
934 else
935 echo 27.ok
936 endif
937 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 0 ] ] && [ 1 ] ] ] && [ 1 ] ]
938 echo 28.err
939 else
940 echo 28.ok
941 endif
942 if [ [ [ [ [ [ [ 0 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
943 echo 29.err
944 else
945 echo 29.ok
946 endif
947 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 0 ]
948 echo 30.err
949 else
950 echo 30.ok
951 endif
952 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 1 ]
953 echo 31.ok
954 else
955 echo 31.err
956 endif
957 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ]
958 echo 32.err
959 else
960 echo 32.ok
961 endif
962 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 1 ]
963 echo 33.ok
964 else
965 echo 33.err
966 endif
967 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 0 ]
968 echo 34.err
969 else
970 echo 34.ok
971 endif
972 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 1 ]
973 echo 35.ok
974 else
975 echo 35.err
976 endif
977 set diet=yo curd=ho
978 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
979 echo 36.err
980 else
981 echo 36.ok
982 endif
983 set ndefined
984 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
985 echo 37.ok
986 else
987 echo 37.err
988 endif
989 # 2. Shitty grouping capabilities as of today
990 unset diet curd ndefined
991 if [ false || false || true ] && [ false || true ] && yes
992 echo 40.ok
993 else
994 echo 40.err
995 endif
996 if [ [ [ 0 || 1 ] && [ 1 || 0 ] ] && 1 ] && [ yes ]
997 echo 41.ok
998 else
999 echo 41.err
1000 endif
1001 if [ 1 || 0 || 0 || 0 ]
1002 echo 42.ok
1003 else
1004 echo 42.err
1005 endif
1006 if [ 1 || 0 || 0 || 0 || [ 1 ] ]
1007 echo 43.ok
1008 else
1009 echo 43.err
1010 endif
1011 if [ 1 || 0 || 0 || 0 || [ 1 ] || 1 ] && no
1012 echo 44.err
1013 else
1014 echo 44.ok
1015 endif
1016 if [ 1 || 0 || 0 || 0 || 1 || [ 1 ] ] && no || [ yes ]
1017 echo 45.ok
1018 else
1019 echo 45.err
1020 endif
1021 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && 1 ] ] && [ 1 ] ]
1022 echo 46.ok
1023 else
1024 echo 46.err
1025 endif
1026 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && [ 1 ] ] ] && 0 ]
1027 echo 47.err
1028 else
1029 echo 47.ok
1030 endif
1031 if [ [ [ [ [ [ [ 1 ] ] && 1 ] && 0 ] && [ 1 ] ] ] && 1 ]
1032 echo 48.err
1033 else
1034 echo 48.ok
1035 endif
1036 if [ [ [ [ [ [ 0 ] && 1 ] && 1 ] && 1 ] ] && 1 ]
1037 echo 49.err
1038 else
1039 echo 49.ok
1040 endif
1041 if 1 || 0 || 0 || 0 && 0
1042 echo 50.err
1043 else
1044 echo 50.ok
1045 endif
1046 if 1 || 0 || 0 || 0 && 1
1047 echo 51.ok
1048 else
1049 echo 51.err
1050 endif
1051 if 0 || 0 || 0 || 1 && 0
1052 echo 52.err
1053 else
1054 echo 52.ok
1055 endif
1056 if 0 || 0 || 0 || 1 && 1
1057 echo 53.ok
1058 else
1059 echo 53.err
1060 endif
1061 if 0 || 0 || 0 || 1 && 0 || 1 && 0
1062 echo 54.err
1063 else
1064 echo 54.ok
1065 endif
1066 if 0 || 0 || 0 || 1 && 0 || 1 && 1
1067 echo 55.ok
1068 else
1069 echo 55.err
1070 endif
1071 set diet=yo curd=ho
1072 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
1073 echo 56.err
1074 else
1075 echo 56.ok
1076 endif
1077 if $diet == 'yo' && $curd == 'ho' && $ndefined
1078 echo 57.err
1079 else
1080 echo 57.ok
1081 endif
1082 set ndefined
1083 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
1084 echo 57.ok
1085 else
1086 echo 57.err
1087 endif
1088 if $diet == 'yo' && $curd == 'ho' && $ndefined
1089 echo 58.ok
1090 else
1091 echo 58.err
1092 endif
1093 if [ [ [ [ [ [ $diet == 'yo' && $curd == 'ho' && $ndefined ] ] ] ] ] ]
1094 echo 59.ok
1095 else
1096 echo 59.err
1097 endif
1098 # Some more en-braced variables
1099 set diet=yo curd=ho
1100 if ${diet} == ${curd}
1101 echo 70.err
1102 else
1103 echo 70.ok
1104 endif
1105 if ${diet} != ${curd}
1106 echo 71.ok
1107 else
1108 echo 71.err
1109 endif
1110 if $diet == ${curd}
1111 echo 72.err
1112 else
1113 echo 72.ok
1114 endif
1115 if ${diet} == $curd
1116 echo 73.err
1117 else
1118 echo 73.ok
1119 endif
1120 # Unary !
1121 if ! 0 && ! ! 1 && ! ! ! ! 2 && 3
1122 echo 80.ok
1123 else
1124 echo 80.err
1125 endif
1126 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ ! 2 ] ] ] && 3
1127 echo 81.ok
1128 else
1129 echo 81.err
1130 endif
1131 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1132 echo 82.ok
1133 else
1134 echo 82.err
1135 endif
1136 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
1137 echo 83.err
1138 else
1139 echo 83.ok
1140 endif
1141 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
1142 echo 84.err
1143 else
1144 echo 84.ok
1145 endif
1146 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1147 echo 85.err
1148 else
1149 echo 85.ok
1150 endif
1151 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1152 echo 86.err
1153 else
1154 echo 86.ok
1155 endif
1156 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] || 3
1157 echo 87.ok
1158 else
1159 echo 87.err
1160 endif
1161 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! ! [ 2 ] ] ] ] ]
1162 echo 88.ok
1163 else
1164 echo 88.err
1165 endif
1166 # Unary !, odd
1167 if ! 0 && ! ! 1 && ! ! ! 0 && 3
1168 echo 90.ok
1169 else
1170 echo 90.err
1171 endif
1172 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ 0 ] ] ] && 3
1173 echo 91.ok
1174 else
1175 echo 91.err
1176 endif
1177 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ [ 0 ] ] ] ] ] && 3
1178 echo 92.ok
1179 else
1180 echo 92.err
1181 endif
1182 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! ! [ ! [ ! 0 ] ] ] ] && ! 3
1183 echo 93.err
1184 else
1185 echo 93.ok
1186 endif
1187 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ ! [ ! [ ! [ ! 0 ] ] ] ] && 3
1188 echo 94.ok
1189 else
1190 echo 94.err
1191 endif
1192 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! ! [ ! [ ! [ ! [ 0 ] ] ] ] ] && 3
1193 echo 95.err
1194 else
1195 echo 95.ok
1196 endif
1197 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! ! 0 ] ] ] ] && 3
1198 echo 96.err
1199 else
1200 echo 96.ok
1201 endif
1202 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ ! 0 ] ] ] ] ] || 3
1203 echo 97.ok
1204 else
1205 echo 97.err
1206 endif
1207 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! [ 0 ] ] ] ] ]
1208 echo 98.ok
1209 else
1210 echo 98.err
1211 endif
1212 __EOT
1214 check behave:if-normal 0 "${MBOX}" '1688759742 719'
1216 if have_feat regex; then
1217 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
1218 set dietcurd=yoho
1219 if $dietcurd =~ '^yo.*'
1220 echo 1.ok
1221 else
1222 echo 1.err
1223 endif
1224 if $dietcurd =~ '^Yo.*'
1225 echo 1-1.err
1226 else
1227 echo 1-1.ok
1228 endif
1229 if $dietcurd @=~ '^Yo.*'
1230 echo 1-2.ok
1231 else
1232 echo 1-2.err
1233 endif
1234 if $dietcurd =~ '^yOho.+'
1235 echo 2.err
1236 else
1237 echo 2.ok
1238 endif
1239 if $dietcurd @!~ '.*Ho$'
1240 echo 3.err
1241 else
1242 echo 3.ok
1243 endif
1244 if $dietcurd !~ '.+yohO$'
1245 echo 4.ok
1246 else
1247 echo 4.err
1248 endif
1249 if [ $dietcurd @i!~ '.+yoho$' ]
1250 echo 5.ok
1251 else
1252 echo 5.err
1253 endif
1254 if ! [ $dietcurd @i=~ '.+yoho$' ]
1255 echo 6.ok
1256 else
1257 echo 6.err
1258 endif
1259 if ! ! [ $dietcurd @i!~ '.+yoho$' ]
1260 echo 7.ok
1261 else
1262 echo 7.err
1263 endif
1264 if ! [ ! [ $dietcurd @i!~ '.+yoho$' ] ]
1265 echo 8.ok
1266 else
1267 echo 8.err
1268 endif
1269 if [ ! [ ! [ $dietcurd @i!~ '.+yoho$' ] ] ]
1270 echo 9.ok
1271 else
1272 echo 9.err
1273 endif
1274 if ! [ ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
1275 echo 10.err
1276 else
1277 echo 10.ok
1278 endif
1279 if ! ! ! $dietcurd !~ '.+yoho$'
1280 echo 11.err
1281 else
1282 echo 11.ok
1283 endif
1284 if ! ! ! $dietcurd =~ '.+yoho$'
1285 echo 12.ok
1286 else
1287 echo 12.err
1288 endif
1289 if ! [ ! ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
1290 echo 13.ok
1291 else
1292 echo 13.err
1293 endif
1294 set diet=abc curd='^abc$'
1295 if $diet =~ $curd
1296 echo 14.ok
1297 else
1298 echo 14.err
1299 endif
1300 set diet=abc curd='^abcd$'
1301 if $diet !~ $curd
1302 echo 15.ok
1303 else
1304 echo 15.err
1305 endif
1306 __EOT
1308 check behave:if-regex 0 "${MBOX}" '1115671789 95'
1309 else
1310 printf 'behave:if-regex: unsupported, skipped\n'
1313 t_epilog
1316 t_behave_localopts() {
1317 t_prolog
1319 # Nestable conditions test
1320 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
1321 define t2 {
1322 echo in: t2
1323 set t2=t2
1324 echo $t2
1326 define t1 {
1327 echo in: t1
1328 set gv1=gv1
1329 localopts on
1330 set lv1=lv1 lv2=lv2
1331 set lv3=lv3
1332 call t2
1333 localopts off
1334 set gv2=gv2
1335 echo $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2
1337 define t0 {
1338 echo in: t0
1339 call t1
1340 echo $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2
1341 echo "$gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2"
1343 account trouble {
1344 echo in: trouble
1345 call t0
1347 call t0
1348 unset gv1 gv2
1349 account trouble
1350 echo active trouble: $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t3
1351 account null
1352 echo active null: $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t3
1353 __EOT
1355 check behave:localopts 0 "${MBOX}" '1936527193 192'
1357 t_epilog
1360 t_behave_macro_param_shift() {
1361 t_prolog
1363 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>/dev/null
1364 define t2 {
1365 echo in: t2
1366 echo t2.0 has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1367 localopts on
1368 wysh set ignerr=$1
1369 shift
1370 localopts off
1371 echo t2.1 has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1372 if [ $# > 1 ] || [ $ignerr == '' ]
1373 shift 2
1374 else
1375 ignerr shift 2
1376 endif
1377 echo t2.2:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1378 shift 0
1379 echo t2.3:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1380 if [ $# > 0 ]
1381 shift
1382 endif
1383 echo t2.4:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1385 define t1 {
1386 set errexit
1387 echo in: t1
1388 call t2 1 you get four args
1389 echo t1.1: $?';' ignerr ($ignerr) should not exist
1390 call t2 1 you get 'three args'
1391 echo t1.2: $?';' ignerr ($ignerr) should not exist
1392 call t2 1 you 'get two args'
1393 echo t1.3: $?';' ignerr ($ignerr) should not exist
1394 call t2 1 'you get one arg'
1395 echo t1.4: $?';' ignerr ($ignerr) should not exist
1396 ignerr call t2 '' 'you get one arg'
1397 echo t1.5: $?';' ignerr ($ignerr) should not exist
1399 call t1
1400 __EOT
1402 check behave:macro_param_shift 0 "${MBOX}" '1402489146 1682'
1404 t_epilog
1407 t_behave_addrcodec() {
1408 t_prolog
1410 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
1411 vput addrcodec res e 1 <doog@def>
1412 echo $?/$^ERRNAME $res
1413 eval vput addrcodec res d $res
1414 echo $?/$^ERRNAME $res
1415 vput addrcodec res e 2 . <doog@def>
1416 echo $?/$^ERRNAME $res
1417 eval vput addrcodec res d $res
1418 echo $?/$^ERRNAME $res
1419 vput addrcodec res e 3 Sauer Dr. <doog@def>
1420 echo $?/$^ERRNAME $res
1421 eval vput addrcodec res d $res
1422 echo $?/$^ERRNAME $res
1423 vput addrcodec res e 3.50 Sauer (Ma) Dr. <doog@def>
1424 echo $?/$^ERRNAME $res
1425 eval vput addrcodec res d $res
1426 echo $?/$^ERRNAME $res
1427 vput addrcodec res e 3.51 Sauer (Ma) "Dr." <doog@def>
1428 echo $?/$^ERRNAME $res
1429 eval vput addrcodec res d $res
1430 echo $?/$^ERRNAME $res
1432 vput addrcodec res +e 4 Sauer (Ma) Dr. <doog@def>
1433 echo $?/$^ERRNAME $res
1434 eval vput addrcodec res d $res
1435 echo $?/$^ERRNAME $res
1436 vput addrcodec res +e 5 Sauer (Ma) Braten Dr. <doog@def>
1437 echo $?/$^ERRNAME $res
1438 eval vput addrcodec res d $res
1439 echo $?/$^ERRNAME $res
1440 vput addrcodec res +e 6 Sauer (Ma) Braten Dr. (Heu) <doog@def>
1441 echo $?/$^ERRNAME $res
1442 eval vput addrcodec res d $res
1443 echo $?/$^ERRNAME $res
1444 vput addrcodec res +e 7 Sauer (Ma) Braten Dr. (Heu) <doog@def> (bu)
1445 echo $?/$^ERRNAME $res
1446 eval vput addrcodec res d $res
1447 echo $?/$^ERRNAME $res
1448 vput addrcodec res +e 8 \
1449 Dr. Sauer (Ma) Braten Dr. (Heu) <doog@def> (bu) Boom. Boom
1450 echo $?/$^ERRNAME $res
1451 eval vput addrcodec res d $res
1452 echo $?/$^ERRNAME $res
1453 vput addrcodec res +e 9 Dr.Sauer(Ma)Braten Dr. (Heu) <doog@def>
1454 echo $?/$^ERRNAME $res
1455 eval vput addrcodec res d $res
1456 echo $?/$^ERRNAME $res
1457 vput addrcodec res +e 10 (Ma)Braten Dr. (Heu) <doog@def>
1458 echo $?/$^ERRNAME $res
1459 eval vput addrcodec res d $res
1460 echo $?/$^ERRNAME $res
1461 vput addrcodec res +e 11 (Ma)Braten Dr"." (Heu) <doog@def>
1462 echo $?/$^ERRNAME $res
1463 eval vput addrcodec res d $res
1464 echo $?/$^ERRNAME $res
1465 vput addrcodec res +e 12 Dr. Sauer (Ma) Braten Dr. (u) <doog@def>
1466 echo $?/$^ERRNAME $res
1467 eval vput addrcodec res d $res
1468 echo $?/$^ERRNAME $res
1469 vput addrcodec res +e 13(Ma)Braten Dr. (Heu) <doog@def>
1470 echo $?/$^ERRNAME $res
1471 eval vput addrcodec res d $res
1472 echo $?/$^ERRNAME $res
1473 vput addrcodec res +e 14 Hey, Du <doog@def> Wie() findet Dr. das? ()
1474 echo $?/$^ERRNAME $res
1475 eval vput addrcodec res d $res
1476 echo $?/$^ERRNAME $res
1477 vput addrcodec res +e 15 \
1478 Hey, Du <doog@def> Wie() findet "" Dr. "" das? ()
1479 echo $?/$^ERRNAME $res
1480 eval vput addrcodec res d $res
1481 echo $?/$^ERRNAME $res
1482 vput addrcodec res +e 16 \
1483 "Hey," "Du" <doog@def> "Wie()" findet "" Dr. "" das? ()
1484 echo $?/$^ERRNAME $res
1485 eval vput addrcodec res d $res
1486 echo $?/$^ERRNAME $res
1487 vput addrcodec res +e 17 \
1488 "Hey" Du <doog@def> "Wie() findet " " Dr. """ das? ()
1489 echo $?/$^ERRNAME $res
1490 eval vput addrcodec res d $res
1491 echo $?/$^ERRNAME $res
1492 vput addrcodec res +e 18 \
1493 <doog@def> "Hey" Du "Wie() findet " " Dr. """ das? ()
1494 echo $?/$^ERRNAME $res
1495 eval vput addrcodec res d $res
1496 echo $?/$^ERRNAME $res
1497 vput addrcodec res +e 19 Hey\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1498 echo $?/$^ERRNAME $res
1499 eval vput addrcodec res d $res
1500 echo $?/$^ERRNAME $res
1502 vput addrcodec res ++e 20 Hey\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1503 echo $?/$^ERRNAME $res
1504 vput addrcodec res ++e 21 Hey\,\"" <doog@def> "Wie()" findet \" Dr. \" das?
1505 echo $?/$^ERRNAME $res
1506 eval vput addrcodec res d $res
1507 echo $?/$^ERRNAME $res
1509 vput addrcodec res +++e 22 Hey\\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1510 echo $?/$^ERRNAME $res
1511 eval vput addrcodec res d $res
1512 echo $?/$^ERRNAME $res
1514 vput addrcodec res s \
1515 "23 Hey\\,\\\" \"Wie" () "\" findet \\\" Dr. \\\" das?" <doog@def>
1516 echo $?/$^ERRNAME $res
1517 __EOT
1519 check behave:addrcodec 0 "${MBOX}" '429099645 2414'
1521 t_epilog
1524 t_behave_vexpr() {
1525 t_prolog
1527 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>/dev/null
1528 vput vexpr res = 9223372036854775807
1529 echo $?/$^ERRNAME $res
1530 vput vexpr res = 9223372036854775808
1531 echo $?/$^ERRNAME $res
1532 vput vexpr res =@ 9223372036854775808
1533 echo $?/$^ERRNAME $res
1534 vput vexpr res = -9223372036854775808
1535 echo $?/$^ERRNAME $res
1536 vput vexpr res = -9223372036854775809
1537 echo $?/$^ERRNAME $res
1538 vput vexpr res =@ -9223372036854775809
1539 echo $?/$^ERRNAME $res
1540 echo ' #1'
1541 vput vexpr res ~ 0
1542 echo $?/$^ERRNAME $res
1543 vput vexpr res ~ 1
1544 echo $?/$^ERRNAME $res
1545 vput vexpr res ~ -1
1546 echo $?/$^ERRNAME $res
1547 echo ' #2'
1548 vput vexpr res + 0 0
1549 echo $?/$^ERRNAME $res
1550 vput vexpr res + 0 1
1551 echo $?/$^ERRNAME $res
1552 vput vexpr res + 1 1
1553 echo $?/$^ERRNAME $res
1554 echo ' #3'
1555 vput vexpr res + 9223372036854775807 0
1556 echo $?/$^ERRNAME $res
1557 vput vexpr res + 9223372036854775807 1
1558 echo $?/$^ERRNAME $res
1559 vput vexpr res +@ 9223372036854775807 1
1560 echo $?/$^ERRNAME $res
1561 vput vexpr res + 0 9223372036854775807
1562 echo $?/$^ERRNAME $res
1563 vput vexpr res + 1 9223372036854775807
1564 echo $?/$^ERRNAME $res
1565 vput vexpr res +@ 1 9223372036854775807
1566 echo $?/$^ERRNAME $res
1567 echo ' #4'
1568 vput vexpr res + -9223372036854775808 0
1569 echo $?/$^ERRNAME $res
1570 vput vexpr res + -9223372036854775808 -1
1571 echo $?/$^ERRNAME $res
1572 vput vexpr res +@ -9223372036854775808 -1
1573 echo $?/$^ERRNAME $res
1574 vput vexpr res + 0 -9223372036854775808
1575 echo $?/$^ERRNAME $res
1576 vput vexpr res + -1 -9223372036854775808
1577 echo $?/$^ERRNAME $res
1578 vput vexpr res +@ -1 -9223372036854775808
1579 echo $?/$^ERRNAME $res
1580 echo ' #5'
1581 vput vexpr res - 0 0
1582 echo $?/$^ERRNAME $res
1583 vput vexpr res - 0 1
1584 echo $?/$^ERRNAME $res
1585 vput vexpr res - 1 1
1586 echo $?/$^ERRNAME $res
1587 echo ' #6'
1588 vput vexpr res - 9223372036854775807 0
1589 echo $?/$^ERRNAME $res
1590 vput vexpr res - 9223372036854775807 -1
1591 echo $?/$^ERRNAME $res
1592 vput vexpr res -@ 9223372036854775807 -1
1593 echo $?/$^ERRNAME $res
1594 vput vexpr res - 0 9223372036854775807
1595 echo $?/$^ERRNAME $res
1596 vput vexpr res - -1 9223372036854775807
1597 echo $?/$^ERRNAME $res
1598 vput vexpr res - -2 9223372036854775807
1599 echo $?/$^ERRNAME $res
1600 vput vexpr res -@ -2 9223372036854775807
1601 echo $?/$^ERRNAME $res
1602 echo ' #7'
1603 vput vexpr res - -9223372036854775808 +0
1604 echo $?/$^ERRNAME $res
1605 vput vexpr res - -9223372036854775808 +1
1606 echo $?/$^ERRNAME $res
1607 vput vexpr res -@ -9223372036854775808 +1
1608 echo $?/$^ERRNAME $res
1609 vput vexpr res - 0 -9223372036854775808
1610 echo $?/$^ERRNAME $res
1611 vput vexpr res - +1 -9223372036854775808
1612 echo $?/$^ERRNAME $res
1613 vput vexpr res -@ +1 -9223372036854775808
1614 echo $?/$^ERRNAME $res
1615 echo ' #8'
1616 vput vexpr res + -13 -2
1617 echo $?/$^ERRNAME $res
1618 vput vexpr res - 0 0
1619 echo $?/$^ERRNAME $res
1620 vput vexpr res - 0 1
1621 echo $?/$^ERRNAME $res
1622 vput vexpr res - 1 1
1623 echo $?/$^ERRNAME $res
1624 vput vexpr res - -13 -2
1625 echo $?/$^ERRNAME $res
1626 echo ' #9'
1627 vput vexpr res * 0 0
1628 echo $?/$^ERRNAME $res
1629 vput vexpr res * 0 1
1630 echo $?/$^ERRNAME $res
1631 vput vexpr res * 1 1
1632 echo $?/$^ERRNAME $res
1633 vput vexpr res * -13 -2
1634 echo $?/$^ERRNAME $res
1635 echo ' #10'
1636 vput vexpr res / 0 0
1637 echo $?/$^ERRNAME $res
1638 vput vexpr res / 0 1
1639 echo $?/$^ERRNAME $res
1640 vput vexpr res / 1 1
1641 echo $?/$^ERRNAME $res
1642 vput vexpr res / -13 -2
1643 echo $?/$^ERRNAME $res
1644 echo ' #11'
1645 vput vexpr res % 0 0
1646 echo $?/$^ERRNAME $res
1647 vput vexpr res % 0 1
1648 echo $?/$^ERRNAME $res
1649 vput vexpr res % 1 1
1650 echo $?/$^ERRNAME $res
1651 vput vexpr res % -13 -2
1652 echo $?/$^ERRNAME $res
1653 __EOT
1655 check behave:vexpr-numeric 0 "${MBOX}" '1723609217 1048'
1657 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" #2>/dev/null
1658 vput vexpr res find 'bananarama' 'nana'
1659 echo $?/$^ERRNAME :$res:
1660 vput vexpr res find 'bananarama' 'bana'
1661 echo $?/$^ERRNAME :$res:
1662 vput vexpr res find 'bananarama' 'Bana'
1663 echo $?/$^ERRNAME :$res:
1664 vput vexpr res find 'bananarama' 'rama'
1665 echo $?/$^ERRNAME :$res:
1666 echo ' #1'
1667 vput vexpr res ifind 'bananarama' 'nana'
1668 echo $?/$^ERRNAME :$res:
1669 vput vexpr res ifind 'bananarama' 'bana'
1670 echo $?/$^ERRNAME :$res:
1671 vput vexpr res ifind 'bananarama' 'Bana'
1672 echo $?/$^ERRNAME :$res:
1673 vput vexpr res ifind 'bananarama' 'rama'
1674 echo $?/$^ERRNAME :$res:
1675 echo ' #2'
1676 vput vexpr res substring 'bananarama' 1
1677 echo $?/$^ERRNAME :$res:
1678 vput vexpr res substring 'bananarama' 3
1679 echo $?/$^ERRNAME :$res:
1680 vput vexpr res substring 'bananarama' 5
1681 echo $?/$^ERRNAME :$res:
1682 vput vexpr res substring 'bananarama' 7
1683 echo $?/$^ERRNAME :$res:
1684 vput vexpr res substring 'bananarama' 9
1685 echo $?/$^ERRNAME :$res:
1686 vput vexpr res substring 'bananarama' 10
1687 echo $?/$^ERRNAME :$res:
1688 vput vexpr res substring 'bananarama' 1 3
1689 echo $?/$^ERRNAME :$res:
1690 vput vexpr res substring 'bananarama' 3 3
1691 echo $?/$^ERRNAME :$res:
1692 vput vexpr res substring 'bananarama' 5 3
1693 echo $?/$^ERRNAME :$res:
1694 vput vexpr res substring 'bananarama' 7 3
1695 echo $?/$^ERRNAME :$res:
1696 vput vexpr res substring 'bananarama' 9 3
1697 echo $?/$^ERRNAME :$res:
1698 vput vexpr res substring 'bananarama' 10 3
1699 echo $?/$^ERRNAME :$res:
1700 echo ' #3'
1701 __EOT
1703 check behave:vexpr-string 0 "${MBOX}" '265398700 267'
1705 if have_feat regex; then
1706 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" #2>/dev/null
1707 vput vexpr res regex 'bananarama' 'nana'
1708 echo $?/$^ERRNAME :$res:
1709 vput vexpr res regex 'bananarama' 'bana'
1710 echo $?/$^ERRNAME :$res:
1711 vput vexpr res regex 'bananarama' 'Bana'
1712 echo $?/$^ERRNAME :$res:
1713 vput vexpr res regex 'bananarama' 'rama'
1714 echo $?/$^ERRNAME :$res:
1715 echo ' #1'
1716 vput vexpr res iregex 'bananarama' 'nana'
1717 echo $?/$^ERRNAME :$res:
1718 vput vexpr res iregex 'bananarama' 'bana'
1719 echo $?/$^ERRNAME :$res:
1720 vput vexpr res iregex 'bananarama' 'Bana'
1721 echo $?/$^ERRNAME :$res:
1722 vput vexpr res iregex 'bananarama' 'rama'
1723 echo $?/$^ERRNAME :$res:
1724 echo ' #2'
1725 vput vexpr res regex 'bananarama' '(.*)nana(.*)' '\${1}a\${0}u{\$2}'
1726 echo $?/$^ERRNAME :$res:
1727 vput vexpr res regex 'bananarama' '(.*)bana(.*)' '\${1}a\${0}u\$2'
1728 echo $?/$^ERRNAME :$res:
1729 vput vexpr res regex 'bananarama' 'Bana(.+)' '\$1\$0'
1730 echo $?/$^ERRNAME :$res:
1731 vput vexpr res regex 'bananarama' '(.+)rama' '\$1\$0'
1732 echo $?/$^ERRNAME :$res:
1733 echo ' #3'
1734 vput vexpr res iregex 'bananarama' '(.*)nana(.*)' '\${1}a\${0}u{\$2}'
1735 echo $?/$^ERRNAME :$res:
1736 vput vexpr res iregex 'bananarama' '(.*)bana(.*)' '\${1}a\${0}u\$2'
1737 echo $?/$^ERRNAME :$res:
1738 vput vexpr res iregex 'bananarama' 'Bana(.+)' '\$1\$0'
1739 echo $?/$^ERRNAME :$res:
1740 vput vexpr res iregex 'bananarama' '(.+)rama' '\$1\$0'
1741 echo $?/$^ERRNAME :$res:
1742 echo ' #4'
1743 __EOT
1745 check behave:vexpr-regex 0 "${MBOX}" '3270360157 311'
1746 else
1747 printf 'behave:vexpr-regex: unsupported, skipped\n'
1750 t_epilog
1753 t_behave_call_ret() {
1754 t_prolog
1756 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Snomemdebug > "${MBOX}" 2>&1
1757 define w1 {
1758 echon ">$1 "
1759 vput vexpr i + $1 1
1760 if [ $i -le 42 ]
1761 vput vexpr j '&' $i 7
1762 if [ $j -eq 7 ]
1763 echo .
1765 call w1 $i
1766 wysh set i=$? k=$!
1767 vput vexpr j '&' $i 7
1768 echon "<$1/$i/$k "
1769 if [ $j -eq 7 ]
1770 echo .
1772 else
1773 echo ! The end for $1
1775 return $1
1777 # Transport $?/$! up the call chain
1778 define w2 {
1779 echon ">$1 "
1780 vput vexpr i + $1 1
1781 if [ $1 -lt 42 ]
1782 call w2 $i
1783 wysh set i=$? j=$! k=$^ERRNAME
1784 echon "<$1/$i/$k "
1785 return $i $j
1786 else
1787 echo ! The end for $1
1788 return $i $^ERR-BUSY
1790 echoerr au
1792 # Up and down it goes
1793 define w3 {
1794 echon ">$1/$2 "
1795 vput vexpr i + $1 1
1796 if [ $1 -lt 42 ]
1797 call w3 $i $2
1798 wysh set i=$? j=$!
1799 vput vexpr k - $1 $2
1800 if [ $k -eq 21 ]
1801 vput vexpr i + $1 1
1802 vput vexpr j + $2 1
1803 echo "# <$i/$j> .. "
1804 call w3 $i $j
1805 wysh set i=$? j=$!
1807 eval echon "<\$1=\$i/\$^ERRNAME-$j "
1808 return $i $j
1809 else
1810 echo ! The end for $1=$i/$2
1811 if [ "$2" != "" ]
1812 return $i $^ERR-DOM
1813 else
1814 return $i $^ERR-BUSY
1817 echoerr au
1820 call w1 0; echo ?=$? !=$!; echo -----;
1821 call w2 0; echo ?=$? !=$^ERRNAME; echo -----;
1822 call w3 0 1; echo ?=$? !=$^ERRNAME; echo -----;
1823 __EOT
1825 check behave:call_ret 0 "${MBOX}" '1572045517 5922'
1827 t_epilog
1830 t_behave_xcall() {
1831 t_prolog
1833 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Snomemdebug > "${MBOX}" 2>&1
1834 define work {
1835 echon "$1 "
1836 vput vexpr i + $1 1
1837 if [ $i -le 1111 ]
1838 vput vexpr j '&' $i 7
1839 if [ $j -eq 7 ]
1840 echo .
1842 \xcall work $i $2
1844 echo ! The end for $1/$2
1845 if [ "$2" != "" ]
1846 return $i $^ERR-BUSY
1849 define xwork {
1850 \xcall work 0 $2
1852 call work 0
1853 echo ?=$? !=$!
1854 call xwork
1855 echo ?=$? !=$!
1856 xcall xwork
1857 echo ?=$? !=$^ERRNAME
1859 call work 0 yes
1860 echo ?=$? !=$^ERRNAME
1861 call xwork 0 yes
1862 echo ?=$? !=$^ERRNAME
1863 __EOT
1865 check behave:xcall-1 0 "${MBOX}" '2401702082 23801'
1869 ${cat} <<- '__EOT' > "${BODY}"
1870 define __w {
1871 echon "$1 "
1872 vput vexpr i + $1 1
1873 if [ $i -le 111 ]
1874 vput vexpr j '&' $i 7
1875 if [ $j -eq 7 ]
1876 echo .
1878 \xcall __w $i $2
1880 echo ! The end for $1
1881 if [ $2 -eq 0 ]
1882 nonexistingcommand
1883 echo would be err with errexit
1884 return
1886 echo calling exit
1887 exit
1889 define work {
1890 echo eins
1891 call __w 0 0
1892 echo zwei, ?=$? !=$!
1893 localopts yes; set errexit
1894 ignerr call __w 0 0
1895 echo drei, ?=$? !=$^ERRNAME
1896 call __w 0 $1
1897 echo vier, ?=$? !=$^ERRNAME, this is an error
1899 ignerr call work 0
1900 echo outer 1, ?=$? !=$^ERRNAME
1901 xxxign call work 0
1902 echo outer 2, ?=$? !=$^ERRNAME, could be error if xxxign non-empty
1903 call work 1
1904 echo outer 3, ?=$? !=$^ERRNAME
1905 echo this is definitely an error
1906 __EOT
1908 < "${BODY}" ${MAILX} ${ARGS} -X'commandalias xxxign ignerr' -Snomemdebug \
1909 > "${MBOX}" 2>&1
1910 check behave:xcall-2 0 "${MBOX}" '3900716531 4200'
1912 < "${BODY}" ${MAILX} ${ARGS} -X'commandalias xxxign " "' -Snomemdebug \
1913 > "${MBOX}" 2>&1
1914 check behave:xcall-3 1 "${MBOX}" '1006776201 2799'
1916 t_epilog
1919 t_behave_vpospar() {
1920 t_prolog
1922 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
1923 vpospar set hey, "'you ", world!
1924 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1925 vput vpospar x quote; echo x<$x>
1926 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1927 vput vpospar y quote;echo y<$y>
1928 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1929 eval vpospar set ${y};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1930 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1932 define infun2 {
1933 echo infun2:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
1934 vput vpospar z quote;echo infun2:z<$z>
1937 define infun {
1938 echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
1939 vput vpospar y quote;echo infun:y<$y>
1940 eval vpospar set ${x};echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
1941 vpospar clear;echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
1942 eval call infun2 $x
1943 echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
1944 eval vpospar set ${y};echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
1947 call infun This "in a" fun
1948 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1949 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1950 __EOT
1951 check behave:vpospar-1 0 "${MBOX}" '155175639 866'
1954 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
1955 set ifs=\'
1956 echo ifs<$ifs> ifs-ws<$ifs-ws>
1957 vpospar set hey, "'you ", world!
1958 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1959 vput vpospar x quote; echo x<$x>
1960 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1961 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1963 set ifs=,
1964 echo ifs<$ifs> ifs-ws<$ifs-ws>
1965 vpospar set hey, "'you ", world!
1966 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1967 vput vpospar x quote; echo x<$x>
1968 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1969 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1971 wysh set ifs=$',\t'
1972 echo ifs<$ifs> ifs-ws<$ifs-ws>
1973 vpospar set hey, "'you ", world!
1974 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1975 vput vpospar x quote; echo x<$x>
1976 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1977 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1978 __EOT
1979 check behave:vpospar-ifs 0 "${MBOX}" '2015927702 706'
1981 t_epilog
1984 t_behave_read() {
1985 t_prolog
1986 TRAP_EXIT_ADDONS="./.t*"
1988 ${cat} <<- '__EOT' > .tin
1989 hey1, "'you ", world!
1990 hey2, "'you ", bugs bunny!
1991 hey3, "'you ",
1992 hey4, "'you "
1993 __EOT
1995 ${cat} <<- '__EOT' |\
1996 ${MAILX} ${ARGS} -X'readctl create ./.tin' > "${MBOX}" 2>&1
1997 read a b c
1998 echo $?/$^ERRNAME / <$a><$b><$c>
1999 read a b c
2000 echo $?/$^ERRNAME / <$a><$b><$c>
2001 read a b c
2002 echo $?/$^ERRNAME / <$a><$b><$c>
2003 read a b c
2004 echo $?/$^ERRNAME / <$a><$b><$c>
2005 read a b c
2006 echo $?/$^ERRNAME / <$a><$b><$c>
2007 readctl remove ./.tin;echo readctl remove:$?/$^ERRNAME
2008 __EOT
2009 check behave:read-1 0 "${MBOX}" '1527910147 173'
2011 ${cat} <<- '__EOT' > .tin2
2012 hey2.0,:"'you ",:world!:mars.:
2013 hey2.1,:"'you ",:world!
2014 hey2.2,:"'you ",:bugs bunny!
2015 hey2.3,:"'you ",:
2016 hey2.4,:"'you ":
2018 __EOT
2020 ${cat} <<- '__EOT' |\
2021 6< .tin2 ${MAILX} ${ARGS} -X 'readctl create 6' > "${MBOX}" 2>&1
2022 set ifs=:
2023 read a b c
2024 echo $?/$^ERRNAME / <$a><$b><$c>
2025 read a b c
2026 echo $?/$^ERRNAME / <$a><$b><$c>
2027 read a b c
2028 echo $?/$^ERRNAME / <$a><$b><$c>
2029 read a b c
2030 echo $?/$^ERRNAME / <$a><$b><$c>
2031 read a b c
2032 echo $?/$^ERRNAME / <$a><$b><$c>
2033 read a b c
2034 echo $?/$^ERRNAME / <$a><$b><$c>
2035 read a b c
2036 echo $?/$^ERRNAME / <$a><$b><$c>
2037 read a b c
2038 echo $?/$^ERRNAME / <$a><$b><$c>
2039 readctl remove 6;echo readctl remove:$?/$^ERRNAME
2040 __EOT
2041 check behave:read-ifs 0 "${MBOX}" '890153490 298'
2043 t_epilog
2046 t_behave_mbox() {
2047 t_prolog
2048 TRAP_EXIT_ADDONS="./.t*"
2052 while [ ${i} -lt 112 ]; do
2053 printf 'm file://%s\n~s Subject %s\nHello %s!\n~.\n' \
2054 "${MBOX}" "${i}" "${i}"
2055 i=`add ${i} 1`
2056 done
2057 ) | ${MAILX} ${ARGS}
2058 check behave:mbox-1 0 "${MBOX}" '1140119864 13780'
2060 printf 'File "%s"
2061 copy * "%s"
2062 File "%s"
2063 from*
2064 ' "${MBOX}" .tmbox1 .tmbox1 |
2065 ${MAILX} ${ARGS} > .tlst
2066 check behave:mbox-2 0 .tlst '2739893312 9103'
2068 printf 'File "%s"
2069 copy * "file://%s"
2070 File "file://%s"
2071 from*
2072 ' "${MBOX}" .tmbox2 .tmbox2 |
2073 ${MAILX} ${ARGS} > .tlst
2074 check behave:mbox-3 0 .tlst '1702194178 9110'
2076 # only the odd (even)
2078 printf 'File "file://%s"
2079 copy ' .tmbox2
2081 while [ ${i} -lt 112 ]; do
2082 j=`modulo ${i} 2`
2083 [ ${j} -eq 1 ] && printf '%s ' "${i}"
2084 i=`add ${i} 1`
2085 done
2086 printf ' file://%s
2087 File "file://%s"
2088 from*
2089 ' .tmbox3 .tmbox3
2090 ) | ${MAILX} ${ARGS} > .tlst
2091 check behave:mbox-4 0 .tmbox3 '631132924 6890'
2092 check behave:mbox-5 - .tlst '2960975049 4573'
2093 # ...
2095 printf 'file "file://%s"
2096 move ' .tmbox2
2098 while [ ${i} -lt 112 ]; do
2099 j=`modulo ${i} 2`
2100 [ ${j} -eq 0 ] && [ ${i} -ne 0 ] && printf '%s ' "${i}"
2101 i=`add ${i} 1`
2102 done
2103 printf ' file://%s
2104 File "file://%s"
2105 from*
2106 File "file://%s"
2107 from*
2108 ' .tmbox3 .tmbox3 .tmbox2
2109 ) | ${MAILX} ${ARGS} > .tlst
2110 check behave:mbox-6 0 .tmbox3 '1387070539 13655'
2111 ${sed} 2d < .tlst > .tlstx
2112 check behave:mbox-7 - .tlstx '2729940494 13645'
2114 t_epilog
2117 t_behave_alternates() {
2118 t_prolog
2119 TRAP_EXIT_ADDONS="./.t*"
2121 ${cat} <<-_EOT > ./.tsendmail.sh
2122 #!${MYSHELL} -
2123 (echo 'From Valeriana Sat Jul 08 15:54:03 2017' && ${cat} && echo
2124 ) >> "${MBOX}"
2125 _EOT
2126 chmod 0755 ./.tsendmail.sh
2128 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Smta=./.tsendmail.sh > ./.tall 2>&1
2129 echo --0
2130 alternates
2131 echo $?/$^ERRNAME
2132 alternates a1@b1 a2@b2 a3@b3
2133 echo $?/$^ERRNAME
2134 alternates
2135 echo $?/$^ERRNAME
2136 vput alternates rv
2137 echo $?/$^ERRNAME <$rv>
2139 echo --1
2140 unalternates a2@b2
2141 vput alternates rv
2142 echo $?/$^ERRNAME <$rv>
2143 unalternates a3@b3
2144 vput alternates rv
2145 echo $?/$^ERRNAME <$rv>
2146 unalternates a1@b1
2147 vput alternates rv
2148 echo $?/$^ERRNAME <$rv>
2150 echo --2
2151 unalternates *
2152 alternates a1@b1 a2@b2 a3@b3
2153 unalternates a3@b3
2154 vput alternates rv
2155 echo $?/$^ERRNAME <$rv>
2156 unalternates a2@b2
2157 vput alternates rv
2158 echo $?/$^ERRNAME <$rv>
2159 unalternates a1@b1
2160 vput alternates rv
2161 echo $?/$^ERRNAME <$rv>
2163 echo --3
2164 alternates a1@b1 a2@b2 a3@b3
2165 unalternates a1@b1
2166 vput alternates rv
2167 echo $?/$^ERRNAME <$rv>
2168 unalternates a2@b2
2169 vput alternates rv
2170 echo $?/$^ERRNAME <$rv>
2171 unalternates a3@b3
2172 vput alternates rv
2173 echo $?/$^ERRNAME <$rv>
2175 echo --4
2176 unalternates *
2177 alternates a1@b1 a2@b2 a3@b3
2178 unalternates *
2179 vput alternates rv
2180 echo $?/$^ERRNAME <$rv>
2182 echo --5
2183 unalternates *
2184 alternates a1@b1 a1@c1 a1@d1 a2@b2 a3@b3 a3@c3 a3@d3
2185 m a1@b1 a1@c1 a1@d1
2186 ~s all alternates, only a1@b1 remains
2187 ~c a2@b2
2188 ~b a3@b3 a3@c3 a3@d3
2189 ~r - '_EOT'
2190 This body is!
2191 This also body is!!
2192 _EOT
2195 echo --6
2196 unalternates *
2197 alternates a1@b1 a1@c1 a2@b2 a3@b3
2198 m a1@b1 a1@c1 a1@d1
2199 ~s a1@b1 a1@d1, and a3@c3 a3@d3 remain
2200 ~c a2@b2
2201 ~b a3@b3 a3@c3 a3@d3
2202 ~r - '_EOT'
2203 This body2 is!
2204 _EOT
2207 echo --7
2208 alternates a1@b1 a2@b2 a3; set allnet
2209 m a1@b1 a1@c1 a1@d1
2210 ~s all alternates via allnet, only a1@b1 remains
2211 ~c a2@b2
2212 ~b a3@b3 a3@c3 a3@d3
2213 ~r - '_EOT'
2214 This body3 is!
2215 _EOT
2218 echo --10
2219 unalternates *
2220 alternates a1@b1
2221 echo $?/$^ERRNAME
2222 vput alternates rv
2223 echo $?/$^ERRNAME <$rv>
2224 alternates a2@b2
2225 echo $?/$^ERRNAME
2226 vput alternates rv
2227 echo $?/$^ERRNAME <$rv>
2228 alternates a3@b3
2229 echo $?/$^ERRNAME
2230 vput alternates rv
2231 echo $?/$^ERRNAME <$rv>
2232 alternates a4@b4
2233 echo $?/$^ERRNAME
2234 vput alternates rv
2235 echo $?/$^ERRNAME <$rv>
2237 unalternates *
2238 vput alternates rv
2239 echo $?/$^ERRNAME <$rv>
2241 echo --11
2242 set posix
2243 alternates a1@b1 a2@b2
2244 echo $?/$^ERRNAME
2245 vput alternates rv
2246 echo $?/$^ERRNAME <$rv>
2247 alternates a3@b3 a4@b4
2248 echo $?/$^ERRNAME
2249 vput alternates rv
2250 echo $?/$^ERRNAME <$rv>
2251 __EOT
2252 check behave:alternates-1 0 "${MBOX}" '142184864 515'
2253 check behave:alternates-2 - .tall '1878598364 505'
2255 t_epilog
2258 t_behave_alias() {
2259 t_prolog
2260 TRAP_EXIT_ADDONS="./.t*"
2262 ${cat} <<-_EOT > ./.tsendmail.sh
2263 #!${MYSHELL} -
2264 (echo 'From Hippocastanum Mon Jun 19 15:07:07 2017' && ${cat} && echo
2265 ) >> "${MBOX}"
2266 _EOT
2267 chmod 0755 ./.tsendmail.sh
2269 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Smta=./.tsendmail.sh > ./.tall 2>&1
2270 alias a1 ex1@a1.ple
2271 alias a1 ex2@a1.ple "EX3 <ex3@a1.ple>"
2272 alias a1 ex4@a1.ple
2273 alias a2 ex1@a2.ple ex2@a2.ple ex3@a2.ple ex4@a2.ple
2274 alias a3 a4
2275 alias a4 a5 ex1@a4.ple
2276 alias a5 a6
2277 alias a6 a7 ex1@a6.ple
2278 alias a7 a8
2279 alias a8 ex1@a8.ple
2280 alias a1
2281 alias a2
2282 alias a3
2283 m a1
2284 ~c a2
2285 ~b a3
2286 ~r - '_EOT'
2287 This body is!
2288 This also body is!!
2289 _EOT
2290 __EOT
2291 check behave:alias-1 0 "${MBOX}" '2496925843 272'
2292 check behave:alias-2 - .tall '3548953204 152'
2294 # TODO t_behave_alias: n_ALIAS_MAXEXP is compile-time constant,
2295 # TODO need to somehow provide its contents to the test, then test
2297 t_epilog
2300 t_behave_filetype() {
2301 t_prolog
2302 TRAP_EXIT_ADDONS="./.t*"
2304 ${cat} <<-_EOT > ./.tsendmail.sh
2305 #!${MYSHELL} -
2306 (echo 'From Alchemilla Wed Apr 25 15:12:13 2017' && ${cat} && echo
2307 ) >> "${MBOX}"
2308 _EOT
2309 chmod 0755 ./.tsendmail.sh
2311 printf 'm m1@e.t\nL1\nHy1\n~.\nm m2@e.t\nL2\nHy2\n~@ ./snailmail.jpg\n~.\n' |
2312 ${MAILX} ${ARGS} -Smta=./.tsendmail.sh
2313 check behave:filetype-1 0 "${MBOX}" '1645747150 13536'
2315 if command -v gzip >/dev/null 2>&1; then
2316 ${rm} -f ./.t.mbox*
2318 printf 'File "%s"\ncopy 1 ./.t.mbox.gz
2319 copy 2 ./.t.mbox.gz' "${MBOX}" |
2320 ${MAILX} ${ARGS} \
2321 -X'filetype gz gzip\ -dc gzip\ -c'
2322 printf 'File ./.t.mbox.gz\ncopy * ./.t.mbox\n' |
2323 ${MAILX} ${ARGS} \
2324 -X'filetype gz gzip\ -dc gzip\ -c'
2325 } >/dev/null 2>&1
2326 check behave:filetype-2 0 "./.t.mbox" '1645747150 13536'
2327 else
2328 echo 'behave:filetype-2: unsupported, skipped'
2332 ${rm} -f ./.t.mbox*
2333 printf 'File "%s"\ncopy 1 ./.t.mbox.gz
2334 copy 2 ./.t.mbox.gz
2335 copy 1 ./.t.mbox.gz
2336 copy 2 ./.t.mbox.gz
2337 ' "${MBOX}" |
2338 ${MAILX} ${ARGS} \
2339 -X'filetype gz gzip\ -dc gzip\ -c' \
2340 -X'filetype mbox.gz "${sed} 1,3d|${cat}" \
2341 "echo eins;echo zwei;echo und mit ${sed} bist Du dabei;${cat}"'
2342 printf 'File ./.t.mbox.gz\ncopy * ./.t.mbox\n' |
2343 ${MAILX} ${ARGS} \
2344 -X'filetype gz gzip\ -dc gzip\ -c' \
2345 -X'filetype mbox.gz "${sed} 1,3d|${cat}" kill\ 0'
2346 } >/dev/null 2>&1
2348 check behave:filetype-3 - "./.t.mbox" '238021003 27092'
2350 t_epilog
2353 t_behave_record_a_resend() {
2354 t_prolog
2355 TRAP_EXIT_ADDONS="./.t.record ./.t.resent"
2357 printf '
2358 set record=%s
2359 m %s\n~s Subject 1.\nHello.\n~.
2360 set record-files add-file-recipients
2361 m %s\n~s Subject 2.\nHello.\n~.
2362 File %s
2363 resend 2 ./.t.resent
2364 Resend 1 ./.t.resent
2365 set record-resent
2366 resend 2 ./.t.resent
2367 Resend 1 ./.t.resent
2368 ' ./.t.record "${MBOX}" "${MBOX}" "${MBOX}" |
2369 ${MAILX} ${ARGS}
2371 check behave:record_a_resend-1 0 "${MBOX}" '3057873538 256'
2372 check behave:record_a_resend-2 - .t.record '391356429 460'
2373 check behave:record_a_resend-3 - .t.resent '2685231691 648'
2375 t_epilog
2378 t_behave_e_H_L_opts() {
2379 t_prolog
2380 TRAP_EXIT_ADDONS="./.tsendmail.sh ./.t.mbox"
2382 touch ./.t.mbox
2383 ${MAILX} ${ARGS} -ef ./.t.mbox
2384 echo ${?} > "${MBOX}"
2386 ${cat} <<-_EOT > ./.tsendmail.sh
2387 #!${MYSHELL} -
2388 (echo 'From Alchemilla Wed Apr 07 17:03:33 2017' && ${cat} && echo
2389 ) >> "./.t.mbox"
2390 _EOT
2391 chmod 0755 ./.tsendmail.sh
2392 printf 'm me@exam.ple\nLine 1.\nHello.\n~.\n' |
2393 ${MAILX} ${ARGS} -Smta=./.tsendmail.sh
2394 printf 'm you@exam.ple\nLine 1.\nBye.\n~.\n' |
2395 ${MAILX} ${ARGS} -Smta=./.tsendmail.sh
2397 ${MAILX} ${ARGS} -ef ./.t.mbox
2398 echo ${?} >> "${MBOX}"
2399 ${MAILX} ${ARGS} -efL @t@me ./.t.mbox
2400 echo ${?} >> "${MBOX}"
2401 ${MAILX} ${ARGS} -efL @t@you ./.t.mbox
2402 echo ${?} >> "${MBOX}"
2403 ${MAILX} ${ARGS} -efL '@>@Line 1' ./.t.mbox
2404 echo ${?} >> "${MBOX}"
2405 ${MAILX} ${ARGS} -efL '@>@Hello.' ./.t.mbox
2406 echo ${?} >> "${MBOX}"
2407 ${MAILX} ${ARGS} -efL '@>@Bye.' ./.t.mbox
2408 echo ${?} >> "${MBOX}"
2409 ${MAILX} ${ARGS} -efL '@>@Good bye.' ./.t.mbox
2410 echo ${?} >> "${MBOX}"
2412 ${MAILX} ${ARGS} -fH ./.t.mbox >> "${MBOX}"
2413 echo ${?} >> "${MBOX}"
2414 ${MAILX} ${ARGS} -fL @t@me ./.t.mbox >> "${MBOX}"
2415 echo ${?} >> "${MBOX}"
2416 ${MAILX} ${ARGS} -fL @t@you ./.t.mbox >> "${MBOX}"
2417 echo ${?} >> "${MBOX}"
2418 ${MAILX} ${ARGS} -fL '@>@Line 1' ./.t.mbox >> "${MBOX}"
2419 echo ${?} >> "${MBOX}"
2420 ${MAILX} ${ARGS} -fL '@>@Hello.' ./.t.mbox >> "${MBOX}"
2421 echo ${?} >> "${MBOX}"
2422 ${MAILX} ${ARGS} -fL '@>@Bye.' ./.t.mbox >> "${MBOX}"
2423 echo ${?} >> "${MBOX}"
2424 ${MAILX} ${ARGS} -fL '@>@Good bye.' ./.t.mbox >> "${MBOX}" 2>/dev/null
2425 echo ${?} >> "${MBOX}"
2427 check behave:e_H_L_opts - "${MBOX}" '1708955574 678'
2429 t_epilog
2432 t_behave_compose_hooks() { # TODO monster
2433 t_prolog
2434 TRAP_EXIT_ADDONS="./.t*"
2436 (echo line one&&echo line two&&echo line three) > ./.treadctl
2437 (echo echo four&&echo echo five&&echo echo six) > ./.tattach
2439 ${cat} <<-_EOT > ./.tsendmail.sh
2440 #!${MYSHELL} -
2441 (echo 'From PrimulaVeris Wed Apr 10 22:59:00 2017' && ${cat} && echo
2442 ) >> "${MBOX}"
2443 _EOT
2444 chmod 0755 ./.tsendmail.sh
2446 ${cat} <<'__EOT__' > ./.trc
2447 define bail {
2448 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
2450 define xerr {
2451 vput vexpr es substr "$1" 0 1
2452 if [ "$es" != 2 ]
2453 xcall bail "$2"
2456 define read_mline_res {
2457 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
2458 echo $len/$es/$^ERRNAME: $hl
2459 if [ $es -ne $^ERR-NONE ]
2460 xcall bail read_mline_res
2461 elif [ $len -ne 0 ]
2462 \xcall read_mline_res
2465 define ins_addr {
2466 wysh set xh=$1
2467 echo "~^header list"; read hl; echo $hl;\
2468 call xerr "$hl" "in_addr ($xh) 0-1"
2470 echo "~^header insert $xh diet <$xh@exam.ple> spliced";\
2471 read es; echo $es; call xerr "$es" "ins_addr $xh 1-1"
2472 echo "~^header insert $xh <${xh}2@exam.ple>";\
2473 read es; echo $es; call xerr "$es" "ins_addr $xh 1-2"
2474 echo "~^header insert $xh ${xh}3@exam.ple";\
2475 read es; echo $es; call xerr "$es" "ins_addr $xh 1-3"
2476 echo "~^header list $xh"; read hl; echo $hl;\
2477 call xerr "$hl" "ins_addr $xh 1-4"
2478 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 1-5"
2479 call read_mline_res
2481 if [ "$t_remove" == "" ]
2482 return
2485 echo "~^header remove $xh"; read es; call xerr $es "ins_addr $xh 2-1"
2486 echo "~^header remove $xh"; read es; vput vexpr es substr $es 0 3
2487 if [ $es != 501 ]
2488 xcall bail "ins_addr $xh 2-2"
2490 echo "~^header list $xh"; read es; vput vexpr es substr $es 0 3
2491 if [ $es != 501 ]
2492 xcall bail "ins_addr $xh 2-3"
2494 echo "~^header show $xh"; read es; vput vexpr es substr $es 0 3
2495 if [ $es != 501 ]
2496 xcall bail "ins_addr $xh 2-4"
2500 echo "~^header insert $xh diet <$xh@exam.ple> spliced";\
2501 read es; echo $es; call xerr "$es" "ins_addr $xh 3-1"
2502 echo "~^header insert $xh <${xh}2@exam.ple>";\
2503 read es; echo $es; call xerr "$es" "ins_addr $xh 3-2"
2504 echo "~^header insert $xh ${xh}3@exam.ple";\
2505 read es; echo $es; call xerr "$es" "ins_addr $xh 3-3"
2506 echo "~^header list $xh"; read hl; echo $hl;\
2507 call xerr "$hl" "ins_addr $xh 3-4"
2508 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 3-5"
2509 call read_mline_res
2511 echo "~^header remove-at $xh 1"; read es;\
2512 call xerr $es "ins_addr $xh 3-6"
2513 echo "~^header remove-at $xh 1"; read es;\
2514 call xerr $es "ins_addr $xh 3-7"
2515 echo "~^header remove-at $xh 1"; read es;\
2516 call xerr $es "ins_addr $xh 3-8"
2517 echo "~^header remove-at $xh 1"; read es;\
2518 vput vexpr es substr $es 0 3
2519 if [ $es != 501 ]
2520 xcall bail "ins_addr $xh 3-9"
2522 echo "~^header remove-at $xh T"; read es;\
2523 vput vexpr es substr $es 0 3
2524 if [ $es != 505 ]
2525 xcall bail "ins_addr $xh 3-10"
2527 echo "~^header list $xh"; read es;\
2528 vput vexpr es substr $es 0 3
2529 if [ $es != 501 ]
2530 xcall bail "ins_addr $xh 3-11"
2532 echo "~^header show $xh"; read es;\
2533 vput vexpr es substr $es 0 3
2534 if [ $es != 501 ]
2535 xcall bail "ins_addr $xh 3-12"
2539 echo "~^header insert $xh diet <$xh@exam.ple> spliced";\
2540 read es; echo $es; call xerr "$es" "ins_addr $xh 4-1"
2541 echo "~^header insert $xh <${xh}2@exam.ple> (comment) \"Quot(e)d\"";\
2542 read es; echo $es; call xerr "$es" "ins_addr $xh 4-2"
2543 echo "~^header insert $xh ${xh}3@exam.ple";\
2544 read es; echo $es; call xerr "$es" "ins_addr $xh 4-3"
2545 echo "~^header list $xh"; read hl; echo $hl;\
2546 call xerr "$hl" "header list $xh 3-4"
2547 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 4-5"
2548 call read_mline_res
2550 echo "~^header remove-at $xh 3"; read es;\
2551 call xerr $es "ins_addr $xh 4-6"
2552 echo "~^header remove-at $xh 2"; read es;\
2553 call xerr $es "ins_addr $xh 4-7"
2554 echo "~^header remove-at $xh 1"; read es;\
2555 call xerr $es "ins_addr $xh 4-8"
2556 echo "~^header remove-at $xh 1"; read es;\
2557 vput vexpr es substr $es 0 3
2558 if [ $es != 501 ]
2559 xcall bail "ins_addr $xh 4-9"
2561 echo "~^header remove-at $xh T"; read es;\
2562 vput vexpr es substr $es 0 3
2563 if [ $es != 505 ]
2564 xcall bail "ins_addr $xh 4-10"
2566 echo "~^header list $xh"; read es;\
2567 vput vexpr es substr $es 0 3
2568 if [ $es != 501 ]
2569 xcall bail "ins_addr $xh 4-11"
2571 echo "~^header show $xh"; read es;\
2572 vput vexpr es substr $es 0 3
2573 if [ $es != 501 ]
2574 xcall bail "ins_addr $xh 4-12"
2577 define ins_ref {
2578 wysh set xh=$1 mult=$2
2579 echo "~^header list"; read hl; echo $hl;\
2580 call xerr "$hl" "ins_ref ($xh) 0-1"
2582 echo "~^header insert $xh <$xh@exam.ple>";\
2583 read es; echo $es; call xerr "$es" "ins_ref $xh 1-1"
2584 if [ $mult -ne 0 ]
2585 echo "~^header insert $xh <${xh}2@exam.ple>";\
2586 read es; echo $es; call xerr "$es" "ins_ref $xh 1-2"
2587 echo "~^header insert $xh ${xh}3@exam.ple";\
2588 read es; echo $es; call xerr "$es" "ins_ref $xh 1-3"
2589 else
2590 echo "~^header insert $xh <${xh}2@exam.ple>"; read es;\
2591 vput vexpr es substr $es 0 3
2592 if [ $es != 506 ]
2593 xcall bail "ins_ref $xh 1-4"
2597 echo "~^header list $xh"; read hl; echo $hl;\
2598 call xerr "$hl" "ins_ref $xh 1-5"
2599 echo "~^header show $xh"; read es; call xerr $es "ins_ref $xh 1-6"
2600 call read_mline_res
2602 if [ "$t_remove" == "" ]
2603 return
2606 echo "~^header remove $xh"; read es;\
2607 call xerr $es "ins_ref $xh 2-1"
2608 echo "~^header remove $xh"; read es;\
2609 vput vexpr es substr $es 0 3
2610 if [ $es != 501 ]
2611 xcall bail "ins_ref $xh 2-2"
2613 echo "~^header list $xh"; read es;\
2614 vput vexpr es substr $es 0 3
2615 if [ $es != 501 ]
2616 xcall bail "$es ins_ref $xh 2-3"
2618 echo "~^header show $xh"; read es;\
2619 vput vexpr es substr $es 0 3
2620 if [ $es != 501 ]
2621 xcall bail "ins_ref $xh 2-4"
2625 echo "~^header insert $xh <$xh@exam.ple>";\
2626 read es; echo $es; call xerr "$es" "ins_ref $xh 3-1"
2627 if [ $mult -ne 0 ]
2628 echo "~^header insert $xh <${xh}2@exam.ple>";\
2629 read es; echo $es; call xerr "$es" "ins_ref $xh 3-2"
2630 echo "~^header insert $xh ${xh}3@exam.ple";\
2631 read es; echo $es; call xerr "$es" "ins_ref $xh 3-3"
2633 echo "~^header list $xh";\
2634 read hl; echo $hl; call xerr "$hl" "ins_ref $xh 3-4"
2635 echo "~^header show $xh";\
2636 read es; call xerr $es "ins_ref $xh 3-5"
2637 call read_mline_res
2639 echo "~^header remove-at $xh 1"; read es;\
2640 call xerr $es "ins_ref $xh 3-6"
2641 if [ $mult -ne 0 ] && [ $xh != subject ]
2642 echo "~^header remove-at $xh 1"; read es;\
2643 call xerr $es "ins_ref $xh 3-7"
2644 echo "~^header remove-at $xh 1"; read es;\
2645 call xerr $es "ins_ref $xh 3-8"
2647 echo "~^header remove-at $xh 1"; read es;\
2648 vput vexpr es substr $es 0 3
2649 if [ $es != 501 ]
2650 xcall bail "ins_ref $xh 3-9"
2652 echo "~^header remove-at $xh T"; read es;\
2653 vput vexpr es substr $es 0 3
2654 if [ $es != 505 ]
2655 xcall bail "ins_ref $xh 3-10"
2657 echo "~^header show $xh"; read es;\
2658 vput vexpr es substr $es 0 3
2659 if [ $es != 501 ]
2660 xcall bail "ins_ref $xh 3-11"
2664 echo "~^header insert $xh <$xh@exam.ple> ";\
2665 read es; echo $es; call xerr "$es" "ins_ref $xh 4-1"
2666 if [ $mult -ne 0 ]
2667 echo "~^header insert $xh <${xh}2@exam.ple> ";\
2668 read es; echo $es; call xerr "$es" "ins_ref $xh 4-2"
2669 echo "~^header insert $xh ${xh}3@exam.ple";\
2670 read es; echo $es; call xerr "$es" "ins_ref $xh 4-3"
2672 echo "~^header list $xh"; read hl; echo $hl;\
2673 call xerr "$hl" "ins_ref $xh 4-4"
2674 echo "~^header show $xh"; read es; call xerr $es "ins_ref $xh 4-5"
2675 call read_mline_res
2677 if [ $mult -ne 0 ] && [ $xh != subject ]
2678 echo "~^header remove-at $xh 3"; read es;\
2679 call xerr $es "ins_ref $xh 4-6"
2680 echo "~^header remove-at $xh 2"; read es;\
2681 call xerr $es "ins_ref $xh 4-7"
2683 echo "~^header remove-at $xh 1"; read es;\
2684 call xerr $es "ins_ref $xh 4-8"
2685 echo "~^header remove-at $xh 1"; read es;\
2686 vput vexpr es substr $es 0 3
2687 if [ $es != 501 ]
2688 xcall bail "ins_ref $xh 4-9"
2690 echo "~^header remove-at $xh T"; read es;\
2691 vput vexpr es substr $es 0 3
2692 if [ $es != 505 ]
2693 xcall bail "ins_ref $xh 4-10"
2695 echo "~^header show $xh"; read es;\
2696 vput vexpr es substr $es 0 3
2697 if [ $es != 501 ]
2698 xcall bail "ins_ref $xh 4-11"
2701 define t_header {
2702 echo t_header ENTER
2703 # In collect.c order
2704 call ins_addr from
2705 call ins_ref sender 0 # Not a "ref", but works
2706 call ins_addr To
2707 call ins_addr cC
2708 call ins_addr bCc
2709 call ins_addr reply-To
2710 call ins_addr mail-Followup-to
2711 call ins_ref messAge-id 0
2712 call ins_ref rEfErEncEs 1
2713 call ins_ref in-Reply-to 1
2714 call ins_ref subject 1 # Not a "ref", but works (with tweaks)
2715 call ins_addr freeForm1
2716 call ins_addr freeform2
2718 echo "~^header show MAILX-Command"; read es; call xerr $es "t_header 1000"
2719 call read_mline_res
2720 echo "~^header show MAILX-raw-TO"; read es; call xerr $es "t_header 1001"
2721 call read_mline_res
2723 echo t_header LEAVE
2725 define t_attach {
2726 echo t_attach ENTER
2728 echo "~^attachment";\
2729 read hl; echo $hl; vput vexpr es substr "$hl" 0 3
2730 if [ "$es" != 501 ]
2731 xcall bail "attach 0-1"
2734 echo "~^attach attribute ./.treadctl";\
2735 read hl; echo $hl; vput vexpr es substr "$hl" 0 3
2736 if [ "$es" != 501 ]
2737 xcall bail "attach 0-2"
2739 echo "~^attachment attribute-at 1";\
2740 read hl; echo $hl; vput vexpr es substr "$hl" 0 3
2741 if [ "$es" != 501 ]
2742 xcall bail "attach 0-3"
2745 echo "~^attachment insert ./.treadctl=ascii";\
2746 read hl; echo $hl; call xerr "$hl" "attach 1-1"
2747 echo "~^attachment list";\
2748 read es; echo $es;call xerr "$es" "attach 1-2"
2749 call read_mline_res
2750 echo "~^attachment attribute ./.treadctl";\
2751 read es; echo $es;call xerr "$es" "attach 1-3"
2752 call read_mline_res
2753 echo "~^attachment attribute .treadctl";\
2754 read es; echo $es;call xerr "$es" "attach 1-4"
2755 call read_mline_res
2756 echo "~^attachment attribute-at 1";\
2757 read es; echo $es;call xerr "$es" "attach 1-5"
2758 call read_mline_res
2760 echo "~^attachment attribute-set ./.treadctl filename rctl";\
2761 read es; echo $es;call xerr "$es" "attach 1-6"
2762 echo "~^attachment attribute-set .treadctl content-description Au";\
2763 read es; echo $es;call xerr "$es" "attach 1-7"
2764 echo "~^attachment attribute-set-at 1 content-id <10.du@ich>";\
2765 read es; echo $es;call xerr "$es" "attach 1-8"
2767 echo "~^attachment attribute ./.treadctl";\
2768 read es; echo $es;call xerr "$es" "attach 1-9"
2769 call read_mline_res
2770 echo "~^attachment attribute .treadctl";\
2771 read es; echo $es;call xerr "$es" "attach 1-10"
2772 call read_mline_res
2773 echo "~^attachment attribute rctl";\
2774 read es; echo $es;call xerr "$es" "attach 1-11"
2775 call read_mline_res
2776 echo "~^attachment attribute-at 1";\
2777 read es; echo $es;call xerr "$es" "attach 1-12"
2778 call read_mline_res
2781 echo "~^attachment insert ./.tattach=latin1";\
2782 read hl; echo $hl; call xerr "$hl" "attach 2-1"
2783 echo "~^attachment list";\
2784 read es; echo $es;call xerr "$es" "attach 2-2"
2785 call read_mline_res
2786 echo "~^attachment attribute ./.tattach";\
2787 read es; echo $es;call xerr "$es" "attach 2-3"
2788 call read_mline_res
2789 echo "~^attachment attribute .tattach";\
2790 read es; echo $es;call xerr "$es" "attach 2-4"
2791 call read_mline_res
2792 echo "~^attachment attribute-at 2";\
2793 read es; echo $es;call xerr "$es" "attach 2-5"
2794 call read_mline_res
2796 echo "~^attachment attribute-set ./.tattach filename tat";\
2797 read es; echo $es;call xerr "$es" "attach 2-6"
2798 echo \
2799 "~^attachment attribute-set .tattach content-description Au2";\
2800 read es; echo $es;call xerr "$es" "attach 2-7"
2801 echo "~^attachment attribute-set-at 2 content-id <20.du@wir>";\
2802 read es; echo $es;call xerr "$es" "attach 2-8"
2803 echo \
2804 "~^attachment attribute-set-at 2 content-type application/x-sh";\
2805 read es; echo $es;call xerr "$es" "attach 2-9"
2807 echo "~^attachment attribute ./.tattach";\
2808 read es; echo $es;call xerr "$es" "attach 2-10"
2809 call read_mline_res
2810 echo "~^attachment attribute .tattach";\
2811 read es; echo $es;call xerr "$es" "attach 2-11"
2812 call read_mline_res
2813 echo "~^attachment attribute tat";\
2814 read es; echo $es;call xerr "$es" "attach 2-12"
2815 call read_mline_res
2816 echo "~^attachment attribute-at 2";\
2817 read es; echo $es;call xerr "$es" "attach 2-13"
2818 call read_mline_res
2821 if [ "$t_remove" == "" ]
2822 return
2825 echo "~^attachment remove ./.treadctl"; read es;\
2826 call xerr $es "attach 3-1"
2827 echo "~^attachment remove ./.tattach"; read es;\
2828 call xerr $es "attach 3-2"
2829 echo "~^ attachment remove ./.treadctl"; read es;\
2830 vput vexpr es substr $es 0 3
2831 if [ $es != 501 ]
2832 xcall bail "attach 3-3"
2834 echo "~^ attachment remove ./.tattach"; read es;\
2835 vput vexpr es substr $es 0 3
2836 if [ $es != 501 ]
2837 xcall bail "attach 3-4"
2839 echo "~^attachment list"; read es;\
2840 vput vexpr es substr $es 0 3
2841 if [ $es != 501 ]
2842 xcall bail "attach 3-5"
2846 echo "~^attachment insert ./.tattach=latin1";\
2847 read hl; echo $hl; call xerr "$hl" "attach 4-1"
2848 echo "~^attachment insert ./.tattach=latin1";\
2849 read hl; echo $hl; call xerr "$hl" "attach 4-2"
2850 echo "~^attachment list";\
2851 read es; echo $es;call xerr "$es" "attach 4-3"
2852 call read_mline_res
2853 echo "~^ attachment remove .tattach"; read es;\
2854 vput vexpr es substr $es 0 3
2855 if [ $es != 506 ]
2856 xcall bail "attach 4-4 $es"
2858 echo "~^attachment remove-at T"; read es;\
2859 vput vexpr es substr $es 0 3
2860 if [ $es != 505 ]
2861 xcall bail "attach 4-5"
2863 echo "~^attachment remove ./.tattach"; read es;\
2864 call xerr $es "attach 4-6"
2865 echo "~^attachment remove ./.tattach"; read es;\
2866 call xerr $es "attach 4-7"
2867 echo "~^ attachment remove ./.tattach"; read es;\
2868 vput vexpr es substr $es 0 3
2869 if [ $es != 501 ]
2870 xcall bail "attach 4-8 $es"
2872 echo "~^attachment list"; read es;\
2873 vput vexpr es substr $es 0 3
2874 if [ $es != 501 ]
2875 xcall bail "attach 4-9"
2879 echo "~^attachment insert ./.tattach=latin1";\
2880 read hl; echo $hl; call xerr "$hl" "attach 5-1"
2881 echo "~^attachment insert ./.tattach=latin1";\
2882 read hl; echo $hl; call xerr "$hl" "attach 5-2"
2883 echo "~^attachment insert ./.tattach=latin1";\
2884 read hl; echo $hl; call xerr "$hl" "attach 5-3"
2885 echo "~^attachment list";\
2886 read es; echo $es;call xerr "$es" "attach 5-4"
2887 call read_mline_res
2889 echo "~^attachment remove-at 3"; read es;\
2890 call xerr $es "attach 5-5"
2891 echo "~^attachment remove-at 3"; read es;\
2892 vput vexpr es substr $es 0 3
2893 if [ $es != 501 ]
2894 xcall bail "attach 5-6"
2896 echo "~^attachment remove-at 2"; read es;\
2897 call xerr $es "attach 5-7"
2898 echo "~^attachment remove-at 2"; read es;\
2899 vput vexpr es substr $es 0 3
2900 if [ $es != 501 ]
2901 xcall bail "attach 5-8"
2903 echo "~^attachment remove-at 1"; read es;\
2904 call xerr $es "attach 5-9"
2905 echo "~^attachment remove-at 1"; read es;\
2906 vput vexpr es substr $es 0 3
2907 if [ $es != 501 ]
2908 xcall bail "attach 5-10"
2911 echo "~^attachment list"; read es;\
2912 vput vexpr es substr $es 0 3
2913 if [ $es != 501 ]
2914 xcall bail "attach 5-11"
2918 echo "~^attachment insert ./.tattach=latin1";\
2919 read hl; echo $hl; call xerr "$hl" "attach 6-1"
2920 echo "~^attachment insert ./.tattach=latin1";\
2921 read hl; echo $hl; call xerr "$hl" "attach 6-2"
2922 echo "~^attachment insert ./.tattach=latin1";\
2923 read hl; echo $hl; call xerr "$hl" "attach 6-3"
2924 echo "~^attachment list";\
2925 read es; echo $es;call xerr "$es" "attach 6-4"
2926 call read_mline_res
2928 echo "~^attachment remove-at 1"; read es;\
2929 call xerr $es "attach 6-5"
2930 echo "~^attachment remove-at 1"; read es;\
2931 call xerr $es "attach 6-6"
2932 echo "~^attachment remove-at 1"; read es;\
2933 call xerr $es "attach 6-7"
2934 echo "~^attachment remove-at 1"; read es;\
2935 vput vexpr es substr $es 0 3
2936 if [ $es != 501 ]
2937 xcall bail "attach 6-8"
2940 echo "~^attachment list"; read es;\
2941 vput vexpr es substr $es 0 3
2942 if [ $es != 501 ]
2943 xcall bail "attach 6-9"
2946 echo t_attach LEAVE
2948 define t_ocs {
2949 read ver
2950 echo t_ocs
2951 call t_header
2952 call t_attach
2954 define t_oce {
2955 echo on-compose-enter, mailx-command<$mailx-command>
2956 alternates alter1@exam.ple alter2@exam.ple
2957 alternates
2958 set autocc='alter1@exam.ple alter2@exam.ple'
2959 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
2960 echo mailx-subject<$mailx-subject>
2961 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
2962 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
2963 mailx-raw-bcc<$mailx-raw-bcc>
2964 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
2965 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
2967 define t_ocl {
2968 echo on-compose-leave, mailx-command<$mailx-command>
2969 vput alternates al
2970 eval alternates $al alter3@exam.ple alter4@exam.ple
2971 alternates
2972 set autobcc='alter3@exam.ple alter4@exam.ple'
2973 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
2974 echo mailx-subject<$mailx-subject>
2975 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
2976 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
2977 mailx-raw-bcc<$mailx-raw-bcc>
2978 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
2979 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
2981 define t_occ {
2982 echo on-compose-cleanup, mailx-command<$mailx-command>
2983 unalternates *
2984 alternates
2985 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
2986 echo mailx-subject<$mailx-subject>
2987 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
2988 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
2989 mailx-raw-bcc<$mailx-raw-bcc>
2990 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
2991 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
2993 wysh set on-compose-splice=t_ocs \
2994 on-compose-enter=t_oce on-compose-leave=t_ocl \
2995 on-compose-cleanup=t_occ
2996 __EOT__
3000 ${rm} -f "${MBOX}"
3001 printf 'm this-goes@nowhere\nbody\n!.\n' |
3002 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
3003 -X'source ./.trc' -Smta=./.tsendmail.sh \
3004 >./.tall 2>&1
3005 ${cat} ./.tall >> "${MBOX}"
3006 check behave:compose_hooks-1 0 "${MBOX}" '3667291468 10101'
3008 ${rm} -f "${MBOX}"
3009 printf 'm this-goes@nowhere\nbody\n!.\n' |
3010 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
3011 -St_remove=1 -X'source ./.trc' -Smta=./.tsendmail.sh \
3012 >./.tall 2>&1
3013 ${cat} ./.tall >> "${MBOX}"
3014 check behave:compose_hooks-2 0 "${MBOX}" '1746765053 12535'
3016 # Some state machine stress, shell compose hook, localopts for hook, etc.
3017 # readctl in child. ~r as HERE document
3018 ${rm} -f "${MBOX}"
3019 printf 'm ex@am.ple\nbody\n!.\nvar t_oce t_ocs t_ocs_sh t_ocl t_occ autocc' |
3020 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! \
3021 -Smta=./.tsendmail.sh \
3023 define bail {
3024 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
3026 define xerr {
3027 vput vexpr es substr "$1" 0 1
3028 if [ "$es" != 2 ]
3029 xcall bail "$2"
3032 define read_mline_res {
3033 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
3034 echo $len/$es/$^ERRNAME: $hl
3035 if [ $es -ne $^ERR-NONE ]
3036 xcall bail read_mline_res
3037 elif [ $len -ne 0 ]
3038 \xcall read_mline_res
3041 define _work {
3042 vput vexpr i + 1 "$2"
3043 if [ $i -lt 111 ]
3044 vput vexpr j % $i 10
3045 if [ $j -ne 0 ]
3046 set j=xcall
3047 else
3048 echon "$i.. "
3049 set j=call
3051 eval \\$j _work $1 $i
3052 return $?
3054 vput vexpr i + $i "$1"
3055 return $i
3057 define _read {
3058 read line;wysh set es=$? en=$^ERRNAME ; echo read:$es/$en: $line
3059 if [ "${es}" -ne -1 ]
3060 xcall _read
3062 readctl remove $cwd/.treadctl; echo readctl remove:$?/$^ERRNAME
3064 define t_ocs {
3065 read ver
3066 echo t_ocs
3067 echo "~^header list"; read hl; echo $hl;\
3068 vput vexpr es substr "$hl" 0 1
3069 if [ "$es" != 2 ]
3070 xcall bail "header list"
3071 endif
3073 call _work 1; echo $?
3074 echo "~^header insert cc splicy diet <splice@exam.ple> spliced";\
3075 read es; echo $es; vput vexpr es substr "$es" 0 1
3076 if [ "$es" != 2 ]
3077 xcall bail "be diet"
3078 endif
3079 echo "~^header insert cc <splice2@exam.ple>";\
3080 read es; echo $es; vput vexpr es substr "$es" 0 1
3081 if [ "$es" != 2 ]
3082 xcall bail "be diet2"
3083 endif
3085 call _work 2; echo $?
3086 echo "~^header insert bcc juicy juice <juice@exam.ple> spliced";\
3087 read es; echo $es;vput vexpr es substr "$es" 0 1
3088 if [ "$es" != 2 ]
3089 xcall bail "be juicy"
3090 endif
3091 echo "~^header insert bcc juice2@exam.ple";\
3092 read es; echo $es;vput vexpr es substr "$es" 0 1
3093 if [ "$es" != 2 ]
3094 xcall bail "be juicy2"
3095 endif
3096 echo "~^header insert bcc juice3 <juice3@exam.ple>";\
3097 read es; echo $es;vput vexpr es substr "$es" 0 1
3098 if [ "$es" != 2 ]
3099 xcall bail "be juicy3"
3100 endif
3101 echo "~^header insert bcc juice4@exam.ple";\
3102 read es; echo $es;vput vexpr es substr "$es" 0 1
3103 if [ "$es" != 2 ]
3104 xcall bail "be juicy4"
3105 endif
3107 echo "~^header remove-at bcc 3";\
3108 read es; echo $es;vput vexpr es substr "$es" 0 1
3109 if [ "$es" != 2 ]
3110 xcall bail "remove juicy5"
3111 endif
3112 echo "~^header remove-at bcc 2";\
3113 read es; echo $es;vput vexpr es substr "$es" 0 1
3114 if [ "$es" != 2 ]
3115 xcall bail "remove juicy6"
3116 endif
3117 echo "~^header remove-at bcc 3";\
3118 read es; echo $es;vput vexpr es substr "$es" 0 3
3119 if [ "$es" != 501 ]
3120 xcall bail "failed to remove-at"
3121 endif
3122 # Add duplicates which ought to be removed!
3123 echo "~^header insert bcc juice4@exam.ple";\
3124 read es; echo $es;vput vexpr es substr "$es" 0 1
3125 if [ "$es" != 2 ]
3126 xcall bail "be juicy4-1"
3127 endif
3128 echo "~^header insert bcc juice4@exam.ple";\
3129 read es; echo $es;vput vexpr es substr "$es" 0 1
3130 if [ "$es" != 2 ]
3131 xcall bail "be juicy4-2"
3132 endif
3133 echo "~^header insert bcc juice4@exam.ple";\
3134 read es; echo $es;vput vexpr es substr "$es" 0 1
3135 if [ "$es" != 2 ]
3136 xcall bail "be juicy4-3"
3137 endif
3138 echo "~:set t_ocs"
3141 call _work 3; echo $?
3142 echo "~r - '__EOT'"
3143 vput ! i echo just knock if you can hear me;\
3144 i=0;\
3145 while [ $i -lt 24 ]; do printf "%s " $i; i=`expr $i + 1`; done;\
3146 echo relax
3147 echon shell-cmd says $?/$^ERRNAME: $i
3148 echo "~x will not become interpreted, we are reading until __EOT"
3149 echo "__EOT"
3150 read r_status; echo "~~r status output: $r_status"
3151 echo "~:echo $? $! $^ERRNAME"
3152 read r_status
3153 echo "~~r status from parent: $r_status"
3156 call _work 4; echo $?
3157 vput cwd cwd;echo cwd:$?
3158 readctl create $cwd/.treadctl ;echo readctl:$?/$^ERRNAME;\
3159 call _read
3162 call _work 5; echo $?
3163 echo "~^header show MAILX-Command"; read es;\
3164 call xerr $es "t_header 1000"; call read_mline_res
3165 echo "~^header show MAILX-raw-TO"; read es;\
3166 call xerr $es "t_header 1001"; xcall read_mline_res
3168 echoerr IT IS WRONG IF YOU SEE THIS
3170 define t_oce {
3171 echo on-compose-enter, mailx-command<$mailx-command>
3172 set t_oce autobcc=oce@exam.ple
3173 alternates alter1@exam.ple alter2@exam.ple
3174 alternates
3175 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3176 echo mailx-subject<$mailx-subject>
3177 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3178 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3179 mailx-raw-bcc<$mailx-raw-bcc>
3180 echo mailx-orig-from<$mailx-orig-from> \
3181 mailx-orig-to<$mailx-orig-to> \
3182 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3184 define t_ocl {
3185 echo on-compose-leave, mailx-command<$mailx-command>
3186 set t_ocl autocc=ocl@exam.ple
3187 unalternates *
3188 alternates alter3@exam.ple alter4@exam.ple
3189 alternates
3190 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3191 echo mailx-subject<$mailx-subject>
3192 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3193 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3194 mailx-raw-bcc<$mailx-raw-bcc>
3195 echo mailx-orig-from<$mailx-orig-from> \
3196 mailx-orig-to<$mailx-orig-to> \
3197 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3199 define t_occ {
3200 echo on-compose-cleanup, mailx-command<$mailx-command>
3201 set t_occ autocc=occ@exam.ple
3202 unalternates *
3203 alternates
3204 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3205 echo mailx-subject<$mailx-subject>
3206 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3207 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3208 mailx-raw-bcc<$mailx-raw-bcc>
3209 echo mailx-orig-from<$mailx-orig-from> \
3210 mailx-orig-to<$mailx-orig-to> \
3211 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3213 wysh set on-compose-splice=t_ocs \
3214 on-compose-splice-shell="read ver;printf \"t_ocs-shell\\n\
3215 ~t shell@exam.ple\\n~:set t_ocs_sh\\n\"" \
3216 on-compose-enter=t_oce on-compose-leave=t_ocl \
3217 on-compose-cleanup=t_occ
3218 ' > ./.tnotes 2>&1
3219 ex0_test behave:compose_hooks-3
3220 ${cat} ./.tnotes >> "${MBOX}"
3222 check behave:compose_hooks-3 - "${MBOX}" '679526364 2431'
3224 # Reply, forward, resend, Resend
3226 ${rm} -f "${MBOX}"
3227 printf 'set from=f1@z\nm t1@z\nb1\n!.\nset from=f2@z\nm t2@z\nb2\n!.\n' |
3228 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! \
3229 -Smta=./.tsendmail.sh
3231 printf '
3232 echo start: $? $! $^ERRNAME
3233 File %s
3234 echo File: $? $! $^ERRNAME;echo;echo
3235 reply 1
3236 this is content of reply 1
3238 echo reply 1: $? $! $^ERRNAME;echo;echo
3239 Reply 1 2
3240 this is content of Reply 1 2
3242 echo Reply 1 2: $? $! $^ERRNAME;echo;echo
3243 forward 1 fwdex@am.ple
3244 this is content of forward 1
3246 echo forward 1: $? $! $^ERRNAME;echo;echo
3247 resend 1 2 resendex@am.ple
3248 echo resend 1 2: $? $! $^ERRNAME;echo;echo
3249 Resend 1 2 Resendex@am.ple
3250 echo Resend 1 2: $? $! $^ERRNAME;echo;echo
3251 ' "${MBOX}" |
3252 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! \
3253 -Smta=./.tsendmail.sh \
3255 define bail {
3256 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
3258 define xerr {
3259 vput vexpr es substr "$1" 0 1
3260 if [ "$es" != 2 ]
3261 xcall bail "$2"
3264 define read_mline_res {
3265 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
3266 echo mline_res:$len/$es/$^ERRNAME: $hl
3267 if [ $es -ne $^ERR-NONE ]
3268 xcall bail read_mline_res
3269 elif [ $len -ne 0 ]
3270 \xcall read_mline_res
3273 define work_hl {
3274 echo "~^header show $1"; read es;\
3275 call xerr $es "work_hl $1"; echo $1; call read_mline_res
3276 if [ $# -gt 1 ]
3277 shift
3278 xcall work_hl "$@"
3281 define t_ocs {
3282 read ver
3283 echo t_ocs version $ver
3284 echo "~^header list"; read hl; echo $hl;\
3285 echoerr the header list is $hl;\
3286 call xerr "$hl" "header list"
3287 eval vpospar set $hl
3288 shift
3289 xcall work_hl "$@"
3290 echoerr IT IS WRONG IF YOU SEE THIS
3292 define t_oce {
3293 echo on-XY-enter, mailx-command<$mailx-command>
3294 set t_oce autobcc=oce@exam.ple
3295 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3296 echo mailx-subject<$mailx-subject>
3297 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3298 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3299 mailx-raw-bcc<$mailx-raw-bcc>
3300 echo mailx-orig-from<$mailx-orig-from> \
3301 mailx-orig-to<$mailx-orig-to> \
3302 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3304 define t_ocl {
3305 echo on-XY-leave, mailx-command<$mailx-command>
3306 set t_ocl autocc=ocl@exam.ple
3307 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3308 echo mailx-subject<$mailx-subject>
3309 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3310 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3311 mailx-raw-bcc<$mailx-raw-bcc>
3312 echo mailx-orig-from<$mailx-orig-from> \
3313 mailx-orig-to<$mailx-orig-to> \
3314 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3316 define t_occ {
3317 echo on-XY-cleanup, mailx-command<$mailx-command>
3318 set t_occ autocc=occ@exam.ple
3319 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3320 echo mailx-subject<$mailx-subject>
3321 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3322 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3323 mailx-raw-bcc<$mailx-raw-bcc>
3324 echo mailx-orig-from<$mailx-orig-from> \
3325 mailx-orig-to<$mailx-orig-to> \
3326 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3328 wysh set on-compose-splice=t_ocs \
3329 on-compose-enter=t_oce on-compose-leave=t_ocl \
3330 on-compose-cleanup=t_occ \
3331 on-resend-enter=t_oce on-resend-cleanup=t_occ
3332 ' > ./.tnotes 2>&1
3333 ex0_test behave:compose_hooks-4
3334 ${cat} ./.tnotes >> "${MBOX}"
3336 check behave:compose_hooks-4 - "${MBOX}" '2711778338 7516'
3338 t_epilog
3341 t_behave_message_injections() {
3342 t_prolog
3343 TRAP_EXIT_ADDONS="./.t*"
3345 ${cat} <<-_EOT > ./.tsendmail.sh
3346 #!${MYSHELL} -
3347 (echo 'From Echinacea Tue Jun 20 15:54:02 2017' && ${cat} && echo
3348 ) > "${MBOX}"
3349 _EOT
3350 chmod 0755 ./.tsendmail.sh
3352 echo mysig > ./.tmysig
3354 echo some-body | ${MAILX} ${ARGS} -Smta=./.tsendmail.sh \
3355 -Smessage-inject-head=head-inject \
3356 -Smessage-inject-tail=tail-inject \
3357 -Ssignature=./.tmysig \
3358 ex@am.ple > ./.tall 2>&1
3359 check behave:message_injections-1 0 "${MBOX}" '2434746382 134'
3360 check behave:message_injections-2 - .tall '4294967295 0' # empty file
3362 ${cat} <<-_EOT > ./.template
3363 From: me
3364 To: ex1@am.ple
3365 Cc: ex2@am.ple
3366 Subject: This subject is
3368 Body, body, body me.
3369 _EOT
3370 < ./.template ${MAILX} ${ARGS} -t -Smta=./.tsendmail.sh \
3371 -Smessage-inject-head=head-inject \
3372 -Smessage-inject-tail=tail-inject \
3373 -Ssignature=./.tmysig \
3374 > ./.tall 2>&1
3375 check behave:message_injections-3 0 "${MBOX}" '3114203412 198'
3376 check behave:message_injections-4 - .tall '4294967295 0' # empty file
3378 t_epilog
3381 t_behave_mime_types_load_control() {
3382 t_prolog
3383 TRAP_EXIT_ADDONS="./.t*"
3385 ${cat} <<-_EOT > ./.tmts1
3386 @ application/mathml+xml mathml
3387 _EOT
3388 ${cat} <<-_EOT > ./.tmts2
3389 @ x-conference/x-cooltalk ice
3390 @ aga-aga aga
3391 @ application/aga-aga aga
3392 _EOT
3394 ${cat} <<-_EOT > ./.tmts1.mathml
3395 <head>nonsense ML</head>
3396 _EOT
3397 ${cat} <<-_EOT > ./.tmts2.ice
3398 Icy, icy road.
3399 _EOT
3400 printf 'of which the c\x01rack is coming soon' > ./.tmtsx.doom
3401 printf 'of which the c\x01rack is coming soon' > ./.tmtsx.aga
3403 printf '
3404 m %s
3405 Schub-di-du
3406 ~@ ./.tmts1.mathml
3407 ~@ ./.tmts2.ice
3408 ~@ ./.tmtsx.doom
3409 ~@ ./.tmtsx.aga
3411 File %s
3412 from*
3413 type
3415 ' "${MBOX}" "${MBOX}" |
3416 ${MAILX} ${ARGS} \
3417 -Smimetypes-load-control=f=./.tmts1,f=./.tmts2 \
3418 > ./.tout 2>&1
3419 ex0_test behave:mime_types_load_control
3421 ${cat} "${MBOX}" >> ./.tout
3422 check behave:mime_types_load_control-1 - ./.tout '529577037 2474'
3424 echo type | ${MAILX} ${ARGS} -R \
3425 -Smimetypes-load-control=f=./.tmts1,f=./.tmts3 \
3426 -f "${MBOX}" >> ./.tout 2>&1
3427 check behave:mime_types_load_control-2 0 ./.tout '2025926659 3558'
3429 t_epilog
3432 t_behave_smime() {
3433 have_feat smime || {
3434 echo 'behave:s/mime: unsupported, skipped'
3435 return
3438 t_prolog
3439 TRAP_EXIT_ADDONS="./.t.conf ./.tkey.pem ./.tcert.pem ./.tpair.pem"
3440 TRAP_EXIT_ADDONS="${TRAP_EXIT_ADDONS} ./.VERIFY ./.DECRYPT ./.ENCRYPT"
3441 TRAP_EXIT_ADDONS="${TRAP_EXIT_ADDONS} ./.tsendmail.sh"
3443 printf 'behave:s/mime: .. generating test key and certificate ..\n'
3444 ${cat} <<-_EOT > ./.t.conf
3445 [ req ]
3446 default_bits = 1024
3447 default_keyfile = keyfile.pem
3448 distinguished_name = req_distinguished_name
3449 attributes = req_attributes
3450 prompt = no
3451 output_password =
3453 [ req_distinguished_name ]
3454 C = GB
3455 ST = Over the
3456 L = rainbow
3457 O = S-nail
3458 OU = S-nail.smime
3459 CN = S-nail.test
3460 emailAddress = test@localhost
3462 [ req_attributes ]
3463 challengePassword =
3464 _EOT
3465 openssl req -x509 -nodes -days 3650 -config ./.t.conf \
3466 -newkey rsa:1024 -keyout ./.tkey.pem -out ./.tcert.pem >/dev/null 2>&1
3467 ${cat} ./.tkey.pem ./.tcert.pem > ./.tpair.pem
3469 # Sign/verify
3470 printf 'behave:s/mime:sign/verify: '
3471 echo bla | ${MAILX} ${ARGS} \
3472 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
3473 -Ssmime-sign -Sfrom=test@localhost \
3474 -s 'S/MIME test' ./.VERIFY
3475 if [ $? -eq 0 ]; then
3476 printf 'ok\n'
3477 else
3478 printf 'failed\n'
3479 ESTAT=1
3480 t_epilog
3481 return
3484 ${awk} '
3485 BEGIN{ skip=0 }
3486 /^Content-Description: /{ skip = 2; print; next }
3487 /^$/{ if(skip) --skip }
3488 { if(!skip) print }
3490 < ./.VERIFY > "${MBOX}"
3491 check behave:s/mime:sign/verify:checksum - "${MBOX}" '2900817158 648'
3493 printf 'behave:s/mime:sign/verify:verify '
3494 printf 'verify\nx\n' |
3495 ${MAILX} ${ARGS} \
3496 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
3497 -Ssmime-sign -Sfrom=test@localhost \
3498 -Serrexit -R \
3499 -f ./.VERIFY >/dev/null 2>&1
3500 if [ $? -eq 0 ]; then
3501 printf 'ok\n'
3502 else
3503 printf 'failed\n'
3504 ESTAT=1
3505 t_epilog
3506 return
3509 printf 'behave:s/mime:sign/verify:disproof-1 '
3510 if openssl smime -verify -CAfile ./.tcert.pem \
3511 -in ./.VERIFY >/dev/null 2>&1; then
3512 printf 'ok\n'
3513 else
3514 printf 'failed\n'
3515 ESTAT=1
3516 t_epilog
3517 return
3520 # (signing +) encryption / decryption
3521 ${cat} <<-_EOT > ./.tsendmail.sh
3522 #!${MYSHELL} -
3523 (echo 'From Euphrasia Thu Apr 27 17:56:23 2017' && ${cat}) > ./.ENCRYPT
3524 _EOT
3525 chmod 0755 ./.tsendmail.sh
3527 printf 'behave:s/mime:encrypt+sign: '
3528 echo bla |
3529 ${MAILX} ${ARGS} \
3530 -Ssmime-force-encryption \
3531 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
3532 -Smta=./.tsendmail.sh \
3533 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
3534 -Ssmime-sign -Sfrom=test@localhost \
3535 -s 'S/MIME test' recei@ver.com
3536 if [ $? -eq 0 ]; then
3537 printf 'ok\n'
3538 else
3539 ESTAT=1
3540 printf 'error: encrypt+sign failed\n'
3543 ${sed} -e '/^$/,$d' < ./.ENCRYPT > "${MBOX}"
3544 check behave:s/mime:encrypt+sign:checksum - "${MBOX}" '1937410597 327'
3546 printf 'behave:s/mime:decrypt+verify: '
3547 printf 'decrypt ./.DECRYPT\nfi ./.DECRYPT\nverify\nx\n' |
3548 ${MAILX} ${ARGS} \
3549 -Ssmime-force-encryption \
3550 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
3551 -Smta=./.tsendmail.sh \
3552 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
3553 -Ssmime-sign -Sfrom=test@localhost \
3554 -Serrexit -R \
3555 -f ./.ENCRYPT >/dev/null 2>&1
3556 if [ $? -eq 0 ]; then
3557 printf 'ok\n'
3558 else
3559 ESTAT=1
3560 printf 'failed\n'
3563 ${awk} '
3564 BEGIN{ skip=0 }
3565 /^Content-Description: /{ skip = 2; print; next }
3566 /^$/{ if(skip) --skip }
3567 { if(!skip) print }
3569 < ./.DECRYPT > "${MBOX}"
3570 check behave:s/mime:decrypt+verify:checksum - "${MBOX}" '1720739247 931'
3572 printf 'behave:s/mime:decrypt+verify:disproof-1: '
3573 if (openssl smime -decrypt -inkey ./.tkey.pem -in ./.ENCRYPT |
3574 openssl smime -verify -CAfile ./.tcert.pem) >/dev/null 2>&1; then
3575 printf 'ok\n'
3576 else
3577 printf 'failed\n'
3578 ESTAT=1
3581 printf "behave:s/mime:encrypt: "
3582 echo bla | ${MAILX} ${ARGS} \
3583 -Ssmime-force-encryption \
3584 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
3585 -Smta=./.tsendmail.sh \
3586 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
3587 -Sfrom=test@localhost \
3588 -s 'S/MIME test' recei@ver.com
3589 if [ $? -eq 0 ]; then
3590 printf 'ok\n'
3591 else
3592 ESTAT=1
3593 printf 'failed\n'
3596 # Same as behave:s/mime:encrypt+sign:checksum above
3597 ${sed} -e '/^$/,$d' < ./.ENCRYPT > "${MBOX}"
3598 check behave:s/mime:encrypt:checksum - "${MBOX}" '1937410597 327'
3600 ${rm} -f ./.DECRYPT
3601 printf 'decrypt ./.DECRYPT\nx\n' | ${MAILX} ${ARGS} \
3602 -Ssmime-force-encryption \
3603 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
3604 -Smta=./.tsendmail.sh \
3605 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
3606 -Sfrom=test@localhost \
3607 -Serrexit -R \
3608 -f ./.ENCRYPT >/dev/null 2>&1
3609 check behave:s/mime:decrypt 0 "./.DECRYPT" '2624716890 422'
3611 printf 'behave:s/mime:decrypt:disproof-1: '
3612 if openssl smime -decrypt -inkey ./.tkey.pem \
3613 -in ./.ENCRYPT >/dev/null 2>&1; then
3614 printf 'ok\n'
3615 else
3616 printf 'failed\n'
3617 ESTAT=1
3620 t_epilog
3623 t_behave_maildir() {
3624 t_prolog
3625 TRAP_EXIT_ADDONS="./.t*"
3629 while [ ${i} -lt 112 ]; do
3630 printf 'm file://%s\n~s Subject %s\nHello %s!\n~.\n' \
3631 "${MBOX}" "${i}" "${i}"
3632 i=`add ${i} 1`
3633 done
3634 ) | ${MAILX} ${ARGS}
3635 check behave:maildir-1 0 "${MBOX}" '1140119864 13780'
3637 printf 'File "%s"
3638 copy * "%s"
3639 File "%s"
3640 from*
3641 ' "${MBOX}" .tmdir1 .tmdir1 |
3642 ${MAILX} ${ARGS} -Snewfolders=maildir > .tlst
3643 check behave:maildir-2 0 .tlst '1797938753 9103'
3645 printf 'File "%s"
3646 copy * "maildir://%s"
3647 File "maildir://%s"
3648 from*
3649 ' "${MBOX}" .tmdir2 .tmdir2 |
3650 ${MAILX} ${ARGS} > .tlst
3651 check behave:maildir-3 0 .tlst '1155631089 9113'
3653 printf 'File "maildir://%s"
3654 copy * "file://%s"
3655 File "file://%s"
3656 from*
3657 ' .tmdir2 .tmbox1 .tmbox1 |
3658 ${MAILX} ${ARGS} > .tlst
3659 check behave:maildir-4 0 .tmbox1 '2646131190 13220'
3660 check behave:maildir-5 - .tlst '3701297796 9110'
3662 # only the odd (even)
3664 printf 'File "maildir://%s"
3665 copy ' .tmdir2
3667 while [ ${i} -lt 112 ]; do
3668 j=`modulo ${i} 2`
3669 [ ${j} -eq 1 ] && printf '%s ' "${i}"
3670 i=`add ${i} 1`
3671 done
3672 printf ' file://%s
3673 File "file://%s"
3674 from*
3675 ' .tmbox2 .tmbox2
3676 ) | ${MAILX} ${ARGS} > .tlst
3677 check behave:maildir-6 0 .tmbox2 '142890131 6610'
3678 check behave:maildir-7 - .tlst '960096773 4573'
3679 # ...
3681 printf 'file "maildir://%s"
3682 move ' .tmdir2
3684 while [ ${i} -lt 112 ]; do
3685 j=`modulo ${i} 2`
3686 [ ${j} -eq 0 ] && [ ${i} -ne 0 ] && printf '%s ' "${i}"
3687 i=`add ${i} 1`
3688 done
3689 printf ' file://%s
3690 File "file://%s"
3691 from*
3692 File "maildir://%s"
3693 from*
3694 ' .tmbox2 .tmbox2 .tmdir2
3695 ) | ${MAILX} ${ARGS} > .tlst
3696 check behave:maildir-8 0 .tmbox2 '3806905791 13100'
3697 ${sed} 2d < .tlst > .tlstx
3698 check behave:maildir-9 - .tlstx '4216815295 13645'
3700 t_epilog
3703 t_behave_mass_recipients() {
3704 t_prolog
3705 TRAP_EXIT_ADDONS="./.t*"
3707 ${cat} <<-_EOT > ./.tsendmail.sh
3708 #!${MYSHELL} -
3709 (echo 'From Eucalyptus Sat Jul 08 21:14:57 2017' && ${cat} && echo
3710 ) >> "${MBOX}"
3711 _EOT
3712 chmod 0755 ./.tsendmail.sh
3714 ${cat} <<'__EOT__' > ./.trc
3715 define bail {
3716 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
3718 define ins_addr {
3719 wysh set nr=$1 hn=$2
3720 echo "~$hn $hn$nr@$hn"; echo '~:echo $?'; read es
3721 if [ "$es" -ne 0 ]
3722 xcall bail "ins_addr $hn 1-$nr"
3724 vput vexpr nr + $nr 1
3725 if [ "$nr" -le "$maximum" ]
3726 xcall ins_addr $nr $hn
3729 define bld_alter {
3730 wysh set nr=$1 hn=$2
3731 alternates $hn$nr@$hn
3732 vput vexpr nr + $nr 2
3733 if [ "$nr" -le "$maximum" ]
3734 xcall bld_alter $nr $hn
3737 define t_ocs {
3738 read ver
3739 call ins_addr 1 t
3740 call ins_addr 1 c
3741 call ins_addr 1 b
3743 define t_ocl {
3744 if [ "$t_remove" != '' ]
3745 call bld_alter 1 t
3746 call bld_alter 2 c
3749 set on-compose-splice=t_ocs on-compose-leave=t_ocl
3750 __EOT__
3752 ${rm} -f "${MBOX}"
3753 printf 'm this-goes@nowhere\nbody\n!.\n' |
3754 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
3755 -X'source ./.trc' -Smta=./.tsendmail.sh -Smaximum=2001 \
3756 >./.tall 2>&1
3757 ${cat} ./.tall >> "${MBOX}"
3758 check behave:mass_recipients-1 0 "${MBOX}" '2912243346 51526'
3760 ${rm} -f "${MBOX}"
3761 printf 'm this-goes@nowhere\nbody\n!.\n' |
3762 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
3763 -St_remove=1 -X'source ./.trc' -Smta=./.tsendmail.sh -Smaximum=2001 \
3764 >./.tall 2>&1
3765 ${cat} ./.tall >> "${MBOX}"
3766 check behave:mass_recipients-2 0 "${MBOX}" '4097804632 34394'
3768 t_epilog
3771 # t_content()
3772 # Some basic tests regarding correct sending of mails, via STDIN / -t / -q,
3773 # including basic MIME Content-Transfer-Encoding correctness (quoted-printable)
3774 # Note we unfortunately need to place some statements without proper
3775 # indentation because of continuation problems
3776 t_content() {
3777 t_prolog
3779 # MIME encoding (QP) stress message body
3780 printf \
3781 'Ich bin eine DÖS-Datäi mit sehr langen Zeilen und auch '\
3782 'sonst bin ich ganz schön am Schleudern, da kannste denke '\
3783 "wasde willst, gelle, gelle, gelle, gelle, gelle.\r\n"\
3784 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst \r\n"\
3785 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1\r\n"\
3786 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12\r\n"\
3787 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123\r\n"\
3788 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1234\r\n"\
3789 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12345\r\n"\
3790 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123456\r\n"\
3791 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1234567\r\n"\
3792 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12345678\r\n"\
3793 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123456789\r\n"\
3794 "Unn ausserdem habe ich trailing SP/HT/SP/HT whitespace \r\n"\
3795 "Unn ausserdem habe ich trailing HT/SP/HT/SP whitespace \r\n"\
3796 "auf den zeilen vorher.\r\n"\
3797 "From am Zeilenbeginn und From der Mitte gibt es auch.\r\n"\
3798 ".\r\n"\
3799 "Die letzte Zeile war nur ein Punkt.\r\n"\
3800 "..\r\n"\
3801 "Das waren deren zwei.\r\n"\
3802 " \r\n"\
3803 "Die letzte Zeile war ein Leerschritt.\n"\
3804 "=VIER = EQUAL SIGNS=ON A LINE=\r\n"\
3805 "Prösterchen.\r\n"\
3806 ".\n"\
3807 "Die letzte Zeile war nur ein Punkt, mit Unix Zeilenende.\n"\
3808 "..\n"\
3809 "Das waren deren zwei. ditto.\n"\
3810 "Prösterchen.\n"\
3811 "Unn ausseerdem habe ich trailing SP/HT/SP/HT whitespace \n"\
3812 "Unn ausseerdem habe ich trailing HT/SP/HT/SP whitespace \n"\
3813 "auf den zeilen vorher.\n"\
3814 "ditto.\n"\
3815 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.\n"\
3816 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.1"\
3817 "\n"\
3818 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
3819 "\n"\
3820 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
3821 "3\n"\
3822 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
3823 "34\n"\
3824 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
3825 "345\n"\
3826 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
3827 "3456\n"\
3828 "QP am Zeilenende über soft-nl hinweg\n"\
3829 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
3830 "ö123\n"\
3831 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
3832 "1ö23\n"\
3833 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
3834 "12ö3\n"\
3835 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
3836 "123ö\n"\
3837 "=VIER = EQUAL SIGNS=ON A LINE=\n"\
3838 " \n"\
3839 "Die letzte Zeile war ein Leerschritt.\n"\
3840 ' '\
3841 > "${BODY}"
3843 # MIME encoding (QP) stress message subject
3844 SUB="Äbrä Kä?dä=brö Fü?di=bus? \
3845 adadaddsssssssddddddddddddddddddddd\
3846 ddddddddddddddddddddddddddddddddddd\
3847 ddddddddddddddddddddddddddddddddddd\
3848 dddddddddddddddddddd Hallelulja? Od\
3849 er?? eeeeeeeeeeeeeeeeeeeeeeeeeeeeee\
3850 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\
3851 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee f\
3852 fffffffffffffffffffffffffffffffffff\
3853 fffffffffffffffffffff ggggggggggggg\
3854 ggggggggggggggggggggggggggggggggggg\
3855 ggggggggggggggggggggggggggggggggggg\
3856 ggggggggggggggggggggggggggggggggggg\
3857 gggggggggggggggg"
3859 # Three tests for MIME encoding and (a bit) content classification.
3860 # At the same time testing -q FILE, < FILE and -t FILE
3862 ${rm} -f "${MBOX}"
3863 < "${BODY}" ${MAILX} ${ARGS} ${ADDARG_UNI} \
3864 -a "${BODY}" -s "${SUB}" "${MBOX}"
3865 check content:001 0 "${MBOX}" '1145066634 6654'
3867 ${rm} -f "${MBOX}"
3868 < /dev/null ${MAILX} ${ARGS} ${ADDARG_UNI} \
3869 -a "${BODY}" -s "${SUB}" -q "${BODY}" "${MBOX}"
3870 check content:002 0 "${MBOX}" '1145066634 6654'
3872 ${rm} -f "${MBOX}"
3873 ( echo "To: ${MBOX}" && echo "Subject: ${SUB}" && echo &&
3874 ${cat} "${BODY}"
3875 ) | ${MAILX} ${ARGS} ${ADDARG_UNI} -Snodot -a "${BODY}" -t
3876 check content:003 0 "${MBOX}" '1145066634 6654'
3878 # Test for [260e19d] (Juergen Daubert)
3879 ${rm} -f "${MBOX}"
3880 echo body | ${MAILX} ${ARGS} "${MBOX}"
3881 check content:004 0 "${MBOX}" '2917662811 98'
3883 # Sending of multiple mails in a single invocation
3884 ${rm} -f "${MBOX}"
3885 ( printf "m ${MBOX}\n~s subject1\nE-Mail Körper 1\n~.\n" &&
3886 printf "m ${MBOX}\n~s subject2\nEmail body 2\n~.\n" &&
3887 echo x
3888 ) | ${MAILX} ${ARGS} ${ADDARG_UNI}
3889 check content:005 0 "${MBOX}" '2098659767 358'
3891 ## $BODY CHANGED
3893 # "Test for" [d6f316a] (Gavin Troy)
3894 ${rm} -f "${MBOX}"
3895 printf "m ${MBOX}\n~s subject1\nEmail body\n~.\nfi ${MBOX}\np\nx\n" |
3896 ${MAILX} ${ARGS} ${ADDARG_UNI} -Spipe-text/plain="@* ${cat}" > "${BODY}"
3897 check content:006 0 "${MBOX}" '2099098650 122'
3898 check content:006-1 - "${BODY}" '794542938 174'
3900 # "Test for" [c299c45] (Peter Hofmann) TODO shouldn't end up QP-encoded?
3901 ${rm} -f "${MBOX}"
3902 ${awk} 'BEGIN{
3903 for(i = 0; i < 10000; ++i)
3904 printf "\xC3\xBC"
3905 #printf "\xF0\x90\x87\x90"
3906 }' | ${MAILX} ${ARGS} ${ADDARG_UNI} -s TestSubject "${MBOX}"
3907 check content:007 0 "${MBOX}" '534262374 61816'
3909 ## Test some more corner cases for header bodies (as good as we can today) ##
3912 ${rm} -f "${MBOX}"
3913 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
3914 -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̲' \
3915 "${MBOX}"
3916 check content:008 0 "${MBOX}" '3370931614 375'
3918 # Single word (overlong line split -- bad standard! Requires injection of
3919 # artificial data!! But can be prevented by using RFC 2047 encoding)
3920 ${rm} -f "${MBOX}"
3921 i=`${awk} 'BEGIN{for(i=0; i<92; ++i) printf "0123456789_"}'`
3922 echo | ${MAILX} ${ARGS} -s "${i}" "${MBOX}"
3923 check content:009 0 "${MBOX}" '489922370 1718'
3925 # Combination of encoded words, space and tabs of varying sort
3926 ${rm} -f "${MBOX}"
3927 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
3928 -s "1Abrä Kaspas1 2Abra Katä b_kaspas2 \
3929 3Abrä Kaspas3 4Abrä Kaspas4 5Abrä Kaspas5 \
3930 6Abra Kaspas6 7Abrä Kaspas7 8Abra Kaspas8 \
3931 9Abra Kaspastäb4-3 10Abra Kaspas1 _ 11Abra Katäb1 \
3932 12Abra Kadabrä1 After Tab after Täb this is NUTS" \
3933 "${MBOX}"
3934 check content:010 0 "${MBOX}" '1676887734 591'
3936 # Overlong multibyte sequence that must be forcefully split
3937 # todo This works even before v15.0, but only by accident
3938 ${rm} -f "${MBOX}"
3939 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
3940 -s "✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
3941 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
3942 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄" \
3943 "${MBOX}"
3944 check content:011 0 "${MBOX}" '3029301775 659'
3946 # Trailing WS
3947 ${rm} -f "${MBOX}"
3948 echo | ${MAILX} ${ARGS} \
3949 -s "1-1 B2 B3 B4 B5 B6 B\
3950 1-2 B2 B3 B4 B5 B6 B\
3951 1-3 B2 B3 B4 B5 B6 B\
3952 1-4 B2 B3 B4 B5 B6 B\
3953 1-5 B2 B3 B4 B5 B6 B\
3954 1-6 B2 B3 B4 B5 B6 " \
3955 "${MBOX}"
3956 check content:012 0 "${MBOX}" '4126167195 297'
3958 # Leading and trailing WS
3959 ${rm} -f "${MBOX}"
3960 echo | ${MAILX} ${ARGS} \
3961 -s " 2-1 B2 B3 B4 B5 B6 B\
3962 1-2 B2 B3 B4 B5 B6 B\
3963 1-3 B2 B3 B4 B5 B6 B\
3964 1-4 B2 B3 B4 B5 B6 " \
3965 "${MBOX}"
3966 check content:013 0 "${MBOX}" '3600624479 236'
3968 # Quick'n dirty RFC 2231 test; i had more when implementing it, but until we
3969 # have a (better) test framework materialize a quick shot
3970 ${rm} -f "${MBOX}"
3971 TRAP_EXIT_ADDONS=./.ttt
3973 mkdir ./.ttt || exit 1
3974 cd ./.ttt || exit 2
3975 : > "ma'ger.txt"
3976 : > "mä'ger.txt"
3977 : > 'diet\ is \curd.txt'
3978 : > 'diet "is" curd.txt'
3979 : > höde-tröge.txt
3980 : > 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
3981 : > höde__tröge__müde__dätte__hätte__vuelle__guelle__aese__aesse__sauerliche__kräuter__österliche__grüße__mäh.txt
3982 : > hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt
3983 : > ✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt
3985 echo bla | ${MAILX} ${ARGS} ${ADDARG_UNI} \
3986 -a "./.ttt/ma'ger.txt" -a "./.ttt/mä'ger.txt" \
3987 -a './.ttt/diet\ is \curd.txt' -a './.ttt/diet "is" curd.txt' \
3988 -a ./.ttt/höde-tröge.txt \
3989 -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 \
3990 -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 \
3991 -a ./.ttt/hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt \
3992 -a ./.ttt/✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt \
3993 "${MBOX}"
3994 check content:014-1 0 "${MBOX}" '684985954 3092'
3996 # `resend' test, reusing $MBOX
3997 ${rm} -f "${BODY}"
3998 printf "Resend ${BODY}\nx\n" | ${MAILX} ${ARGS} -Rf "${MBOX}"
3999 check content:014-2 0 "${BODY}" '684985954 3092'
4001 ${rm} -f "${BODY}"
4002 printf "resend ${BODY}\nx\n" | ${MAILX} ${ARGS} -Rf "${MBOX}"
4003 check content:014-3 0 "${BODY}" '3130352658 3148'
4005 t_epilog
4008 t_all() {
4009 # if have_feat devel; then
4010 # ARGS="${ARGS} -Smemdebug"
4011 # export ARGS
4012 # fi
4013 t_behave
4014 t_content
4017 if [ -z "${CHECK_ONLY}" ]; then
4018 cc_all_configs
4019 else
4020 t_all
4023 [ ${ESTAT} -eq 0 ] && echo Ok || echo >&2 'Errors occurred'
4025 exit ${ESTAT}
4026 # s-sh-mode