Introduce *asksend*, by default enabled
[s-mailx.git] / cc-test.sh
blob25db66bc77a6d2c9452a23489fb850408fe8a503
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 -Sexpandaddr=restrict'
9 ARGS="${ARGS}"' -Smime-encoding=quoted-printable -Snosave -Sstealthmua'
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 # Note valgrind has problems with FDs in forked childs, which causes some tests
18 # to fail (the FD is rewound and thus will be dumped twice)
19 MEMTESTER=
20 #MEMTESTER='valgrind --leak-check=full --log-file=.vl-%p '
22 if ( command -v command ) >/dev/null 2>&1; then :; else
23 command() {
24 shift
25 which "${@}"
29 MAKE="${MAKE:-`command -v make`}"
30 awk=${awk:-`command -v awk`}
31 cat=${cat:-`command -v cat`}
32 cksum=${cksum:-`command -v cksum`}
33 rm=${rm:-`command -v rm`}
34 sed=${sed:-`command -v sed`}
35 grep=${grep:-`command -v grep`}
37 # Problem: force $SHELL to be a real shell. It seems some testing environments
38 # use nologin(?), but we need a real shell for command execution
39 if { echo ${SHELL} | ${grep} nologin; } >/dev/null 2>&1; then
40 echo >&2 '$SHELL seems to be nologin, overwriting to /bin/sh!'
41 SHELL=/bin/sh
42 export SHELL
45 # We sometimes "fake" sendmail(1) a.k.a. *mta* with a shell wrapper, and it
46 # happens that /bin/sh is often terribly slow
47 if command -v dash >/dev/null 2>&1; then
48 MYSHELL="`command -v dash`"
49 elif command -v mksh >/dev/null 2>&1; then
50 MYSHELL="`command -v mksh`"
51 else
52 MYSHELL="${SHELL}"
55 ## -- >8 -- 8< -- ##
57 export ARGS ADDARG_UNI CONF BODY MBOX MAIL MAKE awk cat cksum rm sed grep
59 LC_ALL=C LANG=C
60 TZ=UTC
61 # Wed Oct 2 01:50:07 UTC 1996
62 SOURCE_DATE_EPOCH=844221007
64 export LC_ALL LANG TZ SOURCE_DATE_EPOCH
65 unset POSIXLY_CORRECT
67 usage() {
68 echo >&2 "Usage: ./cc-test.sh [--check-only s-mailx-binary]"
69 exit 1
72 CHECK_ONLY= MAILX=
73 if [ "${1}" = --check-only ]; then
74 CHECK_ONLY=1
75 MAILX=${2}
76 [ -x "${MAILX}" ] || usage
78 RAWMAILX=${MAILX}
79 MAILX="${MEMTESTER}${MAILX}"
80 export RAWMAILX MAILX
82 if [ -n "${CHECK_ONLY}" ] && [ -z "${UTF8_LOCALE}" ]; then
83 # Try ourselfs for nl_langinfo(CODESET) output first (requires a new version)
84 i=`LC_ALL=C.utf8 "${RAWMAILX}" ${ARGS} -X '
85 \define cset_test {
86 \if [ "${ttycharset}" @i=% utf ]
87 \echo $LC_ALL
88 \xit 0
89 \end
90 \if [ "${#}" -gt 0 ]
91 \wysh set LC_ALL=${1}
92 \shift
93 \eval xcall cset_test "${@}"
94 \end
95 \xit 1
97 \call cset_test C.UTF-8 POSIX.utf8 POSIX.UTF-8 en_EN.utf8 en_EN.UTF-8 \
98 en_US.utf8 en_US.UTF-8
100 [ $? -eq 0 ] && UTF8_LOCALE=$i
102 if [ -z "${UTF8_LOCALE}" ] && command -v locale >/dev/null 2>&1; then
103 UTF8_LOCALE=`locale -a | { m=
104 while read n; do
105 if { echo ${n} | ${grep} -i 'utf-\{0,1\}8'; } >/dev/null 2>&1; then
106 m=${n}
107 if { echo ${n} | ${grep} -e POSIX -e en_EN -e en_US; }; then
108 exit 0
111 m=${n}
112 done
113 echo ${m}
118 ESTAT=0
120 TRAP_EXIT_ADDONS=
121 trap "${rm} -rf \"${BODY}\" \"${MBOX}\" \${TRAP_EXIT_ADDONS}" EXIT
122 trap "exit 1" HUP INT TERM
124 # cc_all_configs()
125 # Test all configs TODO doesn't cover all *combinations*, stupid!
126 cc_all_configs() {
127 < ${CONF} ${awk} '
128 BEGIN {
129 NOTME["OPT_AUTOCC"] = 1
130 NOTME["OPT_DEBUG"] = 1
131 NOTME["OPT_DEVEL"] = 1
132 NOTME["OPT_NOEXTMD5"] = 1
133 NOTME["OPT_ASAN_ADDRESS"] = 1
134 NOTME["OPT_ASAN_MEMORY"] = 1
135 NOTME["OPT_FORCED_STACKPROT"] = 1
136 NOTME["OPT_NOMEMDBG"] = 1
137 NOTME["OPT_NYD2"] = 1
138 i = 0
140 /^[[:space:]]*OPT_/ {
141 sub(/^[[:space:]]*/, "")
142 # This bails for UnixWare 7.1.4 awk(1), but preceeding = with \
143 # does not seem to be a compliant escape for =
144 #sub(/=.*$/, "")
145 $1 = substr($1, 1, index($1, "=") - 1)
146 if (NOTME[$1])
147 next
148 data[i++] = $1
150 END {
151 # Doing this completely sequentially and not doing make distclean in
152 # between runs should effectively result in lesser compilations.
153 # It is completely dumb nonetheless... TODO
154 for (j = 1; j < i; ++j) {
155 for (k = 1; k < j; ++k)
156 printf data[k] "=1 "
157 for (k = j; k < i; ++k)
158 printf data[k] "=0 "
159 printf "OPT_AUTOCC=1\n"
161 for (j = 1; j < i; ++j) {
162 for (k = 1; k < j; ++k)
163 printf data[k] "=0 "
164 for (k = j; k < i; ++k)
165 printf data[k] "=1 "
166 printf "OPT_AUTOCC=1\n"
168 # With debug
169 for (j = 1; j < i; ++j) {
170 for (k = 1; k < j; ++k)
171 printf data[k] "=1 "
172 for (k = j; k < i; ++k)
173 printf data[k] "=0 "
174 printf "OPT_AUTOCC=1\n"
175 printf "OPT_DEBUG=1\n"
177 for (j = 1; j < i; ++j) {
178 for (k = 1; k < j; ++k)
179 printf data[k] "=0 "
180 for (k = j; k < i; ++k)
181 printf data[k] "=1 "
182 printf "OPT_AUTOCC=1\n"
183 printf "OPT_DEBUG=1\n"
186 printf "CONFIG=NULL OPT_AUTOCC=0\n"
187 printf "CONFIG=NULL OPT_AUTOCC=1\n"
188 printf "CONFIG=NULLI OPT_AUTOCC=0\n"
189 printf "CONFIG=NULLI OPT_AUTOCC=1\n"
190 printf "CONFIG=MINIMAL OPT_AUTOCC=0\n"
191 printf "CONFIG=MINIMAL 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
294 t_behave_atxplode
296 t_behave_mbox
298 t_behave_alternates
299 t_behave_alias
300 # FIXME t_behave_mlist
301 t_behave_filetype
303 t_behave_record_a_resend
305 t_behave_e_H_L_opts
306 t_behave_compose_hooks
307 t_behave_message_injections
308 t_behave_mime_types_load_control
310 t_behave_smime
312 t_behave_maildir
313 t_behave_mass_recipients
314 t_behave_lreply_futh_rth_etc
315 t_behave_iconv_mbyte_base64
318 t_behave_X_opt_input_command_stack() {
319 t_prolog
321 ${cat} <<- '__EOT' > "${BODY}"
322 echo 1
323 define mac0 {
324 echo mac0-1 via1 $0
326 call mac0
327 echo 2
328 source '\
329 echo "define mac1 {";\
330 echo " echo mac1-1 via1 \$0";\
331 echo " call mac0";\
332 echo " echo mac1-2";\
333 echo " call mac2";\
334 echo " echo mac1-3";\
335 echo "}";\
336 echo "echo 1-1";\
337 echo "define mac2 {";\
338 echo " echo mac2-1 via1 \$0";\
339 echo " call mac0";\
340 echo " echo mac2-2";\
341 echo "}";\
342 echo "echo 1-2";\
343 echo "call mac1";\
344 echo "echo 1-3";\
345 echo "source \"\
346 echo echo 1-1-1 via1 \$0;\
347 echo call mac0;\
348 echo echo 1-1-2;\
349 | \"";\
350 echo "echo 1-4";\
352 echo 3
353 call mac2
354 echo 4
355 undefine *
356 __EOT
358 # The -X option supports multiline arguments, and those can internally use
359 # reverse solidus newline escaping. And all -X options are joined...
360 APO=\'
361 < "${BODY}" ${MAILX} ${ARGS} \
362 -X 'e\' \
363 -X ' c\' \
364 -X ' h\' \
365 -X ' o \' \
366 -X 1 \
368 define mac0 {
369 echo mac0-1 via2 $0
371 call mac0
372 echo 2
375 source '${APO}'\
376 echo "define mac1 {";\
377 echo " echo mac1-1 via2 \$0";\
378 echo " call mac0";\
379 echo " echo mac1-2";\
380 echo " call mac2";\
381 echo " echo mac1-3";\
382 echo "}";\
383 echo "echo 1-1";\
384 echo "define mac2 {";\
385 echo " echo mac2-1 via2 \$0";\
386 echo " call mac0";\
387 echo " echo mac2-2";\
388 echo "}";\
389 echo "echo 1-2";\
390 echo "call mac1";\
391 echo "echo 1-3";\
392 echo "source \"\
393 echo echo 1-1-1 via2 \$0;\
394 echo call mac0;\
395 echo echo 1-1-2;\
396 | \"";\
397 echo "echo 1-4";\
398 | '${APO}'
399 echo 3
402 call mac2
403 echo 4
404 undefine *
405 ' > "${MBOX}"
407 check behave:x_opt_input_command_stack 0 "${MBOX}" '1786542668 416'
409 t_epilog
412 t_behave_X_errexit() {
413 t_prolog
415 ${cat} <<- '__EOT' > "${BODY}"
416 echo one
417 echos nono
418 echo two
419 __EOT
421 </dev/null ${MAILX} ${ARGS} -Snomemdebug \
422 -X'echo one' -X' echos nono ' -X'echo two' \
423 > "${MBOX}" 2>&1
424 check behave:x_errexit-1 0 "${MBOX}" '916157812 53'
426 </dev/null ${MAILX} ${ARGS} -X'source '"${BODY}" -Snomemdebug \
427 > "${MBOX}" 2>&1
428 check behave:x_errexit-2 0 "${MBOX}" '916157812 53'
430 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Snomemdebug \
431 > "${MBOX}" 2>&1
432 check behave:x_errexit-3 0 "${MBOX}" '916157812 53'
436 </dev/null ${MAILX} ${ARGS} -Serrexit -Snomemdebug \
437 -X'echo one' -X' echos nono ' -X'echo two' \
438 > "${MBOX}" 2>&1
439 check behave:x_errexit-4 1 "${MBOX}" '2118430867 49'
441 </dev/null ${MAILX} ${ARGS} -X'source '"${BODY}" -Serrexit -Snomemdebug \
442 > "${MBOX}" 2>&1
443 check behave:x_errexit-5 1 "${MBOX}" '2118430867 49'
445 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Serrexit -Snomemdebug \
446 > "${MBOX}" 2>&1
447 check behave:x_errexit-6 1 "${MBOX}" '12955965 172'
449 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Sposix -Snomemdebug \
450 > "${MBOX}" 2>&1
451 check behave:x_errexit-7 1 "${MBOX}" '12955965 172'
453 ## Repeat 4-7 with ignerr set
455 ${sed} -e 's/^echos /ignerr echos /' < "${BODY}" > "${MBOX}"
457 </dev/null ${MAILX} ${ARGS} -Serrexit -Snomemdebug \
458 -X'echo one' -X'ignerr echos nono ' -X'echo two' \
459 > "${BODY}" 2>&1
460 check behave:x_errexit-8 0 "${BODY}" '916157812 53'
462 </dev/null ${MAILX} ${ARGS} -X'source '"${MBOX}" -Serrexit -Snomemdebug \
463 > "${BODY}" 2>&1
464 check behave:x_errexit-9 0 "${BODY}" '916157812 53'
466 </dev/null MAILRC="${MBOX}" ${MAILX} ${ARGS} -:u -Serrexit -Snomemdebug \
467 > "${BODY}" 2>&1
468 check behave:x_errexit-10 0 "${BODY}" '916157812 53'
470 </dev/null MAILRC="${MBOX}" ${MAILX} ${ARGS} -:u -Sposix -Snomemdebug \
471 > "${BODY}" 2>&1
472 check behave:x_errexit-11 0 "${BODY}" '916157812 53'
474 t_epilog
477 t_behave_wysh() {
478 t_prolog
480 ${cat} <<- '__EOT' > "${BODY}"
482 echo abcd
483 echo a'b'c'd'
484 echo a"b"c"d"
485 echo a$'b'c$'d'
486 echo 'abcd'
487 echo "abcd"
488 echo $'abcd'
489 echo a\ b\ c\ d
490 echo a 'b c' d
491 echo a "b c" d
492 echo a $'b c' d
494 echo 'a$`"\'
495 echo "a\$\`'\"\\"
496 echo $'a\$`\'\"\\'
497 echo $'a\$`\'"\\'
498 # DIET=CURD TIED=
499 echo 'a${DIET}b${TIED}c\${DIET}d\${TIED}e' # COMMENT
500 echo "a${DIET}b${TIED}c\${DIET}d\${TIED}e"
501 echo $'a${DIET}b${TIED}c\${DIET}d\${TIED}e'
503 echo a$'\101\0101\x41\u0041\u41\U00000041\U41'c
504 echo a$'\u0041\u41\u0C1\U00000041\U41'c
505 echo a$'\377'c
506 echo a$'\0377'c
507 echo a$'\400'c
508 echo a$'\0400'c
509 echo a$'\U1100001'c
511 echo a$'b\0c'd
512 echo a$'b\00c'de
513 echo a$'b\000c'df
514 echo a$'b\0000c'dg
515 echo a$'b\x0c'dh
516 echo a$'b\x00c'di
517 echo a$'b\u0'dj
518 echo a$'b\u00'dk
519 echo a$'b\u000'dl
520 echo a$'b\u0000'dm
521 echo a$'b\U0'dn
522 echo a$'b\U00'do
523 echo a$'b\U000'dp
524 echo a$'b\U0000'dq
525 echo a$'b\U00000'dr
526 echo a$'b\U000000'ds
527 echo a$'b\U0000000'dt
528 echo a$'b\U00000000'du
530 echo a$'\cI'b
531 echo a$'\011'b
532 echo a$'\x9'b
533 echo a$'\u9'b
534 echo a$'\U9'b
535 echo a$'\c@'b c d
536 __EOT
538 if [ -z "${UTF8_LOCALE}" ]; then
539 echo 'Skip behave:wysh_unicode, no UTF8_LOCALE'
540 else
541 < "${BODY}" DIET=CURD TIED= \
542 LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} 2>/dev/null > "${MBOX}"
543 check behave:wysh_unicode 0 "${MBOX}" '475805847 317'
546 < "${BODY}" DIET=CURD TIED= ${MAILX} ${ARGS} > "${MBOX}" 2>/dev/null
547 check behave:wysh_c 0 "${MBOX}" '1473887148 321'
549 t_epilog
552 t_behave_input_inject_semicolon_seq() {
553 t_prolog
555 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
556 define mydeepmac {
557 echon '(mydeepmac)';
559 define mymac {
560 echon this_is_mymac;call mydeepmac;echon ';';
562 echon one';';call mymac;echon two";";call mymac;echo three$';';
563 define mymac {
564 echon this_is_mymac;call mydeepmac;echon ,TOO'!;';
566 echon one';';call mymac;echon two";";call mymac;echo three$';';
567 __EOT
569 check behave:input_inject_semicolon_seq 0 "${MBOX}" '512117110 140'
571 t_epilog
574 t_behave_commandalias() {
575 t_prolog
577 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
578 commandalias echo echo hoho
579 echo stop.
580 commandalias X Xx
581 commandalias Xx XxX
582 commandalias XxX XxXx
583 commandalias XxXx XxXxX
584 commandalias XxXxX XxXxXx
585 commandalias XxXxXx echo huhu
586 commandalias XxXxXxX echo huhu
588 commandalias XxXxXx XxXxXxX
590 uncommandalias echo
591 commandalias XxXxXx echo huhu
593 __EOT
595 check behave:commandalias 0 "${MBOX}" '3694143612 31'
597 t_epilog
600 t_behave_ifelse() {
601 t_prolog
603 # Nestable conditions test
604 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
605 if 0
606 echo 1.err
607 else
608 echo 1.ok
609 endif
610 if 1
611 echo 2.ok
612 else
613 echo 2.err
614 endif
615 if $dietcurd
616 echo 3.err
617 else
618 echo 3.ok
619 endif
620 set dietcurd=yoho
621 if $dietcurd
622 echo 4.ok
623 else
624 echo 4.err
625 endif
626 if $dietcurd == 'yoho'
627 echo 5.ok
628 else
629 echo 5.err
630 endif
631 if $dietcurd @== 'Yoho'
632 echo 5-1.ok
633 else
634 echo 5-1.err
635 endif
636 if $dietcurd == 'Yoho'
637 echo 5-2.err
638 else
639 echo 5-2.ok
640 endif
641 if $dietcurd != 'yoho'
642 echo 6.err
643 else
644 echo 6.ok
645 endif
646 if $dietcurd @!= 'Yoho'
647 echo 6-1.err
648 else
649 echo 6-1.ok
650 endif
651 if $dietcurd != 'Yoho'
652 echo 6-2.ok
653 else
654 echo 6-2.err
655 endif
656 # Nesting
657 if faLse
658 echo 7.err1
659 if tRue
660 echo 7.err2
661 if yEs
662 echo 7.err3
663 else
664 echo 7.err4
665 endif
666 echo 7.err5
667 endif
668 echo 7.err6
669 else
670 echo 7.ok7
671 if YeS
672 echo 7.ok8
673 if No
674 echo 7.err9
675 else
676 echo 7.ok9
677 endif
678 echo 7.ok10
679 else
680 echo 7.err11
681 if yeS
682 echo 7.err12
683 else
684 echo 7.err13
685 endif
686 endif
687 echo 7.ok14
688 endif
689 if r
690 echo 8.ok1
691 if R
692 echo 8.ok2
693 else
694 echo 8.err2
695 endif
696 echo 8.ok3
697 else
698 echo 8.err1
699 endif
700 if s
701 echo 9.err1
702 else
703 echo 9.ok1
704 if S
705 echo 9.err2
706 else
707 echo 9.ok2
708 endif
709 echo 9.ok3
710 endif
711 # `elif'
712 if $dietcurd == 'yohu'
713 echo 10.err1
714 elif $dietcurd == 'yoha'
715 echo 10.err2
716 elif $dietcurd == 'yohe'
717 echo 10.err3
718 elif $dietcurd == 'yoho'
719 echo 10.ok1
720 if $dietcurd == 'yohu'
721 echo 10.err4
722 elif $dietcurd == 'yoha'
723 echo 10.err5
724 elif $dietcurd == 'yohe'
725 echo 10.err6
726 elif $dietcurd == 'yoho'
727 echo 10.ok2
728 if $dietcurd == 'yohu'
729 echo 10.err7
730 elif $dietcurd == 'yoha'
731 echo 10.err8
732 elif $dietcurd == 'yohe'
733 echo 10.err9
734 elif $dietcurd == 'yoho'
735 echo 10.ok3
736 else
737 echo 10.err10
738 endif
739 else
740 echo 10.err11
741 endif
742 else
743 echo 10.err12
744 endif
745 # integer
746 set dietcurd=10
747 if $dietcurd -lt 11
748 echo 11.ok1
749 if $dietcurd -gt 9
750 echo 11.ok2
751 else
752 echo 11.err2
753 endif
754 if $dietcurd -eq 10
755 echo 11.ok3
756 else
757 echo 11.err3
758 endif
759 if $dietcurd -ge 10
760 echo 11.ok4
761 else
762 echo 11.err4
763 endif
764 if $dietcurd -le 10
765 echo 11.ok5
766 else
767 echo 11.err5
768 endif
769 if $dietcurd -ge 11
770 echo 11.err6
771 else
772 echo 11.ok6
773 endif
774 if $dietcurd -le 9
775 echo 11.err7
776 else
777 echo 11.ok7
778 endif
779 else
780 echo 11.err1
781 endif
782 set dietcurd=Abc
783 if $dietcurd < aBd
784 echo 12.ok1
785 if $dietcurd @> abB
786 echo 12.ok2
787 else
788 echo 12.err2
789 endif
790 if $dietcurd @== aBC
791 echo 12.ok3
792 else
793 echo 12.err3
794 endif
795 if $dietcurd @>= AbC
796 echo 12.ok4
797 else
798 echo 12.err4
799 endif
800 if $dietcurd @<= ABc
801 echo 12.ok5
802 else
803 echo 12.err5
804 endif
805 if $dietcurd @>= abd
806 echo 12.err6
807 else
808 echo 12.ok6
809 endif
810 if $dietcurd @<= abb
811 echo 12.err7
812 else
813 echo 12.ok7
814 endif
815 else
816 echo 12.err1
817 endif
818 if $dietcurd < aBc
819 echo 12-1.ok
820 else
821 echo 12-1.err
822 endif
823 if $dietcurd @< aBc
824 echo 12-2.err
825 else
826 echo 12-2.ok
827 endif
828 if $dietcurd > ABc
829 echo 12-3.ok
830 else
831 echo 12-3.err
832 endif
833 if $dietcurd @> ABc
834 echo 12-3.err
835 else
836 echo 12-3.ok
837 endif
838 if $dietcurd @i=% aB
839 echo 13.ok
840 else
841 echo 13.err
842 endif
843 if $dietcurd =% aB
844 echo 13-1.err
845 else
846 echo 13-1.ok
847 endif
848 if $dietcurd @=% bC
849 echo 14.ok
850 else
851 echo 14.err
852 endif
853 if $dietcurd !% aB
854 echo 15-1.ok
855 else
856 echo 15-1.err
857 endif
858 if $dietcurd @!% aB
859 echo 15-2.err
860 else
861 echo 15-2.ok
862 endif
863 if $dietcurd !% bC
864 echo 15-3.ok
865 else
866 echo 15-3.err
867 endif
868 if $dietcurd @!% bC
869 echo 15-4.err
870 else
871 echo 15-4.ok
872 endif
873 if $dietcurd =% Cd
874 echo 16.err
875 else
876 echo 16.ok
877 endif
878 if $dietcurd !% Cd
879 echo 17.ok
880 else
881 echo 17.err
882 endif
883 set diet=abc curd=abc
884 if $diet == $curd
885 echo 18.ok
886 else
887 echo 18.err
888 endif
889 set diet=abc curd=abcd
890 if $diet != $curd
891 echo 19.ok
892 else
893 echo 19.err
894 endif
895 # 1. Shitty grouping capabilities as of today
896 unset diet curd ndefined
897 if [ [ false ] || [ false ] || [ true ] ] && [ [ false ] || [ true ] ] && \
898 [ yes ]
899 echo 20.ok
900 else
901 echo 20.err
902 endif
903 if [ [ [ [ 0 ] || [ 1 ] ] && [ [ 1 ] || [ 0 ] ] ] && [ 1 ] ] && [ yes ]
904 echo 21.ok
905 else
906 echo 21.err
907 endif
908 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] ]
909 echo 22.ok
910 else
911 echo 22.err
912 endif
913 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] ]
914 echo 23.ok
915 else
916 echo 23.err
917 endif
918 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] && [ no ]
919 echo 24.err
920 else
921 echo 24.ok
922 endif
923 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] \
924 && [ no ] || [ yes ]
925 echo 25.ok
926 else
927 echo 25.err
928 endif
929 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
930 echo 26.ok
931 else
932 echo 26.err
933 endif
934 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 0 ] ]
935 echo 27.err
936 else
937 echo 27.ok
938 endif
939 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 0 ] ] && [ 1 ] ] ] && [ 1 ] ]
940 echo 28.err
941 else
942 echo 28.ok
943 endif
944 if [ [ [ [ [ [ [ 0 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
945 echo 29.err
946 else
947 echo 29.ok
948 endif
949 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 0 ]
950 echo 30.err
951 else
952 echo 30.ok
953 endif
954 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 1 ]
955 echo 31.ok
956 else
957 echo 31.err
958 endif
959 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ]
960 echo 32.err
961 else
962 echo 32.ok
963 endif
964 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 1 ]
965 echo 33.ok
966 else
967 echo 33.err
968 endif
969 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 0 ]
970 echo 34.err
971 else
972 echo 34.ok
973 endif
974 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 1 ]
975 echo 35.ok
976 else
977 echo 35.err
978 endif
979 set diet=yo curd=ho
980 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
981 echo 36.err
982 else
983 echo 36.ok
984 endif
985 set ndefined
986 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
987 echo 37.ok
988 else
989 echo 37.err
990 endif
991 # 2. Shitty grouping capabilities as of today
992 unset diet curd ndefined
993 if [ false || false || true ] && [ false || true ] && yes
994 echo 40.ok
995 else
996 echo 40.err
997 endif
998 if [ [ [ 0 || 1 ] && [ 1 || 0 ] ] && 1 ] && [ yes ]
999 echo 41.ok
1000 else
1001 echo 41.err
1002 endif
1003 if [ 1 || 0 || 0 || 0 ]
1004 echo 42.ok
1005 else
1006 echo 42.err
1007 endif
1008 if [ 1 || 0 || 0 || 0 || [ 1 ] ]
1009 echo 43.ok
1010 else
1011 echo 43.err
1012 endif
1013 if [ 1 || 0 || 0 || 0 || [ 1 ] || 1 ] && no
1014 echo 44.err
1015 else
1016 echo 44.ok
1017 endif
1018 if [ 1 || 0 || 0 || 0 || 1 || [ 1 ] ] && no || [ yes ]
1019 echo 45.ok
1020 else
1021 echo 45.err
1022 endif
1023 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && 1 ] ] && [ 1 ] ]
1024 echo 46.ok
1025 else
1026 echo 46.err
1027 endif
1028 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && [ 1 ] ] ] && 0 ]
1029 echo 47.err
1030 else
1031 echo 47.ok
1032 endif
1033 if [ [ [ [ [ [ [ 1 ] ] && 1 ] && 0 ] && [ 1 ] ] ] && 1 ]
1034 echo 48.err
1035 else
1036 echo 48.ok
1037 endif
1038 if [ [ [ [ [ [ 0 ] && 1 ] && 1 ] && 1 ] ] && 1 ]
1039 echo 49.err
1040 else
1041 echo 49.ok
1042 endif
1043 if 1 || 0 || 0 || 0 && 0
1044 echo 50.err
1045 else
1046 echo 50.ok
1047 endif
1048 if 1 || 0 || 0 || 0 && 1
1049 echo 51.ok
1050 else
1051 echo 51.err
1052 endif
1053 if 0 || 0 || 0 || 1 && 0
1054 echo 52.err
1055 else
1056 echo 52.ok
1057 endif
1058 if 0 || 0 || 0 || 1 && 1
1059 echo 53.ok
1060 else
1061 echo 53.err
1062 endif
1063 if 0 || 0 || 0 || 1 && 0 || 1 && 0
1064 echo 54.err
1065 else
1066 echo 54.ok
1067 endif
1068 if 0 || 0 || 0 || 1 && 0 || 1 && 1
1069 echo 55.ok
1070 else
1071 echo 55.err
1072 endif
1073 set diet=yo curd=ho
1074 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
1075 echo 56.err
1076 else
1077 echo 56.ok
1078 endif
1079 if $diet == 'yo' && $curd == 'ho' && $ndefined
1080 echo 57.err
1081 else
1082 echo 57.ok
1083 endif
1084 set ndefined
1085 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
1086 echo 57.ok
1087 else
1088 echo 57.err
1089 endif
1090 if $diet == 'yo' && $curd == 'ho' && $ndefined
1091 echo 58.ok
1092 else
1093 echo 58.err
1094 endif
1095 if [ [ [ [ [ [ $diet == 'yo' && $curd == 'ho' && $ndefined ] ] ] ] ] ]
1096 echo 59.ok
1097 else
1098 echo 59.err
1099 endif
1100 # Some more en-braced variables
1101 set diet=yo curd=ho
1102 if ${diet} == ${curd}
1103 echo 70.err
1104 else
1105 echo 70.ok
1106 endif
1107 if ${diet} != ${curd}
1108 echo 71.ok
1109 else
1110 echo 71.err
1111 endif
1112 if $diet == ${curd}
1113 echo 72.err
1114 else
1115 echo 72.ok
1116 endif
1117 if ${diet} == $curd
1118 echo 73.err
1119 else
1120 echo 73.ok
1121 endif
1122 # Unary !
1123 if ! 0 && ! ! 1 && ! ! ! ! 2 && 3
1124 echo 80.ok
1125 else
1126 echo 80.err
1127 endif
1128 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ ! 2 ] ] ] && 3
1129 echo 81.ok
1130 else
1131 echo 81.err
1132 endif
1133 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1134 echo 82.ok
1135 else
1136 echo 82.err
1137 endif
1138 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
1139 echo 83.err
1140 else
1141 echo 83.ok
1142 endif
1143 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
1144 echo 84.err
1145 else
1146 echo 84.ok
1147 endif
1148 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1149 echo 85.err
1150 else
1151 echo 85.ok
1152 endif
1153 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1154 echo 86.err
1155 else
1156 echo 86.ok
1157 endif
1158 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] || 3
1159 echo 87.ok
1160 else
1161 echo 87.err
1162 endif
1163 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! ! [ 2 ] ] ] ] ]
1164 echo 88.ok
1165 else
1166 echo 88.err
1167 endif
1168 # Unary !, odd
1169 if ! 0 && ! ! 1 && ! ! ! 0 && 3
1170 echo 90.ok
1171 else
1172 echo 90.err
1173 endif
1174 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ 0 ] ] ] && 3
1175 echo 91.ok
1176 else
1177 echo 91.err
1178 endif
1179 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ [ 0 ] ] ] ] ] && 3
1180 echo 92.ok
1181 else
1182 echo 92.err
1183 endif
1184 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! ! [ ! [ ! 0 ] ] ] ] && ! 3
1185 echo 93.err
1186 else
1187 echo 93.ok
1188 endif
1189 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ ! [ ! [ ! [ ! 0 ] ] ] ] && 3
1190 echo 94.ok
1191 else
1192 echo 94.err
1193 endif
1194 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! ! [ ! [ ! [ ! [ 0 ] ] ] ] ] && 3
1195 echo 95.err
1196 else
1197 echo 95.ok
1198 endif
1199 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! ! 0 ] ] ] ] && 3
1200 echo 96.err
1201 else
1202 echo 96.ok
1203 endif
1204 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ ! 0 ] ] ] ] ] || 3
1205 echo 97.ok
1206 else
1207 echo 97.err
1208 endif
1209 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! [ 0 ] ] ] ] ]
1210 echo 98.ok
1211 else
1212 echo 98.err
1213 endif
1214 __EOT
1216 check behave:if-normal 0 "${MBOX}" '1688759742 719'
1218 if have_feat regex; then
1219 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
1220 set dietcurd=yoho
1221 if $dietcurd =~ '^yo.*'
1222 echo 1.ok
1223 else
1224 echo 1.err
1225 endif
1226 if $dietcurd =~ '^Yo.*'
1227 echo 1-1.err
1228 else
1229 echo 1-1.ok
1230 endif
1231 if $dietcurd @=~ '^Yo.*'
1232 echo 1-2.ok
1233 else
1234 echo 1-2.err
1235 endif
1236 if $dietcurd =~ '^yOho.+'
1237 echo 2.err
1238 else
1239 echo 2.ok
1240 endif
1241 if $dietcurd @!~ '.*Ho$'
1242 echo 3.err
1243 else
1244 echo 3.ok
1245 endif
1246 if $dietcurd !~ '.+yohO$'
1247 echo 4.ok
1248 else
1249 echo 4.err
1250 endif
1251 if [ $dietcurd @i!~ '.+yoho$' ]
1252 echo 5.ok
1253 else
1254 echo 5.err
1255 endif
1256 if ! [ $dietcurd @i=~ '.+yoho$' ]
1257 echo 6.ok
1258 else
1259 echo 6.err
1260 endif
1261 if ! ! [ $dietcurd @i!~ '.+yoho$' ]
1262 echo 7.ok
1263 else
1264 echo 7.err
1265 endif
1266 if ! [ ! [ $dietcurd @i!~ '.+yoho$' ] ]
1267 echo 8.ok
1268 else
1269 echo 8.err
1270 endif
1271 if [ ! [ ! [ $dietcurd @i!~ '.+yoho$' ] ] ]
1272 echo 9.ok
1273 else
1274 echo 9.err
1275 endif
1276 if ! [ ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
1277 echo 10.err
1278 else
1279 echo 10.ok
1280 endif
1281 if ! ! ! $dietcurd !~ '.+yoho$'
1282 echo 11.err
1283 else
1284 echo 11.ok
1285 endif
1286 if ! ! ! $dietcurd =~ '.+yoho$'
1287 echo 12.ok
1288 else
1289 echo 12.err
1290 endif
1291 if ! [ ! ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
1292 echo 13.ok
1293 else
1294 echo 13.err
1295 endif
1296 set diet=abc curd='^abc$'
1297 if $diet =~ $curd
1298 echo 14.ok
1299 else
1300 echo 14.err
1301 endif
1302 set diet=abc curd='^abcd$'
1303 if $diet !~ $curd
1304 echo 15.ok
1305 else
1306 echo 15.err
1307 endif
1308 __EOT
1310 check behave:if-regex 0 "${MBOX}" '1115671789 95'
1311 else
1312 printf 'behave:if-regex: unsupported, skipped\n'
1315 t_epilog
1318 t_behave_localopts() {
1319 t_prolog
1321 # Nestable conditions test
1322 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
1323 define t2 {
1324 echo in: t2
1325 set t2=t2
1326 echo $t2
1328 define t1 {
1329 echo in: t1
1330 set gv1=gv1
1331 localopts on
1332 set lv1=lv1 lv2=lv2
1333 set lv3=lv3
1334 call t2
1335 localopts off
1336 set gv2=gv2
1337 echo $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2
1339 define t0 {
1340 echo in: t0
1341 call t1
1342 echo $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2
1343 echo "$gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2"
1345 account trouble {
1346 echo in: trouble
1347 call t0
1349 call t0
1350 unset gv1 gv2
1351 account trouble
1352 echo active trouble: $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t3
1353 account null
1354 echo active null: $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t3
1357 define ll2 {
1358 localopts $1
1359 set x=2
1360 echo ll2=$x
1362 define ll1 {
1363 wysh set y=$1; shift; eval localopts $y; localopts $1; shift
1364 set x=1
1365 echo ll1.1=$x
1366 call ll2 $1
1367 echo ll1.2=$x
1369 define ll0 {
1370 wysh set y=$1; shift; eval localopts $y; localopts $1; shift
1371 set x=0
1372 echo ll0.1=$x
1373 call ll1 $y "$@"
1374 echo ll0.2=$x
1376 define llx {
1377 echo ----- $1: $2 -> $3 -> $4
1378 echo ll-1.1=$x
1379 eval localopts $1
1380 call ll0 "$@"
1381 echo ll-1.2=$x
1382 unset x
1384 define lly {
1385 call llx 'call off' on on on
1386 call llx 'call off' off on on
1387 call llx 'call off' on off on
1388 call llx 'call off' on off off
1389 localopts call-fixate on
1390 call llx 'call-fixate on' on on on
1391 call llx 'call-fixate on' off on on
1392 call llx 'call-fixate on' on off on
1393 call llx 'call-fixate on' on off off
1394 unset x;localopts call on
1395 call llx 'call on' on on on
1396 call llx 'call on' off on on
1397 call llx 'call on' on off on
1398 call llx 'call on' on off off
1400 call lly
1401 __EOT
1403 check behave:localopts 0 "${MBOX}" '4016155249 1246'
1405 t_epilog
1408 t_behave_macro_param_shift() {
1409 t_prolog
1411 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>/dev/null
1412 define t2 {
1413 echo in: t2
1414 echo t2.0 has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1415 localopts on
1416 wysh set ignerr=$1
1417 shift
1418 localopts off
1419 echo t2.1 has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1420 if [ $# > 1 ] || [ $ignerr == '' ]
1421 shift 2
1422 else
1423 ignerr shift 2
1424 endif
1425 echo t2.2:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1426 shift 0
1427 echo t2.3:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1428 if [ $# > 0 ]
1429 shift
1430 endif
1431 echo t2.4:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1433 define t1 {
1434 set errexit
1435 echo in: t1
1436 call t2 1 you get four args
1437 echo t1.1: $?';' ignerr ($ignerr) should not exist
1438 call t2 1 you get 'three args'
1439 echo t1.2: $?';' ignerr ($ignerr) should not exist
1440 call t2 1 you 'get two args'
1441 echo t1.3: $?';' ignerr ($ignerr) should not exist
1442 call t2 1 'you get one arg'
1443 echo t1.4: $?';' ignerr ($ignerr) should not exist
1444 ignerr call t2 '' 'you get one arg'
1445 echo t1.5: $?';' ignerr ($ignerr) should not exist
1447 call t1
1448 __EOT
1450 check behave:macro_param_shift 0 "${MBOX}" '1402489146 1682'
1452 t_epilog
1455 t_behave_addrcodec() {
1456 t_prolog
1458 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
1459 vput addrcodec res e 1 <doog@def>
1460 echo $?/$^ERRNAME $res
1461 eval vput addrcodec res d $res
1462 echo $?/$^ERRNAME $res
1463 vput addrcodec res e 2 . <doog@def>
1464 echo $?/$^ERRNAME $res
1465 eval vput addrcodec res d $res
1466 echo $?/$^ERRNAME $res
1467 vput addrcodec res e 3 Sauer Dr. <doog@def>
1468 echo $?/$^ERRNAME $res
1469 eval vput addrcodec res d $res
1470 echo $?/$^ERRNAME $res
1471 vput addrcodec res e 3.50 Sauer (Ma) Dr. <doog@def>
1472 echo $?/$^ERRNAME $res
1473 eval vput addrcodec res d $res
1474 echo $?/$^ERRNAME $res
1475 vput addrcodec res e 3.51 Sauer (Ma) "Dr." <doog@def>
1476 echo $?/$^ERRNAME $res
1477 eval vput addrcodec res d $res
1478 echo $?/$^ERRNAME $res
1480 vput addrcodec res +e 4 Sauer (Ma) Dr. <doog@def>
1481 echo $?/$^ERRNAME $res
1482 eval vput addrcodec res d $res
1483 echo $?/$^ERRNAME $res
1484 vput addrcodec res +e 5 Sauer (Ma) Braten Dr. <doog@def>
1485 echo $?/$^ERRNAME $res
1486 eval vput addrcodec res d $res
1487 echo $?/$^ERRNAME $res
1488 vput addrcodec res +e 6 Sauer (Ma) Braten Dr. (Heu) <doog@def>
1489 echo $?/$^ERRNAME $res
1490 eval vput addrcodec res d $res
1491 echo $?/$^ERRNAME $res
1492 vput addrcodec res +e 7 Sauer (Ma) Braten Dr. (Heu) <doog@def> (bu)
1493 echo $?/$^ERRNAME $res
1494 eval vput addrcodec res d $res
1495 echo $?/$^ERRNAME $res
1496 vput addrcodec res +e 8 \
1497 Dr. Sauer (Ma) Braten Dr. (Heu) <doog@def> (bu) Boom. Boom
1498 echo $?/$^ERRNAME $res
1499 eval vput addrcodec res d $res
1500 echo $?/$^ERRNAME $res
1501 vput addrcodec res +e 9 Dr.Sauer(Ma)Braten Dr. (Heu) <doog@def>
1502 echo $?/$^ERRNAME $res
1503 eval vput addrcodec res d $res
1504 echo $?/$^ERRNAME $res
1505 vput addrcodec res +e 10 (Ma)Braten Dr. (Heu) <doog@def>
1506 echo $?/$^ERRNAME $res
1507 eval vput addrcodec res d $res
1508 echo $?/$^ERRNAME $res
1509 vput addrcodec res +e 11 (Ma)Braten Dr"." (Heu) <doog@def>
1510 echo $?/$^ERRNAME $res
1511 eval vput addrcodec res d $res
1512 echo $?/$^ERRNAME $res
1513 vput addrcodec res +e 12 Dr. Sauer (Ma) Braten Dr. (u) <doog@def>
1514 echo $?/$^ERRNAME $res
1515 eval vput addrcodec res d $res
1516 echo $?/$^ERRNAME $res
1517 vput addrcodec res +e 13(Ma)Braten Dr. (Heu) <doog@def>
1518 echo $?/$^ERRNAME $res
1519 eval vput addrcodec res d $res
1520 echo $?/$^ERRNAME $res
1521 vput addrcodec res +e 14 Hey, Du <doog@def> Wie() findet Dr. das? ()
1522 echo $?/$^ERRNAME $res
1523 eval vput addrcodec res d $res
1524 echo $?/$^ERRNAME $res
1525 vput addrcodec res +e 15 \
1526 Hey, Du <doog@def> Wie() findet "" Dr. "" das? ()
1527 echo $?/$^ERRNAME $res
1528 eval vput addrcodec res d $res
1529 echo $?/$^ERRNAME $res
1530 vput addrcodec res +e 16 \
1531 "Hey," "Du" <doog@def> "Wie()" findet "" Dr. "" das? ()
1532 echo $?/$^ERRNAME $res
1533 eval vput addrcodec res d $res
1534 echo $?/$^ERRNAME $res
1535 vput addrcodec res +e 17 \
1536 "Hey" Du <doog@def> "Wie() findet " " Dr. """ das? ()
1537 echo $?/$^ERRNAME $res
1538 eval vput addrcodec res d $res
1539 echo $?/$^ERRNAME $res
1540 vput addrcodec res +e 18 \
1541 <doog@def> "Hey" Du "Wie() findet " " Dr. """ das? ()
1542 echo $?/$^ERRNAME $res
1543 eval vput addrcodec res d $res
1544 echo $?/$^ERRNAME $res
1545 vput addrcodec res +e 19 Hey\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1546 echo $?/$^ERRNAME $res
1547 eval vput addrcodec res d $res
1548 echo $?/$^ERRNAME $res
1550 vput addrcodec res ++e 20 Hey\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1551 echo $?/$^ERRNAME $res
1552 vput addrcodec res ++e 21 Hey\,\"" <doog@def> "Wie()" findet \" Dr. \" das?
1553 echo $?/$^ERRNAME $res
1554 eval vput addrcodec res d $res
1555 echo $?/$^ERRNAME $res
1557 vput addrcodec res +++e 22 Hey\\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1558 echo $?/$^ERRNAME $res
1559 eval vput addrcodec res d $res
1560 echo $?/$^ERRNAME $res
1562 vput addrcodec res s \
1563 "23 Hey\\,\\\" \"Wie" () "\" findet \\\" Dr. \\\" das?" <doog@def>
1564 echo $?/$^ERRNAME $res
1565 __EOT
1567 check behave:addrcodec 0 "${MBOX}" '429099645 2414'
1569 t_epilog
1572 t_behave_vexpr() {
1573 t_prolog
1575 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>/dev/null
1576 vput vexpr res = 9223372036854775807
1577 echo $?/$^ERRNAME $res
1578 vput vexpr res = 9223372036854775808
1579 echo $?/$^ERRNAME $res
1580 vput vexpr res =@ 9223372036854775808
1581 echo $?/$^ERRNAME $res
1582 vput vexpr res = -9223372036854775808
1583 echo $?/$^ERRNAME $res
1584 vput vexpr res = -9223372036854775809
1585 echo $?/$^ERRNAME $res
1586 vput vexpr res =@ -9223372036854775809
1587 echo $?/$^ERRNAME $res
1588 echo ' #1'
1589 vput vexpr res ~ 0
1590 echo $?/$^ERRNAME $res
1591 vput vexpr res ~ 1
1592 echo $?/$^ERRNAME $res
1593 vput vexpr res ~ -1
1594 echo $?/$^ERRNAME $res
1595 echo ' #2'
1596 vput vexpr res + 0 0
1597 echo $?/$^ERRNAME $res
1598 vput vexpr res + 0 1
1599 echo $?/$^ERRNAME $res
1600 vput vexpr res + 1 1
1601 echo $?/$^ERRNAME $res
1602 echo ' #3'
1603 vput vexpr res + 9223372036854775807 0
1604 echo $?/$^ERRNAME $res
1605 vput vexpr res + 9223372036854775807 1
1606 echo $?/$^ERRNAME $res
1607 vput vexpr res +@ 9223372036854775807 1
1608 echo $?/$^ERRNAME $res
1609 vput vexpr res + 0 9223372036854775807
1610 echo $?/$^ERRNAME $res
1611 vput vexpr res + 1 9223372036854775807
1612 echo $?/$^ERRNAME $res
1613 vput vexpr res +@ 1 9223372036854775807
1614 echo $?/$^ERRNAME $res
1615 echo ' #4'
1616 vput vexpr res + -9223372036854775808 0
1617 echo $?/$^ERRNAME $res
1618 vput vexpr res + -9223372036854775808 -1
1619 echo $?/$^ERRNAME $res
1620 vput vexpr res +@ -9223372036854775808 -1
1621 echo $?/$^ERRNAME $res
1622 vput vexpr res + 0 -9223372036854775808
1623 echo $?/$^ERRNAME $res
1624 vput vexpr res + -1 -9223372036854775808
1625 echo $?/$^ERRNAME $res
1626 vput vexpr res +@ -1 -9223372036854775808
1627 echo $?/$^ERRNAME $res
1628 echo ' #5'
1629 vput vexpr res - 0 0
1630 echo $?/$^ERRNAME $res
1631 vput vexpr res - 0 1
1632 echo $?/$^ERRNAME $res
1633 vput vexpr res - 1 1
1634 echo $?/$^ERRNAME $res
1635 echo ' #6'
1636 vput vexpr res - 9223372036854775807 0
1637 echo $?/$^ERRNAME $res
1638 vput vexpr res - 9223372036854775807 -1
1639 echo $?/$^ERRNAME $res
1640 vput vexpr res -@ 9223372036854775807 -1
1641 echo $?/$^ERRNAME $res
1642 vput vexpr res - 0 9223372036854775807
1643 echo $?/$^ERRNAME $res
1644 vput vexpr res - -1 9223372036854775807
1645 echo $?/$^ERRNAME $res
1646 vput vexpr res - -2 9223372036854775807
1647 echo $?/$^ERRNAME $res
1648 vput vexpr res -@ -2 9223372036854775807
1649 echo $?/$^ERRNAME $res
1650 echo ' #7'
1651 vput vexpr res - -9223372036854775808 +0
1652 echo $?/$^ERRNAME $res
1653 vput vexpr res - -9223372036854775808 +1
1654 echo $?/$^ERRNAME $res
1655 vput vexpr res -@ -9223372036854775808 +1
1656 echo $?/$^ERRNAME $res
1657 vput vexpr res - 0 -9223372036854775808
1658 echo $?/$^ERRNAME $res
1659 vput vexpr res - +1 -9223372036854775808
1660 echo $?/$^ERRNAME $res
1661 vput vexpr res -@ +1 -9223372036854775808
1662 echo $?/$^ERRNAME $res
1663 echo ' #8'
1664 vput vexpr res + -13 -2
1665 echo $?/$^ERRNAME $res
1666 vput vexpr res - 0 0
1667 echo $?/$^ERRNAME $res
1668 vput vexpr res - 0 1
1669 echo $?/$^ERRNAME $res
1670 vput vexpr res - 1 1
1671 echo $?/$^ERRNAME $res
1672 vput vexpr res - -13 -2
1673 echo $?/$^ERRNAME $res
1674 echo ' #9'
1675 vput vexpr res * 0 0
1676 echo $?/$^ERRNAME $res
1677 vput vexpr res * 0 1
1678 echo $?/$^ERRNAME $res
1679 vput vexpr res * 1 1
1680 echo $?/$^ERRNAME $res
1681 vput vexpr res * -13 -2
1682 echo $?/$^ERRNAME $res
1683 echo ' #10'
1684 vput vexpr res / 0 0
1685 echo $?/$^ERRNAME $res
1686 vput vexpr res / 0 1
1687 echo $?/$^ERRNAME $res
1688 vput vexpr res / 1 1
1689 echo $?/$^ERRNAME $res
1690 vput vexpr res / -13 -2
1691 echo $?/$^ERRNAME $res
1692 echo ' #11'
1693 vput vexpr res % 0 0
1694 echo $?/$^ERRNAME $res
1695 vput vexpr res % 0 1
1696 echo $?/$^ERRNAME $res
1697 vput vexpr res % 1 1
1698 echo $?/$^ERRNAME $res
1699 vput vexpr res % -13 -2
1700 echo $?/$^ERRNAME $res
1701 __EOT
1703 check behave:vexpr-numeric 0 "${MBOX}" '1723609217 1048'
1705 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" #2>/dev/null
1706 vput vexpr res find 'bananarama' 'nana'
1707 echo $?/$^ERRNAME :$res:
1708 vput vexpr res find 'bananarama' 'bana'
1709 echo $?/$^ERRNAME :$res:
1710 vput vexpr res find 'bananarama' 'Bana'
1711 echo $?/$^ERRNAME :$res:
1712 vput vexpr res find 'bananarama' 'rama'
1713 echo $?/$^ERRNAME :$res:
1714 echo ' #1'
1715 vput vexpr res ifind 'bananarama' 'nana'
1716 echo $?/$^ERRNAME :$res:
1717 vput vexpr res ifind 'bananarama' 'bana'
1718 echo $?/$^ERRNAME :$res:
1719 vput vexpr res ifind 'bananarama' 'Bana'
1720 echo $?/$^ERRNAME :$res:
1721 vput vexpr res ifind 'bananarama' 'rama'
1722 echo $?/$^ERRNAME :$res:
1723 echo ' #2'
1724 vput vexpr res substring 'bananarama' 1
1725 echo $?/$^ERRNAME :$res:
1726 vput vexpr res substring 'bananarama' 3
1727 echo $?/$^ERRNAME :$res:
1728 vput vexpr res substring 'bananarama' 5
1729 echo $?/$^ERRNAME :$res:
1730 vput vexpr res substring 'bananarama' 7
1731 echo $?/$^ERRNAME :$res:
1732 vput vexpr res substring 'bananarama' 9
1733 echo $?/$^ERRNAME :$res:
1734 vput vexpr res substring 'bananarama' 10
1735 echo $?/$^ERRNAME :$res:
1736 vput vexpr res substring 'bananarama' 1 3
1737 echo $?/$^ERRNAME :$res:
1738 vput vexpr res substring 'bananarama' 3 3
1739 echo $?/$^ERRNAME :$res:
1740 vput vexpr res substring 'bananarama' 5 3
1741 echo $?/$^ERRNAME :$res:
1742 vput vexpr res substring 'bananarama' 7 3
1743 echo $?/$^ERRNAME :$res:
1744 vput vexpr res substring 'bananarama' 9 3
1745 echo $?/$^ERRNAME :$res:
1746 vput vexpr res substring 'bananarama' 10 3
1747 echo $?/$^ERRNAME :$res:
1748 echo ' #3'
1749 vput vexpr res substring 'bananarama' -1
1750 echo $?/$^ERRNAME :$res:
1751 vput vexpr res substring 'bananarama' -3
1752 echo $?/$^ERRNAME :$res:
1753 vput vexpr res substring 'bananarama' -5
1754 echo $?/$^ERRNAME :$res:
1755 vput vexpr res substring 'bananarama' -7
1756 echo $?/$^ERRNAME :$res:
1757 vput vexpr res substring 'bananarama' -9
1758 echo $?/$^ERRNAME :$res:
1759 vput vexpr res substring 'bananarama' -10
1760 echo $?/$^ERRNAME :$res:
1761 vput vexpr res substring 'bananarama' 1 -3
1762 echo $?/$^ERRNAME :$res:
1763 vput vexpr res substring 'bananarama' 3 -3
1764 echo $?/$^ERRNAME :$res:
1765 vput vexpr res substring 'bananarama' 5 -3
1766 echo $?/$^ERRNAME :$res:
1767 vput vexpr res substring 'bananarama' 7 -3
1768 echo $?/$^ERRNAME :$res:
1769 vput vexpr res substring 'bananarama' 9 -3
1770 echo $?/$^ERRNAME :$res:
1771 vput vexpr res substring 'bananarama' 10 -3
1772 echo $?/$^ERRNAME :$res:
1773 echo ' #4'
1774 vput vexpr res trim 'Cocoon Cocoon'
1775 echo $?/$^ERRNAME :$res:
1776 vput vexpr res trim ' Cocoon Cocoon '
1777 echo $?/$^ERRNAME :$res:
1778 vput vexpr res trim-front 'Cocoon Cocoon'
1779 echo $?/$^ERRNAME :$res:
1780 vput vexpr res trim-front ' Cocoon Cocoon '
1781 echo $?/$^ERRNAME :$res:
1782 vput vexpr res trim-end 'Cocoon Cocoon'
1783 echo $?/$^ERRNAME :$res:
1784 vput vexpr res trim-end ' Cocoon Cocoon '
1785 echo $?/$^ERRNAME :$res:
1786 __EOT
1788 check behave:vexpr-string 0 "${MBOX}" '3182004322 601'
1790 if have_feat regex; then
1791 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" #2>/dev/null
1792 vput vexpr res regex 'bananarama' 'nana'
1793 echo $?/$^ERRNAME :$res:
1794 vput vexpr res regex 'bananarama' 'bana'
1795 echo $?/$^ERRNAME :$res:
1796 vput vexpr res regex 'bananarama' 'Bana'
1797 echo $?/$^ERRNAME :$res:
1798 vput vexpr res regex 'bananarama' 'rama'
1799 echo $?/$^ERRNAME :$res:
1800 echo ' #1'
1801 vput vexpr res iregex 'bananarama' 'nana'
1802 echo $?/$^ERRNAME :$res:
1803 vput vexpr res iregex 'bananarama' 'bana'
1804 echo $?/$^ERRNAME :$res:
1805 vput vexpr res iregex 'bananarama' 'Bana'
1806 echo $?/$^ERRNAME :$res:
1807 vput vexpr res iregex 'bananarama' 'rama'
1808 echo $?/$^ERRNAME :$res:
1809 echo ' #2'
1810 vput vexpr res regex 'bananarama' '(.*)nana(.*)' '\${1}a\${0}u{\$2}'
1811 echo $?/$^ERRNAME :$res:
1812 vput vexpr res regex 'bananarama' '(.*)bana(.*)' '\${1}a\${0}u\$2'
1813 echo $?/$^ERRNAME :$res:
1814 vput vexpr res regex 'bananarama' 'Bana(.+)' '\$1\$0'
1815 echo $?/$^ERRNAME :$res:
1816 vput vexpr res regex 'bananarama' '(.+)rama' '\$1\$0'
1817 echo $?/$^ERRNAME :$res:
1818 echo ' #3'
1819 vput vexpr res iregex 'bananarama' '(.*)nana(.*)' '\${1}a\${0}u{\$2}'
1820 echo $?/$^ERRNAME :$res:
1821 vput vexpr res iregex 'bananarama' '(.*)bana(.*)' '\${1}a\${0}u\$2'
1822 echo $?/$^ERRNAME :$res:
1823 vput vexpr res iregex 'bananarama' 'Bana(.+)' '\$1\$0'
1824 echo $?/$^ERRNAME :$res:
1825 vput vexpr res iregex 'bananarama' '(.+)rama' '\$1\$0'
1826 echo $?/$^ERRNAME :$res:
1827 echo ' #4'
1828 __EOT
1830 check behave:vexpr-regex 0 "${MBOX}" '3270360157 311'
1831 else
1832 printf 'behave:vexpr-regex: unsupported, skipped\n'
1835 t_epilog
1838 t_behave_call_ret() {
1839 t_prolog
1841 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Snomemdebug > "${MBOX}" 2>&1
1842 define w1 {
1843 echon ">$1 "
1844 vput vexpr i + $1 1
1845 if [ $i -le 42 ]
1846 vput vexpr j '&' $i 7
1847 if [ $j -eq 7 ]
1848 echo .
1850 call w1 $i
1851 wysh set i=$? k=$!
1852 vput vexpr j '&' $i 7
1853 echon "<$1/$i/$k "
1854 if [ $j -eq 7 ]
1855 echo .
1857 else
1858 echo ! The end for $1
1860 return $1
1862 # Transport $?/$! up the call chain
1863 define w2 {
1864 echon ">$1 "
1865 vput vexpr i + $1 1
1866 if [ $1 -lt 42 ]
1867 call w2 $i
1868 wysh set i=$? j=$! k=$^ERRNAME
1869 echon "<$1/$i/$k "
1870 return $i $j
1871 else
1872 echo ! The end for $1
1873 return $i $^ERR-BUSY
1875 echoerr au
1877 # Up and down it goes
1878 define w3 {
1879 echon ">$1/$2 "
1880 vput vexpr i + $1 1
1881 if [ $1 -lt 42 ]
1882 call w3 $i $2
1883 wysh set i=$? j=$!
1884 vput vexpr k - $1 $2
1885 if [ $k -eq 21 ]
1886 vput vexpr i + $1 1
1887 vput vexpr j + $2 1
1888 echo "# <$i/$j> .. "
1889 call w3 $i $j
1890 wysh set i=$? j=$!
1892 eval echon "<\$1=\$i/\$^ERRNAME-$j "
1893 return $i $j
1894 else
1895 echo ! The end for $1=$i/$2
1896 if [ "$2" != "" ]
1897 return $i $^ERR-DOM
1898 else
1899 return $i $^ERR-BUSY
1902 echoerr au
1905 call w1 0; echo ?=$? !=$!; echo -----;
1906 call w2 0; echo ?=$? !=$^ERRNAME; echo -----;
1907 call w3 0 1; echo ?=$? !=$^ERRNAME; echo -----;
1908 __EOT
1910 check behave:call_ret 0 "${MBOX}" '1572045517 5922'
1912 t_epilog
1915 t_behave_xcall() {
1916 t_prolog
1918 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Snomemdebug > "${MBOX}" 2>&1
1919 define work {
1920 echon "$1 "
1921 vput vexpr i + $1 1
1922 if [ $i -le 1111 ]
1923 vput vexpr j '&' $i 7
1924 if [ $j -eq 7 ]
1925 echo .
1927 \xcall work $i $2
1929 echo ! The end for $1/$2
1930 if [ "$2" != "" ]
1931 return $i $^ERR-BUSY
1934 define xwork {
1935 \xcall work 0 $2
1937 call work 0
1938 echo ?=$? !=$!
1939 call xwork
1940 echo ?=$? !=$!
1941 xcall xwork
1942 echo ?=$? !=$^ERRNAME
1944 call work 0 yes
1945 echo ?=$? !=$^ERRNAME
1946 call xwork 0 yes
1947 echo ?=$? !=$^ERRNAME
1948 __EOT
1950 check behave:xcall-1 0 "${MBOX}" '2401702082 23801'
1954 ${cat} <<- '__EOT' > "${BODY}"
1955 define __w {
1956 echon "$1 "
1957 vput vexpr i + $1 1
1958 if [ $i -le 111 ]
1959 vput vexpr j '&' $i 7
1960 if [ $j -eq 7 ]
1961 echo .
1963 \xcall __w $i $2
1965 echo ! The end for $1
1966 if [ $2 -eq 0 ]
1967 nonexistingcommand
1968 echo would be err with errexit
1969 return
1971 echo calling exit
1972 exit
1974 define work {
1975 echo eins
1976 call __w 0 0
1977 echo zwei, ?=$? !=$!
1978 localopts yes; set errexit
1979 ignerr call __w 0 0
1980 echo drei, ?=$? !=$^ERRNAME
1981 call __w 0 $1
1982 echo vier, ?=$? !=$^ERRNAME, this is an error
1984 ignerr call work 0
1985 echo outer 1, ?=$? !=$^ERRNAME
1986 xxxign call work 0
1987 echo outer 2, ?=$? !=$^ERRNAME, could be error if xxxign non-empty
1988 call work 1
1989 echo outer 3, ?=$? !=$^ERRNAME
1990 echo this is definitely an error
1991 __EOT
1993 < "${BODY}" ${MAILX} ${ARGS} -X'commandalias xxxign ignerr' -Snomemdebug \
1994 > "${MBOX}" 2>&1
1995 check behave:xcall-2 0 "${MBOX}" '3900716531 4200'
1997 < "${BODY}" ${MAILX} ${ARGS} -X'commandalias xxxign " "' -Snomemdebug \
1998 > "${MBOX}" 2>&1
1999 check behave:xcall-3 1 "${MBOX}" '1006776201 2799'
2001 t_epilog
2004 t_behave_vpospar() {
2005 t_prolog
2007 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
2008 vpospar set hey, "'you ", world!
2009 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2010 vput vpospar x quote; echo x<$x>
2011 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2012 vput vpospar y quote;echo y<$y>
2013 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2014 eval vpospar set ${y};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2015 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2017 define infun2 {
2018 echo infun2:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2019 vput vpospar z quote;echo infun2:z<$z>
2022 define infun {
2023 echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2024 vput vpospar y quote;echo infun:y<$y>
2025 eval vpospar set ${x};echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2026 vpospar clear;echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2027 eval call infun2 $x
2028 echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2029 eval vpospar set ${y};echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2032 call infun This "in a" fun
2033 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2034 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2035 __EOT
2036 check behave:vpospar-1 0 "${MBOX}" '155175639 866'
2039 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
2040 set ifs=\'
2041 echo ifs<$ifs> ifs-ws<$ifs-ws>
2042 vpospar set hey, "'you ", world!
2043 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2044 vput vpospar x quote; echo x<$x>
2045 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2046 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2048 set ifs=,
2049 echo ifs<$ifs> ifs-ws<$ifs-ws>
2050 vpospar set hey, "'you ", world!
2051 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2052 vput vpospar x quote; echo x<$x>
2053 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2054 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2056 wysh set ifs=$',\t'
2057 echo ifs<$ifs> ifs-ws<$ifs-ws>
2058 vpospar set hey, "'you ", world!
2059 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2060 vput vpospar x quote; echo x<$x>
2061 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2062 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2063 __EOT
2064 check behave:vpospar-ifs 0 "${MBOX}" '2015927702 706'
2066 t_epilog
2069 t_behave_atxplode() {
2070 t_prolog
2071 TRAP_EXIT_ADDONS="./.t*"
2073 ${cat} > ./.t.sh <<- '___'; ${cat} > ./.t.rc <<- '___'
2074 x() { echo $#; }
2075 xxx() {
2076 printf " (1/$#: <$1>)"
2077 shift
2078 if [ $# -gt 0 ]; then
2079 xxx "$@"
2080 else
2081 echo
2084 yyy() {
2085 eval "$@ ' ball"
2087 set --
2088 x "$@"
2089 x "$@"''
2090 x " $@"
2091 x "$@ "
2092 printf yyy;yyy 'xxx' "b\$'\t'u ' "
2093 printf xxx;xxx arg ,b u.
2094 printf xxx;xxx arg , .
2095 printf xxx;xxx arg ,ball.
2097 define x {
2098 echo $#
2100 define xxx {
2101 echon " (1/$#: <$1>)"
2102 shift
2103 if [ $# -gt 0 ]
2104 \xcall xxx "$@"
2105 endif
2106 echo
2108 define yyy {
2109 eval "$@ ' ball"
2111 vpospar set
2112 call x "$@"
2113 call x "$@"''
2114 call x " $@"
2115 call x "$@ "
2116 echon yyy;call yyy '\call xxx' "b\$'\t'u ' "
2117 echon xxx;call xxx arg ,b u.
2118 echon xxx;call xxx arg , .
2119 echon xxx;call xxx arg ,ball.
2122 ${MAILX} ${ARGS} -X'source ./.t.rc' -Xx > "${MBOX}" 2>&1
2123 check behave:atxplode-1 0 "${MBOX}" '41566293 164'
2125 #${SHELL} ./.t.sh > ./.tshout 2>&1
2126 #check behave:atxplode:disproof-1 0 ./.tshout '41566293 164'
2128 t_epilog
2131 t_behave_read() {
2132 t_prolog
2133 TRAP_EXIT_ADDONS="./.t*"
2135 ${cat} <<- '__EOT' > .tin
2136 hey1, "'you ", world!
2137 hey2, "'you ", bugs bunny!
2138 hey3, "'you ",
2139 hey4, "'you "
2140 __EOT
2142 ${cat} <<- '__EOT' |\
2143 ${MAILX} ${ARGS} -X'readctl create ./.tin' > "${MBOX}" 2>&1
2144 read a b c
2145 echo $?/$^ERRNAME / <$a><$b><$c>
2146 read a b c
2147 echo $?/$^ERRNAME / <$a><$b><$c>
2148 read a b c
2149 echo $?/$^ERRNAME / <$a><$b><$c>
2150 read a b c
2151 echo $?/$^ERRNAME / <$a><$b><$c>
2152 unset a b c;read a b c
2153 echo $?/$^ERRNAME / <$a><$b><$c>
2154 readctl remove ./.tin;echo readctl remove:$?/$^ERRNAME
2155 __EOT
2156 check behave:read-1 0 "${MBOX}" '1527910147 173'
2158 ${cat} <<- '__EOT' > .tin2
2159 hey2.0,:"'you ",:world!:mars.:
2160 hey2.1,:"'you ",:world!
2161 hey2.2,:"'you ",:bugs bunny!
2162 hey2.3,:"'you ",:
2163 hey2.4,:"'you ":
2165 __EOT
2167 ${cat} <<- '__EOT' |\
2168 6< .tin2 ${MAILX} ${ARGS} -X 'readctl create 6' > "${MBOX}" 2>&1
2169 set ifs=:
2170 read a b c
2171 echo $?/$^ERRNAME / <$a><$b><$c>
2172 read a b c
2173 echo $?/$^ERRNAME / <$a><$b><$c>
2174 read a b c
2175 echo $?/$^ERRNAME / <$a><$b><$c>
2176 read a b c
2177 echo $?/$^ERRNAME / <$a><$b><$c>
2178 read a b c
2179 echo $?/$^ERRNAME / <$a><$b><$c>
2180 read a b c
2181 echo $?/$^ERRNAME / <$a><$b><$c>
2182 unset a b c;read a b c
2183 echo $?/$^ERRNAME / <$a><$b><$c>
2184 read a b c
2185 echo $?/$^ERRNAME / <$a><$b><$c>
2186 readctl remove 6;echo readctl remove:$?/$^ERRNAME
2187 __EOT
2188 check behave:read-ifs 0 "${MBOX}" '890153490 298'
2190 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
2191 readctl create .tin
2192 readall d; echo $?/$^ERRNAME / <$d>
2193 wysh set d;readall d;echo $?/$^ERRNAME / <$d>
2194 readctl create .tin2
2195 readall d; echo $?/$^ERRNAME / <$d>
2196 wysh set d;readall d;echo $?/$^ERRNAME / <$d>
2197 readctl remove .tin;echo $?/$^ERRNAME;\
2198 readctl remove .tin2;echo $?/$^ERRNAME
2199 __EOT
2200 check behave:readall 0 "${MBOX}" '860434889 333'
2202 t_epilog
2205 t_behave_mbox() {
2206 t_prolog
2207 TRAP_EXIT_ADDONS="./.t*"
2211 while [ ${i} -lt 112 ]; do
2212 printf 'm file://%s\n~s Subject %s\nHello %s!\n~.\n' \
2213 "${MBOX}" "${i}" "${i}"
2214 i=`add ${i} 1`
2215 done
2216 ) | ${MAILX} ${ARGS}
2217 check behave:mbox-1 0 "${MBOX}" '1140119864 13780'
2219 printf 'File "%s"
2220 copy * "%s"
2221 File "%s"
2222 from*
2223 ' "${MBOX}" .tmbox1 .tmbox1 |
2224 ${MAILX} ${ARGS} > .tlst
2225 check behave:mbox-2 0 .tlst '2739893312 9103'
2227 printf 'File "%s"
2228 copy * "file://%s"
2229 File "file://%s"
2230 from*
2231 ' "${MBOX}" .tmbox2 .tmbox2 |
2232 ${MAILX} ${ARGS} > .tlst
2233 check behave:mbox-3 0 .tlst '1702194178 9110'
2235 # only the odd (even)
2237 printf 'File "file://%s"
2238 copy ' .tmbox2
2240 while [ ${i} -lt 112 ]; do
2241 j=`modulo ${i} 2`
2242 [ ${j} -eq 1 ] && printf '%s ' "${i}"
2243 i=`add ${i} 1`
2244 done
2245 printf ' file://%s
2246 File "file://%s"
2247 from*
2248 ' .tmbox3 .tmbox3
2249 ) | ${MAILX} ${ARGS} > .tlst
2250 check behave:mbox-4 0 .tmbox3 '631132924 6890'
2251 check behave:mbox-5 - .tlst '2960975049 4573'
2252 # ...
2254 printf 'file "file://%s"
2255 move ' .tmbox2
2257 while [ ${i} -lt 112 ]; do
2258 j=`modulo ${i} 2`
2259 [ ${j} -eq 0 ] && [ ${i} -ne 0 ] && printf '%s ' "${i}"
2260 i=`add ${i} 1`
2261 done
2262 printf ' file://%s
2263 File "file://%s"
2264 from*
2265 File "file://%s"
2266 from*
2267 ' .tmbox3 .tmbox3 .tmbox2
2268 ) | ${MAILX} ${ARGS} > .tlst
2269 check behave:mbox-6 0 .tmbox3 '1387070539 13655'
2270 ${sed} 2d < .tlst > .tlstx
2271 check behave:mbox-7 - .tlstx '2729940494 13645'
2273 t_epilog
2276 t_behave_alternates() {
2277 t_prolog
2278 TRAP_EXIT_ADDONS="./.t*"
2280 ${cat} <<-_EOT > ./.tsendmail.sh
2281 #!${MYSHELL} -
2282 (echo 'From Valeriana Sat Jul 08 15:54:03 2017' && ${cat} && echo
2283 ) >> "${MBOX}"
2284 _EOT
2285 chmod 0755 ./.tsendmail.sh
2287 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Smta=./.tsendmail.sh > ./.tall 2>&1
2288 echo --0
2289 alternates
2290 echo $?/$^ERRNAME
2291 alternates a1@b1 a2@b2 a3@b3
2292 echo $?/$^ERRNAME
2293 alternates
2294 echo $?/$^ERRNAME
2295 vput alternates rv
2296 echo $?/$^ERRNAME <$rv>
2298 echo --1
2299 unalternates a2@b2
2300 vput alternates rv
2301 echo $?/$^ERRNAME <$rv>
2302 unalternates a3@b3
2303 vput alternates rv
2304 echo $?/$^ERRNAME <$rv>
2305 unalternates a1@b1
2306 vput alternates rv
2307 echo $?/$^ERRNAME <$rv>
2309 echo --2
2310 unalternates *
2311 alternates a1@b1 a2@b2 a3@b3
2312 unalternates a3@b3
2313 vput alternates rv
2314 echo $?/$^ERRNAME <$rv>
2315 unalternates a2@b2
2316 vput alternates rv
2317 echo $?/$^ERRNAME <$rv>
2318 unalternates a1@b1
2319 vput alternates rv
2320 echo $?/$^ERRNAME <$rv>
2322 echo --3
2323 alternates a1@b1 a2@b2 a3@b3
2324 unalternates a1@b1
2325 vput alternates rv
2326 echo $?/$^ERRNAME <$rv>
2327 unalternates a2@b2
2328 vput alternates rv
2329 echo $?/$^ERRNAME <$rv>
2330 unalternates a3@b3
2331 vput alternates rv
2332 echo $?/$^ERRNAME <$rv>
2334 echo --4
2335 unalternates *
2336 alternates a1@b1 a2@b2 a3@b3
2337 unalternates *
2338 vput alternates rv
2339 echo $?/$^ERRNAME <$rv>
2341 echo --5
2342 unalternates *
2343 alternates a1@b1 a1@c1 a1@d1 a2@b2 a3@b3 a3@c3 a3@d3
2344 m a1@b1 a1@c1 a1@d1
2345 ~s all alternates, only a1@b1 remains
2346 ~c a2@b2
2347 ~b a3@b3 a3@c3 a3@d3
2348 ~r - '_EOT'
2349 This body is!
2350 This also body is!!
2351 _EOT
2354 echo --6
2355 unalternates *
2356 alternates a1@b1 a1@c1 a2@b2 a3@b3
2357 m a1@b1 a1@c1 a1@d1
2358 ~s a1@b1 a1@d1, and a3@c3 a3@d3 remain
2359 ~c a2@b2
2360 ~b a3@b3 a3@c3 a3@d3
2361 ~r - '_EOT'
2362 This body2 is!
2363 _EOT
2366 echo --7
2367 alternates a1@b1 a2@b2 a3; set allnet
2368 m a1@b1 a1@c1 a1@d1
2369 ~s all alternates via allnet, only a1@b1 remains
2370 ~c a2@b2
2371 ~b a3@b3 a3@c3 a3@d3
2372 ~r - '_EOT'
2373 This body3 is!
2374 _EOT
2377 echo --10
2378 unalternates *
2379 alternates a1@b1
2380 echo $?/$^ERRNAME
2381 vput alternates rv
2382 echo $?/$^ERRNAME <$rv>
2383 alternates a2@b2
2384 echo $?/$^ERRNAME
2385 vput alternates rv
2386 echo $?/$^ERRNAME <$rv>
2387 alternates a3@b3
2388 echo $?/$^ERRNAME
2389 vput alternates rv
2390 echo $?/$^ERRNAME <$rv>
2391 alternates a4@b4
2392 echo $?/$^ERRNAME
2393 vput alternates rv
2394 echo $?/$^ERRNAME <$rv>
2396 unalternates *
2397 vput alternates rv
2398 echo $?/$^ERRNAME <$rv>
2400 echo --11
2401 set posix
2402 alternates a1@b1 a2@b2
2403 echo $?/$^ERRNAME
2404 vput alternates rv
2405 echo $?/$^ERRNAME <$rv>
2406 alternates a3@b3 a4@b4
2407 echo $?/$^ERRNAME
2408 vput alternates rv
2409 echo $?/$^ERRNAME <$rv>
2410 __EOT
2411 check behave:alternates-1 0 "${MBOX}" '142184864 515'
2412 check behave:alternates-2 - .tall '1878598364 505'
2414 t_epilog
2417 t_behave_alias() {
2418 t_prolog
2419 TRAP_EXIT_ADDONS="./.t*"
2421 ${cat} <<-_EOT > ./.tsendmail.sh
2422 #!${MYSHELL} -
2423 (echo 'From Hippocastanum Mon Jun 19 15:07:07 2017' && ${cat} && echo
2424 ) >> "${MBOX}"
2425 _EOT
2426 chmod 0755 ./.tsendmail.sh
2428 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Smta=./.tsendmail.sh > ./.tall 2>&1
2429 alias a1 ex1@a1.ple
2430 alias a1 ex2@a1.ple "EX3 <ex3@a1.ple>"
2431 alias a1 ex4@a1.ple
2432 alias a2 ex1@a2.ple ex2@a2.ple ex3@a2.ple ex4@a2.ple
2433 alias a3 a4
2434 alias a4 a5 ex1@a4.ple
2435 alias a5 a6
2436 alias a6 a7 ex1@a6.ple
2437 alias a7 a8
2438 alias a8 ex1@a8.ple
2439 alias a1
2440 alias a2
2441 alias a3
2442 m a1
2443 ~c a2
2444 ~b a3
2445 ~r - '_EOT'
2446 This body is!
2447 This also body is!!
2448 _EOT
2449 __EOT
2450 check behave:alias-1 0 "${MBOX}" '2496925843 272'
2451 check behave:alias-2 - .tall '3548953204 152'
2453 # TODO t_behave_alias: n_ALIAS_MAXEXP is compile-time constant,
2454 # TODO need to somehow provide its contents to the test, then test
2456 t_epilog
2459 t_behave_filetype() {
2460 t_prolog
2461 TRAP_EXIT_ADDONS="./.t*"
2463 ${cat} <<-_EOT > ./.tsendmail.sh
2464 #!${MYSHELL} -
2465 (echo 'From Alchemilla Wed Apr 25 15:12:13 2017' && ${cat} && echo
2466 ) >> "${MBOX}"
2467 _EOT
2468 chmod 0755 ./.tsendmail.sh
2470 printf 'm m1@e.t\nL1\nHy1\n~.\nm m2@e.t\nL2\nHy2\n~@ %s\n~.\n' \
2471 "${SRCDIR}snailmail.jpg" | ${MAILX} ${ARGS} -Smta=./.tsendmail.sh
2472 check behave:filetype-1 0 "${MBOX}" '1594682963 13520'
2474 if command -v gzip >/dev/null 2>&1; then
2475 ${rm} -f ./.t.mbox*
2477 printf 'File "%s"\ncopy 1 ./.t.mbox.gz
2478 copy 2 ./.t.mbox.gz' "${MBOX}" |
2479 ${MAILX} ${ARGS} \
2480 -X'filetype gz gzip\ -dc gzip\ -c'
2481 printf 'File ./.t.mbox.gz\ncopy * ./.t.mbox\n' |
2482 ${MAILX} ${ARGS} \
2483 -X'filetype gz gzip\ -dc gzip\ -c'
2484 } > ./.t.out 2>&1
2485 check behave:filetype-2 - "./.t.mbox" '1594682963 13520'
2486 check behave:filetype-3 - "./.t.out" '2494681730 102'
2487 else
2488 echo 'behave:filetype-2: unsupported, skipped'
2489 echo 'behave:filetype-3: unsupported, skipped'
2493 ${rm} -f ./.t.mbox*
2494 printf 'File "%s"\ncopy 1 ./.t.mbox.gz
2495 copy 2 ./.t.mbox.gz
2496 copy 1 ./.t.mbox.gz
2497 copy 2 ./.t.mbox.gz
2498 ' "${MBOX}" |
2499 ${MAILX} ${ARGS} \
2500 -X'filetype gz gzip\ -dc gzip\ -c' \
2501 -X'filetype mbox.gz "${sed} 1,3d|${cat}" \
2502 "echo eins;echo zwei;echo und mit ${sed} bist Du dabei;${cat}"'
2503 printf 'File ./.t.mbox.gz\ncopy * ./.t.mbox\n' |
2504 ${MAILX} ${ARGS} \
2505 -X'filetype gz gzip\ -dc gzip\ -c' \
2506 -X'filetype mbox.gz "${sed} 1,3d|${cat}" kill\ 0'
2507 } > ./.t.out 2>&1
2508 check behave:filetype-4 - "./.t.mbox" '2886541147 27060'
2509 check behave:filetype-5 - "./.t.out" '838452520 172'
2511 t_epilog
2514 t_behave_record_a_resend() {
2515 t_prolog
2516 TRAP_EXIT_ADDONS="./.t.record ./.t.resent"
2518 printf '
2519 set record=%s
2520 m %s\n~s Subject 1.\nHello.\n~.
2521 set record-files add-file-recipients
2522 m %s\n~s Subject 2.\nHello.\n~.
2523 File %s
2524 resend 2 ./.t.resent
2525 Resend 1 ./.t.resent
2526 set record-resent
2527 resend 2 ./.t.resent
2528 Resend 1 ./.t.resent
2529 ' ./.t.record "${MBOX}" "${MBOX}" "${MBOX}" |
2530 ${MAILX} ${ARGS}
2532 check behave:record_a_resend-1 0 "${MBOX}" '3057873538 256'
2533 check behave:record_a_resend-2 - .t.record '391356429 460'
2534 check behave:record_a_resend-3 - .t.resent '2685231691 648'
2536 t_epilog
2539 t_behave_e_H_L_opts() {
2540 t_prolog
2541 TRAP_EXIT_ADDONS="./.tsendmail.sh ./.t.mbox"
2543 touch ./.t.mbox
2544 ${MAILX} ${ARGS} -ef ./.t.mbox
2545 echo ${?} > "${MBOX}"
2547 ${cat} <<-_EOT > ./.tsendmail.sh
2548 #!${MYSHELL} -
2549 (echo 'From Alchemilla Wed Apr 07 17:03:33 2017' && ${cat} && echo
2550 ) >> "./.t.mbox"
2551 _EOT
2552 chmod 0755 ./.tsendmail.sh
2553 printf 'm me@exam.ple\nLine 1.\nHello.\n~.\n' |
2554 ${MAILX} ${ARGS} -Smta=./.tsendmail.sh
2555 printf 'm you@exam.ple\nLine 1.\nBye.\n~.\n' |
2556 ${MAILX} ${ARGS} -Smta=./.tsendmail.sh
2558 ${MAILX} ${ARGS} -ef ./.t.mbox
2559 echo ${?} >> "${MBOX}"
2560 ${MAILX} ${ARGS} -efL @t@me ./.t.mbox
2561 echo ${?} >> "${MBOX}"
2562 ${MAILX} ${ARGS} -efL @t@you ./.t.mbox
2563 echo ${?} >> "${MBOX}"
2564 ${MAILX} ${ARGS} -efL '@>@Line 1' ./.t.mbox
2565 echo ${?} >> "${MBOX}"
2566 ${MAILX} ${ARGS} -efL '@>@Hello.' ./.t.mbox
2567 echo ${?} >> "${MBOX}"
2568 ${MAILX} ${ARGS} -efL '@>@Bye.' ./.t.mbox
2569 echo ${?} >> "${MBOX}"
2570 ${MAILX} ${ARGS} -efL '@>@Good bye.' ./.t.mbox
2571 echo ${?} >> "${MBOX}"
2573 ${MAILX} ${ARGS} -fH ./.t.mbox >> "${MBOX}"
2574 echo ${?} >> "${MBOX}"
2575 ${MAILX} ${ARGS} -fL @t@me ./.t.mbox >> "${MBOX}"
2576 echo ${?} >> "${MBOX}"
2577 ${MAILX} ${ARGS} -fL @t@you ./.t.mbox >> "${MBOX}"
2578 echo ${?} >> "${MBOX}"
2579 ${MAILX} ${ARGS} -fL '@>@Line 1' ./.t.mbox >> "${MBOX}"
2580 echo ${?} >> "${MBOX}"
2581 ${MAILX} ${ARGS} -fL '@>@Hello.' ./.t.mbox >> "${MBOX}"
2582 echo ${?} >> "${MBOX}"
2583 ${MAILX} ${ARGS} -fL '@>@Bye.' ./.t.mbox >> "${MBOX}"
2584 echo ${?} >> "${MBOX}"
2585 ${MAILX} ${ARGS} -fL '@>@Good bye.' ./.t.mbox >> "${MBOX}" 2>/dev/null
2586 echo ${?} >> "${MBOX}"
2588 check behave:e_H_L_opts - "${MBOX}" '1708955574 678'
2590 t_epilog
2593 t_behave_compose_hooks() { # TODO monster
2594 t_prolog
2595 TRAP_EXIT_ADDONS="./.t*"
2597 (echo line one&&echo line two&&echo line three) > ./.treadctl
2598 (echo echo four&&echo echo five&&echo echo six) > ./.tattach
2600 ${cat} <<-_EOT > ./.tsendmail.sh
2601 #!${MYSHELL} -
2602 (echo 'From PrimulaVeris Wed Apr 10 22:59:00 2017' && ${cat} && echo
2603 ) >> "${MBOX}"
2604 _EOT
2605 chmod 0755 ./.tsendmail.sh
2607 ${cat} <<'__EOT__' > ./.trc
2608 define bail {
2609 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
2611 define xerr {
2612 vput vexpr es substr "$1" 0 1
2613 if [ "$es" != 2 ]
2614 xcall bail "$2"
2617 define read_mline_res {
2618 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
2619 echo $len/$es/$^ERRNAME: $hl
2620 if [ $es -ne $^ERR-NONE ]
2621 xcall bail read_mline_res
2622 elif [ $len -ne 0 ]
2623 \xcall read_mline_res
2626 define ins_addr {
2627 wysh set xh=$1
2628 echo "~^header list"; read hl; echo $hl;\
2629 call xerr "$hl" "in_addr ($xh) 0-1"
2631 echo "~^header insert $xh diet <$xh@exam.ple> spliced";\
2632 read es; echo $es; call xerr "$es" "ins_addr $xh 1-1"
2633 echo "~^header insert $xh <${xh}2@exam.ple>";\
2634 read es; echo $es; call xerr "$es" "ins_addr $xh 1-2"
2635 echo "~^header insert $xh ${xh}3@exam.ple";\
2636 read es; echo $es; call xerr "$es" "ins_addr $xh 1-3"
2637 echo "~^header list $xh"; read hl; echo $hl;\
2638 call xerr "$hl" "ins_addr $xh 1-4"
2639 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 1-5"
2640 call read_mline_res
2642 if [ "$t_remove" == "" ]
2643 return
2646 echo "~^header remove $xh"; read es; call xerr $es "ins_addr $xh 2-1"
2647 echo "~^header remove $xh"; read es; vput vexpr es substr $es 0 3
2648 if [ $es != 501 ]
2649 xcall bail "ins_addr $xh 2-2"
2651 echo "~^header list $xh"; read es; vput vexpr es substr $es 0 3
2652 if [ $es != 501 ]
2653 xcall bail "ins_addr $xh 2-3"
2655 echo "~^header show $xh"; read es; vput vexpr es substr $es 0 3
2656 if [ $es != 501 ]
2657 xcall bail "ins_addr $xh 2-4"
2661 echo "~^header insert $xh diet <$xh@exam.ple> spliced";\
2662 read es; echo $es; call xerr "$es" "ins_addr $xh 3-1"
2663 echo "~^header insert $xh <${xh}2@exam.ple>";\
2664 read es; echo $es; call xerr "$es" "ins_addr $xh 3-2"
2665 echo "~^header insert $xh ${xh}3@exam.ple";\
2666 read es; echo $es; call xerr "$es" "ins_addr $xh 3-3"
2667 echo "~^header list $xh"; read hl; echo $hl;\
2668 call xerr "$hl" "ins_addr $xh 3-4"
2669 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 3-5"
2670 call read_mline_res
2672 echo "~^header remove-at $xh 1"; read es;\
2673 call xerr $es "ins_addr $xh 3-6"
2674 echo "~^header remove-at $xh 1"; read es;\
2675 call xerr $es "ins_addr $xh 3-7"
2676 echo "~^header remove-at $xh 1"; read es;\
2677 call xerr $es "ins_addr $xh 3-8"
2678 echo "~^header remove-at $xh 1"; read es;\
2679 vput vexpr es substr $es 0 3
2680 if [ $es != 501 ]
2681 xcall bail "ins_addr $xh 3-9"
2683 echo "~^header remove-at $xh T"; read es;\
2684 vput vexpr es substr $es 0 3
2685 if [ $es != 505 ]
2686 xcall bail "ins_addr $xh 3-10"
2688 echo "~^header list $xh"; read es;\
2689 vput vexpr es substr $es 0 3
2690 if [ $es != 501 ]
2691 xcall bail "ins_addr $xh 3-11"
2693 echo "~^header show $xh"; read es;\
2694 vput vexpr es substr $es 0 3
2695 if [ $es != 501 ]
2696 xcall bail "ins_addr $xh 3-12"
2700 echo "~^header insert $xh diet <$xh@exam.ple> spliced";\
2701 read es; echo $es; call xerr "$es" "ins_addr $xh 4-1"
2702 echo "~^header insert $xh <${xh}2@exam.ple> (comment) \"Quot(e)d\"";\
2703 read es; echo $es; call xerr "$es" "ins_addr $xh 4-2"
2704 echo "~^header insert $xh ${xh}3@exam.ple";\
2705 read es; echo $es; call xerr "$es" "ins_addr $xh 4-3"
2706 echo "~^header list $xh"; read hl; echo $hl;\
2707 call xerr "$hl" "header list $xh 3-4"
2708 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 4-5"
2709 call read_mline_res
2711 echo "~^header remove-at $xh 3"; read es;\
2712 call xerr $es "ins_addr $xh 4-6"
2713 echo "~^header remove-at $xh 2"; read es;\
2714 call xerr $es "ins_addr $xh 4-7"
2715 echo "~^header remove-at $xh 1"; read es;\
2716 call xerr $es "ins_addr $xh 4-8"
2717 echo "~^header remove-at $xh 1"; read es;\
2718 vput vexpr es substr $es 0 3
2719 if [ $es != 501 ]
2720 xcall bail "ins_addr $xh 4-9"
2722 echo "~^header remove-at $xh T"; read es;\
2723 vput vexpr es substr $es 0 3
2724 if [ $es != 505 ]
2725 xcall bail "ins_addr $xh 4-10"
2727 echo "~^header list $xh"; read es;\
2728 vput vexpr es substr $es 0 3
2729 if [ $es != 501 ]
2730 xcall bail "ins_addr $xh 4-11"
2732 echo "~^header show $xh"; read es;\
2733 vput vexpr es substr $es 0 3
2734 if [ $es != 501 ]
2735 xcall bail "ins_addr $xh 4-12"
2738 define ins_ref {
2739 wysh set xh=$1 mult=$2
2740 echo "~^header list"; read hl; echo $hl;\
2741 call xerr "$hl" "ins_ref ($xh) 0-1"
2743 echo "~^header insert $xh <$xh@exam.ple>";\
2744 read es; echo $es; call xerr "$es" "ins_ref $xh 1-1"
2745 if [ $mult -ne 0 ]
2746 echo "~^header insert $xh <${xh}2@exam.ple>";\
2747 read es; echo $es; call xerr "$es" "ins_ref $xh 1-2"
2748 echo "~^header insert $xh ${xh}3@exam.ple";\
2749 read es; echo $es; call xerr "$es" "ins_ref $xh 1-3"
2750 else
2751 echo "~^header insert $xh <${xh}2@exam.ple>"; read es;\
2752 vput vexpr es substr $es 0 3
2753 if [ $es != 506 ]
2754 xcall bail "ins_ref $xh 1-4"
2758 echo "~^header list $xh"; read hl; echo $hl;\
2759 call xerr "$hl" "ins_ref $xh 1-5"
2760 echo "~^header show $xh"; read es; call xerr $es "ins_ref $xh 1-6"
2761 call read_mline_res
2763 if [ "$t_remove" == "" ]
2764 return
2767 echo "~^header remove $xh"; read es;\
2768 call xerr $es "ins_ref $xh 2-1"
2769 echo "~^header remove $xh"; read es;\
2770 vput vexpr es substr $es 0 3
2771 if [ $es != 501 ]
2772 xcall bail "ins_ref $xh 2-2"
2774 echo "~^header list $xh"; read es;\
2775 vput vexpr es substr $es 0 3
2776 if [ $es != 501 ]
2777 xcall bail "$es ins_ref $xh 2-3"
2779 echo "~^header show $xh"; read es;\
2780 vput vexpr es substr $es 0 3
2781 if [ $es != 501 ]
2782 xcall bail "ins_ref $xh 2-4"
2786 echo "~^header insert $xh <$xh@exam.ple>";\
2787 read es; echo $es; call xerr "$es" "ins_ref $xh 3-1"
2788 if [ $mult -ne 0 ]
2789 echo "~^header insert $xh <${xh}2@exam.ple>";\
2790 read es; echo $es; call xerr "$es" "ins_ref $xh 3-2"
2791 echo "~^header insert $xh ${xh}3@exam.ple";\
2792 read es; echo $es; call xerr "$es" "ins_ref $xh 3-3"
2794 echo "~^header list $xh";\
2795 read hl; echo $hl; call xerr "$hl" "ins_ref $xh 3-4"
2796 echo "~^header show $xh";\
2797 read es; call xerr $es "ins_ref $xh 3-5"
2798 call read_mline_res
2800 echo "~^header remove-at $xh 1"; read es;\
2801 call xerr $es "ins_ref $xh 3-6"
2802 if [ $mult -ne 0 ] && [ $xh != subject ]
2803 echo "~^header remove-at $xh 1"; read es;\
2804 call xerr $es "ins_ref $xh 3-7"
2805 echo "~^header remove-at $xh 1"; read es;\
2806 call xerr $es "ins_ref $xh 3-8"
2808 echo "~^header remove-at $xh 1"; read es;\
2809 vput vexpr es substr $es 0 3
2810 if [ $es != 501 ]
2811 xcall bail "ins_ref $xh 3-9"
2813 echo "~^header remove-at $xh T"; read es;\
2814 vput vexpr es substr $es 0 3
2815 if [ $es != 505 ]
2816 xcall bail "ins_ref $xh 3-10"
2818 echo "~^header show $xh"; read es;\
2819 vput vexpr es substr $es 0 3
2820 if [ $es != 501 ]
2821 xcall bail "ins_ref $xh 3-11"
2825 echo "~^header insert $xh <$xh@exam.ple> ";\
2826 read es; echo $es; call xerr "$es" "ins_ref $xh 4-1"
2827 if [ $mult -ne 0 ]
2828 echo "~^header insert $xh <${xh}2@exam.ple> ";\
2829 read es; echo $es; call xerr "$es" "ins_ref $xh 4-2"
2830 echo "~^header insert $xh ${xh}3@exam.ple";\
2831 read es; echo $es; call xerr "$es" "ins_ref $xh 4-3"
2833 echo "~^header list $xh"; read hl; echo $hl;\
2834 call xerr "$hl" "ins_ref $xh 4-4"
2835 echo "~^header show $xh"; read es; call xerr $es "ins_ref $xh 4-5"
2836 call read_mline_res
2838 if [ $mult -ne 0 ] && [ $xh != subject ]
2839 echo "~^header remove-at $xh 3"; read es;\
2840 call xerr $es "ins_ref $xh 4-6"
2841 echo "~^header remove-at $xh 2"; read es;\
2842 call xerr $es "ins_ref $xh 4-7"
2844 echo "~^header remove-at $xh 1"; read es;\
2845 call xerr $es "ins_ref $xh 4-8"
2846 echo "~^header remove-at $xh 1"; read es;\
2847 vput vexpr es substr $es 0 3
2848 if [ $es != 501 ]
2849 xcall bail "ins_ref $xh 4-9"
2851 echo "~^header remove-at $xh T"; read es;\
2852 vput vexpr es substr $es 0 3
2853 if [ $es != 505 ]
2854 xcall bail "ins_ref $xh 4-10"
2856 echo "~^header show $xh"; read es;\
2857 vput vexpr es substr $es 0 3
2858 if [ $es != 501 ]
2859 xcall bail "ins_ref $xh 4-11"
2862 define t_header {
2863 echo t_header ENTER
2864 # In collect.c order
2865 call ins_addr from
2866 call ins_ref sender 0 # Not a "ref", but works
2867 call ins_addr To
2868 call ins_addr cC
2869 call ins_addr bCc
2870 call ins_addr reply-To
2871 call ins_addr mail-Followup-to
2872 call ins_ref messAge-id 0
2873 call ins_ref rEfErEncEs 1
2874 call ins_ref in-Reply-to 1
2875 call ins_ref subject 1 # Not a "ref", but works (with tweaks)
2876 call ins_addr freeForm1
2877 call ins_addr freeform2
2879 echo "~^header show MAILX-Command"; read es; call xerr $es "t_header 1000"
2880 call read_mline_res
2881 echo "~^header show MAILX-raw-TO"; read es; call xerr $es "t_header 1001"
2882 call read_mline_res
2884 echo t_header LEAVE
2886 define t_attach {
2887 echo t_attach ENTER
2889 echo "~^attachment";\
2890 read hl; echo $hl; vput vexpr es substr "$hl" 0 3
2891 if [ "$es" != 501 ]
2892 xcall bail "attach 0-1"
2895 echo "~^attach attribute ./.treadctl";\
2896 read hl; echo $hl; vput vexpr es substr "$hl" 0 3
2897 if [ "$es" != 501 ]
2898 xcall bail "attach 0-2"
2900 echo "~^attachment attribute-at 1";\
2901 read hl; echo $hl; vput vexpr es substr "$hl" 0 3
2902 if [ "$es" != 501 ]
2903 xcall bail "attach 0-3"
2906 echo "~^attachment insert ./.treadctl=ascii";\
2907 read hl; echo $hl; call xerr "$hl" "attach 1-1"
2908 echo "~^attachment list";\
2909 read es; echo $es;call xerr "$es" "attach 1-2"
2910 call read_mline_res
2911 echo "~^attachment attribute ./.treadctl";\
2912 read es; echo $es;call xerr "$es" "attach 1-3"
2913 call read_mline_res
2914 echo "~^attachment attribute .treadctl";\
2915 read es; echo $es;call xerr "$es" "attach 1-4"
2916 call read_mline_res
2917 echo "~^attachment attribute-at 1";\
2918 read es; echo $es;call xerr "$es" "attach 1-5"
2919 call read_mline_res
2921 echo "~^attachment attribute-set ./.treadctl filename rctl";\
2922 read es; echo $es;call xerr "$es" "attach 1-6"
2923 echo "~^attachment attribute-set .treadctl content-description Au";\
2924 read es; echo $es;call xerr "$es" "attach 1-7"
2925 echo "~^attachment attribute-set-at 1 content-id <10.du@ich>";\
2926 read es; echo $es;call xerr "$es" "attach 1-8"
2928 echo "~^attachment attribute ./.treadctl";\
2929 read es; echo $es;call xerr "$es" "attach 1-9"
2930 call read_mline_res
2931 echo "~^attachment attribute .treadctl";\
2932 read es; echo $es;call xerr "$es" "attach 1-10"
2933 call read_mline_res
2934 echo "~^attachment attribute rctl";\
2935 read es; echo $es;call xerr "$es" "attach 1-11"
2936 call read_mline_res
2937 echo "~^attachment attribute-at 1";\
2938 read es; echo $es;call xerr "$es" "attach 1-12"
2939 call read_mline_res
2942 echo "~^attachment insert ./.tattach=latin1";\
2943 read hl; echo $hl; call xerr "$hl" "attach 2-1"
2944 echo "~^attachment list";\
2945 read es; echo $es;call xerr "$es" "attach 2-2"
2946 call read_mline_res
2947 echo "~^attachment attribute ./.tattach";\
2948 read es; echo $es;call xerr "$es" "attach 2-3"
2949 call read_mline_res
2950 echo "~^attachment attribute .tattach";\
2951 read es; echo $es;call xerr "$es" "attach 2-4"
2952 call read_mline_res
2953 echo "~^attachment attribute-at 2";\
2954 read es; echo $es;call xerr "$es" "attach 2-5"
2955 call read_mline_res
2957 echo "~^attachment attribute-set ./.tattach filename tat";\
2958 read es; echo $es;call xerr "$es" "attach 2-6"
2959 echo \
2960 "~^attachment attribute-set .tattach content-description Au2";\
2961 read es; echo $es;call xerr "$es" "attach 2-7"
2962 echo "~^attachment attribute-set-at 2 content-id <20.du@wir>";\
2963 read es; echo $es;call xerr "$es" "attach 2-8"
2964 echo \
2965 "~^attachment attribute-set-at 2 content-type application/x-sh";\
2966 read es; echo $es;call xerr "$es" "attach 2-9"
2968 echo "~^attachment attribute ./.tattach";\
2969 read es; echo $es;call xerr "$es" "attach 2-10"
2970 call read_mline_res
2971 echo "~^attachment attribute .tattach";\
2972 read es; echo $es;call xerr "$es" "attach 2-11"
2973 call read_mline_res
2974 echo "~^attachment attribute tat";\
2975 read es; echo $es;call xerr "$es" "attach 2-12"
2976 call read_mline_res
2977 echo "~^attachment attribute-at 2";\
2978 read es; echo $es;call xerr "$es" "attach 2-13"
2979 call read_mline_res
2982 if [ "$t_remove" == "" ]
2983 return
2986 echo "~^attachment remove ./.treadctl"; read es;\
2987 call xerr $es "attach 3-1"
2988 echo "~^attachment remove ./.tattach"; read es;\
2989 call xerr $es "attach 3-2"
2990 echo "~^ attachment remove ./.treadctl"; read es;\
2991 vput vexpr es substr $es 0 3
2992 if [ $es != 501 ]
2993 xcall bail "attach 3-3"
2995 echo "~^ attachment remove ./.tattach"; read es;\
2996 vput vexpr es substr $es 0 3
2997 if [ $es != 501 ]
2998 xcall bail "attach 3-4"
3000 echo "~^attachment list"; read es;\
3001 vput vexpr es substr $es 0 3
3002 if [ $es != 501 ]
3003 xcall bail "attach 3-5"
3007 echo "~^attachment insert ./.tattach=latin1";\
3008 read hl; echo $hl; call xerr "$hl" "attach 4-1"
3009 echo "~^attachment insert ./.tattach=latin1";\
3010 read hl; echo $hl; call xerr "$hl" "attach 4-2"
3011 echo "~^attachment list";\
3012 read es; echo $es;call xerr "$es" "attach 4-3"
3013 call read_mline_res
3014 echo "~^ attachment remove .tattach"; read es;\
3015 vput vexpr es substr $es 0 3
3016 if [ $es != 506 ]
3017 xcall bail "attach 4-4 $es"
3019 echo "~^attachment remove-at T"; read es;\
3020 vput vexpr es substr $es 0 3
3021 if [ $es != 505 ]
3022 xcall bail "attach 4-5"
3024 echo "~^attachment remove ./.tattach"; read es;\
3025 call xerr $es "attach 4-6"
3026 echo "~^attachment remove ./.tattach"; read es;\
3027 call xerr $es "attach 4-7"
3028 echo "~^ attachment remove ./.tattach"; read es;\
3029 vput vexpr es substr $es 0 3
3030 if [ $es != 501 ]
3031 xcall bail "attach 4-8 $es"
3033 echo "~^attachment list"; read es;\
3034 vput vexpr es substr $es 0 3
3035 if [ $es != 501 ]
3036 xcall bail "attach 4-9"
3040 echo "~^attachment insert ./.tattach=latin1";\
3041 read hl; echo $hl; call xerr "$hl" "attach 5-1"
3042 echo "~^attachment insert ./.tattach=latin1";\
3043 read hl; echo $hl; call xerr "$hl" "attach 5-2"
3044 echo "~^attachment insert ./.tattach=latin1";\
3045 read hl; echo $hl; call xerr "$hl" "attach 5-3"
3046 echo "~^attachment list";\
3047 read es; echo $es;call xerr "$es" "attach 5-4"
3048 call read_mline_res
3050 echo "~^attachment remove-at 3"; read es;\
3051 call xerr $es "attach 5-5"
3052 echo "~^attachment remove-at 3"; read es;\
3053 vput vexpr es substr $es 0 3
3054 if [ $es != 501 ]
3055 xcall bail "attach 5-6"
3057 echo "~^attachment remove-at 2"; read es;\
3058 call xerr $es "attach 5-7"
3059 echo "~^attachment remove-at 2"; read es;\
3060 vput vexpr es substr $es 0 3
3061 if [ $es != 501 ]
3062 xcall bail "attach 5-8"
3064 echo "~^attachment remove-at 1"; read es;\
3065 call xerr $es "attach 5-9"
3066 echo "~^attachment remove-at 1"; read es;\
3067 vput vexpr es substr $es 0 3
3068 if [ $es != 501 ]
3069 xcall bail "attach 5-10"
3072 echo "~^attachment list"; read es;\
3073 vput vexpr es substr $es 0 3
3074 if [ $es != 501 ]
3075 xcall bail "attach 5-11"
3079 echo "~^attachment insert ./.tattach=latin1";\
3080 read hl; echo $hl; call xerr "$hl" "attach 6-1"
3081 echo "~^attachment insert ./.tattach=latin1";\
3082 read hl; echo $hl; call xerr "$hl" "attach 6-2"
3083 echo "~^attachment insert ./.tattach=latin1";\
3084 read hl; echo $hl; call xerr "$hl" "attach 6-3"
3085 echo "~^attachment list";\
3086 read es; echo $es;call xerr "$es" "attach 6-4"
3087 call read_mline_res
3089 echo "~^attachment remove-at 1"; read es;\
3090 call xerr $es "attach 6-5"
3091 echo "~^attachment remove-at 1"; read es;\
3092 call xerr $es "attach 6-6"
3093 echo "~^attachment remove-at 1"; read es;\
3094 call xerr $es "attach 6-7"
3095 echo "~^attachment remove-at 1"; read es;\
3096 vput vexpr es substr $es 0 3
3097 if [ $es != 501 ]
3098 xcall bail "attach 6-8"
3101 echo "~^attachment list"; read es;\
3102 vput vexpr es substr $es 0 3
3103 if [ $es != 501 ]
3104 xcall bail "attach 6-9"
3107 echo t_attach LEAVE
3109 define t_ocs {
3110 read ver
3111 echo t_ocs
3112 call t_header
3113 call t_attach
3115 define t_oce {
3116 echo on-compose-enter, mailx-command<$mailx-command>
3117 alternates alter1@exam.ple alter2@exam.ple
3118 alternates
3119 set autocc='alter1@exam.ple alter2@exam.ple'
3120 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3121 echo mailx-subject<$mailx-subject>
3122 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3123 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3124 mailx-raw-bcc<$mailx-raw-bcc>
3125 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
3126 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3128 define t_ocl {
3129 echo on-compose-leave, mailx-command<$mailx-command>
3130 vput alternates al
3131 eval alternates $al alter3@exam.ple alter4@exam.ple
3132 alternates
3133 set autobcc='alter3@exam.ple alter4@exam.ple'
3134 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3135 echo mailx-subject<$mailx-subject>
3136 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3137 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3138 mailx-raw-bcc<$mailx-raw-bcc>
3139 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
3140 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3142 define t_occ {
3143 echo on-compose-cleanup, mailx-command<$mailx-command>
3144 unalternates *
3145 alternates
3146 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3147 echo mailx-subject<$mailx-subject>
3148 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3149 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3150 mailx-raw-bcc<$mailx-raw-bcc>
3151 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
3152 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3154 wysh set on-compose-splice=t_ocs \
3155 on-compose-enter=t_oce on-compose-leave=t_ocl \
3156 on-compose-cleanup=t_occ
3157 __EOT__
3159 ${rm} -f "${MBOX}"
3160 printf 'm this-goes@nowhere\nbody\n!.\n' |
3161 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
3162 -X'source ./.trc' -Smta=./.tsendmail.sh \
3163 >./.tall 2>&1
3164 ${cat} ./.tall >> "${MBOX}"
3165 check behave:compose_hooks-1 0 "${MBOX}" '522535560 10101'
3167 ${rm} -f "${MBOX}"
3168 printf 'm this-goes@nowhere\nbody\n!.\n' |
3169 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
3170 -St_remove=1 -X'source ./.trc' -Smta=./.tsendmail.sh \
3171 >./.tall 2>&1
3172 ${cat} ./.tall >> "${MBOX}"
3173 check behave:compose_hooks-2 0 "${MBOX}" '3654000499 12535'
3177 # Some state machine stress, shell compose hook, localopts for hook, etc.
3178 # readctl in child. ~r as HERE document
3179 ${rm} -f "${MBOX}"
3180 printf 'm ex@am.ple\nbody\n!.\nvar t_oce t_ocs t_ocs_sh t_ocl t_occ autocc' |
3181 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! \
3182 -Smta=./.tsendmail.sh \
3184 define bail {
3185 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
3187 define xerr {
3188 vput vexpr es substr "$1" 0 1
3189 if [ "$es" != 2 ]
3190 xcall bail "$2"
3193 define read_mline_res {
3194 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
3195 echo $len/$es/$^ERRNAME: $hl
3196 if [ $es -ne $^ERR-NONE ]
3197 xcall bail read_mline_res
3198 elif [ $len -ne 0 ]
3199 \xcall read_mline_res
3202 define _work {
3203 vput vexpr i + 1 "$2"
3204 if [ $i -lt 111 ]
3205 vput vexpr j % $i 10
3206 if [ $j -ne 0 ]
3207 set j=xcall
3208 else
3209 echon "$i.. "
3210 set j=call
3212 eval \\$j _work $1 $i
3213 return $?
3215 vput vexpr i + $i "$1"
3216 return $i
3218 define _read {
3219 wysh set line; read line;wysh set es=$? en=$^ERRNAME ;\
3220 echo read:$es/$en: $line
3221 if [ "${es}" -ne -1 ]
3222 xcall _read
3224 readctl remove $cwd/.treadctl; echo readctl remove:$?/$^ERRNAME
3226 define t_ocs {
3227 read ver
3228 echo t_ocs
3229 echo "~^header list"; read hl; echo $hl;\
3230 vput vexpr es substr "$hl" 0 1
3231 if [ "$es" != 2 ]
3232 xcall bail "header list"
3233 endif
3235 call _work 1; echo $?
3236 echo "~^header insert cc splicy diet <splice@exam.ple> spliced";\
3237 read es; echo $es; vput vexpr es substr "$es" 0 1
3238 if [ "$es" != 2 ]
3239 xcall bail "be diet"
3240 endif
3241 echo "~^header insert cc <splice2@exam.ple>";\
3242 read es; echo $es; vput vexpr es substr "$es" 0 1
3243 if [ "$es" != 2 ]
3244 xcall bail "be diet2"
3245 endif
3247 call _work 2; echo $?
3248 echo "~^header insert bcc juicy juice <juice@exam.ple> spliced";\
3249 read es; echo $es;vput vexpr es substr "$es" 0 1
3250 if [ "$es" != 2 ]
3251 xcall bail "be juicy"
3252 endif
3253 echo "~^header insert bcc juice2@exam.ple";\
3254 read es; echo $es;vput vexpr es substr "$es" 0 1
3255 if [ "$es" != 2 ]
3256 xcall bail "be juicy2"
3257 endif
3258 echo "~^header insert bcc juice3 <juice3@exam.ple>";\
3259 read es; echo $es;vput vexpr es substr "$es" 0 1
3260 if [ "$es" != 2 ]
3261 xcall bail "be juicy3"
3262 endif
3263 echo "~^header insert bcc juice4@exam.ple";\
3264 read es; echo $es;vput vexpr es substr "$es" 0 1
3265 if [ "$es" != 2 ]
3266 xcall bail "be juicy4"
3267 endif
3269 echo "~^header remove-at bcc 3";\
3270 read es; echo $es;vput vexpr es substr "$es" 0 1
3271 if [ "$es" != 2 ]
3272 xcall bail "remove juicy5"
3273 endif
3274 echo "~^header remove-at bcc 2";\
3275 read es; echo $es;vput vexpr es substr "$es" 0 1
3276 if [ "$es" != 2 ]
3277 xcall bail "remove juicy6"
3278 endif
3279 echo "~^header remove-at bcc 3";\
3280 read es; echo $es;vput vexpr es substr "$es" 0 3
3281 if [ "$es" != 501 ]
3282 xcall bail "failed to remove-at"
3283 endif
3284 # Add duplicates which ought to be removed!
3285 echo "~^header insert bcc juice4@exam.ple";\
3286 read es; echo $es;vput vexpr es substr "$es" 0 1
3287 if [ "$es" != 2 ]
3288 xcall bail "be juicy4-1"
3289 endif
3290 echo "~^header insert bcc juice4@exam.ple";\
3291 read es; echo $es;vput vexpr es substr "$es" 0 1
3292 if [ "$es" != 2 ]
3293 xcall bail "be juicy4-2"
3294 endif
3295 echo "~^header insert bcc juice4@exam.ple";\
3296 read es; echo $es;vput vexpr es substr "$es" 0 1
3297 if [ "$es" != 2 ]
3298 xcall bail "be juicy4-3"
3299 endif
3300 echo "~:set t_ocs"
3303 call _work 3; echo $?
3304 echo "~r - '__EOT'"
3305 vput ! i echo just knock if you can hear me;\
3306 i=0;\
3307 while [ $i -lt 24 ]; do printf "%s " $i; i=`expr $i + 1`; done;\
3308 echo relax
3309 echon shell-cmd says $?/$^ERRNAME: $i
3310 echo "~x will not become interpreted, we are reading until __EOT"
3311 echo "__EOT"
3312 read r_status; echo "~~r status output: $r_status"
3313 echo "~:echo $? $! $^ERRNAME"
3314 read r_status
3315 echo "~~r status from parent: $r_status"
3318 call _work 4; echo $?
3319 vput cwd cwd;echo cwd:$?
3320 readctl create $cwd/.treadctl ;echo readctl:$?/$^ERRNAME;\
3321 call _read
3324 call _work 5; echo $?
3325 echo "~^header show MAILX-Command"; read es;\
3326 call xerr $es "t_header 1000"; call read_mline_res
3327 echo "~^header show MAILX-raw-TO"; read es;\
3328 call xerr $es "t_header 1001"; xcall read_mline_res
3330 echoerr IT IS WRONG IF YOU SEE THIS
3332 define t_oce {
3333 echo on-compose-enter, mailx-command<$mailx-command>
3334 set t_oce autobcc=oce@exam.ple
3335 alternates alter1@exam.ple alter2@exam.ple
3336 alternates
3337 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3338 echo mailx-subject<$mailx-subject>
3339 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3340 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3341 mailx-raw-bcc<$mailx-raw-bcc>
3342 echo mailx-orig-from<$mailx-orig-from> \
3343 mailx-orig-to<$mailx-orig-to> \
3344 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3346 define t_ocl {
3347 echo on-compose-leave, mailx-command<$mailx-command>
3348 set t_ocl autocc=ocl@exam.ple
3349 unalternates *
3350 alternates alter3@exam.ple alter4@exam.ple
3351 alternates
3352 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3353 echo mailx-subject<$mailx-subject>
3354 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3355 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3356 mailx-raw-bcc<$mailx-raw-bcc>
3357 echo mailx-orig-from<$mailx-orig-from> \
3358 mailx-orig-to<$mailx-orig-to> \
3359 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3361 define t_occ {
3362 echo on-compose-cleanup, mailx-command<$mailx-command>
3363 set t_occ autocc=occ@exam.ple
3364 unalternates *
3365 alternates
3366 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3367 echo mailx-subject<$mailx-subject>
3368 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3369 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3370 mailx-raw-bcc<$mailx-raw-bcc>
3371 echo mailx-orig-from<$mailx-orig-from> \
3372 mailx-orig-to<$mailx-orig-to> \
3373 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3375 wysh set on-compose-splice=t_ocs \
3376 on-compose-splice-shell="read ver;printf \"t_ocs-shell\\n\
3377 ~t shell@exam.ple\\n~:set t_ocs_sh\\n\"" \
3378 on-compose-enter=t_oce on-compose-leave=t_ocl \
3379 on-compose-cleanup=t_occ
3380 ' > ./.tnotes 2>&1
3381 ex0_test behave:compose_hooks-3
3382 ${cat} ./.tnotes >> "${MBOX}"
3384 check behave:compose_hooks-3 - "${MBOX}" '679526364 2431'
3386 # Reply, forward, resend, Resend
3388 ${rm} -f "${MBOX}"
3389 printf 'set from=f1@z\nm t1@z\nb1\n!.\nset from=f2@z\nm t2@z\nb2\n!.\n' |
3390 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! \
3391 -Smta=./.tsendmail.sh
3393 printf '
3394 echo start: $? $! $^ERRNAME
3395 File %s
3396 echo File: $? $! $^ERRNAME;echo;echo
3397 reply 1
3398 this is content of reply 1
3400 echo reply 1: $? $! $^ERRNAME;echo;echo
3401 Reply 1 2
3402 this is content of Reply 1 2
3404 echo Reply 1 2: $? $! $^ERRNAME;echo;echo
3405 forward 1 fwdex@am.ple
3406 this is content of forward 1
3408 echo forward 1: $? $! $^ERRNAME;echo;echo
3409 resend 1 2 resendex@am.ple
3410 echo resend 1 2: $? $! $^ERRNAME;echo;echo
3411 Resend 1 2 Resendex@am.ple
3412 echo Resend 1 2: $? $! $^ERRNAME;echo;echo
3413 ' "${MBOX}" |
3414 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! \
3415 -Smta=./.tsendmail.sh \
3417 define bail {
3418 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
3420 define xerr {
3421 vput vexpr es substr "$1" 0 1
3422 if [ "$es" != 2 ]
3423 xcall bail "$2"
3426 define read_mline_res {
3427 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
3428 echo mline_res:$len/$es/$^ERRNAME: $hl
3429 if [ $es -ne $^ERR-NONE ]
3430 xcall bail read_mline_res
3431 elif [ $len -ne 0 ]
3432 \xcall read_mline_res
3435 define work_hl {
3436 echo "~^header show $1"; read es;\
3437 call xerr $es "work_hl $1"; echo $1; call read_mline_res
3438 if [ $# -gt 1 ]
3439 shift
3440 xcall work_hl "$@"
3443 define t_ocs {
3444 read ver
3445 echo t_ocs version $ver
3446 echo "~^header list"; read hl; echo $hl;\
3447 echoerr the header list is $hl;\
3448 call xerr "$hl" "header list"
3449 eval vpospar set $hl
3450 shift
3451 xcall work_hl "$@"
3452 echoerr IT IS WRONG IF YOU SEE THIS
3454 define t_oce {
3455 echo on-XY-enter, mailx-command<$mailx-command>
3456 set t_oce autobcc=oce@exam.ple
3457 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3458 echo mailx-subject<$mailx-subject>
3459 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3460 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3461 mailx-raw-bcc<$mailx-raw-bcc>
3462 echo mailx-orig-from<$mailx-orig-from> \
3463 mailx-orig-to<$mailx-orig-to> \
3464 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3466 define t_ocl {
3467 echo on-XY-leave, mailx-command<$mailx-command>
3468 set t_ocl autocc=ocl@exam.ple
3469 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3470 echo mailx-subject<$mailx-subject>
3471 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3472 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3473 mailx-raw-bcc<$mailx-raw-bcc>
3474 echo mailx-orig-from<$mailx-orig-from> \
3475 mailx-orig-to<$mailx-orig-to> \
3476 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3478 define t_occ {
3479 echo on-XY-cleanup, mailx-command<$mailx-command>
3480 set t_occ autocc=occ@exam.ple
3481 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3482 echo mailx-subject<$mailx-subject>
3483 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3484 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3485 mailx-raw-bcc<$mailx-raw-bcc>
3486 echo mailx-orig-from<$mailx-orig-from> \
3487 mailx-orig-to<$mailx-orig-to> \
3488 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3490 wysh set on-compose-splice=t_ocs \
3491 on-compose-enter=t_oce on-compose-leave=t_ocl \
3492 on-compose-cleanup=t_occ \
3493 on-resend-enter=t_oce on-resend-cleanup=t_occ
3494 ' > ./.tnotes 2>&1
3495 ex0_test behave:compose_hooks-4
3496 ${cat} ./.tnotes >> "${MBOX}"
3498 check behave:compose_hooks-4 - "${MBOX}" '3038884027 7516'
3500 t_epilog
3503 t_behave_message_injections() {
3504 t_prolog
3505 TRAP_EXIT_ADDONS="./.t*"
3507 ${cat} <<-_EOT > ./.tsendmail.sh
3508 #!${MYSHELL} -
3509 (echo 'From Echinacea Tue Jun 20 15:54:02 2017' && ${cat} && echo
3510 ) > "${MBOX}"
3511 _EOT
3512 chmod 0755 ./.tsendmail.sh
3514 echo mysig > ./.tmysig
3516 echo some-body | ${MAILX} ${ARGS} -Smta=./.tsendmail.sh \
3517 -Smessage-inject-head=head-inject \
3518 -Smessage-inject-tail=tail-inject \
3519 -Ssignature=./.tmysig \
3520 ex@am.ple > ./.tall 2>&1
3521 check behave:message_injections-1 0 "${MBOX}" '2434746382 134'
3522 check behave:message_injections-2 - .tall '4294967295 0' # empty file
3524 ${cat} <<-_EOT > ./.template
3525 From: me
3526 To: ex1@am.ple
3527 Cc: ex2@am.ple
3528 Subject: This subject is
3530 Body, body, body me.
3531 _EOT
3532 < ./.template ${MAILX} ${ARGS} -t -Smta=./.tsendmail.sh \
3533 -Smessage-inject-head=head-inject \
3534 -Smessage-inject-tail=tail-inject \
3535 -Ssignature=./.tmysig \
3536 > ./.tall 2>&1
3537 check behave:message_injections-3 0 "${MBOX}" '3114203412 198'
3538 check behave:message_injections-4 - .tall '4294967295 0' # empty file
3540 t_epilog
3543 t_behave_mime_types_load_control() {
3544 t_prolog
3545 TRAP_EXIT_ADDONS="./.t*"
3547 ${cat} <<-_EOT > ./.tmts1
3548 @ application/mathml+xml mathml
3549 _EOT
3550 ${cat} <<-_EOT > ./.tmts2
3551 @ x-conference/x-cooltalk ice
3552 @ aga-aga aga
3553 @ application/aga-aga aga
3554 _EOT
3556 ${cat} <<-_EOT > ./.tmts1.mathml
3557 <head>nonsense ML</head>
3558 _EOT
3559 ${cat} <<-_EOT > ./.tmts2.ice
3560 Icy, icy road.
3561 _EOT
3562 printf 'of which the c\x01rack is coming soon' > ./.tmtsx.doom
3563 printf 'of which the c\x01rack is coming soon' > ./.tmtsx.aga
3565 printf '
3566 m %s
3567 Schub-di-du
3568 ~@ ./.tmts1.mathml
3569 ~@ ./.tmts2.ice
3570 ~@ ./.tmtsx.doom
3571 ~@ ./.tmtsx.aga
3573 File %s
3574 from*
3575 type
3577 ' "${MBOX}" "${MBOX}" |
3578 ${MAILX} ${ARGS} \
3579 -Smimetypes-load-control=f=./.tmts1,f=./.tmts2 \
3580 > ./.tout 2>&1
3581 ex0_test behave:mime_types_load_control
3583 ${cat} "${MBOX}" >> ./.tout
3584 check behave:mime_types_load_control-1 - ./.tout '1441260727 2449'
3586 echo type | ${MAILX} ${ARGS} -R \
3587 -Smimetypes-load-control=f=./.tmts1,f=./.tmts3 \
3588 -f "${MBOX}" >> ./.tout 2>&1
3589 check behave:mime_types_load_control-2 0 ./.tout '1441391438 3646'
3591 t_epilog
3594 t_behave_smime() {
3595 have_feat smime || {
3596 echo 'behave:s/mime: unsupported, skipped'
3597 return
3600 t_prolog
3601 TRAP_EXIT_ADDONS="./.t.conf ./.tkey.pem ./.tcert.pem ./.tpair.pem"
3602 TRAP_EXIT_ADDONS="${TRAP_EXIT_ADDONS} ./.VERIFY ./.DECRYPT ./.ENCRYPT"
3603 TRAP_EXIT_ADDONS="${TRAP_EXIT_ADDONS} ./.tsendmail.sh"
3605 printf 'behave:s/mime: .. generating test key and certificate ..\n'
3606 ${cat} <<-_EOT > ./.t.conf
3607 [ req ]
3608 default_bits = 1024
3609 default_keyfile = keyfile.pem
3610 distinguished_name = req_distinguished_name
3611 attributes = req_attributes
3612 prompt = no
3613 output_password =
3615 [ req_distinguished_name ]
3616 C = GB
3617 ST = Over the
3618 L = rainbow
3619 O = S-nail
3620 OU = S-nail.smime
3621 CN = S-nail.test
3622 emailAddress = test@localhost
3624 [ req_attributes ]
3625 challengePassword =
3626 _EOT
3627 openssl req -x509 -nodes -days 3650 -config ./.t.conf \
3628 -newkey rsa:1024 -keyout ./.tkey.pem -out ./.tcert.pem >/dev/null 2>&1
3629 ${cat} ./.tkey.pem ./.tcert.pem > ./.tpair.pem
3631 # Sign/verify
3632 printf 'behave:s/mime:sign/verify: '
3633 echo bla | ${MAILX} ${ARGS} \
3634 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
3635 -Ssmime-sign -Sfrom=test@localhost \
3636 -s 'S/MIME test' ./.VERIFY
3637 if [ $? -eq 0 ]; then
3638 printf 'ok\n'
3639 else
3640 printf 'failed\n'
3641 ESTAT=1
3642 t_epilog
3643 return
3646 ${awk} '
3647 BEGIN{ skip=0 }
3648 /^Content-Description: /{ skip = 2; print; next }
3649 /^$/{ if(skip) --skip }
3650 { if(!skip) print }
3652 < ./.VERIFY > "${MBOX}"
3653 check behave:s/mime:sign/verify:checksum - "${MBOX}" '2900817158 648'
3655 printf 'behave:s/mime:sign/verify:verify '
3656 printf 'verify\nx\n' |
3657 ${MAILX} ${ARGS} \
3658 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
3659 -Ssmime-sign -Sfrom=test@localhost \
3660 -Serrexit -R \
3661 -f ./.VERIFY >/dev/null 2>&1
3662 if [ $? -eq 0 ]; then
3663 printf 'ok\n'
3664 else
3665 printf 'failed\n'
3666 ESTAT=1
3667 t_epilog
3668 return
3671 printf 'behave:s/mime:sign/verify:disproof-1 '
3672 if openssl smime -verify -CAfile ./.tcert.pem \
3673 -in ./.VERIFY >/dev/null 2>&1; then
3674 printf 'ok\n'
3675 else
3676 printf 'failed\n'
3677 ESTAT=1
3678 t_epilog
3679 return
3682 # (signing +) encryption / decryption
3683 ${cat} <<-_EOT > ./.tsendmail.sh
3684 #!${MYSHELL} -
3685 (echo 'From Euphrasia Thu Apr 27 17:56:23 2017' && ${cat}) > ./.ENCRYPT
3686 _EOT
3687 chmod 0755 ./.tsendmail.sh
3689 printf 'behave:s/mime:encrypt+sign: '
3690 echo bla |
3691 ${MAILX} ${ARGS} \
3692 -Ssmime-force-encryption \
3693 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
3694 -Smta=./.tsendmail.sh \
3695 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
3696 -Ssmime-sign -Sfrom=test@localhost \
3697 -s 'S/MIME test' recei@ver.com
3698 if [ $? -eq 0 ]; then
3699 printf 'ok\n'
3700 else
3701 ESTAT=1
3702 printf 'error: encrypt+sign failed\n'
3705 ${sed} -e '/^$/,$d' < ./.ENCRYPT > "${MBOX}"
3706 check behave:s/mime:encrypt+sign:checksum - "${MBOX}" '1937410597 327'
3708 printf 'behave:s/mime:decrypt+verify: '
3709 printf 'decrypt ./.DECRYPT\nfi ./.DECRYPT\nverify\nx\n' |
3710 ${MAILX} ${ARGS} \
3711 -Ssmime-force-encryption \
3712 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
3713 -Smta=./.tsendmail.sh \
3714 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
3715 -Ssmime-sign -Sfrom=test@localhost \
3716 -Serrexit -R \
3717 -f ./.ENCRYPT >/dev/null 2>&1
3718 if [ $? -eq 0 ]; then
3719 printf 'ok\n'
3720 else
3721 ESTAT=1
3722 printf 'failed\n'
3725 ${awk} '
3726 BEGIN{ skip=0 }
3727 /^Content-Description: /{ skip = 2; print; next }
3728 /^$/{ if(skip) --skip }
3729 { if(!skip) print }
3731 < ./.DECRYPT > "${MBOX}"
3732 check behave:s/mime:decrypt+verify:checksum - "${MBOX}" '1720739247 931'
3734 printf 'behave:s/mime:decrypt+verify:disproof-1: '
3735 if (openssl smime -decrypt -inkey ./.tkey.pem -in ./.ENCRYPT |
3736 openssl smime -verify -CAfile ./.tcert.pem) >/dev/null 2>&1; then
3737 printf 'ok\n'
3738 else
3739 printf 'failed\n'
3740 ESTAT=1
3743 printf "behave:s/mime:encrypt: "
3744 echo bla | ${MAILX} ${ARGS} \
3745 -Ssmime-force-encryption \
3746 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
3747 -Smta=./.tsendmail.sh \
3748 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
3749 -Sfrom=test@localhost \
3750 -s 'S/MIME test' recei@ver.com
3751 if [ $? -eq 0 ]; then
3752 printf 'ok\n'
3753 else
3754 ESTAT=1
3755 printf 'failed\n'
3758 # Same as behave:s/mime:encrypt+sign:checksum above
3759 ${sed} -e '/^$/,$d' < ./.ENCRYPT > "${MBOX}"
3760 check behave:s/mime:encrypt:checksum - "${MBOX}" '1937410597 327'
3762 ${rm} -f ./.DECRYPT
3763 printf 'decrypt ./.DECRYPT\nx\n' | ${MAILX} ${ARGS} \
3764 -Ssmime-force-encryption \
3765 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
3766 -Smta=./.tsendmail.sh \
3767 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
3768 -Sfrom=test@localhost \
3769 -Serrexit -R \
3770 -f ./.ENCRYPT >/dev/null 2>&1
3771 check behave:s/mime:decrypt 0 "./.DECRYPT" '2624716890 422'
3773 printf 'behave:s/mime:decrypt:disproof-1: '
3774 if openssl smime -decrypt -inkey ./.tkey.pem \
3775 -in ./.ENCRYPT >/dev/null 2>&1; then
3776 printf 'ok\n'
3777 else
3778 printf 'failed\n'
3779 ESTAT=1
3782 t_epilog
3785 t_behave_maildir() {
3786 t_prolog
3787 TRAP_EXIT_ADDONS="./.t*"
3791 while [ ${i} -lt 112 ]; do
3792 printf 'm file://%s\n~s Subject %s\nHello %s!\n~.\n' \
3793 "${MBOX}" "${i}" "${i}"
3794 i=`add ${i} 1`
3795 done
3796 ) | ${MAILX} ${ARGS}
3797 check behave:maildir-1 0 "${MBOX}" '1140119864 13780'
3799 printf 'File "%s"
3800 copy * "%s"
3801 File "%s"
3802 from*
3803 ' "${MBOX}" .tmdir1 .tmdir1 |
3804 ${MAILX} ${ARGS} -Snewfolders=maildir > .tlst
3805 check behave:maildir-2 0 .tlst '1797938753 9103'
3807 printf 'File "%s"
3808 copy * "maildir://%s"
3809 File "maildir://%s"
3810 from*
3811 ' "${MBOX}" .tmdir2 .tmdir2 |
3812 ${MAILX} ${ARGS} > .tlst
3813 check behave:maildir-3 0 .tlst '1155631089 9113'
3815 printf 'File "maildir://%s"
3816 copy * "file://%s"
3817 File "file://%s"
3818 from*
3819 ' .tmdir2 .tmbox1 .tmbox1 |
3820 ${MAILX} ${ARGS} > .tlst
3821 check behave:maildir-4 0 .tmbox1 '2646131190 13220'
3822 check behave:maildir-5 - .tlst '3701297796 9110'
3824 # only the odd (even)
3826 printf 'File "maildir://%s"
3827 copy ' .tmdir2
3829 while [ ${i} -lt 112 ]; do
3830 j=`modulo ${i} 2`
3831 [ ${j} -eq 1 ] && printf '%s ' "${i}"
3832 i=`add ${i} 1`
3833 done
3834 printf ' file://%s
3835 File "file://%s"
3836 from*
3837 ' .tmbox2 .tmbox2
3838 ) | ${MAILX} ${ARGS} > .tlst
3839 check behave:maildir-6 0 .tmbox2 '142890131 6610'
3840 check behave:maildir-7 - .tlst '960096773 4573'
3841 # ...
3843 printf 'file "maildir://%s"
3844 move ' .tmdir2
3846 while [ ${i} -lt 112 ]; do
3847 j=`modulo ${i} 2`
3848 [ ${j} -eq 0 ] && [ ${i} -ne 0 ] && printf '%s ' "${i}"
3849 i=`add ${i} 1`
3850 done
3851 printf ' file://%s
3852 File "file://%s"
3853 from*
3854 File "maildir://%s"
3855 from*
3856 ' .tmbox2 .tmbox2 .tmdir2
3857 ) | ${MAILX} ${ARGS} > .tlst
3858 check behave:maildir-8 0 .tmbox2 '3806905791 13100'
3859 ${sed} 2d < .tlst > .tlstx
3860 check behave:maildir-9 - .tlstx '4216815295 13645'
3862 t_epilog
3865 t_behave_mass_recipients() {
3866 t_prolog
3867 TRAP_EXIT_ADDONS="./.t*"
3869 ${cat} <<-_EOT > ./.tsendmail.sh
3870 #!${MYSHELL} -
3871 (echo 'From Eucalyptus Sat Jul 08 21:14:57 2017' && ${cat} && echo
3872 ) >> "${MBOX}"
3873 _EOT
3874 chmod 0755 ./.tsendmail.sh
3876 ${cat} <<'__EOT__' > ./.trc
3877 define bail {
3878 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
3880 define ins_addr {
3881 wysh set nr=$1 hn=$2
3882 echo "~$hn $hn$nr@$hn"; echo '~:echo $?'; read es
3883 if [ "$es" -ne 0 ]
3884 xcall bail "ins_addr $hn 1-$nr"
3886 vput vexpr nr + $nr 1
3887 if [ "$nr" -le "$maximum" ]
3888 xcall ins_addr $nr $hn
3891 define bld_alter {
3892 wysh set nr=$1 hn=$2
3893 alternates $hn$nr@$hn
3894 vput vexpr nr + $nr 2
3895 if [ "$nr" -le "$maximum" ]
3896 xcall bld_alter $nr $hn
3899 define t_ocs {
3900 read ver
3901 call ins_addr 1 t
3902 call ins_addr 1 c
3903 call ins_addr 1 b
3905 define t_ocl {
3906 if [ "$t_remove" != '' ]
3907 call bld_alter 1 t
3908 call bld_alter 2 c
3911 set on-compose-splice=t_ocs on-compose-leave=t_ocl
3912 __EOT__
3914 ${rm} -f "${MBOX}"
3915 printf 'm this-goes@nowhere\nbody\n!.\n' |
3916 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
3917 -X'source ./.trc' -Smta=./.tsendmail.sh -Smaximum=2001 \
3918 >./.tall 2>&1
3919 ${cat} ./.tall >> "${MBOX}"
3920 check behave:mass_recipients-1 0 "${MBOX}" '2912243346 51526'
3922 ${rm} -f "${MBOX}"
3923 printf 'm this-goes@nowhere\nbody\n!.\n' |
3924 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
3925 -St_remove=1 -X'source ./.trc' -Smta=./.tsendmail.sh -Smaximum=2001 \
3926 >./.tall 2>&1
3927 ${cat} ./.tall >> "${MBOX}"
3928 check behave:mass_recipients-2 0 "${MBOX}" '4097804632 34394'
3930 t_epilog
3933 t_behave_lreply_futh_rth_etc() {
3934 t_prolog
3935 TRAP_EXIT_ADDONS="./.t*"
3937 ${cat} <<-_EOT > ./.tsendmail.sh
3938 #!${MYSHELL} -
3939 (echo 'From HumulusLupulus Thu Jul 27 14:41:20 2017' && ${cat} && echo
3940 ) >> "${MBOX}"
3941 _EOT
3942 chmod 0755 ./.tsendmail.sh
3944 ${cat} <<-_EOT > ./.tmbox
3945 From neverneverland Sun Jul 23 13:46:25 2017
3946 Subject: Bugstop: five miles out 1
3947 Reply-To: mister originator2 <mr2@originator>, bugstop@five.miles.out
3948 From: mister originator <mr@originator>
3949 To: bugstop-commit@five.miles.out, laber@backe.eu
3950 Cc: is@a.list
3951 Mail-Followup-To: bugstop@five.miles.out, laber@backe.eu, is@a.list
3952 In-reply-to: <20170719111113.bkcMz%laber@backe.eu>
3953 Date: Wed, 19 Jul 2017 09:22:57 -0400
3954 Message-Id: <20170719132257.766AF781267@originator>
3955 Status: RO
3957 > |Sorry, I think I misunderstand something. I would think that
3959 That's appalling.
3961 From neverneverland Fri Jul 7 22:39:11 2017
3962 Subject: Bugstop: five miles out 2
3963 Reply-To: mister originator2<mr2@originator>,bugstop@five.miles.out,is@a.list
3964 Content-Transfer-Encoding: 7bit
3965 From: mister originator <mr@originator>
3966 To: bugstop-commit@five.miles.out
3967 Cc: is@a.list
3968 Message-ID: <149945963975.28888.6950788126957753723.reportbug@five.miles.out>
3969 Date: Fri, 07 Jul 2017 16:33:59 -0400
3970 Status: R
3972 capable of changing back.
3974 From neverneverland Fri Jul 7 22:42:00 2017
3975 Subject: Bugstop: five miles out 3
3976 Reply-To: mister originator2 <mr2@originator>, bugstop@five.miles.out
3977 Content-Transfer-Encoding: 7bit
3978 From: mister originator <mr@originator>
3979 To: bugstop-commit@five.miles.out
3980 Cc: is@a.list
3981 Message-ID: <149945963975.28888.6950788126957753746.reportbug@five.miles.out>
3982 Date: Fri, 07 Jul 2017 16:33:59 -0400
3983 List-Post: <mailto:bugstop@five.miles.out>
3984 Status: R
3986 are you ready, boots?
3988 From neverneverland Sat Aug 19 23:15:00 2017
3989 Subject: Bugstop: five miles out 4
3990 Reply-To: mister originator2 <mr2@originator>, bugstop@five.miles.out
3991 Content-Transfer-Encoding: 7bit
3992 From: mister originator <mr@originator>
3993 To: bugstop@five.miles.out
3994 Cc: is@a.list
3995 Message-ID: <149945963975.28888.6950788126qtewrqwer.reportbug@five.miles.out>
3996 Date: Fri, 07 Jul 2017 16:33:59 -0400
3997 List-Post: <mailto:bugstop@five.miles.out>
3998 Status: R
4000 are you ready, boots?
4001 _EOT
4005 ${cat} <<-'_EOT' | ${MAILX} ${ARGS} -Sescape=! -Smta=./.tsendmail.sh \
4006 -Rf ./.tmbox >> "${MBOX}" 2>&1
4007 define r {
4008 wysh set m="This is text of \"reply ${1}."
4009 reply 1 2 3
4010 !I m
4013 !I m
4016 !I m
4019 echo -----After reply $1.1 - $1.3: $?/$^ERRNAME
4021 define R {
4022 wysh set m="This is text of \"Reply ${1}."
4023 eval Reply $2
4024 !I m
4025 !I 2
4028 echo -----After Reply $1.$2: $?/$^ERRNAME
4030 define _Lh {
4031 read protover
4032 echo '~I m'
4033 echo '~I n'
4034 echo '".'
4036 define _Ls {
4037 wysh set m="This is text of \"Lreply ${1}." on-compose-splice=_Lh n=$2
4038 eval Lreply $2
4040 define L {
4041 # We need two indirections for this test: one for the case that Lreply
4042 # fails because of missing recipients: we need to read EOF next, thus
4043 # place this in _Ls last; and second for the succeeding cases EOF is
4044 # not what these should read, so go over the backside and splice it in!
4045 call _Ls "$@"
4046 echo -----After Lreply $1.$2: $?/$^ERRNAME
4048 define x {
4049 localopts call-fixate yes
4050 call r $1
4051 call R $1 1; call R $1 2; call R $1 3; call R $1 4
4052 call L $1 1; call L $1 2; call L $1 3
4054 define tweak {
4055 echo;echo '===== CHANGING === '"$*"' =====';echo
4056 eval "$@"
4059 set from=laber@backe.eu
4060 mlist is@a.list
4061 call x 1
4062 call tweak set reply-to-honour
4063 call x 2
4064 call tweak set followup-to
4065 call x 3
4066 call tweak set followup-to-honour
4067 call x 4
4068 call tweak mlist bugstop@five.miles.out
4069 call x 5
4070 call tweak mlsubscribe bugstop@five.miles.out
4071 call x 6
4072 call tweak set recipients-in-cc
4073 call x 7
4074 _EOT
4076 check behave:lreply_futh_rth_etc 0 "${MBOX}" '940818845 29373'
4078 t_epilog
4081 t_behave_iconv_mbyte_base64() {
4082 t_prolog
4083 TRAP_EXIT_ADDONS="./.t*"
4085 if [ -n "${UTF8_LOCALE}" ] && have_feat iconv &&
4086 command -v iconv >/dev/null 2>&1 &&
4087 ( iconv -l | ${grep} -i -e iso-2022-jp -e euc-jp) >/dev/null 2>&1; then
4089 else
4090 echo 'behave:iconv_mbyte_base64: unsupported, skipped'
4091 return
4094 ${cat} <<-_EOT > ./.tsendmail.sh
4095 #!${MYSHELL} -
4096 (echo 'From DroseriaRotundifolia Thu Aug 03 17:26:25 2017' && ${cat} &&
4097 echo) >> "${MBOX}"
4098 _EOT
4099 chmod 0755 ./.tsendmail.sh
4101 if ( iconv -l | ${grep} -i iso-2022-jp ) >/dev/null 2>&1; then
4102 printf '
4103 set ttycharset=utf-8 sendcharsets=iso-2022-jp
4104 m t1@exam.ple
4105 !s Japanese from UTF-8 to ISO-2022-JP
4106 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
4108 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
4111 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
4113 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
4116 set ttycharset=iso-2022-jp charset-7bit=iso-2022-jp sendcharsets=utf-8
4117 m t2@exam.ple
4118 !s Japanese from ISO-2022-JP to UTF-8, eh, no, also ISO-2022-JP
4119 \e$B%%7%%8%%e%%&%%+%%i2J!J%%7%%8%%e%%&%%+%%i$+!"3XL>\e(B Paridae\e$B!K$O!"D;N`%%9%%:%%aL\\$N2J$G$"$k!#%%7%%8%%e%%&%%+%%i!J;M==?}!K$HAm>N$5$l$k$,!"695A$K$O$3$N\e(B1\e$B<o$r%%7%%8%%e%%&%%+%%i$H8F$V!#\e(B
4121 \e$B%%+%%s%%`%%j%%,%%i!J3XL>\e(BParus cristatus\e$B!K$O!"%%9%%:%%aL\\%%7%%8%%e%%&%%+%%i2J$KJ,N`$5$l$kD;N`$N0l<o!#\e(B
4124 \e$B%%+%%s%%`%%j%%,%%i!J3XL>\e(BParus cristatus\e$B!K$O!"%%9%%:%%aL\\%%7%%8%%e%%&%%+%%i2J$KJ,N`$5$l$kD;N`$N0l<o!#\e(B
4126 \e$B%%7%%8%%e%%&%%+%%i2J!J%%7%%8%%e%%&%%+%%i$+!"3XL>\e(B Paridae\e$B!K$O!"D;N`%%9%%:%%aL\\$N2J$G$"$k!#%%7%%8%%e%%&%%+%%i!J;M==?}!K$HAm>N$5$l$k$,!"695A$K$O$3$N\e(B1\e$B<o$r%%7%%8%%e%%&%%+%%i$H8F$V!#\e(B
4128 ' | LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} -Smta=./.tsendmail.sh \
4129 -Sescape=! -Smime-encoding=base64 2>./.terr
4130 check behave:iconv_mbyte_base64-1 0 "${MBOX}" '3428985079 1976'
4131 check behave:iconv_mbyte_base64-2 - ./.terr '4294967295 0'
4133 printf 'eval f 1; write ./.twrite\n' |
4134 ${MAILX} ${ARGS} ${ADDARG_UNI} -Rf "${MBOX}" >./.tlog 2>&1
4135 check behave:iconv_mbyte_base64-3 0 ./.twrite '1259742080 686'
4136 check behave:iconv_mbyte_base64-4 - ./.tlog '3956097665 119'
4137 else
4138 echo 'behave:iconv_mbyte_base64: ISO-2022-JP unsupported, skipping 1-4'
4141 if ( iconv -l | ${grep} -i euc-jp ) >/dev/null 2>&1; then
4142 rm -f "${MBOX}" ./.twrite
4143 printf '
4144 set ttycharset=utf-8 sendcharsets=euc-jp
4145 m t1@exam.ple
4146 !s Japanese from UTF-8 to EUC-JP
4147 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
4149 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
4152 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
4154 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
4157 set ttycharset=EUC-JP sendcharsets=utf-8
4158 m t2@exam.ple
4159 !s Japanese from EUC-JP to UTF-8
4160 ¥·¥¸¥å¥¦¥«¥é²Ê¡Ê¥·¥¸¥å¥¦¥«¥é¤«¡¢³Ø̾ Paridae¡Ë¤Ï¡¢Ä»Îॹ¥º¥áÌܤβʤǤ¢¤ë¡£¥·¥¸¥å¥¦¥«¥é¡Ê»Í½½¿ý¡Ë¤ÈÁí¾Î¤µ¤ì¤ë¤¬¡¢¶¹µÁ¤Ë¤Ï¤³¤Î1¼ï¤ò¥·¥¸¥å¥¦¥«¥é¤È¸Æ¤Ö¡£
4162 ¥«¥ó¥à¥ê¥¬¥é¡Ê³Ø̾Parus cristatus¡Ë¤Ï¡¢¥¹¥º¥áÌÜ¥·¥¸¥å¥¦¥«¥é²Ê¤ËʬÎव¤ì¤ëÄ»Îà¤Î°ì¼ï¡£
4165 ¥«¥ó¥à¥ê¥¬¥é¡Ê³Ø̾Parus cristatus¡Ë¤Ï¡¢¥¹¥º¥áÌÜ¥·¥¸¥å¥¦¥«¥é²Ê¤ËʬÎव¤ì¤ëÄ»Îà¤Î°ì¼ï¡£
4167 ¥·¥¸¥å¥¦¥«¥é²Ê¡Ê¥·¥¸¥å¥¦¥«¥é¤«¡¢³Ø̾ Paridae¡Ë¤Ï¡¢Ä»Îॹ¥º¥áÌܤβʤǤ¢¤ë¡£¥·¥¸¥å¥¦¥«¥é¡Ê»Í½½¿ý¡Ë¤ÈÁí¾Î¤µ¤ì¤ë¤¬¡¢¶¹µÁ¤Ë¤Ï¤³¤Î1¼ï¤ò¥·¥¸¥å¥¦¥«¥é¤È¸Æ¤Ö¡£
4169 ' | LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} -Smta=./.tsendmail.sh \
4170 -Sescape=! -Smime-encoding=base64 2>./.terr
4171 check behave:iconv_mbyte_base64-5 0 "${MBOX}" '1686827547 2051'
4172 check behave:iconv_mbyte_base64-6 - ./.terr '4294967295 0'
4174 printf 'eval f 1; write ./.twrite\n' |
4175 ${MAILX} ${ARGS} ${ADDARG_UNI} -Rf "${MBOX}" >./.tlog 2>&1
4176 check behave:iconv_mbyte_base64-7 0 ./.twrite '1259742080 686'
4177 check behave:iconv_mbyte_base64-8 - ./.tlog '500059195 119'
4178 else
4179 echo 'behave:iconv_mbyte_base64: EUC-JP unsupported, skipping 5-8'
4182 t_epilog
4185 # t_content()
4186 # Some basic tests regarding correct sending of mails, via STDIN / -t / -q,
4187 # including basic MIME Content-Transfer-Encoding correctness (quoted-printable)
4188 # Note we unfortunately need to place some statements without proper
4189 # indentation because of continuation problems
4190 t_content() {
4191 t_prolog
4193 # MIME encoding (QP) stress message body
4194 printf \
4195 'Ich bin eine DÖS-Datäi mit sehr langen Zeilen und auch '\
4196 'sonst bin ich ganz schön am Schleudern, da kannste denke '\
4197 "wasde willst, gelle, gelle, gelle, gelle, gelle.\r\n"\
4198 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst \r\n"\
4199 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1\r\n"\
4200 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12\r\n"\
4201 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123\r\n"\
4202 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1234\r\n"\
4203 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12345\r\n"\
4204 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123456\r\n"\
4205 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1234567\r\n"\
4206 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12345678\r\n"\
4207 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123456789\r\n"\
4208 "Unn ausserdem habe ich trailing SP/HT/SP/HT whitespace \r\n"\
4209 "Unn ausserdem habe ich trailing HT/SP/HT/SP whitespace \r\n"\
4210 "auf den zeilen vorher.\r\n"\
4211 "From am Zeilenbeginn und From der Mitte gibt es auch.\r\n"\
4212 ".\r\n"\
4213 "Die letzte Zeile war nur ein Punkt.\r\n"\
4214 "..\r\n"\
4215 "Das waren deren zwei.\r\n"\
4216 " \r\n"\
4217 "Die letzte Zeile war ein Leerschritt.\n"\
4218 "=VIER = EQUAL SIGNS=ON A LINE=\r\n"\
4219 "Prösterchen.\r\n"\
4220 ".\n"\
4221 "Die letzte Zeile war nur ein Punkt, mit Unix Zeilenende.\n"\
4222 "..\n"\
4223 "Das waren deren zwei. ditto.\n"\
4224 "Prösterchen.\n"\
4225 "Unn ausseerdem habe ich trailing SP/HT/SP/HT whitespace \n"\
4226 "Unn ausseerdem habe ich trailing HT/SP/HT/SP whitespace \n"\
4227 "auf den zeilen vorher.\n"\
4228 "ditto.\n"\
4229 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.\n"\
4230 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.1"\
4231 "\n"\
4232 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
4233 "\n"\
4234 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
4235 "3\n"\
4236 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
4237 "34\n"\
4238 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
4239 "345\n"\
4240 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
4241 "3456\n"\
4242 "QP am Zeilenende über soft-nl hinweg\n"\
4243 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
4244 "ö123\n"\
4245 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
4246 "1ö23\n"\
4247 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
4248 "12ö3\n"\
4249 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
4250 "123ö\n"\
4251 "=VIER = EQUAL SIGNS=ON A LINE=\n"\
4252 " \n"\
4253 "Die letzte Zeile war ein Leerschritt.\n"\
4254 ' '\
4255 > "${BODY}"
4257 # MIME encoding (QP) stress message subject
4258 SUB="Äbrä Kä?dä=brö Fü?di=bus? \
4259 adadaddsssssssddddddddddddddddddddd\
4260 ddddddddddddddddddddddddddddddddddd\
4261 ddddddddddddddddddddddddddddddddddd\
4262 dddddddddddddddddddd Hallelulja? Od\
4263 er?? eeeeeeeeeeeeeeeeeeeeeeeeeeeeee\
4264 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\
4265 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee f\
4266 fffffffffffffffffffffffffffffffffff\
4267 fffffffffffffffffffff ggggggggggggg\
4268 ggggggggggggggggggggggggggggggggggg\
4269 ggggggggggggggggggggggggggggggggggg\
4270 ggggggggggggggggggggggggggggggggggg\
4271 gggggggggggggggg"
4273 # Three tests for MIME encoding and (a bit) content classification.
4274 # At the same time testing -q FILE, < FILE and -t FILE
4276 ${rm} -f "${MBOX}"
4277 < "${BODY}" ${MAILX} ${ARGS} ${ADDARG_UNI} \
4278 -a "${BODY}" -s "${SUB}" "${MBOX}"
4279 check content:001 0 "${MBOX}" '1145066634 6654'
4281 ${rm} -f "${MBOX}"
4282 < /dev/null ${MAILX} ${ARGS} ${ADDARG_UNI} \
4283 -a "${BODY}" -s "${SUB}" -q "${BODY}" "${MBOX}"
4284 check content:002 0 "${MBOX}" '1145066634 6654'
4286 ${rm} -f "${MBOX}"
4287 ( echo "To: ${MBOX}" && echo "Subject: ${SUB}" && echo &&
4288 ${cat} "${BODY}"
4289 ) | ${MAILX} ${ARGS} ${ADDARG_UNI} -Snodot -a "${BODY}" -t
4290 check content:003 0 "${MBOX}" '1145066634 6654'
4292 # Test for [260e19d] (Juergen Daubert)
4293 ${rm} -f "${MBOX}"
4294 echo body | ${MAILX} ${ARGS} "${MBOX}"
4295 check content:004 0 "${MBOX}" '2917662811 98'
4297 # Sending of multiple mails in a single invocation
4298 ${rm} -f "${MBOX}"
4299 ( printf "m ${MBOX}\n~s subject1\nE-Mail Körper 1\n~.\n" &&
4300 printf "m ${MBOX}\n~s subject2\nEmail body 2\n~.\n" &&
4301 echo x
4302 ) | ${MAILX} ${ARGS} ${ADDARG_UNI}
4303 check content:005 0 "${MBOX}" '2098659767 358'
4305 ## $BODY CHANGED
4307 # "Test for" [d6f316a] (Gavin Troy)
4308 ${rm} -f "${MBOX}"
4309 printf "m ${MBOX}\n~s subject1\nEmail body\n~.\nfi ${MBOX}\np\nx\n" |
4310 ${MAILX} ${ARGS} ${ADDARG_UNI} -Spipe-text/plain="@* ${cat}" > "${BODY}"
4311 check content:006 0 "${MBOX}" '2099098650 122'
4312 check content:006-1 - "${BODY}" '794542938 174'
4314 # "Test for" [c299c45] (Peter Hofmann) TODO shouldn't end up QP-encoded?
4315 ${rm} -f "${MBOX}"
4316 ${awk} 'BEGIN{
4317 for(i = 0; i < 10000; ++i)
4318 printf "\xC3\xBC"
4319 #printf "\xF0\x90\x87\x90"
4320 }' | ${MAILX} ${ARGS} ${ADDARG_UNI} -s TestSubject "${MBOX}"
4321 check content:007 0 "${MBOX}" '534262374 61816'
4323 ## Test some more corner cases for header bodies (as good as we can today) ##
4326 ${rm} -f "${MBOX}"
4327 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
4328 -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̲' \
4329 "${MBOX}"
4330 check content:008 0 "${MBOX}" '3370931614 375'
4332 # Single word (overlong line split -- bad standard! Requires injection of
4333 # artificial data!! But can be prevented by using RFC 2047 encoding)
4334 ${rm} -f "${MBOX}"
4335 i=`${awk} 'BEGIN{for(i=0; i<92; ++i) printf "0123456789_"}'`
4336 echo | ${MAILX} ${ARGS} -s "${i}" "${MBOX}"
4337 check content:009 0 "${MBOX}" '489922370 1718'
4339 # Combination of encoded words, space and tabs of varying sort
4340 ${rm} -f "${MBOX}"
4341 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
4342 -s "1Abrä Kaspas1 2Abra Katä b_kaspas2 \
4343 3Abrä Kaspas3 4Abrä Kaspas4 5Abrä Kaspas5 \
4344 6Abra Kaspas6 7Abrä Kaspas7 8Abra Kaspas8 \
4345 9Abra Kaspastäb4-3 10Abra Kaspas1 _ 11Abra Katäb1 \
4346 12Abra Kadabrä1 After Tab after Täb this is NUTS" \
4347 "${MBOX}"
4348 check content:010 0 "${MBOX}" '1676887734 591'
4350 # Overlong multibyte sequence that must be forcefully split
4351 # todo This works even before v15.0, but only by accident
4352 ${rm} -f "${MBOX}"
4353 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
4354 -s "✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
4355 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
4356 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄" \
4357 "${MBOX}"
4358 check content:011 0 "${MBOX}" '3029301775 659'
4360 # Trailing WS
4361 ${rm} -f "${MBOX}"
4362 echo | ${MAILX} ${ARGS} \
4363 -s "1-1 B2 B3 B4 B5 B6 B\
4364 1-2 B2 B3 B4 B5 B6 B\
4365 1-3 B2 B3 B4 B5 B6 B\
4366 1-4 B2 B3 B4 B5 B6 B\
4367 1-5 B2 B3 B4 B5 B6 B\
4368 1-6 B2 B3 B4 B5 B6 " \
4369 "${MBOX}"
4370 check content:012 0 "${MBOX}" '4126167195 297'
4372 # Leading and trailing WS
4373 ${rm} -f "${MBOX}"
4374 echo | ${MAILX} ${ARGS} \
4375 -s " 2-1 B2 B3 B4 B5 B6 B\
4376 1-2 B2 B3 B4 B5 B6 B\
4377 1-3 B2 B3 B4 B5 B6 B\
4378 1-4 B2 B3 B4 B5 B6 " \
4379 "${MBOX}"
4380 check content:013 0 "${MBOX}" '3600624479 236'
4382 # Quick'n dirty RFC 2231 test; i had more when implementing it, but until we
4383 # have a (better) test framework materialize a quick shot
4384 ${rm} -f "${MBOX}"
4385 TRAP_EXIT_ADDONS=./.ttt
4387 mkdir ./.ttt || exit 1
4388 cd ./.ttt || exit 2
4389 : > "ma'ger.txt"
4390 : > "mä'ger.txt"
4391 : > 'diet\ is \curd.txt'
4392 : > 'diet "is" curd.txt'
4393 : > höde-tröge.txt
4394 : > 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
4395 : > höde__tröge__müde__dätte__hätte__vuelle__guelle__aese__aesse__sauerliche__kräuter__österliche__grüße__mäh.txt
4396 : > hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt
4397 : > ✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt
4399 echo bla | ${MAILX} ${ARGS} ${ADDARG_UNI} \
4400 -a "./.ttt/ma'ger.txt" -a "./.ttt/mä'ger.txt" \
4401 -a './.ttt/diet\ is \curd.txt' -a './.ttt/diet "is" curd.txt' \
4402 -a ./.ttt/höde-tröge.txt \
4403 -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 \
4404 -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 \
4405 -a ./.ttt/hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt \
4406 -a ./.ttt/✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt \
4407 "${MBOX}"
4408 check content:014-1 0 "${MBOX}" '684985954 3092'
4410 # `resend' test, reusing $MBOX
4411 ${rm} -f "${BODY}"
4412 printf "Resend ${BODY}\nx\n" | ${MAILX} ${ARGS} -Rf "${MBOX}"
4413 check content:014-2 0 "${BODY}" '684985954 3092'
4415 ${rm} -f "${BODY}"
4416 printf "resend ${BODY}\nx\n" | ${MAILX} ${ARGS} -Rf "${MBOX}"
4417 check content:014-3 0 "${BODY}" '3130352658 3148'
4419 t_epilog
4422 t_all() {
4423 # if have_feat devel; then
4424 # ARGS="${ARGS} -Smemdebug"
4425 # export ARGS
4426 # fi
4428 if [ -n "${UTF8_LOCALE}" ]; then
4429 printf 'Using Unicode locale %s\n' "${UTF8_LOCALE}"
4430 else
4431 printf 'No Unicode locale found, disabling Unicode tests\n'
4434 t_behave
4435 t_content
4438 if [ -z "${CHECK_ONLY}" ]; then
4439 cc_all_configs
4440 else
4441 t_all
4444 [ ${ESTAT} -eq 0 ] && echo Ok || echo >&2 'Errors occurred'
4446 exit ${ESTAT}
4447 # s-sh-mode