mime-types.c: (just) (satisfy) scan-build
[s-mailx.git] / cc-test.sh
blob609152844be57d0b9298440cb3cd79613ebf1bf8
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_alias
299 # FIXME t_behave_mlist
300 t_behave_filetype
302 t_behave_record_a_resend
304 t_behave_e_H_L_opts
305 t_behave_compose_hooks
306 t_behave_message_injections
307 t_behave_mime_types_load_control
309 t_behave_smime
311 t_behave_maildir
314 t_behave_X_opt_input_command_stack() {
315 t_prolog
317 ${cat} <<- '__EOT' > "${BODY}"
318 echo 1
319 define mac0 {
320 echo mac0-1 via1 $0
322 call mac0
323 echo 2
324 source '\
325 echo "define mac1 {";\
326 echo " echo mac1-1 via1 \$0";\
327 echo " call mac0";\
328 echo " echo mac1-2";\
329 echo " call mac2";\
330 echo " echo mac1-3";\
331 echo "}";\
332 echo "echo 1-1";\
333 echo "define mac2 {";\
334 echo " echo mac2-1 via1 \$0";\
335 echo " call mac0";\
336 echo " echo mac2-2";\
337 echo "}";\
338 echo "echo 1-2";\
339 echo "call mac1";\
340 echo "echo 1-3";\
341 echo "source \"\
342 echo echo 1-1-1 via1 \$0;\
343 echo call mac0;\
344 echo echo 1-1-2;\
345 | \"";\
346 echo "echo 1-4";\
348 echo 3
349 call mac2
350 echo 4
351 undefine *
352 __EOT
354 # The -X option supports multiline arguments, and those can internally use
355 # reverse solidus newline escaping. And all -X options are joined...
356 APO=\'
357 < "${BODY}" ${MAILX} ${ARGS} \
358 -X 'e\' \
359 -X ' c\' \
360 -X ' h\' \
361 -X ' o \' \
362 -X 1 \
364 define mac0 {
365 echo mac0-1 via2 $0
367 call mac0
368 echo 2
371 source '${APO}'\
372 echo "define mac1 {";\
373 echo " echo mac1-1 via2 \$0";\
374 echo " call mac0";\
375 echo " echo mac1-2";\
376 echo " call mac2";\
377 echo " echo mac1-3";\
378 echo "}";\
379 echo "echo 1-1";\
380 echo "define mac2 {";\
381 echo " echo mac2-1 via2 \$0";\
382 echo " call mac0";\
383 echo " echo mac2-2";\
384 echo "}";\
385 echo "echo 1-2";\
386 echo "call mac1";\
387 echo "echo 1-3";\
388 echo "source \"\
389 echo echo 1-1-1 via2 \$0;\
390 echo call mac0;\
391 echo echo 1-1-2;\
392 | \"";\
393 echo "echo 1-4";\
394 | '${APO}'
395 echo 3
398 call mac2
399 echo 4
400 undefine *
401 ' > "${MBOX}"
403 check behave:x_opt_input_command_stack 0 "${MBOX}" '1786542668 416'
405 t_epilog
408 t_behave_X_errexit() {
409 t_prolog
411 ${cat} <<- '__EOT' > "${BODY}"
412 echo one
413 echos nono
414 echo two
415 __EOT
417 </dev/null ${MAILX} ${ARGS} -Snomemdebug \
418 -X'echo one' -X' echos nono ' -X'echo two' \
419 > "${MBOX}" 2>&1
420 check behave:x_errexit-1 0 "${MBOX}" '916157812 53'
422 </dev/null ${MAILX} ${ARGS} -X'source '"${BODY}" -Snomemdebug \
423 > "${MBOX}" 2>&1
424 check behave:x_errexit-2 0 "${MBOX}" '916157812 53'
426 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Snomemdebug \
427 > "${MBOX}" 2>&1
428 check behave:x_errexit-3 0 "${MBOX}" '916157812 53'
432 </dev/null ${MAILX} ${ARGS} -Serrexit -Snomemdebug \
433 -X'echo one' -X' echos nono ' -X'echo two' \
434 > "${MBOX}" 2>&1
435 check behave:x_errexit-4 1 "${MBOX}" '2118430867 49'
437 </dev/null ${MAILX} ${ARGS} -X'source '"${BODY}" -Serrexit -Snomemdebug \
438 > "${MBOX}" 2>&1
439 check behave:x_errexit-5 1 "${MBOX}" '2118430867 49'
441 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Serrexit -Snomemdebug \
442 > "${MBOX}" 2>&1
443 check behave:x_errexit-6 1 "${MBOX}" '12955965 172'
445 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Sposix -Snomemdebug \
446 > "${MBOX}" 2>&1
447 check behave:x_errexit-7 1 "${MBOX}" '12955965 172'
449 ## Repeat 4-7 with ignerr set
451 ${sed} -e 's/^echos /ignerr echos /' < "${BODY}" > "${MBOX}"
453 </dev/null ${MAILX} ${ARGS} -Serrexit -Snomemdebug \
454 -X'echo one' -X'ignerr echos nono ' -X'echo two' \
455 > "${BODY}" 2>&1
456 check behave:x_errexit-8 0 "${BODY}" '916157812 53'
458 </dev/null ${MAILX} ${ARGS} -X'source '"${MBOX}" -Serrexit -Snomemdebug \
459 > "${BODY}" 2>&1
460 check behave:x_errexit-9 0 "${BODY}" '916157812 53'
462 </dev/null MAILRC="${MBOX}" ${MAILX} ${ARGS} -:u -Serrexit -Snomemdebug \
463 > "${BODY}" 2>&1
464 check behave:x_errexit-10 0 "${BODY}" '916157812 53'
466 </dev/null MAILRC="${MBOX}" ${MAILX} ${ARGS} -:u -Sposix -Snomemdebug \
467 > "${BODY}" 2>&1
468 check behave:x_errexit-11 0 "${BODY}" '916157812 53'
470 t_epilog
473 t_behave_wysh() {
474 t_prolog
476 ${cat} <<- '__EOT' > "${BODY}"
478 echo abcd
479 echo a'b'c'd'
480 echo a"b"c"d"
481 echo a$'b'c$'d'
482 echo 'abcd'
483 echo "abcd"
484 echo $'abcd'
485 echo a\ b\ c\ d
486 echo a 'b c' d
487 echo a "b c" d
488 echo a $'b c' d
490 echo 'a$`"\'
491 echo "a\$\`'\"\\"
492 echo $'a\$`\'\"\\'
493 echo $'a\$`\'"\\'
494 # DIET=CURD TIED=
495 echo 'a${DIET}b${TIED}c\${DIET}d\${TIED}e' # COMMENT
496 echo "a${DIET}b${TIED}c\${DIET}d\${TIED}e"
497 echo $'a${DIET}b${TIED}c\${DIET}d\${TIED}e'
499 echo a$'\101\0101\x41\u0041\u41\U00000041\U41'c
500 echo a$'\u0041\u41\u0C1\U00000041\U41'c
501 echo a$'\377'c
502 echo a$'\0377'c
503 echo a$'\400'c
504 echo a$'\0400'c
505 echo a$'\U1100001'c
507 echo a$'b\0c'd
508 echo a$'b\00c'de
509 echo a$'b\000c'df
510 echo a$'b\0000c'dg
511 echo a$'b\x0c'dh
512 echo a$'b\x00c'di
513 echo a$'b\u0'dj
514 echo a$'b\u00'dk
515 echo a$'b\u000'dl
516 echo a$'b\u0000'dm
517 echo a$'b\U0'dn
518 echo a$'b\U00'do
519 echo a$'b\U000'dp
520 echo a$'b\U0000'dq
521 echo a$'b\U00000'dr
522 echo a$'b\U000000'ds
523 echo a$'b\U0000000'dt
524 echo a$'b\U00000000'du
526 echo a$'\cI'b
527 echo a$'\011'b
528 echo a$'\x9'b
529 echo a$'\u9'b
530 echo a$'\U9'b
531 echo a$'\c@'b c d
532 __EOT
534 if [ -z "${UTF8_LOCALE}" ]; then
535 echo 'Skip behave:wysh_unicode, no UTF8_LOCALE'
536 else
537 < "${BODY}" DIET=CURD TIED= \
538 LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} 2>/dev/null > "${MBOX}"
539 check behave:wysh_unicode 0 "${MBOX}" '475805847 317'
542 < "${BODY}" DIET=CURD TIED= ${MAILX} ${ARGS} > "${MBOX}" 2>/dev/null
543 check behave:wysh_c 0 "${MBOX}" '1473887148 321'
545 t_epilog
548 t_behave_input_inject_semicolon_seq() {
549 t_prolog
551 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
552 define mydeepmac {
553 echon '(mydeepmac)';
555 define mymac {
556 echon this_is_mymac;call mydeepmac;echon ';';
558 echon one';';call mymac;echon two";";call mymac;echo three$';';
559 define mymac {
560 echon this_is_mymac;call mydeepmac;echon ,TOO'!;';
562 echon one';';call mymac;echon two";";call mymac;echo three$';';
563 __EOT
565 check behave:input_inject_semicolon_seq 0 "${MBOX}" '512117110 140'
567 t_epilog
570 t_behave_commandalias() {
571 t_prolog
573 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
574 commandalias echo echo hoho
575 echo stop.
576 commandalias X Xx
577 commandalias Xx XxX
578 commandalias XxX XxXx
579 commandalias XxXx XxXxX
580 commandalias XxXxX XxXxXx
581 commandalias XxXxXx echo huhu
582 commandalias XxXxXxX echo huhu
584 commandalias XxXxXx XxXxXxX
586 uncommandalias echo
587 commandalias XxXxXx echo huhu
589 __EOT
591 check behave:commandalias 0 "${MBOX}" '3694143612 31'
593 t_epilog
596 t_behave_ifelse() {
597 t_prolog
599 # Nestable conditions test
600 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
601 if 0
602 echo 1.err
603 else
604 echo 1.ok
605 endif
606 if 1
607 echo 2.ok
608 else
609 echo 2.err
610 endif
611 if $dietcurd
612 echo 3.err
613 else
614 echo 3.ok
615 endif
616 set dietcurd=yoho
617 if $dietcurd
618 echo 4.ok
619 else
620 echo 4.err
621 endif
622 if $dietcurd == 'yoho'
623 echo 5.ok
624 else
625 echo 5.err
626 endif
627 if $dietcurd @== 'Yoho'
628 echo 5-1.ok
629 else
630 echo 5-1.err
631 endif
632 if $dietcurd == 'Yoho'
633 echo 5-2.err
634 else
635 echo 5-2.ok
636 endif
637 if $dietcurd != 'yoho'
638 echo 6.err
639 else
640 echo 6.ok
641 endif
642 if $dietcurd @!= 'Yoho'
643 echo 6-1.err
644 else
645 echo 6-1.ok
646 endif
647 if $dietcurd != 'Yoho'
648 echo 6-2.ok
649 else
650 echo 6-2.err
651 endif
652 # Nesting
653 if faLse
654 echo 7.err1
655 if tRue
656 echo 7.err2
657 if yEs
658 echo 7.err3
659 else
660 echo 7.err4
661 endif
662 echo 7.err5
663 endif
664 echo 7.err6
665 else
666 echo 7.ok7
667 if YeS
668 echo 7.ok8
669 if No
670 echo 7.err9
671 else
672 echo 7.ok9
673 endif
674 echo 7.ok10
675 else
676 echo 7.err11
677 if yeS
678 echo 7.err12
679 else
680 echo 7.err13
681 endif
682 endif
683 echo 7.ok14
684 endif
685 if r
686 echo 8.ok1
687 if R
688 echo 8.ok2
689 else
690 echo 8.err2
691 endif
692 echo 8.ok3
693 else
694 echo 8.err1
695 endif
696 if s
697 echo 9.err1
698 else
699 echo 9.ok1
700 if S
701 echo 9.err2
702 else
703 echo 9.ok2
704 endif
705 echo 9.ok3
706 endif
707 # `elif'
708 if $dietcurd == 'yohu'
709 echo 10.err1
710 elif $dietcurd == 'yoha'
711 echo 10.err2
712 elif $dietcurd == 'yohe'
713 echo 10.err3
714 elif $dietcurd == 'yoho'
715 echo 10.ok1
716 if $dietcurd == 'yohu'
717 echo 10.err4
718 elif $dietcurd == 'yoha'
719 echo 10.err5
720 elif $dietcurd == 'yohe'
721 echo 10.err6
722 elif $dietcurd == 'yoho'
723 echo 10.ok2
724 if $dietcurd == 'yohu'
725 echo 10.err7
726 elif $dietcurd == 'yoha'
727 echo 10.err8
728 elif $dietcurd == 'yohe'
729 echo 10.err9
730 elif $dietcurd == 'yoho'
731 echo 10.ok3
732 else
733 echo 10.err10
734 endif
735 else
736 echo 10.err11
737 endif
738 else
739 echo 10.err12
740 endif
741 # integer
742 set dietcurd=10
743 if $dietcurd -lt 11
744 echo 11.ok1
745 if $dietcurd -gt 9
746 echo 11.ok2
747 else
748 echo 11.err2
749 endif
750 if $dietcurd -eq 10
751 echo 11.ok3
752 else
753 echo 11.err3
754 endif
755 if $dietcurd -ge 10
756 echo 11.ok4
757 else
758 echo 11.err4
759 endif
760 if $dietcurd -le 10
761 echo 11.ok5
762 else
763 echo 11.err5
764 endif
765 if $dietcurd -ge 11
766 echo 11.err6
767 else
768 echo 11.ok6
769 endif
770 if $dietcurd -le 9
771 echo 11.err7
772 else
773 echo 11.ok7
774 endif
775 else
776 echo 11.err1
777 endif
778 set dietcurd=Abc
779 if $dietcurd < aBd
780 echo 12.ok1
781 if $dietcurd @> abB
782 echo 12.ok2
783 else
784 echo 12.err2
785 endif
786 if $dietcurd @== aBC
787 echo 12.ok3
788 else
789 echo 12.err3
790 endif
791 if $dietcurd @>= AbC
792 echo 12.ok4
793 else
794 echo 12.err4
795 endif
796 if $dietcurd @<= ABc
797 echo 12.ok5
798 else
799 echo 12.err5
800 endif
801 if $dietcurd @>= abd
802 echo 12.err6
803 else
804 echo 12.ok6
805 endif
806 if $dietcurd @<= abb
807 echo 12.err7
808 else
809 echo 12.ok7
810 endif
811 else
812 echo 12.err1
813 endif
814 if $dietcurd < aBc
815 echo 12-1.ok
816 else
817 echo 12-1.err
818 endif
819 if $dietcurd @< aBc
820 echo 12-2.err
821 else
822 echo 12-2.ok
823 endif
824 if $dietcurd > ABc
825 echo 12-3.ok
826 else
827 echo 12-3.err
828 endif
829 if $dietcurd @> ABc
830 echo 12-3.err
831 else
832 echo 12-3.ok
833 endif
834 if $dietcurd @i=% aB
835 echo 13.ok
836 else
837 echo 13.err
838 endif
839 if $dietcurd =% aB
840 echo 13-1.err
841 else
842 echo 13-1.ok
843 endif
844 if $dietcurd @=% bC
845 echo 14.ok
846 else
847 echo 14.err
848 endif
849 if $dietcurd !% aB
850 echo 15-1.ok
851 else
852 echo 15-1.err
853 endif
854 if $dietcurd @!% aB
855 echo 15-2.err
856 else
857 echo 15-2.ok
858 endif
859 if $dietcurd !% bC
860 echo 15-3.ok
861 else
862 echo 15-3.err
863 endif
864 if $dietcurd @!% bC
865 echo 15-4.err
866 else
867 echo 15-4.ok
868 endif
869 if $dietcurd =% Cd
870 echo 16.err
871 else
872 echo 16.ok
873 endif
874 if $dietcurd !% Cd
875 echo 17.ok
876 else
877 echo 17.err
878 endif
879 set diet=abc curd=abc
880 if $diet == $curd
881 echo 18.ok
882 else
883 echo 18.err
884 endif
885 set diet=abc curd=abcd
886 if $diet != $curd
887 echo 19.ok
888 else
889 echo 19.err
890 endif
891 # 1. Shitty grouping capabilities as of today
892 unset diet curd ndefined
893 if [ [ false ] || [ false ] || [ true ] ] && [ [ false ] || [ true ] ] && \
894 [ yes ]
895 echo 20.ok
896 else
897 echo 20.err
898 endif
899 if [ [ [ [ 0 ] || [ 1 ] ] && [ [ 1 ] || [ 0 ] ] ] && [ 1 ] ] && [ yes ]
900 echo 21.ok
901 else
902 echo 21.err
903 endif
904 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] ]
905 echo 22.ok
906 else
907 echo 22.err
908 endif
909 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] ]
910 echo 23.ok
911 else
912 echo 23.err
913 endif
914 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] && [ no ]
915 echo 24.err
916 else
917 echo 24.ok
918 endif
919 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] \
920 && [ no ] || [ yes ]
921 echo 25.ok
922 else
923 echo 25.err
924 endif
925 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
926 echo 26.ok
927 else
928 echo 26.err
929 endif
930 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 0 ] ]
931 echo 27.err
932 else
933 echo 27.ok
934 endif
935 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 0 ] ] && [ 1 ] ] ] && [ 1 ] ]
936 echo 28.err
937 else
938 echo 28.ok
939 endif
940 if [ [ [ [ [ [ [ 0 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
941 echo 29.err
942 else
943 echo 29.ok
944 endif
945 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 0 ]
946 echo 30.err
947 else
948 echo 30.ok
949 endif
950 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 1 ]
951 echo 31.ok
952 else
953 echo 31.err
954 endif
955 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ]
956 echo 32.err
957 else
958 echo 32.ok
959 endif
960 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 1 ]
961 echo 33.ok
962 else
963 echo 33.err
964 endif
965 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 0 ]
966 echo 34.err
967 else
968 echo 34.ok
969 endif
970 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 1 ]
971 echo 35.ok
972 else
973 echo 35.err
974 endif
975 set diet=yo curd=ho
976 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
977 echo 36.err
978 else
979 echo 36.ok
980 endif
981 set ndefined
982 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
983 echo 37.ok
984 else
985 echo 37.err
986 endif
987 # 2. Shitty grouping capabilities as of today
988 unset diet curd ndefined
989 if [ false || false || true ] && [ false || true ] && yes
990 echo 40.ok
991 else
992 echo 40.err
993 endif
994 if [ [ [ 0 || 1 ] && [ 1 || 0 ] ] && 1 ] && [ yes ]
995 echo 41.ok
996 else
997 echo 41.err
998 endif
999 if [ 1 || 0 || 0 || 0 ]
1000 echo 42.ok
1001 else
1002 echo 42.err
1003 endif
1004 if [ 1 || 0 || 0 || 0 || [ 1 ] ]
1005 echo 43.ok
1006 else
1007 echo 43.err
1008 endif
1009 if [ 1 || 0 || 0 || 0 || [ 1 ] || 1 ] && no
1010 echo 44.err
1011 else
1012 echo 44.ok
1013 endif
1014 if [ 1 || 0 || 0 || 0 || 1 || [ 1 ] ] && no || [ yes ]
1015 echo 45.ok
1016 else
1017 echo 45.err
1018 endif
1019 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && 1 ] ] && [ 1 ] ]
1020 echo 46.ok
1021 else
1022 echo 46.err
1023 endif
1024 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && [ 1 ] ] ] && 0 ]
1025 echo 47.err
1026 else
1027 echo 47.ok
1028 endif
1029 if [ [ [ [ [ [ [ 1 ] ] && 1 ] && 0 ] && [ 1 ] ] ] && 1 ]
1030 echo 48.err
1031 else
1032 echo 48.ok
1033 endif
1034 if [ [ [ [ [ [ 0 ] && 1 ] && 1 ] && 1 ] ] && 1 ]
1035 echo 49.err
1036 else
1037 echo 49.ok
1038 endif
1039 if 1 || 0 || 0 || 0 && 0
1040 echo 50.err
1041 else
1042 echo 50.ok
1043 endif
1044 if 1 || 0 || 0 || 0 && 1
1045 echo 51.ok
1046 else
1047 echo 51.err
1048 endif
1049 if 0 || 0 || 0 || 1 && 0
1050 echo 52.err
1051 else
1052 echo 52.ok
1053 endif
1054 if 0 || 0 || 0 || 1 && 1
1055 echo 53.ok
1056 else
1057 echo 53.err
1058 endif
1059 if 0 || 0 || 0 || 1 && 0 || 1 && 0
1060 echo 54.err
1061 else
1062 echo 54.ok
1063 endif
1064 if 0 || 0 || 0 || 1 && 0 || 1 && 1
1065 echo 55.ok
1066 else
1067 echo 55.err
1068 endif
1069 set diet=yo curd=ho
1070 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
1071 echo 56.err
1072 else
1073 echo 56.ok
1074 endif
1075 if $diet == 'yo' && $curd == 'ho' && $ndefined
1076 echo 57.err
1077 else
1078 echo 57.ok
1079 endif
1080 set ndefined
1081 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
1082 echo 57.ok
1083 else
1084 echo 57.err
1085 endif
1086 if $diet == 'yo' && $curd == 'ho' && $ndefined
1087 echo 58.ok
1088 else
1089 echo 58.err
1090 endif
1091 if [ [ [ [ [ [ $diet == 'yo' && $curd == 'ho' && $ndefined ] ] ] ] ] ]
1092 echo 59.ok
1093 else
1094 echo 59.err
1095 endif
1096 # Some more en-braced variables
1097 set diet=yo curd=ho
1098 if ${diet} == ${curd}
1099 echo 70.err
1100 else
1101 echo 70.ok
1102 endif
1103 if ${diet} != ${curd}
1104 echo 71.ok
1105 else
1106 echo 71.err
1107 endif
1108 if $diet == ${curd}
1109 echo 72.err
1110 else
1111 echo 72.ok
1112 endif
1113 if ${diet} == $curd
1114 echo 73.err
1115 else
1116 echo 73.ok
1117 endif
1118 # Unary !
1119 if ! 0 && ! ! 1 && ! ! ! ! 2 && 3
1120 echo 80.ok
1121 else
1122 echo 80.err
1123 endif
1124 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ ! 2 ] ] ] && 3
1125 echo 81.ok
1126 else
1127 echo 81.err
1128 endif
1129 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1130 echo 82.ok
1131 else
1132 echo 82.err
1133 endif
1134 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
1135 echo 83.err
1136 else
1137 echo 83.ok
1138 endif
1139 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
1140 echo 84.err
1141 else
1142 echo 84.ok
1143 endif
1144 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1145 echo 85.err
1146 else
1147 echo 85.ok
1148 endif
1149 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1150 echo 86.err
1151 else
1152 echo 86.ok
1153 endif
1154 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] || 3
1155 echo 87.ok
1156 else
1157 echo 87.err
1158 endif
1159 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! ! [ 2 ] ] ] ] ]
1160 echo 88.ok
1161 else
1162 echo 88.err
1163 endif
1164 # Unary !, odd
1165 if ! 0 && ! ! 1 && ! ! ! 0 && 3
1166 echo 90.ok
1167 else
1168 echo 90.err
1169 endif
1170 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ 0 ] ] ] && 3
1171 echo 91.ok
1172 else
1173 echo 91.err
1174 endif
1175 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ [ 0 ] ] ] ] ] && 3
1176 echo 92.ok
1177 else
1178 echo 92.err
1179 endif
1180 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! ! [ ! [ ! 0 ] ] ] ] && ! 3
1181 echo 93.err
1182 else
1183 echo 93.ok
1184 endif
1185 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ ! [ ! [ ! [ ! 0 ] ] ] ] && 3
1186 echo 94.ok
1187 else
1188 echo 94.err
1189 endif
1190 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! ! [ ! [ ! [ ! [ 0 ] ] ] ] ] && 3
1191 echo 95.err
1192 else
1193 echo 95.ok
1194 endif
1195 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! ! 0 ] ] ] ] && 3
1196 echo 96.err
1197 else
1198 echo 96.ok
1199 endif
1200 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ ! 0 ] ] ] ] ] || 3
1201 echo 97.ok
1202 else
1203 echo 97.err
1204 endif
1205 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! [ 0 ] ] ] ] ]
1206 echo 98.ok
1207 else
1208 echo 98.err
1209 endif
1210 __EOT
1212 check behave:if-normal 0 "${MBOX}" '1688759742 719'
1214 if have_feat regex; then
1215 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
1216 set dietcurd=yoho
1217 if $dietcurd =~ '^yo.*'
1218 echo 1.ok
1219 else
1220 echo 1.err
1221 endif
1222 if $dietcurd =~ '^Yo.*'
1223 echo 1-1.err
1224 else
1225 echo 1-1.ok
1226 endif
1227 if $dietcurd @=~ '^Yo.*'
1228 echo 1-2.ok
1229 else
1230 echo 1-2.err
1231 endif
1232 if $dietcurd =~ '^yOho.+'
1233 echo 2.err
1234 else
1235 echo 2.ok
1236 endif
1237 if $dietcurd @!~ '.*Ho$'
1238 echo 3.err
1239 else
1240 echo 3.ok
1241 endif
1242 if $dietcurd !~ '.+yohO$'
1243 echo 4.ok
1244 else
1245 echo 4.err
1246 endif
1247 if [ $dietcurd @i!~ '.+yoho$' ]
1248 echo 5.ok
1249 else
1250 echo 5.err
1251 endif
1252 if ! [ $dietcurd @i=~ '.+yoho$' ]
1253 echo 6.ok
1254 else
1255 echo 6.err
1256 endif
1257 if ! ! [ $dietcurd @i!~ '.+yoho$' ]
1258 echo 7.ok
1259 else
1260 echo 7.err
1261 endif
1262 if ! [ ! [ $dietcurd @i!~ '.+yoho$' ] ]
1263 echo 8.ok
1264 else
1265 echo 8.err
1266 endif
1267 if [ ! [ ! [ $dietcurd @i!~ '.+yoho$' ] ] ]
1268 echo 9.ok
1269 else
1270 echo 9.err
1271 endif
1272 if ! [ ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
1273 echo 10.err
1274 else
1275 echo 10.ok
1276 endif
1277 if ! ! ! $dietcurd !~ '.+yoho$'
1278 echo 11.err
1279 else
1280 echo 11.ok
1281 endif
1282 if ! ! ! $dietcurd =~ '.+yoho$'
1283 echo 12.ok
1284 else
1285 echo 12.err
1286 endif
1287 if ! [ ! ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
1288 echo 13.ok
1289 else
1290 echo 13.err
1291 endif
1292 set diet=abc curd='^abc$'
1293 if $diet =~ $curd
1294 echo 14.ok
1295 else
1296 echo 14.err
1297 endif
1298 set diet=abc curd='^abcd$'
1299 if $diet !~ $curd
1300 echo 15.ok
1301 else
1302 echo 15.err
1303 endif
1304 __EOT
1306 check behave:if-regex 0 "${MBOX}" '1115671789 95'
1307 else
1308 printf 'behave:if-regex: unsupported, skipped\n'
1311 t_epilog
1314 t_behave_localopts() {
1315 t_prolog
1317 # Nestable conditions test
1318 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
1319 define t2 {
1320 echo in: t2
1321 set t2=t2
1322 echo $t2
1324 define t1 {
1325 echo in: t1
1326 set gv1=gv1
1327 localopts on
1328 set lv1=lv1 lv2=lv2
1329 set lv3=lv3
1330 call t2
1331 localopts off
1332 set gv2=gv2
1333 echo $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2
1335 define t0 {
1336 echo in: t0
1337 call t1
1338 echo $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2
1339 echo "$gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2"
1341 account trouble {
1342 echo in: trouble
1343 call t0
1345 call t0
1346 unset gv1 gv2
1347 account trouble
1348 echo active trouble: $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t3
1349 account null
1350 echo active null: $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t3
1351 __EOT
1353 check behave:localopts 0 "${MBOX}" '1936527193 192'
1355 t_epilog
1358 t_behave_macro_param_shift() {
1359 t_prolog
1361 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>/dev/null
1362 define t2 {
1363 echo in: t2
1364 echo t2.0 has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1365 localopts on
1366 wysh set ignerr=$1
1367 shift
1368 localopts off
1369 echo t2.1 has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1370 if [ $# > 1 ] || [ $ignerr == '' ]
1371 shift 2
1372 else
1373 ignerr shift 2
1374 endif
1375 echo t2.2:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1376 shift 0
1377 echo t2.3:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1378 if [ $# > 0 ]
1379 shift
1380 endif
1381 echo t2.4:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1383 define t1 {
1384 set errexit
1385 echo in: t1
1386 call t2 1 you get four args
1387 echo t1.1: $?';' ignerr ($ignerr) should not exist
1388 call t2 1 you get 'three args'
1389 echo t1.2: $?';' ignerr ($ignerr) should not exist
1390 call t2 1 you 'get two args'
1391 echo t1.3: $?';' ignerr ($ignerr) should not exist
1392 call t2 1 'you get one arg'
1393 echo t1.4: $?';' ignerr ($ignerr) should not exist
1394 ignerr call t2 '' 'you get one arg'
1395 echo t1.5: $?';' ignerr ($ignerr) should not exist
1397 call t1
1398 __EOT
1400 check behave:macro_param_shift 0 "${MBOX}" '1402489146 1682'
1402 t_epilog
1405 t_behave_addrcodec() {
1406 t_prolog
1408 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
1409 vput addrcodec res e 1 <doog@def>
1410 echo $?/$^ERRNAME $res
1411 eval vput addrcodec res d $res
1412 echo $?/$^ERRNAME $res
1413 vput addrcodec res e 2 . <doog@def>
1414 echo $?/$^ERRNAME $res
1415 eval vput addrcodec res d $res
1416 echo $?/$^ERRNAME $res
1417 vput addrcodec res e 3 Sauer Dr. <doog@def>
1418 echo $?/$^ERRNAME $res
1419 eval vput addrcodec res d $res
1420 echo $?/$^ERRNAME $res
1421 vput addrcodec res e 3.50 Sauer (Ma) Dr. <doog@def>
1422 echo $?/$^ERRNAME $res
1423 eval vput addrcodec res d $res
1424 echo $?/$^ERRNAME $res
1425 vput addrcodec res e 3.51 Sauer (Ma) "Dr." <doog@def>
1426 echo $?/$^ERRNAME $res
1427 eval vput addrcodec res d $res
1428 echo $?/$^ERRNAME $res
1430 vput addrcodec res +e 4 Sauer (Ma) Dr. <doog@def>
1431 echo $?/$^ERRNAME $res
1432 eval vput addrcodec res d $res
1433 echo $?/$^ERRNAME $res
1434 vput addrcodec res +e 5 Sauer (Ma) Braten Dr. <doog@def>
1435 echo $?/$^ERRNAME $res
1436 eval vput addrcodec res d $res
1437 echo $?/$^ERRNAME $res
1438 vput addrcodec res +e 6 Sauer (Ma) Braten Dr. (Heu) <doog@def>
1439 echo $?/$^ERRNAME $res
1440 eval vput addrcodec res d $res
1441 echo $?/$^ERRNAME $res
1442 vput addrcodec res +e 7 Sauer (Ma) Braten Dr. (Heu) <doog@def> (bu)
1443 echo $?/$^ERRNAME $res
1444 eval vput addrcodec res d $res
1445 echo $?/$^ERRNAME $res
1446 vput addrcodec res +e 8 \
1447 Dr. Sauer (Ma) Braten Dr. (Heu) <doog@def> (bu) Boom. Boom
1448 echo $?/$^ERRNAME $res
1449 eval vput addrcodec res d $res
1450 echo $?/$^ERRNAME $res
1451 vput addrcodec res +e 9 Dr.Sauer(Ma)Braten Dr. (Heu) <doog@def>
1452 echo $?/$^ERRNAME $res
1453 eval vput addrcodec res d $res
1454 echo $?/$^ERRNAME $res
1455 vput addrcodec res +e 10 (Ma)Braten Dr. (Heu) <doog@def>
1456 echo $?/$^ERRNAME $res
1457 eval vput addrcodec res d $res
1458 echo $?/$^ERRNAME $res
1459 vput addrcodec res +e 11 (Ma)Braten Dr"." (Heu) <doog@def>
1460 echo $?/$^ERRNAME $res
1461 eval vput addrcodec res d $res
1462 echo $?/$^ERRNAME $res
1463 vput addrcodec res +e 12 Dr. Sauer (Ma) Braten Dr. (u) <doog@def>
1464 echo $?/$^ERRNAME $res
1465 eval vput addrcodec res d $res
1466 echo $?/$^ERRNAME $res
1467 vput addrcodec res +e 13(Ma)Braten Dr. (Heu) <doog@def>
1468 echo $?/$^ERRNAME $res
1469 eval vput addrcodec res d $res
1470 echo $?/$^ERRNAME $res
1471 vput addrcodec res +e 14 Hey, Du <doog@def> Wie() findet Dr. das? ()
1472 echo $?/$^ERRNAME $res
1473 eval vput addrcodec res d $res
1474 echo $?/$^ERRNAME $res
1475 vput addrcodec res +e 15 \
1476 Hey, Du <doog@def> Wie() findet "" Dr. "" das? ()
1477 echo $?/$^ERRNAME $res
1478 eval vput addrcodec res d $res
1479 echo $?/$^ERRNAME $res
1480 vput addrcodec res +e 16 \
1481 "Hey," "Du" <doog@def> "Wie()" findet "" Dr. "" das? ()
1482 echo $?/$^ERRNAME $res
1483 eval vput addrcodec res d $res
1484 echo $?/$^ERRNAME $res
1485 vput addrcodec res +e 17 \
1486 "Hey" Du <doog@def> "Wie() findet " " Dr. """ das? ()
1487 echo $?/$^ERRNAME $res
1488 eval vput addrcodec res d $res
1489 echo $?/$^ERRNAME $res
1490 vput addrcodec res +e 18 \
1491 <doog@def> "Hey" Du "Wie() findet " " Dr. """ das? ()
1492 echo $?/$^ERRNAME $res
1493 eval vput addrcodec res d $res
1494 echo $?/$^ERRNAME $res
1495 vput addrcodec res +e 19 Hey\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1496 echo $?/$^ERRNAME $res
1497 eval vput addrcodec res d $res
1498 echo $?/$^ERRNAME $res
1500 vput addrcodec res ++e 20 Hey\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1501 echo $?/$^ERRNAME $res
1502 vput addrcodec res ++e 21 Hey\,\"" <doog@def> "Wie()" findet \" Dr. \" das?
1503 echo $?/$^ERRNAME $res
1504 eval vput addrcodec res d $res
1505 echo $?/$^ERRNAME $res
1507 vput addrcodec res +++e 22 Hey\\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1508 echo $?/$^ERRNAME $res
1509 eval vput addrcodec res d $res
1510 echo $?/$^ERRNAME $res
1512 vput addrcodec res s \
1513 "23 Hey\\,\\\" \"Wie" () "\" findet \\\" Dr. \\\" das?" <doog@def>
1514 echo $?/$^ERRNAME $res
1515 __EOT
1517 check behave:addrcodec 0 "${MBOX}" '429099645 2414'
1519 t_epilog
1522 t_behave_vexpr() {
1523 t_prolog
1525 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>/dev/null
1526 vput vexpr res = 9223372036854775807
1527 echo $?/$^ERRNAME $res
1528 vput vexpr res = 9223372036854775808
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 = -9223372036854775809
1535 echo $?/$^ERRNAME $res
1536 vput vexpr res =@ -9223372036854775809
1537 echo $?/$^ERRNAME $res
1538 echo ' #1'
1539 vput vexpr res ~ 0
1540 echo $?/$^ERRNAME $res
1541 vput vexpr res ~ 1
1542 echo $?/$^ERRNAME $res
1543 vput vexpr res ~ -1
1544 echo $?/$^ERRNAME $res
1545 echo ' #2'
1546 vput vexpr res + 0 0
1547 echo $?/$^ERRNAME $res
1548 vput vexpr res + 0 1
1549 echo $?/$^ERRNAME $res
1550 vput vexpr res + 1 1
1551 echo $?/$^ERRNAME $res
1552 echo ' #3'
1553 vput vexpr res + 9223372036854775807 0
1554 echo $?/$^ERRNAME $res
1555 vput vexpr res + 9223372036854775807 1
1556 echo $?/$^ERRNAME $res
1557 vput vexpr res +@ 9223372036854775807 1
1558 echo $?/$^ERRNAME $res
1559 vput vexpr res + 0 9223372036854775807
1560 echo $?/$^ERRNAME $res
1561 vput vexpr res + 1 9223372036854775807
1562 echo $?/$^ERRNAME $res
1563 vput vexpr res +@ 1 9223372036854775807
1564 echo $?/$^ERRNAME $res
1565 echo ' #4'
1566 vput vexpr res + -9223372036854775808 0
1567 echo $?/$^ERRNAME $res
1568 vput vexpr res + -9223372036854775808 -1
1569 echo $?/$^ERRNAME $res
1570 vput vexpr res +@ -9223372036854775808 -1
1571 echo $?/$^ERRNAME $res
1572 vput vexpr res + 0 -9223372036854775808
1573 echo $?/$^ERRNAME $res
1574 vput vexpr res + -1 -9223372036854775808
1575 echo $?/$^ERRNAME $res
1576 vput vexpr res +@ -1 -9223372036854775808
1577 echo $?/$^ERRNAME $res
1578 echo ' #5'
1579 vput vexpr res - 0 0
1580 echo $?/$^ERRNAME $res
1581 vput vexpr res - 0 1
1582 echo $?/$^ERRNAME $res
1583 vput vexpr res - 1 1
1584 echo $?/$^ERRNAME $res
1585 echo ' #6'
1586 vput vexpr res - 9223372036854775807 0
1587 echo $?/$^ERRNAME $res
1588 vput vexpr res - 9223372036854775807 -1
1589 echo $?/$^ERRNAME $res
1590 vput vexpr res -@ 9223372036854775807 -1
1591 echo $?/$^ERRNAME $res
1592 vput vexpr res - 0 9223372036854775807
1593 echo $?/$^ERRNAME $res
1594 vput vexpr res - -1 9223372036854775807
1595 echo $?/$^ERRNAME $res
1596 vput vexpr res - -2 9223372036854775807
1597 echo $?/$^ERRNAME $res
1598 vput vexpr res -@ -2 9223372036854775807
1599 echo $?/$^ERRNAME $res
1600 echo ' #7'
1601 vput vexpr res - -9223372036854775808 +0
1602 echo $?/$^ERRNAME $res
1603 vput vexpr res - -9223372036854775808 +1
1604 echo $?/$^ERRNAME $res
1605 vput vexpr res -@ -9223372036854775808 +1
1606 echo $?/$^ERRNAME $res
1607 vput vexpr res - 0 -9223372036854775808
1608 echo $?/$^ERRNAME $res
1609 vput vexpr res - +1 -9223372036854775808
1610 echo $?/$^ERRNAME $res
1611 vput vexpr res -@ +1 -9223372036854775808
1612 echo $?/$^ERRNAME $res
1613 echo ' #8'
1614 vput vexpr res + -13 -2
1615 echo $?/$^ERRNAME $res
1616 vput vexpr res - 0 0
1617 echo $?/$^ERRNAME $res
1618 vput vexpr res - 0 1
1619 echo $?/$^ERRNAME $res
1620 vput vexpr res - 1 1
1621 echo $?/$^ERRNAME $res
1622 vput vexpr res - -13 -2
1623 echo $?/$^ERRNAME $res
1624 echo ' #9'
1625 vput vexpr res * 0 0
1626 echo $?/$^ERRNAME $res
1627 vput vexpr res * 0 1
1628 echo $?/$^ERRNAME $res
1629 vput vexpr res * 1 1
1630 echo $?/$^ERRNAME $res
1631 vput vexpr res * -13 -2
1632 echo $?/$^ERRNAME $res
1633 echo ' #10'
1634 vput vexpr res / 0 0
1635 echo $?/$^ERRNAME $res
1636 vput vexpr res / 0 1
1637 echo $?/$^ERRNAME $res
1638 vput vexpr res / 1 1
1639 echo $?/$^ERRNAME $res
1640 vput vexpr res / -13 -2
1641 echo $?/$^ERRNAME $res
1642 echo ' #11'
1643 vput vexpr res % 0 0
1644 echo $?/$^ERRNAME $res
1645 vput vexpr res % 0 1
1646 echo $?/$^ERRNAME $res
1647 vput vexpr res % 1 1
1648 echo $?/$^ERRNAME $res
1649 vput vexpr res % -13 -2
1650 echo $?/$^ERRNAME $res
1651 __EOT
1653 check behave:vexpr-numeric 0 "${MBOX}" '1723609217 1048'
1655 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" #2>/dev/null
1656 vput vexpr res find 'bananarama' 'nana'
1657 echo $?/$^ERRNAME :$res:
1658 vput vexpr res find 'bananarama' 'bana'
1659 echo $?/$^ERRNAME :$res:
1660 vput vexpr res find 'bananarama' 'Bana'
1661 echo $?/$^ERRNAME :$res:
1662 vput vexpr res find 'bananarama' 'rama'
1663 echo $?/$^ERRNAME :$res:
1664 echo ' #1'
1665 vput vexpr res ifind 'bananarama' 'nana'
1666 echo $?/$^ERRNAME :$res:
1667 vput vexpr res ifind 'bananarama' 'bana'
1668 echo $?/$^ERRNAME :$res:
1669 vput vexpr res ifind 'bananarama' 'Bana'
1670 echo $?/$^ERRNAME :$res:
1671 vput vexpr res ifind 'bananarama' 'rama'
1672 echo $?/$^ERRNAME :$res:
1673 echo ' #2'
1674 vput vexpr res substring 'bananarama' 1
1675 echo $?/$^ERRNAME :$res:
1676 vput vexpr res substring 'bananarama' 3
1677 echo $?/$^ERRNAME :$res:
1678 vput vexpr res substring 'bananarama' 5
1679 echo $?/$^ERRNAME :$res:
1680 vput vexpr res substring 'bananarama' 7
1681 echo $?/$^ERRNAME :$res:
1682 vput vexpr res substring 'bananarama' 9
1683 echo $?/$^ERRNAME :$res:
1684 vput vexpr res substring 'bananarama' 10
1685 echo $?/$^ERRNAME :$res:
1686 vput vexpr res substring 'bananarama' 1 3
1687 echo $?/$^ERRNAME :$res:
1688 vput vexpr res substring 'bananarama' 3 3
1689 echo $?/$^ERRNAME :$res:
1690 vput vexpr res substring 'bananarama' 5 3
1691 echo $?/$^ERRNAME :$res:
1692 vput vexpr res substring 'bananarama' 7 3
1693 echo $?/$^ERRNAME :$res:
1694 vput vexpr res substring 'bananarama' 9 3
1695 echo $?/$^ERRNAME :$res:
1696 vput vexpr res substring 'bananarama' 10 3
1697 echo $?/$^ERRNAME :$res:
1698 echo ' #3'
1699 __EOT
1701 check behave:vexpr-string 0 "${MBOX}" '265398700 267'
1703 if have_feat regex; then
1704 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" #2>/dev/null
1705 vput vexpr res regex 'bananarama' 'nana'
1706 echo $?/$^ERRNAME :$res:
1707 vput vexpr res regex 'bananarama' 'bana'
1708 echo $?/$^ERRNAME :$res:
1709 vput vexpr res regex 'bananarama' 'Bana'
1710 echo $?/$^ERRNAME :$res:
1711 vput vexpr res regex 'bananarama' 'rama'
1712 echo $?/$^ERRNAME :$res:
1713 echo ' #1'
1714 vput vexpr res iregex 'bananarama' 'nana'
1715 echo $?/$^ERRNAME :$res:
1716 vput vexpr res iregex 'bananarama' 'bana'
1717 echo $?/$^ERRNAME :$res:
1718 vput vexpr res iregex 'bananarama' 'Bana'
1719 echo $?/$^ERRNAME :$res:
1720 vput vexpr res iregex 'bananarama' 'rama'
1721 echo $?/$^ERRNAME :$res:
1722 echo ' #2'
1723 vput vexpr res regex 'bananarama' '(.*)nana(.*)' '\${1}a\${0}u{\$2}'
1724 echo $?/$^ERRNAME :$res:
1725 vput vexpr res regex 'bananarama' '(.*)bana(.*)' '\${1}a\${0}u\$2'
1726 echo $?/$^ERRNAME :$res:
1727 vput vexpr res regex 'bananarama' 'Bana(.+)' '\$1\$0'
1728 echo $?/$^ERRNAME :$res:
1729 vput vexpr res regex 'bananarama' '(.+)rama' '\$1\$0'
1730 echo $?/$^ERRNAME :$res:
1731 echo ' #3'
1732 vput vexpr res iregex 'bananarama' '(.*)nana(.*)' '\${1}a\${0}u{\$2}'
1733 echo $?/$^ERRNAME :$res:
1734 vput vexpr res iregex 'bananarama' '(.*)bana(.*)' '\${1}a\${0}u\$2'
1735 echo $?/$^ERRNAME :$res:
1736 vput vexpr res iregex 'bananarama' 'Bana(.+)' '\$1\$0'
1737 echo $?/$^ERRNAME :$res:
1738 vput vexpr res iregex 'bananarama' '(.+)rama' '\$1\$0'
1739 echo $?/$^ERRNAME :$res:
1740 echo ' #4'
1741 __EOT
1743 check behave:vexpr-regex 0 "${MBOX}" '3270360157 311'
1744 else
1745 printf 'behave:vexpr-regex: unsupported, skipped\n'
1748 t_epilog
1751 t_behave_call_ret() {
1752 t_prolog
1754 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Snomemdebug > "${MBOX}" 2>&1
1755 define w1 {
1756 echon ">$1 "
1757 vput vexpr i + $1 1
1758 if [ $i -le 42 ]
1759 vput vexpr j '&' $i 7
1760 if [ $j -eq 7 ]
1761 echo .
1763 call w1 $i
1764 wysh set i=$? k=$!
1765 vput vexpr j '&' $i 7
1766 echon "<$1/$i/$k "
1767 if [ $j -eq 7 ]
1768 echo .
1770 else
1771 echo ! The end for $1
1773 return $1
1775 # Transport $?/$! up the call chain
1776 define w2 {
1777 echon ">$1 "
1778 vput vexpr i + $1 1
1779 if [ $1 -lt 42 ]
1780 call w2 $i
1781 wysh set i=$? j=$! k=$^ERRNAME
1782 echon "<$1/$i/$k "
1783 return $i $j
1784 else
1785 echo ! The end for $1
1786 return $i $^ERR-BUSY
1788 echoerr au
1790 # Up and down it goes
1791 define w3 {
1792 echon ">$1/$2 "
1793 vput vexpr i + $1 1
1794 if [ $1 -lt 42 ]
1795 call w3 $i $2
1796 wysh set i=$? j=$!
1797 vput vexpr k - $1 $2
1798 if [ $k -eq 21 ]
1799 vput vexpr i + $1 1
1800 vput vexpr j + $2 1
1801 echo "# <$i/$j> .. "
1802 call w3 $i $j
1803 wysh set i=$? j=$!
1805 eval echon "<\$1=\$i/\$^ERRNAME-$j "
1806 return $i $j
1807 else
1808 echo ! The end for $1=$i/$2
1809 if [ "$2" != "" ]
1810 return $i $^ERR-DOM
1811 else
1812 return $i $^ERR-BUSY
1815 echoerr au
1818 call w1 0; echo ?=$? !=$!; echo -----;
1819 call w2 0; echo ?=$? !=$^ERRNAME; echo -----;
1820 call w3 0 1; echo ?=$? !=$^ERRNAME; echo -----;
1821 __EOT
1823 check behave:call_ret 0 "${MBOX}" '1572045517 5922'
1825 t_epilog
1828 t_behave_xcall() {
1829 t_prolog
1831 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Snomemdebug > "${MBOX}" 2>&1
1832 define work {
1833 echon "$1 "
1834 vput vexpr i + $1 1
1835 if [ $i -le 1111 ]
1836 vput vexpr j '&' $i 7
1837 if [ $j -eq 7 ]
1838 echo .
1840 \xcall work $i $2
1842 echo ! The end for $1/$2
1843 if [ "$2" != "" ]
1844 return $i $^ERR-BUSY
1847 define xwork {
1848 \xcall work 0 $2
1850 call work 0
1851 echo ?=$? !=$!
1852 call xwork
1853 echo ?=$? !=$!
1854 xcall xwork
1855 echo ?=$? !=$^ERRNAME
1857 call work 0 yes
1858 echo ?=$? !=$^ERRNAME
1859 call xwork 0 yes
1860 echo ?=$? !=$^ERRNAME
1861 __EOT
1863 check behave:xcall-1 0 "${MBOX}" '2401702082 23801'
1867 ${cat} <<- '__EOT' > "${BODY}"
1868 define __w {
1869 echon "$1 "
1870 vput vexpr i + $1 1
1871 if [ $i -le 111 ]
1872 vput vexpr j '&' $i 7
1873 if [ $j -eq 7 ]
1874 echo .
1876 \xcall __w $i $2
1878 echo ! The end for $1
1879 if [ $2 -eq 0 ]
1880 nonexistingcommand
1881 echo would be err with errexit
1882 return
1884 echo calling exit
1885 exit
1887 define work {
1888 echo eins
1889 call __w 0 0
1890 echo zwei, ?=$? !=$!
1891 localopts yes; set errexit
1892 ignerr call __w 0 0
1893 echo drei, ?=$? !=$^ERRNAME
1894 call __w 0 $1
1895 echo vier, ?=$? !=$^ERRNAME, this is an error
1897 ignerr call work 0
1898 echo outer 1, ?=$? !=$^ERRNAME
1899 xxxign call work 0
1900 echo outer 2, ?=$? !=$^ERRNAME, could be error if xxxign non-empty
1901 call work 1
1902 echo outer 3, ?=$? !=$^ERRNAME
1903 echo this is definitely an error
1904 __EOT
1906 < "${BODY}" ${MAILX} ${ARGS} -X'commandalias xxxign ignerr' -Snomemdebug \
1907 > "${MBOX}" 2>&1
1908 check behave:xcall-2 0 "${MBOX}" '3900716531 4200'
1910 < "${BODY}" ${MAILX} ${ARGS} -X'commandalias xxxign " "' -Snomemdebug \
1911 > "${MBOX}" 2>&1
1912 check behave:xcall-3 1 "${MBOX}" '1006776201 2799'
1914 t_epilog
1917 t_behave_vpospar() {
1918 t_prolog
1920 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
1921 vpospar set hey, "'you ", world!
1922 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1923 vput vpospar x quote; echo x<$x>
1924 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1925 vput vpospar y quote;echo y<$y>
1926 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1927 eval vpospar set ${y};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1928 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1930 define infun2 {
1931 echo infun2:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
1932 vput vpospar z quote;echo infun2:z<$z>
1935 define infun {
1936 echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
1937 vput vpospar y quote;echo infun:y<$y>
1938 eval vpospar set ${x};echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
1939 vpospar clear;echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
1940 eval call infun2 $x
1941 echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
1942 eval vpospar set ${y};echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
1945 call infun This "in a" fun
1946 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1947 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1948 __EOT
1949 check behave:vpospar-1 0 "${MBOX}" '155175639 866'
1952 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
1953 set ifs=\'
1954 echo ifs<$ifs> ifs-ws<$ifs-ws>
1955 vpospar set hey, "'you ", world!
1956 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1957 vput vpospar x quote; echo x<$x>
1958 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1959 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1961 set ifs=,
1962 echo ifs<$ifs> ifs-ws<$ifs-ws>
1963 vpospar set hey, "'you ", world!
1964 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1965 vput vpospar x quote; echo x<$x>
1966 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1967 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1969 wysh set ifs=$',\t'
1970 echo ifs<$ifs> ifs-ws<$ifs-ws>
1971 vpospar set hey, "'you ", world!
1972 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1973 vput vpospar x quote; echo x<$x>
1974 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1975 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1976 __EOT
1977 check behave:vpospar-ifs 0 "${MBOX}" '2015927702 706'
1979 t_epilog
1982 t_behave_read() {
1983 t_prolog
1984 TRAP_EXIT_ADDONS="./.t*"
1986 ${cat} <<- '__EOT' > .tin
1987 hey1, "'you ", world!
1988 hey2, "'you ", bugs bunny!
1989 hey3, "'you ",
1990 hey4, "'you "
1991 __EOT
1993 ${cat} <<- '__EOT' |\
1994 ${MAILX} ${ARGS} -X'readctl create ./.tin' > "${MBOX}" 2>&1
1995 read a b c
1996 echo $?/$^ERRNAME / <$a><$b><$c>
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 readctl remove ./.tin;echo readctl remove:$?/$^ERRNAME
2006 __EOT
2007 check behave:read-1 0 "${MBOX}" '1527910147 173'
2009 ${cat} <<- '__EOT' > .tin2
2010 hey2.0,:"'you ",:world!:mars.:
2011 hey2.1,:"'you ",:world!
2012 hey2.2,:"'you ",:bugs bunny!
2013 hey2.3,:"'you ",:
2014 hey2.4,:"'you ":
2016 __EOT
2018 ${cat} <<- '__EOT' |\
2019 6< .tin2 ${MAILX} ${ARGS} -X 'readctl create 6' > "${MBOX}" 2>&1
2020 set ifs=:
2021 read a b c
2022 echo $?/$^ERRNAME / <$a><$b><$c>
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 readctl remove 6;echo readctl remove:$?/$^ERRNAME
2038 __EOT
2039 check behave:read-ifs 0 "${MBOX}" '890153490 298'
2041 t_epilog
2044 t_behave_mbox() {
2045 t_prolog
2046 TRAP_EXIT_ADDONS="./.t*"
2050 while [ ${i} -lt 112 ]; do
2051 printf 'm file://%s\n~s Subject %s\nHello %s!\n~.\n' \
2052 "${MBOX}" "${i}" "${i}"
2053 i=`add ${i} 1`
2054 done
2055 ) | ${MAILX} ${ARGS}
2056 check behave:mbox-1 0 "${MBOX}" '1140119864 13780'
2058 printf 'File "%s"
2059 copy * "%s"
2060 File "%s"
2061 from*
2062 ' "${MBOX}" .tmbox1 .tmbox1 |
2063 ${MAILX} ${ARGS} > .tlst
2064 check behave:mbox-2 0 .tlst '2739893312 9103'
2066 printf 'File "%s"
2067 copy * "file://%s"
2068 File "file://%s"
2069 from*
2070 ' "${MBOX}" .tmbox2 .tmbox2 |
2071 ${MAILX} ${ARGS} > .tlst
2072 check behave:mbox-3 0 .tlst '1702194178 9110'
2074 # only the odd (even)
2076 printf 'File "file://%s"
2077 copy ' .tmbox2
2079 while [ ${i} -lt 112 ]; do
2080 j=`modulo ${i} 2`
2081 [ ${j} -eq 1 ] && printf '%s ' "${i}"
2082 i=`add ${i} 1`
2083 done
2084 printf ' file://%s
2085 File "file://%s"
2086 from*
2087 ' .tmbox3 .tmbox3
2088 ) | ${MAILX} ${ARGS} > .tlst
2089 check behave:mbox-4 0 .tmbox3 '631132924 6890'
2090 check behave:mbox-5 - .tlst '2960975049 4573'
2091 # ...
2093 printf 'file "file://%s"
2094 move ' .tmbox2
2096 while [ ${i} -lt 112 ]; do
2097 j=`modulo ${i} 2`
2098 [ ${j} -eq 0 ] && [ ${i} -ne 0 ] && printf '%s ' "${i}"
2099 i=`add ${i} 1`
2100 done
2101 printf ' file://%s
2102 File "file://%s"
2103 from*
2104 File "file://%s"
2105 from*
2106 ' .tmbox3 .tmbox3 .tmbox2
2107 ) | ${MAILX} ${ARGS} > .tlst
2108 check behave:mbox-6 0 .tmbox3 '1387070539 13655'
2109 ${sed} 2d < .tlst > .tlstx
2110 check behave:mbox-7 - .tlstx '2729940494 13645'
2112 t_epilog
2115 t_behave_alias() {
2116 t_prolog
2117 TRAP_EXIT_ADDONS="./.t*"
2119 ${cat} <<-_EOT > ./.tsendmail.sh
2120 #!${MYSHELL} -
2121 (echo 'From Hippocastanum Mon Jun 19 15:07:07 2017' && ${cat} && echo
2122 ) >> "${MBOX}"
2123 _EOT
2124 chmod 0755 ./.tsendmail.sh
2126 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Smta=./.tsendmail.sh > ./.tall 2>&1
2127 alias a1 ex1@a1.ple
2128 alias a1 ex2@a1.ple "EX3 <ex3@a1.ple>"
2129 alias a1 ex4@a1.ple
2130 alias a2 ex1@a2.ple ex2@a2.ple ex3@a2.ple ex4@a2.ple
2131 alias a3 a4
2132 alias a4 a5 ex1@a4.ple
2133 alias a5 a6
2134 alias a6 a7 ex1@a6.ple
2135 alias a7 a8
2136 alias a8 ex1@a8.ple
2137 alias a1
2138 alias a2
2139 alias a3
2140 m a1
2141 ~c a2
2142 ~b a3
2143 ~r - '_EOT'
2144 This body is!
2145 This also body is!!
2146 _EOT
2147 __EOT
2148 check behave:alias-1 0 "${MBOX}" '2496925843 272'
2149 check behave:alias-2 - .tall '3548953204 152'
2151 # TODO t_behave_alias: n_ALIAS_MAXEXP is compile-time constant,
2152 # TODO need to somehow provide its contents to the test, then test
2154 t_epilog
2157 t_behave_filetype() {
2158 t_prolog
2159 TRAP_EXIT_ADDONS="./.t*"
2161 ${cat} <<-_EOT > ./.tsendmail.sh
2162 #!${MYSHELL} -
2163 (echo 'From Alchemilla Wed Apr 25 15:12:13 2017' && ${cat} && echo
2164 ) >> "${MBOX}"
2165 _EOT
2166 chmod 0755 ./.tsendmail.sh
2168 printf 'm m1@e.t\nL1\nHy1\n~.\nm m2@e.t\nL2\nHy2\n~@ ./snailmail.jpg\n~.\n' |
2169 ${MAILX} ${ARGS} -Smta=./.tsendmail.sh
2170 check behave:filetype-1 0 "${MBOX}" '1645747150 13536'
2172 if command -v gzip >/dev/null 2>&1; then
2173 ${rm} -f ./.t.mbox*
2175 printf 'File "%s"\ncopy 1 ./.t.mbox.gz
2176 copy 2 ./.t.mbox.gz' "${MBOX}" |
2177 ${MAILX} ${ARGS} \
2178 -X'filetype gz gzip\ -dc gzip\ -c'
2179 printf 'File ./.t.mbox.gz\ncopy * ./.t.mbox\n' |
2180 ${MAILX} ${ARGS} \
2181 -X'filetype gz gzip\ -dc gzip\ -c'
2182 } >/dev/null 2>&1
2183 check behave:filetype-2 0 "./.t.mbox" '1645747150 13536'
2184 else
2185 echo 'behave:filetype-2: unsupported, skipped'
2189 ${rm} -f ./.t.mbox*
2190 printf 'File "%s"\ncopy 1 ./.t.mbox.gz
2191 copy 2 ./.t.mbox.gz
2192 copy 1 ./.t.mbox.gz
2193 copy 2 ./.t.mbox.gz
2194 ' "${MBOX}" |
2195 ${MAILX} ${ARGS} \
2196 -X'filetype gz gzip\ -dc gzip\ -c' \
2197 -X'filetype mbox.gz "${sed} 1,3d|${cat}" \
2198 "echo eins;echo zwei;echo und mit ${sed} bist Du dabei;${cat}"'
2199 printf 'File ./.t.mbox.gz\ncopy * ./.t.mbox\n' |
2200 ${MAILX} ${ARGS} \
2201 -X'filetype gz gzip\ -dc gzip\ -c' \
2202 -X'filetype mbox.gz "${sed} 1,3d|${cat}" kill\ 0'
2203 } >/dev/null 2>&1
2205 check behave:filetype-3 - "./.t.mbox" '238021003 27092'
2207 t_epilog
2210 t_behave_record_a_resend() {
2211 t_prolog
2212 TRAP_EXIT_ADDONS="./.t.record ./.t.resent"
2214 printf '
2215 set record=%s
2216 m %s\n~s Subject 1.\nHello.\n~.
2217 set record-files add-file-recipients
2218 m %s\n~s Subject 2.\nHello.\n~.
2219 File %s
2220 resend 2 ./.t.resent
2221 Resend 1 ./.t.resent
2222 set record-resent
2223 resend 2 ./.t.resent
2224 Resend 1 ./.t.resent
2225 ' ./.t.record "${MBOX}" "${MBOX}" "${MBOX}" |
2226 ${MAILX} ${ARGS}
2228 check behave:record_a_resend-1 0 "${MBOX}" '3057873538 256'
2229 check behave:record_a_resend-2 - .t.record '391356429 460'
2230 check behave:record_a_resend-3 - .t.resent '2685231691 648'
2232 t_epilog
2235 t_behave_e_H_L_opts() {
2236 t_prolog
2237 TRAP_EXIT_ADDONS="./.tsendmail.sh ./.t.mbox"
2239 touch ./.t.mbox
2240 ${MAILX} ${ARGS} -ef ./.t.mbox
2241 echo ${?} > "${MBOX}"
2243 ${cat} <<-_EOT > ./.tsendmail.sh
2244 #!${MYSHELL} -
2245 (echo 'From Alchemilla Wed Apr 07 17:03:33 2017' && ${cat} && echo
2246 ) >> "./.t.mbox"
2247 _EOT
2248 chmod 0755 ./.tsendmail.sh
2249 printf 'm me@exam.ple\nLine 1.\nHello.\n~.\n' |
2250 ${MAILX} ${ARGS} -Smta=./.tsendmail.sh
2251 printf 'm you@exam.ple\nLine 1.\nBye.\n~.\n' |
2252 ${MAILX} ${ARGS} -Smta=./.tsendmail.sh
2254 ${MAILX} ${ARGS} -ef ./.t.mbox
2255 echo ${?} >> "${MBOX}"
2256 ${MAILX} ${ARGS} -efL @t@me ./.t.mbox
2257 echo ${?} >> "${MBOX}"
2258 ${MAILX} ${ARGS} -efL @t@you ./.t.mbox
2259 echo ${?} >> "${MBOX}"
2260 ${MAILX} ${ARGS} -efL '@>@Line 1' ./.t.mbox
2261 echo ${?} >> "${MBOX}"
2262 ${MAILX} ${ARGS} -efL '@>@Hello.' ./.t.mbox
2263 echo ${?} >> "${MBOX}"
2264 ${MAILX} ${ARGS} -efL '@>@Bye.' ./.t.mbox
2265 echo ${?} >> "${MBOX}"
2266 ${MAILX} ${ARGS} -efL '@>@Good bye.' ./.t.mbox
2267 echo ${?} >> "${MBOX}"
2269 ${MAILX} ${ARGS} -fH ./.t.mbox >> "${MBOX}"
2270 echo ${?} >> "${MBOX}"
2271 ${MAILX} ${ARGS} -fL @t@me ./.t.mbox >> "${MBOX}"
2272 echo ${?} >> "${MBOX}"
2273 ${MAILX} ${ARGS} -fL @t@you ./.t.mbox >> "${MBOX}"
2274 echo ${?} >> "${MBOX}"
2275 ${MAILX} ${ARGS} -fL '@>@Line 1' ./.t.mbox >> "${MBOX}"
2276 echo ${?} >> "${MBOX}"
2277 ${MAILX} ${ARGS} -fL '@>@Hello.' ./.t.mbox >> "${MBOX}"
2278 echo ${?} >> "${MBOX}"
2279 ${MAILX} ${ARGS} -fL '@>@Bye.' ./.t.mbox >> "${MBOX}"
2280 echo ${?} >> "${MBOX}"
2281 ${MAILX} ${ARGS} -fL '@>@Good bye.' ./.t.mbox >> "${MBOX}" 2>/dev/null
2282 echo ${?} >> "${MBOX}"
2284 check behave:e_H_L_opts - "${MBOX}" '1708955574 678'
2286 t_epilog
2289 t_behave_compose_hooks() { # TODO monster: "tests" also `alternates', at least
2290 t_prolog
2291 TRAP_EXIT_ADDONS="./.t*"
2293 (echo line one&&echo line two&&echo line three) > ./.treadctl
2294 (echo echo four&&echo echo five&&echo echo six) > ./.tattach
2296 ${cat} <<-_EOT > ./.tsendmail.sh
2297 #!${MYSHELL} -
2298 (echo 'From PrimulaVeris Wed Apr 10 22:59:00 2017' && ${cat} && echo
2299 ) >> "${MBOX}"
2300 _EOT
2301 chmod 0755 ./.tsendmail.sh
2303 ${cat} <<'__EOT__' > ./.trc
2304 define bail {
2305 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
2307 define xerr {
2308 vput vexpr es substr "$1" 0 1
2309 if [ "$es" != 2 ]
2310 xcall bail "$2"
2313 define read_mline_res {
2314 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
2315 echo $len/$es/$^ERRNAME: $hl
2316 if [ $es -ne $^ERR-NONE ]
2317 xcall bail read_mline_res
2318 elif [ $len -ne 0 ]
2319 \xcall read_mline_res
2322 define ins_addr {
2323 wysh set xh=$1
2324 echo "~^header list"; read hl; echo $hl;\
2325 call xerr "$hl" "in_addr ($xh) 0-1"
2327 echo "~^header insert $xh diet <$xh@exam.ple> spliced";\
2328 read es; echo $es; call xerr "$es" "ins_addr $xh 1-1"
2329 echo "~^header insert $xh <${xh}2@exam.ple>";\
2330 read es; echo $es; call xerr "$es" "ins_addr $xh 1-2"
2331 echo "~^header insert $xh ${xh}3@exam.ple";\
2332 read es; echo $es; call xerr "$es" "ins_addr $xh 1-3"
2333 echo "~^header list $xh"; read hl; echo $hl;\
2334 call xerr "$hl" "ins_addr $xh 1-4"
2335 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 1-5"
2336 call read_mline_res
2338 if [ "$t_remove" == "" ]
2339 return
2342 echo "~^header remove $xh"; read es; call xerr $es "ins_addr $xh 2-1"
2343 echo "~^header remove $xh"; read es; vput vexpr es substr $es 0 3
2344 if [ $es != 501 ]
2345 xcall bail "ins_addr $xh 2-2"
2347 echo "~^header list $xh"; read es; vput vexpr es substr $es 0 3
2348 if [ $es != 501 ]
2349 xcall bail "ins_addr $xh 2-3"
2351 echo "~^header show $xh"; read es; vput vexpr es substr $es 0 3
2352 if [ $es != 501 ]
2353 xcall bail "ins_addr $xh 2-4"
2357 echo "~^header insert $xh diet <$xh@exam.ple> spliced";\
2358 read es; echo $es; call xerr "$es" "ins_addr $xh 3-1"
2359 echo "~^header insert $xh <${xh}2@exam.ple>";\
2360 read es; echo $es; call xerr "$es" "ins_addr $xh 3-2"
2361 echo "~^header insert $xh ${xh}3@exam.ple";\
2362 read es; echo $es; call xerr "$es" "ins_addr $xh 3-3"
2363 echo "~^header list $xh"; read hl; echo $hl;\
2364 call xerr "$hl" "ins_addr $xh 3-4"
2365 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 3-5"
2366 call read_mline_res
2368 echo "~^header remove-at $xh 1"; read es;\
2369 call xerr $es "ins_addr $xh 3-6"
2370 echo "~^header remove-at $xh 1"; read es;\
2371 call xerr $es "ins_addr $xh 3-7"
2372 echo "~^header remove-at $xh 1"; read es;\
2373 call xerr $es "ins_addr $xh 3-8"
2374 echo "~^header remove-at $xh 1"; read es;\
2375 vput vexpr es substr $es 0 3
2376 if [ $es != 501 ]
2377 xcall bail "ins_addr $xh 3-9"
2379 echo "~^header remove-at $xh T"; read es;\
2380 vput vexpr es substr $es 0 3
2381 if [ $es != 505 ]
2382 xcall bail "ins_addr $xh 3-10"
2384 echo "~^header list $xh"; read es;\
2385 vput vexpr es substr $es 0 3
2386 if [ $es != 501 ]
2387 xcall bail "ins_addr $xh 3-11"
2389 echo "~^header show $xh"; read es;\
2390 vput vexpr es substr $es 0 3
2391 if [ $es != 501 ]
2392 xcall bail "ins_addr $xh 3-12"
2396 echo "~^header insert $xh diet <$xh@exam.ple> spliced";\
2397 read es; echo $es; call xerr "$es" "ins_addr $xh 4-1"
2398 echo "~^header insert $xh <${xh}2@exam.ple> (comment) \"Quot(e)d\"";\
2399 read es; echo $es; call xerr "$es" "ins_addr $xh 4-2"
2400 echo "~^header insert $xh ${xh}3@exam.ple";\
2401 read es; echo $es; call xerr "$es" "ins_addr $xh 4-3"
2402 echo "~^header list $xh"; read hl; echo $hl;\
2403 call xerr "$hl" "header list $xh 3-4"
2404 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 4-5"
2405 call read_mline_res
2407 echo "~^header remove-at $xh 3"; read es;\
2408 call xerr $es "ins_addr $xh 4-6"
2409 echo "~^header remove-at $xh 2"; read es;\
2410 call xerr $es "ins_addr $xh 4-7"
2411 echo "~^header remove-at $xh 1"; read es;\
2412 call xerr $es "ins_addr $xh 4-8"
2413 echo "~^header remove-at $xh 1"; read es;\
2414 vput vexpr es substr $es 0 3
2415 if [ $es != 501 ]
2416 xcall bail "ins_addr $xh 4-9"
2418 echo "~^header remove-at $xh T"; read es;\
2419 vput vexpr es substr $es 0 3
2420 if [ $es != 505 ]
2421 xcall bail "ins_addr $xh 4-10"
2423 echo "~^header list $xh"; read es;\
2424 vput vexpr es substr $es 0 3
2425 if [ $es != 501 ]
2426 xcall bail "ins_addr $xh 4-11"
2428 echo "~^header show $xh"; read es;\
2429 vput vexpr es substr $es 0 3
2430 if [ $es != 501 ]
2431 xcall bail "ins_addr $xh 4-12"
2434 define ins_ref {
2435 wysh set xh=$1 mult=$2
2436 echo "~^header list"; read hl; echo $hl;\
2437 call xerr "$hl" "ins_ref ($xh) 0-1"
2439 echo "~^header insert $xh <$xh@exam.ple>";\
2440 read es; echo $es; call xerr "$es" "ins_ref $xh 1-1"
2441 if [ $mult -ne 0 ]
2442 echo "~^header insert $xh <${xh}2@exam.ple>";\
2443 read es; echo $es; call xerr "$es" "ins_ref $xh 1-2"
2444 echo "~^header insert $xh ${xh}3@exam.ple";\
2445 read es; echo $es; call xerr "$es" "ins_ref $xh 1-3"
2446 else
2447 echo "~^header insert $xh <${xh}2@exam.ple>"; read es;\
2448 vput vexpr es substr $es 0 3
2449 if [ $es != 506 ]
2450 xcall bail "ins_ref $xh 1-4"
2454 echo "~^header list $xh"; read hl; echo $hl;\
2455 call xerr "$hl" "ins_ref $xh 1-5"
2456 echo "~^header show $xh"; read es; call xerr $es "ins_ref $xh 1-6"
2457 call read_mline_res
2459 if [ "$t_remove" == "" ]
2460 return
2463 echo "~^header remove $xh"; read es;\
2464 call xerr $es "ins_ref $xh 2-1"
2465 echo "~^header remove $xh"; read es;\
2466 vput vexpr es substr $es 0 3
2467 if [ $es != 501 ]
2468 xcall bail "ins_ref $xh 2-2"
2470 echo "~^header list $xh"; read es;\
2471 vput vexpr es substr $es 0 3
2472 if [ $es != 501 ]
2473 xcall bail "$es ins_ref $xh 2-3"
2475 echo "~^header show $xh"; read es;\
2476 vput vexpr es substr $es 0 3
2477 if [ $es != 501 ]
2478 xcall bail "ins_ref $xh 2-4"
2482 echo "~^header insert $xh <$xh@exam.ple>";\
2483 read es; echo $es; call xerr "$es" "ins_ref $xh 3-1"
2484 if [ $mult -ne 0 ]
2485 echo "~^header insert $xh <${xh}2@exam.ple>";\
2486 read es; echo $es; call xerr "$es" "ins_ref $xh 3-2"
2487 echo "~^header insert $xh ${xh}3@exam.ple";\
2488 read es; echo $es; call xerr "$es" "ins_ref $xh 3-3"
2490 echo "~^header list $xh";\
2491 read hl; echo $hl; call xerr "$hl" "ins_ref $xh 3-4"
2492 echo "~^header show $xh";\
2493 read es; call xerr $es "ins_ref $xh 3-5"
2494 call read_mline_res
2496 echo "~^header remove-at $xh 1"; read es;\
2497 call xerr $es "ins_ref $xh 3-6"
2498 if [ $mult -ne 0 ] && [ $xh != subject ]
2499 echo "~^header remove-at $xh 1"; read es;\
2500 call xerr $es "ins_ref $xh 3-7"
2501 echo "~^header remove-at $xh 1"; read es;\
2502 call xerr $es "ins_ref $xh 3-8"
2504 echo "~^header remove-at $xh 1"; read es;\
2505 vput vexpr es substr $es 0 3
2506 if [ $es != 501 ]
2507 xcall bail "ins_ref $xh 3-9"
2509 echo "~^header remove-at $xh T"; read es;\
2510 vput vexpr es substr $es 0 3
2511 if [ $es != 505 ]
2512 xcall bail "ins_ref $xh 3-10"
2514 echo "~^header show $xh"; read es;\
2515 vput vexpr es substr $es 0 3
2516 if [ $es != 501 ]
2517 xcall bail "ins_ref $xh 3-11"
2521 echo "~^header insert $xh <$xh@exam.ple> ";\
2522 read es; echo $es; call xerr "$es" "ins_ref $xh 4-1"
2523 if [ $mult -ne 0 ]
2524 echo "~^header insert $xh <${xh}2@exam.ple> ";\
2525 read es; echo $es; call xerr "$es" "ins_ref $xh 4-2"
2526 echo "~^header insert $xh ${xh}3@exam.ple";\
2527 read es; echo $es; call xerr "$es" "ins_ref $xh 4-3"
2529 echo "~^header list $xh"; read hl; echo $hl;\
2530 call xerr "$hl" "ins_ref $xh 4-4"
2531 echo "~^header show $xh"; read es; call xerr $es "ins_ref $xh 4-5"
2532 call read_mline_res
2534 if [ $mult -ne 0 ] && [ $xh != subject ]
2535 echo "~^header remove-at $xh 3"; read es;\
2536 call xerr $es "ins_ref $xh 4-6"
2537 echo "~^header remove-at $xh 2"; read es;\
2538 call xerr $es "ins_ref $xh 4-7"
2540 echo "~^header remove-at $xh 1"; read es;\
2541 call xerr $es "ins_ref $xh 4-8"
2542 echo "~^header remove-at $xh 1"; read es;\
2543 vput vexpr es substr $es 0 3
2544 if [ $es != 501 ]
2545 xcall bail "ins_ref $xh 4-9"
2547 echo "~^header remove-at $xh T"; read es;\
2548 vput vexpr es substr $es 0 3
2549 if [ $es != 505 ]
2550 xcall bail "ins_ref $xh 4-10"
2552 echo "~^header show $xh"; read es;\
2553 vput vexpr es substr $es 0 3
2554 if [ $es != 501 ]
2555 xcall bail "ins_ref $xh 4-11"
2558 define t_header {
2559 echo t_header ENTER
2560 # In collect.c order
2561 call ins_addr from
2562 call ins_ref sender 0 # Not a "ref", but works
2563 call ins_addr To
2564 call ins_addr cC
2565 call ins_addr bCc
2566 call ins_addr reply-To
2567 call ins_addr mail-Followup-to
2568 call ins_ref messAge-id 0
2569 call ins_ref rEfErEncEs 1
2570 call ins_ref in-Reply-to 1
2571 call ins_ref subject 1 # Not a "ref", but works (with tweaks)
2572 call ins_addr freeForm1
2573 call ins_addr freeform2
2575 echo "~^header show MAILX-Command"; read es; call xerr $es "t_header 1000"
2576 call read_mline_res
2577 echo "~^header show MAILX-raw-TO"; read es; call xerr $es "t_header 1001"
2578 call read_mline_res
2580 echo t_header LEAVE
2582 define t_attach {
2583 echo t_attach ENTER
2585 echo "~^attachment";\
2586 read hl; echo $hl; vput vexpr es substr "$hl" 0 3
2587 if [ "$es" != 501 ]
2588 xcall bail "attach 0-1"
2591 echo "~^attach attribute ./.treadctl";\
2592 read hl; echo $hl; vput vexpr es substr "$hl" 0 3
2593 if [ "$es" != 501 ]
2594 xcall bail "attach 0-2"
2596 echo "~^attachment attribute-at 1";\
2597 read hl; echo $hl; vput vexpr es substr "$hl" 0 3
2598 if [ "$es" != 501 ]
2599 xcall bail "attach 0-3"
2602 echo "~^attachment insert ./.treadctl=ascii";\
2603 read hl; echo $hl; call xerr "$hl" "attach 1-1"
2604 echo "~^attachment list";\
2605 read es; echo $es;call xerr "$es" "attach 1-2"
2606 call read_mline_res
2607 echo "~^attachment attribute ./.treadctl";\
2608 read es; echo $es;call xerr "$es" "attach 1-3"
2609 call read_mline_res
2610 echo "~^attachment attribute .treadctl";\
2611 read es; echo $es;call xerr "$es" "attach 1-4"
2612 call read_mline_res
2613 echo "~^attachment attribute-at 1";\
2614 read es; echo $es;call xerr "$es" "attach 1-5"
2615 call read_mline_res
2617 echo "~^attachment attribute-set ./.treadctl filename rctl";\
2618 read es; echo $es;call xerr "$es" "attach 1-6"
2619 echo "~^attachment attribute-set .treadctl content-description Au";\
2620 read es; echo $es;call xerr "$es" "attach 1-7"
2621 echo "~^attachment attribute-set-at 1 content-id <10.du@ich>";\
2622 read es; echo $es;call xerr "$es" "attach 1-8"
2624 echo "~^attachment attribute ./.treadctl";\
2625 read es; echo $es;call xerr "$es" "attach 1-9"
2626 call read_mline_res
2627 echo "~^attachment attribute .treadctl";\
2628 read es; echo $es;call xerr "$es" "attach 1-10"
2629 call read_mline_res
2630 echo "~^attachment attribute rctl";\
2631 read es; echo $es;call xerr "$es" "attach 1-11"
2632 call read_mline_res
2633 echo "~^attachment attribute-at 1";\
2634 read es; echo $es;call xerr "$es" "attach 1-12"
2635 call read_mline_res
2638 echo "~^attachment insert ./.tattach=latin1";\
2639 read hl; echo $hl; call xerr "$hl" "attach 2-1"
2640 echo "~^attachment list";\
2641 read es; echo $es;call xerr "$es" "attach 2-2"
2642 call read_mline_res
2643 echo "~^attachment attribute ./.tattach";\
2644 read es; echo $es;call xerr "$es" "attach 2-3"
2645 call read_mline_res
2646 echo "~^attachment attribute .tattach";\
2647 read es; echo $es;call xerr "$es" "attach 2-4"
2648 call read_mline_res
2649 echo "~^attachment attribute-at 2";\
2650 read es; echo $es;call xerr "$es" "attach 2-5"
2651 call read_mline_res
2653 echo "~^attachment attribute-set ./.tattach filename tat";\
2654 read es; echo $es;call xerr "$es" "attach 2-6"
2655 echo \
2656 "~^attachment attribute-set .tattach content-description Au2";\
2657 read es; echo $es;call xerr "$es" "attach 2-7"
2658 echo "~^attachment attribute-set-at 2 content-id <20.du@wir>";\
2659 read es; echo $es;call xerr "$es" "attach 2-8"
2660 echo \
2661 "~^attachment attribute-set-at 2 content-type application/x-sh";\
2662 read es; echo $es;call xerr "$es" "attach 2-9"
2664 echo "~^attachment attribute ./.tattach";\
2665 read es; echo $es;call xerr "$es" "attach 2-10"
2666 call read_mline_res
2667 echo "~^attachment attribute .tattach";\
2668 read es; echo $es;call xerr "$es" "attach 2-11"
2669 call read_mline_res
2670 echo "~^attachment attribute tat";\
2671 read es; echo $es;call xerr "$es" "attach 2-12"
2672 call read_mline_res
2673 echo "~^attachment attribute-at 2";\
2674 read es; echo $es;call xerr "$es" "attach 2-13"
2675 call read_mline_res
2678 if [ "$t_remove" == "" ]
2679 return
2682 echo "~^attachment remove ./.treadctl"; read es;\
2683 call xerr $es "attach 3-1"
2684 echo "~^attachment remove ./.tattach"; read es;\
2685 call xerr $es "attach 3-2"
2686 echo "~^ attachment remove ./.treadctl"; read es;\
2687 vput vexpr es substr $es 0 3
2688 if [ $es != 501 ]
2689 xcall bail "attach 3-3"
2691 echo "~^ attachment remove ./.tattach"; read es;\
2692 vput vexpr es substr $es 0 3
2693 if [ $es != 501 ]
2694 xcall bail "attach 3-4"
2696 echo "~^attachment list"; read es;\
2697 vput vexpr es substr $es 0 3
2698 if [ $es != 501 ]
2699 xcall bail "attach 3-5"
2703 echo "~^attachment insert ./.tattach=latin1";\
2704 read hl; echo $hl; call xerr "$hl" "attach 4-1"
2705 echo "~^attachment insert ./.tattach=latin1";\
2706 read hl; echo $hl; call xerr "$hl" "attach 4-2"
2707 echo "~^attachment list";\
2708 read es; echo $es;call xerr "$es" "attach 4-3"
2709 call read_mline_res
2710 echo "~^ attachment remove .tattach"; read es;\
2711 vput vexpr es substr $es 0 3
2712 if [ $es != 506 ]
2713 xcall bail "attach 4-4 $es"
2715 echo "~^attachment remove-at T"; read es;\
2716 vput vexpr es substr $es 0 3
2717 if [ $es != 505 ]
2718 xcall bail "attach 4-5"
2720 echo "~^attachment remove ./.tattach"; read es;\
2721 call xerr $es "attach 4-6"
2722 echo "~^attachment remove ./.tattach"; read es;\
2723 call xerr $es "attach 4-7"
2724 echo "~^ attachment remove ./.tattach"; read es;\
2725 vput vexpr es substr $es 0 3
2726 if [ $es != 501 ]
2727 xcall bail "attach 4-8 $es"
2729 echo "~^attachment list"; read es;\
2730 vput vexpr es substr $es 0 3
2731 if [ $es != 501 ]
2732 xcall bail "attach 4-9"
2736 echo "~^attachment insert ./.tattach=latin1";\
2737 read hl; echo $hl; call xerr "$hl" "attach 5-1"
2738 echo "~^attachment insert ./.tattach=latin1";\
2739 read hl; echo $hl; call xerr "$hl" "attach 5-2"
2740 echo "~^attachment insert ./.tattach=latin1";\
2741 read hl; echo $hl; call xerr "$hl" "attach 5-3"
2742 echo "~^attachment list";\
2743 read es; echo $es;call xerr "$es" "attach 5-4"
2744 call read_mline_res
2746 echo "~^attachment remove-at 3"; read es;\
2747 call xerr $es "attach 5-5"
2748 echo "~^attachment remove-at 3"; read es;\
2749 vput vexpr es substr $es 0 3
2750 if [ $es != 501 ]
2751 xcall bail "attach 5-6"
2753 echo "~^attachment remove-at 2"; read es;\
2754 call xerr $es "attach 5-7"
2755 echo "~^attachment remove-at 2"; read es;\
2756 vput vexpr es substr $es 0 3
2757 if [ $es != 501 ]
2758 xcall bail "attach 5-8"
2760 echo "~^attachment remove-at 1"; read es;\
2761 call xerr $es "attach 5-9"
2762 echo "~^attachment remove-at 1"; read es;\
2763 vput vexpr es substr $es 0 3
2764 if [ $es != 501 ]
2765 xcall bail "attach 5-10"
2768 echo "~^attachment list"; read es;\
2769 vput vexpr es substr $es 0 3
2770 if [ $es != 501 ]
2771 xcall bail "attach 5-11"
2775 echo "~^attachment insert ./.tattach=latin1";\
2776 read hl; echo $hl; call xerr "$hl" "attach 6-1"
2777 echo "~^attachment insert ./.tattach=latin1";\
2778 read hl; echo $hl; call xerr "$hl" "attach 6-2"
2779 echo "~^attachment insert ./.tattach=latin1";\
2780 read hl; echo $hl; call xerr "$hl" "attach 6-3"
2781 echo "~^attachment list";\
2782 read es; echo $es;call xerr "$es" "attach 6-4"
2783 call read_mline_res
2785 echo "~^attachment remove-at 1"; read es;\
2786 call xerr $es "attach 6-5"
2787 echo "~^attachment remove-at 1"; read es;\
2788 call xerr $es "attach 6-6"
2789 echo "~^attachment remove-at 1"; read es;\
2790 call xerr $es "attach 6-7"
2791 echo "~^attachment remove-at 1"; read es;\
2792 vput vexpr es substr $es 0 3
2793 if [ $es != 501 ]
2794 xcall bail "attach 6-8"
2797 echo "~^attachment list"; read es;\
2798 vput vexpr es substr $es 0 3
2799 if [ $es != 501 ]
2800 xcall bail "attach 6-9"
2803 echo t_attach LEAVE
2805 define t_ocs {
2806 read ver
2807 echo t_ocs
2808 call t_header
2809 call t_attach
2811 define t_oce {
2812 echo on-compose-enter, mailx-command<$mailx-command>
2813 alternates alter1@exam.ple alter2@exam.ple
2814 alternates
2815 set autocc='alter1@exam.ple alter2@exam.ple'
2816 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
2817 echo mailx-subject<$mailx-subject>
2818 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
2819 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
2820 mailx-raw-bcc<$mailx-raw-bcc>
2821 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
2822 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
2824 define t_ocl {
2825 echo on-compose-leave, mailx-command<$mailx-command>
2826 eval alternates $alternates alter3@exam.ple alter4@exam.ple
2827 alternates
2828 set autobcc='alter3@exam.ple alter4@exam.ple'
2829 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
2830 echo mailx-subject<$mailx-subject>
2831 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
2832 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
2833 mailx-raw-bcc<$mailx-raw-bcc>
2834 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
2835 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
2837 define t_occ {
2838 echo on-compose-cleanup, mailx-command<$mailx-command>
2839 alternates -
2840 alternates
2841 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
2842 echo mailx-subject<$mailx-subject>
2843 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
2844 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
2845 mailx-raw-bcc<$mailx-raw-bcc>
2846 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
2847 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
2849 wysh set on-compose-splice=t_ocs \
2850 on-compose-enter=t_oce on-compose-leave=t_ocl \
2851 on-compose-cleanup=t_occ
2852 __EOT__
2856 ${rm} -f "${MBOX}"
2857 printf 'm this-goes@nowhere\nbody\n!.\n' |
2858 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
2859 -X'source ./.trc' -Smta=./.tsendmail.sh \
2860 >./.tall 2>&1
2861 ${cat} ./.tall >> "${MBOX}"
2862 check behave:compose_hooks-1 0 "${MBOX}" '3667291468 10101'
2864 ${rm} -f "${MBOX}"
2865 printf 'm this-goes@nowhere\nbody\n!.\n' |
2866 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
2867 -St_remove=1 -X'source ./.trc' -Smta=./.tsendmail.sh \
2868 >./.tall 2>&1
2869 ${cat} ./.tall >> "${MBOX}"
2870 check behave:compose_hooks-2 0 "${MBOX}" '1746765053 12535'
2872 # Some state machine stress, shell compose hook, localopts for hook, etc.
2873 # readctl in child. ~r as HERE document
2874 ${rm} -f "${MBOX}"
2875 printf 'm ex@am.ple\nbody\n!.\nvar t_oce t_ocs t_ocs_sh t_ocl t_occ autocc' |
2876 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! \
2877 -Smta=./.tsendmail.sh \
2879 define bail {
2880 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
2882 define xerr {
2883 vput vexpr es substr "$1" 0 1
2884 if [ "$es" != 2 ]
2885 xcall bail "$2"
2888 define read_mline_res {
2889 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
2890 echo $len/$es/$^ERRNAME: $hl
2891 if [ $es -ne $^ERR-NONE ]
2892 xcall bail read_mline_res
2893 elif [ $len -ne 0 ]
2894 \xcall read_mline_res
2897 define _work {
2898 vput vexpr i + 1 "$2"
2899 if [ $i -lt 111 ]
2900 vput vexpr j % $i 10
2901 if [ $j -ne 0 ]
2902 set j=xcall
2903 else
2904 echon "$i.. "
2905 set j=call
2907 eval \\$j _work $1 $i
2908 return $?
2910 vput vexpr i + $i "$1"
2911 return $i
2913 define _read {
2914 read line;wysh set es=$? en=$^ERRNAME ; echo read:$es/$en: $line
2915 if [ "${es}" -ne -1 ]
2916 xcall _read
2918 readctl remove $cwd/.treadctl; echo readctl remove:$?/$^ERRNAME
2920 define t_ocs {
2921 read ver
2922 echo t_ocs
2923 echo "~^header list"; read hl; echo $hl;\
2924 vput vexpr es substr "$hl" 0 1
2925 if [ "$es" != 2 ]
2926 xcall bail "header list"
2927 endif
2929 call _work 1; echo $?
2930 echo "~^header insert cc splicy diet <splice@exam.ple> spliced";\
2931 read es; echo $es; vput vexpr es substr "$es" 0 1
2932 if [ "$es" != 2 ]
2933 xcall bail "be diet"
2934 endif
2935 echo "~^header insert cc <splice2@exam.ple>";\
2936 read es; echo $es; vput vexpr es substr "$es" 0 1
2937 if [ "$es" != 2 ]
2938 xcall bail "be diet2"
2939 endif
2941 call _work 2; echo $?
2942 echo "~^header insert bcc juicy juice <juice@exam.ple> spliced";\
2943 read es; echo $es;vput vexpr es substr "$es" 0 1
2944 if [ "$es" != 2 ]
2945 xcall bail "be juicy"
2946 endif
2947 echo "~^header insert bcc juice2@exam.ple";\
2948 read es; echo $es;vput vexpr es substr "$es" 0 1
2949 if [ "$es" != 2 ]
2950 xcall bail "be juicy2"
2951 endif
2952 echo "~^header insert bcc juice3 <juice3@exam.ple>";\
2953 read es; echo $es;vput vexpr es substr "$es" 0 1
2954 if [ "$es" != 2 ]
2955 xcall bail "be juicy3"
2956 endif
2957 echo "~^header insert bcc juice4@exam.ple";\
2958 read es; echo $es;vput vexpr es substr "$es" 0 1
2959 if [ "$es" != 2 ]
2960 xcall bail "be juicy4"
2961 endif
2963 echo "~^header remove-at bcc 3";\
2964 read es; echo $es;vput vexpr es substr "$es" 0 1
2965 if [ "$es" != 2 ]
2966 xcall bail "remove juicy5"
2967 endif
2968 echo "~^header remove-at bcc 2";\
2969 read es; echo $es;vput vexpr es substr "$es" 0 1
2970 if [ "$es" != 2 ]
2971 xcall bail "remove juicy6"
2972 endif
2973 echo "~^header remove-at bcc 3";\
2974 read es; echo $es;vput vexpr es substr "$es" 0 3
2975 if [ "$es" != 501 ]
2976 xcall bail "failed to remove-at"
2977 endif
2978 # Add duplicates which ought to be removed!
2979 echo "~^header insert bcc juice4@exam.ple";\
2980 read es; echo $es;vput vexpr es substr "$es" 0 1
2981 if [ "$es" != 2 ]
2982 xcall bail "be juicy4-1"
2983 endif
2984 echo "~^header insert bcc juice4@exam.ple";\
2985 read es; echo $es;vput vexpr es substr "$es" 0 1
2986 if [ "$es" != 2 ]
2987 xcall bail "be juicy4-2"
2988 endif
2989 echo "~^header insert bcc juice4@exam.ple";\
2990 read es; echo $es;vput vexpr es substr "$es" 0 1
2991 if [ "$es" != 2 ]
2992 xcall bail "be juicy4-3"
2993 endif
2994 echo "~:set t_ocs"
2997 call _work 3; echo $?
2998 echo "~r - '__EOT'"
2999 vput ! i echo just knock if you can hear me;\
3000 i=0;\
3001 while [ $i -lt 24 ]; do printf "%s " $i; i=`expr $i + 1`; done;\
3002 echo relax
3003 echon shell-cmd says $?/$^ERRNAME: $i
3004 echo "~x will not become interpreted, we are reading until __EOT"
3005 echo "__EOT"
3006 read r_status; echo "~~r status output: $r_status"
3007 echo "~:echo $? $! $^ERRNAME"
3008 read r_status
3009 echo "~~r status from parent: $r_status"
3012 call _work 4; echo $?
3013 vput cwd cwd;echo cwd:$?
3014 readctl create $cwd/.treadctl ;echo readctl:$?/$^ERRNAME;\
3015 call _read
3018 call _work 5; echo $?
3019 echo "~^header show MAILX-Command"; read es;\
3020 call xerr $es "t_header 1000"; call read_mline_res
3021 echo "~^header show MAILX-raw-TO"; read es;\
3022 call xerr $es "t_header 1001"; xcall read_mline_res
3024 echoerr IT IS WRONG IF YOU SEE THIS
3026 define t_oce {
3027 echo on-compose-enter, mailx-command<$mailx-command>
3028 set t_oce autobcc=oce@exam.ple
3029 alternates alter1@exam.ple alter2@exam.ple
3030 alternates
3031 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3032 echo mailx-subject<$mailx-subject>
3033 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3034 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3035 mailx-raw-bcc<$mailx-raw-bcc>
3036 echo mailx-orig-from<$mailx-orig-from> \
3037 mailx-orig-to<$mailx-orig-to> \
3038 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3040 define t_ocl {
3041 echo on-compose-leave, mailx-command<$mailx-command>
3042 set t_ocl autocc=ocl@exam.ple
3043 alternates alter3@exam.ple alter4@exam.ple
3044 alternates
3045 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3046 echo mailx-subject<$mailx-subject>
3047 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3048 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3049 mailx-raw-bcc<$mailx-raw-bcc>
3050 echo mailx-orig-from<$mailx-orig-from> \
3051 mailx-orig-to<$mailx-orig-to> \
3052 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3054 define t_occ {
3055 echo on-compose-cleanup, mailx-command<$mailx-command>
3056 set t_occ autocc=occ@exam.ple
3057 alternates -
3058 alternates
3059 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3060 echo mailx-subject<$mailx-subject>
3061 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3062 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3063 mailx-raw-bcc<$mailx-raw-bcc>
3064 echo mailx-orig-from<$mailx-orig-from> \
3065 mailx-orig-to<$mailx-orig-to> \
3066 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3068 wysh set on-compose-splice=t_ocs \
3069 on-compose-splice-shell="read ver;printf \"t_ocs-shell\\n\
3070 ~t shell@exam.ple\\n~:set t_ocs_sh\\n\"" \
3071 on-compose-enter=t_oce on-compose-leave=t_ocl \
3072 on-compose-cleanup=t_occ
3073 ' > ./.tnotes 2>&1
3074 ex0_test behave:compose_hooks-3
3075 ${cat} ./.tnotes >> "${MBOX}"
3077 check behave:compose_hooks-3 - "${MBOX}" '679526364 2431'
3079 # Reply, forward, resend, Resend
3081 ${rm} -f "${MBOX}"
3082 printf 'set from=f1@z\nm t1@z\nb1\n!.\nset from=f2@z\nm t2@z\nb2\n!.\n' |
3083 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! \
3084 -Smta=./.tsendmail.sh
3086 printf '
3087 echo start: $? $! $^ERRNAME
3088 File %s
3089 echo File: $? $! $^ERRNAME;echo;echo
3090 reply 1
3091 this is content of reply 1
3093 echo reply 1: $? $! $^ERRNAME;echo;echo
3094 Reply 1 2
3095 this is content of Reply 1 2
3097 echo Reply 1 2: $? $! $^ERRNAME;echo;echo
3098 forward 1 fwdex@am.ple
3099 this is content of forward 1
3101 echo forward 1: $? $! $^ERRNAME;echo;echo
3102 resend 1 2 resendex@am.ple
3103 echo resend 1 2: $? $! $^ERRNAME;echo;echo
3104 Resend 1 2 Resendex@am.ple
3105 echo Resend 1 2: $? $! $^ERRNAME;echo;echo
3106 ' "${MBOX}" |
3107 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! \
3108 -Smta=./.tsendmail.sh \
3110 define bail {
3111 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
3113 define xerr {
3114 vput vexpr es substr "$1" 0 1
3115 if [ "$es" != 2 ]
3116 xcall bail "$2"
3119 define read_mline_res {
3120 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
3121 echo mline_res:$len/$es/$^ERRNAME: $hl
3122 if [ $es -ne $^ERR-NONE ]
3123 xcall bail read_mline_res
3124 elif [ $len -ne 0 ]
3125 \xcall read_mline_res
3128 define work_hl {
3129 echo "~^header show $1"; read es;\
3130 call xerr $es "work_hl $1"; echo $1; call read_mline_res
3131 if [ $# -gt 1 ]
3132 shift
3133 xcall work_hl "$@"
3136 define t_ocs {
3137 read ver
3138 echo t_ocs version $ver
3139 echo "~^header list"; read hl; echo $hl;\
3140 echoerr the header list is $hl;\
3141 call xerr "$hl" "header list"
3142 eval vpospar set $hl
3143 shift
3144 xcall work_hl "$@"
3145 echoerr IT IS WRONG IF YOU SEE THIS
3147 define t_oce {
3148 echo on-XY-enter, mailx-command<$mailx-command>
3149 set t_oce autobcc=oce@exam.ple
3150 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3151 echo mailx-subject<$mailx-subject>
3152 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3153 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3154 mailx-raw-bcc<$mailx-raw-bcc>
3155 echo mailx-orig-from<$mailx-orig-from> \
3156 mailx-orig-to<$mailx-orig-to> \
3157 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3159 define t_ocl {
3160 echo on-XY-leave, mailx-command<$mailx-command>
3161 set t_ocl autocc=ocl@exam.ple
3162 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3163 echo mailx-subject<$mailx-subject>
3164 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3165 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3166 mailx-raw-bcc<$mailx-raw-bcc>
3167 echo mailx-orig-from<$mailx-orig-from> \
3168 mailx-orig-to<$mailx-orig-to> \
3169 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3171 define t_occ {
3172 echo on-XY-cleanup, mailx-command<$mailx-command>
3173 set t_occ autocc=occ@exam.ple
3174 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3175 echo mailx-subject<$mailx-subject>
3176 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3177 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3178 mailx-raw-bcc<$mailx-raw-bcc>
3179 echo mailx-orig-from<$mailx-orig-from> \
3180 mailx-orig-to<$mailx-orig-to> \
3181 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3183 wysh set on-compose-splice=t_ocs \
3184 on-compose-enter=t_oce on-compose-leave=t_ocl \
3185 on-compose-cleanup=t_occ \
3186 on-resend-enter=t_oce on-resend-cleanup=t_occ
3187 ' > ./.tnotes 2>&1
3188 ex0_test behave:compose_hooks-4
3189 ${cat} ./.tnotes >> "${MBOX}"
3191 check behave:compose_hooks-4 - "${MBOX}" '2711778338 7516'
3193 t_epilog
3196 t_behave_message_injections() {
3197 t_prolog
3198 TRAP_EXIT_ADDONS="./.t*"
3200 ${cat} <<-_EOT > ./.tsendmail.sh
3201 #!${MYSHELL} -
3202 (echo 'From Echinacea Tue Jun 20 15:54:02 2017' && ${cat} && echo
3203 ) > "${MBOX}"
3204 _EOT
3205 chmod 0755 ./.tsendmail.sh
3207 echo mysig > ./.tmysig
3209 echo some-body | ${MAILX} ${ARGS} -Smta=./.tsendmail.sh \
3210 -Smessage-inject-head=head-inject \
3211 -Smessage-inject-tail=tail-inject \
3212 -Ssignature=./.tmysig \
3213 ex@am.ple > ./.tall 2>&1
3214 check behave:message_injections-1 0 "${MBOX}" '2434746382 134'
3215 check behave:message_injections-2 - .tall '4294967295 0' # empty file
3217 ${cat} <<-_EOT > ./.template
3218 From: me
3219 To: ex1@am.ple
3220 Cc: ex2@am.ple
3221 Subject: This subject is
3223 Body, body, body me.
3224 _EOT
3225 < ./.template ${MAILX} ${ARGS} -t -Smta=./.tsendmail.sh \
3226 -Smessage-inject-head=head-inject \
3227 -Smessage-inject-tail=tail-inject \
3228 -Ssignature=./.tmysig \
3229 > ./.tall 2>&1
3230 check behave:message_injections-3 0 "${MBOX}" '3114203412 198'
3231 check behave:message_injections-4 - .tall '4294967295 0' # empty file
3233 t_epilog
3236 t_behave_mime_types_load_control() {
3237 t_prolog
3238 TRAP_EXIT_ADDONS="./.t*"
3240 ${cat} <<-_EOT > ./.tmts1
3241 @ application/mathml+xml mathml
3242 _EOT
3243 ${cat} <<-_EOT > ./.tmts2
3244 @ x-conference/x-cooltalk ice
3245 @ aga-aga aga
3246 @ application/aga-aga aga
3247 _EOT
3249 ${cat} <<-_EOT > ./.tmts1.mathml
3250 <head>nonsense ML</head>
3251 _EOT
3252 ${cat} <<-_EOT > ./.tmts2.ice
3253 Icy, icy road.
3254 _EOT
3255 printf 'of which the c\x01rack is coming soon' > ./.tmtsx.doom
3256 printf 'of which the c\x01rack is coming soon' > ./.tmtsx.aga
3258 printf '
3259 m %s
3260 Schub-di-du
3261 ~@ ./.tmts1.mathml
3262 ~@ ./.tmts2.ice
3263 ~@ ./.tmtsx.doom
3264 ~@ ./.tmtsx.aga
3266 File %s
3267 from*
3268 type
3270 ' "${MBOX}" "${MBOX}" |
3271 ${MAILX} ${ARGS} \
3272 -Smimetypes-load-control=f=./.tmts1,f=./.tmts2 \
3273 > ./.tout 2>&1
3274 ex0_test behave:mime_types_load_control
3276 ${cat} "${MBOX}" >> ./.tout
3277 check behave:mime_types_load_control-1 - ./.tout '529577037 2474'
3279 echo type | ${MAILX} ${ARGS} -R \
3280 -Smimetypes-load-control=f=./.tmts1,f=./.tmts3 \
3281 -f "${MBOX}" >> ./.tout 2>&1
3282 check behave:mime_types_load_control-2 0 ./.tout '2025926659 3558'
3284 t_epilog
3287 t_behave_smime() {
3288 have_feat smime || {
3289 echo 'behave:s/mime: unsupported, skipped'
3290 return
3293 t_prolog
3294 TRAP_EXIT_ADDONS="./.t.conf ./.tkey.pem ./.tcert.pem ./.tpair.pem"
3295 TRAP_EXIT_ADDONS="${TRAP_EXIT_ADDONS} ./.VERIFY ./.DECRYPT ./.ENCRYPT"
3296 TRAP_EXIT_ADDONS="${TRAP_EXIT_ADDONS} ./.tsendmail.sh"
3298 printf 'behave:s/mime: .. generating test key and certificate ..\n'
3299 ${cat} <<-_EOT > ./.t.conf
3300 [ req ]
3301 default_bits = 1024
3302 default_keyfile = keyfile.pem
3303 distinguished_name = req_distinguished_name
3304 attributes = req_attributes
3305 prompt = no
3306 output_password =
3308 [ req_distinguished_name ]
3309 C = GB
3310 ST = Over the
3311 L = rainbow
3312 O = S-nail
3313 OU = S-nail.smime
3314 CN = S-nail.test
3315 emailAddress = test@localhost
3317 [ req_attributes ]
3318 challengePassword =
3319 _EOT
3320 openssl req -x509 -nodes -days 3650 -config ./.t.conf \
3321 -newkey rsa:1024 -keyout ./.tkey.pem -out ./.tcert.pem >/dev/null 2>&1
3322 ${cat} ./.tkey.pem ./.tcert.pem > ./.tpair.pem
3324 # Sign/verify
3325 printf 'behave:s/mime:sign/verify: '
3326 echo bla | ${MAILX} ${ARGS} \
3327 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
3328 -Ssmime-sign -Sfrom=test@localhost \
3329 -s 'S/MIME test' ./.VERIFY
3330 if [ $? -eq 0 ]; then
3331 printf 'ok\n'
3332 else
3333 printf 'failed\n'
3334 ESTAT=1
3335 t_epilog
3336 return
3339 ${awk} '
3340 BEGIN{ skip=0 }
3341 /^Content-Description: /{ skip = 2; print; next }
3342 /^$/{ if(skip) --skip }
3343 { if(!skip) print }
3345 < ./.VERIFY > "${MBOX}"
3346 check behave:s/mime:sign/verify:checksum - "${MBOX}" '2900817158 648'
3348 printf 'behave:s/mime:sign/verify:verify '
3349 printf 'verify\nx\n' |
3350 ${MAILX} ${ARGS} \
3351 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
3352 -Ssmime-sign -Sfrom=test@localhost \
3353 -Serrexit -R \
3354 -f ./.VERIFY >/dev/null 2>&1
3355 if [ $? -eq 0 ]; then
3356 printf 'ok\n'
3357 else
3358 printf 'failed\n'
3359 ESTAT=1
3360 t_epilog
3361 return
3364 printf 'behave:s/mime:sign/verify:disproof-1 '
3365 if openssl smime -verify -CAfile ./.tcert.pem \
3366 -in ./.VERIFY >/dev/null 2>&1; then
3367 printf 'ok\n'
3368 else
3369 printf 'failed\n'
3370 ESTAT=1
3371 t_epilog
3372 return
3375 # (signing +) encryption / decryption
3376 ${cat} <<-_EOT > ./.tsendmail.sh
3377 #!${MYSHELL} -
3378 (echo 'From Euphrasia Thu Apr 27 17:56:23 2017' && ${cat}) > ./.ENCRYPT
3379 _EOT
3380 chmod 0755 ./.tsendmail.sh
3382 printf 'behave:s/mime:encrypt+sign: '
3383 echo bla |
3384 ${MAILX} ${ARGS} \
3385 -Ssmime-force-encryption \
3386 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
3387 -Smta=./.tsendmail.sh \
3388 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
3389 -Ssmime-sign -Sfrom=test@localhost \
3390 -s 'S/MIME test' recei@ver.com
3391 if [ $? -eq 0 ]; then
3392 printf 'ok\n'
3393 else
3394 ESTAT=1
3395 printf 'error: encrypt+sign failed\n'
3398 ${sed} -e '/^$/,$d' < ./.ENCRYPT > "${MBOX}"
3399 check behave:s/mime:encrypt+sign:checksum - "${MBOX}" '1937410597 327'
3401 printf 'behave:s/mime:decrypt+verify: '
3402 printf 'decrypt ./.DECRYPT\nfi ./.DECRYPT\nverify\nx\n' |
3403 ${MAILX} ${ARGS} \
3404 -Ssmime-force-encryption \
3405 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
3406 -Smta=./.tsendmail.sh \
3407 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
3408 -Ssmime-sign -Sfrom=test@localhost \
3409 -Serrexit -R \
3410 -f ./.ENCRYPT >/dev/null 2>&1
3411 if [ $? -eq 0 ]; then
3412 printf 'ok\n'
3413 else
3414 ESTAT=1
3415 printf 'failed\n'
3418 ${awk} '
3419 BEGIN{ skip=0 }
3420 /^Content-Description: /{ skip = 2; print; next }
3421 /^$/{ if(skip) --skip }
3422 { if(!skip) print }
3424 < ./.DECRYPT > "${MBOX}"
3425 check behave:s/mime:decrypt+verify:checksum - "${MBOX}" '1720739247 931'
3427 printf 'behave:s/mime:decrypt+verify:disproof-1: '
3428 if (openssl smime -decrypt -inkey ./.tkey.pem -in ./.ENCRYPT |
3429 openssl smime -verify -CAfile ./.tcert.pem) >/dev/null 2>&1; then
3430 printf 'ok\n'
3431 else
3432 printf 'failed\n'
3433 ESTAT=1
3436 printf "behave:s/mime:encrypt: "
3437 echo bla | ${MAILX} ${ARGS} \
3438 -Ssmime-force-encryption \
3439 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
3440 -Smta=./.tsendmail.sh \
3441 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
3442 -Sfrom=test@localhost \
3443 -s 'S/MIME test' recei@ver.com
3444 if [ $? -eq 0 ]; then
3445 printf 'ok\n'
3446 else
3447 ESTAT=1
3448 printf 'failed\n'
3451 # Same as behave:s/mime:encrypt+sign:checksum above
3452 ${sed} -e '/^$/,$d' < ./.ENCRYPT > "${MBOX}"
3453 check behave:s/mime:encrypt:checksum - "${MBOX}" '1937410597 327'
3455 ${rm} -f ./.DECRYPT
3456 printf 'decrypt ./.DECRYPT\nx\n' | ${MAILX} ${ARGS} \
3457 -Ssmime-force-encryption \
3458 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
3459 -Smta=./.tsendmail.sh \
3460 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
3461 -Sfrom=test@localhost \
3462 -Serrexit -R \
3463 -f ./.ENCRYPT >/dev/null 2>&1
3464 check behave:s/mime:decrypt 0 "./.DECRYPT" '2624716890 422'
3466 printf 'behave:s/mime:decrypt:disproof-1: '
3467 if openssl smime -decrypt -inkey ./.tkey.pem \
3468 -in ./.ENCRYPT >/dev/null 2>&1; then
3469 printf 'ok\n'
3470 else
3471 printf 'failed\n'
3472 ESTAT=1
3475 t_epilog
3478 t_behave_maildir() {
3479 t_prolog
3480 TRAP_EXIT_ADDONS="./.t*"
3484 while [ ${i} -lt 112 ]; do
3485 printf 'm file://%s\n~s Subject %s\nHello %s!\n~.\n' \
3486 "${MBOX}" "${i}" "${i}"
3487 i=`add ${i} 1`
3488 done
3489 ) | ${MAILX} ${ARGS}
3490 check behave:maildir-1 0 "${MBOX}" '1140119864 13780'
3492 printf 'File "%s"
3493 copy * "%s"
3494 File "%s"
3495 from*
3496 ' "${MBOX}" .tmdir1 .tmdir1 |
3497 ${MAILX} ${ARGS} -Snewfolders=maildir > .tlst
3498 check behave:maildir-2 0 .tlst '1797938753 9103'
3500 printf 'File "%s"
3501 copy * "maildir://%s"
3502 File "maildir://%s"
3503 from*
3504 ' "${MBOX}" .tmdir2 .tmdir2 |
3505 ${MAILX} ${ARGS} > .tlst
3506 check behave:maildir-3 0 .tlst '1155631089 9113'
3508 printf 'File "maildir://%s"
3509 copy * "file://%s"
3510 File "file://%s"
3511 from*
3512 ' .tmdir2 .tmbox1 .tmbox1 |
3513 ${MAILX} ${ARGS} > .tlst
3514 check behave:maildir-4 0 .tmbox1 '2646131190 13220'
3515 check behave:maildir-5 - .tlst '3701297796 9110'
3517 # only the odd (even)
3519 printf 'File "maildir://%s"
3520 copy ' .tmdir2
3522 while [ ${i} -lt 112 ]; do
3523 j=`modulo ${i} 2`
3524 [ ${j} -eq 1 ] && printf '%s ' "${i}"
3525 i=`add ${i} 1`
3526 done
3527 printf ' file://%s
3528 File "file://%s"
3529 from*
3530 ' .tmbox2 .tmbox2
3531 ) | ${MAILX} ${ARGS} > .tlst
3532 check behave:maildir-6 0 .tmbox2 '142890131 6610'
3533 check behave:maildir-7 - .tlst '960096773 4573'
3534 # ...
3536 printf 'file "maildir://%s"
3537 move ' .tmdir2
3539 while [ ${i} -lt 112 ]; do
3540 j=`modulo ${i} 2`
3541 [ ${j} -eq 0 ] && [ ${i} -ne 0 ] && printf '%s ' "${i}"
3542 i=`add ${i} 1`
3543 done
3544 printf ' file://%s
3545 File "file://%s"
3546 from*
3547 File "maildir://%s"
3548 from*
3549 ' .tmbox2 .tmbox2 .tmdir2
3550 ) | ${MAILX} ${ARGS} > .tlst
3551 check behave:maildir-8 0 .tmbox2 '3806905791 13100'
3552 ${sed} 2d < .tlst > .tlstx
3553 check behave:maildir-9 - .tlstx '4216815295 13645'
3555 t_epilog
3558 # t_content()
3559 # Some basic tests regarding correct sending of mails, via STDIN / -t / -q,
3560 # including basic MIME Content-Transfer-Encoding correctness (quoted-printable)
3561 # Note we unfortunately need to place some statements without proper
3562 # indentation because of continuation problems
3563 t_content() {
3564 t_prolog
3566 # MIME encoding (QP) stress message body
3567 printf \
3568 'Ich bin eine DÖS-Datäi mit sehr langen Zeilen und auch '\
3569 'sonst bin ich ganz schön am Schleudern, da kannste denke '\
3570 "wasde willst, gelle, gelle, gelle, gelle, gelle.\r\n"\
3571 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst \r\n"\
3572 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1\r\n"\
3573 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12\r\n"\
3574 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123\r\n"\
3575 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1234\r\n"\
3576 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12345\r\n"\
3577 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123456\r\n"\
3578 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1234567\r\n"\
3579 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12345678\r\n"\
3580 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123456789\r\n"\
3581 "Unn ausserdem habe ich trailing SP/HT/SP/HT whitespace \r\n"\
3582 "Unn ausserdem habe ich trailing HT/SP/HT/SP whitespace \r\n"\
3583 "auf den zeilen vorher.\r\n"\
3584 "From am Zeilenbeginn und From der Mitte gibt es auch.\r\n"\
3585 ".\r\n"\
3586 "Die letzte Zeile war nur ein Punkt.\r\n"\
3587 "..\r\n"\
3588 "Das waren deren zwei.\r\n"\
3589 " \r\n"\
3590 "Die letzte Zeile war ein Leerschritt.\n"\
3591 "=VIER = EQUAL SIGNS=ON A LINE=\r\n"\
3592 "Prösterchen.\r\n"\
3593 ".\n"\
3594 "Die letzte Zeile war nur ein Punkt, mit Unix Zeilenende.\n"\
3595 "..\n"\
3596 "Das waren deren zwei. ditto.\n"\
3597 "Prösterchen.\n"\
3598 "Unn ausseerdem habe ich trailing SP/HT/SP/HT whitespace \n"\
3599 "Unn ausseerdem habe ich trailing HT/SP/HT/SP whitespace \n"\
3600 "auf den zeilen vorher.\n"\
3601 "ditto.\n"\
3602 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.\n"\
3603 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.1"\
3604 "\n"\
3605 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
3606 "\n"\
3607 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
3608 "3\n"\
3609 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
3610 "34\n"\
3611 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
3612 "345\n"\
3613 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
3614 "3456\n"\
3615 "QP am Zeilenende über soft-nl hinweg\n"\
3616 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
3617 "ö123\n"\
3618 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
3619 "1ö23\n"\
3620 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
3621 "12ö3\n"\
3622 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
3623 "123ö\n"\
3624 "=VIER = EQUAL SIGNS=ON A LINE=\n"\
3625 " \n"\
3626 "Die letzte Zeile war ein Leerschritt.\n"\
3627 ' '\
3628 > "${BODY}"
3630 # MIME encoding (QP) stress message subject
3631 SUB="Äbrä Kä?dä=brö Fü?di=bus? \
3632 adadaddsssssssddddddddddddddddddddd\
3633 ddddddddddddddddddddddddddddddddddd\
3634 ddddddddddddddddddddddddddddddddddd\
3635 dddddddddddddddddddd Hallelulja? Od\
3636 er?? eeeeeeeeeeeeeeeeeeeeeeeeeeeeee\
3637 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\
3638 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee f\
3639 fffffffffffffffffffffffffffffffffff\
3640 fffffffffffffffffffff ggggggggggggg\
3641 ggggggggggggggggggggggggggggggggggg\
3642 ggggggggggggggggggggggggggggggggggg\
3643 ggggggggggggggggggggggggggggggggggg\
3644 gggggggggggggggg"
3646 # Three tests for MIME encoding and (a bit) content classification.
3647 # At the same time testing -q FILE, < FILE and -t FILE
3649 ${rm} -f "${MBOX}"
3650 < "${BODY}" ${MAILX} ${ARGS} ${ADDARG_UNI} \
3651 -a "${BODY}" -s "${SUB}" "${MBOX}"
3652 check content:001 0 "${MBOX}" '1145066634 6654'
3654 ${rm} -f "${MBOX}"
3655 < /dev/null ${MAILX} ${ARGS} ${ADDARG_UNI} \
3656 -a "${BODY}" -s "${SUB}" -q "${BODY}" "${MBOX}"
3657 check content:002 0 "${MBOX}" '1145066634 6654'
3659 ${rm} -f "${MBOX}"
3660 ( echo "To: ${MBOX}" && echo "Subject: ${SUB}" && echo &&
3661 ${cat} "${BODY}"
3662 ) | ${MAILX} ${ARGS} ${ADDARG_UNI} -Snodot -a "${BODY}" -t
3663 check content:003 0 "${MBOX}" '1145066634 6654'
3665 # Test for [260e19d] (Juergen Daubert)
3666 ${rm} -f "${MBOX}"
3667 echo body | ${MAILX} ${ARGS} "${MBOX}"
3668 check content:004 0 "${MBOX}" '2917662811 98'
3670 # Sending of multiple mails in a single invocation
3671 ${rm} -f "${MBOX}"
3672 ( printf "m ${MBOX}\n~s subject1\nE-Mail Körper 1\n~.\n" &&
3673 printf "m ${MBOX}\n~s subject2\nEmail body 2\n~.\n" &&
3674 echo x
3675 ) | ${MAILX} ${ARGS} ${ADDARG_UNI}
3676 check content:005 0 "${MBOX}" '2098659767 358'
3678 ## $BODY CHANGED
3680 # "Test for" [d6f316a] (Gavin Troy)
3681 ${rm} -f "${MBOX}"
3682 printf "m ${MBOX}\n~s subject1\nEmail body\n~.\nfi ${MBOX}\np\nx\n" |
3683 ${MAILX} ${ARGS} ${ADDARG_UNI} -Spipe-text/plain="@* ${cat}" > "${BODY}"
3684 check content:006 0 "${MBOX}" '2099098650 122'
3685 check content:006-1 - "${BODY}" '794542938 174'
3687 # "Test for" [c299c45] (Peter Hofmann) TODO shouldn't end up QP-encoded?
3688 ${rm} -f "${MBOX}"
3689 ${awk} 'BEGIN{
3690 for(i = 0; i < 10000; ++i)
3691 printf "\xC3\xBC"
3692 #printf "\xF0\x90\x87\x90"
3693 }' | ${MAILX} ${ARGS} ${ADDARG_UNI} -s TestSubject "${MBOX}"
3694 check content:007 0 "${MBOX}" '534262374 61816'
3696 ## Test some more corner cases for header bodies (as good as we can today) ##
3699 ${rm} -f "${MBOX}"
3700 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
3701 -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̲' \
3702 "${MBOX}"
3703 check content:008 0 "${MBOX}" '3370931614 375'
3705 # Single word (overlong line split -- bad standard! Requires injection of
3706 # artificial data!! But can be prevented by using RFC 2047 encoding)
3707 ${rm} -f "${MBOX}"
3708 i=`${awk} 'BEGIN{for(i=0; i<92; ++i) printf "0123456789_"}'`
3709 echo | ${MAILX} ${ARGS} -s "${i}" "${MBOX}"
3710 check content:009 0 "${MBOX}" '489922370 1718'
3712 # Combination of encoded words, space and tabs of varying sort
3713 ${rm} -f "${MBOX}"
3714 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
3715 -s "1Abrä Kaspas1 2Abra Katä b_kaspas2 \
3716 3Abrä Kaspas3 4Abrä Kaspas4 5Abrä Kaspas5 \
3717 6Abra Kaspas6 7Abrä Kaspas7 8Abra Kaspas8 \
3718 9Abra Kaspastäb4-3 10Abra Kaspas1 _ 11Abra Katäb1 \
3719 12Abra Kadabrä1 After Tab after Täb this is NUTS" \
3720 "${MBOX}"
3721 check content:010 0 "${MBOX}" '1676887734 591'
3723 # Overlong multibyte sequence that must be forcefully split
3724 # todo This works even before v15.0, but only by accident
3725 ${rm} -f "${MBOX}"
3726 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
3727 -s "✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
3728 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
3729 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄" \
3730 "${MBOX}"
3731 check content:011 0 "${MBOX}" '3029301775 659'
3733 # Trailing WS
3734 ${rm} -f "${MBOX}"
3735 echo | ${MAILX} ${ARGS} \
3736 -s "1-1 B2 B3 B4 B5 B6 B\
3737 1-2 B2 B3 B4 B5 B6 B\
3738 1-3 B2 B3 B4 B5 B6 B\
3739 1-4 B2 B3 B4 B5 B6 B\
3740 1-5 B2 B3 B4 B5 B6 B\
3741 1-6 B2 B3 B4 B5 B6 " \
3742 "${MBOX}"
3743 check content:012 0 "${MBOX}" '4126167195 297'
3745 # Leading and trailing WS
3746 ${rm} -f "${MBOX}"
3747 echo | ${MAILX} ${ARGS} \
3748 -s " 2-1 B2 B3 B4 B5 B6 B\
3749 1-2 B2 B3 B4 B5 B6 B\
3750 1-3 B2 B3 B4 B5 B6 B\
3751 1-4 B2 B3 B4 B5 B6 " \
3752 "${MBOX}"
3753 check content:013 0 "${MBOX}" '3600624479 236'
3755 # Quick'n dirty RFC 2231 test; i had more when implementing it, but until we
3756 # have a (better) test framework materialize a quick shot
3757 ${rm} -f "${MBOX}"
3758 TRAP_EXIT_ADDONS=./.ttt
3760 mkdir ./.ttt || exit 1
3761 cd ./.ttt || exit 2
3762 : > "ma'ger.txt"
3763 : > "mä'ger.txt"
3764 : > 'diet\ is \curd.txt'
3765 : > 'diet "is" curd.txt'
3766 : > höde-tröge.txt
3767 : > 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
3768 : > höde__tröge__müde__dätte__hätte__vuelle__guelle__aese__aesse__sauerliche__kräuter__österliche__grüße__mäh.txt
3769 : > hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt
3770 : > ✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt
3772 echo bla | ${MAILX} ${ARGS} ${ADDARG_UNI} \
3773 -a "./.ttt/ma'ger.txt" -a "./.ttt/mä'ger.txt" \
3774 -a './.ttt/diet\ is \curd.txt' -a './.ttt/diet "is" curd.txt' \
3775 -a ./.ttt/höde-tröge.txt \
3776 -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 \
3777 -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 \
3778 -a ./.ttt/hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt \
3779 -a ./.ttt/✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt \
3780 "${MBOX}"
3781 check content:014-1 0 "${MBOX}" '684985954 3092'
3783 # `resend' test, reusing $MBOX
3784 ${rm} -f "${BODY}"
3785 printf "Resend ${BODY}\nx\n" | ${MAILX} ${ARGS} -Rf "${MBOX}"
3786 check content:014-2 0 "${BODY}" '684985954 3092'
3788 ${rm} -f "${BODY}"
3789 printf "resend ${BODY}\nx\n" | ${MAILX} ${ARGS} -Rf "${MBOX}"
3790 check content:014-3 0 "${BODY}" '3130352658 3148'
3792 t_epilog
3795 t_all() {
3796 # if have_feat devel; then
3797 # ARGS="${ARGS} -Smemdebug"
3798 # export ARGS
3799 # fi
3800 t_behave
3801 t_content
3804 if [ -z "${CHECK_ONLY}" ]; then
3805 cc_all_configs
3806 else
3807 t_all
3810 [ ${ESTAT} -eq 0 ] && echo Ok || echo >&2 'Errors occurred'
3812 exit ${ESTAT}
3813 # s-sh-mode