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