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