nail.1: (re)add s_client certificate fetch (Olav Mørkrid)
[s-mailx.git] / cc-test.sh
blobb39958b8d7a28b174f271127d86526fe72fe7123
1 #!/bin/sh -
2 #@ Synopsis: ./cc-test.sh --check-only [s-mailx-binary]
3 #@ ./cc-test.sh --mae-test s-mailx-binary [:TESTNAME:]
4 #@ [./cc-test.sh # Note: performs hundreds of compilations!]
5 #@ The latter generates output files.
6 #@ TODO _All_ the tests should happen in a temporary subdir.
7 # Public Domain
9 # Instead of figuring out the environment in here, require a configured build
10 # system and include that! Our makefile and configure ensure that this test
11 # does not run in the configured, but the user environment nonetheless!
13 if [ -f ./mk-config.ev ]; then
15 elif [ -f snailmail.jpg ] && [ -f .obj/mk-config.ev ]; then
16 cd .obj
17 i=../
18 else
19 echo >&2 'S-nail/S-mailx is not configured.'
20 echo >&2 'This test script requires the shell environment that only the'
21 echo >&2 'configuration script can figure out, even if it will be used to'
22 echo >&2 'test a different binary than the one that would be produced!'
23 echo >&2 '(The necessary information will be in .obj/mk-config.ev.)'
24 echo >&2 'Hit RETURN to run "make config CONFIG=null'
25 read l
26 make config CONFIG=null
28 . ./mk-config.ev
29 if [ -z "${MAILX__CC_TEST_RUNNING}" ]; then
30 MAILX__CC_TEST_RUNNING=1
31 export MAILX__CC_TEST_RUNNING
32 exec "${SHELL}" "${i}${0}" "${@}"
35 # We need *stealthmua* regardless of $SOURCE_DATE_EPOCH, the program name as
36 # such is a compile-time variable
37 ARGS='-:/ -# -Sdotlock-ignore-error -Sexpandaddr=restrict'
38 ARGS="${ARGS}"' -Smime-encoding=quoted-printable -Snosave -Sstealthmua'
39 ADDARG_UNI=-Sttycharset=UTF-8
40 CONF=../make.rc
41 BODY=./.cc-body.txt
42 MBOX=./.cc-test.mbox
43 ERR=./.cc-test.err # Covers only some which cannot be checksummed; not quoted!
44 MAIL=/dev/null
45 #UTF8_LOCALE= autodetected unless set
47 # Note valgrind has problems with FDs in forked childs, which causes some tests
48 # to fail (the FD is rewound and thus will be dumped twice)
49 MEMTESTER=
50 #MEMTESTER='valgrind --leak-check=full --log-file=.vl-%p '
52 ## -- (>8 -- 8<) -- ##
54 msg() {
55 fmt=${1}
56 shift
57 printf >&2 -- "${fmt}\\n" "${@}"
60 ## -- >8 -- 8< -- ##
62 export ARGS ADDARG_UNI CONF BODY MBOX MAIL MAKE awk cat cksum rm sed grep
64 LC_ALL=C LANG=C
65 TZ=UTC
66 # Wed Oct 2 01:50:07 UTC 1996
67 SOURCE_DATE_EPOCH=844221007
69 export LC_ALL LANG TZ SOURCE_DATE_EPOCH
70 unset POSIXLY_CORRECT LOGNAME USER
72 usage() {
73 ${cat} >&2 <<_EOT
74 Synopsis: cc-test.sh --check-only s-mailx-binary
75 Synopsis: cc-test.sh --mae-test s-mailx-binary [:TEST:]
76 Synopsis: cc-test.sh
78 --check-only EXE run the test series, exit success or error;
79 if run in a git(1) checkout then failed tests
80 create test output data files
81 --mae-test EXE [:TEST:] run all or only the given TESTs, and create
82 test output data files; if run in a git(1)
83 checkout with the [test-out] branch available,
84 it will also create file differences
86 Without arguments as many different configurations as possible
87 will be compiled and tested.
88 _EOT
89 exit 1
92 CHECK_ONLY= MAE_TEST= GIT_REPO= MAILX=
93 if [ "${1}" = --check-only ]; then
94 [ ${#} -eq 2 ] || usage
95 CHECK_ONLY=1 MAILX=${2}
96 [ -x "${MAILX}" ] || usage
97 echo 'Mode: --check-only, binary: '"${MAILX}"
98 [ -d ../.git ] && [ -z "${MAILX__CC_TEST_NO_DATA_FILES}" ] && GIT_REPO=1
99 elif [ "${1}" = --mae-test ]; then
100 [ ${#} -ge 2 ] || usage
101 MAE_TEST=1 MAILX=${2}
102 [ -x "${MAILX}" ] || usage
103 shift 2
104 echo 'Mode: --mae-test, binary: '"${MAILX}"
105 [ -d ../.git ] && GIT_REPO=1
106 else
107 [ ${#} -eq 0 ] || usage
108 echo 'Mode: full compile test, this will take a long time...'
109 MAILX__CC_TEST_NO_DATA_FILES=1
110 export MAILX__CC_TEST_NO_DATA_FILES
113 RAWMAILX=${MAILX}
114 MAILX="${MEMTESTER}${MAILX}"
115 export RAWMAILX MAILX
117 if [ -n "${CHECK_ONLY}${MAE_TEST}" ]; then
118 if [ -z "${UTF8_LOCALE}" ]; then
119 # Try ourselfs via nl_langinfo(CODESET) first (requires a new version)
120 if command -v "${RAWMAILX}" >/dev/null 2>&1 &&
121 ("${RAWMAILX}" -:/ -Xxit) >/dev/null 2>&1; then
122 echo 'Trying to detect UTF-8 locale via '"${RAWMAILX}"
123 i=`LC_ALL=C.utf8 "${RAWMAILX}" ${ARGS} -X '
124 \define cset_test {
125 \if [ "${ttycharset}" @i=% utf ]
126 \echo $LC_ALL
127 \xit 0
128 \end
129 \if [ "${#}" -gt 0 ]
130 \wysh set LC_ALL=${1}
131 \shift
132 \eval xcall cset_test "${@}"
133 \end
134 \xit 1
136 \call cset_test C.UTF-8 POSIX.utf8 POSIX.UTF-8 \
137 en_EN.utf8 en_EN.UTF-8 en_US.utf8 en_US.UTF-8
139 [ $? -eq 0 ] && UTF8_LOCALE=$i
142 if [ -z "${UTF8_LOCALE}" ] && (locale yesexpr) >/dev/null 2>&1; then
143 echo 'Trying to detect UTF-8 locale via locale -a'
144 UTF8_LOCALE=`locale -a | { m=
145 while read n; do
146 if { echo ${n} |
147 ${grep} -i -e utf8 -e utf-8; } >/dev/null 2>&1; then
148 m=${n}
149 if { echo ${n} |
150 ${grep} -e POSIX -e en_EN -e en_US; } \
151 >/dev/null 2>&1; then
152 break
155 done
156 echo ${m}
161 if [ -n "${UTF8_LOCALE}" ]; then
162 echo 'Using Unicode locale '"${UTF8_LOCALE}"
163 else
164 echo 'No Unicode locale found, disabling Unicode tests'
168 ESTAT=0
170 TRAP_EXIT_ADDONS=
171 TEST_NAME=
172 trap "${rm} -rf \"${BODY}\" \"${MBOX}\" \"${ERR}\" \${TRAP_EXIT_ADDONS}" EXIT
173 trap "exit 1" HUP INT TERM
175 have_feat() {
176 ( "${RAWMAILX}" ${ARGS} -X'echo $features' -Xx |
177 ${grep} +${1} ) >/dev/null 2>&1
180 t_prolog() {
181 ${rm} -rf "${BODY}" "${MBOX}" ${TRAP_EXIT_ADDONS}
182 TRAP_EXIT_ADDONS=
183 if [ ${#} -gt 0 ]; then
184 TEST_NAME=${1}
185 printf '[%s]\n' "${1}"
188 t_epilog() {
189 t_prolog
192 t_xmta() {
193 [ ${#} -ge 1 ] && __from=${1} ||
194 __from='Silybum Marianum Tue Apr 17 15:55:01 2018'
195 [ ${#} -eq 2 ] && __to=${2} || __to="${MBOX}"
196 ${cat} <<-_EOT > .tmta.sh
197 #!${SHELL} -
198 ( echo 'From '"${__from}" && ${cat} && echo ) >> "${__to}"
199 _EOT
200 chmod 0755 .tmta.sh
203 check() {
204 restat=${?} tid=${1} eestat=${2} f=${3} s=${4}
205 [ "${eestat}" != - ] && [ "${restat}" != "${eestat}" ] &&
206 err "${TESTNAME}-${tid}" 'unexpected status: '"${restat} != ${eestat}"
207 csum="`${cksum} < ${f}`"
208 if [ "${csum}" = "${s}" ]; then
209 maex=
210 printf '%s-%s: ok\n' "${TEST_NAME}" "${tid}"
211 else
212 maex=yes
213 ESTAT=1
214 printf '%s-%s: error: checksum mismatch (got %s)\n' \
215 "${TEST_NAME}" "${tid}" "${csum}"
218 if [ -n "${CHECK_ONLY}${MAE_TEST}" ]; then
219 x="t.${TEST_NAME}-${tid}"
220 if [ -n "${MAE_TEST}" ] || [ -n "${maex}" -a -n "${GIT_REPO}" ]; then
221 ${cp} -f "${f}" ./"${x}"
224 if [ -n "${maex}" ] && [ -n "${GIT_REPO}" ] &&
225 command -v diff >/dev/null 2>&1 &&
226 (git rev-parse --verify test-out) >/dev/null 2>&1 &&
227 git show test-out:"${x}" > ./"${x}".old 2>/dev/null; then
228 diff -ru ./"${x}".old ./"${x}" > "${x}".diff
233 err() {
234 ESTAT=1
235 printf '%s: error: %s\n' ${1} "${2}"
238 check_ex0() {
239 # $1=test name [$2=status]
240 __qm__=${?}
241 [ ${#} -gt 1 ] && __qm__=${2}
242 if [ ${__qm__} -ne 0 ]; then
243 err "${TEST_NAME}-${1}" 'unexpected non-0 exit status'
244 return 0
245 else
246 printf '%s-%s: ok\n' "${TEST_NAME}" "${1}"
247 return 1
251 check_exn0() {
252 # $1=test name [$2=status]
253 __qm__=${?}
254 [ ${#} -gt 1 ] && __qm__=${2}
255 if [ ${__qm__} -eq 0 ]; then
256 err "${TEST_NAME}-${1}" 'unexpected 0 exit status'
257 return 1
258 else
259 printf '%s-%s: ok\n' "${TEST_NAME}" "${1}"
260 return 0
264 if ( [ "$((1 + 1))" = 2 ] ) >/dev/null 2>&1; then
265 add() {
266 echo "$((${1} + ${2}))"
268 else
269 add() {
270 echo `${awk} 'BEGIN{print '${1}' + '${2}'}'`
274 if ( [ "$((2 % 3))" = 2 ] ) >/dev/null 2>&1; then
275 modulo() {
276 echo "$((${1} % ${2}))"
278 else
279 modulo() {
280 echo `${awk} 'BEGIN{print '${1}' % '${2}'}'`
284 t_all() {
285 t_X_opt_input_command_stack
286 t_X_errexit
287 t_S_freeze
288 t_wysh
289 t_input_inject_semicolon_seq
290 t_commandalias
291 t_ifelse
292 t_localopts
293 t_local
294 t_macro_param_shift
295 t_addrcodec
296 t_vexpr
297 t_call_ret
298 t_xcall
299 t_vpospar
300 t_atxplode
301 t_read
303 t_mbox
304 t_maildir
305 t_record_a_resend
306 t_e_H_L_opts
308 t_alternates
309 t_alias
310 # FIXME t_mlist
311 t_filetype
313 t_message_injections
314 t_attachments
315 t_compose_hooks
316 t_C_opt_customhdr
317 t_quote_a_cmd_escapes
319 t_mass_recipients
320 t_mime_types_load_control
321 t_lreply_futh_rth_etc
323 t_mime_if_not_ascii
324 t_xxxheads_rfc2047
325 t_rfc2231
326 t_iconv_mbyte_base64
327 t_iconv_mainbody
328 t_binary_mainbody
329 t_q_t_etc_opts
331 t_s_mime
334 t_X_opt_input_command_stack() {
335 t_prolog X_opt_input_command_stack
337 ${cat} <<- '__EOT' > "${BODY}"
338 echo 1
339 define mac0 {
340 echo mac0-1 via1 $0
342 call mac0
343 echo 2
344 source '\
345 echo "define mac1 {";\
346 echo " echo mac1-1 via1 \$0";\
347 echo " call mac0";\
348 echo " echo mac1-2";\
349 echo " call mac2";\
350 echo " echo mac1-3";\
351 echo "}";\
352 echo "echo 1-1";\
353 echo "define mac2 {";\
354 echo " echo mac2-1 via1 \$0";\
355 echo " call mac0";\
356 echo " echo mac2-2";\
357 echo "}";\
358 echo "echo 1-2";\
359 echo "call mac1";\
360 echo "echo 1-3";\
361 echo "source \"\
362 echo echo 1-1-1 via1 \$0;\
363 echo call mac0;\
364 echo echo 1-1-2;\
365 | \"";\
366 echo "echo 1-4";\
368 echo 3
369 call mac2
370 echo 4
371 undefine *
372 __EOT
374 # The -X option supports multiline arguments, and those can internally use
375 # reverse solidus newline escaping. And all -X options are joined...
376 APO=\'
377 < "${BODY}" ${MAILX} ${ARGS} \
378 -X 'e\' \
379 -X ' c\' \
380 -X ' h\' \
381 -X ' o \' \
382 -X 1 \
384 define mac0 {
385 echo mac0-1 via2 $0
387 call mac0
388 echo 2
391 source '${APO}'\
392 echo "define mac1 {";\
393 echo " echo mac1-1 via2 \$0";\
394 echo " call mac0";\
395 echo " echo mac1-2";\
396 echo " call mac2";\
397 echo " echo mac1-3";\
398 echo "}";\
399 echo "echo 1-1";\
400 echo "define mac2 {";\
401 echo " echo mac2-1 via2 \$0";\
402 echo " call mac0";\
403 echo " echo mac2-2";\
404 echo "}";\
405 echo "echo 1-2";\
406 echo "call mac1";\
407 echo "echo 1-3";\
408 echo "source \"\
409 echo echo 1-1-1 via2 \$0;\
410 echo call mac0;\
411 echo echo 1-1-2;\
412 | \"";\
413 echo "echo 1-4";\
414 | '${APO}'
415 echo 3
418 call mac2
419 echo 4
420 undefine *
421 ' > "${MBOX}"
423 check 1 0 "${MBOX}" '1786542668 416'
425 t_epilog
428 t_X_errexit() {
429 t_prolog X_errexit
430 if have_feat uistrings; then :; else
431 echo 'x_errexit: unsupported, skipped'
432 return
435 ${cat} <<- '__EOT' > "${BODY}"
436 echo one
437 echos nono
438 echo two
439 __EOT
441 </dev/null ${MAILX} ${ARGS} -Snomemdebug \
442 -X'echo one' -X' echos nono ' -X'echo two' \
443 > "${MBOX}" 2>&1
444 check 1 0 "${MBOX}" '916157812 53'
446 </dev/null ${MAILX} ${ARGS} -X'source '"${BODY}" -Snomemdebug \
447 > "${MBOX}" 2>&1
448 check 2 0 "${MBOX}" '916157812 53'
450 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Snomemdebug \
451 > "${MBOX}" 2>&1
452 check 3 0 "${MBOX}" '916157812 53'
456 </dev/null ${MAILX} ${ARGS} -Serrexit -Snomemdebug \
457 -X'echo one' -X' echos nono ' -X'echo two' \
458 > "${MBOX}" 2>&1
459 check 4 1 "${MBOX}" '2118430867 49'
461 </dev/null ${MAILX} ${ARGS} -X'source '"${BODY}" -Serrexit -Snomemdebug \
462 > "${MBOX}" 2>&1
463 check 5 1 "${MBOX}" '2118430867 49'
465 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Serrexit -Snomemdebug \
466 > "${MBOX}" 2>&1
467 check 6 1 "${MBOX}" '12955965 172'
469 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Sposix -Snomemdebug \
470 > "${MBOX}" 2>&1
471 check 7 1 "${MBOX}" '12955965 172'
473 ## Repeat 4-7 with ignerr set
475 ${sed} -e 's/^echos /ignerr echos /' < "${BODY}" > "${MBOX}"
477 </dev/null ${MAILX} ${ARGS} -Serrexit -Snomemdebug \
478 -X'echo one' -X'ignerr echos nono ' -X'echo two' \
479 > "${BODY}" 2>&1
480 check 8 0 "${BODY}" '916157812 53'
482 </dev/null ${MAILX} ${ARGS} -X'source '"${MBOX}" -Serrexit -Snomemdebug \
483 > "${BODY}" 2>&1
484 check 9 0 "${BODY}" '916157812 53'
486 </dev/null MAILRC="${MBOX}" ${MAILX} ${ARGS} -:u -Serrexit -Snomemdebug \
487 > "${BODY}" 2>&1
488 check 10 0 "${BODY}" '916157812 53'
490 </dev/null MAILRC="${MBOX}" ${MAILX} ${ARGS} -:u -Sposix -Snomemdebug \
491 > "${BODY}" 2>&1
492 check 11 0 "${BODY}" '916157812 53'
494 t_epilog
497 t_S_freeze() {
498 t_prolog S_freeze
499 oterm=$TERM
500 unset TERM
502 # Test basic assumption
503 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} \
504 -X'echo asksub<$asksub> dietcurd<$dietcurd>' \
505 -Xx > "${MBOX}" 2>&1
506 check 1 0 "${MBOX}" '270686329 21'
509 ${cat} <<- '__EOT' > "${BODY}"
510 echo asksub<$asksub>
511 set asksub
512 echo asksub<$asksub>
513 __EOT
514 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
515 -Snoasksub -Sasksub -Snoasksub \
516 -X'echo asksub<$asksub>' -X'set asksub' -X'echo asksub<$asksub>' \
517 -Xx > "${MBOX}" 2>&1
518 check 2 0 "${MBOX}" '3182942628 37'
520 ${cat} <<- '__EOT' > "${BODY}"
521 echo asksub<$asksub>
522 unset asksub
523 echo asksub<$asksub>
524 __EOT
525 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
526 -Snoasksub -Sasksub \
527 -X'echo asksub<$asksub>' -X'unset asksub' -X'echo asksub<$asksub>' \
528 -Xx > "${MBOX}" 2>&1
529 check 3 0 "${MBOX}" '2006554293 39'
532 ${cat} <<- '__EOT' > "${BODY}"
533 echo dietcurd<$dietcurd>
534 set dietcurd=cherry
535 echo dietcurd<$dietcurd>
536 __EOT
537 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
538 -Sdietcurd=strawberry -Snodietcurd -Sdietcurd=vanilla \
539 -X'echo dietcurd<$dietcurd>' -X'unset dietcurd' \
540 -X'echo dietcurd<$dietcurd>' \
541 -Xx > "${MBOX}" 2>&1
542 check 4 0 "${MBOX}" '1985768109 65'
544 ${cat} <<- '__EOT' > "${BODY}"
545 echo dietcurd<$dietcurd>
546 unset dietcurd
547 echo dietcurd<$dietcurd>
548 __EOT
549 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
550 -Sdietcurd=strawberry -Snodietcurd \
551 -X'echo dietcurd<$dietcurd>' -X'set dietcurd=vanilla' \
552 -X'echo dietcurd<$dietcurd>' \
553 -Xx > "${MBOX}" 2>&1
554 check 5 0 "${MBOX}" '151574279 51'
556 # TODO once we have a detached one with env=1..
557 if [ -n "`</dev/null ${MAILX} ${ARGS} -X'!echo \$TERM' -Xx`" ]; then
558 echo 's_freeze-{6,7}: shell sets $TERM, skipped'
559 else
560 ${cat} <<- '__EOT' > "${BODY}"
561 !echo "shell says TERM<$TERM>"
562 echo TERM<$TERM>
563 !echo "shell says TERM<$TERM>"
564 set TERM=cherry
565 !echo "shell says TERM<$TERM>"
566 echo TERM<$TERM>
567 !echo "shell says TERM<$TERM>"
568 __EOT
569 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
570 -STERM=strawberry -SnoTERM -STERM=vanilla \
571 -X'echo mail<$TERM>' -X'unset TERM' \
572 -X'!echo "shell says TERM<$TERM>"' -X'echo TERM<$TERM>' \
573 -Xx > "${MBOX}" 2>&1
574 check 6 0 "${MBOX}" '1211476036 167'
576 ${cat} <<- '__EOT' > "${BODY}"
577 !echo "shell says TERM<$TERM>"
578 echo TERM<$TERM>
579 !echo "shell says TERM<$TERM>"
580 set TERM=cherry
581 !echo "shell says TERM<$TERM>"
582 echo TERM<$TERM>
583 !echo "shell says TERM<$TERM>"
584 __EOT
585 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
586 -STERM=strawberry -SnoTERM \
587 -X'echo TERM<$TERM>' -X'set TERM=vanilla' \
588 -X'!echo "shell says TERM<$TERM>"' -X'echo TERM<$TERM>' \
589 -Xx > "${MBOX}" 2>&1
590 check 7 0 "${MBOX}" '3365080441 132'
593 TERM=$oterm
594 t_epilog
597 t_wysh() {
598 t_prolog wysh
600 ${cat} <<- '__EOT' > "${BODY}"
602 echo abcd
603 echo a'b'c'd'
604 echo a"b"c"d"
605 echo a$'b'c$'d'
606 echo 'abcd'
607 echo "abcd"
608 echo $'abcd'
609 echo a\ b\ c\ d
610 echo a 'b c' d
611 echo a "b c" d
612 echo a $'b c' d
614 echo 'a$`"\'
615 echo "a\$\`'\"\\"
616 echo $'a\$`\'\"\\'
617 echo $'a\$`\'"\\'
618 # DIET=CURD TIED=
619 echo 'a${DIET}b${TIED}c\${DIET}d\${TIED}e' # COMMENT
620 echo "a${DIET}b${TIED}c\${DIET}d\${TIED}e"
621 echo $'a${DIET}b${TIED}c\${DIET}d\${TIED}e'
623 echo a$'\101\0101\x41\u0041\u41\U00000041\U41'c
624 echo a$'\u0041\u41\u0C1\U00000041\U41'c
625 echo a$'\377'c
626 echo a$'\0377'c
627 echo a$'\400'c
628 echo a$'\0400'c
629 echo a$'\U1100001'c
631 echo a$'b\0c'd
632 echo a$'b\00c'de
633 echo a$'b\000c'df
634 echo a$'b\0000c'dg
635 echo a$'b\x0c'dh
636 echo a$'b\x00c'di
637 echo a$'b\u0'dj
638 echo a$'b\u00'dk
639 echo a$'b\u000'dl
640 echo a$'b\u0000'dm
641 echo a$'b\U0'dn
642 echo a$'b\U00'do
643 echo a$'b\U000'dp
644 echo a$'b\U0000'dq
645 echo a$'b\U00000'dr
646 echo a$'b\U000000'ds
647 echo a$'b\U0000000'dt
648 echo a$'b\U00000000'du
650 echo a$'\cI'b
651 echo a$'\011'b
652 echo a$'\x9'b
653 echo a$'\u9'b
654 echo a$'\U9'b
655 echo a$'\c@'b c d
656 __EOT
658 if [ -z "${UTF8_LOCALE}" ]; then
659 echo 'Skip wysh-unicode, no UTF8_LOCALE'
660 else
661 < "${BODY}" DIET=CURD TIED= \
662 LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} > "${MBOX}" 2>>${ERR}
663 check unicode 0 "${MBOX}" '475805847 317'
666 < "${BODY}" DIET=CURD TIED= ${MAILX} ${ARGS} > "${MBOX}" 2>>${ERR}
667 check c 0 "${MBOX}" '1473887148 321'
669 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
670 wysh set mager='\hey\'
671 varshow mager
672 wysh set mager="\hey\\"
673 varshow mager
674 wysh set mager=$'\hey\\'
675 varshow mager
676 __EOT
677 check 3 0 "${MBOX}" '1289698238 69'
679 t_epilog
682 t_input_inject_semicolon_seq() {
683 t_prolog input_inject_semicolon_seq
685 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
686 define mydeepmac {
687 echon '(mydeepmac)';
689 define mymac {
690 echon this_is_mymac;call mydeepmac;echon ';';
692 echon one';';call mymac;echon two";";call mymac;echo three$';';
693 define mymac {
694 echon this_is_mymac;call mydeepmac;echon ,TOO'!;';
696 echon one';';call mymac;echon two";";call mymac;echo three$';';
697 __EOT
699 check 1 0 "${MBOX}" '512117110 140'
701 t_epilog
704 t_commandalias() {
705 t_prolog commandalias
707 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
708 commandalias echo echo hoho
709 echo stop.
710 commandalias X Xx
711 commandalias Xx XxX
712 commandalias XxX XxXx
713 commandalias XxXx XxXxX
714 commandalias XxXxX XxXxXx
715 commandalias XxXxXx echo huhu
716 commandalias XxXxXxX echo huhu
718 commandalias XxXxXx XxXxXxX
720 uncommandalias echo
721 commandalias XxXxXx echo huhu
723 __EOT
725 check 1 0 "${MBOX}" '1638809585 36'
727 t_epilog
730 t_ifelse() {
731 t_prolog ifelse
733 # Nestable conditions test
734 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
735 if 0
736 echo 1.err
737 else
738 echo 1.ok
739 endif
740 if 1
741 echo 2.ok
742 else
743 echo 2.err
744 endif
745 if $dietcurd
746 echo 3.err
747 else
748 echo 3.ok
749 endif
750 set dietcurd=yoho
751 if $dietcurd
752 echo 4.ok
753 else
754 echo 4.err
755 endif
756 if $dietcurd == 'yoho'
757 echo 5.ok
758 else
759 echo 5.err
760 endif
761 if $dietcurd @== 'Yoho'
762 echo 5-1.ok
763 else
764 echo 5-1.err
765 endif
766 if $dietcurd == 'Yoho'
767 echo 5-2.err
768 else
769 echo 5-2.ok
770 endif
771 if $dietcurd != 'yoho'
772 echo 6.err
773 else
774 echo 6.ok
775 endif
776 if $dietcurd @!= 'Yoho'
777 echo 6-1.err
778 else
779 echo 6-1.ok
780 endif
781 if $dietcurd != 'Yoho'
782 echo 6-2.ok
783 else
784 echo 6-2.err
785 endif
786 # Nesting
787 if faLse
788 echo 7.err1
789 if tRue
790 echo 7.err2
791 if yEs
792 echo 7.err3
793 else
794 echo 7.err4
795 endif
796 echo 7.err5
797 endif
798 echo 7.err6
799 else
800 echo 7.ok7
801 if YeS
802 echo 7.ok8
803 if No
804 echo 7.err9
805 else
806 echo 7.ok9
807 endif
808 echo 7.ok10
809 else
810 echo 7.err11
811 if yeS
812 echo 7.err12
813 else
814 echo 7.err13
815 endif
816 endif
817 echo 7.ok14
818 endif
819 if r
820 echo 8.ok1
821 if R
822 echo 8.ok2
823 else
824 echo 8.err2
825 endif
826 echo 8.ok3
827 else
828 echo 8.err1
829 endif
830 if s
831 echo 9.err1
832 else
833 echo 9.ok1
834 if S
835 echo 9.err2
836 else
837 echo 9.ok2
838 endif
839 echo 9.ok3
840 endif
841 # `elif'
842 if $dietcurd == 'yohu'
843 echo 10.err1
844 elif $dietcurd == 'yoha'
845 echo 10.err2
846 elif $dietcurd == 'yohe'
847 echo 10.err3
848 elif $dietcurd == 'yoho'
849 echo 10.ok1
850 if $dietcurd == 'yohu'
851 echo 10.err4
852 elif $dietcurd == 'yoha'
853 echo 10.err5
854 elif $dietcurd == 'yohe'
855 echo 10.err6
856 elif $dietcurd == 'yoho'
857 echo 10.ok2
858 if $dietcurd == 'yohu'
859 echo 10.err7
860 elif $dietcurd == 'yoha'
861 echo 10.err8
862 elif $dietcurd == 'yohe'
863 echo 10.err9
864 elif $dietcurd == 'yoho'
865 echo 10.ok3
866 else
867 echo 10.err10
868 endif
869 else
870 echo 10.err11
871 endif
872 else
873 echo 10.err12
874 endif
875 # integer
876 set dietcurd=10
877 if $dietcurd -lt 11
878 echo 11.ok1
879 if $dietcurd -gt 9
880 echo 11.ok2
881 else
882 echo 11.err2
883 endif
884 if $dietcurd -eq 10
885 echo 11.ok3
886 else
887 echo 11.err3
888 endif
889 if $dietcurd -ge 10
890 echo 11.ok4
891 else
892 echo 11.err4
893 endif
894 if $dietcurd -le 10
895 echo 11.ok5
896 else
897 echo 11.err5
898 endif
899 if $dietcurd -ge 11
900 echo 11.err6
901 else
902 echo 11.ok6
903 endif
904 if $dietcurd -le 9
905 echo 11.err7
906 else
907 echo 11.ok7
908 endif
909 else
910 echo 11.err1
911 endif
912 set dietcurd=Abc
913 if $dietcurd < aBd
914 echo 12.ok1
915 if $dietcurd @> abB
916 echo 12.ok2
917 else
918 echo 12.err2
919 endif
920 if $dietcurd @== aBC
921 echo 12.ok3
922 else
923 echo 12.err3
924 endif
925 if $dietcurd @>= AbC
926 echo 12.ok4
927 else
928 echo 12.err4
929 endif
930 if $dietcurd @<= ABc
931 echo 12.ok5
932 else
933 echo 12.err5
934 endif
935 if $dietcurd @>= abd
936 echo 12.err6
937 else
938 echo 12.ok6
939 endif
940 if $dietcurd @<= abb
941 echo 12.err7
942 else
943 echo 12.ok7
944 endif
945 else
946 echo 12.err1
947 endif
948 if $dietcurd < aBc
949 echo 12-1.ok
950 else
951 echo 12-1.err
952 endif
953 if $dietcurd @< aBc
954 echo 12-2.err
955 else
956 echo 12-2.ok
957 endif
958 if $dietcurd > ABc
959 echo 12-3.ok
960 else
961 echo 12-3.err
962 endif
963 if $dietcurd @> ABc
964 echo 12-3.err
965 else
966 echo 12-3.ok
967 endif
968 if $dietcurd @i=% aB
969 echo 13.ok
970 else
971 echo 13.err
972 endif
973 if $dietcurd =% aB
974 echo 13-1.err
975 else
976 echo 13-1.ok
977 endif
978 if $dietcurd @=% bC
979 echo 14.ok
980 else
981 echo 14.err
982 endif
983 if $dietcurd !% aB
984 echo 15-1.ok
985 else
986 echo 15-1.err
987 endif
988 if $dietcurd @!% aB
989 echo 15-2.err
990 else
991 echo 15-2.ok
992 endif
993 if $dietcurd !% bC
994 echo 15-3.ok
995 else
996 echo 15-3.err
997 endif
998 if $dietcurd @!% bC
999 echo 15-4.err
1000 else
1001 echo 15-4.ok
1002 endif
1003 if $dietcurd =% Cd
1004 echo 16.err
1005 else
1006 echo 16.ok
1007 endif
1008 if $dietcurd !% Cd
1009 echo 17.ok
1010 else
1011 echo 17.err
1012 endif
1013 set diet=abc curd=abc
1014 if $diet == $curd
1015 echo 18.ok
1016 else
1017 echo 18.err
1018 endif
1019 set diet=abc curd=abcd
1020 if $diet != $curd
1021 echo 19.ok
1022 else
1023 echo 19.err
1024 endif
1025 # 1. Shitty grouping capabilities as of today
1026 unset diet curd ndefined
1027 if [ [ false ] || [ false ] || [ true ] ] && [ [ false ] || [ true ] ] && \
1028 [ yes ]
1029 echo 20.ok
1030 else
1031 echo 20.err
1032 endif
1033 if [ [ [ [ 0 ] || [ 1 ] ] && [ [ 1 ] || [ 0 ] ] ] && [ 1 ] ] && [ yes ]
1034 echo 21.ok
1035 else
1036 echo 21.err
1037 endif
1038 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] ]
1039 echo 22.ok
1040 else
1041 echo 22.err
1042 endif
1043 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] ]
1044 echo 23.ok
1045 else
1046 echo 23.err
1047 endif
1048 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] && [ no ]
1049 echo 24.err
1050 else
1051 echo 24.ok
1052 endif
1053 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] \
1054 && [ no ] || [ yes ]
1055 echo 25.ok
1056 else
1057 echo 25.err
1058 endif
1059 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
1060 echo 26.ok
1061 else
1062 echo 26.err
1063 endif
1064 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 0 ] ]
1065 echo 27.err
1066 else
1067 echo 27.ok
1068 endif
1069 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 0 ] ] && [ 1 ] ] ] && [ 1 ] ]
1070 echo 28.err
1071 else
1072 echo 28.ok
1073 endif
1074 if [ [ [ [ [ [ [ 0 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
1075 echo 29.err
1076 else
1077 echo 29.ok
1078 endif
1079 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 0 ]
1080 echo 30.err
1081 else
1082 echo 30.ok
1083 endif
1084 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 1 ]
1085 echo 31.ok
1086 else
1087 echo 31.err
1088 endif
1089 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ]
1090 echo 32.err
1091 else
1092 echo 32.ok
1093 endif
1094 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 1 ]
1095 echo 33.ok
1096 else
1097 echo 33.err
1098 endif
1099 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 0 ]
1100 echo 34.err
1101 else
1102 echo 34.ok
1103 endif
1104 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 1 ]
1105 echo 35.ok
1106 else
1107 echo 35.err
1108 endif
1109 set diet=yo curd=ho
1110 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
1111 echo 36.err
1112 else
1113 echo 36.ok
1114 endif
1115 set ndefined
1116 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
1117 echo 37.ok
1118 else
1119 echo 37.err
1120 endif
1121 # 2. Shitty grouping capabilities as of today
1122 unset diet curd ndefined
1123 if [ false || false || true ] && [ false || true ] && yes
1124 echo 40.ok
1125 else
1126 echo 40.err
1127 endif
1128 if [ [ [ 0 || 1 ] && [ 1 || 0 ] ] && 1 ] && [ yes ]
1129 echo 41.ok
1130 else
1131 echo 41.err
1132 endif
1133 if [ 1 || 0 || 0 || 0 ]
1134 echo 42.ok
1135 else
1136 echo 42.err
1137 endif
1138 if [ 1 || 0 || 0 || 0 || [ 1 ] ]
1139 echo 43.ok
1140 else
1141 echo 43.err
1142 endif
1143 if [ 1 || 0 || 0 || 0 || [ 1 ] || 1 ] && no
1144 echo 44.err
1145 else
1146 echo 44.ok
1147 endif
1148 if [ 1 || 0 || 0 || 0 || 1 || [ 1 ] ] && no || [ yes ]
1149 echo 45.ok
1150 else
1151 echo 45.err
1152 endif
1153 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && 1 ] ] && [ 1 ] ]
1154 echo 46.ok
1155 else
1156 echo 46.err
1157 endif
1158 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && [ 1 ] ] ] && 0 ]
1159 echo 47.err
1160 else
1161 echo 47.ok
1162 endif
1163 if [ [ [ [ [ [ [ 1 ] ] && 1 ] && 0 ] && [ 1 ] ] ] && 1 ]
1164 echo 48.err
1165 else
1166 echo 48.ok
1167 endif
1168 if [ [ [ [ [ [ 0 ] && 1 ] && 1 ] && 1 ] ] && 1 ]
1169 echo 49.err
1170 else
1171 echo 49.ok
1172 endif
1173 if 1 || 0 || 0 || 0 && 0
1174 echo 50.err
1175 else
1176 echo 50.ok
1177 endif
1178 if 1 || 0 || 0 || 0 && 1
1179 echo 51.ok
1180 else
1181 echo 51.err
1182 endif
1183 if 0 || 0 || 0 || 1 && 0
1184 echo 52.err
1185 else
1186 echo 52.ok
1187 endif
1188 if 0 || 0 || 0 || 1 && 1
1189 echo 53.ok
1190 else
1191 echo 53.err
1192 endif
1193 if 0 || 0 || 0 || 1 && 0 || 1 && 0
1194 echo 54.err
1195 else
1196 echo 54.ok
1197 endif
1198 if 0 || 0 || 0 || 1 && 0 || 1 && 1
1199 echo 55.ok
1200 else
1201 echo 55.err
1202 endif
1203 set diet=yo curd=ho
1204 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
1205 echo 56.err
1206 else
1207 echo 56.ok
1208 endif
1209 if $diet == 'yo' && $curd == 'ho' && $ndefined
1210 echo 57.err
1211 else
1212 echo 57.ok
1213 endif
1214 set ndefined
1215 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
1216 echo 57.ok
1217 else
1218 echo 57.err
1219 endif
1220 if $diet == 'yo' && $curd == 'ho' && $ndefined
1221 echo 58.ok
1222 else
1223 echo 58.err
1224 endif
1225 if [ [ [ [ [ [ $diet == 'yo' && $curd == 'ho' && $ndefined ] ] ] ] ] ]
1226 echo 59.ok
1227 else
1228 echo 59.err
1229 endif
1230 # Some more en-braced variables
1231 set diet=yo curd=ho
1232 if ${diet} == ${curd}
1233 echo 70.err
1234 else
1235 echo 70.ok
1236 endif
1237 if ${diet} != ${curd}
1238 echo 71.ok
1239 else
1240 echo 71.err
1241 endif
1242 if $diet == ${curd}
1243 echo 72.err
1244 else
1245 echo 72.ok
1246 endif
1247 if ${diet} == $curd
1248 echo 73.err
1249 else
1250 echo 73.ok
1251 endif
1252 # Unary !
1253 if ! 0 && ! ! 1 && ! ! ! ! 2 && 3
1254 echo 80.ok
1255 else
1256 echo 80.err
1257 endif
1258 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ ! 2 ] ] ] && 3
1259 echo 81.ok
1260 else
1261 echo 81.err
1262 endif
1263 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1264 echo 82.ok
1265 else
1266 echo 82.err
1267 endif
1268 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
1269 echo 83.err
1270 else
1271 echo 83.ok
1272 endif
1273 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
1274 echo 84.err
1275 else
1276 echo 84.ok
1277 endif
1278 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1279 echo 85.err
1280 else
1281 echo 85.ok
1282 endif
1283 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1284 echo 86.err
1285 else
1286 echo 86.ok
1287 endif
1288 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] || 3
1289 echo 87.ok
1290 else
1291 echo 87.err
1292 endif
1293 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! ! [ 2 ] ] ] ] ]
1294 echo 88.ok
1295 else
1296 echo 88.err
1297 endif
1298 # Unary !, odd
1299 if ! 0 && ! ! 1 && ! ! ! 0 && 3
1300 echo 90.ok
1301 else
1302 echo 90.err
1303 endif
1304 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ 0 ] ] ] && 3
1305 echo 91.ok
1306 else
1307 echo 91.err
1308 endif
1309 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ [ 0 ] ] ] ] ] && 3
1310 echo 92.ok
1311 else
1312 echo 92.err
1313 endif
1314 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! ! [ ! [ ! 0 ] ] ] ] && ! 3
1315 echo 93.err
1316 else
1317 echo 93.ok
1318 endif
1319 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ ! [ ! [ ! [ ! 0 ] ] ] ] && 3
1320 echo 94.ok
1321 else
1322 echo 94.err
1323 endif
1324 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! ! [ ! [ ! [ ! [ 0 ] ] ] ] ] && 3
1325 echo 95.err
1326 else
1327 echo 95.ok
1328 endif
1329 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! ! 0 ] ] ] ] && 3
1330 echo 96.err
1331 else
1332 echo 96.ok
1333 endif
1334 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ ! 0 ] ] ] ] ] || 3
1335 echo 97.ok
1336 else
1337 echo 97.err
1338 endif
1339 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! [ 0 ] ] ] ] ]
1340 echo 98.ok
1341 else
1342 echo 98.err
1343 endif
1344 __EOT
1346 check normal 0 "${MBOX}" '1688759742 719'
1348 if have_feat regex; then
1349 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
1350 set dietcurd=yoho
1351 if $dietcurd =~ '^yo.*'
1352 echo 1.ok
1353 else
1354 echo 1.err
1355 endif
1356 if $dietcurd =~ '^Yo.*'
1357 echo 1-1.err
1358 else
1359 echo 1-1.ok
1360 endif
1361 if $dietcurd @=~ '^Yo.*'
1362 echo 1-2.ok
1363 else
1364 echo 1-2.err
1365 endif
1366 if $dietcurd =~ '^yOho.+'
1367 echo 2.err
1368 else
1369 echo 2.ok
1370 endif
1371 if $dietcurd @!~ '.*Ho$'
1372 echo 3.err
1373 else
1374 echo 3.ok
1375 endif
1376 if $dietcurd !~ '.+yohO$'
1377 echo 4.ok
1378 else
1379 echo 4.err
1380 endif
1381 if [ $dietcurd @i!~ '.+yoho$' ]
1382 echo 5.ok
1383 else
1384 echo 5.err
1385 endif
1386 if ! [ $dietcurd @i=~ '.+yoho$' ]
1387 echo 6.ok
1388 else
1389 echo 6.err
1390 endif
1391 if ! ! [ $dietcurd @i!~ '.+yoho$' ]
1392 echo 7.ok
1393 else
1394 echo 7.err
1395 endif
1396 if ! [ ! [ $dietcurd @i!~ '.+yoho$' ] ]
1397 echo 8.ok
1398 else
1399 echo 8.err
1400 endif
1401 if [ ! [ ! [ $dietcurd @i!~ '.+yoho$' ] ] ]
1402 echo 9.ok
1403 else
1404 echo 9.err
1405 endif
1406 if ! [ ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
1407 echo 10.err
1408 else
1409 echo 10.ok
1410 endif
1411 if ! ! ! $dietcurd !~ '.+yoho$'
1412 echo 11.err
1413 else
1414 echo 11.ok
1415 endif
1416 if ! ! ! $dietcurd =~ '.+yoho$'
1417 echo 12.ok
1418 else
1419 echo 12.err
1420 endif
1421 if ! [ ! ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
1422 echo 13.ok
1423 else
1424 echo 13.err
1425 endif
1426 set diet=abc curd='^abc$'
1427 if $diet =~ $curd
1428 echo 14.ok
1429 else
1430 echo 14.err
1431 endif
1432 set diet=abc curd='^abcd$'
1433 if $diet !~ $curd
1434 echo 15.ok
1435 else
1436 echo 15.err
1437 endif
1438 __EOT
1440 check regex 0 "${MBOX}" '1115671789 95'
1441 else
1442 printf 'if-regex: unsupported, skipped\n'
1445 t_epilog
1448 t_localopts() {
1449 t_prolog localopts
1451 # Nestable conditions test
1452 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
1453 define t2 {
1454 echo in: t2
1455 set t2=t2
1456 echo $t2
1458 define t1 {
1459 echo in: t1
1460 set gv1=gv1
1461 localopts on
1462 set lv1=lv1 lv2=lv2
1463 set lv3=lv3
1464 call t2
1465 localopts off
1466 set gv2=gv2
1467 echo $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2
1469 define t0 {
1470 echo in: t0
1471 call t1
1472 echo $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2
1473 echo "$gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2"
1475 account trouble {
1476 echo in: trouble
1477 call t0
1479 call t0
1480 unset gv1 gv2
1481 account trouble
1482 echo active trouble: $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t3
1483 account null
1484 echo active null: $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t3
1487 define ll2 {
1488 localopts $1
1489 set x=2
1490 echo ll2=$x
1492 define ll1 {
1493 wysh set y=$1; shift; eval localopts $y; localopts $1; shift
1494 set x=1
1495 echo ll1.1=$x
1496 call ll2 $1
1497 echo ll1.2=$x
1499 define ll0 {
1500 wysh set y=$1; shift; eval localopts $y; localopts $1; shift
1501 set x=0
1502 echo ll0.1=$x
1503 call ll1 $y "$@"
1504 echo ll0.2=$x
1506 define llx {
1507 echo ----- $1: $2 -> $3 -> $4
1508 echo ll-1.1=$x
1509 eval localopts $1
1510 call ll0 "$@"
1511 echo ll-1.2=$x
1512 unset x
1514 define lly {
1515 call llx 'call off' on on on
1516 call llx 'call off' off on on
1517 call llx 'call off' on off on
1518 call llx 'call off' on off off
1519 localopts call-fixate on
1520 call llx 'call-fixate on' on on on
1521 call llx 'call-fixate on' off on on
1522 call llx 'call-fixate on' on off on
1523 call llx 'call-fixate on' on off off
1524 unset x;localopts call on
1525 call llx 'call on' on on on
1526 call llx 'call on' off on on
1527 call llx 'call on' on off on
1528 call llx 'call on' on off off
1530 call lly
1531 __EOT
1533 check 1 0 "${MBOX}" '4016155249 1246'
1535 t_epilog
1538 t_local() {
1539 t_prolog local
1541 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
1542 define du2 {
1543 echo du2-1 du=$du
1544 local set du=$1
1545 echo du2-2 du=$du
1546 local unset du
1547 echo du2-3 du=$du
1549 define du {
1550 local set du=dudu
1551 echo du-1 du=$du
1552 call du2 du2du2
1553 echo du-2 du=$du
1554 local set nodu
1555 echo du-3 du=$du
1557 define ich {
1558 echo ich-1 du=$du
1559 call du
1560 echo ich-2 du=$du
1562 define wir {
1563 localopts $1
1564 set du=wirwir
1565 echo wir-1 du=$du
1566 call ich
1567 echo wir-2 du=$du
1569 echo ------- global-1 du=$du
1570 call ich
1571 echo ------- global-2 du=$du
1572 set du=global
1573 call ich
1574 echo ------- global-3 du=$du
1575 call wir on
1576 echo ------- global-4 du=$du
1577 call wir off
1578 echo ------- global-5 du=$du
1579 __EOT
1581 check 1 0 "${MBOX}" '2411598140 641'
1583 t_epilog
1586 t_macro_param_shift() {
1587 t_prolog macro_param_shift
1589 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>>${ERR}
1590 define t2 {
1591 echo in: t2
1592 echo t2.0 has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1593 localopts on
1594 wysh set ignerr=$1
1595 shift
1596 localopts off
1597 echo t2.1 has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1598 if [ $# > 1 ] || [ $ignerr == '' ]
1599 shift 2
1600 else
1601 ignerr shift 2
1602 endif
1603 echo t2.2:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1604 shift 0
1605 echo t2.3:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1606 if [ $# > 0 ]
1607 shift
1608 endif
1609 echo t2.4:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1611 define t1 {
1612 set errexit
1613 echo in: t1
1614 call t2 1 you get four args
1615 echo t1.1: $?';' ignerr ($ignerr) should not exist
1616 call t2 1 you get 'three args'
1617 echo t1.2: $?';' ignerr ($ignerr) should not exist
1618 call t2 1 you 'get two args'
1619 echo t1.3: $?';' ignerr ($ignerr) should not exist
1620 call t2 1 'you get one arg'
1621 echo t1.4: $?';' ignerr ($ignerr) should not exist
1622 ignerr call t2 '' 'you get one arg'
1623 echo t1.5: $?';' ignerr ($ignerr) should not exist
1625 call t1
1626 __EOT
1628 check 1 0 "${MBOX}" '1402489146 1682'
1630 t_epilog
1633 t_addrcodec() {
1634 t_prolog addrcodec
1636 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
1637 vput addrcodec res e 1 <doog@def>
1638 echo $?/$^ERRNAME $res
1639 eval vput addrcodec res d $res
1640 echo $?/$^ERRNAME $res
1641 vput addrcodec res e 2 . <doog@def>
1642 echo $?/$^ERRNAME $res
1643 eval vput addrcodec res d $res
1644 echo $?/$^ERRNAME $res
1645 vput addrcodec res e 3 Sauer Dr. <doog@def>
1646 echo $?/$^ERRNAME $res
1647 eval vput addrcodec res d $res
1648 echo $?/$^ERRNAME $res
1649 vput addrcodec res e 3.50 Sauer (Ma) Dr. <doog@def>
1650 echo $?/$^ERRNAME $res
1651 eval vput addrcodec res d $res
1652 echo $?/$^ERRNAME $res
1653 vput addrcodec res e 3.51 Sauer (Ma) "Dr." <doog@def>
1654 echo $?/$^ERRNAME $res
1655 eval vput addrcodec res d $res
1656 echo $?/$^ERRNAME $res
1658 vput addrcodec res +e 4 Sauer (Ma) Dr. <doog@def>
1659 echo $?/$^ERRNAME $res
1660 eval vput addrcodec res d $res
1661 echo $?/$^ERRNAME $res
1662 vput addrcodec res +e 5 Sauer (Ma) Braten Dr. <doog@def>
1663 echo $?/$^ERRNAME $res
1664 eval vput addrcodec res d $res
1665 echo $?/$^ERRNAME $res
1666 vput addrcodec res +e 6 Sauer (Ma) Braten Dr. (Heu) <doog@def>
1667 echo $?/$^ERRNAME $res
1668 eval vput addrcodec res d $res
1669 echo $?/$^ERRNAME $res
1670 vput addrcodec res +e 7 Sauer (Ma) Braten Dr. (Heu) <doog@def> (bu)
1671 echo $?/$^ERRNAME $res
1672 eval vput addrcodec res d $res
1673 echo $?/$^ERRNAME $res
1674 vput addrcodec res +e 8 \
1675 Dr. Sauer (Ma) Braten Dr. (Heu) <doog@def> (bu) Boom. Boom
1676 echo $?/$^ERRNAME $res
1677 eval vput addrcodec res d $res
1678 echo $?/$^ERRNAME $res
1679 vput addrcodec res +e 9 Dr.Sauer(Ma)Braten Dr. (Heu) <doog@def>
1680 echo $?/$^ERRNAME $res
1681 eval vput addrcodec res d $res
1682 echo $?/$^ERRNAME $res
1683 vput addrcodec res +e 10 (Ma)Braten Dr. (Heu) <doog@def>
1684 echo $?/$^ERRNAME $res
1685 eval vput addrcodec res d $res
1686 echo $?/$^ERRNAME $res
1687 vput addrcodec res +e 11 (Ma)Braten Dr"." (Heu) <doog@def>
1688 echo $?/$^ERRNAME $res
1689 eval vput addrcodec res d $res
1690 echo $?/$^ERRNAME $res
1691 vput addrcodec res +e 12 Dr. Sauer (Ma) Braten Dr. (u) <doog@def>
1692 echo $?/$^ERRNAME $res
1693 eval vput addrcodec res d $res
1694 echo $?/$^ERRNAME $res
1695 vput addrcodec res +e 13(Ma)Braten Dr. (Heu) <doog@def>
1696 echo $?/$^ERRNAME $res
1697 eval vput addrcodec res d $res
1698 echo $?/$^ERRNAME $res
1699 vput addrcodec res +e 14 Hey, Du <doog@def> Wie() findet Dr. das? ()
1700 echo $?/$^ERRNAME $res
1701 eval vput addrcodec res d $res
1702 echo $?/$^ERRNAME $res
1703 vput addrcodec res +e 15 \
1704 Hey, Du <doog@def> Wie() findet "" Dr. "" das? ()
1705 echo $?/$^ERRNAME $res
1706 eval vput addrcodec res d $res
1707 echo $?/$^ERRNAME $res
1708 vput addrcodec res +e 16 \
1709 "Hey," "Du" <doog@def> "Wie()" findet "" Dr. "" das? ()
1710 echo $?/$^ERRNAME $res
1711 eval vput addrcodec res d $res
1712 echo $?/$^ERRNAME $res
1713 vput addrcodec res +e 17 \
1714 "Hey" Du <doog@def> "Wie() findet " " Dr. """ das? ()
1715 echo $?/$^ERRNAME $res
1716 eval vput addrcodec res d $res
1717 echo $?/$^ERRNAME $res
1718 vput addrcodec res +e 18 \
1719 <doog@def> "Hey" Du "Wie() findet " " Dr. """ das? ()
1720 echo $?/$^ERRNAME $res
1721 eval vput addrcodec res d $res
1722 echo $?/$^ERRNAME $res
1723 vput addrcodec res +e 19 Hey\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1724 echo $?/$^ERRNAME $res
1725 eval vput addrcodec res d $res
1726 echo $?/$^ERRNAME $res
1728 vput addrcodec res ++e 20 Hey\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1729 echo $?/$^ERRNAME $res
1730 vput addrcodec res ++e 21 Hey\,\"" <doog@def> "Wie()" findet \" Dr. \" das?
1731 echo $?/$^ERRNAME $res
1732 eval vput addrcodec res d $res
1733 echo $?/$^ERRNAME $res
1735 vput addrcodec res +++e 22 Hey\\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1736 echo $?/$^ERRNAME $res
1737 eval vput addrcodec res d $res
1738 echo $?/$^ERRNAME $res
1740 vput addrcodec res s \
1741 "23 Hey\\,\\\" \"Wie" () "\" findet \\\" Dr. \\\" das?" <doog@def>
1742 echo $?/$^ERRNAME $res
1744 # Fix for [f3852f88]
1745 vput addrcodec res ++e <from2@exam.ple> 100 (comment) "Quot(e)d"
1746 echo $?/$^ERRNAME $res
1747 eval vput addrcodec res d $res
1748 echo $?/$^ERRNAME $res
1749 vput addrcodec res e <from2@exam.ple> 100 (comment) "Quot(e)d"
1750 echo $?/$^ERRNAME $res
1751 eval vput addrcodec res d $res
1752 echo $?/$^ERRNAME $res
1753 __EOT
1755 check 1 0 "${MBOX}" '1047317989 2612'
1757 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
1758 mlist isa1@list
1759 mlsubscribe isa2@list
1761 vput addrcodec res skin Hey\\,\" <isa0@list> "Wie()" find \" Dr. \" das?
1762 echo $?/$^ERRNAME $res
1763 vput addrcodec res skinlist Hey\\,\" <isa0@list> "Wie()" find \" Dr. \" das?
1764 echo $?/$^ERRNAME $res
1765 vput addrcodec res skin Hey\\,\" <isa1@list> "Wie()" find \" Dr. \" das?
1766 echo $?/$^ERRNAME $res
1767 vput addrcodec res skinlist Hey\\,\" <isa1@list> "Wie()" find \" Dr. \" das?
1768 echo $?/$^ERRNAME $res
1769 vput addrcodec res skin Hey\\,\" <isa2@list> "Wie()" find \" Dr. \" das?
1770 echo $?/$^ERRNAME $res
1771 vput addrcodec res skinlist Hey\\,\" <isa2@list> "Wie()" find \" Dr. \" das?
1772 echo $?/$^ERRNAME $res
1773 __EOT
1775 check 2 0 "${MBOX}" '1391779299 104'
1777 if have_feat idna; then
1778 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} ${ADDARG_UNI} > "${MBOX}" 2>&1
1779 vput addrcodec res e (heu) <du@blödiän> "stroh" du
1780 echo $?/$^ERRNAME $res
1781 eval vput addrcodec res d $res
1782 echo $?/$^ERRNAME $res
1783 vput addrcodec res e <du@blödiän> du
1784 echo $?/$^ERRNAME $res
1785 eval vput addrcodec res d $res
1786 echo $?/$^ERRNAME $res
1787 vput addrcodec res e du <du@blödiän>
1788 echo $?/$^ERRNAME $res
1789 eval vput addrcodec res d $res
1790 echo $?/$^ERRNAME $res
1791 vput addrcodec res e <du@blödiän>
1792 echo $?/$^ERRNAME $res
1793 eval vput addrcodec res d $res
1794 echo $?/$^ERRNAME $res
1795 vput addrcodec res e du@blödiän
1796 echo $?/$^ERRNAME $res
1797 eval vput addrcodec res d $res
1798 echo $?/$^ERRNAME $res
1799 __EOT
1801 check idna 0 "${MBOX}" '498775983 326'
1802 else
1803 printf 'addrcodec-idna: unsupported, skipped\n'
1806 t_epilog
1809 t_vexpr() {
1810 t_prolog vexpr
1812 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>>${ERR}
1813 echo ' #0.0'
1814 vput vexpr res = 9223372036854775807
1815 echo $?/$^ERRNAME $res
1816 vput vexpr res = 9223372036854775808
1817 echo $?/$^ERRNAME $res
1818 vput vexpr res = u9223372036854775808
1819 echo $?/$^ERRNAME $res
1820 vput vexpr res @= 9223372036854775808
1821 echo $?/$^ERRNAME $res
1822 vput vexpr res = -9223372036854775808
1823 echo $?/$^ERRNAME $res
1824 vput vexpr res = -9223372036854775809
1825 echo $?/$^ERRNAME $res
1826 vput vexpr res @= -9223372036854775809
1827 echo $?/$^ERRNAME $res
1828 vput vexpr res = U9223372036854775809
1829 echo $?/$^ERRNAME $res
1830 echo ' #0.1'
1831 vput vexpr res = \
1832 0b0111111111111111111111111111111111111111111111111111111111111111
1833 echo $?/$^ERRNAME $res
1834 vput vexpr res = \
1835 S0b1000000000000000000000000000000000000000000000000000000000000000
1836 echo $?/$^ERRNAME $res
1837 vput vexpr res @= \
1838 S0b1000000000000000000000000000000000000000000000000000000000000000
1839 echo $?/$^ERRNAME $res
1840 vput vexpr res = \
1841 U0b1000000000000000000000000000000000000000000000000000000000000000
1842 echo $?/$^ERRNAME $res
1843 vput vexpr res = \
1844 0b1000000000000000000000000000000000000000000000000000000000000000
1845 echo $?/$^ERRNAME $res
1846 vput vexpr res @= \
1847 0b1000000000000000000000000000000000000000000000000000000000000000
1848 echo $?/$^ERRNAME $res
1849 vput vexpr res = \
1850 -0b1000000000000000000000000000000000000000000000000000000000000000
1851 echo $?/$^ERRNAME $res
1852 vput vexpr res = \
1853 S0b1000000000000000000000000000000000000000000000000000000000000001
1854 echo $?/$^ERRNAME $res
1855 vput vexpr res @= \
1856 S0b1000000000000000000000000000000000000000000000000000000000000001
1857 echo $?/$^ERRNAME $res
1858 vput vexpr res @= \
1859 -0b1000000000000000000000000000000000000000000000000000000000000001
1860 echo $?/$^ERRNAME $res
1861 vput vexpr res = \
1862 U0b1000000000000000000000000000000000000000000000000000000000000001
1863 echo $?/$^ERRNAME $res
1864 echo ' #0.2'
1865 vput vexpr res = 0777777777777777777777
1866 echo $?/$^ERRNAME $res
1867 vput vexpr res = S01000000000000000000000
1868 echo $?/$^ERRNAME $res
1869 vput vexpr res @= S01000000000000000000000
1870 echo $?/$^ERRNAME $res
1871 vput vexpr res = U01000000000000000000000
1872 echo $?/$^ERRNAME $res
1873 vput vexpr res = 01000000000000000000000
1874 echo $?/$^ERRNAME $res
1875 vput vexpr res @= 01000000000000000000000
1876 echo $?/$^ERRNAME $res
1877 vput vexpr res = -01000000000000000000000
1878 echo $?/$^ERRNAME $res
1879 vput vexpr res = S01000000000000000000001
1880 echo $?/$^ERRNAME $res
1881 vput vexpr res @= S01000000000000000000001
1882 echo $?/$^ERRNAME $res
1883 vput vexpr res @= -01000000000000000000001
1884 echo $?/$^ERRNAME $res
1885 vput vexpr res = U01000000000000000000001
1886 echo $?/$^ERRNAME $res
1887 echo ' #0.3'
1888 vput vexpr res = 0x7FFFFFFFFFFFFFFF
1889 echo $?/$^ERRNAME $res
1890 vput vexpr res = S0x8000000000000000
1891 echo $?/$^ERRNAME $res
1892 vput vexpr res @= S0x8000000000000000
1893 echo $?/$^ERRNAME $res
1894 vput vexpr res = U0x8000000000000000
1895 echo $?/$^ERRNAME $res
1896 vput vexpr res = 0x8000000000000000
1897 echo $?/$^ERRNAME $res
1898 vput vexpr res @= 0x8000000000000000
1899 echo $?/$^ERRNAME $res
1900 vput vexpr res = -0x8000000000000000
1901 echo $?/$^ERRNAME $res
1902 vput vexpr res = S0x8000000000000001
1903 echo $?/$^ERRNAME $res
1904 vput vexpr res @= S0x8000000000000001
1905 echo $?/$^ERRNAME $res
1906 vput vexpr res @= -0x8000000000000001
1907 echo $?/$^ERRNAME $res
1908 vput vexpr res = u0x8000000000000001
1909 echo $?/$^ERRNAME $res
1910 echo ' #1'
1911 vput vexpr res ~ 0
1912 echo $?/$^ERRNAME $res
1913 vput vexpr res ~ 1
1914 echo $?/$^ERRNAME $res
1915 vput vexpr res ~ -1
1916 echo $?/$^ERRNAME $res
1917 echo ' #2'
1918 vput vexpr res + 0 0
1919 echo $?/$^ERRNAME $res
1920 vput vexpr res + 0 1
1921 echo $?/$^ERRNAME $res
1922 vput vexpr res + 1 1
1923 echo $?/$^ERRNAME $res
1924 echo ' #3'
1925 vput vexpr res + 9223372036854775807 0
1926 echo $?/$^ERRNAME $res
1927 vput vexpr res + 9223372036854775807 1
1928 echo $?/$^ERRNAME $res
1929 vput vexpr res @+ 9223372036854775807 1
1930 echo $?/$^ERRNAME $res
1931 vput vexpr res + 0 9223372036854775807
1932 echo $?/$^ERRNAME $res
1933 vput vexpr res + 1 9223372036854775807
1934 echo $?/$^ERRNAME $res
1935 vput vexpr res @+ 1 9223372036854775807
1936 echo $?/$^ERRNAME $res
1937 echo ' #4'
1938 vput vexpr res + -9223372036854775808 0
1939 echo $?/$^ERRNAME $res
1940 vput vexpr res + -9223372036854775808 -1
1941 echo $?/$^ERRNAME $res
1942 vput vexpr res @+ -9223372036854775808 -1
1943 echo $?/$^ERRNAME $res
1944 vput vexpr res + 0 -9223372036854775808
1945 echo $?/$^ERRNAME $res
1946 vput vexpr res + -1 -9223372036854775808
1947 echo $?/$^ERRNAME $res
1948 vput vexpr res @+ -1 -9223372036854775808
1949 echo $?/$^ERRNAME $res
1950 echo ' #5'
1951 vput vexpr res - 0 0
1952 echo $?/$^ERRNAME $res
1953 vput vexpr res - 0 1
1954 echo $?/$^ERRNAME $res
1955 vput vexpr res - 1 1
1956 echo $?/$^ERRNAME $res
1957 echo ' #6'
1958 vput vexpr res - 9223372036854775807 0
1959 echo $?/$^ERRNAME $res
1960 vput vexpr res - 9223372036854775807 -1
1961 echo $?/$^ERRNAME $res
1962 vput vexpr res @- 9223372036854775807 -1
1963 echo $?/$^ERRNAME $res
1964 vput vexpr res - 0 9223372036854775807
1965 echo $?/$^ERRNAME $res
1966 vput vexpr res - -1 9223372036854775807
1967 echo $?/$^ERRNAME $res
1968 vput vexpr res - -2 9223372036854775807
1969 echo $?/$^ERRNAME $res
1970 vput vexpr res @- -2 9223372036854775807
1971 echo $?/$^ERRNAME $res
1972 echo ' #7'
1973 vput vexpr res - -9223372036854775808 +0
1974 echo $?/$^ERRNAME $res
1975 vput vexpr res - -9223372036854775808 +1
1976 echo $?/$^ERRNAME $res
1977 vput vexpr res @- -9223372036854775808 +1
1978 echo $?/$^ERRNAME $res
1979 vput vexpr res - 0 -9223372036854775808
1980 echo $?/$^ERRNAME $res
1981 vput vexpr res - +1 -9223372036854775808
1982 echo $?/$^ERRNAME $res
1983 vput vexpr res @- +1 -9223372036854775808
1984 echo $?/$^ERRNAME $res
1985 echo ' #8'
1986 vput vexpr res + -13 -2
1987 echo $?/$^ERRNAME $res
1988 vput vexpr res - 0 0
1989 echo $?/$^ERRNAME $res
1990 vput vexpr res - 0 1
1991 echo $?/$^ERRNAME $res
1992 vput vexpr res - 1 1
1993 echo $?/$^ERRNAME $res
1994 vput vexpr res - -13 -2
1995 echo $?/$^ERRNAME $res
1996 echo ' #9'
1997 vput vexpr res * 0 0
1998 echo $?/$^ERRNAME $res
1999 vput vexpr res * 0 1
2000 echo $?/$^ERRNAME $res
2001 vput vexpr res * 1 1
2002 echo $?/$^ERRNAME $res
2003 vput vexpr res * -13 -2
2004 echo $?/$^ERRNAME $res
2005 echo ' #10'
2006 vput vexpr res / 0 0
2007 echo $?/$^ERRNAME $res
2008 vput vexpr res / 0 1
2009 echo $?/$^ERRNAME $res
2010 vput vexpr res / 1 1
2011 echo $?/$^ERRNAME $res
2012 vput vexpr res / -13 -2
2013 echo $?/$^ERRNAME $res
2014 echo ' #11'
2015 vput vexpr res % 0 0
2016 echo $?/$^ERRNAME $res
2017 vput vexpr res % 0 1
2018 echo $?/$^ERRNAME $res
2019 vput vexpr res % 1 1
2020 echo $?/$^ERRNAME $res
2021 vput vexpr res % -13 -2
2022 echo $?/$^ERRNAME $res
2023 __EOT
2025 check numeric 0 "${MBOX}" '960821755 1962'
2027 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
2028 vput vexpr res find 'bananarama' 'nana'
2029 echo $?/$^ERRNAME :$res:
2030 vput vexpr res find 'bananarama' 'bana'
2031 echo $?/$^ERRNAME :$res:
2032 vput vexpr res find 'bananarama' 'Bana'
2033 echo $?/$^ERRNAME :$res:
2034 vput vexpr res find 'bananarama' 'rama'
2035 echo $?/$^ERRNAME :$res:
2036 echo ' #1'
2037 vput vexpr res ifind 'bananarama' 'nana'
2038 echo $?/$^ERRNAME :$res:
2039 vput vexpr res ifind 'bananarama' 'bana'
2040 echo $?/$^ERRNAME :$res:
2041 vput vexpr res ifind 'bananarama' 'Bana'
2042 echo $?/$^ERRNAME :$res:
2043 vput vexpr res ifind 'bananarama' 'rama'
2044 echo $?/$^ERRNAME :$res:
2045 echo ' #2'
2046 vput vexpr res substring 'bananarama' 1
2047 echo $?/$^ERRNAME :$res:
2048 vput vexpr res substring 'bananarama' 3
2049 echo $?/$^ERRNAME :$res:
2050 vput vexpr res substring 'bananarama' 5
2051 echo $?/$^ERRNAME :$res:
2052 vput vexpr res substring 'bananarama' 7
2053 echo $?/$^ERRNAME :$res:
2054 vput vexpr res substring 'bananarama' 9
2055 echo $?/$^ERRNAME :$res:
2056 vput vexpr res substring 'bananarama' 10
2057 echo $?/$^ERRNAME :$res:
2058 vput vexpr res substring 'bananarama' 1 3
2059 echo $?/$^ERRNAME :$res:
2060 vput vexpr res substring 'bananarama' 3 3
2061 echo $?/$^ERRNAME :$res:
2062 vput vexpr res substring 'bananarama' 5 3
2063 echo $?/$^ERRNAME :$res:
2064 vput vexpr res substring 'bananarama' 7 3
2065 echo $?/$^ERRNAME :$res:
2066 vput vexpr res substring 'bananarama' 9 3
2067 echo $?/$^ERRNAME :$res:
2068 vput vexpr res substring 'bananarama' 10 3
2069 echo $?/$^ERRNAME :$res:
2070 echo ' #3'
2071 vput vexpr res substring 'bananarama' -1
2072 echo $?/$^ERRNAME :$res:
2073 vput vexpr res substring 'bananarama' -3
2074 echo $?/$^ERRNAME :$res:
2075 vput vexpr res substring 'bananarama' -5
2076 echo $?/$^ERRNAME :$res:
2077 vput vexpr res substring 'bananarama' -7
2078 echo $?/$^ERRNAME :$res:
2079 vput vexpr res substring 'bananarama' -9
2080 echo $?/$^ERRNAME :$res:
2081 vput vexpr res substring 'bananarama' -10
2082 echo $?/$^ERRNAME :$res:
2083 vput vexpr res substring 'bananarama' 1 -3
2084 echo $?/$^ERRNAME :$res:
2085 vput vexpr res substring 'bananarama' 3 -3
2086 echo $?/$^ERRNAME :$res:
2087 vput vexpr res substring 'bananarama' 5 -3
2088 echo $?/$^ERRNAME :$res:
2089 vput vexpr res substring 'bananarama' 7 -3
2090 echo $?/$^ERRNAME :$res:
2091 vput vexpr res substring 'bananarama' 9 -3
2092 echo $?/$^ERRNAME :$res:
2093 vput vexpr res substring 'bananarama' 10 -3
2094 echo $?/$^ERRNAME :$res:
2095 echo ' #4'
2096 vput vexpr res trim 'Cocoon Cocoon'
2097 echo $?/$^ERRNAME :$res:
2098 vput vexpr res trim ' Cocoon Cocoon '
2099 echo $?/$^ERRNAME :$res:
2100 vput vexpr res trim-front 'Cocoon Cocoon'
2101 echo $?/$^ERRNAME :$res:
2102 vput vexpr res trim-front ' Cocoon Cocoon '
2103 echo $?/$^ERRNAME :$res:
2104 vput vexpr res trim-end 'Cocoon Cocoon'
2105 echo $?/$^ERRNAME :$res:
2106 vput vexpr res trim-end ' Cocoon Cocoon '
2107 echo $?/$^ERRNAME :$res:
2108 __EOT
2110 check string 0 "${MBOX}" '3182004322 601'
2112 if have_feat regex; then
2113 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
2114 vput vexpr res regex 'bananarama' 'nana'
2115 echo $?/$^ERRNAME :$res:
2116 vput vexpr res regex 'bananarama' 'bana'
2117 echo $?/$^ERRNAME :$res:
2118 vput vexpr res regex 'bananarama' 'Bana'
2119 echo $?/$^ERRNAME :$res:
2120 vput vexpr res regex 'bananarama' 'rama'
2121 echo $?/$^ERRNAME :$res:
2122 echo ' #1'
2123 vput vexpr res iregex 'bananarama' 'nana'
2124 echo $?/$^ERRNAME :$res:
2125 vput vexpr res iregex 'bananarama' 'bana'
2126 echo $?/$^ERRNAME :$res:
2127 vput vexpr res iregex 'bananarama' 'Bana'
2128 echo $?/$^ERRNAME :$res:
2129 vput vexpr res iregex 'bananarama' 'rama'
2130 echo $?/$^ERRNAME :$res:
2131 echo ' #2'
2132 vput vexpr res regex 'bananarama' '(.*)nana(.*)' '\${1}a\${0}u{\$2}'
2133 echo $?/$^ERRNAME :$res:
2134 vput vexpr res regex 'bananarama' '(.*)bana(.*)' '\${1}a\${0}u\$2'
2135 echo $?/$^ERRNAME :$res:
2136 vput vexpr res regex 'bananarama' 'Bana(.+)' '\$1\$0'
2137 echo $?/$^ERRNAME :$res:
2138 vput vexpr res regex 'bananarama' '(.+)rama' '\$1\$0'
2139 echo $?/$^ERRNAME :$res:
2140 echo ' #3'
2141 vput vexpr res iregex 'bananarama' '(.*)nana(.*)' '\${1}a\${0}u{\$2}'
2142 echo $?/$^ERRNAME :$res:
2143 vput vexpr res iregex 'bananarama' '(.*)bana(.*)' '\${1}a\${0}u\$2'
2144 echo $?/$^ERRNAME :$res:
2145 vput vexpr res iregex 'bananarama' 'Bana(.+)' '\$1\$0'
2146 echo $?/$^ERRNAME :$res:
2147 vput vexpr res iregex 'bananarama' '(.+)rama' '\$1\$0'
2148 echo $?/$^ERRNAME :$res:
2149 echo ' #4'
2150 __EOT
2152 check regex 0 "${MBOX}" '3270360157 311'
2153 else
2154 printf 'vexpr-regex: unsupported, skipped\n'
2157 t_epilog
2160 t_call_ret() {
2161 t_prolog call_ret
2163 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Snomemdebug > "${MBOX}" 2>&1
2164 define w1 {
2165 echon ">$1 "
2166 vput vexpr i + $1 1
2167 if [ $i -le 42 ]
2168 vput vexpr j '&' $i 7
2169 if [ $j -eq 7 ]
2170 echo .
2172 call w1 $i
2173 wysh set i=$? k=$!
2174 vput vexpr j '&' $i 7
2175 echon "<$1/$i/$k "
2176 if [ $j -eq 7 ]
2177 echo .
2179 else
2180 echo ! The end for $1
2182 return $1
2184 # Transport $?/$! up the call chain
2185 define w2 {
2186 echon ">$1 "
2187 vput vexpr i + $1 1
2188 if [ $1 -lt 42 ]
2189 call w2 $i
2190 wysh set i=$? j=$! k=$^ERRNAME
2191 echon "<$1/$i/$k "
2192 return $i $j
2193 else
2194 echo ! The end for $1
2195 return $i $^ERR-BUSY
2197 echoerr au
2199 # Up and down it goes
2200 define w3 {
2201 echon ">$1/$2 "
2202 vput vexpr i + $1 1
2203 if [ $1 -lt 42 ]
2204 call w3 $i $2
2205 wysh set i=$? j=$!
2206 vput vexpr k - $1 $2
2207 if [ $k -eq 21 ]
2208 vput vexpr i + $1 1
2209 vput vexpr j + $2 1
2210 echo "# <$i/$j> .. "
2211 call w3 $i $j
2212 wysh set i=$? j=$!
2214 eval echon "<\$1=\$i/\$^ERRNAME-$j "
2215 return $i $j
2216 else
2217 echo ! The end for $1=$i/$2
2218 if [ "$2" != "" ]
2219 return $i $^ERR-DOM
2220 else
2221 return $i $^ERR-BUSY
2224 echoerr au
2227 call w1 0; echo ?=$? !=$!; echo -----;
2228 call w2 0; echo ?=$? !=$^ERRNAME; echo -----;
2229 call w3 0 1; echo ?=$? !=$^ERRNAME; echo -----;
2230 __EOT
2232 check 1 0 "${MBOX}" '1572045517 5922'
2234 t_epilog
2237 t_xcall() {
2238 t_prolog xcall
2240 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Snomemdebug > "${MBOX}" 2>&1
2241 define work {
2242 echon "$1 "
2243 vput vexpr i + $1 1
2244 if [ $i -le 1111 ]
2245 vput vexpr j '&' $i 7
2246 if [ $j -eq 7 ]
2247 echo .
2249 \xcall work $i $2
2251 echo ! The end for $1/$2
2252 if [ "$2" != "" ]
2253 return $i $^ERR-BUSY
2256 define xwork {
2257 \xcall work 0 $2
2259 call work 0
2260 echo ?=$? !=$!
2261 call xwork
2262 echo ?=$? !=$!
2263 xcall xwork
2264 echo ?=$? !=$^ERRNAME
2266 call work 0 yes
2267 echo ?=$? !=$^ERRNAME
2268 call xwork 0 yes
2269 echo ?=$? !=$^ERRNAME
2270 __EOT
2272 check 1 0 "${MBOX}" '2401702082 23801'
2276 if have_feat uistrings; then
2277 ${cat} <<- '__EOT' > "${BODY}"
2278 define __w {
2279 echon "$1 "
2280 vput vexpr i + $1 1
2281 if [ $i -le 111 ]
2282 vput vexpr j '&' $i 7
2283 if [ $j -eq 7 ]
2284 echo .
2286 \xcall __w $i $2
2288 echo ! The end for $1
2289 if [ $2 -eq 0 ]
2290 nonexistingcommand
2291 echo would be err with errexit
2292 return
2294 echo calling exit
2295 exit
2297 define work {
2298 echo eins
2299 call __w 0 0
2300 echo zwei, ?=$? !=$!
2301 localopts yes; set errexit
2302 ignerr call __w 0 0
2303 echo drei, ?=$? !=$^ERRNAME
2304 call __w 0 $1
2305 echo vier, ?=$? !=$^ERRNAME, this is an error
2307 ignerr call work 0
2308 echo outer 1, ?=$? !=$^ERRNAME
2309 xxxign call work 0
2310 echo outer 2, ?=$? !=$^ERRNAME, could be error if xxxign non-empty
2311 call work 1
2312 echo outer 3, ?=$? !=$^ERRNAME
2313 echo this is definitely an error
2314 __EOT
2316 < "${BODY}" ${MAILX} ${ARGS} -X'commandalias xxxign ignerr' \
2317 -Snomemdebug > "${MBOX}" 2>&1
2318 check 2 0 "${MBOX}" '3900716531 4200'
2320 < "${BODY}" ${MAILX} ${ARGS} -X'commandalias xxxign " "' \
2321 -Snomemdebug > "${MBOX}" 2>&1
2322 check 3 1 "${MBOX}" '1006776201 2799'
2323 else
2324 echo 'xcall-2: unsupported, skipped'
2325 echo 'xcall-3: unsupported, skipped'
2328 t_epilog
2331 t_vpospar() {
2332 t_prolog vpospar
2334 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
2335 vpospar set hey, "'you ", world!
2336 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2337 vput vpospar x quote; echo x<$x>
2338 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2339 vput vpospar y quote;echo y<$y>
2340 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2341 eval vpospar set ${y};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2342 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2344 define infun2 {
2345 echo infun2:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2346 vput vpospar z quote;echo infun2:z<$z>
2349 define infun {
2350 echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2351 vput vpospar y quote;echo infun:y<$y>
2352 eval vpospar set ${x};echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2353 vpospar clear;echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2354 eval call infun2 $x
2355 echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2356 eval vpospar set ${y};echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2359 call infun This "in a" fun
2360 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2361 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2362 __EOT
2363 check 1 0 "${MBOX}" '155175639 866'
2366 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
2367 set ifs=\'
2368 echo ifs<$ifs> ifs-ws<$ifs-ws>
2369 vpospar set hey, "'you ", world!
2370 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2371 vput vpospar x quote; echo x<$x>
2372 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2373 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2375 set ifs=,
2376 echo ifs<$ifs> ifs-ws<$ifs-ws>
2377 vpospar set hey, "'you ", world!
2378 unset ifs;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2379 set ifs=,
2380 vput vpospar x quote; echo x<$x>
2381 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2382 eval vpospar set ${x};\
2383 unset ifs;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2385 wysh set ifs=$',\t'
2386 echo ifs<$ifs> ifs-ws<$ifs-ws>
2387 vpospar set hey, "'you ", world!
2388 unset ifs; echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2389 wysh set ifs=$',\t'
2390 vput vpospar x quote; echo x<$x>
2391 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2392 eval vpospar set ${x};\
2393 unset ifs;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2394 __EOT
2395 check ifs 0 "${MBOX}" '2015927702 706'
2397 t_epilog
2400 t_atxplode() {
2401 t_prolog atxplode
2402 TRAP_EXIT_ADDONS="./.t*"
2404 ${cat} > ./.t.sh <<- '___'; ${cat} > ./.t.rc <<- '___'
2405 x() { echo $#; }
2406 xxx() {
2407 printf " (1/$#: <$1>)"
2408 shift
2409 if [ $# -gt 0 ]; then
2410 xxx "$@"
2411 else
2412 echo
2415 yyy() {
2416 eval "$@ ' ball"
2418 set --
2419 x "$@"
2420 x "$@"''
2421 x " $@"
2422 x "$@ "
2423 printf yyy;yyy 'xxx' "b\$'\t'u ' "
2424 printf xxx;xxx arg ,b u.
2425 printf xxx;xxx arg , .
2426 printf xxx;xxx arg ,ball.
2428 define x {
2429 echo $#
2431 define xxx {
2432 echon " (1/$#: <$1>)"
2433 shift
2434 if [ $# -gt 0 ]
2435 \xcall xxx "$@"
2436 endif
2437 echo
2439 define yyy {
2440 eval "$@ ' ball"
2442 vpospar set
2443 call x "$@"
2444 call x "$@"''
2445 call x " $@"
2446 call x "$@ "
2447 echon yyy;call yyy '\call xxx' "b\$'\t'u ' "
2448 echon xxx;call xxx arg ,b u.
2449 echon xxx;call xxx arg , .
2450 echon xxx;call xxx arg ,ball.
2453 ${MAILX} ${ARGS} -X'source ./.t.rc' -Xx > "${MBOX}" 2>&1
2454 check 1 0 "${MBOX}" '41566293 164'
2456 #${SHELL} ./.t.sh > ./.tshout 2>&1
2457 #check disproof-1 0 ./.tshout '41566293 164'
2459 t_epilog
2462 t_read() {
2463 t_prolog read
2464 TRAP_EXIT_ADDONS="./.t*"
2466 ${cat} <<- '__EOT' > .tin
2467 hey1, "'you ", world!
2468 hey2, "'you ", bugs bunny!
2469 hey3, "'you ",
2470 hey4, "'you "
2471 __EOT
2473 ${cat} <<- '__EOT' |\
2474 ${MAILX} ${ARGS} -X'readctl create ./.tin' > "${MBOX}" 2>&1
2475 read a b c
2476 echo $?/$^ERRNAME / <$a><$b><$c>
2477 read a b c
2478 echo $?/$^ERRNAME / <$a><$b><$c>
2479 read a b c
2480 echo $?/$^ERRNAME / <$a><$b><$c>
2481 read a b c
2482 echo $?/$^ERRNAME / <$a><$b><$c>
2483 unset a b c;read a b c
2484 echo $?/$^ERRNAME / <$a><$b><$c>
2485 readctl remove ./.tin;echo readctl remove:$?/$^ERRNAME
2486 __EOT
2487 check 1 0 "${MBOX}" '1527910147 173'
2489 ${cat} <<- '__EOT' > .tin2
2490 hey2.0,:"'you ",:world!:mars.:
2491 hey2.1,:"'you ",:world!
2492 hey2.2,:"'you ",:bugs bunny!
2493 hey2.3,:"'you ",:
2494 hey2.4,:"'you ":
2496 __EOT
2498 ${cat} <<- '__EOT' |\
2499 6< .tin2 ${MAILX} ${ARGS} -X 'readctl create 6' > "${MBOX}" 2>&1
2500 set ifs=:
2501 read a b c
2502 echo $?/$^ERRNAME / <$a><$b><$c>
2503 read a b c
2504 echo $?/$^ERRNAME / <$a><$b><$c>
2505 read a b c
2506 echo $?/$^ERRNAME / <$a><$b><$c>
2507 read a b c
2508 echo $?/$^ERRNAME / <$a><$b><$c>
2509 read a b c
2510 echo $?/$^ERRNAME / <$a><$b><$c>
2511 read a b c
2512 echo $?/$^ERRNAME / <$a><$b><$c>
2513 unset a b c;read a b c
2514 echo $?/$^ERRNAME / <$a><$b><$c>
2515 read a b c
2516 echo $?/$^ERRNAME / <$a><$b><$c>
2517 readctl remove 6;echo readctl remove:$?/$^ERRNAME
2518 __EOT
2519 check ifs 0 "${MBOX}" '890153490 298'
2521 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
2522 readctl create .tin
2523 readall d; echo $?/$^ERRNAME / <$d>
2524 wysh set d;readall d;echo $?/$^ERRNAME / <$d>
2525 readctl create .tin2
2526 readall d; echo $?/$^ERRNAME / <$d>
2527 wysh set d;readall d;echo $?/$^ERRNAME / <$d>
2528 readctl remove .tin;echo $?/$^ERRNAME;\
2529 readctl remove .tin2;echo $?/$^ERRNAME
2530 echo '### now with empty lines'
2531 ! printf 'one line\n\ntwo line\n\n' > ./.temptynl
2532 readctl create .temptynl;echo $?/$^ERRNAME
2533 readall d; echo "$?/$^ERRNAME / <$d>"
2534 readctl remove .temptynl;echo $?/$^ERRNAME
2535 __EOT
2536 check readall 0 "${MBOX}" '4113506527 405'
2538 t_epilog
2541 t_mbox() {
2542 t_prolog mbox
2543 TRAP_EXIT_ADDONS="./.t*"
2547 while [ ${i} -lt 113 ]; do
2548 printf 'm file://%s\n~s Subject %s\nHello %s!\n~.\n' \
2549 "${MBOX}" "${i}" "${i}"
2550 i=`add ${i} 1`
2551 done
2552 ) | ${MAILX} ${ARGS} > .tall 2>&1
2553 check 1 0 "${MBOX}" '1872102723 13784'
2554 check 1-outerr - ./.tall '4294967295 0' # empty file
2556 printf 'File "%s"\ncopy * "%s"\nFile "%s"\nfrom*' "${MBOX}" .tmbox1 .tmbox1 |
2557 ${MAILX} ${ARGS} -Sshowlast > .tall 2>&1
2558 check 2 0 .tall '3498373999 9103'
2560 printf 'File "%s"\ncopy * "file://%s"\nFile "file://%s"\nfrom*' \
2561 "${MBOX}" .tmbox2 .tmbox2 | ${MAILX} ${ARGS} -Sshowlast > .tall 2>&1
2562 check 3 0 .tall '381610797 9110'
2564 # copy only the odd (but the first), move the even
2566 printf 'File "file://%s"\ncopy ' .tmbox2
2568 while [ ${i} -lt 113 ]; do
2569 printf '%s ' "${i}"
2570 i=`add ${i} 2`
2571 done
2572 printf 'file://%s\nFile "file://%s"\nfrom*' .tmbox3 .tmbox3
2573 ) | ${MAILX} ${ARGS} -Sshowlast > .tall 2>&1
2574 check 4 0 .tmbox3 '4145104131 6890'
2575 check 5 - .tall '361127721 4573'
2576 # ...
2578 printf 'file "file://%s"\nmove ' .tmbox2
2580 while [ ${i} -lt 113 ]; do
2581 printf '%s ' "${i}"
2582 i=`add ${i} 2`
2583 done
2584 printf 'file://%s\nFile "file://%s"\nfrom*\nFile "file://%s"\nfrom*' \
2585 .tmbox3 .tmbox3 .tmbox2
2586 ) | ${MAILX} ${ARGS} -Sshowlast > .tall 2>>${ERR}
2587 check 6 0 .tmbox3 '3249991493 13784'
2588 if have_feat uistrings; then
2589 ${sed} 2d < .tall > .tallx
2590 else
2591 ${cp} .tall .tallx
2593 check 7 - .tallx '1584413080 13645'
2595 # Invalid MBOXes (after [f4db93b3])
2596 echo > .tinvmbox
2597 printf 'copy 1 ./.tinvmbox' | ${MAILX} ${ARGS} -Rf "${MBOX}" > .tall 2>&1
2598 check 8 0 .tinvmbox '896415941 122'
2599 check 9 - ./.tall '3146754194 33'
2601 echo ' ' > .tinvmbox
2602 printf 'copy 1 ./.tinvmbox' | ${MAILX} ${ARGS} -Rf "${MBOX}" > .tall 2>&1
2603 check 10 0 .tinvmbox '4011310616 124'
2604 check 11 - ./.tall '3146754194 33'
2606 { echo; echo; } > .tinvmbox # (not invalid)
2607 printf 'copy 1 ./.tinvmbox' | ${MAILX} ${ARGS} -Rf "${MBOX}" > .tall 2>&1
2608 check 12 0 .tinvmbox '287409579 123'
2609 check 13 - ./.tall '3146754194 33'
2611 # *mbox-rfc4155*, plus
2612 ${cat} <<-_EOT > ./.tinv1
2615 From MAILER-DAEMON-1 Wed Oct 2 01:50:07 1996
2616 Date: Wed, 02 Oct 1996 01:50:07 +0000
2618 Subject: Bad bad message 1
2620 From me to you, blinde Kuh!
2622 From MAILER-DAEMON-2 Wed Oct 2 01:50:07 1996
2623 Date: Wed, 02 Oct 1996 01:50:07 +0000
2625 Subject: Bad bad message 2
2627 From me to you, blindes Kalb!
2628 _EOT
2629 ${cp} ./.tinv1 ./.tinv2
2631 printf \
2632 'define mboxfix {
2633 \\localopts yes; \\wysh set mbox-rfc4155;\\wysh File "${1}";\\
2634 \\eval copy * "${2}"
2636 call mboxfix ./.tinv1 ./.tok' | ${MAILX} ${ARGS} > .tall 2>&1
2637 check_ex0 14-estat
2638 ${cat} ./.tinv1 ./.tok >> .tall
2639 check 14 - ./.tall '739301109 616'
2641 printf \
2642 'wysh file ./.tinv1 # ^From not repaired, but missing trailing NL is
2643 wysh File ./.tok # Just move away to nowhere
2644 set mbox-rfc4155
2645 wysh file ./.tinv2 # Fully repaired
2646 File ./.tok' | ${MAILX} ${ARGS} >>${ERR} 2>&1
2647 check_ex0 15-estat
2648 check 15-1 - ./.tinv1 '3178048820 332'
2649 check 15-2 - ./.tinv2 '4151504442 314'
2651 t_epilog
2654 t_maildir() {
2655 t_prolog maildir
2656 TRAP_EXIT_ADDONS="./.t*"
2660 while [ ${i} -lt 112 ]; do
2661 printf 'm file://%s\n~s Subject %s\nHello %s!\n~.\n' \
2662 "${MBOX}" "${i}" "${i}"
2663 i=`add ${i} 1`
2664 done
2665 ) | ${MAILX} ${ARGS}
2666 check 1 0 "${MBOX}" '1140119864 13780'
2668 printf 'File "%s"
2669 copy * "%s"
2670 File "%s"
2671 from*
2672 ' "${MBOX}" .tmdir1 .tmdir1 |
2673 ${MAILX} ${ARGS} -Snewfolders=maildir -Sshowlast > .tlst
2674 check 2 0 .tlst '1797938753 9103'
2676 printf 'File "%s"
2677 copy * "maildir://%s"
2678 File "maildir://%s"
2679 from*
2680 ' "${MBOX}" .tmdir2 .tmdir2 |
2681 ${MAILX} ${ARGS} -Sshowlast > .tlst
2682 check 3 0 .tlst '1155631089 9113'
2684 printf 'File "maildir://%s"
2685 copy * "file://%s"
2686 File "file://%s"
2687 from*
2688 ' .tmdir2 .tmbox1 .tmbox1 |
2689 ${MAILX} ${ARGS} -Sshowlast > .tlst
2690 check 4 0 .tmbox1 '2646131190 13220'
2691 check 5 - .tlst '3701297796 9110'
2693 # only the odd (even)
2695 printf 'File "maildir://%s"
2696 copy ' .tmdir2
2698 while [ ${i} -lt 112 ]; do
2699 j=`modulo ${i} 2`
2700 [ ${j} -eq 1 ] && printf '%s ' "${i}"
2701 i=`add ${i} 1`
2702 done
2703 printf ' file://%s
2704 File "file://%s"
2705 from*
2706 ' .tmbox2 .tmbox2
2707 ) | ${MAILX} ${ARGS} -Sshowlast > .tlst
2708 check 6 0 .tmbox2 '142890131 6610'
2709 check 7 - .tlst '960096773 4573'
2710 # ...
2712 printf 'file "maildir://%s"
2713 move ' .tmdir2
2715 while [ ${i} -lt 112 ]; do
2716 j=`modulo ${i} 2`
2717 [ ${j} -eq 0 ] && [ ${i} -ne 0 ] && printf '%s ' "${i}"
2718 i=`add ${i} 1`
2719 done
2720 printf ' file://%s
2721 File "file://%s"
2722 from*
2723 File "maildir://%s"
2724 from*
2725 ' .tmbox2 .tmbox2 .tmdir2
2726 ) | ${MAILX} ${ARGS} -Sshowlast > .tlst
2727 check 8 0 .tmbox2 '3806905791 13100'
2728 ${sed} 2d < .tlst > .tlstx
2729 check 9 - .tlstx '4216815295 13645'
2731 t_epilog
2734 t_record_a_resend() {
2735 t_prolog record_a_resend
2736 TRAP_EXIT_ADDONS="./.t.record ./.t.resent"
2738 printf '
2739 set record=%s
2740 m %s\n~s Subject 1.\nHello.\n~.
2741 set record-files add-file-recipients
2742 m %s\n~s Subject 2.\nHello.\n~.
2743 File %s
2744 resend 2 ./.t.resent
2745 Resend 1 ./.t.resent
2746 set record-resent
2747 resend 2 ./.t.resent
2748 Resend 1 ./.t.resent
2749 ' ./.t.record "${MBOX}" "${MBOX}" "${MBOX}" |
2750 ${MAILX} ${ARGS}
2752 check 1 0 "${MBOX}" '3057873538 256'
2753 check 2 - .t.record '391356429 460'
2754 check 3 - .t.resent '2685231691 648'
2756 t_epilog
2759 t_e_H_L_opts() {
2760 t_prolog e_H_L_opts
2761 TRAP_EXIT_ADDONS="./.tmta.sh ./.t.mbox"
2763 t_xmta 'Alchemilla Wed Apr 07 17:03:33 2017' ./.t.mbox
2765 touch ./.t.mbox
2766 ${MAILX} ${ARGS} -ef ./.t.mbox
2767 echo ${?} > "${MBOX}"
2769 printf 'm me@exam.ple\nLine 1.\nHello.\n~.\n' |
2770 ${MAILX} ${ARGS} -Smta=./.tmta.sh
2771 printf 'm you@exam.ple\nLine 1.\nBye.\n~.\n' |
2772 ${MAILX} ${ARGS} -Smta=./.tmta.sh
2774 ${MAILX} ${ARGS} -ef ./.t.mbox
2775 echo ${?} >> "${MBOX}"
2776 ${MAILX} ${ARGS} -efL @t@me ./.t.mbox
2777 echo ${?} >> "${MBOX}"
2778 ${MAILX} ${ARGS} -efL @t@you ./.t.mbox
2779 echo ${?} >> "${MBOX}"
2780 ${MAILX} ${ARGS} -efL '@>@Line 1' ./.t.mbox
2781 echo ${?} >> "${MBOX}"
2782 ${MAILX} ${ARGS} -efL '@>@Hello.' ./.t.mbox
2783 echo ${?} >> "${MBOX}"
2784 ${MAILX} ${ARGS} -efL '@>@Bye.' ./.t.mbox
2785 echo ${?} >> "${MBOX}"
2786 ${MAILX} ${ARGS} -efL '@>@Good bye.' ./.t.mbox
2787 echo ${?} >> "${MBOX}"
2789 ${MAILX} ${ARGS} -fH ./.t.mbox >> "${MBOX}"
2790 echo ${?} >> "${MBOX}"
2791 ${MAILX} ${ARGS} -fL @t@me ./.t.mbox >> "${MBOX}"
2792 echo ${?} >> "${MBOX}"
2793 ${MAILX} ${ARGS} -fL @t@you ./.t.mbox >> "${MBOX}"
2794 echo ${?} >> "${MBOX}"
2795 ${MAILX} ${ARGS} -fL '@>@Line 1' ./.t.mbox >> "${MBOX}"
2796 echo ${?} >> "${MBOX}"
2797 ${MAILX} ${ARGS} -fL '@>@Hello.' ./.t.mbox >> "${MBOX}"
2798 echo ${?} >> "${MBOX}"
2799 ${MAILX} ${ARGS} -fL '@>@Bye.' ./.t.mbox >> "${MBOX}"
2800 echo ${?} >> "${MBOX}"
2801 ${MAILX} ${ARGS} -fL '@>@Good bye.' ./.t.mbox >> "${MBOX}" 2>>${ERR}
2802 echo ${?} >> "${MBOX}"
2804 check 1 - "${MBOX}" '1708955574 678'
2806 t_epilog
2809 t_alternates() {
2810 t_prolog alternates
2811 TRAP_EXIT_ADDONS="./.t*"
2813 t_xmta 'Valeriana Sat Jul 08 15:54:03 2017'
2815 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Smta=./.tmta.sh > ./.tall 2>&1
2816 echo --0
2817 alternates
2818 echo $?/$^ERRNAME
2819 alternates a1@b1 a2@b2 a3@b3
2820 echo $?/$^ERRNAME
2821 alternates
2822 echo $?/$^ERRNAME
2823 vput alternates rv
2824 echo $?/$^ERRNAME <$rv>
2826 echo --1
2827 unalternates a2@b2
2828 vput alternates rv
2829 echo $?/$^ERRNAME <$rv>
2830 unalternates a3@b3
2831 vput alternates rv
2832 echo $?/$^ERRNAME <$rv>
2833 unalternates a1@b1
2834 vput alternates rv
2835 echo $?/$^ERRNAME <$rv>
2837 echo --2
2838 unalternates *
2839 alternates a1@b1 a2@b2 a3@b3
2840 unalternates a3@b3
2841 vput alternates rv
2842 echo $?/$^ERRNAME <$rv>
2843 unalternates a2@b2
2844 vput alternates rv
2845 echo $?/$^ERRNAME <$rv>
2846 unalternates a1@b1
2847 vput alternates rv
2848 echo $?/$^ERRNAME <$rv>
2850 echo --3
2851 alternates a1@b1 a2@b2 a3@b3
2852 unalternates a1@b1
2853 vput alternates rv
2854 echo $?/$^ERRNAME <$rv>
2855 unalternates a2@b2
2856 vput alternates rv
2857 echo $?/$^ERRNAME <$rv>
2858 unalternates a3@b3
2859 vput alternates rv
2860 echo $?/$^ERRNAME <$rv>
2862 echo --4
2863 unalternates *
2864 alternates a1@b1 a2@b2 a3@b3
2865 unalternates *
2866 vput alternates rv
2867 echo $?/$^ERRNAME <$rv>
2869 echo --5
2870 unalternates *
2871 alternates a1@b1 a1@c1 a1@d1 a2@b2 a3@b3 a3@c3 a3@d3
2872 m a1@b1 a1@c1 a1@d1
2873 ~s all alternates, only a1@b1 remains
2874 ~c a2@b2
2875 ~b a3@b3 a3@c3 a3@d3
2876 ~r - '_EOT'
2877 This body is!
2878 This also body is!!
2879 _EOT
2882 echo --6
2883 unalternates *
2884 alternates a1@b1 a1@c1 a2@b2 a3@b3
2885 m a1@b1 a1@c1 a1@d1
2886 ~s a1@b1 a1@d1, and a3@c3 a3@d3 remain
2887 ~c a2@b2
2888 ~b a3@b3 a3@c3 a3@d3
2889 ~r - '_EOT'
2890 This body2 is!
2891 _EOT
2894 echo --7
2895 alternates a1@b1 a2@b2 a3; set allnet
2896 m a1@b1 a1@c1 a1@d1
2897 ~s all alternates via allnet, only a1@b1 remains
2898 ~c a2@b2
2899 ~b a3@b3 a3@c3 a3@d3
2900 ~r - '_EOT'
2901 This body3 is!
2902 _EOT
2905 echo --10
2906 unalternates *
2907 alternates a1@b1
2908 echo $?/$^ERRNAME
2909 vput alternates rv
2910 echo $?/$^ERRNAME <$rv>
2911 alternates a2@b2
2912 echo $?/$^ERRNAME
2913 vput alternates rv
2914 echo $?/$^ERRNAME <$rv>
2915 alternates a3@b3
2916 echo $?/$^ERRNAME
2917 vput alternates rv
2918 echo $?/$^ERRNAME <$rv>
2919 alternates a4@b4
2920 echo $?/$^ERRNAME
2921 vput alternates rv
2922 echo $?/$^ERRNAME <$rv>
2924 unalternates *
2925 vput alternates rv
2926 echo $?/$^ERRNAME <$rv>
2928 echo --11
2929 set posix
2930 alternates a1@b1 a2@b2
2931 echo $?/$^ERRNAME
2932 vput alternates rv
2933 echo $?/$^ERRNAME <$rv>
2934 alternates a3@b3 a4@b4
2935 echo $?/$^ERRNAME
2936 vput alternates rv
2937 echo $?/$^ERRNAME <$rv>
2938 __EOT
2940 check 1 0 "${MBOX}" '142184864 515'
2941 if have_feat uistrings; then
2942 check 2 - .tall '1878598364 505'
2943 else
2944 echo 'alternates-2: unsupported, skipped'
2947 t_epilog
2950 t_alias() {
2951 t_prolog alias
2952 TRAP_EXIT_ADDONS="./.t*"
2954 t_xmta 'Hippocastanum Mon Jun 19 15:07:07 2017'
2956 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Smta=./.tmta.sh > ./.tall 2>&1
2957 alias a1 ex1@a1.ple
2958 alias a1 ex2@a1.ple "EX3 <ex3@a1.ple>"
2959 alias a1 ex4@a1.ple
2960 alias a2 ex1@a2.ple ex2@a2.ple ex3@a2.ple ex4@a2.ple
2961 alias a3 a4
2962 alias a4 a5 ex1@a4.ple
2963 alias a5 a6
2964 alias a6 a7 ex1@a6.ple
2965 alias a7 a8
2966 alias a8 ex1@a8.ple
2967 alias a1
2968 alias a2
2969 alias a3
2970 m a1
2971 ~c a2
2972 ~b a3
2973 ~r - '_EOT'
2974 This body is!
2975 This also body is!!
2976 _EOT
2977 __EOT
2978 check 1 0 "${MBOX}" '2496925843 272'
2979 check 2 - .tall '3548953204 152'
2981 # TODO t_alias: n_ALIAS_MAXEXP is compile-time constant,
2982 # TODO need to somehow provide its contents to the test, then test
2984 t_epilog
2987 t_filetype() {
2988 t_prolog filetype
2989 TRAP_EXIT_ADDONS="./.t*"
2991 t_xmta 'Alchemilla Wed Apr 25 15:12:13 2017'
2993 printf 'm m1@e.t\nL1\nHy1\n~.\nm m2@e.t\nL2\nHy2\n~@ %s\n~.\n' \
2994 "${SRCDIR}snailmail.jpg" | ${MAILX} ${ARGS} -Smta=./.tmta.sh
2995 check 1 0 "${MBOX}" '1594682963 13520'
2997 if (echo | gzip -c) >/dev/null 2>&1; then
2999 printf 'File "%s"\ncopy 1 ./.t.mbox.gz\ncopy 2 ./.t.mbox.gz' \
3000 "${MBOX}" | ${MAILX} ${ARGS} \
3001 -X'filetype gz gzip\ -dc gzip\ -c'
3002 printf 'File ./.t.mbox.gz\ncopy * ./.t.mbox\n' |
3003 ${MAILX} ${ARGS} -X'filetype gz gzip\ -dc gzip\ -c'
3004 } > ./.t.out 2>&1
3005 check 2 - "./.t.mbox" '1594682963 13520'
3006 check 3 - "./.t.out" '2392348396 102'
3007 else
3008 echo 'filetype-2: unsupported, skipped'
3009 echo 'filetype-3: unsupported, skipped'
3013 ${rm} ./.t.mbox*
3014 printf 'File "%s"\ncopy 1 ./.t.mbox.gz
3015 copy 2 ./.t.mbox.gz
3016 copy 1 ./.t.mbox.gz
3017 copy 2 ./.t.mbox.gz
3018 ' "${MBOX}" |
3019 ${MAILX} ${ARGS} \
3020 -X'filetype gz gzip\ -dc gzip\ -c' \
3021 -X'filetype mbox.gz "${sed} 1,3d|${cat}" \
3022 "echo eins;echo zwei;echo und mit ${sed} bist Du dabei;${cat}"'
3023 printf 'File ./.t.mbox.gz\ncopy * ./.t.mbox\n' |
3024 ${MAILX} ${ARGS} \
3025 -X'filetype gz gzip\ -dc gzip\ -c' \
3026 -X'filetype mbox.gz "${sed} 1,3d|${cat}" kill\ 0'
3027 } > ./.t.out 2>&1
3028 check 4 - "./.t.mbox" '2886541147 27060'
3029 check 5 - "./.t.out" '852335377 172'
3031 t_epilog
3034 t_message_injections() {
3035 t_prolog message_injections
3036 TRAP_EXIT_ADDONS="./.t*"
3038 t_xmta 'Echinacea Tue Jun 20 15:54:02 2017'
3040 echo mysig > ./.tmysig
3042 echo some-body | ${MAILX} ${ARGS} -Smta=./.tmta.sh \
3043 -Smessage-inject-head=head-inject \
3044 -Smessage-inject-tail=tail-inject \
3045 -Ssignature=./.tmysig \
3046 ex@am.ple > ./.tall 2>&1
3047 check 1 0 "${MBOX}" '2434746382 134'
3048 check 2 - .tall '4294967295 0' # empty file
3050 ${rm} "${MBOX}"
3051 ${cat} <<-_EOT > ./.template
3052 From: me
3053 To: ex1@am.ple
3054 Cc: ex2@am.ple
3055 Subject: This subject is
3057 Body, body, body me.
3058 _EOT
3059 < ./.template ${MAILX} ${ARGS} -t -Smta=./.tmta.sh \
3060 -Smessage-inject-head=head-inject \
3061 -Smessage-inject-tail=tail-inject \
3062 -Ssignature=./.tmysig \
3063 > ./.tall 2>&1
3064 check 3 0 "${MBOX}" '3114203412 198'
3065 check 4 - .tall '4294967295 0' # empty file
3067 t_epilog
3070 t_attachments() {
3071 t_prolog attachments
3072 TRAP_EXIT_ADDONS="./.t*"
3074 t_xmta 'Cannabis Sun Feb 18 02:02:46 2018'
3076 ${cat} <<-_EOT > ./.tx
3077 From steffen Sun Feb 18 02:48:40 2018
3078 Date: Sun, 18 Feb 2018 02:48:40 +0100
3080 Subject: m1
3081 User-Agent: s-nail v14.9.7
3084 From steffen Sun Feb 18 02:48:42 2018
3085 Date: Sun, 18 Feb 2018 02:48:42 +0100
3087 Subject: m2
3088 User-Agent: s-nail v14.9.7
3091 _EOT
3092 echo att1 > ./.t1
3093 printf 'att2-1\natt2-2\natt2-4\n' > ./'.t 2'
3094 printf 'att3-1\natt3-2\natt3-4\n' > ./.t3
3095 printf 'att4-1\natt4-2\natt4-4\n' > './.t 4'
3097 printf \
3098 '!@ ./.t3 "./.t 4" ""
3101 ./.t3
3102 "./.t 2"
3105 !.' \
3106 | ${MAILX} ${ARGS} -Sescape=! -Smta=./.tmta.sh \
3107 -a ./.t1 -a './.t 2' \
3108 -s attachment-test \
3109 ex@am.ple > ./.tall 2>&1
3110 check 1 0 "${MBOX}" '4107062253 634'
3111 if have_feat uistrings; then
3112 check 2 - .tall '1928331872 720'
3113 else
3114 echo 'attachments-2: unsupported, skipped'
3117 ${rm} "${MBOX}"
3118 printf \
3119 'mail ex@amp.ple
3120 !s This the subject is
3121 !@ ./.t3 "#2" "./.t 4" "#1" ""
3124 "./.t 4"
3125 "#2"
3129 mail ex@amp.ple
3130 !s Subject two
3131 !@ ./.t3 "#2" "./.t 4" "#1" ""
3137 mail ex@amp.ple
3138 !s Subject three
3139 !@ ./.t3 "" "#2" "" "./.t 4" "" "#1" ""
3142 ./.t3
3146 mail ex@amp.ple
3147 !s Subject Four
3148 !@ ./.t3 "" "#2" "" "./.t 4" "" "#1" ""
3151 "#1"
3155 mail ex@amp.ple
3156 !s Subject Five
3158 "#2"
3161 !.' \
3162 | ${MAILX} ${ARGS} -Sescape=! -Smta=./.tmta.sh -Rf ./.tx \
3163 > ./.tall 2>&1
3164 check 3 0 "${MBOX}" '798122412 2285'
3165 if have_feat uistrings; then
3166 check 4 - .tall '2526106274 1910'
3167 else
3168 echo 'attachments-4: unsupported, skipped'
3171 t_epilog
3174 t_compose_hooks() { # TODO monster
3175 t_prolog compose_hooks
3176 if have_feat uistrings; then :; else
3177 echo 'compose_hooks: unsupported, skipped'
3178 return
3180 TRAP_EXIT_ADDONS="./.t*"
3182 t_xmta 'PrimulaVeris Wed Apr 10 22:59:00 2017'
3184 (echo line one&&echo line two&&echo line three) > ./.treadctl
3185 (echo echo four&&echo echo five&&echo echo six) > ./.tattach
3187 ${cat} <<'__EOT__' > ./.trc
3188 define bail {
3189 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
3191 define xerr {
3192 vput vexpr es substr "$1" 0 1
3193 if [ "$es" != 2 ]
3194 xcall bail "$2"
3197 define read_mline_res {
3198 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
3199 echo $len/$es/$^ERRNAME: $hl
3200 if [ $es -ne $^ERR-NONE ]
3201 xcall bail read_mline_res
3202 elif [ $len -ne 0 ]
3203 \xcall read_mline_res
3206 define ins_addr {
3207 wysh set xh=$1
3208 echo "~^header list"; read hl; echo $hl;\
3209 call xerr "$hl" "in_addr ($xh) 0-1"
3211 echo "~^header insert $xh diet <$xh@exam.ple> spliced";\
3212 read es; echo $es; call xerr "$es" "ins_addr $xh 1-1"
3213 echo "~^header insert $xh <${xh}2@exam.ple>";\
3214 read es; echo $es; call xerr "$es" "ins_addr $xh 1-2"
3215 echo "~^header insert $xh ${xh}3@exam.ple";\
3216 read es; echo $es; call xerr "$es" "ins_addr $xh 1-3"
3217 echo "~^header list $xh"; read hl; echo $hl;\
3218 call xerr "$hl" "ins_addr $xh 1-4"
3219 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 1-5"
3220 call read_mline_res
3222 if [ "$t_remove" == "" ]
3223 return
3226 echo "~^header remove $xh"; read es; call xerr $es "ins_addr $xh 2-1"
3227 echo "~^header remove $xh"; read es; vput vexpr es substr $es 0 3
3228 if [ $es != 501 ]
3229 xcall bail "ins_addr $xh 2-2"
3231 echo "~^header list $xh"; read es; vput vexpr es substr $es 0 3
3232 if [ $es != 501 ]
3233 xcall bail "ins_addr $xh 2-3"
3235 echo "~^header show $xh"; read es; vput vexpr es substr $es 0 3
3236 if [ $es != 501 ]
3237 xcall bail "ins_addr $xh 2-4"
3241 echo "~^header insert $xh diet <$xh@exam.ple> spliced";\
3242 read es; echo $es; call xerr "$es" "ins_addr $xh 3-1"
3243 echo "~^header insert $xh <${xh}2@exam.ple>";\
3244 read es; echo $es; call xerr "$es" "ins_addr $xh 3-2"
3245 echo "~^header insert $xh ${xh}3@exam.ple";\
3246 read es; echo $es; call xerr "$es" "ins_addr $xh 3-3"
3247 echo "~^header list $xh"; read hl; echo $hl;\
3248 call xerr "$hl" "ins_addr $xh 3-4"
3249 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 3-5"
3250 call read_mline_res
3252 echo "~^header remove-at $xh 1"; read es;\
3253 call xerr $es "ins_addr $xh 3-6"
3254 echo "~^header remove-at $xh 1"; read es;\
3255 call xerr $es "ins_addr $xh 3-7"
3256 echo "~^header remove-at $xh 1"; read es;\
3257 call xerr $es "ins_addr $xh 3-8"
3258 echo "~^header remove-at $xh 1"; read es;\
3259 vput vexpr es substr $es 0 3
3260 if [ $es != 501 ]
3261 xcall bail "ins_addr $xh 3-9"
3263 echo "~^header remove-at $xh T"; read es;\
3264 vput vexpr es substr $es 0 3
3265 if [ $es != 505 ]
3266 xcall bail "ins_addr $xh 3-10"
3268 echo "~^header list $xh"; read es;\
3269 vput vexpr es substr $es 0 3
3270 if [ $es != 501 ]
3271 xcall bail "ins_addr $xh 3-11"
3273 echo "~^header show $xh"; read es;\
3274 vput vexpr es substr $es 0 3
3275 if [ $es != 501 ]
3276 xcall bail "ins_addr $xh 3-12"
3280 echo "~^header insert $xh diet <$xh@exam.ple> spliced";\
3281 read es; echo $es; call xerr "$es" "ins_addr $xh 4-1"
3282 echo "~^header insert $xh <${xh}2@exam.ple> (comment) \"Quot(e)d\"";\
3283 read es; echo $es; call xerr "$es" "ins_addr $xh 4-2"
3284 echo "~^header insert $xh ${xh}3@exam.ple";\
3285 read es; echo $es; call xerr "$es" "ins_addr $xh 4-3"
3286 echo "~^header list $xh"; read hl; echo $hl;\
3287 call xerr "$hl" "header list $xh 3-4"
3288 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 4-5"
3289 call read_mline_res
3291 echo "~^header remove-at $xh 3"; read es;\
3292 call xerr $es "ins_addr $xh 4-6"
3293 echo "~^header remove-at $xh 2"; read es;\
3294 call xerr $es "ins_addr $xh 4-7"
3295 echo "~^header remove-at $xh 1"; read es;\
3296 call xerr $es "ins_addr $xh 4-8"
3297 echo "~^header remove-at $xh 1"; read es;\
3298 vput vexpr es substr $es 0 3
3299 if [ $es != 501 ]
3300 xcall bail "ins_addr $xh 4-9"
3302 echo "~^header remove-at $xh T"; read es;\
3303 vput vexpr es substr $es 0 3
3304 if [ $es != 505 ]
3305 xcall bail "ins_addr $xh 4-10"
3307 echo "~^header list $xh"; read es;\
3308 vput vexpr es substr $es 0 3
3309 if [ $es != 501 ]
3310 xcall bail "ins_addr $xh 4-11"
3312 echo "~^header show $xh"; read es;\
3313 vput vexpr es substr $es 0 3
3314 if [ $es != 501 ]
3315 xcall bail "ins_addr $xh 4-12"
3318 define ins_ref {
3319 wysh set xh=$1 mult=$2
3320 echo "~^header list"; read hl; echo $hl;\
3321 call xerr "$hl" "ins_ref ($xh) 0-1"
3323 echo "~^header insert $xh <$xh@exam.ple>";\
3324 read es; echo $es; call xerr "$es" "ins_ref $xh 1-1"
3325 if [ $mult -ne 0 ]
3326 echo "~^header insert $xh <${xh}2@exam.ple>";\
3327 read es; echo $es; call xerr "$es" "ins_ref $xh 1-2"
3328 echo "~^header insert $xh ${xh}3@exam.ple";\
3329 read es; echo $es; call xerr "$es" "ins_ref $xh 1-3"
3330 else
3331 echo "~^header insert $xh <${xh}2@exam.ple>"; read es;\
3332 vput vexpr es substr $es 0 3
3333 if [ $es != 506 ]
3334 xcall bail "ins_ref $xh 1-4"
3338 echo "~^header list $xh"; read hl; echo $hl;\
3339 call xerr "$hl" "ins_ref $xh 1-5"
3340 echo "~^header show $xh"; read es; call xerr $es "ins_ref $xh 1-6"
3341 call read_mline_res
3343 if [ "$t_remove" == "" ]
3344 return
3347 echo "~^header remove $xh"; read es;\
3348 call xerr $es "ins_ref $xh 2-1"
3349 echo "~^header remove $xh"; read es;\
3350 vput vexpr es substr $es 0 3
3351 if [ $es != 501 ]
3352 xcall bail "ins_ref $xh 2-2"
3354 echo "~^header list $xh"; read es;\
3355 vput vexpr es substr $es 0 3
3356 if [ $es != 501 ]
3357 xcall bail "$es ins_ref $xh 2-3"
3359 echo "~^header show $xh"; read es;\
3360 vput vexpr es substr $es 0 3
3361 if [ $es != 501 ]
3362 xcall bail "ins_ref $xh 2-4"
3366 echo "~^header insert $xh <$xh@exam.ple>";\
3367 read es; echo $es; call xerr "$es" "ins_ref $xh 3-1"
3368 if [ $mult -ne 0 ]
3369 echo "~^header insert $xh <${xh}2@exam.ple>";\
3370 read es; echo $es; call xerr "$es" "ins_ref $xh 3-2"
3371 echo "~^header insert $xh ${xh}3@exam.ple";\
3372 read es; echo $es; call xerr "$es" "ins_ref $xh 3-3"
3374 echo "~^header list $xh";\
3375 read hl; echo $hl; call xerr "$hl" "ins_ref $xh 3-4"
3376 echo "~^header show $xh";\
3377 read es; call xerr $es "ins_ref $xh 3-5"
3378 call read_mline_res
3380 echo "~^header remove-at $xh 1"; read es;\
3381 call xerr $es "ins_ref $xh 3-6"
3382 if [ $mult -ne 0 ] && [ $xh != subject ]
3383 echo "~^header remove-at $xh 1"; read es;\
3384 call xerr $es "ins_ref $xh 3-7"
3385 echo "~^header remove-at $xh 1"; read es;\
3386 call xerr $es "ins_ref $xh 3-8"
3388 echo "~^header remove-at $xh 1"; read es;\
3389 vput vexpr es substr $es 0 3
3390 if [ $es != 501 ]
3391 xcall bail "ins_ref $xh 3-9"
3393 echo "~^header remove-at $xh T"; read es;\
3394 vput vexpr es substr $es 0 3
3395 if [ $es != 505 ]
3396 xcall bail "ins_ref $xh 3-10"
3398 echo "~^header show $xh"; read es;\
3399 vput vexpr es substr $es 0 3
3400 if [ $es != 501 ]
3401 xcall bail "ins_ref $xh 3-11"
3405 echo "~^header insert $xh <$xh@exam.ple> ";\
3406 read es; echo $es; call xerr "$es" "ins_ref $xh 4-1"
3407 if [ $mult -ne 0 ]
3408 echo "~^header insert $xh <${xh}2@exam.ple> ";\
3409 read es; echo $es; call xerr "$es" "ins_ref $xh 4-2"
3410 echo "~^header insert $xh ${xh}3@exam.ple";\
3411 read es; echo $es; call xerr "$es" "ins_ref $xh 4-3"
3413 echo "~^header list $xh"; read hl; echo $hl;\
3414 call xerr "$hl" "ins_ref $xh 4-4"
3415 echo "~^header show $xh"; read es; call xerr $es "ins_ref $xh 4-5"
3416 call read_mline_res
3418 if [ $mult -ne 0 ] && [ $xh != subject ]
3419 echo "~^header remove-at $xh 3"; read es;\
3420 call xerr $es "ins_ref $xh 4-6"
3421 echo "~^header remove-at $xh 2"; read es;\
3422 call xerr $es "ins_ref $xh 4-7"
3424 echo "~^header remove-at $xh 1"; read es;\
3425 call xerr $es "ins_ref $xh 4-8"
3426 echo "~^header remove-at $xh 1"; read es;\
3427 vput vexpr es substr $es 0 3
3428 if [ $es != 501 ]
3429 xcall bail "ins_ref $xh 4-9"
3431 echo "~^header remove-at $xh T"; read es;\
3432 vput vexpr es substr $es 0 3
3433 if [ $es != 505 ]
3434 xcall bail "ins_ref $xh 4-10"
3436 echo "~^header show $xh"; read es;\
3437 vput vexpr es substr $es 0 3
3438 if [ $es != 501 ]
3439 xcall bail "ins_ref $xh 4-11"
3442 define t_header {
3443 echo t_header ENTER
3444 # In collect.c order
3445 call ins_addr from
3446 call ins_ref sender 0 # Not a "ref", but works
3447 call ins_addr To
3448 call ins_addr cC
3449 call ins_addr bCc
3450 call ins_addr reply-To
3451 call ins_addr mail-Followup-to
3452 call ins_ref messAge-id 0
3453 call ins_ref rEfErEncEs 1
3454 call ins_ref in-Reply-to 1
3455 call ins_ref subject 1 # Not a "ref", but works (with tweaks)
3456 call ins_addr freeForm1
3457 call ins_addr freeform2
3459 echo "~^header show MAILX-Command"; read es; call xerr $es "t_header 1000"
3460 call read_mline_res
3461 echo "~^header show MAILX-raw-TO"; read es; call xerr $es "t_header 1001"
3462 call read_mline_res
3464 echo t_header LEAVE
3466 define t_attach {
3467 echo t_attach ENTER
3469 echo "~^attachment";\
3470 read hl; echo $hl; vput vexpr es substr "$hl" 0 3
3471 if [ "$es" != 501 ]
3472 xcall bail "attach 0-1"
3475 echo "~^attach attribute ./.treadctl";\
3476 read hl; echo $hl; vput vexpr es substr "$hl" 0 3
3477 if [ "$es" != 501 ]
3478 xcall bail "attach 0-2"
3480 echo "~^attachment attribute-at 1";\
3481 read hl; echo $hl; vput vexpr es substr "$hl" 0 3
3482 if [ "$es" != 501 ]
3483 xcall bail "attach 0-3"
3486 echo "~^attachment insert ./.treadctl=ascii";\
3487 read hl; echo $hl; call xerr "$hl" "attach 1-1"
3488 echo "~^attachment list";\
3489 read es; echo $es;call xerr "$es" "attach 1-2"
3490 call read_mline_res
3491 echo "~^attachment attribute ./.treadctl";\
3492 read es; echo $es;call xerr "$es" "attach 1-3"
3493 call read_mline_res
3494 echo "~^attachment attribute .treadctl";\
3495 read es; echo $es;call xerr "$es" "attach 1-4"
3496 call read_mline_res
3497 echo "~^attachment attribute-at 1";\
3498 read es; echo $es;call xerr "$es" "attach 1-5"
3499 call read_mline_res
3501 echo "~^attachment attribute-set ./.treadctl filename rctl";\
3502 read es; echo $es;call xerr "$es" "attach 1-6"
3503 echo "~^attachment attribute-set .treadctl content-description Au";\
3504 read es; echo $es;call xerr "$es" "attach 1-7"
3505 echo "~^attachment attribute-set-at 1 content-id <10.du@ich>";\
3506 read es; echo $es;call xerr "$es" "attach 1-8"
3508 echo "~^attachment attribute ./.treadctl";\
3509 read es; echo $es;call xerr "$es" "attach 1-9"
3510 call read_mline_res
3511 echo "~^attachment attribute .treadctl";\
3512 read es; echo $es;call xerr "$es" "attach 1-10"
3513 call read_mline_res
3514 echo "~^attachment attribute rctl";\
3515 read es; echo $es;call xerr "$es" "attach 1-11"
3516 call read_mline_res
3517 echo "~^attachment attribute-at 1";\
3518 read es; echo $es;call xerr "$es" "attach 1-12"
3519 call read_mline_res
3522 echo "~^attachment insert ./.tattach=latin1";\
3523 read hl; echo $hl; call xerr "$hl" "attach 2-1"
3524 echo "~^attachment list";\
3525 read es; echo $es;call xerr "$es" "attach 2-2"
3526 call read_mline_res
3527 echo "~^attachment attribute ./.tattach";\
3528 read es; echo $es;call xerr "$es" "attach 2-3"
3529 call read_mline_res
3530 echo "~^attachment attribute .tattach";\
3531 read es; echo $es;call xerr "$es" "attach 2-4"
3532 call read_mline_res
3533 echo "~^attachment attribute-at 2";\
3534 read es; echo $es;call xerr "$es" "attach 2-5"
3535 call read_mline_res
3537 echo "~^attachment attribute-set ./.tattach filename tat";\
3538 read es; echo $es;call xerr "$es" "attach 2-6"
3539 echo \
3540 "~^attachment attribute-set .tattach content-description Au2";\
3541 read es; echo $es;call xerr "$es" "attach 2-7"
3542 echo "~^attachment attribute-set-at 2 content-id <20.du@wir>";\
3543 read es; echo $es;call xerr "$es" "attach 2-8"
3544 echo \
3545 "~^attachment attribute-set-at 2 content-type application/x-sh";\
3546 read es; echo $es;call xerr "$es" "attach 2-9"
3548 echo "~^attachment attribute ./.tattach";\
3549 read es; echo $es;call xerr "$es" "attach 2-10"
3550 call read_mline_res
3551 echo "~^attachment attribute .tattach";\
3552 read es; echo $es;call xerr "$es" "attach 2-11"
3553 call read_mline_res
3554 echo "~^attachment attribute tat";\
3555 read es; echo $es;call xerr "$es" "attach 2-12"
3556 call read_mline_res
3557 echo "~^attachment attribute-at 2";\
3558 read es; echo $es;call xerr "$es" "attach 2-13"
3559 call read_mline_res
3562 if [ "$t_remove" == "" ]
3563 return
3566 echo "~^attachment remove ./.treadctl"; read es;\
3567 call xerr $es "attach 3-1"
3568 echo "~^attachment remove ./.tattach"; read es;\
3569 call xerr $es "attach 3-2"
3570 echo "~^ attachment remove ./.treadctl"; read es;\
3571 vput vexpr es substr $es 0 3
3572 if [ $es != 501 ]
3573 xcall bail "attach 3-3"
3575 echo "~^ attachment remove ./.tattach"; read es;\
3576 vput vexpr es substr $es 0 3
3577 if [ $es != 501 ]
3578 xcall bail "attach 3-4"
3580 echo "~^attachment list"; read es;\
3581 vput vexpr es substr $es 0 3
3582 if [ $es != 501 ]
3583 xcall bail "attach 3-5"
3587 echo "~^attachment insert ./.tattach=latin1";\
3588 read hl; echo $hl; call xerr "$hl" "attach 4-1"
3589 echo "~^attachment insert ./.tattach=latin1";\
3590 read hl; echo $hl; call xerr "$hl" "attach 4-2"
3591 echo "~^attachment list";\
3592 read es; echo $es;call xerr "$es" "attach 4-3"
3593 call read_mline_res
3594 echo "~^ attachment remove .tattach"; read es;\
3595 vput vexpr es substr $es 0 3
3596 if [ $es != 506 ]
3597 xcall bail "attach 4-4 $es"
3599 echo "~^attachment remove-at T"; read es;\
3600 vput vexpr es substr $es 0 3
3601 if [ $es != 505 ]
3602 xcall bail "attach 4-5"
3604 echo "~^attachment remove ./.tattach"; read es;\
3605 call xerr $es "attach 4-6"
3606 echo "~^attachment remove ./.tattach"; read es;\
3607 call xerr $es "attach 4-7"
3608 echo "~^ attachment remove ./.tattach"; read es;\
3609 vput vexpr es substr $es 0 3
3610 if [ $es != 501 ]
3611 xcall bail "attach 4-8 $es"
3613 echo "~^attachment list"; read es;\
3614 vput vexpr es substr $es 0 3
3615 if [ $es != 501 ]
3616 xcall bail "attach 4-9"
3620 echo "~^attachment insert ./.tattach=latin1";\
3621 read hl; echo $hl; call xerr "$hl" "attach 5-1"
3622 echo "~^attachment insert ./.tattach=latin1";\
3623 read hl; echo $hl; call xerr "$hl" "attach 5-2"
3624 echo "~^attachment insert ./.tattach=latin1";\
3625 read hl; echo $hl; call xerr "$hl" "attach 5-3"
3626 echo "~^attachment list";\
3627 read es; echo $es;call xerr "$es" "attach 5-4"
3628 call read_mline_res
3630 echo "~^attachment remove-at 3"; read es;\
3631 call xerr $es "attach 5-5"
3632 echo "~^attachment remove-at 3"; read es;\
3633 vput vexpr es substr $es 0 3
3634 if [ $es != 501 ]
3635 xcall bail "attach 5-6"
3637 echo "~^attachment remove-at 2"; read es;\
3638 call xerr $es "attach 5-7"
3639 echo "~^attachment remove-at 2"; read es;\
3640 vput vexpr es substr $es 0 3
3641 if [ $es != 501 ]
3642 xcall bail "attach 5-8"
3644 echo "~^attachment remove-at 1"; read es;\
3645 call xerr $es "attach 5-9"
3646 echo "~^attachment remove-at 1"; read es;\
3647 vput vexpr es substr $es 0 3
3648 if [ $es != 501 ]
3649 xcall bail "attach 5-10"
3652 echo "~^attachment list"; read es;\
3653 vput vexpr es substr $es 0 3
3654 if [ $es != 501 ]
3655 xcall bail "attach 5-11"
3659 echo "~^attachment insert ./.tattach=latin1";\
3660 read hl; echo $hl; call xerr "$hl" "attach 6-1"
3661 echo "~^attachment insert ./.tattach=latin1";\
3662 read hl; echo $hl; call xerr "$hl" "attach 6-2"
3663 echo "~^attachment insert ./.tattach=latin1";\
3664 read hl; echo $hl; call xerr "$hl" "attach 6-3"
3665 echo "~^attachment list";\
3666 read es; echo $es;call xerr "$es" "attach 6-4"
3667 call read_mline_res
3669 echo "~^attachment remove-at 1"; read es;\
3670 call xerr $es "attach 6-5"
3671 echo "~^attachment remove-at 1"; read es;\
3672 call xerr $es "attach 6-6"
3673 echo "~^attachment remove-at 1"; read es;\
3674 call xerr $es "attach 6-7"
3675 echo "~^attachment remove-at 1"; read es;\
3676 vput vexpr es substr $es 0 3
3677 if [ $es != 501 ]
3678 xcall bail "attach 6-8"
3681 echo "~^attachment list"; read es;\
3682 vput vexpr es substr $es 0 3
3683 if [ $es != 501 ]
3684 xcall bail "attach 6-9"
3687 echo t_attach LEAVE
3689 define t_ocs {
3690 read ver
3691 echo t_ocs
3692 call t_header
3693 call t_attach
3695 define t_oce {
3696 echo on-compose-enter, mailx-command<$mailx-command>
3697 alternates alter1@exam.ple alter2@exam.ple
3698 alternates
3699 set autocc='alter1@exam.ple alter2@exam.ple'
3700 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3701 echo mailx-subject<$mailx-subject>
3702 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3703 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3704 mailx-raw-bcc<$mailx-raw-bcc>
3705 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
3706 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3708 define t_ocl {
3709 echo on-compose-leave, mailx-command<$mailx-command>
3710 vput alternates al
3711 eval alternates $al alter3@exam.ple alter4@exam.ple
3712 alternates
3713 set autobcc='alter3@exam.ple alter4@exam.ple'
3714 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3715 echo mailx-subject<$mailx-subject>
3716 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3717 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3718 mailx-raw-bcc<$mailx-raw-bcc>
3719 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
3720 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3722 define t_occ {
3723 echo on-compose-cleanup, mailx-command<$mailx-command>
3724 unalternates *
3725 alternates
3726 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3727 echo mailx-subject<$mailx-subject>
3728 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3729 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3730 mailx-raw-bcc<$mailx-raw-bcc>
3731 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
3732 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3734 wysh set on-compose-splice=t_ocs \
3735 on-compose-enter=t_oce on-compose-leave=t_ocl \
3736 on-compose-cleanup=t_occ
3737 __EOT__
3739 printf 'm this-goes@nowhere\nbody\n!.\n' |
3740 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
3741 -X'source ./.trc' -Smta=./.tmta.sh \
3742 >./.tall 2>&1
3743 ${cat} ./.tall >> "${MBOX}"
3744 check 1 0 "${MBOX}" '522535560 10101'
3746 ${rm} "${MBOX}"
3747 printf 'm this-goes@nowhere\nbody\n!.\n' |
3748 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
3749 -St_remove=1 -X'source ./.trc' -Smta=./.tmta.sh \
3750 >./.tall 2>&1
3751 ${cat} ./.tall >> "${MBOX}"
3752 check 2 0 "${MBOX}" '3654000499 12535'
3756 # Some state machine stress, shell compose hook, localopts for hook, etc.
3757 # readctl in child. ~r as HERE document
3758 ${rm} "${MBOX}"
3759 printf 'm ex@am.ple\nbody\n!.
3760 echon ${mailx-command}${mailx-subject}
3761 echon ${mailx-from}${mailx-sender}
3762 echon ${mailx-to}${mailx-cc}${mailx-bcc}
3763 echon ${mailx-raw-to}${mailx-raw-cc}${mailx-raw-bcc}
3764 echon ${mailx-orig-from}${mailx-orig-to}${mailx-orig-gcc}${mailx-orig-bcc}
3765 var t_oce t_ocs t_ocs_sh t_ocl t_occ autocc
3766 ' | ${MAILX} ${ARGS} -Snomemdebug -Sescape=! \
3767 -Smta=./.tmta.sh \
3769 define bail {
3770 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
3772 define xerr {
3773 vput vexpr es substr "$1" 0 1
3774 if [ "$es" != 2 ]
3775 xcall bail "$2"
3778 define read_mline_res {
3779 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
3780 echo $len/$es/$^ERRNAME: $hl
3781 if [ $es -ne $^ERR-NONE ]
3782 xcall bail read_mline_res
3783 elif [ $len -ne 0 ]
3784 \xcall read_mline_res
3787 define _work {
3788 vput vexpr i + 1 "$2"
3789 if [ $i -lt 111 ]
3790 vput vexpr j % $i 10
3791 if [ $j -ne 0 ]
3792 set j=xcall
3793 else
3794 echon "$i.. "
3795 set j=call
3797 eval \\$j _work $1 $i
3798 return $?
3800 vput vexpr i + $i "$1"
3801 return $i
3803 define _read {
3804 wysh set line; read line;wysh set es=$? en=$^ERRNAME ;\
3805 echo read:$es/$en: $line
3806 if [ "${es}" -ne -1 ]
3807 xcall _read
3809 readctl remove $cwd/.treadctl; echo readctl remove:$?/$^ERRNAME
3811 define t_ocs {
3812 read ver
3813 echo t_ocs
3814 echo "~^header list"; read hl; echo $hl;\
3815 vput vexpr es substr "$hl" 0 1
3816 if [ "$es" != 2 ]
3817 xcall bail "header list"
3818 endif
3820 call _work 1; echo $?
3821 echo "~^header insert cc splicy diet <splice@exam.ple> spliced";\
3822 read es; echo $es; vput vexpr es substr "$es" 0 1
3823 if [ "$es" != 2 ]
3824 xcall bail "be diet"
3825 endif
3826 echo "~^header insert cc <splice2@exam.ple>";\
3827 read es; echo $es; vput vexpr es substr "$es" 0 1
3828 if [ "$es" != 2 ]
3829 xcall bail "be diet2"
3830 endif
3832 call _work 2; echo $?
3833 echo "~^header insert bcc juicy juice <juice@exam.ple> spliced";\
3834 read es; echo $es;vput vexpr es substr "$es" 0 1
3835 if [ "$es" != 2 ]
3836 xcall bail "be juicy"
3837 endif
3838 echo "~^header insert bcc juice2@exam.ple";\
3839 read es; echo $es;vput vexpr es substr "$es" 0 1
3840 if [ "$es" != 2 ]
3841 xcall bail "be juicy2"
3842 endif
3843 echo "~^header insert bcc juice3 <juice3@exam.ple>";\
3844 read es; echo $es;vput vexpr es substr "$es" 0 1
3845 if [ "$es" != 2 ]
3846 xcall bail "be juicy3"
3847 endif
3848 echo "~^header insert bcc juice4@exam.ple";\
3849 read es; echo $es;vput vexpr es substr "$es" 0 1
3850 if [ "$es" != 2 ]
3851 xcall bail "be juicy4"
3852 endif
3854 echo "~^header remove-at bcc 3";\
3855 read es; echo $es;vput vexpr es substr "$es" 0 1
3856 if [ "$es" != 2 ]
3857 xcall bail "remove juicy5"
3858 endif
3859 echo "~^header remove-at bcc 2";\
3860 read es; echo $es;vput vexpr es substr "$es" 0 1
3861 if [ "$es" != 2 ]
3862 xcall bail "remove juicy6"
3863 endif
3864 echo "~^header remove-at bcc 3";\
3865 read es; echo $es;vput vexpr es substr "$es" 0 3
3866 if [ "$es" != 501 ]
3867 xcall bail "failed to remove-at"
3868 endif
3869 # Add duplicates which ought to be removed!
3870 echo "~^header insert bcc juice4@exam.ple";\
3871 read es; echo $es;vput vexpr es substr "$es" 0 1
3872 if [ "$es" != 2 ]
3873 xcall bail "be juicy4-1"
3874 endif
3875 echo "~^header insert bcc juice4@exam.ple";\
3876 read es; echo $es;vput vexpr es substr "$es" 0 1
3877 if [ "$es" != 2 ]
3878 xcall bail "be juicy4-2"
3879 endif
3880 echo "~^header insert bcc juice4@exam.ple";\
3881 read es; echo $es;vput vexpr es substr "$es" 0 1
3882 if [ "$es" != 2 ]
3883 xcall bail "be juicy4-3"
3884 endif
3885 echo "~:set t_ocs"
3888 call _work 3; echo $?
3889 echo "~r - '__EOT'"
3890 vput ! i echo just knock if you can hear me;\
3891 i=0;\
3892 while [ $i -lt 24 ]; do printf "%s " $i; i=`expr $i + 1`; done;\
3893 echo relax
3894 echon shell-cmd says $?/$^ERRNAME: $i
3895 echo "~x will not become interpreted, we are reading until __EOT"
3896 echo "__EOT"
3897 read r_status; echo "~~r status output: $r_status"
3898 echo "~:echo $? $! $^ERRNAME"
3899 read r_status
3900 echo "~~r status from parent: $r_status"
3903 call _work 4; echo $?
3904 vput cwd cwd;echo cwd:$?
3905 readctl create $cwd/.treadctl ;echo readctl:$?/$^ERRNAME;\
3906 call _read
3909 call _work 5; echo $?
3910 echo "~^header show MAILX-Command"; read es;\
3911 call xerr $es "t_header 1000"; call read_mline_res
3912 echo "~^header show MAILX-raw-TO"; read es;\
3913 call xerr $es "t_header 1001"; xcall read_mline_res
3915 echoerr IT IS WRONG IF YOU SEE THIS
3917 define t_oce {
3918 echo on-compose-enter, mailx-command<$mailx-command>
3919 set t_oce autobcc=oce@exam.ple
3920 alternates alter1@exam.ple alter2@exam.ple
3921 alternates
3922 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3923 echo mailx-subject<$mailx-subject>
3924 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3925 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3926 mailx-raw-bcc<$mailx-raw-bcc>
3927 echo mailx-orig-from<$mailx-orig-from> \
3928 mailx-orig-to<$mailx-orig-to> \
3929 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3931 define t_ocl {
3932 echo on-compose-leave, mailx-command<$mailx-command>
3933 set t_ocl autocc=ocl@exam.ple
3934 unalternates *
3935 alternates alter3@exam.ple alter4@exam.ple
3936 alternates
3937 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3938 echo mailx-subject<$mailx-subject>
3939 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3940 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3941 mailx-raw-bcc<$mailx-raw-bcc>
3942 echo mailx-orig-from<$mailx-orig-from> \
3943 mailx-orig-to<$mailx-orig-to> \
3944 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3946 define t_occ {
3947 echo on-compose-cleanup, mailx-command<$mailx-command>
3948 set t_occ autocc=occ@exam.ple
3949 unalternates *
3950 alternates
3951 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3952 echo mailx-subject<$mailx-subject>
3953 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3954 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3955 mailx-raw-bcc<$mailx-raw-bcc>
3956 echo mailx-orig-from<$mailx-orig-from> \
3957 mailx-orig-to<$mailx-orig-to> \
3958 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3960 wysh set on-compose-splice=t_ocs \
3961 on-compose-splice-shell="read ver;echo t_ocs-shell;\
3962 echo \"~t shell@exam.ple\"; echo \"~:set t_ocs_sh\"" \
3963 on-compose-enter=t_oce on-compose-leave=t_ocl \
3964 on-compose-cleanup=t_occ
3965 ' > ./.tnotes 2>&1
3966 check_ex0 3-estat
3967 ${cat} ./.tnotes >> "${MBOX}"
3968 check 3 - "${MBOX}" '679526364 2431'
3970 # Reply, forward, resend, Resend
3972 ${rm} "${MBOX}"
3973 printf 'set from=f1@z\nm t1@z\nb1\n!.\nset from=f2@z\nm t2@z\nb2\n!.\n' |
3974 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! \
3975 -Smta=./.tmta.sh
3977 printf '
3978 echo start: $? $! $^ERRNAME
3979 File %s
3980 echo File: $? $! $^ERRNAME;echo;echo
3981 reply 1
3982 this is content of reply 1
3984 echo reply 1: $? $! $^ERRNAME;echo;echo
3985 Reply 1 2
3986 this is content of Reply 1 2
3988 echo Reply 1 2: $? $! $^ERRNAME;echo;echo
3989 forward 1 fwdex@am.ple
3990 this is content of forward 1
3992 echo forward 1: $? $! $^ERRNAME;echo;echo
3993 resend 1 2 resendex@am.ple
3994 echo resend 1 2: $? $! $^ERRNAME;echo;echo
3995 Resend 1 2 Resendex@am.ple
3996 echo Resend 1 2: $? $! $^ERRNAME;echo;echo
3997 ' "${MBOX}" |
3998 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! \
3999 -Smta=./.tmta.sh \
4001 define bail {
4002 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
4004 define xerr {
4005 vput vexpr es substr "$1" 0 1
4006 if [ "$es" != 2 ]
4007 xcall bail "$2"
4010 define read_mline_res {
4011 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
4012 echo mline_res:$len/$es/$^ERRNAME: $hl
4013 if [ $es -ne $^ERR-NONE ]
4014 xcall bail read_mline_res
4015 elif [ $len -ne 0 ]
4016 \xcall read_mline_res
4019 define work_hl {
4020 echo "~^header show $1"; read es;\
4021 call xerr $es "work_hl $1"; echo $1; call read_mline_res
4022 if [ $# -gt 1 ]
4023 shift
4024 xcall work_hl "$@"
4027 define t_ocs {
4028 read ver
4029 echo t_ocs version $ver
4030 echo "~^header list"; read hl; echo $hl;\
4031 echoerr the header list is $hl;\
4032 call xerr "$hl" "header list"
4033 eval vpospar set $hl
4034 shift
4035 xcall work_hl "$@"
4036 echoerr IT IS WRONG IF YOU SEE THIS
4038 define t_oce {
4039 echo on-XY-enter, mailx-command<$mailx-command>
4040 set t_oce autobcc=oce@exam.ple
4041 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
4042 echo mailx-subject<$mailx-subject>
4043 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
4044 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
4045 mailx-raw-bcc<$mailx-raw-bcc>
4046 echo mailx-orig-from<$mailx-orig-from> \
4047 mailx-orig-to<$mailx-orig-to> \
4048 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
4050 define t_ocl {
4051 echo on-XY-leave, mailx-command<$mailx-command>
4052 set t_ocl autocc=ocl@exam.ple
4053 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
4054 echo mailx-subject<$mailx-subject>
4055 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
4056 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
4057 mailx-raw-bcc<$mailx-raw-bcc>
4058 echo mailx-orig-from<$mailx-orig-from> \
4059 mailx-orig-to<$mailx-orig-to> \
4060 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
4062 define t_occ {
4063 echo on-XY-cleanup, mailx-command<$mailx-command>
4064 set t_occ autocc=occ@exam.ple
4065 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
4066 echo mailx-subject<$mailx-subject>
4067 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
4068 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
4069 mailx-raw-bcc<$mailx-raw-bcc>
4070 echo mailx-orig-from<$mailx-orig-from> \
4071 mailx-orig-to<$mailx-orig-to> \
4072 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
4074 wysh set on-compose-splice=t_ocs \
4075 on-compose-enter=t_oce on-compose-leave=t_ocl \
4076 on-compose-cleanup=t_occ \
4077 on-resend-enter=t_oce on-resend-cleanup=t_occ
4078 ' > ./.tnotes 2>&1
4079 check_ex0 4-estat
4080 ${cat} ./.tnotes >> "${MBOX}"
4081 check 4 - "${MBOX}" '3038884027 7516'
4083 t_epilog
4086 t_C_opt_customhdr() {
4087 t_prolog C_opt_customhdr
4088 TRAP_EXIT_ADDONS="./.t*"
4090 t_xmta 'CimicifugaRacemosa Mon Dec 25 21:33:40 2017'
4092 echo bla |
4093 ${MAILX} ${ARGS} -Smta=./.tmta.sh \
4094 -C 'C-One : Custom One Body' \
4095 -C 'C-Two:CustomTwoBody' \
4096 -S customhdr='chdr1: chdr1 body, chdr2:chdr2 body' \
4097 this-goes@nowhere >./.tall 2>&1
4098 check_ex0 1-estat
4099 ${cat} ./.tall >> "${MBOX}"
4100 check 1 0 "${MBOX}" '2400078426 195'
4102 ${rm} "${MBOX}"
4103 printf 'm this-goes@nowhere\nbody\n!.
4104 unset customhdr
4105 m this-goes2@nowhere\nbody2\n!.
4106 set customhdr=%ccustom1 : custom1 body%c
4107 m this-goes2@nowhere\nbody2\n!.
4108 set customhdr=%ccustom1 : custom1\\, body , custom2: custom2 body%c
4109 m this-goes3@nowhere\nbody3\n!.
4110 ' "'" "'" "'" "'" |
4111 ${MAILX} ${ARGS} -Smta=./.tmta.sh -Sescape=! \
4112 -C 'C-One : Custom One Body' \
4113 -C 'C-Two:CustomTwoBody' \
4114 -S customhdr='chdr1: chdr1 body, chdr2:chdr2 body' \
4115 >./.tall 2>&1
4116 check_ex0 2-estat
4117 ${cat} ./.tall >> "${MBOX}"
4118 check 2 0 "${MBOX}" '3546878678 752'
4120 t_epilog
4123 t_quote_a_cmd_escapes() {
4124 t_prolog quote_a_cmd_escapes
4125 TRAP_EXIT_ADDONS="./.t*"
4127 t_xmta
4129 echo 'included file' > ./.ttxt
4131 ${cat} <<-_EOT > ./.tmbox
4132 From neverneverland Sun Jul 23 13:46:25 2017
4133 Subject: Bugstop: five miles out 1
4134 Reply-To: mister originator1 <mr1@originator>
4135 From: mister originator1 <mr1@originator>
4136 To: bugstop-commit@five.miles.out
4137 Cc: is1@a.list
4138 In-reply-to: <20170719111113.bkcMz%laber1@backe.eu>
4139 Date: Wed, 19 Jul 2017 09:22:57 -0400
4140 Message-Id: <20170719132257.766AF781267-1@originator>
4141 Status: RO
4143 That's appalling, I.
4145 From neverneverland Sun Jul 23 13:47:25 2017
4146 Subject: Bugstop: five miles out 2
4147 Reply-To: mister originator2 <mr2@originator>
4148 From: mister originator2 <mr2@originator>
4149 To: bugstop-commit@five.miles.out
4150 Cc: is2@a.list
4151 In-reply-to: <20170719111113.bkcMz%laber2@backe.eu>
4152 Date: Wed, 19 Jul 2017 09:23:57 -0400
4153 Message-Id: <20170719132257.766AF781267-2@originator>
4154 Status: RO
4156 That's appalling, II.
4158 From neverneverland Sun Jul 23 13:48:25 2017
4159 Subject: Bugstop: five miles out 3
4160 Reply-To: mister originator3 <mr3@originator>
4161 From: mister originator3 <mr3@originator>
4162 To: bugstop-commit@five.miles.out
4163 Cc: is3@a.list
4164 In-reply-to: <20170719111113.bkcMz%laber3@backe.eu>
4165 Date: Wed, 19 Jul 2017 09:24:57 -0400
4166 Message-Id: <20170719132257.766AF781267-3@originator>
4167 Status: RO
4169 That's appalling, III.
4171 _EOT
4173 printf '#
4174 set indentprefix=" |"
4175 set quote
4176 reply 2
4178 set quote=noheading
4179 reply 2
4181 headerpick type retain cc date from message-id reply-to subject to
4182 set quote=headers
4183 reply 2
4185 set quote=allheaders
4186 reply 2
4188 ' | ${MAILX} ${ARGS} -Smta=./.tmta.sh -Rf \
4189 -Sescape=! -Sindentprefix=' >' \
4190 ./.tmbox >./.tall 2>&1
4191 check_ex0 1-estat
4192 ${cat} ./.tall >> "${MBOX}"
4193 check 1 0 "${MBOX}" '3048941846 2023'
4195 # ~@ is tested with other attachment stuff, ~^ is in compose_hooks
4196 ${rm} "${MBOX}"
4197 printf '#
4198 set Sign=SignVar sign=signvar DEAD=./.ttxt
4199 headerpick type retain Subject
4200 reply 2
4201 !!1 Not escaped. And shell test last, right before !..
4202 !: echo 2 only echoed via colon
4203 !_ echo 3 only echoed via underscore
4204 !< ./.ttxt
4205 !<! echo 5 shell echo included
4206 !| echo 6 pipecmd-pre; cat; echo 6 pipecmd-post
4207 7 and 8 are ~A and ~a:
4210 !b 9 added ~b cc <ex1@am.ple>
4211 !c 10 added ~c c <ex2@am.ple>
4212 11 next ~d / $DEAD
4214 12: ~F
4216 13: ~F 1 3
4217 !F 1 3
4218 14: ~f (headerpick: subject)
4220 15: ~f 1
4221 !f 1
4222 16, 17: ~I Sign, ~i Sign
4223 !I Sign
4224 !i Sign
4225 18: ~M
4227 19: ~M 1
4228 !M 1
4229 20: ~m
4231 21: ~m 3
4232 !m 3
4233 22: ~R ./.ttxt
4234 !R ./.ttxt
4235 23: ~r ./.ttxt
4236 !r ./.ttxt
4237 24: ~s this new subject
4238 !s 24 did new ~s ubject
4239 !t 25 added ~t o <ex3@am.ple>
4240 26: ~U
4242 27: ~U 1
4243 !U 1
4244 and i ~w rite this out to ./.tmsg
4245 !w ./.tmsg
4246 !:wysh set x=$escape;set escape=~
4247 ~!echo shell command output
4248 ~:wysh set escape=$x
4250 ' | ${MAILX} ${ARGS} -Smta=./.tmta.sh -Rf \
4251 -Sescape=! -Sindentprefix=' |' \
4252 ./.tmbox >./.tall 2>&1
4253 check_ex0 2-estat
4254 ${cat} ./.tall >> "${MBOX}"
4255 check 2 0 "${MBOX}" '375879934 3604'
4256 check 3 - ./.tmsg '2112542907 2789'
4258 t_epilog
4261 t_mass_recipients() {
4262 t_prolog mass_recipients
4263 TRAP_EXIT_ADDONS="./.t*"
4265 t_xmta 'Eucalyptus Sat Jul 08 21:14:57 2017'
4267 ${cat} <<'__EOT__' > ./.trc
4268 define bail {
4269 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
4271 define ins_addr {
4272 wysh set nr=$1 hn=$2
4273 echo "~$hn $hn$nr@$hn"; echo '~:echo $?'; read es
4274 if [ "$es" -ne 0 ]
4275 xcall bail "ins_addr $hn 1-$nr"
4277 vput vexpr nr + $nr 1
4278 if [ "$nr" -le "$maximum" ]
4279 xcall ins_addr $nr $hn
4282 define bld_alter {
4283 wysh set nr=$1 hn=$2
4284 alternates $hn$nr@$hn
4285 vput vexpr nr + $nr 2
4286 if [ "$nr" -le "$maximum" ]
4287 xcall bld_alter $nr $hn
4290 define t_ocs {
4291 read ver
4292 call ins_addr 1 t
4293 call ins_addr 1 c
4294 call ins_addr 1 b
4296 define t_ocl {
4297 if [ "$t_remove" != '' ]
4298 call bld_alter 1 t
4299 call bld_alter 2 c
4302 set on-compose-splice=t_ocs on-compose-leave=t_ocl
4303 __EOT__
4305 printf 'm this-goes@nowhere\nbody\n!.\n' |
4306 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
4307 -X'source ./.trc' -Smta=./.tmta.sh -Smaximum=2001 \
4308 >./.tall 2>&1
4309 check_ex0 1-estat
4310 ${cat} ./.tall >> "${MBOX}"
4311 check 1 - "${MBOX}" '2912243346 51526'
4313 ${rm} "${MBOX}"
4314 printf 'm this-goes@nowhere\nbody\n!.\n' |
4315 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
4316 -St_remove=1 -X'source ./.trc' -Smta=./.tmta.sh -Smaximum=2001 \
4317 >./.tall 2>&1
4318 check_ex0 2-estat
4319 ${cat} ./.tall >> "${MBOX}"
4320 check 2 - "${MBOX}" '4097804632 34394'
4322 t_epilog
4325 t_mime_types_load_control() {
4326 t_prolog mime_types_load_control
4327 if have_feat uistrings; then :; else
4328 echo 'mime_types_load_control: unsupported, skipped'
4329 return
4331 TRAP_EXIT_ADDONS="./.t*"
4333 ${cat} <<-_EOT > ./.tmts1
4334 @ application/mathml+xml mathml
4335 _EOT
4336 ${cat} <<-_EOT > ./.tmts2
4337 @ x-conference/x-cooltalk ice
4338 @ aga-aga aga
4339 @ application/aga-aga aga
4340 _EOT
4342 ${cat} <<-_EOT > ./.tmts1.mathml
4343 <head>nonsense ML</head>
4344 _EOT
4345 ${cat} <<-_EOT > ./.tmts2.ice
4346 Icy, icy road.
4347 _EOT
4348 printf 'of which the c\x01rack is coming soon' > ./.tmtsx.doom
4349 printf 'of which the c\x01rack is coming soon' > ./.tmtsx.aga
4351 printf '
4352 m %s
4353 Schub-di-du
4354 ~@ ./.tmts1.mathml
4355 ~@ ./.tmts2.ice
4356 ~@ ./.tmtsx.doom
4357 ~@ ./.tmtsx.aga
4359 File %s
4360 from*
4361 type
4363 ' "${MBOX}" "${MBOX}" |
4364 ${MAILX} ${ARGS} \
4365 -Smimetypes-load-control=f=./.tmts1,f=./.tmts2 \
4366 > ./.tout 2>&1
4367 check_ex0 1-estat
4368 ${cat} "${MBOX}" >> ./.tout
4369 check 1 - ./.tout '1441260727 2449'
4371 echo type | ${MAILX} ${ARGS} -R \
4372 -Smimetypes-load-control=f=./.tmts1,f=./.tmts3 \
4373 -f "${MBOX}" >> ./.tout 2>&1
4374 check 2 0 ./.tout '1441391438 3646'
4376 t_epilog
4379 t_lreply_futh_rth_etc() {
4380 t_prolog lreply_futh_rth_etc
4381 TRAP_EXIT_ADDONS="./.t*"
4383 t_xmta 'HumulusLupulus Thu Jul 27 14:41:20 2017'
4385 ${cat} <<-_EOT > ./.tmbox
4386 From neverneverland Sun Jul 23 13:46:25 2017
4387 Subject: Bugstop: five miles out 1
4388 Reply-To: mister originator2 <mr2@originator>, bugstop@five.miles.out
4389 From: mister originator <mr@originator>
4390 To: bugstop-commit@five.miles.out, laber@backe.eu
4391 Cc: is@a.list
4392 Mail-Followup-To: bugstop@five.miles.out, laber@backe.eu, is@a.list
4393 In-reply-to: <20170719111113.bkcMz%laber@backe.eu>
4394 Date: Wed, 19 Jul 2017 09:22:57 -0400
4395 Message-Id: <20170719132257.766AF781267@originator>
4396 Status: RO
4398 > |Sorry, I think I misunderstand something. I would think that
4400 That's appalling.
4402 From neverneverland Fri Jul 7 22:39:11 2017
4403 Subject: Bugstop: five miles out 2
4404 Reply-To: mister originator2<mr2@originator>,bugstop@five.miles.out,is@a.list
4405 Content-Transfer-Encoding: 7bit
4406 From: mister originator <mr@originator>
4407 To: bugstop-commit@five.miles.out
4408 Cc: is@a.list
4409 Message-ID: <149945963975.28888.6950788126957753723.reportbug@five.miles.out>
4410 Date: Fri, 07 Jul 2017 16:33:59 -0400
4411 Status: R
4413 capable of changing back.
4415 From neverneverland Fri Jul 7 22:42:00 2017
4416 Subject: Bugstop: five miles out 3
4417 Reply-To: mister originator2 <mr2@originator>, bugstop@five.miles.out
4418 Content-Transfer-Encoding: 7bit
4419 From: mister originator <mr@originator>
4420 To: bugstop-commit@five.miles.out
4421 Cc: is@a.list
4422 Message-ID: <149945963975.28888.6950788126957753746.reportbug@five.miles.out>
4423 Date: Fri, 07 Jul 2017 16:33:59 -0400
4424 List-Post: <mailto:bugstop@five.miles.out>
4425 Status: R
4427 are you ready, boots?
4429 From neverneverland Sat Aug 19 23:15:00 2017
4430 Subject: Bugstop: five miles out 4
4431 Reply-To: mister originator2 <mr2@originator>, bugstop@five.miles.out
4432 Content-Transfer-Encoding: 7bit
4433 From: mister originator <mr@originator>
4434 To: bugstop@five.miles.out
4435 Cc: is@a.list
4436 Message-ID: <149945963975.28888.6950788126qtewrqwer.reportbug@five.miles.out>
4437 Date: Fri, 07 Jul 2017 16:33:59 -0400
4438 List-Post: <mailto:bugstop@five.miles.out>
4439 Status: R
4441 are you ready, boots?
4442 _EOT
4446 ${cat} <<-'_EOT' | ${MAILX} ${ARGS} -Sescape=! -Smta=./.tmta.sh \
4447 -Rf ./.tmbox >> "${MBOX}" 2>&1
4448 define r {
4449 wysh set m="This is text of \"reply ${1}."
4450 reply 1 2 3
4451 !I m
4454 !I m
4457 !I m
4460 echo -----After reply $1.1 - $1.3: $?/$^ERRNAME
4462 define R {
4463 wysh set m="This is text of \"Reply ${1}."
4464 eval Reply $2
4465 !I m
4466 !I 2
4469 echo -----After Reply $1.$2: $?/$^ERRNAME
4471 define _Lh {
4472 read protover
4473 echo '~I m'
4474 echo '~I n'
4475 echo '".'
4477 define _Ls {
4478 wysh set m="This is text of \"Lreply ${1}." on-compose-splice=_Lh n=$2
4479 eval Lreply $2
4481 define L {
4482 # We need two indirections for this test: one for the case that Lreply
4483 # fails because of missing recipients: we need to read EOF next, thus
4484 # place this in _Ls last; and second for the succeeding cases EOF is
4485 # not what these should read, so go over the backside and splice it in!
4486 call _Ls "$@"
4487 echo -----After Lreply $1.$2: $?/$^ERRNAME
4489 define x {
4490 localopts call-fixate yes
4491 call r $1
4492 call R $1 1; call R $1 2; call R $1 3; call R $1 4
4493 call L $1 1; call L $1 2; call L $1 3
4495 define tweak {
4496 echo;echo '===== CHANGING === '"$*"' =====';echo
4497 eval "$@"
4500 set from=laber@backe.eu
4501 mlist is@a.list
4502 call x 1
4503 call tweak set reply-to-honour
4504 call x 2
4505 call tweak set followup-to
4506 call x 3
4507 call tweak set followup-to-honour
4508 call x 4
4509 call tweak mlist bugstop@five.miles.out
4510 call x 5
4511 call tweak mlsubscribe bugstop@five.miles.out
4512 call x 6
4513 call tweak set recipients-in-cc
4514 call x 7
4515 _EOT
4517 check_ex0 1-estat
4518 if have_feat uistrings; then # xxx should not be so, skip??
4519 check 1 - "${MBOX}" '940818845 29373'
4520 else
4521 check 1 - "${MBOX}" '3917430455 29259'
4526 ${cat} <<-_EOT > ./.tmbox
4527 From tom@i-i.example Thu Oct 26 03:15:55 2017
4528 Date: Wed, 25 Oct 2017 21:15:46 -0400
4529 From: tom <tom@i-i.example>
4530 To: Steffen Nurpmeso <steffen@sdaoden.eu>
4531 Cc: tom <tom@i-i.example>
4532 Subject: Re: xxxx yyyyyyyy configure does not really like a missing zzzzz
4533 Message-ID: <20171026011546.GA11643@i-i.example>
4534 Reply-To: tom@i-i.example
4535 References: <20171025214601.T2pNd%steffen@sdaoden.eu>
4536 In-Reply-To: <20171025214601.T2pNd%steffen@sdaoden.eu>
4537 Status: R
4539 The report's useful :-)
4540 _EOT
4542 printf 'reply 1\nthank you\n!.\n' |
4543 ${MAILX} ${ARGS} -Sescape=! -Smta=./.tmta.sh -Sreply-to-honour \
4544 -Rf ./.tmbox > "${MBOX}" 2>&1
4545 check 2 0 "${MBOX}" '1045866991 331'
4547 t_epilog
4550 t_mime_if_not_ascii() {
4551 t_prolog mime_if_not_ascii
4553 </dev/null ${MAILX} ${ARGS} -s Subject "${MBOX}" >> "${MBOX}" 2>&1
4554 check 1 0 "${MBOX}" '2287855519 110'
4556 </dev/null ${MAILX} ${ARGS} -Scharset-7bit=not-ascii -s Subject "${MBOX}" \
4557 >> "${MBOX}" 2>&1
4558 check 2 0 "${MBOX}" '70754682 282'
4560 t_epilog
4563 t_xxxheads_rfc2047() {
4564 t_prolog xxxheads_rfc2047
4565 TRAP_EXIT_ADDONS="./.t*"
4567 t_xmta 'GentianaLutea Mon Dec 04 17:15:29 2017'
4569 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
4570 -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̲' \
4571 "${MBOX}"
4572 check 1 0 "${MBOX}" '3370931614 375'
4574 # Single word (overlong line split -- bad standard! Requires injection of
4575 # artificial data!! But can be prevented by using RFC 2047 encoding)
4576 ${rm} "${MBOX}"
4577 i=`${awk} 'BEGIN{for(i=0; i<92; ++i) printf "0123456789_"}'`
4578 echo | ${MAILX} ${ARGS} -s "${i}" "${MBOX}"
4579 check 2 0 "${MBOX}" '489922370 1718'
4581 # Combination of encoded words, space and tabs of varying sort
4582 ${rm} "${MBOX}"
4583 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
4584 -s "1Abrä Kaspas1 2Abra Katä b_kaspas2 \
4585 3Abrä Kaspas3 4Abrä Kaspas4 5Abrä Kaspas5 \
4586 6Abra Kaspas6 7Abrä Kaspas7 8Abra Kaspas8 \
4587 9Abra Kaspastäb4-3 10Abra Kaspas1 _ 11Abra Katäb1 \
4588 12Abra Kadabrä1 After Tab after Täb this is NUTS" \
4589 "${MBOX}"
4590 check 3 0 "${MBOX}" '1676887734 591'
4592 # Overlong multibyte sequence that must be forcefully split
4593 # todo This works even before v15.0, but only by accident
4594 ${rm} "${MBOX}"
4595 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
4596 -s "✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
4597 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
4598 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄" \
4599 "${MBOX}"
4600 check 4 0 "${MBOX}" '3029301775 659'
4602 # Trailing WS
4603 ${rm} "${MBOX}"
4604 echo | ${MAILX} ${ARGS} \
4605 -s "1-1 B2 B3 B4 B5 B6 B\
4606 1-2 B2 B3 B4 B5 B6 B\
4607 1-3 B2 B3 B4 B5 B6 B\
4608 1-4 B2 B3 B4 B5 B6 B\
4609 1-5 B2 B3 B4 B5 B6 B\
4610 1-6 B2 B3 B4 B5 B6 " \
4611 "${MBOX}"
4612 check 5 0 "${MBOX}" '4126167195 297'
4614 # Leading and trailing WS
4615 ${rm} "${MBOX}"
4616 echo | ${MAILX} ${ARGS} \
4617 -s " 2-1 B2 B3 B4 B5 B6 B\
4618 1-2 B2 B3 B4 B5 B6 B\
4619 1-3 B2 B3 B4 B5 B6 B\
4620 1-4 B2 B3 B4 B5 B6 " \
4621 "${MBOX}"
4622 check 6 0 "${MBOX}" '3600624479 236'
4624 # RFC 2047 in an address field! (Missing test caused v14.9.6!)
4625 ${rm} "${MBOX}"
4626 echo "Dat Früchtchen riecht häußlich" |
4627 ${MAILX} ${ARGS} ${ADDARG_UNI} -Sfullnames -Smta=./.tmta.sh \
4628 -s Hühöttchen \
4629 'Schnödes "Früchtchen" <do@du> (Hä!)'
4630 check 7 0 "${MBOX}" '800505986 368'
4632 # RFC 2047 in an address field, and iconv involved
4633 if have_feat iconv; then
4634 ${rm} "${MBOX}"
4635 ${cat} > ./.trebox <<_EOT
4636 From zaza@exam.ple Fri Mar 2 21:31:56 2018
4637 Date: Fri, 2 Mar 2018 20:31:45 +0000
4638 From: z=?iso-8859-1?Q?=E1?=za <zaza@exam.ple>
4639 To: dude <dude@exam.ple>
4640 Subject: houston(...)
4641 Message-ID: <abra@1>
4642 MIME-Version: 1.0
4643 Content-Type: text/plain; charset=iso-8859-1
4644 Content-Disposition: inline
4645 Content-Transfer-Encoding: 8bit
4647 _EOT
4648 echo reply | ${MAILX} ${ARGS} ${ADDARG_UNI} \
4649 -Sfullnames -Sreply-in-same-charset \
4650 -Smta=./.tmta.sh -Rf ./.trebox
4651 check 8 0 "${MBOX}" '2821484185 280'
4652 else
4653 echo 'xxxheads_rfc2047-8: iconv unsupported, skipped'
4656 t_epilog
4659 t_rfc2231() {
4660 t_prolog rfc2231
4661 TRAP_EXIT_ADDONS="./.t*"
4664 mkdir ./.ttt || exit 1
4665 cd ./.ttt || exit 2
4666 : > "ma'ger.txt"
4667 : > "mä'ger.txt"
4668 : > 'diet\ is \curd.txt'
4669 : > 'diet "is" curd.txt'
4670 : > höde-tröge.txt
4671 : > 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
4672 : > höde__tröge__müde__dätte__hätte__vuelle__guelle__aese__aesse__sauerliche__kräuter__österliche__grüße__mäh.txt
4673 : > hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt
4674 : > ✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt
4676 echo bla | ${MAILX} ${ARGS} ${ADDARG_UNI} \
4677 -a "./.ttt/ma'ger.txt" -a "./.ttt/mä'ger.txt" \
4678 -a './.ttt/diet\ is \curd.txt' -a './.ttt/diet "is" curd.txt' \
4679 -a ./.ttt/höde-tröge.txt \
4680 -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 \
4681 -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 \
4682 -a ./.ttt/hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt \
4683 -a ./.ttt/✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt \
4684 "${MBOX}"
4685 check 1 0 "${MBOX}" '684985954 3092'
4687 # `resend' test, reusing $MBOX
4688 printf "Resend ./.t2\nx\n" | ${MAILX} ${ARGS} -Rf "${MBOX}"
4689 check 2 0 ./.t2 '684985954 3092'
4691 printf "resend ./.t3\nx\n" | ${MAILX} ${ARGS} -Rf "${MBOX}"
4692 check 3 0 ./.t3 '3130352658 3148'
4694 t_epilog
4697 t_iconv_mbyte_base64() { # TODO uses sed(1) and special *headline*!!
4698 t_prolog iconv_mbyte_base64
4699 TRAP_EXIT_ADDONS="./.t*"
4701 if [ -n "${UTF8_LOCALE}" ] && have_feat iconv; then
4702 if (</dev/null iconv -f ascii -t iso-2022-jp) >/dev/null 2>&1 ||
4703 (</dev/null iconv -f ascii -t euc-jp) >/dev/null 2>&1; then
4705 else
4706 echo 'iconv_mbyte_base64: unsupported, skipped'
4707 return
4709 else
4710 echo 'iconv_mbyte_base64: unsupported, skipped'
4711 return
4714 t_xmta 'DroseriaRotundifolia Thu Aug 03 17:26:25 2017'
4716 if (</dev/null iconv -f ascii -t iso-2022-jp) >/dev/null 2>&1; then
4717 ${cat} <<-'_EOT' | LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} \
4718 -Smta=./.tmta.sh \
4719 -Sescape=! -Smime-encoding=base64 2>./.terr
4720 set ttycharset=utf-8 sendcharsets=iso-2022-jp
4721 m t1@exam.ple
4722 !s Japanese from UTF-8 to ISO-2022-JP
4723 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
4725 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
4728 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
4730 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
4733 set ttycharset=iso-2022-jp charset-7bit=iso-2022-jp sendcharsets=utf-8
4734 m t2@exam.ple
4735 !s Japanese from ISO-2022-JP to UTF-8, eh, no, also ISO-2022-JP
4736 \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
4738 \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
4741 \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
4743 \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
4745 _EOT
4746 # May not presume iconv output as long as roundtrip possible [489a7122]
4747 check_ex0 1-estat
4748 ${awk} 'BEGIN{h=1}/^$/{++h;next}{if(h % 2 == 1)print}' \
4749 < "${MBOX}" > ./.tcksum
4750 check 1 - ./.tcksum '2694609714 520'
4751 check 2 - ./.terr '4294967295 0'
4753 printf 'eval f 1; eval write ./.twrite; eval type 1; eval type 2\n' |
4754 LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} \
4755 -S headline="%>%a%m %-18f %-16d %i%-s" \
4756 -Rf "${MBOX}" >./.tlog 2>&1
4757 check 3 0 ./.twrite '1259742080 686'
4758 #check 4 - ./.tlog '3214068822 2123'
4759 ${sed} -e '/^\[-- M/d' < ./.tlog > ./.txlog
4760 check 4 - ./.txlog '3659773472 2035'
4761 else
4762 echo 'iconv_mbyte_base64: ISO-2022-JP unsupported, skipping 1-4'
4765 if (</dev/null iconv -f ascii -t euc-jp) >/dev/null 2>&1; then
4766 rm -f "${MBOX}" ./.twrite
4767 ${cat} <<-'_EOT' | LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} \
4768 -Smta=./.tmta.sh \
4769 -Sescape=! -Smime-encoding=base64 2>./.terr
4770 set ttycharset=utf-8 sendcharsets=euc-jp
4771 m t1@exam.ple
4772 !s Japanese from UTF-8 to EUC-JP
4773 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
4775 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
4778 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
4780 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
4783 set ttycharset=EUC-JP sendcharsets=utf-8
4784 m t2@exam.ple
4785 !s Japanese from EUC-JP to UTF-8
4786 ¥·¥¸¥å¥¦¥«¥é²Ê¡Ê¥·¥¸¥å¥¦¥«¥é¤«¡¢³Ø̾ Paridae¡Ë¤Ï¡¢Ä»Îॹ¥º¥áÌܤβʤǤ¢¤ë¡£¥·¥¸¥å¥¦¥«¥é¡Ê»Í½½¿ý¡Ë¤ÈÁí¾Î¤µ¤ì¤ë¤¬¡¢¶¹µÁ¤Ë¤Ï¤³¤Î1¼ï¤ò¥·¥¸¥å¥¦¥«¥é¤È¸Æ¤Ö¡£
4788 ¥«¥ó¥à¥ê¥¬¥é¡Ê³Ø̾Parus cristatus¡Ë¤Ï¡¢¥¹¥º¥áÌÜ¥·¥¸¥å¥¦¥«¥é²Ê¤ËʬÎव¤ì¤ëÄ»Îà¤Î°ì¼ï¡£
4791 ¥«¥ó¥à¥ê¥¬¥é¡Ê³Ø̾Parus cristatus¡Ë¤Ï¡¢¥¹¥º¥áÌÜ¥·¥¸¥å¥¦¥«¥é²Ê¤ËʬÎव¤ì¤ëÄ»Îà¤Î°ì¼ï¡£
4793 ¥·¥¸¥å¥¦¥«¥é²Ê¡Ê¥·¥¸¥å¥¦¥«¥é¤«¡¢³Ø̾ Paridae¡Ë¤Ï¡¢Ä»Îॹ¥º¥áÌܤβʤǤ¢¤ë¡£¥·¥¸¥å¥¦¥«¥é¡Ê»Í½½¿ý¡Ë¤ÈÁí¾Î¤µ¤ì¤ë¤¬¡¢¶¹µÁ¤Ë¤Ï¤³¤Î1¼ï¤ò¥·¥¸¥å¥¦¥«¥é¤È¸Æ¤Ö¡£
4795 _EOT
4796 check_ex0 5-estat
4797 ${awk} 'BEGIN{h=1}/^$/{++h;next}{if(h % 2 == 1)print}' \
4798 < "${MBOX}" > ./.tcksum
4799 check 5 - ./.tcksum '2870183985 473'
4800 check 6 - ./.terr '4294967295 0'
4802 printf 'eval f 1; eval write ./.twrite; eval type 1; eval type 2\n' |
4803 LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} \
4804 -S headline="%>%a%m %-18f %-16d %i%-s" \
4805 -Rf "${MBOX}" >./.tlog 2>&1
4806 check 7 0 ./.twrite '1259742080 686'
4807 #check 8 - ./.tlog '2506063395 2075'
4808 ${sed} -e '/^\[-- M/d' < ./.tlog > ./.txlog
4809 check 8 - ./.txlog '2528199891 1988'
4810 else
4811 echo 'iconv_mbyte_base64: EUC-JP unsupported, skipping 5-8'
4814 t_epilog
4817 t_iconv_mainbody() {
4818 t_prolog iconv_mainbody
4819 TRAP_EXIT_ADDONS="./.t*"
4821 if [ -n "${UTF8_LOCALE}" ] && have_feat iconv; then
4823 else
4824 echo 'iconv_mainbody: unsupported, skipped'
4825 return
4828 t_xmta 'HamamelisVirginiana Fri Oct 20 16:23:21 2017'
4830 printf '–' | ${MAILX} ${ARGS} ${ADDARG_UNI} -Smta=./.tmta.sh \
4831 -S charset-7bit=us-ascii -S charset-8bit=utf-8 \
4832 -s '–' over-the@rain.bow 2>./.terr
4833 check 1 0 "${MBOX}" '3634015017 251'
4834 check 2 - ./.terr '4294967295 0'
4836 printf '–' | ${MAILX} ${ARGS} ${ADDARG_UNI} -Smta=./.tmta.sh \
4837 -S charset-7bit=us-ascii -S charset-8bit=us-ascii \
4838 -s '–' over-the@rain.bow 2>./.terr
4839 check_exn0 3
4840 check 3 - "${MBOX}" '3634015017 251'
4841 if have_feat uistrings; then
4842 if have_feat docstrings; then # xxx should not be like that
4843 check 4 - ./.terr '2579894983 148'
4844 else
4845 check 4 - ./.terr '271380835 121'
4847 else
4848 echo 'iconv_mainbody-4: unsupported, skipped'
4851 # The different iconv(3) implementations use different replacement sequence
4852 # types (character-wise, byte-wise, and the character(s) used differ)
4853 i="${MAILX_ICONV_MODE}"
4854 if [ -n "${i}" ]; then
4855 printf 'p\nx\n' | ${MAILX} ${ARGS} -Rf "${MBOX}" >./.tout 2>./.terr
4856 j=${?}
4857 check_ex0 5-1-estat ${j}
4858 check 5-1 - ./.terr '4294967295 0'
4859 if [ ${i} -eq 13 ]; then
4860 check 5-2 - ./.tout '189327996 283'
4861 elif [ ${i} -eq 12 ]; then
4862 check 5-3 - ./.tout '1959197095 283'
4863 elif [ ${i} -eq 3 ]; then
4864 check 5-4 - ./.tout '3196380198 279'
4865 else
4866 check 5-5 - ./.tout '3760313827 279'
4868 else
4869 echo 'iconv_mainbody-5: unsupported, skipped'
4872 t_epilog
4875 t_binary_mainbody() {
4876 t_prolog binary_mainbody
4877 TRAP_EXIT_ADDONS="./.t*"
4879 printf 'abra\0\nka\r\ndabra' |
4880 ${MAILX} ${ARGS} ${ADDARG_UNI} -s 'binary with carriage-return!' \
4881 "${MBOX}" 2>./.terr
4882 check 1 0 "${MBOX}" '2430168141 243'
4883 check 2 - ./.terr '4294967295 0'
4885 printf 'p\necho\necho writing now\nwrite ./.twrite\n' |
4886 ${MAILX} ${ARGS} -Rf \
4887 -Spipe-application/octet-stream="@* ${cat} > ./.tcat" \
4888 "${MBOX}" >./.tall 2>&1
4889 check 3 0 ./.tall '1151843761 324'
4890 check 4 - ./.tcat '3817108933 15'
4891 check 5 - ./.twrite '3817108933 15'
4893 t_epilog
4896 t_q_t_etc_opts() {
4897 t_prolog q_t_etc_opts
4898 TRAP_EXIT_ADDONS="./.t*"
4900 # Three tests for MIME encoding and (a bit) content classification.
4901 # At the same time testing -q FILE, < FILE and -t FILE
4902 t__put_body > ./.tin
4904 < ./.tin ${MAILX} ${ARGS} ${ADDARG_UNI} \
4905 -a ./.tin -s "`t__put_subject`" "${MBOX}"
4906 check 1 0 "${MBOX}" '3570973309 6646'
4908 ${rm} "${MBOX}"
4909 < /dev/null ${MAILX} ${ARGS} ${ADDARG_UNI} \
4910 -a ./.tin -s "`t__put_subject`" -q ./.tin "${MBOX}"
4911 check 2 0 "${MBOX}" '3570973309 6646'
4913 ${rm} "${MBOX}"
4914 ( echo "To: ${MBOX}" && echo "Subject: `t__put_subject`" && echo &&
4915 ${cat} ./.tin
4916 ) | ${MAILX} ${ARGS} ${ADDARG_UNI} -Snodot -a ./.tin -t
4917 check 3 0 "${MBOX}" '3570973309 6646'
4919 t_epilog
4922 t_s_mime() {
4923 have_feat smime || {
4924 echo 's_mime: unsupported, skipped'
4925 return
4928 t_prolog s_mime
4929 TRAP_EXIT_ADDONS="./.t.conf ./.tkey.pem ./.tcert.pem ./.tpair.pem"
4930 TRAP_EXIT_ADDONS="${TRAP_EXIT_ADDONS} ./.VERIFY ./.DECRYPT ./.ENCRYPT"
4931 TRAP_EXIT_ADDONS="${TRAP_EXIT_ADDONS} ./.tmta.sh"
4933 ${cat} <<-_EOT > ./.t.conf
4934 [ req ]
4935 default_bits = 1024
4936 default_keyfile = keyfile.pem
4937 distinguished_name = req_distinguished_name
4938 attributes = req_attributes
4939 prompt = no
4940 output_password =
4942 [ req_distinguished_name ]
4943 C = GB
4944 ST = Over the
4945 L = rainbow
4946 O = S-nail
4947 OU = S-nail.smime
4948 CN = S-nail.test
4949 emailAddress = test@localhost
4951 [ req_attributes ]
4952 challengePassword =
4953 _EOT
4954 openssl req -x509 -nodes -days 3650 -config ./.t.conf \
4955 -newkey rsa:1024 -keyout ./.tkey.pem -out ./.tcert.pem >>${ERR} 2>&1
4956 check_ex0 0
4957 ${cat} ./.tkey.pem ./.tcert.pem > ./.tpair.pem
4959 # Sign/verify
4960 echo bla | ${MAILX} ${ARGS} \
4961 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
4962 -Ssmime-sign -Sfrom=test@localhost \
4963 -s 'S/MIME test' ./.VERIFY
4964 check_ex0 1-estat
4965 ${awk} '
4966 BEGIN{ skip=0 }
4967 /^Content-Description: /{ skip = 2; print; next }
4968 /^$/{ if(skip) --skip }
4969 { if(!skip) print }
4971 < ./.VERIFY > "${MBOX}"
4972 check 1 - "${MBOX}" '2900817158 648'
4974 printf 'verify\nx\n' |
4975 ${MAILX} ${ARGS} \
4976 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
4977 -Ssmime-sign -Sfrom=test@localhost \
4978 -Serrexit -R \
4979 -f ./.VERIFY >>${ERR} 2>&1
4980 check_ex0 2
4982 openssl smime -verify -CAfile ./.tcert.pem \
4983 -in ./.VERIFY >>${ERR} 2>&1
4984 check_ex0 3
4986 # (signing +) encryption / decryption
4987 t_xmta 'Euphrasia Thu Apr 27 17:56:23 2017' ./.ENCRYPT
4989 echo bla |
4990 ${MAILX} ${ARGS} \
4991 -Ssmime-force-encryption \
4992 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
4993 -Smta=./.tmta.sh \
4994 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
4995 -Ssmime-sign -Sfrom=test@localhost \
4996 -s 'S/MIME test' recei@ver.com
4997 check_ex0 4-estat
4998 ${sed} -e '/^$/,$d' < ./.ENCRYPT > "${MBOX}"
4999 check 4 - "${MBOX}" '1937410597 327'
5001 printf 'decrypt ./.DECRYPT\nfi ./.DECRYPT\nverify\nx\n' |
5002 ${MAILX} ${ARGS} \
5003 -Ssmime-force-encryption \
5004 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
5005 -Smta=./.tmta.sh \
5006 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
5007 -Ssmime-sign -Sfrom=test@localhost \
5008 -Serrexit -R \
5009 -f ./.ENCRYPT >>${ERR} 2>&1
5010 check_ex0 5-estat
5011 ${awk} '
5012 BEGIN{ skip=0 }
5013 /^Content-Description: /{ skip = 2; print; next }
5014 /^$/{ if(skip) --skip }
5015 { if(!skip) print }
5017 < ./.DECRYPT > "${MBOX}"
5018 check 5 - "${MBOX}" '1720739247 931'
5020 (openssl smime -decrypt -inkey ./.tkey.pem -in ./.ENCRYPT |
5021 openssl smime -verify -CAfile ./.tcert.pem) >>${ERR} 2>&1
5022 check_ex0 6
5024 ${rm} ./.ENCRYPT
5025 echo bla | ${MAILX} ${ARGS} \
5026 -Ssmime-force-encryption \
5027 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
5028 -Smta=./.tmta.sh \
5029 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
5030 -Sfrom=test@localhost \
5031 -s 'S/MIME test' recei@ver.com
5032 check_ex0 7-estat
5033 ${sed} -e '/^$/,$d' < ./.ENCRYPT > "${MBOX}"
5034 check 7 - "${MBOX}" '1937410597 327'
5036 ${rm} ./.DECRYPT
5037 printf 'decrypt ./.DECRYPT\nx\n' | ${MAILX} ${ARGS} \
5038 -Ssmime-force-encryption \
5039 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
5040 -Smta=./.tmta.sh \
5041 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
5042 -Sfrom=test@localhost \
5043 -Serrexit -R \
5044 -f ./.ENCRYPT >>${ERR} 2>&1
5045 check 8 0 "./.DECRYPT" '2624716890 422'
5047 openssl smime -decrypt -inkey ./.tkey.pem \
5048 -in ./.ENCRYPT >>${ERR} 2>&1
5049 check_ex0 9
5051 t_epilog
5054 # xxx Note: t_z() was the first test (series) written. Today many
5055 # xxx aspects are (better) covered by other tests above, some are not.
5056 # xxx At some future date and time, convert the last remains not covered
5057 # xxx elsewhere to a real t_* test and drop it
5058 t_z() {
5059 t_prolog z
5061 # Test for [260e19d] (Juergen Daubert)
5062 echo body | ${MAILX} ${ARGS} "${MBOX}"
5063 check 4 0 "${MBOX}" '2917662811 98'
5065 # "Test for" [d6f316a] (Gavin Troy)
5066 ${rm} "${MBOX}"
5067 printf "m ${MBOX}\n~s subject1\nEmail body\n~.\nfi ${MBOX}\np\nx\n" |
5068 ${MAILX} ${ARGS} ${ADDARG_UNI} -Spipe-text/plain="@* ${cat}" > "${BODY}"
5069 check 6 0 "${MBOX}" '2099098650 122'
5070 check 6-1 - "${BODY}" '794542938 174'
5072 # "Test for" [c299c45] (Peter Hofmann) TODO shouldn't end up QP-encoded?
5073 ${rm} "${MBOX}"
5074 ${awk} 'BEGIN{
5075 for(i = 0; i < 10000; ++i)
5076 printf "\xC3\xBC"
5077 #printf "\xF0\x90\x87\x90"
5078 }' | ${MAILX} ${ARGS} ${ADDARG_UNI} -s TestSubject "${MBOX}"
5079 check 7 0 "${MBOX}" '534262374 61816'
5081 t_epilog
5084 t__put_subject() {
5085 # MIME encoding (QP) stress message subject
5086 printf 'Äbrä Kä?dä=brö Fü?di=bus? '\
5087 'adadaddsssssssddddddddddddddddddddd'\
5088 'ddddddddddddddddddddddddddddddddddd'\
5089 'ddddddddddddddddddddddddddddddddddd'\
5090 'dddddddddddddddddddd Hallelulja? Od'\
5091 'er?? eeeeeeeeeeeeeeeeeeeeeeeeeeeeee'\
5092 'eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'\
5093 'eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee f'\
5094 'fffffffffffffffffffffffffffffffffff'\
5095 'fffffffffffffffffffff ggggggggggggg'\
5096 'ggggggggggggggggggggggggggggggggggg'\
5097 'ggggggggggggggggggggggggggggggggggg'\
5098 'ggggggggggggggggggggggggggggggggggg'\
5099 'gggggggggggggggg'
5102 t__put_body() {
5103 # MIME encoding (QP) stress message body
5104 printf \
5105 'Ich bin eine DÖS-Datäi mit sehr langen Zeilen und auch '\
5106 'sonst bin ich ganz schön am Schleudern, da kannste denke '\
5107 "wasde willst, gelle, gelle, gelle, gelle, gelle.\r\n"\
5108 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst \r\n"\
5109 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1\r\n"\
5110 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12\r\n"\
5111 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123\r\n"\
5112 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1234\r\n"\
5113 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12345\r\n"\
5114 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123456\r\n"\
5115 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1234567\r\n"\
5116 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12345678\r\n"\
5117 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123456789\r\n"\
5118 "Unn ausserdem habe ich trailing SP/HT/SP/HT whitespace \r\n"\
5119 "Unn ausserdem habe ich trailing HT/SP/HT/SP whitespace \r\n"\
5120 "auf den zeilen vorher.\r\n"\
5121 "From am Zeilenbeginn und From der Mitte gibt es auch.\r\n"\
5122 ".\r\n"\
5123 "Die letzte Zeile war nur ein Punkt.\r\n"\
5124 "..\r\n"\
5125 "Das waren deren zwei.\r\n"\
5126 " \r\n"\
5127 "Die letzte Zeile war ein Leerschritt.\n"\
5128 "=VIER = EQUAL SIGNS=ON A LINE=\r\n"\
5129 "Prösterchen.\r\n"\
5130 ".\n"\
5131 "Die letzte Zeile war nur ein Punkt, mit Unix Zeilenende.\n"\
5132 "..\n"\
5133 "Das waren deren zwei. ditto.\n"\
5134 "Prösterchen.\n"\
5135 "Unn ausseerdem habe ich trailing SP/HT/SP/HT whitespace \n"\
5136 "Unn ausseerdem habe ich trailing HT/SP/HT/SP whitespace \n"\
5137 "auf den zeilen vorher.\n"\
5138 "ditto.\n"\
5139 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.\n"\
5140 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.1"\
5141 "\n"\
5142 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
5143 "\n"\
5144 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
5145 "3\n"\
5146 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
5147 "34\n"\
5148 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
5149 "345\n"\
5150 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
5151 "3456\n"\
5152 "QP am Zeilenende über soft-nl hinweg\n"\
5153 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
5154 "ö123\n"\
5155 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
5156 "1ö23\n"\
5157 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
5158 "12ö3\n"\
5159 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
5160 "123ö\n"\
5161 "=VIER = EQUAL SIGNS=ON A LINE=\n"\
5162 " \n"\
5163 "Die letzte Zeile war ein Leerschritt.\n"\
5167 # cc_all_configs()
5168 # Test all configs TODO doesn't cover all *combinations*, stupid!
5169 cc_all_configs() {
5170 < ${CONF} ${awk} '
5171 BEGIN{
5172 ALWAYS = "OPT_AUTOCC=1 OPT_AMALGAMATION=1"
5173 NOTME["OPT_ALWAYS_UNICODE_LOCALE"] = 1
5174 NOTME["OPT_CROSS_BUILD"] = 1
5175 NOTME["OPT_AUTOCC"] = 1
5176 NOTME["OPT_AMALGAMATION"] = 1
5177 NOTME["OPT_DEBUG"] = 1
5178 NOTME["OPT_DEVEL"] = 1
5179 NOTME["OPT_ASAN_ADDRESS"] = 1
5180 NOTME["OPT_ASAN_MEMORY"] = 1
5181 NOTME["OPT_FORCED_STACKPROT"] = 1
5182 NOTME["OPT_NOMEMDBG"] = 1
5183 NOTME["OPT_NYD2"] = 1
5185 #OPTVALS
5186 OPTNO = 0
5188 MULCHOICE["OPT_IDNA"] = "VAL_IDNA"
5189 MULVALS["VAL_IDNA"] = 1
5191 #VALKEYS[0] = "VAL_RANDOM"
5192 VALVALS["VAL_RANDOM"] = 1
5193 VALNO = 0
5195 /^[[:space:]]*OPT_/{
5196 sub(/^[[:space:]]*/, "")
5197 # This bails for UnixWare 7.1.4 awk(1), but preceeding = with \
5198 # does not seem to be a compliant escape for =
5199 #sub(/=.*$/, "")
5200 $1 = substr($1, 1, index($1, "=") - 1)
5201 if(!NOTME[$1])
5202 OPTVALS[OPTNO++] = $1
5203 next
5205 /^[[:space:]]*VAL_/{
5206 sub(/^[[:space:]]*/, "")
5207 val = substr($0, index($0, "=") + 1)
5208 if(val ~ /^\"/){
5209 val = substr(val, 2)
5210 val = substr(val, 1, length(val) - 1)
5212 $1 = substr($1, 1, index($1, "=") - 1)
5213 if(MULVALS[$1])
5214 MULVALS[$1] = val
5215 else if(VALVALS[$1]){
5216 VALKEYS[VALNO++] = $1
5217 VALVALS[$1] = val
5219 next
5221 function onepass(addons){
5222 a_onepass__worker(addons, "1", "0")
5223 a_onepass__worker(addons, "0", "1")
5225 function a_onepass__worker(addons, b0, b1){
5226 # Doing this completely sequentially and not doing make distclean in
5227 # between runs should effectively result in lesser compilations.
5228 # It is completely dumb nonetheless... TODO
5229 for(ono = 0; ono < OPTNO; ++ono){
5230 myconf = mula = ""
5231 for(i = 0; i < ono; ++i){
5232 myconf = myconf " " OPTVALS[i] "=" b0 " "
5233 if(b0 == "1"){
5234 j = MULCHOICE[OPTVALS[i]]
5235 if(j){
5236 if(i + 1 == ono)
5237 mula = j
5238 else
5239 myconf = myconf " " MULCHOICE[OPTVALS[i]] "=any "
5243 for(i = ono; i < OPTNO; ++i){
5244 myconf = myconf " " OPTVALS[i] "=" b1 " "
5245 if(b1 == "1"){
5246 j = MULCHOICE[OPTVALS[i]]
5247 if(j){
5248 if(i + 1 == OPTNO)
5249 mula = j;
5250 else
5251 myconf = myconf " " MULCHOICE[OPTVALS[i]] "=any "
5256 for(i in VALKEYS)
5257 myconf = VALKEYS[i] "=any " myconf
5259 myconf = myconf " " ALWAYS " " addons
5261 if(mula == "")
5262 print myconf
5263 else{
5264 i = split(MULVALS[mula], ia)
5265 j = "any"
5266 while(i >= 1){
5267 j = ia[i--] " " j
5268 print mula "=\"" j "\" " myconf
5273 END{
5274 # We cannot test NULL because of missing UI strings, which will end
5275 # up with different checksums
5276 print "CONFIG=NULLI OPT_AUTOCC=1"
5277 for(i in VALKEYS){
5278 j = split(VALVALS[VALKEYS[i]], ia)
5279 k = "any"
5280 while(j >= 1){
5281 k = ia[j--] " " k
5282 print VALKEYS[i] "=\"" k "\" CONFIG=NULLI OPT_AUTOCC=1"
5285 print "CONFIG=MINIMAL OPT_AUTOCC=1"
5286 print "CONFIG=NETSEND OPT_AUTOCC=1"
5287 print "CONFIG=MAXIMAL OPT_AUTOCC=1"
5288 for(i in VALKEYS){
5289 j = split(VALVALS[VALKEYS[i]], ia)
5290 k = "any"
5291 while(j >= 1){
5292 k = ia[j--] " " k
5293 print VALKEYS[i] "=\"" k "\" CONFIG=MAXIMAL OPT_AUTOCC=1"
5296 print "CONFIG=DEVEL OPT_AUTOCC=1"
5297 print "CONFIG=ODEVEL OPT_AUTOCC=1"
5299 onepass("OPT_DEBUG=1")
5300 onepass("")
5302 ' | while read c; do
5303 [ -f mk-config.h ] && ${cp} mk-config.h .ccac.h
5304 printf "\n\n##########\n$c\n"
5305 printf "\n\n##########\n$c\n" >&2
5306 ${SHELL} -c "cd .. && ${MAKE} ${c} config"
5307 if [ -f .ccac.h ] && ${cmp} mk-config.h .ccac.h; then
5308 printf 'Skipping after config, nothing changed\n'
5309 printf 'Skipping after config, nothing changed\n' >&2
5310 continue
5312 ${SHELL} -c "cd ../ && ${MAKE} build test"
5313 done
5314 ${rm} -f .ccac.h
5315 cd .. && ${MAKE} distclean
5318 [ -n "${ERR}" ] && echo > ${ERR}
5319 if [ -z "${CHECK_ONLY}${MAE_TEST}" ]; then
5320 cc_all_configs
5321 elif [ -z "${MAE_TEST}" ] || [ ${#} -eq 0 ]; then
5322 # if have_feat devel; then
5323 # ARGS="${ARGS} -Smemdebug"
5324 # export ARGS
5325 # fi
5326 t_all
5328 else
5329 while [ ${#} -gt 0 ]; do
5330 eval t_${1}
5331 shift
5332 done
5335 [ ${ESTAT} -eq 0 ] && echo Ok || echo >&2 'Errors occurred'
5337 exit ${ESTAT}
5338 # s-sh-mode