cc-test.sh: state which locale is used for Unicode, if any
[s-mailx.git] / cc-test.sh
blobf84bdf5b647e4a75321d9cd9cbddefcd9f78fe5c
1 #!/bin/sh -
2 #@ Usage: ./cc-test.sh [--check-only s-mailx-binary]
3 #@ TODO _All_ the tests should happen in a temporary subdir.
4 # Public Domain
6 # We need *stealthmua* regardless of $SOURCE_DATE_EPOCH, the program name as
7 # such is a compile-time variable
8 ARGS='-:/ -# -Sdotlock-ignore-error -Sexpandaddr=restrict'
9 ARGS="${ARGS}"' -Smime-encoding=quoted-printable -Snosave -Sstealthmua'
10 ADDARG_UNI=-Sttycharset=UTF-8
11 CONF=./make.rc
12 BODY=./.cc-body.txt
13 MBOX=./.cc-test.mbox
14 MAIL=/dev/null
15 #UTF8_LOCALE= autodetected unless set
17 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
314 t_behave_lreply_futh_rth_etc
317 t_behave_X_opt_input_command_stack() {
318 t_prolog
320 ${cat} <<- '__EOT' > "${BODY}"
321 echo 1
322 define mac0 {
323 echo mac0-1 via1 $0
325 call mac0
326 echo 2
327 source '\
328 echo "define mac1 {";\
329 echo " echo mac1-1 via1 \$0";\
330 echo " call mac0";\
331 echo " echo mac1-2";\
332 echo " call mac2";\
333 echo " echo mac1-3";\
334 echo "}";\
335 echo "echo 1-1";\
336 echo "define mac2 {";\
337 echo " echo mac2-1 via1 \$0";\
338 echo " call mac0";\
339 echo " echo mac2-2";\
340 echo "}";\
341 echo "echo 1-2";\
342 echo "call mac1";\
343 echo "echo 1-3";\
344 echo "source \"\
345 echo echo 1-1-1 via1 \$0;\
346 echo call mac0;\
347 echo echo 1-1-2;\
348 | \"";\
349 echo "echo 1-4";\
351 echo 3
352 call mac2
353 echo 4
354 undefine *
355 __EOT
357 # The -X option supports multiline arguments, and those can internally use
358 # reverse solidus newline escaping. And all -X options are joined...
359 APO=\'
360 < "${BODY}" ${MAILX} ${ARGS} \
361 -X 'e\' \
362 -X ' c\' \
363 -X ' h\' \
364 -X ' o \' \
365 -X 1 \
367 define mac0 {
368 echo mac0-1 via2 $0
370 call mac0
371 echo 2
374 source '${APO}'\
375 echo "define mac1 {";\
376 echo " echo mac1-1 via2 \$0";\
377 echo " call mac0";\
378 echo " echo mac1-2";\
379 echo " call mac2";\
380 echo " echo mac1-3";\
381 echo "}";\
382 echo "echo 1-1";\
383 echo "define mac2 {";\
384 echo " echo mac2-1 via2 \$0";\
385 echo " call mac0";\
386 echo " echo mac2-2";\
387 echo "}";\
388 echo "echo 1-2";\
389 echo "call mac1";\
390 echo "echo 1-3";\
391 echo "source \"\
392 echo echo 1-1-1 via2 \$0;\
393 echo call mac0;\
394 echo echo 1-1-2;\
395 | \"";\
396 echo "echo 1-4";\
397 | '${APO}'
398 echo 3
401 call mac2
402 echo 4
403 undefine *
404 ' > "${MBOX}"
406 check behave:x_opt_input_command_stack 0 "${MBOX}" '1786542668 416'
408 t_epilog
411 t_behave_X_errexit() {
412 t_prolog
414 ${cat} <<- '__EOT' > "${BODY}"
415 echo one
416 echos nono
417 echo two
418 __EOT
420 </dev/null ${MAILX} ${ARGS} -Snomemdebug \
421 -X'echo one' -X' echos nono ' -X'echo two' \
422 > "${MBOX}" 2>&1
423 check behave:x_errexit-1 0 "${MBOX}" '916157812 53'
425 </dev/null ${MAILX} ${ARGS} -X'source '"${BODY}" -Snomemdebug \
426 > "${MBOX}" 2>&1
427 check behave:x_errexit-2 0 "${MBOX}" '916157812 53'
429 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Snomemdebug \
430 > "${MBOX}" 2>&1
431 check behave:x_errexit-3 0 "${MBOX}" '916157812 53'
435 </dev/null ${MAILX} ${ARGS} -Serrexit -Snomemdebug \
436 -X'echo one' -X' echos nono ' -X'echo two' \
437 > "${MBOX}" 2>&1
438 check behave:x_errexit-4 1 "${MBOX}" '2118430867 49'
440 </dev/null ${MAILX} ${ARGS} -X'source '"${BODY}" -Serrexit -Snomemdebug \
441 > "${MBOX}" 2>&1
442 check behave:x_errexit-5 1 "${MBOX}" '2118430867 49'
444 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Serrexit -Snomemdebug \
445 > "${MBOX}" 2>&1
446 check behave:x_errexit-6 1 "${MBOX}" '12955965 172'
448 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Sposix -Snomemdebug \
449 > "${MBOX}" 2>&1
450 check behave:x_errexit-7 1 "${MBOX}" '12955965 172'
452 ## Repeat 4-7 with ignerr set
454 ${sed} -e 's/^echos /ignerr echos /' < "${BODY}" > "${MBOX}"
456 </dev/null ${MAILX} ${ARGS} -Serrexit -Snomemdebug \
457 -X'echo one' -X'ignerr echos nono ' -X'echo two' \
458 > "${BODY}" 2>&1
459 check behave:x_errexit-8 0 "${BODY}" '916157812 53'
461 </dev/null ${MAILX} ${ARGS} -X'source '"${MBOX}" -Serrexit -Snomemdebug \
462 > "${BODY}" 2>&1
463 check behave:x_errexit-9 0 "${BODY}" '916157812 53'
465 </dev/null MAILRC="${MBOX}" ${MAILX} ${ARGS} -:u -Serrexit -Snomemdebug \
466 > "${BODY}" 2>&1
467 check behave:x_errexit-10 0 "${BODY}" '916157812 53'
469 </dev/null MAILRC="${MBOX}" ${MAILX} ${ARGS} -:u -Sposix -Snomemdebug \
470 > "${BODY}" 2>&1
471 check behave:x_errexit-11 0 "${BODY}" '916157812 53'
473 t_epilog
476 t_behave_wysh() {
477 t_prolog
479 ${cat} <<- '__EOT' > "${BODY}"
481 echo abcd
482 echo a'b'c'd'
483 echo a"b"c"d"
484 echo a$'b'c$'d'
485 echo 'abcd'
486 echo "abcd"
487 echo $'abcd'
488 echo a\ b\ c\ d
489 echo a 'b c' d
490 echo a "b c" d
491 echo a $'b c' d
493 echo 'a$`"\'
494 echo "a\$\`'\"\\"
495 echo $'a\$`\'\"\\'
496 echo $'a\$`\'"\\'
497 # DIET=CURD TIED=
498 echo 'a${DIET}b${TIED}c\${DIET}d\${TIED}e' # COMMENT
499 echo "a${DIET}b${TIED}c\${DIET}d\${TIED}e"
500 echo $'a${DIET}b${TIED}c\${DIET}d\${TIED}e'
502 echo a$'\101\0101\x41\u0041\u41\U00000041\U41'c
503 echo a$'\u0041\u41\u0C1\U00000041\U41'c
504 echo a$'\377'c
505 echo a$'\0377'c
506 echo a$'\400'c
507 echo a$'\0400'c
508 echo a$'\U1100001'c
510 echo a$'b\0c'd
511 echo a$'b\00c'de
512 echo a$'b\000c'df
513 echo a$'b\0000c'dg
514 echo a$'b\x0c'dh
515 echo a$'b\x00c'di
516 echo a$'b\u0'dj
517 echo a$'b\u00'dk
518 echo a$'b\u000'dl
519 echo a$'b\u0000'dm
520 echo a$'b\U0'dn
521 echo a$'b\U00'do
522 echo a$'b\U000'dp
523 echo a$'b\U0000'dq
524 echo a$'b\U00000'dr
525 echo a$'b\U000000'ds
526 echo a$'b\U0000000'dt
527 echo a$'b\U00000000'du
529 echo a$'\cI'b
530 echo a$'\011'b
531 echo a$'\x9'b
532 echo a$'\u9'b
533 echo a$'\U9'b
534 echo a$'\c@'b c d
535 __EOT
537 if [ -z "${UTF8_LOCALE}" ]; then
538 echo 'Skip behave:wysh_unicode, no UTF8_LOCALE'
539 else
540 < "${BODY}" DIET=CURD TIED= \
541 LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} 2>/dev/null > "${MBOX}"
542 check behave:wysh_unicode 0 "${MBOX}" '475805847 317'
545 < "${BODY}" DIET=CURD TIED= ${MAILX} ${ARGS} > "${MBOX}" 2>/dev/null
546 check behave:wysh_c 0 "${MBOX}" '1473887148 321'
548 t_epilog
551 t_behave_input_inject_semicolon_seq() {
552 t_prolog
554 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
555 define mydeepmac {
556 echon '(mydeepmac)';
558 define mymac {
559 echon this_is_mymac;call mydeepmac;echon ';';
561 echon one';';call mymac;echon two";";call mymac;echo three$';';
562 define mymac {
563 echon this_is_mymac;call mydeepmac;echon ,TOO'!;';
565 echon one';';call mymac;echon two";";call mymac;echo three$';';
566 __EOT
568 check behave:input_inject_semicolon_seq 0 "${MBOX}" '512117110 140'
570 t_epilog
573 t_behave_commandalias() {
574 t_prolog
576 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
577 commandalias echo echo hoho
578 echo stop.
579 commandalias X Xx
580 commandalias Xx XxX
581 commandalias XxX XxXx
582 commandalias XxXx XxXxX
583 commandalias XxXxX XxXxXx
584 commandalias XxXxXx echo huhu
585 commandalias XxXxXxX echo huhu
587 commandalias XxXxXx XxXxXxX
589 uncommandalias echo
590 commandalias XxXxXx echo huhu
592 __EOT
594 check behave:commandalias 0 "${MBOX}" '3694143612 31'
596 t_epilog
599 t_behave_ifelse() {
600 t_prolog
602 # Nestable conditions test
603 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
604 if 0
605 echo 1.err
606 else
607 echo 1.ok
608 endif
609 if 1
610 echo 2.ok
611 else
612 echo 2.err
613 endif
614 if $dietcurd
615 echo 3.err
616 else
617 echo 3.ok
618 endif
619 set dietcurd=yoho
620 if $dietcurd
621 echo 4.ok
622 else
623 echo 4.err
624 endif
625 if $dietcurd == 'yoho'
626 echo 5.ok
627 else
628 echo 5.err
629 endif
630 if $dietcurd @== 'Yoho'
631 echo 5-1.ok
632 else
633 echo 5-1.err
634 endif
635 if $dietcurd == 'Yoho'
636 echo 5-2.err
637 else
638 echo 5-2.ok
639 endif
640 if $dietcurd != 'yoho'
641 echo 6.err
642 else
643 echo 6.ok
644 endif
645 if $dietcurd @!= 'Yoho'
646 echo 6-1.err
647 else
648 echo 6-1.ok
649 endif
650 if $dietcurd != 'Yoho'
651 echo 6-2.ok
652 else
653 echo 6-2.err
654 endif
655 # Nesting
656 if faLse
657 echo 7.err1
658 if tRue
659 echo 7.err2
660 if yEs
661 echo 7.err3
662 else
663 echo 7.err4
664 endif
665 echo 7.err5
666 endif
667 echo 7.err6
668 else
669 echo 7.ok7
670 if YeS
671 echo 7.ok8
672 if No
673 echo 7.err9
674 else
675 echo 7.ok9
676 endif
677 echo 7.ok10
678 else
679 echo 7.err11
680 if yeS
681 echo 7.err12
682 else
683 echo 7.err13
684 endif
685 endif
686 echo 7.ok14
687 endif
688 if r
689 echo 8.ok1
690 if R
691 echo 8.ok2
692 else
693 echo 8.err2
694 endif
695 echo 8.ok3
696 else
697 echo 8.err1
698 endif
699 if s
700 echo 9.err1
701 else
702 echo 9.ok1
703 if S
704 echo 9.err2
705 else
706 echo 9.ok2
707 endif
708 echo 9.ok3
709 endif
710 # `elif'
711 if $dietcurd == 'yohu'
712 echo 10.err1
713 elif $dietcurd == 'yoha'
714 echo 10.err2
715 elif $dietcurd == 'yohe'
716 echo 10.err3
717 elif $dietcurd == 'yoho'
718 echo 10.ok1
719 if $dietcurd == 'yohu'
720 echo 10.err4
721 elif $dietcurd == 'yoha'
722 echo 10.err5
723 elif $dietcurd == 'yohe'
724 echo 10.err6
725 elif $dietcurd == 'yoho'
726 echo 10.ok2
727 if $dietcurd == 'yohu'
728 echo 10.err7
729 elif $dietcurd == 'yoha'
730 echo 10.err8
731 elif $dietcurd == 'yohe'
732 echo 10.err9
733 elif $dietcurd == 'yoho'
734 echo 10.ok3
735 else
736 echo 10.err10
737 endif
738 else
739 echo 10.err11
740 endif
741 else
742 echo 10.err12
743 endif
744 # integer
745 set dietcurd=10
746 if $dietcurd -lt 11
747 echo 11.ok1
748 if $dietcurd -gt 9
749 echo 11.ok2
750 else
751 echo 11.err2
752 endif
753 if $dietcurd -eq 10
754 echo 11.ok3
755 else
756 echo 11.err3
757 endif
758 if $dietcurd -ge 10
759 echo 11.ok4
760 else
761 echo 11.err4
762 endif
763 if $dietcurd -le 10
764 echo 11.ok5
765 else
766 echo 11.err5
767 endif
768 if $dietcurd -ge 11
769 echo 11.err6
770 else
771 echo 11.ok6
772 endif
773 if $dietcurd -le 9
774 echo 11.err7
775 else
776 echo 11.ok7
777 endif
778 else
779 echo 11.err1
780 endif
781 set dietcurd=Abc
782 if $dietcurd < aBd
783 echo 12.ok1
784 if $dietcurd @> abB
785 echo 12.ok2
786 else
787 echo 12.err2
788 endif
789 if $dietcurd @== aBC
790 echo 12.ok3
791 else
792 echo 12.err3
793 endif
794 if $dietcurd @>= AbC
795 echo 12.ok4
796 else
797 echo 12.err4
798 endif
799 if $dietcurd @<= ABc
800 echo 12.ok5
801 else
802 echo 12.err5
803 endif
804 if $dietcurd @>= abd
805 echo 12.err6
806 else
807 echo 12.ok6
808 endif
809 if $dietcurd @<= abb
810 echo 12.err7
811 else
812 echo 12.ok7
813 endif
814 else
815 echo 12.err1
816 endif
817 if $dietcurd < aBc
818 echo 12-1.ok
819 else
820 echo 12-1.err
821 endif
822 if $dietcurd @< aBc
823 echo 12-2.err
824 else
825 echo 12-2.ok
826 endif
827 if $dietcurd > ABc
828 echo 12-3.ok
829 else
830 echo 12-3.err
831 endif
832 if $dietcurd @> ABc
833 echo 12-3.err
834 else
835 echo 12-3.ok
836 endif
837 if $dietcurd @i=% aB
838 echo 13.ok
839 else
840 echo 13.err
841 endif
842 if $dietcurd =% aB
843 echo 13-1.err
844 else
845 echo 13-1.ok
846 endif
847 if $dietcurd @=% bC
848 echo 14.ok
849 else
850 echo 14.err
851 endif
852 if $dietcurd !% aB
853 echo 15-1.ok
854 else
855 echo 15-1.err
856 endif
857 if $dietcurd @!% aB
858 echo 15-2.err
859 else
860 echo 15-2.ok
861 endif
862 if $dietcurd !% bC
863 echo 15-3.ok
864 else
865 echo 15-3.err
866 endif
867 if $dietcurd @!% bC
868 echo 15-4.err
869 else
870 echo 15-4.ok
871 endif
872 if $dietcurd =% Cd
873 echo 16.err
874 else
875 echo 16.ok
876 endif
877 if $dietcurd !% Cd
878 echo 17.ok
879 else
880 echo 17.err
881 endif
882 set diet=abc curd=abc
883 if $diet == $curd
884 echo 18.ok
885 else
886 echo 18.err
887 endif
888 set diet=abc curd=abcd
889 if $diet != $curd
890 echo 19.ok
891 else
892 echo 19.err
893 endif
894 # 1. Shitty grouping capabilities as of today
895 unset diet curd ndefined
896 if [ [ false ] || [ false ] || [ true ] ] && [ [ false ] || [ true ] ] && \
897 [ yes ]
898 echo 20.ok
899 else
900 echo 20.err
901 endif
902 if [ [ [ [ 0 ] || [ 1 ] ] && [ [ 1 ] || [ 0 ] ] ] && [ 1 ] ] && [ yes ]
903 echo 21.ok
904 else
905 echo 21.err
906 endif
907 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] ]
908 echo 22.ok
909 else
910 echo 22.err
911 endif
912 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] ]
913 echo 23.ok
914 else
915 echo 23.err
916 endif
917 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] && [ no ]
918 echo 24.err
919 else
920 echo 24.ok
921 endif
922 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] \
923 && [ no ] || [ yes ]
924 echo 25.ok
925 else
926 echo 25.err
927 endif
928 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
929 echo 26.ok
930 else
931 echo 26.err
932 endif
933 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 0 ] ]
934 echo 27.err
935 else
936 echo 27.ok
937 endif
938 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 0 ] ] && [ 1 ] ] ] && [ 1 ] ]
939 echo 28.err
940 else
941 echo 28.ok
942 endif
943 if [ [ [ [ [ [ [ 0 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
944 echo 29.err
945 else
946 echo 29.ok
947 endif
948 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 0 ]
949 echo 30.err
950 else
951 echo 30.ok
952 endif
953 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 1 ]
954 echo 31.ok
955 else
956 echo 31.err
957 endif
958 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ]
959 echo 32.err
960 else
961 echo 32.ok
962 endif
963 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 1 ]
964 echo 33.ok
965 else
966 echo 33.err
967 endif
968 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 0 ]
969 echo 34.err
970 else
971 echo 34.ok
972 endif
973 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 1 ]
974 echo 35.ok
975 else
976 echo 35.err
977 endif
978 set diet=yo curd=ho
979 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
980 echo 36.err
981 else
982 echo 36.ok
983 endif
984 set ndefined
985 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
986 echo 37.ok
987 else
988 echo 37.err
989 endif
990 # 2. Shitty grouping capabilities as of today
991 unset diet curd ndefined
992 if [ false || false || true ] && [ false || true ] && yes
993 echo 40.ok
994 else
995 echo 40.err
996 endif
997 if [ [ [ 0 || 1 ] && [ 1 || 0 ] ] && 1 ] && [ yes ]
998 echo 41.ok
999 else
1000 echo 41.err
1001 endif
1002 if [ 1 || 0 || 0 || 0 ]
1003 echo 42.ok
1004 else
1005 echo 42.err
1006 endif
1007 if [ 1 || 0 || 0 || 0 || [ 1 ] ]
1008 echo 43.ok
1009 else
1010 echo 43.err
1011 endif
1012 if [ 1 || 0 || 0 || 0 || [ 1 ] || 1 ] && no
1013 echo 44.err
1014 else
1015 echo 44.ok
1016 endif
1017 if [ 1 || 0 || 0 || 0 || 1 || [ 1 ] ] && no || [ yes ]
1018 echo 45.ok
1019 else
1020 echo 45.err
1021 endif
1022 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && 1 ] ] && [ 1 ] ]
1023 echo 46.ok
1024 else
1025 echo 46.err
1026 endif
1027 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && [ 1 ] ] ] && 0 ]
1028 echo 47.err
1029 else
1030 echo 47.ok
1031 endif
1032 if [ [ [ [ [ [ [ 1 ] ] && 1 ] && 0 ] && [ 1 ] ] ] && 1 ]
1033 echo 48.err
1034 else
1035 echo 48.ok
1036 endif
1037 if [ [ [ [ [ [ 0 ] && 1 ] && 1 ] && 1 ] ] && 1 ]
1038 echo 49.err
1039 else
1040 echo 49.ok
1041 endif
1042 if 1 || 0 || 0 || 0 && 0
1043 echo 50.err
1044 else
1045 echo 50.ok
1046 endif
1047 if 1 || 0 || 0 || 0 && 1
1048 echo 51.ok
1049 else
1050 echo 51.err
1051 endif
1052 if 0 || 0 || 0 || 1 && 0
1053 echo 52.err
1054 else
1055 echo 52.ok
1056 endif
1057 if 0 || 0 || 0 || 1 && 1
1058 echo 53.ok
1059 else
1060 echo 53.err
1061 endif
1062 if 0 || 0 || 0 || 1 && 0 || 1 && 0
1063 echo 54.err
1064 else
1065 echo 54.ok
1066 endif
1067 if 0 || 0 || 0 || 1 && 0 || 1 && 1
1068 echo 55.ok
1069 else
1070 echo 55.err
1071 endif
1072 set diet=yo curd=ho
1073 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
1074 echo 56.err
1075 else
1076 echo 56.ok
1077 endif
1078 if $diet == 'yo' && $curd == 'ho' && $ndefined
1079 echo 57.err
1080 else
1081 echo 57.ok
1082 endif
1083 set ndefined
1084 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
1085 echo 57.ok
1086 else
1087 echo 57.err
1088 endif
1089 if $diet == 'yo' && $curd == 'ho' && $ndefined
1090 echo 58.ok
1091 else
1092 echo 58.err
1093 endif
1094 if [ [ [ [ [ [ $diet == 'yo' && $curd == 'ho' && $ndefined ] ] ] ] ] ]
1095 echo 59.ok
1096 else
1097 echo 59.err
1098 endif
1099 # Some more en-braced variables
1100 set diet=yo curd=ho
1101 if ${diet} == ${curd}
1102 echo 70.err
1103 else
1104 echo 70.ok
1105 endif
1106 if ${diet} != ${curd}
1107 echo 71.ok
1108 else
1109 echo 71.err
1110 endif
1111 if $diet == ${curd}
1112 echo 72.err
1113 else
1114 echo 72.ok
1115 endif
1116 if ${diet} == $curd
1117 echo 73.err
1118 else
1119 echo 73.ok
1120 endif
1121 # Unary !
1122 if ! 0 && ! ! 1 && ! ! ! ! 2 && 3
1123 echo 80.ok
1124 else
1125 echo 80.err
1126 endif
1127 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ ! 2 ] ] ] && 3
1128 echo 81.ok
1129 else
1130 echo 81.err
1131 endif
1132 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1133 echo 82.ok
1134 else
1135 echo 82.err
1136 endif
1137 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
1138 echo 83.err
1139 else
1140 echo 83.ok
1141 endif
1142 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
1143 echo 84.err
1144 else
1145 echo 84.ok
1146 endif
1147 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1148 echo 85.err
1149 else
1150 echo 85.ok
1151 endif
1152 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1153 echo 86.err
1154 else
1155 echo 86.ok
1156 endif
1157 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] || 3
1158 echo 87.ok
1159 else
1160 echo 87.err
1161 endif
1162 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! ! [ 2 ] ] ] ] ]
1163 echo 88.ok
1164 else
1165 echo 88.err
1166 endif
1167 # Unary !, odd
1168 if ! 0 && ! ! 1 && ! ! ! 0 && 3
1169 echo 90.ok
1170 else
1171 echo 90.err
1172 endif
1173 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ 0 ] ] ] && 3
1174 echo 91.ok
1175 else
1176 echo 91.err
1177 endif
1178 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ [ 0 ] ] ] ] ] && 3
1179 echo 92.ok
1180 else
1181 echo 92.err
1182 endif
1183 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! ! [ ! [ ! 0 ] ] ] ] && ! 3
1184 echo 93.err
1185 else
1186 echo 93.ok
1187 endif
1188 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ ! [ ! [ ! [ ! 0 ] ] ] ] && 3
1189 echo 94.ok
1190 else
1191 echo 94.err
1192 endif
1193 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! ! [ ! [ ! [ ! [ 0 ] ] ] ] ] && 3
1194 echo 95.err
1195 else
1196 echo 95.ok
1197 endif
1198 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! ! 0 ] ] ] ] && 3
1199 echo 96.err
1200 else
1201 echo 96.ok
1202 endif
1203 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ ! 0 ] ] ] ] ] || 3
1204 echo 97.ok
1205 else
1206 echo 97.err
1207 endif
1208 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! [ 0 ] ] ] ] ]
1209 echo 98.ok
1210 else
1211 echo 98.err
1212 endif
1213 __EOT
1215 check behave:if-normal 0 "${MBOX}" '1688759742 719'
1217 if have_feat regex; then
1218 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
1219 set dietcurd=yoho
1220 if $dietcurd =~ '^yo.*'
1221 echo 1.ok
1222 else
1223 echo 1.err
1224 endif
1225 if $dietcurd =~ '^Yo.*'
1226 echo 1-1.err
1227 else
1228 echo 1-1.ok
1229 endif
1230 if $dietcurd @=~ '^Yo.*'
1231 echo 1-2.ok
1232 else
1233 echo 1-2.err
1234 endif
1235 if $dietcurd =~ '^yOho.+'
1236 echo 2.err
1237 else
1238 echo 2.ok
1239 endif
1240 if $dietcurd @!~ '.*Ho$'
1241 echo 3.err
1242 else
1243 echo 3.ok
1244 endif
1245 if $dietcurd !~ '.+yohO$'
1246 echo 4.ok
1247 else
1248 echo 4.err
1249 endif
1250 if [ $dietcurd @i!~ '.+yoho$' ]
1251 echo 5.ok
1252 else
1253 echo 5.err
1254 endif
1255 if ! [ $dietcurd @i=~ '.+yoho$' ]
1256 echo 6.ok
1257 else
1258 echo 6.err
1259 endif
1260 if ! ! [ $dietcurd @i!~ '.+yoho$' ]
1261 echo 7.ok
1262 else
1263 echo 7.err
1264 endif
1265 if ! [ ! [ $dietcurd @i!~ '.+yoho$' ] ]
1266 echo 8.ok
1267 else
1268 echo 8.err
1269 endif
1270 if [ ! [ ! [ $dietcurd @i!~ '.+yoho$' ] ] ]
1271 echo 9.ok
1272 else
1273 echo 9.err
1274 endif
1275 if ! [ ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
1276 echo 10.err
1277 else
1278 echo 10.ok
1279 endif
1280 if ! ! ! $dietcurd !~ '.+yoho$'
1281 echo 11.err
1282 else
1283 echo 11.ok
1284 endif
1285 if ! ! ! $dietcurd =~ '.+yoho$'
1286 echo 12.ok
1287 else
1288 echo 12.err
1289 endif
1290 if ! [ ! ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
1291 echo 13.ok
1292 else
1293 echo 13.err
1294 endif
1295 set diet=abc curd='^abc$'
1296 if $diet =~ $curd
1297 echo 14.ok
1298 else
1299 echo 14.err
1300 endif
1301 set diet=abc curd='^abcd$'
1302 if $diet !~ $curd
1303 echo 15.ok
1304 else
1305 echo 15.err
1306 endif
1307 __EOT
1309 check behave:if-regex 0 "${MBOX}" '1115671789 95'
1310 else
1311 printf 'behave:if-regex: unsupported, skipped\n'
1314 t_epilog
1317 t_behave_localopts() {
1318 t_prolog
1320 # Nestable conditions test
1321 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
1322 define t2 {
1323 echo in: t2
1324 set t2=t2
1325 echo $t2
1327 define t1 {
1328 echo in: t1
1329 set gv1=gv1
1330 localopts on
1331 set lv1=lv1 lv2=lv2
1332 set lv3=lv3
1333 call t2
1334 localopts off
1335 set gv2=gv2
1336 echo $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2
1338 define t0 {
1339 echo in: t0
1340 call t1
1341 echo $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2
1342 echo "$gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2"
1344 account trouble {
1345 echo in: trouble
1346 call t0
1348 call t0
1349 unset gv1 gv2
1350 account trouble
1351 echo active trouble: $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t3
1352 account null
1353 echo active null: $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t3
1356 define ll2 {
1357 localopts $1
1358 set x=2
1359 echo ll2=$x
1361 define ll1 {
1362 wysh set y=$1; shift; eval localopts $y; localopts $1; shift
1363 set x=1
1364 echo ll1.1=$x
1365 call ll2 $1
1366 echo ll1.2=$x
1368 define ll0 {
1369 wysh set y=$1; shift; eval localopts $y; localopts $1; shift
1370 set x=0
1371 echo ll0.1=$x
1372 call ll1 $y "$@"
1373 echo ll0.2=$x
1375 define llx {
1376 echo ----- $1: $2 -> $3 -> $4
1377 echo ll-1.1=$x
1378 eval localopts $1
1379 call ll0 "$@"
1380 echo ll-1.2=$x
1381 unset x
1383 define lly {
1384 call llx 'call off' on on on
1385 call llx 'call off' off on on
1386 call llx 'call off' on off on
1387 call llx 'call off' on off off
1388 localopts call-fixate on
1389 call llx 'call-fixate on' on on on
1390 call llx 'call-fixate on' off on on
1391 call llx 'call-fixate on' on off on
1392 call llx 'call-fixate on' on off off
1393 unset x;localopts call on
1394 call llx 'call on' on on on
1395 call llx 'call on' off on on
1396 call llx 'call on' on off on
1397 call llx 'call on' on off off
1399 call lly
1400 __EOT
1402 check behave:localopts 0 "${MBOX}" '4016155249 1246'
1404 t_epilog
1407 t_behave_macro_param_shift() {
1408 t_prolog
1410 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>/dev/null
1411 define t2 {
1412 echo in: t2
1413 echo t2.0 has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1414 localopts on
1415 wysh set ignerr=$1
1416 shift
1417 localopts off
1418 echo t2.1 has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1419 if [ $# > 1 ] || [ $ignerr == '' ]
1420 shift 2
1421 else
1422 ignerr shift 2
1423 endif
1424 echo t2.2:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1425 shift 0
1426 echo t2.3:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1427 if [ $# > 0 ]
1428 shift
1429 endif
1430 echo t2.4:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1432 define t1 {
1433 set errexit
1434 echo in: t1
1435 call t2 1 you get four args
1436 echo t1.1: $?';' ignerr ($ignerr) should not exist
1437 call t2 1 you get 'three args'
1438 echo t1.2: $?';' ignerr ($ignerr) should not exist
1439 call t2 1 you 'get two args'
1440 echo t1.3: $?';' ignerr ($ignerr) should not exist
1441 call t2 1 'you get one arg'
1442 echo t1.4: $?';' ignerr ($ignerr) should not exist
1443 ignerr call t2 '' 'you get one arg'
1444 echo t1.5: $?';' ignerr ($ignerr) should not exist
1446 call t1
1447 __EOT
1449 check behave:macro_param_shift 0 "${MBOX}" '1402489146 1682'
1451 t_epilog
1454 t_behave_addrcodec() {
1455 t_prolog
1457 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
1458 vput addrcodec res e 1 <doog@def>
1459 echo $?/$^ERRNAME $res
1460 eval vput addrcodec res d $res
1461 echo $?/$^ERRNAME $res
1462 vput addrcodec res e 2 . <doog@def>
1463 echo $?/$^ERRNAME $res
1464 eval vput addrcodec res d $res
1465 echo $?/$^ERRNAME $res
1466 vput addrcodec res e 3 Sauer Dr. <doog@def>
1467 echo $?/$^ERRNAME $res
1468 eval vput addrcodec res d $res
1469 echo $?/$^ERRNAME $res
1470 vput addrcodec res e 3.50 Sauer (Ma) Dr. <doog@def>
1471 echo $?/$^ERRNAME $res
1472 eval vput addrcodec res d $res
1473 echo $?/$^ERRNAME $res
1474 vput addrcodec res e 3.51 Sauer (Ma) "Dr." <doog@def>
1475 echo $?/$^ERRNAME $res
1476 eval vput addrcodec res d $res
1477 echo $?/$^ERRNAME $res
1479 vput addrcodec res +e 4 Sauer (Ma) Dr. <doog@def>
1480 echo $?/$^ERRNAME $res
1481 eval vput addrcodec res d $res
1482 echo $?/$^ERRNAME $res
1483 vput addrcodec res +e 5 Sauer (Ma) Braten Dr. <doog@def>
1484 echo $?/$^ERRNAME $res
1485 eval vput addrcodec res d $res
1486 echo $?/$^ERRNAME $res
1487 vput addrcodec res +e 6 Sauer (Ma) Braten Dr. (Heu) <doog@def>
1488 echo $?/$^ERRNAME $res
1489 eval vput addrcodec res d $res
1490 echo $?/$^ERRNAME $res
1491 vput addrcodec res +e 7 Sauer (Ma) Braten Dr. (Heu) <doog@def> (bu)
1492 echo $?/$^ERRNAME $res
1493 eval vput addrcodec res d $res
1494 echo $?/$^ERRNAME $res
1495 vput addrcodec res +e 8 \
1496 Dr. Sauer (Ma) Braten Dr. (Heu) <doog@def> (bu) Boom. Boom
1497 echo $?/$^ERRNAME $res
1498 eval vput addrcodec res d $res
1499 echo $?/$^ERRNAME $res
1500 vput addrcodec res +e 9 Dr.Sauer(Ma)Braten Dr. (Heu) <doog@def>
1501 echo $?/$^ERRNAME $res
1502 eval vput addrcodec res d $res
1503 echo $?/$^ERRNAME $res
1504 vput addrcodec res +e 10 (Ma)Braten Dr. (Heu) <doog@def>
1505 echo $?/$^ERRNAME $res
1506 eval vput addrcodec res d $res
1507 echo $?/$^ERRNAME $res
1508 vput addrcodec res +e 11 (Ma)Braten Dr"." (Heu) <doog@def>
1509 echo $?/$^ERRNAME $res
1510 eval vput addrcodec res d $res
1511 echo $?/$^ERRNAME $res
1512 vput addrcodec res +e 12 Dr. Sauer (Ma) Braten Dr. (u) <doog@def>
1513 echo $?/$^ERRNAME $res
1514 eval vput addrcodec res d $res
1515 echo $?/$^ERRNAME $res
1516 vput addrcodec res +e 13(Ma)Braten Dr. (Heu) <doog@def>
1517 echo $?/$^ERRNAME $res
1518 eval vput addrcodec res d $res
1519 echo $?/$^ERRNAME $res
1520 vput addrcodec res +e 14 Hey, Du <doog@def> Wie() findet Dr. das? ()
1521 echo $?/$^ERRNAME $res
1522 eval vput addrcodec res d $res
1523 echo $?/$^ERRNAME $res
1524 vput addrcodec res +e 15 \
1525 Hey, Du <doog@def> Wie() findet "" Dr. "" das? ()
1526 echo $?/$^ERRNAME $res
1527 eval vput addrcodec res d $res
1528 echo $?/$^ERRNAME $res
1529 vput addrcodec res +e 16 \
1530 "Hey," "Du" <doog@def> "Wie()" findet "" Dr. "" das? ()
1531 echo $?/$^ERRNAME $res
1532 eval vput addrcodec res d $res
1533 echo $?/$^ERRNAME $res
1534 vput addrcodec res +e 17 \
1535 "Hey" Du <doog@def> "Wie() findet " " Dr. """ das? ()
1536 echo $?/$^ERRNAME $res
1537 eval vput addrcodec res d $res
1538 echo $?/$^ERRNAME $res
1539 vput addrcodec res +e 18 \
1540 <doog@def> "Hey" Du "Wie() findet " " Dr. """ das? ()
1541 echo $?/$^ERRNAME $res
1542 eval vput addrcodec res d $res
1543 echo $?/$^ERRNAME $res
1544 vput addrcodec res +e 19 Hey\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1545 echo $?/$^ERRNAME $res
1546 eval vput addrcodec res d $res
1547 echo $?/$^ERRNAME $res
1549 vput addrcodec res ++e 20 Hey\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1550 echo $?/$^ERRNAME $res
1551 vput addrcodec res ++e 21 Hey\,\"" <doog@def> "Wie()" findet \" Dr. \" das?
1552 echo $?/$^ERRNAME $res
1553 eval vput addrcodec res d $res
1554 echo $?/$^ERRNAME $res
1556 vput addrcodec res +++e 22 Hey\\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1557 echo $?/$^ERRNAME $res
1558 eval vput addrcodec res d $res
1559 echo $?/$^ERRNAME $res
1561 vput addrcodec res s \
1562 "23 Hey\\,\\\" \"Wie" () "\" findet \\\" Dr. \\\" das?" <doog@def>
1563 echo $?/$^ERRNAME $res
1564 __EOT
1566 check behave:addrcodec 0 "${MBOX}" '429099645 2414'
1568 t_epilog
1571 t_behave_vexpr() {
1572 t_prolog
1574 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>/dev/null
1575 vput vexpr res = 9223372036854775807
1576 echo $?/$^ERRNAME $res
1577 vput vexpr res = 9223372036854775808
1578 echo $?/$^ERRNAME $res
1579 vput vexpr res =@ 9223372036854775808
1580 echo $?/$^ERRNAME $res
1581 vput vexpr res = -9223372036854775808
1582 echo $?/$^ERRNAME $res
1583 vput vexpr res = -9223372036854775809
1584 echo $?/$^ERRNAME $res
1585 vput vexpr res =@ -9223372036854775809
1586 echo $?/$^ERRNAME $res
1587 echo ' #1'
1588 vput vexpr res ~ 0
1589 echo $?/$^ERRNAME $res
1590 vput vexpr res ~ 1
1591 echo $?/$^ERRNAME $res
1592 vput vexpr res ~ -1
1593 echo $?/$^ERRNAME $res
1594 echo ' #2'
1595 vput vexpr res + 0 0
1596 echo $?/$^ERRNAME $res
1597 vput vexpr res + 0 1
1598 echo $?/$^ERRNAME $res
1599 vput vexpr res + 1 1
1600 echo $?/$^ERRNAME $res
1601 echo ' #3'
1602 vput vexpr res + 9223372036854775807 0
1603 echo $?/$^ERRNAME $res
1604 vput vexpr res + 9223372036854775807 1
1605 echo $?/$^ERRNAME $res
1606 vput vexpr res +@ 9223372036854775807 1
1607 echo $?/$^ERRNAME $res
1608 vput vexpr res + 0 9223372036854775807
1609 echo $?/$^ERRNAME $res
1610 vput vexpr res + 1 9223372036854775807
1611 echo $?/$^ERRNAME $res
1612 vput vexpr res +@ 1 9223372036854775807
1613 echo $?/$^ERRNAME $res
1614 echo ' #4'
1615 vput vexpr res + -9223372036854775808 0
1616 echo $?/$^ERRNAME $res
1617 vput vexpr res + -9223372036854775808 -1
1618 echo $?/$^ERRNAME $res
1619 vput vexpr res +@ -9223372036854775808 -1
1620 echo $?/$^ERRNAME $res
1621 vput vexpr res + 0 -9223372036854775808
1622 echo $?/$^ERRNAME $res
1623 vput vexpr res + -1 -9223372036854775808
1624 echo $?/$^ERRNAME $res
1625 vput vexpr res +@ -1 -9223372036854775808
1626 echo $?/$^ERRNAME $res
1627 echo ' #5'
1628 vput vexpr res - 0 0
1629 echo $?/$^ERRNAME $res
1630 vput vexpr res - 0 1
1631 echo $?/$^ERRNAME $res
1632 vput vexpr res - 1 1
1633 echo $?/$^ERRNAME $res
1634 echo ' #6'
1635 vput vexpr res - 9223372036854775807 0
1636 echo $?/$^ERRNAME $res
1637 vput vexpr res - 9223372036854775807 -1
1638 echo $?/$^ERRNAME $res
1639 vput vexpr res -@ 9223372036854775807 -1
1640 echo $?/$^ERRNAME $res
1641 vput vexpr res - 0 9223372036854775807
1642 echo $?/$^ERRNAME $res
1643 vput vexpr res - -1 9223372036854775807
1644 echo $?/$^ERRNAME $res
1645 vput vexpr res - -2 9223372036854775807
1646 echo $?/$^ERRNAME $res
1647 vput vexpr res -@ -2 9223372036854775807
1648 echo $?/$^ERRNAME $res
1649 echo ' #7'
1650 vput vexpr res - -9223372036854775808 +0
1651 echo $?/$^ERRNAME $res
1652 vput vexpr res - -9223372036854775808 +1
1653 echo $?/$^ERRNAME $res
1654 vput vexpr res -@ -9223372036854775808 +1
1655 echo $?/$^ERRNAME $res
1656 vput vexpr res - 0 -9223372036854775808
1657 echo $?/$^ERRNAME $res
1658 vput vexpr res - +1 -9223372036854775808
1659 echo $?/$^ERRNAME $res
1660 vput vexpr res -@ +1 -9223372036854775808
1661 echo $?/$^ERRNAME $res
1662 echo ' #8'
1663 vput vexpr res + -13 -2
1664 echo $?/$^ERRNAME $res
1665 vput vexpr res - 0 0
1666 echo $?/$^ERRNAME $res
1667 vput vexpr res - 0 1
1668 echo $?/$^ERRNAME $res
1669 vput vexpr res - 1 1
1670 echo $?/$^ERRNAME $res
1671 vput vexpr res - -13 -2
1672 echo $?/$^ERRNAME $res
1673 echo ' #9'
1674 vput vexpr res * 0 0
1675 echo $?/$^ERRNAME $res
1676 vput vexpr res * 0 1
1677 echo $?/$^ERRNAME $res
1678 vput vexpr res * 1 1
1679 echo $?/$^ERRNAME $res
1680 vput vexpr res * -13 -2
1681 echo $?/$^ERRNAME $res
1682 echo ' #10'
1683 vput vexpr res / 0 0
1684 echo $?/$^ERRNAME $res
1685 vput vexpr res / 0 1
1686 echo $?/$^ERRNAME $res
1687 vput vexpr res / 1 1
1688 echo $?/$^ERRNAME $res
1689 vput vexpr res / -13 -2
1690 echo $?/$^ERRNAME $res
1691 echo ' #11'
1692 vput vexpr res % 0 0
1693 echo $?/$^ERRNAME $res
1694 vput vexpr res % 0 1
1695 echo $?/$^ERRNAME $res
1696 vput vexpr res % 1 1
1697 echo $?/$^ERRNAME $res
1698 vput vexpr res % -13 -2
1699 echo $?/$^ERRNAME $res
1700 __EOT
1702 check behave:vexpr-numeric 0 "${MBOX}" '1723609217 1048'
1704 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" #2>/dev/null
1705 vput vexpr res find 'bananarama' 'nana'
1706 echo $?/$^ERRNAME :$res:
1707 vput vexpr res find 'bananarama' 'bana'
1708 echo $?/$^ERRNAME :$res:
1709 vput vexpr res find 'bananarama' 'Bana'
1710 echo $?/$^ERRNAME :$res:
1711 vput vexpr res find 'bananarama' 'rama'
1712 echo $?/$^ERRNAME :$res:
1713 echo ' #1'
1714 vput vexpr res ifind 'bananarama' 'nana'
1715 echo $?/$^ERRNAME :$res:
1716 vput vexpr res ifind 'bananarama' 'bana'
1717 echo $?/$^ERRNAME :$res:
1718 vput vexpr res ifind 'bananarama' 'Bana'
1719 echo $?/$^ERRNAME :$res:
1720 vput vexpr res ifind 'bananarama' 'rama'
1721 echo $?/$^ERRNAME :$res:
1722 echo ' #2'
1723 vput vexpr res substring 'bananarama' 1
1724 echo $?/$^ERRNAME :$res:
1725 vput vexpr res substring 'bananarama' 3
1726 echo $?/$^ERRNAME :$res:
1727 vput vexpr res substring 'bananarama' 5
1728 echo $?/$^ERRNAME :$res:
1729 vput vexpr res substring 'bananarama' 7
1730 echo $?/$^ERRNAME :$res:
1731 vput vexpr res substring 'bananarama' 9
1732 echo $?/$^ERRNAME :$res:
1733 vput vexpr res substring 'bananarama' 10
1734 echo $?/$^ERRNAME :$res:
1735 vput vexpr res substring 'bananarama' 1 3
1736 echo $?/$^ERRNAME :$res:
1737 vput vexpr res substring 'bananarama' 3 3
1738 echo $?/$^ERRNAME :$res:
1739 vput vexpr res substring 'bananarama' 5 3
1740 echo $?/$^ERRNAME :$res:
1741 vput vexpr res substring 'bananarama' 7 3
1742 echo $?/$^ERRNAME :$res:
1743 vput vexpr res substring 'bananarama' 9 3
1744 echo $?/$^ERRNAME :$res:
1745 vput vexpr res substring 'bananarama' 10 3
1746 echo $?/$^ERRNAME :$res:
1747 echo ' #3'
1748 __EOT
1750 check behave:vexpr-string 0 "${MBOX}" '265398700 267'
1752 if have_feat regex; then
1753 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" #2>/dev/null
1754 vput vexpr res regex 'bananarama' 'nana'
1755 echo $?/$^ERRNAME :$res:
1756 vput vexpr res regex 'bananarama' 'bana'
1757 echo $?/$^ERRNAME :$res:
1758 vput vexpr res regex 'bananarama' 'Bana'
1759 echo $?/$^ERRNAME :$res:
1760 vput vexpr res regex 'bananarama' 'rama'
1761 echo $?/$^ERRNAME :$res:
1762 echo ' #1'
1763 vput vexpr res iregex 'bananarama' 'nana'
1764 echo $?/$^ERRNAME :$res:
1765 vput vexpr res iregex 'bananarama' 'bana'
1766 echo $?/$^ERRNAME :$res:
1767 vput vexpr res iregex 'bananarama' 'Bana'
1768 echo $?/$^ERRNAME :$res:
1769 vput vexpr res iregex 'bananarama' 'rama'
1770 echo $?/$^ERRNAME :$res:
1771 echo ' #2'
1772 vput vexpr res regex 'bananarama' '(.*)nana(.*)' '\${1}a\${0}u{\$2}'
1773 echo $?/$^ERRNAME :$res:
1774 vput vexpr res regex 'bananarama' '(.*)bana(.*)' '\${1}a\${0}u\$2'
1775 echo $?/$^ERRNAME :$res:
1776 vput vexpr res regex 'bananarama' 'Bana(.+)' '\$1\$0'
1777 echo $?/$^ERRNAME :$res:
1778 vput vexpr res regex 'bananarama' '(.+)rama' '\$1\$0'
1779 echo $?/$^ERRNAME :$res:
1780 echo ' #3'
1781 vput vexpr res iregex 'bananarama' '(.*)nana(.*)' '\${1}a\${0}u{\$2}'
1782 echo $?/$^ERRNAME :$res:
1783 vput vexpr res iregex 'bananarama' '(.*)bana(.*)' '\${1}a\${0}u\$2'
1784 echo $?/$^ERRNAME :$res:
1785 vput vexpr res iregex 'bananarama' 'Bana(.+)' '\$1\$0'
1786 echo $?/$^ERRNAME :$res:
1787 vput vexpr res iregex 'bananarama' '(.+)rama' '\$1\$0'
1788 echo $?/$^ERRNAME :$res:
1789 echo ' #4'
1790 __EOT
1792 check behave:vexpr-regex 0 "${MBOX}" '3270360157 311'
1793 else
1794 printf 'behave:vexpr-regex: unsupported, skipped\n'
1797 t_epilog
1800 t_behave_call_ret() {
1801 t_prolog
1803 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Snomemdebug > "${MBOX}" 2>&1
1804 define w1 {
1805 echon ">$1 "
1806 vput vexpr i + $1 1
1807 if [ $i -le 42 ]
1808 vput vexpr j '&' $i 7
1809 if [ $j -eq 7 ]
1810 echo .
1812 call w1 $i
1813 wysh set i=$? k=$!
1814 vput vexpr j '&' $i 7
1815 echon "<$1/$i/$k "
1816 if [ $j -eq 7 ]
1817 echo .
1819 else
1820 echo ! The end for $1
1822 return $1
1824 # Transport $?/$! up the call chain
1825 define w2 {
1826 echon ">$1 "
1827 vput vexpr i + $1 1
1828 if [ $1 -lt 42 ]
1829 call w2 $i
1830 wysh set i=$? j=$! k=$^ERRNAME
1831 echon "<$1/$i/$k "
1832 return $i $j
1833 else
1834 echo ! The end for $1
1835 return $i $^ERR-BUSY
1837 echoerr au
1839 # Up and down it goes
1840 define w3 {
1841 echon ">$1/$2 "
1842 vput vexpr i + $1 1
1843 if [ $1 -lt 42 ]
1844 call w3 $i $2
1845 wysh set i=$? j=$!
1846 vput vexpr k - $1 $2
1847 if [ $k -eq 21 ]
1848 vput vexpr i + $1 1
1849 vput vexpr j + $2 1
1850 echo "# <$i/$j> .. "
1851 call w3 $i $j
1852 wysh set i=$? j=$!
1854 eval echon "<\$1=\$i/\$^ERRNAME-$j "
1855 return $i $j
1856 else
1857 echo ! The end for $1=$i/$2
1858 if [ "$2" != "" ]
1859 return $i $^ERR-DOM
1860 else
1861 return $i $^ERR-BUSY
1864 echoerr au
1867 call w1 0; echo ?=$? !=$!; echo -----;
1868 call w2 0; echo ?=$? !=$^ERRNAME; echo -----;
1869 call w3 0 1; echo ?=$? !=$^ERRNAME; echo -----;
1870 __EOT
1872 check behave:call_ret 0 "${MBOX}" '1572045517 5922'
1874 t_epilog
1877 t_behave_xcall() {
1878 t_prolog
1880 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Snomemdebug > "${MBOX}" 2>&1
1881 define work {
1882 echon "$1 "
1883 vput vexpr i + $1 1
1884 if [ $i -le 1111 ]
1885 vput vexpr j '&' $i 7
1886 if [ $j -eq 7 ]
1887 echo .
1889 \xcall work $i $2
1891 echo ! The end for $1/$2
1892 if [ "$2" != "" ]
1893 return $i $^ERR-BUSY
1896 define xwork {
1897 \xcall work 0 $2
1899 call work 0
1900 echo ?=$? !=$!
1901 call xwork
1902 echo ?=$? !=$!
1903 xcall xwork
1904 echo ?=$? !=$^ERRNAME
1906 call work 0 yes
1907 echo ?=$? !=$^ERRNAME
1908 call xwork 0 yes
1909 echo ?=$? !=$^ERRNAME
1910 __EOT
1912 check behave:xcall-1 0 "${MBOX}" '2401702082 23801'
1916 ${cat} <<- '__EOT' > "${BODY}"
1917 define __w {
1918 echon "$1 "
1919 vput vexpr i + $1 1
1920 if [ $i -le 111 ]
1921 vput vexpr j '&' $i 7
1922 if [ $j -eq 7 ]
1923 echo .
1925 \xcall __w $i $2
1927 echo ! The end for $1
1928 if [ $2 -eq 0 ]
1929 nonexistingcommand
1930 echo would be err with errexit
1931 return
1933 echo calling exit
1934 exit
1936 define work {
1937 echo eins
1938 call __w 0 0
1939 echo zwei, ?=$? !=$!
1940 localopts yes; set errexit
1941 ignerr call __w 0 0
1942 echo drei, ?=$? !=$^ERRNAME
1943 call __w 0 $1
1944 echo vier, ?=$? !=$^ERRNAME, this is an error
1946 ignerr call work 0
1947 echo outer 1, ?=$? !=$^ERRNAME
1948 xxxign call work 0
1949 echo outer 2, ?=$? !=$^ERRNAME, could be error if xxxign non-empty
1950 call work 1
1951 echo outer 3, ?=$? !=$^ERRNAME
1952 echo this is definitely an error
1953 __EOT
1955 < "${BODY}" ${MAILX} ${ARGS} -X'commandalias xxxign ignerr' -Snomemdebug \
1956 > "${MBOX}" 2>&1
1957 check behave:xcall-2 0 "${MBOX}" '3900716531 4200'
1959 < "${BODY}" ${MAILX} ${ARGS} -X'commandalias xxxign " "' -Snomemdebug \
1960 > "${MBOX}" 2>&1
1961 check behave:xcall-3 1 "${MBOX}" '1006776201 2799'
1963 t_epilog
1966 t_behave_vpospar() {
1967 t_prolog
1969 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
1970 vpospar set hey, "'you ", world!
1971 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1972 vput vpospar x quote; echo x<$x>
1973 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1974 vput vpospar y quote;echo y<$y>
1975 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1976 eval vpospar set ${y};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1977 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1979 define infun2 {
1980 echo infun2:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
1981 vput vpospar z quote;echo infun2:z<$z>
1984 define infun {
1985 echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
1986 vput vpospar y quote;echo infun:y<$y>
1987 eval vpospar set ${x};echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
1988 vpospar clear;echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
1989 eval call infun2 $x
1990 echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
1991 eval vpospar set ${y};echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
1994 call infun This "in a" fun
1995 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1996 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1997 __EOT
1998 check behave:vpospar-1 0 "${MBOX}" '155175639 866'
2001 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
2002 set ifs=\'
2003 echo ifs<$ifs> ifs-ws<$ifs-ws>
2004 vpospar set hey, "'you ", world!
2005 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2006 vput vpospar x quote; echo x<$x>
2007 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2008 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2010 set ifs=,
2011 echo ifs<$ifs> ifs-ws<$ifs-ws>
2012 vpospar set hey, "'you ", world!
2013 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2014 vput vpospar x quote; echo x<$x>
2015 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2016 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2018 wysh set ifs=$',\t'
2019 echo ifs<$ifs> ifs-ws<$ifs-ws>
2020 vpospar set hey, "'you ", world!
2021 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2022 vput vpospar x quote; echo x<$x>
2023 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2024 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2025 __EOT
2026 check behave:vpospar-ifs 0 "${MBOX}" '2015927702 706'
2028 t_epilog
2031 t_behave_atxplode() {
2032 t_prolog
2033 TRAP_EXIT_ADDONS="./.t*"
2035 ${cat} > ./.t.sh <<- '___'; ${cat} > ./.t.rc <<- '___'
2036 x() { echo $#; }
2037 xxx() {
2038 printf " (1/$#: <$1>)"
2039 shift
2040 if [ $# -gt 0 ]; then
2041 xxx "$@"
2042 else
2043 echo
2046 yyy() {
2047 eval "$@ ' ball"
2049 set --
2050 x "$@"
2051 x "$@"''
2052 x " $@"
2053 x "$@ "
2054 printf yyy;yyy 'xxx' "b\$'\t'u ' "
2055 printf xxx;xxx arg ,b u.
2056 printf xxx;xxx arg , .
2057 printf xxx;xxx arg ,ball.
2059 define x {
2060 echo $#
2062 define xxx {
2063 echon " (1/$#: <$1>)"
2064 shift
2065 if [ $# -gt 0 ]
2066 \xcall xxx "$@"
2067 endif
2068 echo
2070 define yyy {
2071 eval "$@ ' ball"
2073 vpospar set
2074 call x "$@"
2075 call x "$@"''
2076 call x " $@"
2077 call x "$@ "
2078 echon yyy;call yyy '\call xxx' "b\$'\t'u ' "
2079 echon xxx;call xxx arg ,b u.
2080 echon xxx;call xxx arg , .
2081 echon xxx;call xxx arg ,ball.
2084 ${MAILX} ${ARGS} -X'source ./.t.rc' -Xx > "${MBOX}" 2>&1
2085 check behave:atxplode-1 0 "${MBOX}" '41566293 164'
2087 #${SHELL} ./.t.sh > ./.tshout 2>&1
2088 #check behave:atxplode:disproof-1 0 ./.tshout '41566293 164'
2090 t_epilog
2093 t_behave_read() {
2094 t_prolog
2095 TRAP_EXIT_ADDONS="./.t*"
2097 ${cat} <<- '__EOT' > .tin
2098 hey1, "'you ", world!
2099 hey2, "'you ", bugs bunny!
2100 hey3, "'you ",
2101 hey4, "'you "
2102 __EOT
2104 ${cat} <<- '__EOT' |\
2105 ${MAILX} ${ARGS} -X'readctl create ./.tin' > "${MBOX}" 2>&1
2106 read a b c
2107 echo $?/$^ERRNAME / <$a><$b><$c>
2108 read a b c
2109 echo $?/$^ERRNAME / <$a><$b><$c>
2110 read a b c
2111 echo $?/$^ERRNAME / <$a><$b><$c>
2112 read a b c
2113 echo $?/$^ERRNAME / <$a><$b><$c>
2114 read a b c
2115 echo $?/$^ERRNAME / <$a><$b><$c>
2116 readctl remove ./.tin;echo readctl remove:$?/$^ERRNAME
2117 __EOT
2118 check behave:read-1 0 "${MBOX}" '1527910147 173'
2120 ${cat} <<- '__EOT' > .tin2
2121 hey2.0,:"'you ",:world!:mars.:
2122 hey2.1,:"'you ",:world!
2123 hey2.2,:"'you ",:bugs bunny!
2124 hey2.3,:"'you ",:
2125 hey2.4,:"'you ":
2127 __EOT
2129 ${cat} <<- '__EOT' |\
2130 6< .tin2 ${MAILX} ${ARGS} -X 'readctl create 6' > "${MBOX}" 2>&1
2131 set ifs=:
2132 read a b c
2133 echo $?/$^ERRNAME / <$a><$b><$c>
2134 read a b c
2135 echo $?/$^ERRNAME / <$a><$b><$c>
2136 read a b c
2137 echo $?/$^ERRNAME / <$a><$b><$c>
2138 read a b c
2139 echo $?/$^ERRNAME / <$a><$b><$c>
2140 read a b c
2141 echo $?/$^ERRNAME / <$a><$b><$c>
2142 read a b c
2143 echo $?/$^ERRNAME / <$a><$b><$c>
2144 read a b c
2145 echo $?/$^ERRNAME / <$a><$b><$c>
2146 read a b c
2147 echo $?/$^ERRNAME / <$a><$b><$c>
2148 readctl remove 6;echo readctl remove:$?/$^ERRNAME
2149 __EOT
2150 check behave:read-ifs 0 "${MBOX}" '890153490 298'
2152 t_epilog
2155 t_behave_mbox() {
2156 t_prolog
2157 TRAP_EXIT_ADDONS="./.t*"
2161 while [ ${i} -lt 112 ]; do
2162 printf 'm file://%s\n~s Subject %s\nHello %s!\n~.\n' \
2163 "${MBOX}" "${i}" "${i}"
2164 i=`add ${i} 1`
2165 done
2166 ) | ${MAILX} ${ARGS}
2167 check behave:mbox-1 0 "${MBOX}" '1140119864 13780'
2169 printf 'File "%s"
2170 copy * "%s"
2171 File "%s"
2172 from*
2173 ' "${MBOX}" .tmbox1 .tmbox1 |
2174 ${MAILX} ${ARGS} > .tlst
2175 check behave:mbox-2 0 .tlst '2739893312 9103'
2177 printf 'File "%s"
2178 copy * "file://%s"
2179 File "file://%s"
2180 from*
2181 ' "${MBOX}" .tmbox2 .tmbox2 |
2182 ${MAILX} ${ARGS} > .tlst
2183 check behave:mbox-3 0 .tlst '1702194178 9110'
2185 # only the odd (even)
2187 printf 'File "file://%s"
2188 copy ' .tmbox2
2190 while [ ${i} -lt 112 ]; do
2191 j=`modulo ${i} 2`
2192 [ ${j} -eq 1 ] && printf '%s ' "${i}"
2193 i=`add ${i} 1`
2194 done
2195 printf ' file://%s
2196 File "file://%s"
2197 from*
2198 ' .tmbox3 .tmbox3
2199 ) | ${MAILX} ${ARGS} > .tlst
2200 check behave:mbox-4 0 .tmbox3 '631132924 6890'
2201 check behave:mbox-5 - .tlst '2960975049 4573'
2202 # ...
2204 printf 'file "file://%s"
2205 move ' .tmbox2
2207 while [ ${i} -lt 112 ]; do
2208 j=`modulo ${i} 2`
2209 [ ${j} -eq 0 ] && [ ${i} -ne 0 ] && printf '%s ' "${i}"
2210 i=`add ${i} 1`
2211 done
2212 printf ' file://%s
2213 File "file://%s"
2214 from*
2215 File "file://%s"
2216 from*
2217 ' .tmbox3 .tmbox3 .tmbox2
2218 ) | ${MAILX} ${ARGS} > .tlst
2219 check behave:mbox-6 0 .tmbox3 '1387070539 13655'
2220 ${sed} 2d < .tlst > .tlstx
2221 check behave:mbox-7 - .tlstx '2729940494 13645'
2223 t_epilog
2226 t_behave_alternates() {
2227 t_prolog
2228 TRAP_EXIT_ADDONS="./.t*"
2230 ${cat} <<-_EOT > ./.tsendmail.sh
2231 #!${MYSHELL} -
2232 (echo 'From Valeriana Sat Jul 08 15:54:03 2017' && ${cat} && echo
2233 ) >> "${MBOX}"
2234 _EOT
2235 chmod 0755 ./.tsendmail.sh
2237 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Smta=./.tsendmail.sh > ./.tall 2>&1
2238 echo --0
2239 alternates
2240 echo $?/$^ERRNAME
2241 alternates a1@b1 a2@b2 a3@b3
2242 echo $?/$^ERRNAME
2243 alternates
2244 echo $?/$^ERRNAME
2245 vput alternates rv
2246 echo $?/$^ERRNAME <$rv>
2248 echo --1
2249 unalternates a2@b2
2250 vput alternates rv
2251 echo $?/$^ERRNAME <$rv>
2252 unalternates a3@b3
2253 vput alternates rv
2254 echo $?/$^ERRNAME <$rv>
2255 unalternates a1@b1
2256 vput alternates rv
2257 echo $?/$^ERRNAME <$rv>
2259 echo --2
2260 unalternates *
2261 alternates a1@b1 a2@b2 a3@b3
2262 unalternates a3@b3
2263 vput alternates rv
2264 echo $?/$^ERRNAME <$rv>
2265 unalternates a2@b2
2266 vput alternates rv
2267 echo $?/$^ERRNAME <$rv>
2268 unalternates a1@b1
2269 vput alternates rv
2270 echo $?/$^ERRNAME <$rv>
2272 echo --3
2273 alternates a1@b1 a2@b2 a3@b3
2274 unalternates a1@b1
2275 vput alternates rv
2276 echo $?/$^ERRNAME <$rv>
2277 unalternates a2@b2
2278 vput alternates rv
2279 echo $?/$^ERRNAME <$rv>
2280 unalternates a3@b3
2281 vput alternates rv
2282 echo $?/$^ERRNAME <$rv>
2284 echo --4
2285 unalternates *
2286 alternates a1@b1 a2@b2 a3@b3
2287 unalternates *
2288 vput alternates rv
2289 echo $?/$^ERRNAME <$rv>
2291 echo --5
2292 unalternates *
2293 alternates a1@b1 a1@c1 a1@d1 a2@b2 a3@b3 a3@c3 a3@d3
2294 m a1@b1 a1@c1 a1@d1
2295 ~s all alternates, only a1@b1 remains
2296 ~c a2@b2
2297 ~b a3@b3 a3@c3 a3@d3
2298 ~r - '_EOT'
2299 This body is!
2300 This also body is!!
2301 _EOT
2304 echo --6
2305 unalternates *
2306 alternates a1@b1 a1@c1 a2@b2 a3@b3
2307 m a1@b1 a1@c1 a1@d1
2308 ~s a1@b1 a1@d1, and a3@c3 a3@d3 remain
2309 ~c a2@b2
2310 ~b a3@b3 a3@c3 a3@d3
2311 ~r - '_EOT'
2312 This body2 is!
2313 _EOT
2316 echo --7
2317 alternates a1@b1 a2@b2 a3; set allnet
2318 m a1@b1 a1@c1 a1@d1
2319 ~s all alternates via allnet, only a1@b1 remains
2320 ~c a2@b2
2321 ~b a3@b3 a3@c3 a3@d3
2322 ~r - '_EOT'
2323 This body3 is!
2324 _EOT
2327 echo --10
2328 unalternates *
2329 alternates a1@b1
2330 echo $?/$^ERRNAME
2331 vput alternates rv
2332 echo $?/$^ERRNAME <$rv>
2333 alternates a2@b2
2334 echo $?/$^ERRNAME
2335 vput alternates rv
2336 echo $?/$^ERRNAME <$rv>
2337 alternates a3@b3
2338 echo $?/$^ERRNAME
2339 vput alternates rv
2340 echo $?/$^ERRNAME <$rv>
2341 alternates a4@b4
2342 echo $?/$^ERRNAME
2343 vput alternates rv
2344 echo $?/$^ERRNAME <$rv>
2346 unalternates *
2347 vput alternates rv
2348 echo $?/$^ERRNAME <$rv>
2350 echo --11
2351 set posix
2352 alternates a1@b1 a2@b2
2353 echo $?/$^ERRNAME
2354 vput alternates rv
2355 echo $?/$^ERRNAME <$rv>
2356 alternates a3@b3 a4@b4
2357 echo $?/$^ERRNAME
2358 vput alternates rv
2359 echo $?/$^ERRNAME <$rv>
2360 __EOT
2361 check behave:alternates-1 0 "${MBOX}" '142184864 515'
2362 check behave:alternates-2 - .tall '1878598364 505'
2364 t_epilog
2367 t_behave_alias() {
2368 t_prolog
2369 TRAP_EXIT_ADDONS="./.t*"
2371 ${cat} <<-_EOT > ./.tsendmail.sh
2372 #!${MYSHELL} -
2373 (echo 'From Hippocastanum Mon Jun 19 15:07:07 2017' && ${cat} && echo
2374 ) >> "${MBOX}"
2375 _EOT
2376 chmod 0755 ./.tsendmail.sh
2378 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Smta=./.tsendmail.sh > ./.tall 2>&1
2379 alias a1 ex1@a1.ple
2380 alias a1 ex2@a1.ple "EX3 <ex3@a1.ple>"
2381 alias a1 ex4@a1.ple
2382 alias a2 ex1@a2.ple ex2@a2.ple ex3@a2.ple ex4@a2.ple
2383 alias a3 a4
2384 alias a4 a5 ex1@a4.ple
2385 alias a5 a6
2386 alias a6 a7 ex1@a6.ple
2387 alias a7 a8
2388 alias a8 ex1@a8.ple
2389 alias a1
2390 alias a2
2391 alias a3
2392 m a1
2393 ~c a2
2394 ~b a3
2395 ~r - '_EOT'
2396 This body is!
2397 This also body is!!
2398 _EOT
2399 __EOT
2400 check behave:alias-1 0 "${MBOX}" '2496925843 272'
2401 check behave:alias-2 - .tall '3548953204 152'
2403 # TODO t_behave_alias: n_ALIAS_MAXEXP is compile-time constant,
2404 # TODO need to somehow provide its contents to the test, then test
2406 t_epilog
2409 t_behave_filetype() {
2410 t_prolog
2411 TRAP_EXIT_ADDONS="./.t*"
2413 ${cat} <<-_EOT > ./.tsendmail.sh
2414 #!${MYSHELL} -
2415 (echo 'From Alchemilla Wed Apr 25 15:12:13 2017' && ${cat} && echo
2416 ) >> "${MBOX}"
2417 _EOT
2418 chmod 0755 ./.tsendmail.sh
2420 printf 'm m1@e.t\nL1\nHy1\n~.\nm m2@e.t\nL2\nHy2\n~@ ./snailmail.jpg\n~.\n' |
2421 ${MAILX} ${ARGS} -Smta=./.tsendmail.sh
2422 check behave:filetype-1 0 "${MBOX}" '1645747150 13536'
2424 if command -v gzip >/dev/null 2>&1; then
2425 ${rm} -f ./.t.mbox*
2427 printf 'File "%s"\ncopy 1 ./.t.mbox.gz
2428 copy 2 ./.t.mbox.gz' "${MBOX}" |
2429 ${MAILX} ${ARGS} \
2430 -X'filetype gz gzip\ -dc gzip\ -c'
2431 printf 'File ./.t.mbox.gz\ncopy * ./.t.mbox\n' |
2432 ${MAILX} ${ARGS} \
2433 -X'filetype gz gzip\ -dc gzip\ -c'
2434 } >/dev/null 2>&1
2435 check behave:filetype-2 0 "./.t.mbox" '1645747150 13536'
2436 else
2437 echo 'behave:filetype-2: unsupported, skipped'
2441 ${rm} -f ./.t.mbox*
2442 printf 'File "%s"\ncopy 1 ./.t.mbox.gz
2443 copy 2 ./.t.mbox.gz
2444 copy 1 ./.t.mbox.gz
2445 copy 2 ./.t.mbox.gz
2446 ' "${MBOX}" |
2447 ${MAILX} ${ARGS} \
2448 -X'filetype gz gzip\ -dc gzip\ -c' \
2449 -X'filetype mbox.gz "${sed} 1,3d|${cat}" \
2450 "echo eins;echo zwei;echo und mit ${sed} bist Du dabei;${cat}"'
2451 printf 'File ./.t.mbox.gz\ncopy * ./.t.mbox\n' |
2452 ${MAILX} ${ARGS} \
2453 -X'filetype gz gzip\ -dc gzip\ -c' \
2454 -X'filetype mbox.gz "${sed} 1,3d|${cat}" kill\ 0'
2455 } >/dev/null 2>&1
2457 check behave:filetype-3 - "./.t.mbox" '238021003 27092'
2459 t_epilog
2462 t_behave_record_a_resend() {
2463 t_prolog
2464 TRAP_EXIT_ADDONS="./.t.record ./.t.resent"
2466 printf '
2467 set record=%s
2468 m %s\n~s Subject 1.\nHello.\n~.
2469 set record-files add-file-recipients
2470 m %s\n~s Subject 2.\nHello.\n~.
2471 File %s
2472 resend 2 ./.t.resent
2473 Resend 1 ./.t.resent
2474 set record-resent
2475 resend 2 ./.t.resent
2476 Resend 1 ./.t.resent
2477 ' ./.t.record "${MBOX}" "${MBOX}" "${MBOX}" |
2478 ${MAILX} ${ARGS}
2480 check behave:record_a_resend-1 0 "${MBOX}" '3057873538 256'
2481 check behave:record_a_resend-2 - .t.record '391356429 460'
2482 check behave:record_a_resend-3 - .t.resent '2685231691 648'
2484 t_epilog
2487 t_behave_e_H_L_opts() {
2488 t_prolog
2489 TRAP_EXIT_ADDONS="./.tsendmail.sh ./.t.mbox"
2491 touch ./.t.mbox
2492 ${MAILX} ${ARGS} -ef ./.t.mbox
2493 echo ${?} > "${MBOX}"
2495 ${cat} <<-_EOT > ./.tsendmail.sh
2496 #!${MYSHELL} -
2497 (echo 'From Alchemilla Wed Apr 07 17:03:33 2017' && ${cat} && echo
2498 ) >> "./.t.mbox"
2499 _EOT
2500 chmod 0755 ./.tsendmail.sh
2501 printf 'm me@exam.ple\nLine 1.\nHello.\n~.\n' |
2502 ${MAILX} ${ARGS} -Smta=./.tsendmail.sh
2503 printf 'm you@exam.ple\nLine 1.\nBye.\n~.\n' |
2504 ${MAILX} ${ARGS} -Smta=./.tsendmail.sh
2506 ${MAILX} ${ARGS} -ef ./.t.mbox
2507 echo ${?} >> "${MBOX}"
2508 ${MAILX} ${ARGS} -efL @t@me ./.t.mbox
2509 echo ${?} >> "${MBOX}"
2510 ${MAILX} ${ARGS} -efL @t@you ./.t.mbox
2511 echo ${?} >> "${MBOX}"
2512 ${MAILX} ${ARGS} -efL '@>@Line 1' ./.t.mbox
2513 echo ${?} >> "${MBOX}"
2514 ${MAILX} ${ARGS} -efL '@>@Hello.' ./.t.mbox
2515 echo ${?} >> "${MBOX}"
2516 ${MAILX} ${ARGS} -efL '@>@Bye.' ./.t.mbox
2517 echo ${?} >> "${MBOX}"
2518 ${MAILX} ${ARGS} -efL '@>@Good bye.' ./.t.mbox
2519 echo ${?} >> "${MBOX}"
2521 ${MAILX} ${ARGS} -fH ./.t.mbox >> "${MBOX}"
2522 echo ${?} >> "${MBOX}"
2523 ${MAILX} ${ARGS} -fL @t@me ./.t.mbox >> "${MBOX}"
2524 echo ${?} >> "${MBOX}"
2525 ${MAILX} ${ARGS} -fL @t@you ./.t.mbox >> "${MBOX}"
2526 echo ${?} >> "${MBOX}"
2527 ${MAILX} ${ARGS} -fL '@>@Line 1' ./.t.mbox >> "${MBOX}"
2528 echo ${?} >> "${MBOX}"
2529 ${MAILX} ${ARGS} -fL '@>@Hello.' ./.t.mbox >> "${MBOX}"
2530 echo ${?} >> "${MBOX}"
2531 ${MAILX} ${ARGS} -fL '@>@Bye.' ./.t.mbox >> "${MBOX}"
2532 echo ${?} >> "${MBOX}"
2533 ${MAILX} ${ARGS} -fL '@>@Good bye.' ./.t.mbox >> "${MBOX}" 2>/dev/null
2534 echo ${?} >> "${MBOX}"
2536 check behave:e_H_L_opts - "${MBOX}" '1708955574 678'
2538 t_epilog
2541 t_behave_compose_hooks() { # TODO monster
2542 t_prolog
2543 TRAP_EXIT_ADDONS="./.t*"
2545 (echo line one&&echo line two&&echo line three) > ./.treadctl
2546 (echo echo four&&echo echo five&&echo echo six) > ./.tattach
2548 ${cat} <<-_EOT > ./.tsendmail.sh
2549 #!${MYSHELL} -
2550 (echo 'From PrimulaVeris Wed Apr 10 22:59:00 2017' && ${cat} && echo
2551 ) >> "${MBOX}"
2552 _EOT
2553 chmod 0755 ./.tsendmail.sh
2555 ${cat} <<'__EOT__' > ./.trc
2556 define bail {
2557 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
2559 define xerr {
2560 vput vexpr es substr "$1" 0 1
2561 if [ "$es" != 2 ]
2562 xcall bail "$2"
2565 define read_mline_res {
2566 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
2567 echo $len/$es/$^ERRNAME: $hl
2568 if [ $es -ne $^ERR-NONE ]
2569 xcall bail read_mline_res
2570 elif [ $len -ne 0 ]
2571 \xcall read_mline_res
2574 define ins_addr {
2575 wysh set xh=$1
2576 echo "~^header list"; read hl; echo $hl;\
2577 call xerr "$hl" "in_addr ($xh) 0-1"
2579 echo "~^header insert $xh diet <$xh@exam.ple> spliced";\
2580 read es; echo $es; call xerr "$es" "ins_addr $xh 1-1"
2581 echo "~^header insert $xh <${xh}2@exam.ple>";\
2582 read es; echo $es; call xerr "$es" "ins_addr $xh 1-2"
2583 echo "~^header insert $xh ${xh}3@exam.ple";\
2584 read es; echo $es; call xerr "$es" "ins_addr $xh 1-3"
2585 echo "~^header list $xh"; read hl; echo $hl;\
2586 call xerr "$hl" "ins_addr $xh 1-4"
2587 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 1-5"
2588 call read_mline_res
2590 if [ "$t_remove" == "" ]
2591 return
2594 echo "~^header remove $xh"; read es; call xerr $es "ins_addr $xh 2-1"
2595 echo "~^header remove $xh"; read es; vput vexpr es substr $es 0 3
2596 if [ $es != 501 ]
2597 xcall bail "ins_addr $xh 2-2"
2599 echo "~^header list $xh"; read es; vput vexpr es substr $es 0 3
2600 if [ $es != 501 ]
2601 xcall bail "ins_addr $xh 2-3"
2603 echo "~^header show $xh"; read es; vput vexpr es substr $es 0 3
2604 if [ $es != 501 ]
2605 xcall bail "ins_addr $xh 2-4"
2609 echo "~^header insert $xh diet <$xh@exam.ple> spliced";\
2610 read es; echo $es; call xerr "$es" "ins_addr $xh 3-1"
2611 echo "~^header insert $xh <${xh}2@exam.ple>";\
2612 read es; echo $es; call xerr "$es" "ins_addr $xh 3-2"
2613 echo "~^header insert $xh ${xh}3@exam.ple";\
2614 read es; echo $es; call xerr "$es" "ins_addr $xh 3-3"
2615 echo "~^header list $xh"; read hl; echo $hl;\
2616 call xerr "$hl" "ins_addr $xh 3-4"
2617 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 3-5"
2618 call read_mline_res
2620 echo "~^header remove-at $xh 1"; read es;\
2621 call xerr $es "ins_addr $xh 3-6"
2622 echo "~^header remove-at $xh 1"; read es;\
2623 call xerr $es "ins_addr $xh 3-7"
2624 echo "~^header remove-at $xh 1"; read es;\
2625 call xerr $es "ins_addr $xh 3-8"
2626 echo "~^header remove-at $xh 1"; read es;\
2627 vput vexpr es substr $es 0 3
2628 if [ $es != 501 ]
2629 xcall bail "ins_addr $xh 3-9"
2631 echo "~^header remove-at $xh T"; read es;\
2632 vput vexpr es substr $es 0 3
2633 if [ $es != 505 ]
2634 xcall bail "ins_addr $xh 3-10"
2636 echo "~^header list $xh"; read es;\
2637 vput vexpr es substr $es 0 3
2638 if [ $es != 501 ]
2639 xcall bail "ins_addr $xh 3-11"
2641 echo "~^header show $xh"; read es;\
2642 vput vexpr es substr $es 0 3
2643 if [ $es != 501 ]
2644 xcall bail "ins_addr $xh 3-12"
2648 echo "~^header insert $xh diet <$xh@exam.ple> spliced";\
2649 read es; echo $es; call xerr "$es" "ins_addr $xh 4-1"
2650 echo "~^header insert $xh <${xh}2@exam.ple> (comment) \"Quot(e)d\"";\
2651 read es; echo $es; call xerr "$es" "ins_addr $xh 4-2"
2652 echo "~^header insert $xh ${xh}3@exam.ple";\
2653 read es; echo $es; call xerr "$es" "ins_addr $xh 4-3"
2654 echo "~^header list $xh"; read hl; echo $hl;\
2655 call xerr "$hl" "header list $xh 3-4"
2656 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 4-5"
2657 call read_mline_res
2659 echo "~^header remove-at $xh 3"; read es;\
2660 call xerr $es "ins_addr $xh 4-6"
2661 echo "~^header remove-at $xh 2"; read es;\
2662 call xerr $es "ins_addr $xh 4-7"
2663 echo "~^header remove-at $xh 1"; read es;\
2664 call xerr $es "ins_addr $xh 4-8"
2665 echo "~^header remove-at $xh 1"; read es;\
2666 vput vexpr es substr $es 0 3
2667 if [ $es != 501 ]
2668 xcall bail "ins_addr $xh 4-9"
2670 echo "~^header remove-at $xh T"; read es;\
2671 vput vexpr es substr $es 0 3
2672 if [ $es != 505 ]
2673 xcall bail "ins_addr $xh 4-10"
2675 echo "~^header list $xh"; read es;\
2676 vput vexpr es substr $es 0 3
2677 if [ $es != 501 ]
2678 xcall bail "ins_addr $xh 4-11"
2680 echo "~^header show $xh"; read es;\
2681 vput vexpr es substr $es 0 3
2682 if [ $es != 501 ]
2683 xcall bail "ins_addr $xh 4-12"
2686 define ins_ref {
2687 wysh set xh=$1 mult=$2
2688 echo "~^header list"; read hl; echo $hl;\
2689 call xerr "$hl" "ins_ref ($xh) 0-1"
2691 echo "~^header insert $xh <$xh@exam.ple>";\
2692 read es; echo $es; call xerr "$es" "ins_ref $xh 1-1"
2693 if [ $mult -ne 0 ]
2694 echo "~^header insert $xh <${xh}2@exam.ple>";\
2695 read es; echo $es; call xerr "$es" "ins_ref $xh 1-2"
2696 echo "~^header insert $xh ${xh}3@exam.ple";\
2697 read es; echo $es; call xerr "$es" "ins_ref $xh 1-3"
2698 else
2699 echo "~^header insert $xh <${xh}2@exam.ple>"; read es;\
2700 vput vexpr es substr $es 0 3
2701 if [ $es != 506 ]
2702 xcall bail "ins_ref $xh 1-4"
2706 echo "~^header list $xh"; read hl; echo $hl;\
2707 call xerr "$hl" "ins_ref $xh 1-5"
2708 echo "~^header show $xh"; read es; call xerr $es "ins_ref $xh 1-6"
2709 call read_mline_res
2711 if [ "$t_remove" == "" ]
2712 return
2715 echo "~^header remove $xh"; read es;\
2716 call xerr $es "ins_ref $xh 2-1"
2717 echo "~^header remove $xh"; read es;\
2718 vput vexpr es substr $es 0 3
2719 if [ $es != 501 ]
2720 xcall bail "ins_ref $xh 2-2"
2722 echo "~^header list $xh"; read es;\
2723 vput vexpr es substr $es 0 3
2724 if [ $es != 501 ]
2725 xcall bail "$es ins_ref $xh 2-3"
2727 echo "~^header show $xh"; read es;\
2728 vput vexpr es substr $es 0 3
2729 if [ $es != 501 ]
2730 xcall bail "ins_ref $xh 2-4"
2734 echo "~^header insert $xh <$xh@exam.ple>";\
2735 read es; echo $es; call xerr "$es" "ins_ref $xh 3-1"
2736 if [ $mult -ne 0 ]
2737 echo "~^header insert $xh <${xh}2@exam.ple>";\
2738 read es; echo $es; call xerr "$es" "ins_ref $xh 3-2"
2739 echo "~^header insert $xh ${xh}3@exam.ple";\
2740 read es; echo $es; call xerr "$es" "ins_ref $xh 3-3"
2742 echo "~^header list $xh";\
2743 read hl; echo $hl; call xerr "$hl" "ins_ref $xh 3-4"
2744 echo "~^header show $xh";\
2745 read es; call xerr $es "ins_ref $xh 3-5"
2746 call read_mline_res
2748 echo "~^header remove-at $xh 1"; read es;\
2749 call xerr $es "ins_ref $xh 3-6"
2750 if [ $mult -ne 0 ] && [ $xh != subject ]
2751 echo "~^header remove-at $xh 1"; read es;\
2752 call xerr $es "ins_ref $xh 3-7"
2753 echo "~^header remove-at $xh 1"; read es;\
2754 call xerr $es "ins_ref $xh 3-8"
2756 echo "~^header remove-at $xh 1"; read es;\
2757 vput vexpr es substr $es 0 3
2758 if [ $es != 501 ]
2759 xcall bail "ins_ref $xh 3-9"
2761 echo "~^header remove-at $xh T"; read es;\
2762 vput vexpr es substr $es 0 3
2763 if [ $es != 505 ]
2764 xcall bail "ins_ref $xh 3-10"
2766 echo "~^header show $xh"; read es;\
2767 vput vexpr es substr $es 0 3
2768 if [ $es != 501 ]
2769 xcall bail "ins_ref $xh 3-11"
2773 echo "~^header insert $xh <$xh@exam.ple> ";\
2774 read es; echo $es; call xerr "$es" "ins_ref $xh 4-1"
2775 if [ $mult -ne 0 ]
2776 echo "~^header insert $xh <${xh}2@exam.ple> ";\
2777 read es; echo $es; call xerr "$es" "ins_ref $xh 4-2"
2778 echo "~^header insert $xh ${xh}3@exam.ple";\
2779 read es; echo $es; call xerr "$es" "ins_ref $xh 4-3"
2781 echo "~^header list $xh"; read hl; echo $hl;\
2782 call xerr "$hl" "ins_ref $xh 4-4"
2783 echo "~^header show $xh"; read es; call xerr $es "ins_ref $xh 4-5"
2784 call read_mline_res
2786 if [ $mult -ne 0 ] && [ $xh != subject ]
2787 echo "~^header remove-at $xh 3"; read es;\
2788 call xerr $es "ins_ref $xh 4-6"
2789 echo "~^header remove-at $xh 2"; read es;\
2790 call xerr $es "ins_ref $xh 4-7"
2792 echo "~^header remove-at $xh 1"; read es;\
2793 call xerr $es "ins_ref $xh 4-8"
2794 echo "~^header remove-at $xh 1"; read es;\
2795 vput vexpr es substr $es 0 3
2796 if [ $es != 501 ]
2797 xcall bail "ins_ref $xh 4-9"
2799 echo "~^header remove-at $xh T"; read es;\
2800 vput vexpr es substr $es 0 3
2801 if [ $es != 505 ]
2802 xcall bail "ins_ref $xh 4-10"
2804 echo "~^header show $xh"; read es;\
2805 vput vexpr es substr $es 0 3
2806 if [ $es != 501 ]
2807 xcall bail "ins_ref $xh 4-11"
2810 define t_header {
2811 echo t_header ENTER
2812 # In collect.c order
2813 call ins_addr from
2814 call ins_ref sender 0 # Not a "ref", but works
2815 call ins_addr To
2816 call ins_addr cC
2817 call ins_addr bCc
2818 call ins_addr reply-To
2819 call ins_addr mail-Followup-to
2820 call ins_ref messAge-id 0
2821 call ins_ref rEfErEncEs 1
2822 call ins_ref in-Reply-to 1
2823 call ins_ref subject 1 # Not a "ref", but works (with tweaks)
2824 call ins_addr freeForm1
2825 call ins_addr freeform2
2827 echo "~^header show MAILX-Command"; read es; call xerr $es "t_header 1000"
2828 call read_mline_res
2829 echo "~^header show MAILX-raw-TO"; read es; call xerr $es "t_header 1001"
2830 call read_mline_res
2832 echo t_header LEAVE
2834 define t_attach {
2835 echo t_attach ENTER
2837 echo "~^attachment";\
2838 read hl; echo $hl; vput vexpr es substr "$hl" 0 3
2839 if [ "$es" != 501 ]
2840 xcall bail "attach 0-1"
2843 echo "~^attach attribute ./.treadctl";\
2844 read hl; echo $hl; vput vexpr es substr "$hl" 0 3
2845 if [ "$es" != 501 ]
2846 xcall bail "attach 0-2"
2848 echo "~^attachment attribute-at 1";\
2849 read hl; echo $hl; vput vexpr es substr "$hl" 0 3
2850 if [ "$es" != 501 ]
2851 xcall bail "attach 0-3"
2854 echo "~^attachment insert ./.treadctl=ascii";\
2855 read hl; echo $hl; call xerr "$hl" "attach 1-1"
2856 echo "~^attachment list";\
2857 read es; echo $es;call xerr "$es" "attach 1-2"
2858 call read_mline_res
2859 echo "~^attachment attribute ./.treadctl";\
2860 read es; echo $es;call xerr "$es" "attach 1-3"
2861 call read_mline_res
2862 echo "~^attachment attribute .treadctl";\
2863 read es; echo $es;call xerr "$es" "attach 1-4"
2864 call read_mline_res
2865 echo "~^attachment attribute-at 1";\
2866 read es; echo $es;call xerr "$es" "attach 1-5"
2867 call read_mline_res
2869 echo "~^attachment attribute-set ./.treadctl filename rctl";\
2870 read es; echo $es;call xerr "$es" "attach 1-6"
2871 echo "~^attachment attribute-set .treadctl content-description Au";\
2872 read es; echo $es;call xerr "$es" "attach 1-7"
2873 echo "~^attachment attribute-set-at 1 content-id <10.du@ich>";\
2874 read es; echo $es;call xerr "$es" "attach 1-8"
2876 echo "~^attachment attribute ./.treadctl";\
2877 read es; echo $es;call xerr "$es" "attach 1-9"
2878 call read_mline_res
2879 echo "~^attachment attribute .treadctl";\
2880 read es; echo $es;call xerr "$es" "attach 1-10"
2881 call read_mline_res
2882 echo "~^attachment attribute rctl";\
2883 read es; echo $es;call xerr "$es" "attach 1-11"
2884 call read_mline_res
2885 echo "~^attachment attribute-at 1";\
2886 read es; echo $es;call xerr "$es" "attach 1-12"
2887 call read_mline_res
2890 echo "~^attachment insert ./.tattach=latin1";\
2891 read hl; echo $hl; call xerr "$hl" "attach 2-1"
2892 echo "~^attachment list";\
2893 read es; echo $es;call xerr "$es" "attach 2-2"
2894 call read_mline_res
2895 echo "~^attachment attribute ./.tattach";\
2896 read es; echo $es;call xerr "$es" "attach 2-3"
2897 call read_mline_res
2898 echo "~^attachment attribute .tattach";\
2899 read es; echo $es;call xerr "$es" "attach 2-4"
2900 call read_mline_res
2901 echo "~^attachment attribute-at 2";\
2902 read es; echo $es;call xerr "$es" "attach 2-5"
2903 call read_mline_res
2905 echo "~^attachment attribute-set ./.tattach filename tat";\
2906 read es; echo $es;call xerr "$es" "attach 2-6"
2907 echo \
2908 "~^attachment attribute-set .tattach content-description Au2";\
2909 read es; echo $es;call xerr "$es" "attach 2-7"
2910 echo "~^attachment attribute-set-at 2 content-id <20.du@wir>";\
2911 read es; echo $es;call xerr "$es" "attach 2-8"
2912 echo \
2913 "~^attachment attribute-set-at 2 content-type application/x-sh";\
2914 read es; echo $es;call xerr "$es" "attach 2-9"
2916 echo "~^attachment attribute ./.tattach";\
2917 read es; echo $es;call xerr "$es" "attach 2-10"
2918 call read_mline_res
2919 echo "~^attachment attribute .tattach";\
2920 read es; echo $es;call xerr "$es" "attach 2-11"
2921 call read_mline_res
2922 echo "~^attachment attribute tat";\
2923 read es; echo $es;call xerr "$es" "attach 2-12"
2924 call read_mline_res
2925 echo "~^attachment attribute-at 2";\
2926 read es; echo $es;call xerr "$es" "attach 2-13"
2927 call read_mline_res
2930 if [ "$t_remove" == "" ]
2931 return
2934 echo "~^attachment remove ./.treadctl"; read es;\
2935 call xerr $es "attach 3-1"
2936 echo "~^attachment remove ./.tattach"; read es;\
2937 call xerr $es "attach 3-2"
2938 echo "~^ attachment remove ./.treadctl"; read es;\
2939 vput vexpr es substr $es 0 3
2940 if [ $es != 501 ]
2941 xcall bail "attach 3-3"
2943 echo "~^ attachment remove ./.tattach"; read es;\
2944 vput vexpr es substr $es 0 3
2945 if [ $es != 501 ]
2946 xcall bail "attach 3-4"
2948 echo "~^attachment list"; read es;\
2949 vput vexpr es substr $es 0 3
2950 if [ $es != 501 ]
2951 xcall bail "attach 3-5"
2955 echo "~^attachment insert ./.tattach=latin1";\
2956 read hl; echo $hl; call xerr "$hl" "attach 4-1"
2957 echo "~^attachment insert ./.tattach=latin1";\
2958 read hl; echo $hl; call xerr "$hl" "attach 4-2"
2959 echo "~^attachment list";\
2960 read es; echo $es;call xerr "$es" "attach 4-3"
2961 call read_mline_res
2962 echo "~^ attachment remove .tattach"; read es;\
2963 vput vexpr es substr $es 0 3
2964 if [ $es != 506 ]
2965 xcall bail "attach 4-4 $es"
2967 echo "~^attachment remove-at T"; read es;\
2968 vput vexpr es substr $es 0 3
2969 if [ $es != 505 ]
2970 xcall bail "attach 4-5"
2972 echo "~^attachment remove ./.tattach"; read es;\
2973 call xerr $es "attach 4-6"
2974 echo "~^attachment remove ./.tattach"; read es;\
2975 call xerr $es "attach 4-7"
2976 echo "~^ attachment remove ./.tattach"; read es;\
2977 vput vexpr es substr $es 0 3
2978 if [ $es != 501 ]
2979 xcall bail "attach 4-8 $es"
2981 echo "~^attachment list"; read es;\
2982 vput vexpr es substr $es 0 3
2983 if [ $es != 501 ]
2984 xcall bail "attach 4-9"
2988 echo "~^attachment insert ./.tattach=latin1";\
2989 read hl; echo $hl; call xerr "$hl" "attach 5-1"
2990 echo "~^attachment insert ./.tattach=latin1";\
2991 read hl; echo $hl; call xerr "$hl" "attach 5-2"
2992 echo "~^attachment insert ./.tattach=latin1";\
2993 read hl; echo $hl; call xerr "$hl" "attach 5-3"
2994 echo "~^attachment list";\
2995 read es; echo $es;call xerr "$es" "attach 5-4"
2996 call read_mline_res
2998 echo "~^attachment remove-at 3"; read es;\
2999 call xerr $es "attach 5-5"
3000 echo "~^attachment remove-at 3"; read es;\
3001 vput vexpr es substr $es 0 3
3002 if [ $es != 501 ]
3003 xcall bail "attach 5-6"
3005 echo "~^attachment remove-at 2"; read es;\
3006 call xerr $es "attach 5-7"
3007 echo "~^attachment remove-at 2"; read es;\
3008 vput vexpr es substr $es 0 3
3009 if [ $es != 501 ]
3010 xcall bail "attach 5-8"
3012 echo "~^attachment remove-at 1"; read es;\
3013 call xerr $es "attach 5-9"
3014 echo "~^attachment remove-at 1"; read es;\
3015 vput vexpr es substr $es 0 3
3016 if [ $es != 501 ]
3017 xcall bail "attach 5-10"
3020 echo "~^attachment list"; read es;\
3021 vput vexpr es substr $es 0 3
3022 if [ $es != 501 ]
3023 xcall bail "attach 5-11"
3027 echo "~^attachment insert ./.tattach=latin1";\
3028 read hl; echo $hl; call xerr "$hl" "attach 6-1"
3029 echo "~^attachment insert ./.tattach=latin1";\
3030 read hl; echo $hl; call xerr "$hl" "attach 6-2"
3031 echo "~^attachment insert ./.tattach=latin1";\
3032 read hl; echo $hl; call xerr "$hl" "attach 6-3"
3033 echo "~^attachment list";\
3034 read es; echo $es;call xerr "$es" "attach 6-4"
3035 call read_mline_res
3037 echo "~^attachment remove-at 1"; read es;\
3038 call xerr $es "attach 6-5"
3039 echo "~^attachment remove-at 1"; read es;\
3040 call xerr $es "attach 6-6"
3041 echo "~^attachment remove-at 1"; read es;\
3042 call xerr $es "attach 6-7"
3043 echo "~^attachment remove-at 1"; read es;\
3044 vput vexpr es substr $es 0 3
3045 if [ $es != 501 ]
3046 xcall bail "attach 6-8"
3049 echo "~^attachment list"; read es;\
3050 vput vexpr es substr $es 0 3
3051 if [ $es != 501 ]
3052 xcall bail "attach 6-9"
3055 echo t_attach LEAVE
3057 define t_ocs {
3058 read ver
3059 echo t_ocs
3060 call t_header
3061 call t_attach
3063 define t_oce {
3064 echo on-compose-enter, mailx-command<$mailx-command>
3065 alternates alter1@exam.ple alter2@exam.ple
3066 alternates
3067 set autocc='alter1@exam.ple alter2@exam.ple'
3068 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3069 echo mailx-subject<$mailx-subject>
3070 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3071 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3072 mailx-raw-bcc<$mailx-raw-bcc>
3073 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
3074 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3076 define t_ocl {
3077 echo on-compose-leave, mailx-command<$mailx-command>
3078 vput alternates al
3079 eval alternates $al alter3@exam.ple alter4@exam.ple
3080 alternates
3081 set autobcc='alter3@exam.ple alter4@exam.ple'
3082 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3083 echo mailx-subject<$mailx-subject>
3084 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3085 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3086 mailx-raw-bcc<$mailx-raw-bcc>
3087 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
3088 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3090 define t_occ {
3091 echo on-compose-cleanup, mailx-command<$mailx-command>
3092 unalternates *
3093 alternates
3094 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3095 echo mailx-subject<$mailx-subject>
3096 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3097 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3098 mailx-raw-bcc<$mailx-raw-bcc>
3099 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
3100 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3102 wysh set on-compose-splice=t_ocs \
3103 on-compose-enter=t_oce on-compose-leave=t_ocl \
3104 on-compose-cleanup=t_occ
3105 __EOT__
3109 ${rm} -f "${MBOX}"
3110 printf 'm this-goes@nowhere\nbody\n!.\n' |
3111 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
3112 -X'source ./.trc' -Smta=./.tsendmail.sh \
3113 >./.tall 2>&1
3114 ${cat} ./.tall >> "${MBOX}"
3115 check behave:compose_hooks-1 0 "${MBOX}" '3667291468 10101'
3117 ${rm} -f "${MBOX}"
3118 printf 'm this-goes@nowhere\nbody\n!.\n' |
3119 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
3120 -St_remove=1 -X'source ./.trc' -Smta=./.tsendmail.sh \
3121 >./.tall 2>&1
3122 ${cat} ./.tall >> "${MBOX}"
3123 check behave:compose_hooks-2 0 "${MBOX}" '1746765053 12535'
3125 # Some state machine stress, shell compose hook, localopts for hook, etc.
3126 # readctl in child. ~r as HERE document
3127 ${rm} -f "${MBOX}"
3128 printf 'm ex@am.ple\nbody\n!.\nvar t_oce t_ocs t_ocs_sh t_ocl t_occ autocc' |
3129 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! \
3130 -Smta=./.tsendmail.sh \
3132 define bail {
3133 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
3135 define xerr {
3136 vput vexpr es substr "$1" 0 1
3137 if [ "$es" != 2 ]
3138 xcall bail "$2"
3141 define read_mline_res {
3142 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
3143 echo $len/$es/$^ERRNAME: $hl
3144 if [ $es -ne $^ERR-NONE ]
3145 xcall bail read_mline_res
3146 elif [ $len -ne 0 ]
3147 \xcall read_mline_res
3150 define _work {
3151 vput vexpr i + 1 "$2"
3152 if [ $i -lt 111 ]
3153 vput vexpr j % $i 10
3154 if [ $j -ne 0 ]
3155 set j=xcall
3156 else
3157 echon "$i.. "
3158 set j=call
3160 eval \\$j _work $1 $i
3161 return $?
3163 vput vexpr i + $i "$1"
3164 return $i
3166 define _read {
3167 read line;wysh set es=$? en=$^ERRNAME ; echo read:$es/$en: $line
3168 if [ "${es}" -ne -1 ]
3169 xcall _read
3171 readctl remove $cwd/.treadctl; echo readctl remove:$?/$^ERRNAME
3173 define t_ocs {
3174 read ver
3175 echo t_ocs
3176 echo "~^header list"; read hl; echo $hl;\
3177 vput vexpr es substr "$hl" 0 1
3178 if [ "$es" != 2 ]
3179 xcall bail "header list"
3180 endif
3182 call _work 1; echo $?
3183 echo "~^header insert cc splicy diet <splice@exam.ple> spliced";\
3184 read es; echo $es; vput vexpr es substr "$es" 0 1
3185 if [ "$es" != 2 ]
3186 xcall bail "be diet"
3187 endif
3188 echo "~^header insert cc <splice2@exam.ple>";\
3189 read es; echo $es; vput vexpr es substr "$es" 0 1
3190 if [ "$es" != 2 ]
3191 xcall bail "be diet2"
3192 endif
3194 call _work 2; echo $?
3195 echo "~^header insert bcc juicy juice <juice@exam.ple> spliced";\
3196 read es; echo $es;vput vexpr es substr "$es" 0 1
3197 if [ "$es" != 2 ]
3198 xcall bail "be juicy"
3199 endif
3200 echo "~^header insert bcc juice2@exam.ple";\
3201 read es; echo $es;vput vexpr es substr "$es" 0 1
3202 if [ "$es" != 2 ]
3203 xcall bail "be juicy2"
3204 endif
3205 echo "~^header insert bcc juice3 <juice3@exam.ple>";\
3206 read es; echo $es;vput vexpr es substr "$es" 0 1
3207 if [ "$es" != 2 ]
3208 xcall bail "be juicy3"
3209 endif
3210 echo "~^header insert bcc juice4@exam.ple";\
3211 read es; echo $es;vput vexpr es substr "$es" 0 1
3212 if [ "$es" != 2 ]
3213 xcall bail "be juicy4"
3214 endif
3216 echo "~^header remove-at bcc 3";\
3217 read es; echo $es;vput vexpr es substr "$es" 0 1
3218 if [ "$es" != 2 ]
3219 xcall bail "remove juicy5"
3220 endif
3221 echo "~^header remove-at bcc 2";\
3222 read es; echo $es;vput vexpr es substr "$es" 0 1
3223 if [ "$es" != 2 ]
3224 xcall bail "remove juicy6"
3225 endif
3226 echo "~^header remove-at bcc 3";\
3227 read es; echo $es;vput vexpr es substr "$es" 0 3
3228 if [ "$es" != 501 ]
3229 xcall bail "failed to remove-at"
3230 endif
3231 # Add duplicates which ought to be removed!
3232 echo "~^header insert bcc juice4@exam.ple";\
3233 read es; echo $es;vput vexpr es substr "$es" 0 1
3234 if [ "$es" != 2 ]
3235 xcall bail "be juicy4-1"
3236 endif
3237 echo "~^header insert bcc juice4@exam.ple";\
3238 read es; echo $es;vput vexpr es substr "$es" 0 1
3239 if [ "$es" != 2 ]
3240 xcall bail "be juicy4-2"
3241 endif
3242 echo "~^header insert bcc juice4@exam.ple";\
3243 read es; echo $es;vput vexpr es substr "$es" 0 1
3244 if [ "$es" != 2 ]
3245 xcall bail "be juicy4-3"
3246 endif
3247 echo "~:set t_ocs"
3250 call _work 3; echo $?
3251 echo "~r - '__EOT'"
3252 vput ! i echo just knock if you can hear me;\
3253 i=0;\
3254 while [ $i -lt 24 ]; do printf "%s " $i; i=`expr $i + 1`; done;\
3255 echo relax
3256 echon shell-cmd says $?/$^ERRNAME: $i
3257 echo "~x will not become interpreted, we are reading until __EOT"
3258 echo "__EOT"
3259 read r_status; echo "~~r status output: $r_status"
3260 echo "~:echo $? $! $^ERRNAME"
3261 read r_status
3262 echo "~~r status from parent: $r_status"
3265 call _work 4; echo $?
3266 vput cwd cwd;echo cwd:$?
3267 readctl create $cwd/.treadctl ;echo readctl:$?/$^ERRNAME;\
3268 call _read
3271 call _work 5; echo $?
3272 echo "~^header show MAILX-Command"; read es;\
3273 call xerr $es "t_header 1000"; call read_mline_res
3274 echo "~^header show MAILX-raw-TO"; read es;\
3275 call xerr $es "t_header 1001"; xcall read_mline_res
3277 echoerr IT IS WRONG IF YOU SEE THIS
3279 define t_oce {
3280 echo on-compose-enter, mailx-command<$mailx-command>
3281 set t_oce autobcc=oce@exam.ple
3282 alternates alter1@exam.ple alter2@exam.ple
3283 alternates
3284 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3285 echo mailx-subject<$mailx-subject>
3286 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3287 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3288 mailx-raw-bcc<$mailx-raw-bcc>
3289 echo mailx-orig-from<$mailx-orig-from> \
3290 mailx-orig-to<$mailx-orig-to> \
3291 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3293 define t_ocl {
3294 echo on-compose-leave, mailx-command<$mailx-command>
3295 set t_ocl autocc=ocl@exam.ple
3296 unalternates *
3297 alternates alter3@exam.ple alter4@exam.ple
3298 alternates
3299 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3300 echo mailx-subject<$mailx-subject>
3301 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3302 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3303 mailx-raw-bcc<$mailx-raw-bcc>
3304 echo mailx-orig-from<$mailx-orig-from> \
3305 mailx-orig-to<$mailx-orig-to> \
3306 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3308 define t_occ {
3309 echo on-compose-cleanup, mailx-command<$mailx-command>
3310 set t_occ autocc=occ@exam.ple
3311 unalternates *
3312 alternates
3313 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3314 echo mailx-subject<$mailx-subject>
3315 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3316 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3317 mailx-raw-bcc<$mailx-raw-bcc>
3318 echo mailx-orig-from<$mailx-orig-from> \
3319 mailx-orig-to<$mailx-orig-to> \
3320 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3322 wysh set on-compose-splice=t_ocs \
3323 on-compose-splice-shell="read ver;printf \"t_ocs-shell\\n\
3324 ~t shell@exam.ple\\n~:set t_ocs_sh\\n\"" \
3325 on-compose-enter=t_oce on-compose-leave=t_ocl \
3326 on-compose-cleanup=t_occ
3327 ' > ./.tnotes 2>&1
3328 ex0_test behave:compose_hooks-3
3329 ${cat} ./.tnotes >> "${MBOX}"
3331 check behave:compose_hooks-3 - "${MBOX}" '679526364 2431'
3333 # Reply, forward, resend, Resend
3335 ${rm} -f "${MBOX}"
3336 printf 'set from=f1@z\nm t1@z\nb1\n!.\nset from=f2@z\nm t2@z\nb2\n!.\n' |
3337 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! \
3338 -Smta=./.tsendmail.sh
3340 printf '
3341 echo start: $? $! $^ERRNAME
3342 File %s
3343 echo File: $? $! $^ERRNAME;echo;echo
3344 reply 1
3345 this is content of reply 1
3347 echo reply 1: $? $! $^ERRNAME;echo;echo
3348 Reply 1 2
3349 this is content of Reply 1 2
3351 echo Reply 1 2: $? $! $^ERRNAME;echo;echo
3352 forward 1 fwdex@am.ple
3353 this is content of forward 1
3355 echo forward 1: $? $! $^ERRNAME;echo;echo
3356 resend 1 2 resendex@am.ple
3357 echo resend 1 2: $? $! $^ERRNAME;echo;echo
3358 Resend 1 2 Resendex@am.ple
3359 echo Resend 1 2: $? $! $^ERRNAME;echo;echo
3360 ' "${MBOX}" |
3361 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! \
3362 -Smta=./.tsendmail.sh \
3364 define bail {
3365 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
3367 define xerr {
3368 vput vexpr es substr "$1" 0 1
3369 if [ "$es" != 2 ]
3370 xcall bail "$2"
3373 define read_mline_res {
3374 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
3375 echo mline_res:$len/$es/$^ERRNAME: $hl
3376 if [ $es -ne $^ERR-NONE ]
3377 xcall bail read_mline_res
3378 elif [ $len -ne 0 ]
3379 \xcall read_mline_res
3382 define work_hl {
3383 echo "~^header show $1"; read es;\
3384 call xerr $es "work_hl $1"; echo $1; call read_mline_res
3385 if [ $# -gt 1 ]
3386 shift
3387 xcall work_hl "$@"
3390 define t_ocs {
3391 read ver
3392 echo t_ocs version $ver
3393 echo "~^header list"; read hl; echo $hl;\
3394 echoerr the header list is $hl;\
3395 call xerr "$hl" "header list"
3396 eval vpospar set $hl
3397 shift
3398 xcall work_hl "$@"
3399 echoerr IT IS WRONG IF YOU SEE THIS
3401 define t_oce {
3402 echo on-XY-enter, mailx-command<$mailx-command>
3403 set t_oce autobcc=oce@exam.ple
3404 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3405 echo mailx-subject<$mailx-subject>
3406 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3407 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3408 mailx-raw-bcc<$mailx-raw-bcc>
3409 echo mailx-orig-from<$mailx-orig-from> \
3410 mailx-orig-to<$mailx-orig-to> \
3411 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3413 define t_ocl {
3414 echo on-XY-leave, mailx-command<$mailx-command>
3415 set t_ocl autocc=ocl@exam.ple
3416 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3417 echo mailx-subject<$mailx-subject>
3418 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3419 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3420 mailx-raw-bcc<$mailx-raw-bcc>
3421 echo mailx-orig-from<$mailx-orig-from> \
3422 mailx-orig-to<$mailx-orig-to> \
3423 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3425 define t_occ {
3426 echo on-XY-cleanup, mailx-command<$mailx-command>
3427 set t_occ autocc=occ@exam.ple
3428 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3429 echo mailx-subject<$mailx-subject>
3430 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3431 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3432 mailx-raw-bcc<$mailx-raw-bcc>
3433 echo mailx-orig-from<$mailx-orig-from> \
3434 mailx-orig-to<$mailx-orig-to> \
3435 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3437 wysh set on-compose-splice=t_ocs \
3438 on-compose-enter=t_oce on-compose-leave=t_ocl \
3439 on-compose-cleanup=t_occ \
3440 on-resend-enter=t_oce on-resend-cleanup=t_occ
3441 ' > ./.tnotes 2>&1
3442 ex0_test behave:compose_hooks-4
3443 ${cat} ./.tnotes >> "${MBOX}"
3445 check behave:compose_hooks-4 - "${MBOX}" '3038884027 7516'
3447 t_epilog
3450 t_behave_message_injections() {
3451 t_prolog
3452 TRAP_EXIT_ADDONS="./.t*"
3454 ${cat} <<-_EOT > ./.tsendmail.sh
3455 #!${MYSHELL} -
3456 (echo 'From Echinacea Tue Jun 20 15:54:02 2017' && ${cat} && echo
3457 ) > "${MBOX}"
3458 _EOT
3459 chmod 0755 ./.tsendmail.sh
3461 echo mysig > ./.tmysig
3463 echo some-body | ${MAILX} ${ARGS} -Smta=./.tsendmail.sh \
3464 -Smessage-inject-head=head-inject \
3465 -Smessage-inject-tail=tail-inject \
3466 -Ssignature=./.tmysig \
3467 ex@am.ple > ./.tall 2>&1
3468 check behave:message_injections-1 0 "${MBOX}" '2434746382 134'
3469 check behave:message_injections-2 - .tall '4294967295 0' # empty file
3471 ${cat} <<-_EOT > ./.template
3472 From: me
3473 To: ex1@am.ple
3474 Cc: ex2@am.ple
3475 Subject: This subject is
3477 Body, body, body me.
3478 _EOT
3479 < ./.template ${MAILX} ${ARGS} -t -Smta=./.tsendmail.sh \
3480 -Smessage-inject-head=head-inject \
3481 -Smessage-inject-tail=tail-inject \
3482 -Ssignature=./.tmysig \
3483 > ./.tall 2>&1
3484 check behave:message_injections-3 0 "${MBOX}" '3114203412 198'
3485 check behave:message_injections-4 - .tall '4294967295 0' # empty file
3487 t_epilog
3490 t_behave_mime_types_load_control() {
3491 t_prolog
3492 TRAP_EXIT_ADDONS="./.t*"
3494 ${cat} <<-_EOT > ./.tmts1
3495 @ application/mathml+xml mathml
3496 _EOT
3497 ${cat} <<-_EOT > ./.tmts2
3498 @ x-conference/x-cooltalk ice
3499 @ aga-aga aga
3500 @ application/aga-aga aga
3501 _EOT
3503 ${cat} <<-_EOT > ./.tmts1.mathml
3504 <head>nonsense ML</head>
3505 _EOT
3506 ${cat} <<-_EOT > ./.tmts2.ice
3507 Icy, icy road.
3508 _EOT
3509 printf 'of which the c\x01rack is coming soon' > ./.tmtsx.doom
3510 printf 'of which the c\x01rack is coming soon' > ./.tmtsx.aga
3512 printf '
3513 m %s
3514 Schub-di-du
3515 ~@ ./.tmts1.mathml
3516 ~@ ./.tmts2.ice
3517 ~@ ./.tmtsx.doom
3518 ~@ ./.tmtsx.aga
3520 File %s
3521 from*
3522 type
3524 ' "${MBOX}" "${MBOX}" |
3525 ${MAILX} ${ARGS} \
3526 -Smimetypes-load-control=f=./.tmts1,f=./.tmts2 \
3527 > ./.tout 2>&1
3528 ex0_test behave:mime_types_load_control
3530 ${cat} "${MBOX}" >> ./.tout
3531 check behave:mime_types_load_control-1 - ./.tout '529577037 2474'
3533 echo type | ${MAILX} ${ARGS} -R \
3534 -Smimetypes-load-control=f=./.tmts1,f=./.tmts3 \
3535 -f "${MBOX}" >> ./.tout 2>&1
3536 check behave:mime_types_load_control-2 0 ./.tout '2025926659 3558'
3538 t_epilog
3541 t_behave_smime() {
3542 have_feat smime || {
3543 echo 'behave:s/mime: unsupported, skipped'
3544 return
3547 t_prolog
3548 TRAP_EXIT_ADDONS="./.t.conf ./.tkey.pem ./.tcert.pem ./.tpair.pem"
3549 TRAP_EXIT_ADDONS="${TRAP_EXIT_ADDONS} ./.VERIFY ./.DECRYPT ./.ENCRYPT"
3550 TRAP_EXIT_ADDONS="${TRAP_EXIT_ADDONS} ./.tsendmail.sh"
3552 printf 'behave:s/mime: .. generating test key and certificate ..\n'
3553 ${cat} <<-_EOT > ./.t.conf
3554 [ req ]
3555 default_bits = 1024
3556 default_keyfile = keyfile.pem
3557 distinguished_name = req_distinguished_name
3558 attributes = req_attributes
3559 prompt = no
3560 output_password =
3562 [ req_distinguished_name ]
3563 C = GB
3564 ST = Over the
3565 L = rainbow
3566 O = S-nail
3567 OU = S-nail.smime
3568 CN = S-nail.test
3569 emailAddress = test@localhost
3571 [ req_attributes ]
3572 challengePassword =
3573 _EOT
3574 openssl req -x509 -nodes -days 3650 -config ./.t.conf \
3575 -newkey rsa:1024 -keyout ./.tkey.pem -out ./.tcert.pem >/dev/null 2>&1
3576 ${cat} ./.tkey.pem ./.tcert.pem > ./.tpair.pem
3578 # Sign/verify
3579 printf 'behave:s/mime:sign/verify: '
3580 echo bla | ${MAILX} ${ARGS} \
3581 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
3582 -Ssmime-sign -Sfrom=test@localhost \
3583 -s 'S/MIME test' ./.VERIFY
3584 if [ $? -eq 0 ]; then
3585 printf 'ok\n'
3586 else
3587 printf 'failed\n'
3588 ESTAT=1
3589 t_epilog
3590 return
3593 ${awk} '
3594 BEGIN{ skip=0 }
3595 /^Content-Description: /{ skip = 2; print; next }
3596 /^$/{ if(skip) --skip }
3597 { if(!skip) print }
3599 < ./.VERIFY > "${MBOX}"
3600 check behave:s/mime:sign/verify:checksum - "${MBOX}" '2900817158 648'
3602 printf 'behave:s/mime:sign/verify:verify '
3603 printf 'verify\nx\n' |
3604 ${MAILX} ${ARGS} \
3605 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
3606 -Ssmime-sign -Sfrom=test@localhost \
3607 -Serrexit -R \
3608 -f ./.VERIFY >/dev/null 2>&1
3609 if [ $? -eq 0 ]; then
3610 printf 'ok\n'
3611 else
3612 printf 'failed\n'
3613 ESTAT=1
3614 t_epilog
3615 return
3618 printf 'behave:s/mime:sign/verify:disproof-1 '
3619 if openssl smime -verify -CAfile ./.tcert.pem \
3620 -in ./.VERIFY >/dev/null 2>&1; then
3621 printf 'ok\n'
3622 else
3623 printf 'failed\n'
3624 ESTAT=1
3625 t_epilog
3626 return
3629 # (signing +) encryption / decryption
3630 ${cat} <<-_EOT > ./.tsendmail.sh
3631 #!${MYSHELL} -
3632 (echo 'From Euphrasia Thu Apr 27 17:56:23 2017' && ${cat}) > ./.ENCRYPT
3633 _EOT
3634 chmod 0755 ./.tsendmail.sh
3636 printf 'behave:s/mime:encrypt+sign: '
3637 echo bla |
3638 ${MAILX} ${ARGS} \
3639 -Ssmime-force-encryption \
3640 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
3641 -Smta=./.tsendmail.sh \
3642 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
3643 -Ssmime-sign -Sfrom=test@localhost \
3644 -s 'S/MIME test' recei@ver.com
3645 if [ $? -eq 0 ]; then
3646 printf 'ok\n'
3647 else
3648 ESTAT=1
3649 printf 'error: encrypt+sign failed\n'
3652 ${sed} -e '/^$/,$d' < ./.ENCRYPT > "${MBOX}"
3653 check behave:s/mime:encrypt+sign:checksum - "${MBOX}" '1937410597 327'
3655 printf 'behave:s/mime:decrypt+verify: '
3656 printf 'decrypt ./.DECRYPT\nfi ./.DECRYPT\nverify\nx\n' |
3657 ${MAILX} ${ARGS} \
3658 -Ssmime-force-encryption \
3659 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
3660 -Smta=./.tsendmail.sh \
3661 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
3662 -Ssmime-sign -Sfrom=test@localhost \
3663 -Serrexit -R \
3664 -f ./.ENCRYPT >/dev/null 2>&1
3665 if [ $? -eq 0 ]; then
3666 printf 'ok\n'
3667 else
3668 ESTAT=1
3669 printf 'failed\n'
3672 ${awk} '
3673 BEGIN{ skip=0 }
3674 /^Content-Description: /{ skip = 2; print; next }
3675 /^$/{ if(skip) --skip }
3676 { if(!skip) print }
3678 < ./.DECRYPT > "${MBOX}"
3679 check behave:s/mime:decrypt+verify:checksum - "${MBOX}" '1720739247 931'
3681 printf 'behave:s/mime:decrypt+verify:disproof-1: '
3682 if (openssl smime -decrypt -inkey ./.tkey.pem -in ./.ENCRYPT |
3683 openssl smime -verify -CAfile ./.tcert.pem) >/dev/null 2>&1; then
3684 printf 'ok\n'
3685 else
3686 printf 'failed\n'
3687 ESTAT=1
3690 printf "behave:s/mime:encrypt: "
3691 echo bla | ${MAILX} ${ARGS} \
3692 -Ssmime-force-encryption \
3693 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
3694 -Smta=./.tsendmail.sh \
3695 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
3696 -Sfrom=test@localhost \
3697 -s 'S/MIME test' recei@ver.com
3698 if [ $? -eq 0 ]; then
3699 printf 'ok\n'
3700 else
3701 ESTAT=1
3702 printf 'failed\n'
3705 # Same as behave:s/mime:encrypt+sign:checksum above
3706 ${sed} -e '/^$/,$d' < ./.ENCRYPT > "${MBOX}"
3707 check behave:s/mime:encrypt:checksum - "${MBOX}" '1937410597 327'
3709 ${rm} -f ./.DECRYPT
3710 printf 'decrypt ./.DECRYPT\nx\n' | ${MAILX} ${ARGS} \
3711 -Ssmime-force-encryption \
3712 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
3713 -Smta=./.tsendmail.sh \
3714 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
3715 -Sfrom=test@localhost \
3716 -Serrexit -R \
3717 -f ./.ENCRYPT >/dev/null 2>&1
3718 check behave:s/mime:decrypt 0 "./.DECRYPT" '2624716890 422'
3720 printf 'behave:s/mime:decrypt:disproof-1: '
3721 if openssl smime -decrypt -inkey ./.tkey.pem \
3722 -in ./.ENCRYPT >/dev/null 2>&1; then
3723 printf 'ok\n'
3724 else
3725 printf 'failed\n'
3726 ESTAT=1
3729 t_epilog
3732 t_behave_maildir() {
3733 t_prolog
3734 TRAP_EXIT_ADDONS="./.t*"
3738 while [ ${i} -lt 112 ]; do
3739 printf 'm file://%s\n~s Subject %s\nHello %s!\n~.\n' \
3740 "${MBOX}" "${i}" "${i}"
3741 i=`add ${i} 1`
3742 done
3743 ) | ${MAILX} ${ARGS}
3744 check behave:maildir-1 0 "${MBOX}" '1140119864 13780'
3746 printf 'File "%s"
3747 copy * "%s"
3748 File "%s"
3749 from*
3750 ' "${MBOX}" .tmdir1 .tmdir1 |
3751 ${MAILX} ${ARGS} -Snewfolders=maildir > .tlst
3752 check behave:maildir-2 0 .tlst '1797938753 9103'
3754 printf 'File "%s"
3755 copy * "maildir://%s"
3756 File "maildir://%s"
3757 from*
3758 ' "${MBOX}" .tmdir2 .tmdir2 |
3759 ${MAILX} ${ARGS} > .tlst
3760 check behave:maildir-3 0 .tlst '1155631089 9113'
3762 printf 'File "maildir://%s"
3763 copy * "file://%s"
3764 File "file://%s"
3765 from*
3766 ' .tmdir2 .tmbox1 .tmbox1 |
3767 ${MAILX} ${ARGS} > .tlst
3768 check behave:maildir-4 0 .tmbox1 '2646131190 13220'
3769 check behave:maildir-5 - .tlst '3701297796 9110'
3771 # only the odd (even)
3773 printf 'File "maildir://%s"
3774 copy ' .tmdir2
3776 while [ ${i} -lt 112 ]; do
3777 j=`modulo ${i} 2`
3778 [ ${j} -eq 1 ] && printf '%s ' "${i}"
3779 i=`add ${i} 1`
3780 done
3781 printf ' file://%s
3782 File "file://%s"
3783 from*
3784 ' .tmbox2 .tmbox2
3785 ) | ${MAILX} ${ARGS} > .tlst
3786 check behave:maildir-6 0 .tmbox2 '142890131 6610'
3787 check behave:maildir-7 - .tlst '960096773 4573'
3788 # ...
3790 printf 'file "maildir://%s"
3791 move ' .tmdir2
3793 while [ ${i} -lt 112 ]; do
3794 j=`modulo ${i} 2`
3795 [ ${j} -eq 0 ] && [ ${i} -ne 0 ] && printf '%s ' "${i}"
3796 i=`add ${i} 1`
3797 done
3798 printf ' file://%s
3799 File "file://%s"
3800 from*
3801 File "maildir://%s"
3802 from*
3803 ' .tmbox2 .tmbox2 .tmdir2
3804 ) | ${MAILX} ${ARGS} > .tlst
3805 check behave:maildir-8 0 .tmbox2 '3806905791 13100'
3806 ${sed} 2d < .tlst > .tlstx
3807 check behave:maildir-9 - .tlstx '4216815295 13645'
3809 t_epilog
3812 t_behave_mass_recipients() {
3813 t_prolog
3814 TRAP_EXIT_ADDONS="./.t*"
3816 ${cat} <<-_EOT > ./.tsendmail.sh
3817 #!${MYSHELL} -
3818 (echo 'From Eucalyptus Sat Jul 08 21:14:57 2017' && ${cat} && echo
3819 ) >> "${MBOX}"
3820 _EOT
3821 chmod 0755 ./.tsendmail.sh
3823 ${cat} <<'__EOT__' > ./.trc
3824 define bail {
3825 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
3827 define ins_addr {
3828 wysh set nr=$1 hn=$2
3829 echo "~$hn $hn$nr@$hn"; echo '~:echo $?'; read es
3830 if [ "$es" -ne 0 ]
3831 xcall bail "ins_addr $hn 1-$nr"
3833 vput vexpr nr + $nr 1
3834 if [ "$nr" -le "$maximum" ]
3835 xcall ins_addr $nr $hn
3838 define bld_alter {
3839 wysh set nr=$1 hn=$2
3840 alternates $hn$nr@$hn
3841 vput vexpr nr + $nr 2
3842 if [ "$nr" -le "$maximum" ]
3843 xcall bld_alter $nr $hn
3846 define t_ocs {
3847 read ver
3848 call ins_addr 1 t
3849 call ins_addr 1 c
3850 call ins_addr 1 b
3852 define t_ocl {
3853 if [ "$t_remove" != '' ]
3854 call bld_alter 1 t
3855 call bld_alter 2 c
3858 set on-compose-splice=t_ocs on-compose-leave=t_ocl
3859 __EOT__
3861 ${rm} -f "${MBOX}"
3862 printf 'm this-goes@nowhere\nbody\n!.\n' |
3863 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
3864 -X'source ./.trc' -Smta=./.tsendmail.sh -Smaximum=2001 \
3865 >./.tall 2>&1
3866 ${cat} ./.tall >> "${MBOX}"
3867 check behave:mass_recipients-1 0 "${MBOX}" '2912243346 51526'
3869 ${rm} -f "${MBOX}"
3870 printf 'm this-goes@nowhere\nbody\n!.\n' |
3871 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
3872 -St_remove=1 -X'source ./.trc' -Smta=./.tsendmail.sh -Smaximum=2001 \
3873 >./.tall 2>&1
3874 ${cat} ./.tall >> "${MBOX}"
3875 check behave:mass_recipients-2 0 "${MBOX}" '4097804632 34394'
3877 t_epilog
3880 t_behave_lreply_futh_rth_etc() {
3881 t_prolog
3882 TRAP_EXIT_ADDONS="./.t*"
3884 ${cat} <<-_EOT > ./.tsendmail.sh
3885 #!${MYSHELL} -
3886 (echo 'From HumulusLupulus Thu Jul 27 14:41:20 2017' && ${cat} && echo
3887 ) >> "${MBOX}"
3888 _EOT
3889 chmod 0755 ./.tsendmail.sh
3891 ${cat} <<-_EOT > ./.tmbox
3892 From neverneverland Sun Jul 23 13:46:25 2017
3893 Subject: Bugstop: five miles out 1
3894 Reply-To: mister originator2 <mr2@originator>, bugstop@five.miles.out
3895 From: mister originator <mr@originator>
3896 To: bugstop-commit@five.miles.out, laber@backe.eu
3897 Cc: is@a.list
3898 Mail-Followup-To: bugstop@five.miles.out, laber@backe.eu, is@a.list
3899 In-reply-to: <20170719111113.bkcMz%laber@backe.eu>
3900 Date: Wed, 19 Jul 2017 09:22:57 -0400
3901 Message-Id: <20170719132257.766AF781267@originator>
3902 Status: RO
3904 > |Sorry, I think I misunderstand something. I would think that
3906 That's appalling.
3908 From neverneverland Fri Jul 7 22:39:11 2017
3909 Subject: Bugstop: five miles out 2
3910 Reply-To: mister originator2<mr2@originator>,bugstop@five.miles.out,is@a.list
3911 Content-Transfer-Encoding: 7bit
3912 From: mister originator <mr@originator>
3913 To: bugstop-commit@five.miles.out
3914 Cc: is@a.list
3915 Message-ID: <149945963975.28888.6950788126957753723.reportbug@five.miles.out>
3916 Date: Fri, 07 Jul 2017 16:33:59 -0400
3917 Status: R
3919 capable of changing back.
3921 From neverneverland Fri Jul 7 22:42:00 2017
3922 Subject: Bugstop: five miles out 3
3923 Reply-To: mister originator2 <mr2@originator>, bugstop@five.miles.out
3924 Content-Transfer-Encoding: 7bit
3925 From: mister originator <mr@originator>
3926 To: bugstop-commit@five.miles.out
3927 Cc: is@a.list
3928 Message-ID: <149945963975.28888.6950788126957753746.reportbug@five.miles.out>
3929 Date: Fri, 07 Jul 2017 16:33:59 -0400
3930 List-Post: <mailto:bugstop@five.miles.out>
3931 Status: R
3933 are you ready, boots?
3935 _EOT
3939 printf '
3940 define r {
3941 wysh set m="This is text of \\\"reply ${1}."
3942 reply 1 2 3
3943 !I m
3946 !I m
3949 !I m
3952 echo -----After reply $1.1 - $1.3: $?/$^ERRNAME
3954 define R {
3955 wysh set m="This is text of \\\"Reply ${1}."
3956 eval Reply $2
3957 !I m
3958 !I 2
3961 echo -----After Reply $1.$2: $?/$^ERRNAME
3963 define _Lh {
3964 read protover
3965 echo '"'"'~I m'"'"'
3966 echo '"'"'~I n'"'"'
3967 echo '"'"'".'"'"'
3969 define _Ls {
3970 wysh set m="This is text of \\\"Lreply ${1}." \
3971 on-compose-splice=_Lh n=$2
3972 eval Lreply $2
3974 define L {
3975 # We need two indirections for this test: one for the case that Lreply
3976 # fails because if missing recipients, we need to read EOF next, thus
3977 # place this in _Ls last, and second for the succeeding cases EOF is
3978 # not what these should read, so go over the backside and splice it in!
3979 call _Ls "$@"
3980 echo -----After Lreply $1.$2: $?/$^ERRNAME
3982 define x {
3983 localopts call-fixate yes
3984 call r $1
3985 call R $1 1; call R $1 2; call R $1 3
3986 call L $1 1; call L $1 2; call L $1 3
3988 define tweak {
3989 echo;echo '"'"'===== CHANGING === '"'"'"$*"'"'"' ====='"'"';echo
3990 eval "$@"
3993 set from=laber@backe.eu
3994 mlist is@a.list
3995 call x 1
3996 call tweak set reply-to-honour
3997 call x 2
3998 call tweak set followup-to
3999 call x 3
4000 call tweak set followup-to-honour
4001 call x 4
4002 call tweak mlist bugstop@five.miles.out
4003 call x 5
4004 call tweak mlsubscribe bugstop@five.miles.out
4005 call x 6
4006 call tweak set recipients-in-cc
4007 call x 7
4008 ' | ${MAILX} ${ARGS} -Sescape=! -Smta=./.tsendmail.sh \
4009 -Rf ./.tmbox >> "${MBOX}" 2>&1
4011 check behave:lreply_futh_rth_etc 0 "${MBOX}" '2491739775 22062'
4013 t_epilog
4016 # t_content()
4017 # Some basic tests regarding correct sending of mails, via STDIN / -t / -q,
4018 # including basic MIME Content-Transfer-Encoding correctness (quoted-printable)
4019 # Note we unfortunately need to place some statements without proper
4020 # indentation because of continuation problems
4021 t_content() {
4022 t_prolog
4024 # MIME encoding (QP) stress message body
4025 printf \
4026 'Ich bin eine DÖS-Datäi mit sehr langen Zeilen und auch '\
4027 'sonst bin ich ganz schön am Schleudern, da kannste denke '\
4028 "wasde willst, gelle, gelle, gelle, gelle, gelle.\r\n"\
4029 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst \r\n"\
4030 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1\r\n"\
4031 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12\r\n"\
4032 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123\r\n"\
4033 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1234\r\n"\
4034 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12345\r\n"\
4035 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123456\r\n"\
4036 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1234567\r\n"\
4037 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12345678\r\n"\
4038 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123456789\r\n"\
4039 "Unn ausserdem habe ich trailing SP/HT/SP/HT whitespace \r\n"\
4040 "Unn ausserdem habe ich trailing HT/SP/HT/SP whitespace \r\n"\
4041 "auf den zeilen vorher.\r\n"\
4042 "From am Zeilenbeginn und From der Mitte gibt es auch.\r\n"\
4043 ".\r\n"\
4044 "Die letzte Zeile war nur ein Punkt.\r\n"\
4045 "..\r\n"\
4046 "Das waren deren zwei.\r\n"\
4047 " \r\n"\
4048 "Die letzte Zeile war ein Leerschritt.\n"\
4049 "=VIER = EQUAL SIGNS=ON A LINE=\r\n"\
4050 "Prösterchen.\r\n"\
4051 ".\n"\
4052 "Die letzte Zeile war nur ein Punkt, mit Unix Zeilenende.\n"\
4053 "..\n"\
4054 "Das waren deren zwei. ditto.\n"\
4055 "Prösterchen.\n"\
4056 "Unn ausseerdem habe ich trailing SP/HT/SP/HT whitespace \n"\
4057 "Unn ausseerdem habe ich trailing HT/SP/HT/SP whitespace \n"\
4058 "auf den zeilen vorher.\n"\
4059 "ditto.\n"\
4060 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.\n"\
4061 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.1"\
4062 "\n"\
4063 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
4064 "\n"\
4065 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
4066 "3\n"\
4067 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
4068 "34\n"\
4069 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
4070 "345\n"\
4071 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
4072 "3456\n"\
4073 "QP am Zeilenende über soft-nl hinweg\n"\
4074 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
4075 "ö123\n"\
4076 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
4077 "1ö23\n"\
4078 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
4079 "12ö3\n"\
4080 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
4081 "123ö\n"\
4082 "=VIER = EQUAL SIGNS=ON A LINE=\n"\
4083 " \n"\
4084 "Die letzte Zeile war ein Leerschritt.\n"\
4085 ' '\
4086 > "${BODY}"
4088 # MIME encoding (QP) stress message subject
4089 SUB="Äbrä Kä?dä=brö Fü?di=bus? \
4090 adadaddsssssssddddddddddddddddddddd\
4091 ddddddddddddddddddddddddddddddddddd\
4092 ddddddddddddddddddddddddddddddddddd\
4093 dddddddddddddddddddd Hallelulja? Od\
4094 er?? eeeeeeeeeeeeeeeeeeeeeeeeeeeeee\
4095 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\
4096 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee f\
4097 fffffffffffffffffffffffffffffffffff\
4098 fffffffffffffffffffff ggggggggggggg\
4099 ggggggggggggggggggggggggggggggggggg\
4100 ggggggggggggggggggggggggggggggggggg\
4101 ggggggggggggggggggggggggggggggggggg\
4102 gggggggggggggggg"
4104 # Three tests for MIME encoding and (a bit) content classification.
4105 # At the same time testing -q FILE, < FILE and -t FILE
4107 ${rm} -f "${MBOX}"
4108 < "${BODY}" ${MAILX} ${ARGS} ${ADDARG_UNI} \
4109 -a "${BODY}" -s "${SUB}" "${MBOX}"
4110 check content:001 0 "${MBOX}" '1145066634 6654'
4112 ${rm} -f "${MBOX}"
4113 < /dev/null ${MAILX} ${ARGS} ${ADDARG_UNI} \
4114 -a "${BODY}" -s "${SUB}" -q "${BODY}" "${MBOX}"
4115 check content:002 0 "${MBOX}" '1145066634 6654'
4117 ${rm} -f "${MBOX}"
4118 ( echo "To: ${MBOX}" && echo "Subject: ${SUB}" && echo &&
4119 ${cat} "${BODY}"
4120 ) | ${MAILX} ${ARGS} ${ADDARG_UNI} -Snodot -a "${BODY}" -t
4121 check content:003 0 "${MBOX}" '1145066634 6654'
4123 # Test for [260e19d] (Juergen Daubert)
4124 ${rm} -f "${MBOX}"
4125 echo body | ${MAILX} ${ARGS} "${MBOX}"
4126 check content:004 0 "${MBOX}" '2917662811 98'
4128 # Sending of multiple mails in a single invocation
4129 ${rm} -f "${MBOX}"
4130 ( printf "m ${MBOX}\n~s subject1\nE-Mail Körper 1\n~.\n" &&
4131 printf "m ${MBOX}\n~s subject2\nEmail body 2\n~.\n" &&
4132 echo x
4133 ) | ${MAILX} ${ARGS} ${ADDARG_UNI}
4134 check content:005 0 "${MBOX}" '2098659767 358'
4136 ## $BODY CHANGED
4138 # "Test for" [d6f316a] (Gavin Troy)
4139 ${rm} -f "${MBOX}"
4140 printf "m ${MBOX}\n~s subject1\nEmail body\n~.\nfi ${MBOX}\np\nx\n" |
4141 ${MAILX} ${ARGS} ${ADDARG_UNI} -Spipe-text/plain="@* ${cat}" > "${BODY}"
4142 check content:006 0 "${MBOX}" '2099098650 122'
4143 check content:006-1 - "${BODY}" '794542938 174'
4145 # "Test for" [c299c45] (Peter Hofmann) TODO shouldn't end up QP-encoded?
4146 ${rm} -f "${MBOX}"
4147 ${awk} 'BEGIN{
4148 for(i = 0; i < 10000; ++i)
4149 printf "\xC3\xBC"
4150 #printf "\xF0\x90\x87\x90"
4151 }' | ${MAILX} ${ARGS} ${ADDARG_UNI} -s TestSubject "${MBOX}"
4152 check content:007 0 "${MBOX}" '534262374 61816'
4154 ## Test some more corner cases for header bodies (as good as we can today) ##
4157 ${rm} -f "${MBOX}"
4158 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
4159 -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̲' \
4160 "${MBOX}"
4161 check content:008 0 "${MBOX}" '3370931614 375'
4163 # Single word (overlong line split -- bad standard! Requires injection of
4164 # artificial data!! But can be prevented by using RFC 2047 encoding)
4165 ${rm} -f "${MBOX}"
4166 i=`${awk} 'BEGIN{for(i=0; i<92; ++i) printf "0123456789_"}'`
4167 echo | ${MAILX} ${ARGS} -s "${i}" "${MBOX}"
4168 check content:009 0 "${MBOX}" '489922370 1718'
4170 # Combination of encoded words, space and tabs of varying sort
4171 ${rm} -f "${MBOX}"
4172 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
4173 -s "1Abrä Kaspas1 2Abra Katä b_kaspas2 \
4174 3Abrä Kaspas3 4Abrä Kaspas4 5Abrä Kaspas5 \
4175 6Abra Kaspas6 7Abrä Kaspas7 8Abra Kaspas8 \
4176 9Abra Kaspastäb4-3 10Abra Kaspas1 _ 11Abra Katäb1 \
4177 12Abra Kadabrä1 After Tab after Täb this is NUTS" \
4178 "${MBOX}"
4179 check content:010 0 "${MBOX}" '1676887734 591'
4181 # Overlong multibyte sequence that must be forcefully split
4182 # todo This works even before v15.0, but only by accident
4183 ${rm} -f "${MBOX}"
4184 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
4185 -s "✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
4186 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
4187 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄" \
4188 "${MBOX}"
4189 check content:011 0 "${MBOX}" '3029301775 659'
4191 # Trailing WS
4192 ${rm} -f "${MBOX}"
4193 echo | ${MAILX} ${ARGS} \
4194 -s "1-1 B2 B3 B4 B5 B6 B\
4195 1-2 B2 B3 B4 B5 B6 B\
4196 1-3 B2 B3 B4 B5 B6 B\
4197 1-4 B2 B3 B4 B5 B6 B\
4198 1-5 B2 B3 B4 B5 B6 B\
4199 1-6 B2 B3 B4 B5 B6 " \
4200 "${MBOX}"
4201 check content:012 0 "${MBOX}" '4126167195 297'
4203 # Leading and trailing WS
4204 ${rm} -f "${MBOX}"
4205 echo | ${MAILX} ${ARGS} \
4206 -s " 2-1 B2 B3 B4 B5 B6 B\
4207 1-2 B2 B3 B4 B5 B6 B\
4208 1-3 B2 B3 B4 B5 B6 B\
4209 1-4 B2 B3 B4 B5 B6 " \
4210 "${MBOX}"
4211 check content:013 0 "${MBOX}" '3600624479 236'
4213 # Quick'n dirty RFC 2231 test; i had more when implementing it, but until we
4214 # have a (better) test framework materialize a quick shot
4215 ${rm} -f "${MBOX}"
4216 TRAP_EXIT_ADDONS=./.ttt
4218 mkdir ./.ttt || exit 1
4219 cd ./.ttt || exit 2
4220 : > "ma'ger.txt"
4221 : > "mä'ger.txt"
4222 : > 'diet\ is \curd.txt'
4223 : > 'diet "is" curd.txt'
4224 : > höde-tröge.txt
4225 : > 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
4226 : > höde__tröge__müde__dätte__hätte__vuelle__guelle__aese__aesse__sauerliche__kräuter__österliche__grüße__mäh.txt
4227 : > hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt
4228 : > ✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt
4230 echo bla | ${MAILX} ${ARGS} ${ADDARG_UNI} \
4231 -a "./.ttt/ma'ger.txt" -a "./.ttt/mä'ger.txt" \
4232 -a './.ttt/diet\ is \curd.txt' -a './.ttt/diet "is" curd.txt' \
4233 -a ./.ttt/höde-tröge.txt \
4234 -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 \
4235 -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 \
4236 -a ./.ttt/hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt \
4237 -a ./.ttt/✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt \
4238 "${MBOX}"
4239 check content:014-1 0 "${MBOX}" '684985954 3092'
4241 # `resend' test, reusing $MBOX
4242 ${rm} -f "${BODY}"
4243 printf "Resend ${BODY}\nx\n" | ${MAILX} ${ARGS} -Rf "${MBOX}"
4244 check content:014-2 0 "${BODY}" '684985954 3092'
4246 ${rm} -f "${BODY}"
4247 printf "resend ${BODY}\nx\n" | ${MAILX} ${ARGS} -Rf "${MBOX}"
4248 check content:014-3 0 "${BODY}" '3130352658 3148'
4250 t_epilog
4253 t_all() {
4254 # if have_feat devel; then
4255 # ARGS="${ARGS} -Smemdebug"
4256 # export ARGS
4257 # fi
4259 if [ -n "${UTF8_LOCALE}" ]; then
4260 printf 'Using Unicode locale %s\n' "${UTF8_LOCALE}"
4261 else
4262 printf 'No Unicode locale found, disabling Unicode tests\n'
4265 t_behave
4266 t_content
4269 if [ -z "${CHECK_ONLY}" ]; then
4270 cc_all_configs
4271 else
4272 t_all
4275 [ ${ESTAT} -eq 0 ] && echo Ok || echo >&2 'Errors occurred'
4277 exit ${ESTAT}
4278 # s-sh-mode