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