NEWS: v14.9.21 ("Tit escapes with a peanut"), 2021-01-21
[s-mailx.git] / mx-test.sh
blob4a2637955b16d22c7bacf7e43049bc69ab0c6387
1 #!/bin/sh -
2 #@ Synopsis: [OBJDIR=XY] ./mx-test.sh --check mailx-binary [:SKIPTESTNAME:]
3 #@ [OBJDIR=XY] ./mx-test.sh --run-test mailx-binary [:TESTNAME:]
4 #@ [./mx-test.sh # Note: performs hundreds of compilations!]
5 #@ --no-jobs can be used to prevent spawning concurrent tests.
6 #@ --no-colour or $MAILX_CC_TEST_NO_COLOUR for not trying to use colour
7 #@ (then grep for ^ERROR, for example).
8 #@ The last mode also reacts on $MAILX_CC_ALL_TESTS_DUMPERR, for even easier
9 #@ grep ^ERROR handling.
10 #@ And setting $MAILX_CC_TEST_NO_CLEANUP keeps all test data around, fwiw:
11 #@ this works with --run-test only.
12 #@ $JOBWAIT, $JOBMON and $SKIPTEST are taken from environment when found.
14 # Public Domain
16 : ${OBJDIR:=.obj}
18 # Instead of figuring out the environment in here, require a configured build
19 # system and include that! Our makefile and configure ensure that this test
20 # does not run in the configured, but the user environment nonetheless!
22 while :; do
23 if [ -f ./mk-config.env ]; then
24 break
25 elif [ -f snailmail.jpg ] && [ -f "${OBJDIR}"/mk-config.env ]; then
26 i=`pwd`/ # not from environment, sic
27 cd "${OBJDIR}"
28 break
29 else
30 echo >&2 'S-nail/S-mailx is not configured.'
31 echo >&2 'This test script requires the shell environment that only the'
32 echo >&2 'configuration script can figure out, even if used to test'
33 echo >&2 'a different binary than the one that would be produced!'
34 echo >&2 '(The information will be in ${OBJDIR:=.obj}/mk-config.env.)'
35 echo >&2 'Hit RETURN to run "make config"'
36 read l
37 make config
39 done
40 . ./mk-config.env
41 if [ -z "${MAILX__CC_TEST_RUNNING}" ]; then
42 MAILX__CC_TEST_RUNNING=1
43 export MAILX__CC_TEST_RUNNING
44 exec "${SHELL}" "${i}${0}" "${@}"
47 # We need *stealthmua* regardless of $SOURCE_DATE_EPOCH, the program name as
48 # such is a compile-time variable
49 ARGS='-Sv15-compat -:/ -Sdotlock-disable -Smta=test -Smta-bcc-ok'
50 ARGS="${ARGS}"' -Smemdebug -Sstealthmua'
51 ARGS="${ARGS}"' -Smime-encoding=quoted-printable -Snosave'
52 ARGS="${ARGS}"' -Smailcap-disable -Smimetypes-load-control='
53 NOBATCH_ARGS="${ARGS}"' -Sexpandaddr'
54 ARGS="${ARGS}"' -Sexpandaddr=restrict -#'
55 ADDARG_UNI=-Sttycharset=UTF-8
56 CONF=../make.rc
57 BODY=./.cc-body.txt
58 MBOX=./.cc-test.mbox
59 ERR=./.cc-test.err # Covers some which cannot be checksummed; not quoted!
60 MAIL=/dev/null
61 #UTF8_LOCALE= HONOURS_READONLY= autodetected unless set
62 TMPDIR=`${pwd}`
64 # When testing mass mail/loops, maximum number of receivers/loops.
65 # TODO note we do not gracefully handle ARG_MAX excess yet!
66 # Those which use this have checksums for 2001 and 201.
67 # Some use the smaller automatically if +debug
68 LOOPS_BIG=2001 LOOPS_SMALL=201
69 LOOPS_MAX=$LOOPS_SMALL
71 # How long unless started tests get reaped (avoid endless looping)
72 : ${JOBWAIT:=42}
73 : ${JOBMON:=y}
74 : ${SKIPTEST:=}
76 # Note valgrind has problems with FDs in forked childs, which causes some tests
77 # to fail (the FD is rewound and thus will be dumped twice)
78 MEMTESTER=
79 #MEMTESTER='valgrind --leak-check=full --log-file=.vl-%p '
81 ## -- >8 -- 8< -- ##
83 t_all() {
84 # Absolute Basics
85 jspawn X_Y_opt_input_go_stack
86 jspawn X_errexit
87 jspawn Y_errexit
88 jspawn S_freeze
89 jspawn f_batch_order
90 jspawn input_inject_semicolon_seq
91 jspawn wysh
92 jspawn commandalias # test now, save space later on!
93 jspawn posix_abbrev
94 jsync
96 # Basics
97 jspawn shcodec
98 jspawn ifelse
99 jspawn localopts
100 jspawn local
101 jspawn environ
102 jspawn macro_param_shift
103 jspawn addrcodec
104 jspawn csop
105 jspawn vexpr
106 jspawn call_ret
107 jspawn xcall
108 jspawn vpospar
109 jspawn atxplode
110 jspawn read
111 jspawn readsh
112 jspawn headerpick # so we have a notion that it works a bit
113 jsync
115 # Send/RFC absolute basics
116 jspawn can_send_rfc
117 jspawn reply
118 jspawn forward
119 jspawn resend
120 jsync
122 # VFS
123 jspawn copy
124 jspawn save
125 jspawn move
126 jspawn mbox
127 jspawn maildir
128 jsync
130 # MIME and RFC basics
131 jspawn mime_if_not_ascii
132 jspawn mime_encoding
133 jspawn xxxheads_rfc2047
134 jspawn iconv_mbyte_base64
135 jspawn iconv_mainbody
136 jspawn mime_force_sendout
137 jspawn binary_mainbody
138 jspawn C_opt_customhdr
139 jsync
141 # Operational basics with trivial tests
142 jspawn alias
143 jspawn charsetalias
144 jspawn shortcut
145 jspawn netrc
146 jsync
148 # Operational basics with easy tests
149 jspawn expandaddr # (after t_alias)
150 jspawn mta_aliases # (after t_expandaddr)
151 jspawn filetype
152 jspawn e_H_L_opts
153 jspawn q_t_etc_opts
154 jspawn message_injections
155 jspawn attachments
156 jspawn rfc2231 # (after attachments)
157 jspawn mime_types_load_control
158 jsync
160 # Around state machine, after basics
161 jspawn alternates
162 jspawn cmd_escapes
163 jspawn compose_edits
164 jspawn digmsg
165 jspawn on_main_loop_tick
166 jspawn on_program_exit
167 jsync
169 # Heavy use of/rely on state machine (behaviour) and basics
170 jspawn compose_hooks
171 jspawn mass_recipients
172 jspawn lreply_futh_rth_etc
173 jspawn pipe_handlers
174 jspawn mailcap
175 jsync
177 # Unclassified rest
178 jspawn top
179 jspawn s_mime
180 jspawn z
181 jsync
183 jsync 1
186 ## Now it is getting really weird. You have been warned.
187 # Setup and support {{{
188 export ARGS ADDARG_UNI CONF BODY MBOX MAIL TMPDIR \
189 MAKE awk cat cksum rm sed grep
191 LC_ALL=C LANG=C
192 TZ=UTC
193 # Wed Oct 2 01:50:07 UTC 1996
194 SOURCE_DATE_EPOCH=844221007
196 export LC_ALL LANG TZ SOURCE_DATE_EPOCH
197 unset POSIXLY_CORRECT LOGNAME USER
199 # usage {{{
200 usage() {
201 ${cat} >&2 <<'_EOT'
202 Synopsis: [OBJDIR=x] mx-test.sh [--no-jobs] --check mailx-binary [:SKIPTEST:]
203 Synopsis: [OBJDIR=x] mx-test.sh [--no-jobs] --run-test mailx-binary [:TEST:]
204 Synopsis: [OBJDIR=x] mx-test.sh [--no-jobs]
206 --check EXE [:SKIPTEST:] run test series, exit success or error.
207 [:SKIPTEST:]s (and $SKIPTEST=) will be excluded.
208 --run-test EXE [:TEST:] run all or only the given TESTs, and create
209 test output data files; if run in a git(1)
210 checkout with the [test-out] branch available,
211 it will also create file diff(1)erences
212 --no-jobs do not spawn multiple jobs simultaneously
213 (dependent on make(1) and sh(1), pass JOBMON=n, too)
214 --no-colour or $MAILX_CC_TEST_NO_COLOUR: no colour
215 (for example to: grep ^ERROR)
216 $MAILX_CC_ALL_TESTS_DUMPER in addition for even
217 easier grep ^ERROR handling
219 The last invocation style will compile and test as many different
220 configurations as possible.
221 EXE should be absolute or relative to $OBJDIR, which can be may be set to the
222 location of the built objects etc.
223 $MAILX_CC_TEST_NO_CLEANUP skips deletion of test data (works only with
224 one test, aka --run-test).
225 $JOBWAIT could denote a timeout, $JOBMON controls usage of "set -m".
226 _EOT
227 exit 1
230 CHECK= RUN_TEST= MAILX=
231 DEVELDIFF= DUMPERR= GIT_REPO=
232 MAXJOBS=1 NOCOLOUR= NOJOBS=
233 while [ ${#} -gt 0 ]; do
234 if [ "${1}" = --no-jobs ]; then
235 NOJOBS=y
236 shift
237 elif [ "${1}" = --no-colour ]; then
238 NOCOLOUR=y
239 shift
240 elif [ "${1}" = -h ] || [ "${1}" = --help ]; then
241 usage
242 exit 0
243 else
244 break
246 done
248 if [ "${1}" = --check ]; then
249 CHECK=1 MAILX=${2}
250 [ -x "${MAILX}" ] || usage
251 shift 2
252 SKIPTEST="${@} ${SKIPTEST}"
253 [ -d ../.git ] && [ -z "${MAILX__CC_TEST_NO_DATA_FILES}" ] && GIT_REPO=1
254 echo 'Mode: --check, binary: '"${MAILX}"
255 elif [ "${1}" = --run-test ]; then
256 [ ${#} -ge 2 ] || usage
257 RUN_TEST=1 MAILX=${2}
258 [ -x "${MAILX}" ] || usage
259 shift 2
260 [ -d ../.git ] && GIT_REPO=1
261 echo 'Mode: --run-test, binary: '"${MAILX}"
262 else
263 [ ${#} -eq 0 ] || usage
264 echo 'Mode: full compile test, this will take a long time...'
265 MAILX__CC_TEST_NO_DATA_FILES=1
266 export MAILX__CC_TEST_NO_DATA_FILES
268 # }}}
270 # Since we invoke $MAILX from within several directories we need a fully
271 # qualified path. Or at least something similar.
272 { echo ${MAILX} | ${grep} -q ^/; } || MAILX="${TMPDIR}"/${MAILX}
273 RAWMAILX=${MAILX}
274 MAILX="${MEMTESTER}${MAILX}"
275 export RAWMAILX MAILX
277 # We want an UTF-8 locale, and HONOURS_READONLY {{{
278 if [ -n "${CHECK}${RUN_TEST}" ]; then
279 if [ -z "${UTF8_LOCALE}" ]; then
280 # Try ourselfs via nl_langinfo(CODESET) first (requires a new version)
281 if command -v "${RAWMAILX}" >/dev/null 2>&1 &&
282 ("${RAWMAILX}" -:/ -Xxit) >/dev/null 2>&1; then
283 echo 'Trying to detect UTF-8 locale via '"${RAWMAILX}"
284 i=`</dev/null LC_ALL=C.utf8 "${RAWMAILX}" ${ARGS} -X '
285 \set errexit
286 \define cset_test {
287 \if "${ttycharset}" =%?case utf
288 \echo $LC_ALL
289 \xit 0
290 \end
291 \if "${#}" -gt 0
292 \set LC_ALL=${1}
293 \shift
294 \xcall cset_test "${@}"
295 \end
296 \xit 1
298 \call cset_test C.UTF-8 POSIX.utf8 POSIX.UTF-8 \
299 en_EN.utf8 en_EN.UTF-8 en_US.utf8 en_US.UTF-8
301 [ $? -eq 0 ] && UTF8_LOCALE=$i
304 if [ -z "${UTF8_LOCALE}" ] && (locale yesexpr) >/dev/null 2>&1; then
305 echo 'Trying to detect UTF-8 locale via locale -a'
306 UTF8_LOCALE=`locale -a | { m=
307 while read n; do
308 if { echo ${n} |
309 ${grep} -i -e utf8 -e utf-8; } >/dev/null 2>&1; then
310 m=${n}
311 if { echo ${n} |
312 ${grep} -e POSIX -e en_EN -e en_US; } \
313 >/dev/null 2>&1; then
314 break
317 done
318 echo ${m}
323 if [ -n "${UTF8_LOCALE}" ]; then
324 echo 'Using Unicode locale '"${UTF8_LOCALE}"
325 else
326 echo 'No Unicode locale found, disabling Unicode tests'
329 if [ -z "${HONOURS_READONLY}" ]; then
330 trap "${rm} -f ./.tisrdonly" EXIT
331 trap "exit 1" HUP INT TERM
332 printf '' > ./.tisrdonly
333 ${chmod} 0444 ./.tisrdonly
334 if (printf 'no\n' > ./.tisrdonly) >/dev/null 2>&1 &&
335 test -s ./.tisrdonly; then
336 HONOURS_READONLY=
337 else
338 HONOURS_READONLY=yes
340 ${rm} -f ./.tisrdonly
341 trap '' EXIT HUP INT TERM
345 export UTF8_LOCALE HONOURS_READONLY
346 # }}}
348 TESTS_PERFORMED=0 TESTS_OK=0 TESTS_FAILED=0 TESTS_SKIPPED=0
349 JOBS=0 JOBLIST= JOBREAPER= JOBSYNC=
350 SUBSECOND_SLEEP=
351 ( sleep .1 ) >/dev/null 2>&1 && SUBSECOND_SLEEP=y
353 COLOR_ERR_ON= COLOR_ERR_OFF=
354 COLOR_WARN_ON= COLOR_WARN_OFF=
355 COLOR_OK_ON= COLOR_OK_OFF=
356 ESTAT=0
357 TEST_NAME=
359 trap "
360 jobreaper_stop
361 [ -z "${MAILX_CC_TEST_NO_CLEANUP}" ] &&
362 ${rm} -rf ./t.*.d ./t.*.io ./t.*.result ./t.time.out
363 " EXIT
364 trap "exit 1" HUP INT QUIT TERM
366 # JOBS {{{
367 if [ -n "${NOJOBS}" ]; then
368 jobs_max() { :; }
369 else
370 jobs_max() {
371 # The user desired variant
372 if ( echo "${MAKEFLAGS}" | ${grep} -- -j ) >/dev/null 2>&1; then
373 i=`echo "${MAKEFLAGS}" |
374 ${sed} -e 's/^.*-j[ ]*\([0-9]\{1,\}\).*$/\1/'`
375 if ( echo "${i}" | grep -q -e '^[0-9]\{1,\}$' ); then
376 printf 'Job number derived from MAKEFLAGS: %s\n' ${i}
377 MAXJOBS=${i}
378 [ "${MAXJOBS}" -eq 0 ] && MAXJOBS=1
379 return
383 # The actual hardware
384 printf 'all:\n' > t.mk.io
385 if ( ${MAKE} -j 10 -f t.mk.io ) >/dev/null 2>&1; then
386 if command -v nproc >/dev/null 2>&1; then
387 i=`nproc 2>/dev/null`
388 [ ${?} -eq 0 ] && MAXJOBS=${i}
389 else
390 i=`getconf _NPROCESSORS_ONLN 2>/dev/null`
391 j=${?}
392 if [ ${j} -ne 0 ]; then
393 i=`getconf NPROCESSORS_ONLN 2>/dev/null`
394 j=${?}
396 if [ ${j} -ne 0 ]; then
397 # SunOS 5.9 ++
398 if command -v kstat >/dev/null 2>&1; then
399 i=`PERL5OPT= kstat -p cpu | ${awk} '
400 BEGIN{no=0; FS=":"}
401 {if($2 > no) max = $2; next}
402 END{print ++max}
403 ' 2>/dev/null`
404 j=${?}
407 if [ ${j} -eq 0 ] && [ -n "${i}" ]; then
408 printf 'Job number derived from CPU number: %s\n' ${i}
409 MAXJOBS=${i}
412 [ "${MAXJOBS}" -eq 0 ] && MAXJOBS=1
417 jobreaper_start() {
418 case "${JOBMON}" in
419 [yY]*)
420 # There were problems when using monitor mode with mksh
421 i=`env -i ${SHELL} -c 'echo $KSH_VERSION'`
422 if [ -n "${i}" ]; then
423 if [ "${i}" != "${i#*MIRBSD}" ]; then
424 JOBMON=
428 if [ -n "${JOBMON}" ]; then
429 ( set -m ) </dev/null >/dev/null 2>&1 || JOBMON=
430 else
431 printf >&2 '%s! $JOBMON: $SHELL %s incapable, disabled!%s\n' \
432 "${COLOR_ERR_ON}" "${SHELL}" "${COLOR_ERR_OFF}"
433 printf >&2 '%s! No process groups available, killed tests may '\
434 'leave process "zombies"!%s\n' \
435 "${COLOR_ERR_ON}" "${COLOR_ERR_OFF}"
439 JOBMON=
441 esac
444 jobreaper_stop() {
445 if [ ${JOBS} -gt 0 ]; then
446 echo 'Cleaning up running jobs'
447 [ -n "${JOBREAPER}" ] && kill -KILL ${JOBREAPER} >/dev/null 2>&1
448 jtimeout
449 wait ${JOBLIST}
450 JOBLIST=
454 jspawn() {
455 if [ -n "${CHECK}" ] && [ -n "${SKIPTEST}" ]; then
456 i="${@}"
457 j="${1}"
459 set -- ${SKIPTEST}
460 SKIPTEST=
461 while [ ${#} -gt 0 ]; do
462 if [ "${1}" != "${j}" ]; then
463 SKIPTEST="${SKIPTEST} ${1}"
464 elif [ -z "${k}" ]; then
466 t_echoskip ${1}
468 shift
469 done
470 [ -n "${k}" ] && return
471 set -- "${i}"
474 if [ ${MAXJOBS} -gt 1 ]; then
475 # We are spawning multiple jobs..
476 [ ${JOBS} -eq 0 ] && printf '...'
477 JOBS=`add ${JOBS} 1`
478 printf ' [%s=%s]' ${JOBS} "${1}"
479 else
480 JOBS=1
481 # Assume problems exist, do not let user keep hanging on terminal
482 if [ -n "${RUN_TEST}" ]; then
483 printf '... [%s]\n' "${1}"
487 [ -n "${JOBMON}" ] && set -m >/dev/null 2>&1
488 ( # Place the job in its own directory to ease file management
489 trap '' EXIT HUP INT QUIT TERM USR1 USR2
490 ${mkdir} t.${JOBS}.d && cd t.${JOBS}.d &&
491 eval t_${1} ${JOBS} ${1} &&
492 ${rm} -f ../t.${JOBS}.id
493 ) > t.${JOBS}.io </dev/null & # 2>&1 </dev/null &
494 i=${!}
495 [ -n "${JOBMON}" ] && set +m >/dev/null 2>&1
496 JOBLIST="${JOBLIST} ${i}"
497 printf '%s\n%s\n' ${i} ${1} > t.${JOBS}.id
499 # ..until we should sync or reach the maximum concurrent number
500 [ ${JOBS} -lt ${MAXJOBS} ] && return
502 jsync 1
505 jsync() {
506 if [ ${JOBS} -eq 0 ]; then
507 [ -n "${TEST_ANY}" ] && printf '\n'
508 TEST_ANY=
509 return
511 [ -z "${JOBSYNC}" ] && [ ${#} -eq 0 ] && return
513 [ ${MAXJOBS} -ne 1 ] && printf ' .. waiting\n'
515 # Start an asynchronous notify process
516 ${rm} -f ./t.time.out
518 sleep ${JOBWAIT} &
519 sleeper=${!}
520 trap "kill -TERM ${sleeper}; exit 1" HUP INT TERM
521 wait ${sleeper}
522 trap '' HUP INT TERM
523 printf '' > ./t.time.out
524 ) </dev/null >/dev/null 2>&1 &
525 JOBREAPER=${!}
527 # Then loop a while, looking out for collecting tests
528 loops=0
529 while :; do
530 [ -f ./t.time.out ] && break
531 alldone=1
533 while [ ${i} -lt ${JOBS} ]; do
534 i=`add ${i} 1`
535 [ -f t.${i}.id ] || continue
536 alldone=
537 break
538 done
539 [ -n "${alldone}" ] && break
541 if [ -z "${SUBSECOND_SLEEP}" ]; then
542 loops=`add ${loops} 1`
543 [ ${loops} -lt 111 ] && continue
544 sleep 1 &
545 else
546 sleep .25 &
548 wait ${!}
549 done
551 if [ -f ./t.time.out ]; then
552 ${rm} -f ./t.time.out
553 jtimeout
554 else
555 kill -TERM ${JOBREAPER} >/dev/null 2>&1
557 wait ${JOBREAPER}
558 JOBREAPER=
560 # Now collect the zombies
561 wait ${JOBLIST}
562 JOBLIST=
564 # Update global counters
566 while [ ${i} -lt ${JOBS} ]; do
567 i=`add ${i} 1`
569 [ -s t.${i}.io ] && ${cat} t.${i}.io
570 if [ -n "${DUMPERR}" ] && [ -s ./t.${i}.d/${ERR} ]; then
571 printf '%s [Debug/Devel: nullified errors]\n' "${COLOR_ERR_ON}"
572 while read l; do
573 printf ' %s\n' "${l}"
574 done < t.${i}.d/${ERR}
575 printf '%s' "${COLOR_ERR_OFF}"
578 if [ -f t.${i}.id ]; then
579 { read pid; read desc; } < t.${i}.id
580 desc=${desc#${desc%%[! ]*}}
581 desc=${desc%${desc##*[! ]}}
582 [ -s t.${i}.io ] && printf >&2 '\n'
583 printf >&2 '%s!! Timeout: reaped job %s [%s]%s\n' \
584 "${COLOR_ERR_ON}" ${i} "${desc}" "${COLOR_ERR_OFF}"
585 TESTS_FAILED=`add ${TESTS_FAILED} 1`
586 elif [ -s t.${i}.result ]; then
587 read es tp to tf ts < t.${i}.result
588 TESTS_PERFORMED=`add ${TESTS_PERFORMED} ${tp}`
589 TESTS_OK=`add ${TESTS_OK} ${to}`
590 TESTS_FAILED=`add ${TESTS_FAILED} ${tf}`
591 TESTS_SKIPPED=`add ${TESTS_SKIPPED} ${ts}`
592 [ "${es}" != 0 ] && ESTAT=${es}
593 else
594 TESTS_FAILED=`add ${TESTS_FAILED} 1`
595 ESTAT=1
597 done
599 [ -z "${MAILX_CC_TEST_NO_CLEANUP}" ] &&
600 ${rm} -rf ./t.*.d ./t.*.id ./t.*.io t.*.result ./t.time.out
602 JOBS=0
605 jtimeout() {
607 while [ ${i} -lt ${JOBS} ]; do
608 i=`add ${i} 1`
609 if [ -f t.${i}.id ] &&
610 read pid < t.${i}.id >/dev/null 2>&1 &&
611 kill -0 ${pid} >/dev/null 2>&1; then
612 j=${pid}
613 [ -n "${JOBMON}" ] && j=-${j}
614 kill -KILL ${j} >/dev/null 2>&1
615 else
616 ${rm} -f t.${i}.id
618 done
620 # }}}
622 # echoes, checks, etc. {{{
623 t_prolog() {
624 shift
626 ESTAT=0 TESTS_PERFORMED=0 TESTS_OK=0 TESTS_FAILED=0 TESTS_SKIPPED=0 \
627 TEST_NAME=${1} TEST_ANY=
629 printf '%s[%s]%s\n' "" "${TEST_NAME}" ""
632 t_epilog() {
633 [ -n "${TEST_ANY}" ] && printf '\n'
635 printf '%s %s %s %s %s\n' \
636 ${ESTAT} \
637 ${TESTS_PERFORMED} ${TESTS_OK} ${TESTS_FAILED} ${TESTS_SKIPPED} \
638 > ../t.${1}.result
641 t_echo() {
642 [ -n "${TEST_ANY}" ] && __i__=' ' || __i__=
643 printf "${__i__}"'%s' "${*}"
644 TEST_ANY=1
647 t_echook() {
648 [ -n "${TEST_ANY}" ] && __i__=' ' || __i__=
649 printf "${__i__}"'%s%s:ok%s' "${COLOR_OK_ON}" "${*}" "${COLOR_OK_OFF}"
650 TEST_ANY=1
653 t_echoerr() {
654 ESTAT=1
655 t_echo0err "${@}"
658 t_echo0err() {
659 [ -n "${TEST_ANY}" ] && __i__="\n" || __i__=
660 printf "${__i__}"'%sERROR: %s%s\n' \
661 "${COLOR_ERR_ON}" "${*}" "${COLOR_ERR_OFF}"
662 TEST_ANY=
665 t_echowarn() {
666 [ -n "${TEST_ANY}" ] && __i__=' ' || __i__=
667 printf "${__i__}"'%s%s%s' "${COLOR_WARN_ON}" "${*}" "${COLOR_WARN_OFF}"
668 TEST_ANY=1
671 t_echoskip() {
672 [ -n "${TEST_ANY}" ] && __i__=' ' || __i__=
673 printf "${__i__}"'%s%s[skip]%s' \
674 "${COLOR_WARN_ON}" "${*}" "${COLOR_WARN_OFF}"
675 TEST_ANY=1
676 TESTS_SKIPPED=`add ${TESTS_SKIPPED} 1`
679 check() {
680 restat=${?} tid=${1} eestat=${2} f=${3} s=${4} optmode=${5}
682 TESTS_PERFORMED=`add ${TESTS_PERFORMED} 1`
684 case "${optmode}" in
685 '') ;;
686 async)
687 [ "$eestat" = - ] || exit 200
688 while :; do
689 [ -f "${f}" ] && break
690 t_echowarn "[${tid}:async=wait]"
691 sleep 1 &
692 wait ${!}
693 done
695 *) exit 222;;
696 esac
698 check__bad= check__runx=
700 if [ "${eestat}" != - ] && [ "${restat}" != "${eestat}" ]; then
701 ESTAT=1
702 t_echoerr "${tid}: bad-status: ${restat} != ${eestat}"
703 check__bad=1
706 csum="`${cksum} < "${f}" | ${sed} -e 's/[ ]\{1,\}/ /g'`"
707 if [ "${csum}" = "${s}" ]; then
708 t_echook "${tid}"
709 check__runx=${DEVELDIFF}
710 else
711 ESTAT=1
712 t_echoerr "${tid}: checksum mismatch (got ${csum})"
713 check__bad=1 check__runx=1
716 if [ -z "${check__bad}" ]; then
717 TESTS_OK=`add ${TESTS_OK} 1`
718 else
719 TESTS_FAILED=`add ${TESTS_FAILED} 1`
722 if [ -n "${CHECK}${RUN_TEST}" ]; then
723 x="t.${TEST_NAME}-${tid}"
724 if [ -n "${RUN_TEST}" ] ||
725 [ -n "${check__runx}" -a -n "${GIT_REPO}" ]; then
726 ${cp} -f "${f}" ../"${x}"
729 if [ -n "${check__runx}" ] && [ -n "${GIT_REPO}" ] &&
730 command -v diff >/dev/null 2>&1; then
731 y=test-out
732 if (git rev-parse --verify $y) >/dev/null 2>&1; then :; else
733 y=refs/remotes/origin/test-out
734 (git rev-parse --verify $y) >/dev/null 2>&1 || y=
736 if [ -n "${y}" ]; then
737 if GIT_CONFIG=/dev/null git show "${y}":"${x}" > \
738 ../"${x}".old 2>/dev/null; then
739 diff -ru ../"${x}".old ../"${x}" > ../"${x}".diff
740 if [ ${?} -eq 0 ]; then
741 [ -z "${MAILX_CC_TEST_NO_CLEANUP}" ] &&
742 ${rm} -f ../"${x}" ../"${x}".old ../"${x}".diff
743 elif [ -n "${MAILX_CC_ALL_TESTS_DUMPERR}" ]; then
744 while read l; do
745 printf 'ERROR-DIFF %s\n' "${l}"
746 done < ../"${x}".diff
748 else
749 t_echo0err "${tid}: misses [test-out] template"
756 check_ex0() {
757 # $1=test name [$2=status]
758 __qm__=${?}
759 [ ${#} -gt 1 ] && __qm__=${2}
761 TESTS_PERFORMED=`add ${TESTS_PERFORMED} 1`
763 if [ ${__qm__} -ne 0 ]; then
764 ESTAT=1
765 t_echoerr "${1}: unexpected non-0 exit status: ${__qm__}"
766 TESTS_FAILED=`add ${TESTS_FAILED} 1`
767 else
768 t_echook "${1}"
769 TESTS_OK=`add ${TESTS_OK} 1`
773 check_exn0() {
774 # $1=test name [$2=status]
775 __qm__=${?}
776 [ ${#} -gt 1 ] && __qm__=${2}
777 [ ${#} -gt 2 ] && __expect__=${3} || __expect__=
779 TESTS_PERFORMED=`add ${TESTS_PERFORMED} 1`
781 if [ ${__qm__} -eq 0 ]; then
782 ESTAT=1
783 t_echoerr "${1}: unexpected 0 exit status: ${__qm__}"
784 TESTS_FAILED=`add ${TESTS_FAILED} 1`
785 elif [ -n "${__expect__}" ] && [ ${__expect__} -ne ${__qm__} ]; then
786 ESTAT=1
787 t_echoerr "${1}: unexpected exit status: ${__qm__} != ${__expected__}"
788 TESTS_FAILED=`add ${TESTS_FAILED} 1`
789 else
790 t_echook "${1}"
791 TESTS_OK=`add ${TESTS_OK} 1`
794 # }}}
796 color_init() {
797 [ -n "${NOCOLOUR}" ] && return
798 [ -n "${MAILX_CC_TEST_NO_COLOUR}" ] && return
799 # We do not want color for "make test > .LOG"!
800 if command -v stty >/dev/null 2>&1 && command -v tput >/dev/null 2>&1 &&
801 (<&1 >/dev/null stty -a) 2>/dev/null; then
802 { sgr0=`tput sgr0`; } 2>/dev/null
803 [ $? -eq 0 ] || return
804 { saf1=`tput setaf 1`; } 2>/dev/null
805 [ $? -eq 0 ] || return
806 { saf2=`tput setaf 2`; } 2>/dev/null
807 [ $? -eq 0 ] || return
808 { saf3=`tput setaf 3`; } 2>/dev/null
809 [ $? -eq 0 ] || return
810 { b=`tput bold`; } 2>/dev/null
811 [ $? -eq 0 ] || return
813 COLOR_ERR_ON=${saf1}${b} COLOR_ERR_OFF=${sgr0}
814 COLOR_WARN_ON=${saf3}${b} COLOR_WARN_OFF=${sgr0}
815 COLOR_OK_ON=${saf2} COLOR_OK_OFF=${sgr0}
816 unset saf1 saf2 saf3 b
820 if ( [ "$((1 + 1))" = 2 ] ) >/dev/null 2>&1; then
821 add() {
822 echo "$((${1} + ${2}))"
824 else
825 add() {
826 ${awk} 'BEGIN{print '${1}' + '${2}'}'
830 if ( [ "$((2 % 3))" = 2 ] ) >/dev/null 2>&1; then
831 modulo() {
832 echo "$((${1} % ${2}))"
834 else
835 modulo() {
836 ${awk} 'BEGIN{print '${1}' % '${2}'}'
840 have_feat() {
841 ( "${RAWMAILX}" ${ARGS} -X'echo $features' -Xx |
842 ${grep} ,+${1}, ) >/dev/null 2>&1
844 # }}}
846 # Absolute Basics {{{
847 t_X_Y_opt_input_go_stack() {
848 t_prolog "${@}"
850 ${cat} <<- '__EOT' > "${BODY}"
851 echo 1
852 define mac0 {
853 echo mac0-1 via1 $0
855 call mac0
856 echo 2
857 source '\
858 echo "define mac1 {";\
859 echo " echo mac1-1 via1 \$0";\
860 echo " call mac0";\
861 echo " echo mac1-2";\
862 echo " call mac2";\
863 echo " echo mac1-3";\
864 echo "}";\
865 echo "echo 1-1";\
866 echo "define mac2 {";\
867 echo " echo mac2-1 via1 \$0";\
868 echo " call mac0";\
869 echo " echo mac2-2";\
870 echo "}";\
871 echo "echo 1-2";\
872 echo "call mac1";\
873 echo "echo 1-3";\
874 echo "source \"\
875 echo echo 1-1-1 via1 \$0;\
876 echo call mac0;\
877 echo echo 1-1-2;\
878 | \"";\
879 echo "echo 1-4";\
881 echo 3
882 call mac2
883 echo 4
884 undefine *
885 __EOT
887 # The -X option supports multiline arguments, and those can internally use
888 # reverse solidus newline escaping. And all -X options are joined...
889 APO=\'
890 < "${BODY}" ${MAILX} ${ARGS} \
891 -X 'e\' \
892 -X ' c\' \
893 -X ' h\' \
894 -X ' o \' \
895 -X 1 \
897 define mac0 {
898 echo mac0-1 via2 $0
900 call mac0
901 echo 2
904 source '${APO}'\
905 echo "define mac1 {";\
906 echo " echo mac1-1 via2 \$0";\
907 echo " call mac0";\
908 echo " echo mac1-2";\
909 echo " call mac2";\
910 echo " echo mac1-3";\
911 echo "}";\
912 echo "echo 1-1";\
913 echo "define mac2 {";\
914 echo " echo mac2-1 via2 \$0";\
915 echo " call mac0";\
916 echo " echo mac2-2";\
917 echo "}";\
918 echo "echo 1-2";\
919 echo "call mac1";\
920 echo "echo 1-3";\
921 echo "source \"\
922 echo echo 1-1-1 via2 \$0;\
923 echo call mac0;\
924 echo echo 1-1-2;\
925 | \"";\
926 echo "echo 1-4";\
927 | '${APO}'
928 echo 3
931 call mac2
932 echo 4
933 undefine *
934 ' > "${MBOX}"
936 check 1 0 "${MBOX}" '1786542668 416'
938 # The -Y option supports multiline arguments, and those can internally use
939 # reverse solidus newline escaping.
940 APO=\'
941 < "${BODY}" ${MAILX} ${ARGS} \
942 -X 'echo FIRST_X' \
943 -X 'echo SECOND_X' \
944 -Y 'e\' \
945 -Y ' c\' \
946 -Y ' h\' \
947 -Y ' o \' \
948 -Y 1 \
950 define mac0 {
951 echo mac0-1 via2 $0
953 call mac0
954 echo 2
957 source '${APO}'\
958 echo "define mac1 {";\
959 echo " echo mac1-1 via2 \$0";\
960 echo " call mac0";\
961 echo " echo mac1-2";\
962 echo " call mac2";\
963 echo " echo mac1-3";\
964 echo "}";\
965 echo "echo 1-1";\
966 echo "define mac2 {";\
967 echo " echo mac2-1 via2 \$0";\
968 echo " call mac0";\
969 echo " echo mac2-2";\
970 echo "}";\
971 echo "echo 1-2";\
972 echo "call mac1";\
973 echo "echo 1-3";\
974 echo "source \"\
975 echo echo 1-1-1 via2 \$0;\
976 echo call mac0;\
977 echo echo 1-1-2;\
978 | \"";\
979 echo "echo 1-4";\
980 | '${APO}'
981 echo 3
984 call mac2
985 echo 4
986 undefine *
988 -Y 'echo LAST_Y' > "${MBOX}"
990 check 2 0 "${MBOX}" '1845176711 440'
992 # Compose mode, too!
993 </dev/null ${MAILX} ${ARGS} \
994 -X 'echo X before compose mode' \
995 -Y '~s Subject via -Y' \
996 -Y 'Body via -Y' -. ./.tybox > "${MBOX}" 2>&1
997 check 3 0 ./.tybox '264636255 125'
998 check 4 - "${MBOX}" '467429373 22'
1000 ${cat} <<-_EOT | ${MAILX} ${ARGS} -t \
1001 -X 'echo X before compose mode' \
1002 -Y '~s Subject via -Y' \
1003 -Y 'Additional body via -Y' -. ./.tybox > "${MBOX}" 2>&1
1004 from: heya@exam.ple
1005 subject:diet not to be seen!
1007 this body via -t.
1008 _EOT
1009 check 5 0 ./.tybox '3313167452 299'
1010 check 6 - "${MBOX}" '467429373 22'
1013 printf 'this body via stdin pipe.\n' | ${MAILX} ${NOBATCH_ARGS} \
1014 -X 'echo X before compose mode' \
1015 -Y '~s Subject via -Y (not!)' \
1016 -Y 'Additional body via -Y, nobatch mode' -. ./.tybox > "${MBOX}" 2>&1
1017 check 7 0 ./.tybox '1561798488 476'
1018 check 8 - "${MBOX}" '467429373 22'
1020 printf 'this body via stdin pipe.\n' | ${MAILX} ${ARGS} \
1021 -X 'echo X before compose mode' \
1022 -Y '~s Subject via -Y' \
1023 -Y 'Additional body via -Y, batch mode' -. ./.tybox > "${MBOX}" 2>&1
1024 check 9 0 ./.tybox '3245082485 650'
1025 check 10 - "${MBOX}" '467429373 22'
1027 # Test for [8412796a] (n_cmd_arg_parse(): FIX token error -> crash, e.g.
1028 # "-RX 'bind;echo $?' -Xx".., 2018-08-02)
1029 ${MAILX} ${ARGS} -RX'call;echo $?' -Xx > ./.tall 2>&1
1030 ${MAILX} ${ARGS} -RX'call ;echo $?' -Xx >> ./.tall 2>&1
1031 ${MAILX} ${ARGS} -RX'call ;echo $?' -Xx >> ./.tall 2>&1
1032 ${MAILX} ${ARGS} -RX'call ;echo $?' -Xx >> ./.tall 2>&1
1033 check cmdline 0 ./.tall '1867586969 8'
1035 t_epilog "${@}"
1038 t_X_errexit() {
1039 t_prolog "${@}"
1041 if have_feat uistrings; then :; else
1042 t_echoskip '[!UISTRINGS]'
1043 t_epilog "${@}"
1044 return
1047 ${cat} <<- '__EOT' > "${BODY}"
1048 echo one
1049 echos nono
1050 echo two
1051 __EOT
1053 </dev/null ${MAILX} ${ARGS} -Snomemdebug \
1054 -X'echo one' -X' echos nono ' -X'echo two' \
1055 > "${MBOX}" 2>&1
1056 check 1 0 "${MBOX}" '2700500141 51'
1058 </dev/null ${MAILX} ${ARGS} -X'source '"${BODY}" -Snomemdebug \
1059 > "${MBOX}" 2>&1
1060 check 2 0 "${MBOX}" '2700500141 51'
1062 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Snomemdebug \
1063 > "${MBOX}" 2>&1
1064 check 3 0 "${MBOX}" '2700500141 51'
1068 </dev/null ${MAILX} ${ARGS} -Serrexit -Snomemdebug \
1069 -X'echo one' -X' echos nono ' -X'echo two' \
1070 > "${MBOX}" 2>&1
1071 check 4 1 "${MBOX}" '4096689457 47'
1073 </dev/null ${MAILX} ${ARGS} -X'source '"${BODY}" -Serrexit -Snomemdebug \
1074 > "${MBOX}" 2>&1
1075 check 5 1 "${MBOX}" '4096689457 47'
1077 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Serrexit -Snomemdebug \
1078 > "${MBOX}" 2>&1
1079 check 6 1 "${MBOX}" '1669262132 170'
1081 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Sposix -Snomemdebug \
1082 > "${MBOX}" 2>&1
1083 check 7 1 "${MBOX}" '1669262132 170'
1085 ## Repeat 4-7 with ignerr set
1087 ${sed} -e 's/^echos /ignerr echos /' < "${BODY}" > "${MBOX}"
1089 </dev/null ${MAILX} ${ARGS} -Serrexit -Snomemdebug \
1090 -X'echo one' -X'ignerr echos nono ' -X'echo two' \
1091 > "${BODY}" 2>&1
1092 check 8 0 "${BODY}" '2700500141 51'
1094 </dev/null ${MAILX} ${ARGS} -X'source '"${MBOX}" -Serrexit -Snomemdebug \
1095 > "${BODY}" 2>&1
1096 check 9 0 "${BODY}" '2700500141 51'
1098 </dev/null MAILRC="${MBOX}" ${MAILX} ${ARGS} -:u -Serrexit -Snomemdebug \
1099 > "${BODY}" 2>&1
1100 check 10 0 "${BODY}" '2700500141 51'
1102 </dev/null MAILRC="${MBOX}" ${MAILX} ${ARGS} -:u -Sposix -Snomemdebug \
1103 > "${BODY}" 2>&1
1104 check 11 0 "${BODY}" '2700500141 51'
1106 # Ensure "good-injection" in a deeper indirection does not cause trouble
1107 # This actually only works with MLE and HISTORY, and TODO needs a pseudo TTY
1108 # interaction so that we DO initialize our line editor...
1109 ${cat} <<- '__EOT' > "${BODY}"
1110 define oha {
1111 return 0
1113 define x {
1114 eval set $xarg
1115 echoes time
1116 return 0
1118 __EOT
1120 printf 'source %s\ncall x\necho au' "${BODY}" |
1121 ${MAILX} ${ARGS} -Snomemdebug -Sxarg=errexit > "${MBOX}" 2>&1
1122 check 12 1 "${MBOX}" '2908921993 44'
1124 printf 'source %s\nset on-history-addition=oha\ncall x\necho au' "${BODY}" |
1125 ${MAILX} ${ARGS} -Snomemdebug -Sxarg=errexit > "${MBOX}" 2>&1
1126 check 13 1 "${MBOX}" '2908921993 44'
1128 printf 'source %s\ncall x\necho au' "${BODY}" |
1129 ${MAILX} ${ARGS} -Snomemdebug -Sxarg=nowhere > "${MBOX}" 2>&1
1130 check 14 0 "${MBOX}" '2049365617 47'
1132 t_epilog "${@}"
1135 t_Y_errexit() {
1136 t_prolog "${@}"
1138 if have_feat uistrings; then :; else
1139 t_echoskip '[!UISTRINGS]'
1140 t_epilog "${@}"
1141 return
1144 ${cat} <<- '__EOT' > "${BODY}"
1145 echo one
1146 echos nono
1147 echo two
1148 __EOT
1150 </dev/null ${MAILX} ${ARGS} -Snomemdebug \
1151 -Y'echo one' -Y' echos nono ' -Y'echo two' \
1152 > "${MBOX}" 2>&1
1153 check 1 0 "${MBOX}" '2700500141 51'
1155 </dev/null ${MAILX} ${ARGS} -Y'source '"${BODY}" -Snomemdebug \
1156 > "${MBOX}" 2>&1
1157 check 2 0 "${MBOX}" '2700500141 51'
1161 </dev/null ${MAILX} ${ARGS} -Serrexit -Snomemdebug \
1162 -Y'echo one' -Y' echos nono ' -Y'echo two' \
1163 > "${MBOX}" 2>&1
1164 check 3 1 "${MBOX}" '4096689457 47'
1166 </dev/null ${MAILX} ${ARGS} -Y'source '"${BODY}" -Serrexit -Snomemdebug \
1167 > "${MBOX}" 2>&1
1168 check 4 1 "${MBOX}" '4096689457 47'
1170 ## Repeat 3-4 with ignerr set
1172 ${sed} -e 's/^echos /ignerr echos /' < "${BODY}" > "${MBOX}"
1174 </dev/null ${MAILX} ${ARGS} -Serrexit -Snomemdebug \
1175 -Y'echo one' -Y'ignerr echos nono ' -Y'echo two' \
1176 > "${BODY}" 2>&1
1177 check 5 0 "${BODY}" '2700500141 51'
1179 </dev/null ${MAILX} ${ARGS} -Y'source '"${MBOX}" -Serrexit -Snomemdebug \
1180 > "${BODY}" 2>&1
1181 check 6 0 "${BODY}" '2700500141 51'
1183 t_epilog "${@}"
1186 t_S_freeze() {
1187 t_prolog "${@}"
1188 oterm=$TERM
1189 unset TERM
1191 # Test basic assumption
1192 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} \
1193 -X'echo asksub<$asksub> dietcurd<$dietcurd>' \
1194 -Xx > "${MBOX}" 2>&1
1195 check 1 0 "${MBOX}" '270686329 21'
1198 ${cat} <<- '__EOT' > "${BODY}"
1199 echo asksub<$asksub>
1200 set asksub
1201 echo asksub<$asksub>
1202 __EOT
1203 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
1204 -Snoasksub -Sasksub -Snoasksub \
1205 -X'echo asksub<$asksub>' -X'set asksub' -X'echo asksub<$asksub>' \
1206 -Xx > "${MBOX}" 2>&1
1207 check 2 0 "${MBOX}" '3182942628 37'
1209 ${cat} <<- '__EOT' > "${BODY}"
1210 echo asksub<$asksub>
1211 unset asksub
1212 echo asksub<$asksub>
1213 __EOT
1214 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
1215 -Snoasksub -Sasksub \
1216 -X'echo asksub<$asksub>' -X'unset asksub' -X'echo asksub<$asksub>' \
1217 -Xx > "${MBOX}" 2>&1
1218 check 3 0 "${MBOX}" '2006554293 39'
1221 ${cat} <<- '__EOT' > "${BODY}"
1222 echo dietcurd<$dietcurd>
1223 set dietcurd=cherry
1224 echo dietcurd<$dietcurd>
1225 __EOT
1226 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
1227 -Sdietcurd=strawberry -Snodietcurd -Sdietcurd=vanilla \
1228 -X'echo dietcurd<$dietcurd>' -X'unset dietcurd' \
1229 -X'echo dietcurd<$dietcurd>' \
1230 -Xx > "${MBOX}" 2>&1
1231 check 4 0 "${MBOX}" '1985768109 65'
1233 ${cat} <<- '__EOT' > "${BODY}"
1234 echo dietcurd<$dietcurd>
1235 unset dietcurd
1236 echo dietcurd<$dietcurd>
1237 __EOT
1238 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
1239 -Sdietcurd=strawberry -Snodietcurd \
1240 -X'echo dietcurd<$dietcurd>' -X'set dietcurd=vanilla' \
1241 -X'echo dietcurd<$dietcurd>' \
1242 -Xx > "${MBOX}" 2>&1
1243 check 5 0 "${MBOX}" '151574279 51'
1245 # TODO once we have a detached one with env=1..
1246 if [ -n "`</dev/null ${MAILX} ${ARGS} -X'!echo \$TERM' -Xx`" ]; then
1247 t_echoskip 's_freeze-{6,7}:[shell sets $TERM]'
1248 else
1249 ${cat} <<- '__EOT' > "${BODY}"
1250 !echo "shell says TERM<$TERM>"
1251 echo TERM<$TERM>
1252 !echo "shell says TERM<$TERM>"
1253 set TERM=cherry
1254 !echo "shell says TERM<$TERM>"
1255 echo TERM<$TERM>
1256 !echo "shell says TERM<$TERM>"
1257 __EOT
1258 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
1259 -STERM=strawberry -SnoTERM -STERM=vanilla \
1260 -X'echo mail<$TERM>' -X'unset TERM' \
1261 -X'!echo "shell says TERM<$TERM>"' -X'echo TERM<$TERM>' \
1262 -Xx > "${MBOX}" 2>&1
1263 check 6 0 "${MBOX}" '1211476036 167'
1265 ${cat} <<- '__EOT' > "${BODY}"
1266 !echo "shell says TERM<$TERM>"
1267 echo TERM<$TERM>
1268 !echo "shell says TERM<$TERM>"
1269 set TERM=cherry
1270 !echo "shell says TERM<$TERM>"
1271 echo TERM<$TERM>
1272 !echo "shell says TERM<$TERM>"
1273 __EOT
1274 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
1275 -STERM=strawberry -SnoTERM \
1276 -X'echo TERM<$TERM>' -X'set TERM=vanilla' \
1277 -X'!echo "shell says TERM<$TERM>"' -X'echo TERM<$TERM>' \
1278 -Xx > "${MBOX}" 2>&1
1279 check 7 0 "${MBOX}" '3365080441 132'
1282 TERM=$oterm
1283 t_epilog "${@}"
1286 t_f_batch_order() {
1287 t_prolog "${@}"
1289 t__gen_msg subject f-batch-order > "${MBOX}"
1291 # This would exit 64 (EX_USAGE) from ? to [fbddb3b3] (FIX: -f: add
1292 # n_PO_f_FLAG to avoid that command line order matters)
1293 </dev/null ${MAILX} ${NOBATCH_ARGS} -R -f -# \
1294 -Y 'echo du;h;echo da;x' "${MBOX}" >./.tall 2>&1
1295 check 1 0 ./.tall '1690247457 86'
1297 # And this ever worked (hopefully)
1298 </dev/null ${MAILX} ${NOBATCH_ARGS} -R -# -f \
1299 -Y 'echo du;h;echo da;x' "${MBOX}" >./.tall 2>&1
1300 check 2 0 ./.tall '1690247457 86'
1302 t_epilog "${@}"
1305 t_input_inject_semicolon_seq() {
1306 t_prolog "${@}"
1308 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
1309 define mydeepmac {
1310 echon '(mydeepmac)';
1312 define mymac {
1313 echon this_is_mymac;call mydeepmac;echon ';';
1315 echon one';';call mymac;echon two";";call mymac;echo three$';';
1316 define mymac {
1317 echon this_is_mymac;call mydeepmac;echon ,TOO'!;';
1319 echon one';';call mymac;echon two";";call mymac;echo three$';';
1320 __EOT
1322 check 1 0 "${MBOX}" '512117110 140'
1324 t_epilog "${@}"
1327 t_wysh() {
1328 t_prolog "${@}"
1330 ${cat} <<- '__EOT' > "${BODY}"
1332 echo abcd
1333 echo a'b'c'd'
1334 echo a"b"c"d"
1335 echo a$'b'c$'d'
1336 echo 'abcd'
1337 echo "abcd"
1338 echo $'abcd'
1339 echo a\ b\ c\ d
1340 echo a 'b c' d
1341 echo a "b c" d
1342 echo a $'b c' d
1344 echo 'a$`"\'
1345 echo "a\$\`'\"\\"
1346 echo $'a\$`\'\"\\'
1347 echo $'a\$`\'"\\'
1348 # DIET=CURD TIED=
1349 echo 'a${DIET}b${TIED}c\${DIET}d\${TIED}e' # COMMENT
1350 echo "a${DIET}b${TIED}c\${DIET}d\${TIED}e"
1351 echo $'a${DIET}b${TIED}c\${DIET}d\${TIED}e'
1353 echo a$'\101\0101\x41\u0041\u41\U00000041\U41'c
1354 echo a$'\u0041\u41\u0C1\U00000041\U41'c
1355 echo a$'\377'c
1356 echo a$'\0377'c
1357 echo a$'\400'c
1358 echo a$'\0400'c
1359 echo a$'\U1100001'c
1361 echo a$'b\0c'd
1362 echo a$'b\00c'de
1363 echo a$'b\000c'df
1364 echo a$'b\0000c'dg
1365 echo a$'b\x0c'dh
1366 echo a$'b\x00c'di
1367 echo a$'b\u0'dj
1368 echo a$'b\u00'dk
1369 echo a$'b\u000'dl
1370 echo a$'b\u0000'dm
1371 echo a$'b\U0'dn
1372 echo a$'b\U00'do
1373 echo a$'b\U000'dp
1374 echo a$'b\U0000'dq
1375 echo a$'b\U00000'dr
1376 echo a$'b\U000000'ds
1377 echo a$'b\U0000000'dt
1378 echo a$'b\U00000000'du
1380 echo a$'\cI'b
1381 echo a$'\011'b
1382 echo a$'\x9'b
1383 echo a$'\u9'b
1384 echo a$'\U9'b
1385 echo a$'\c@'b c d
1386 __EOT
1388 if [ -z "${UTF8_LOCALE}" ]; then
1389 t_echoskip 'wysh-unicode:[no UTF-8 locale]'
1390 else
1391 < "${BODY}" DIET=CURD TIED= \
1392 LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} > "${MBOX}" 2>>${ERR}
1393 check unicode 0 "${MBOX}" '475805847 317'
1396 < "${BODY}" DIET=CURD TIED= ${MAILX} ${ARGS} > "${MBOX}" 2>>${ERR}
1397 check c 0 "${MBOX}" '1473887148 321'
1399 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
1400 wysh set mager='\hey\'
1401 varshow mager
1402 wysh set mager="\hey\\"
1403 varshow mager
1404 wysh set mager=$'\hey\\'
1405 varshow mager
1406 __EOT
1407 check 3 0 "${MBOX}" '1289698238 69'
1409 t_epilog "${@}"
1412 t_commandalias() {
1413 t_prolog "${@}"
1415 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
1416 commandalias echo echo hoho
1417 echo stop.
1418 commandalias X Xx
1419 commandalias Xx XxX
1420 commandalias XxX XxXx
1421 commandalias XxXx XxXxX
1422 commandalias XxXxX XxXxXx
1423 commandalias XxXxXx echo huhu
1424 commandalias XxXxXxX echo huhu
1426 commandalias XxXxXx XxXxXxX
1428 uncommandalias echo
1429 commandalias XxXxXx echo huhu
1431 __EOT
1433 check 1 0 "${MBOX}" '1638809585 36'
1435 t_epilog "${@}"
1438 t_posix_abbrev() {
1439 t_prolog "${@}"
1441 # In POSIX C181 standard order
1442 </dev/null ${MAILX} ${ARGS} \
1443 -Y 'echon alias/a\ ; ? a; echon group/g\ ; ?g' \
1444 -Y 'echon alternates/alt\ ; ? alt' \
1445 -Y 'echon chdir/ch\ ; ? ch' \
1446 -Y 'echon copy/c\ ; ? c; echon Copy/C\ ; ?C' \
1447 -Y 'echon delete/d\ ; ? d' \
1448 -Y 'echon discard/di\ ; ? di; echon ignore/ig\ ; ?ig' \
1449 -Y 'echon echo/ec\ ; ? ec' \
1450 -Y 'echon edit/e\ ; ? e' \
1451 -Y 'echon exit/ex\ ; ? ex; echon xit/x\ ; ?x' \
1452 -Y 'echon file/fi\ ; ? fi; echon folder/fold\ ; ? fold' \
1453 -Y 'echon followup/fo\ ; ? fo; echon Followup/F\ ; ?F' \
1454 -Y 'echon from/f\ ; ? f' \
1455 -Y 'echon headers/h\ ; ? h' \
1456 -Y 'echon help/hel\ ; ? hel' \
1457 -Y 'echon hold/ho\ ; ? ho; echon preserve/pre\ ; ? pre' \
1458 -Y 'echon if/i\ ; ? i; echon else/el\ ; ? el; echon endif/en\ ; ? en' \
1459 -Y 'echon list/l\ ; ? l' \
1460 -Y 'echon mail/m\ ; ? m' \
1461 -Y 'echon mbox/mb\ ; ? mb' \
1462 -Y 'echon next/n\ ; ? n' \
1463 -Y 'echon pipe/pi\ ; ? pi' \
1464 -Y 'echon Print/P\ ; ? P; echon Type/T\ ; ? T' \
1465 -Y 'echon print/p\ ; ? p; echon type/t\ ; ? t' \
1466 -Y 'echon quit/q\ ; ? q' \
1467 -Y 'echon Reply/R\ ; ? R' \
1468 -Y 'echon reply/r\ ; ? r' \
1469 -Y 'echon retain/ret\ ; ? ret' \
1470 -Y 'echon save/s\ ; ? s; echon Save/S\ ; ? S' \
1471 -Y 'echon set/se\ ; ? se' \
1472 -Y 'echon shell/sh\ ; ? sh' \
1473 -Y 'echon size/si\ ; ? si' \
1474 -Y 'echon source/so\ ; ? so' \
1475 -Y 'echon touch/tou\ ; ? tou' \
1476 -Y 'echon unalias/una\ ; ? una' \
1477 -Y 'echon undelete/u\ ; ? u' \
1478 -Y 'echon unset/uns\ ; ? uns' \
1479 -Y 'echon visual/v\ ; ? v' \
1480 -Y 'echon write/w\ ; ? w' \
1481 | ${sed} -e 's/:.*$//' > "${MBOX}"
1482 check 1 0 "${MBOX}" '1012680481 968'
1484 t_epilog "${@}"
1486 # }}}
1488 # Basics {{{
1489 t_shcodec() {
1490 t_prolog "${@}"
1492 # XXX the first needs to be checked, it is quite dumb as such
1493 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
1494 commandalias x echo '$?/$^ERRNAME'
1495 shcodec e abcd
1497 shcodec d abcd
1499 shcodec e a'b'c'd'
1501 shcodec d a'b'c'd'
1503 shcodec e a"b"c"d"
1505 shcodec d a"b"c"d"
1507 shcodec e a$'b'c$'d'
1509 shcodec d a$'b'c$'d'
1511 shcodec e 'abcd'
1513 shcodec d 'abcd'
1515 shcodec e "abcd"
1517 shcodec d "abcd"
1519 shcodec e $'abcd'
1521 shcodec d $'abcd'
1523 # same but with vput
1524 commandalias y echo '$?/$^ERRNAME $res'
1525 vput shcodec res e abcd
1527 eval shcodec d $res
1529 vput shcodec res d abcd
1531 eval shcodec d $res
1533 vput shcodec res e a'b'c'd'
1535 eval shcodec d $res
1537 vput shcodec res d a'b'c'd'
1539 eval shcodec d $res
1541 vput shcodec res e a"b"c"d"
1543 eval shcodec d $res
1545 vput shcodec res d a"b"c"d"
1547 eval shcodec d $res
1549 vput shcodec res e a$'b'c$'d'
1551 eval shcodec d $res
1553 vput shcodec res d a$'b'c$'d'
1555 eval shcodec d $res
1557 vput shcodec res e 'abcd'
1559 eval shcodec d $res
1561 vput shcodec res d 'abcd'
1563 eval shcodec d $res
1565 vput shcodec res e "abcd"
1567 eval shcodec d $res
1569 vput shcodec res d "abcd"
1571 eval shcodec d $res
1573 vput shcodec res e $'abcd'
1575 eval shcodec d $res
1577 vput shcodec res d $'abcd'
1579 eval shcodec d $res
1582 vput shcodec res e a b\ c d
1584 eval shcodec d $res
1586 vput shcodec res d a b\ c d
1588 vput shcodec res e ab cd
1590 eval shcodec d $res
1592 vput shcodec res d 'ab cd'
1594 vput shcodec res e a 'b c' d
1596 eval shcodec d $res
1598 vput shcodec res d a 'b c' d
1600 vput shcodec res e a "b c" d
1602 eval shcodec d $res
1604 vput shcodec res d a "b c" d
1606 vput shcodec res e a $'b c' d
1608 eval shcodec d $res
1610 vput shcodec res d a $'b c' d
1613 vput shcodec res e 'a$`"\'
1615 eval shcodec d $res
1617 vput shcodec res d 'a$`"\'
1619 vput shcodec res e "a\$\`'\"\\"
1621 eval shcodec d $res
1623 vput shcodec res d "a\$\`'\"\\"
1625 vput shcodec res e $'a\$`\'\"\\'
1627 eval shcodec d $res
1629 vput shcodec res d $'a\$`\'\"\\'
1631 vput shcodec res e $'a\$`\'"\\'
1633 eval shcodec d $res
1635 vput shcodec res d $'a\$`\'"\\'
1638 set diet=curd
1639 vput shcodec res e a${diet}c
1641 eval shcodec d $res
1643 eval vput shcodec res e a${diet}c
1645 eval shcodec d $res
1647 vput shcodec res e "a${diet}c"
1649 eval shcodec d $res
1651 eval vput shcodec res e "a${diet}c"
1653 eval shcodec d $res
1655 __EOT
1656 check 1 0 "${MBOX}" '3316745312 1241'
1658 if [ -z "${UTF8_LOCALE}" ]; then
1659 t_echoskip 'unicode:[no UTF-8 locale]'
1660 elif have_feat multibyte-charsets; then
1661 ${cat} <<- '__EOT' | LC_ALL=${UTF8_LOCALE} \
1662 ${MAILX} ${ARGS} > "${MBOX}" 2>>${ERR}
1664 shcodec e täst
1665 shcodec +e täst
1666 shcodec d $'t\u00E4st'
1667 shcodec e aՍc
1668 shcodec +e aՍc
1669 shcodec d $'a\u054Dc'
1670 shcodec e a𝕂c
1671 shcodec +e a𝕂c
1672 shcodec d $'a\U0001D542c'
1673 __EOT
1674 check unicode 0 "${MBOX}" '1175985867 77'
1675 else
1676 t_echoskip 'unicode:[!MULTIBYTE-CHARSETS]'
1679 t_epilog "${@}"
1682 t_ifelse() {
1683 t_prolog "${@}"
1685 # v15compat: old and new tests share the same result files!
1686 # v15compat: i.e., just throw away -old tests one day
1688 # Nestable conditions test
1689 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
1690 if 0
1691 echo 1.err
1692 else
1693 echo 1.ok
1694 endif
1695 if 1
1696 echo 2.ok
1697 else
1698 echo 2.err
1699 endif
1700 if $dietcurd
1701 echo 3.err
1702 else
1703 echo 3.ok
1704 endif
1705 set dietcurd=yoho
1706 if $dietcurd
1707 echo 4.ok
1708 else
1709 echo 4.err
1710 endif
1711 if $dietcurd == 'yoho'
1712 echo 5.ok
1713 else
1714 echo 5.err
1715 endif
1716 if $dietcurd ==? 'Yoho'
1717 echo 5-1.ok
1718 else
1719 echo 5-1.err
1720 endif
1721 if $dietcurd == 'Yoho'
1722 echo 5-2.err
1723 else
1724 echo 5-2.ok
1725 endif
1726 if $dietcurd != 'yoho'
1727 echo 6.err
1728 else
1729 echo 6.ok
1730 endif
1731 if $dietcurd !=?case 'Yoho'
1732 echo 6-1.err
1733 else
1734 echo 6-1.ok
1735 endif
1736 if $dietcurd != 'Yoho'
1737 echo 6-2.ok
1738 else
1739 echo 6-2.err
1740 endif
1741 # Nesting
1742 if faLse
1743 echo 7.err1
1744 if tRue
1745 echo 7.err2
1746 if yEs
1747 echo 7.err3
1748 else
1749 echo 7.err4
1750 endif
1751 echo 7.err5
1752 endif
1753 echo 7.err6
1754 else
1755 echo 7.ok7
1756 if YeS
1757 echo 7.ok8
1758 if No
1759 echo 7.err9
1760 else
1761 echo 7.ok9
1762 endif
1763 echo 7.ok10
1764 else
1765 echo 7.err11
1766 if yeS
1767 echo 7.err12
1768 else
1769 echo 7.err13
1770 endif
1771 endif
1772 echo 7.ok14
1773 endif
1774 if r
1775 echo 8.ok1
1776 if R
1777 echo 8.ok2
1778 else
1779 echo 8.err2
1780 endif
1781 echo 8.ok3
1782 else
1783 echo 8.err1
1784 endif
1785 if s
1786 echo 9.err1
1787 else
1788 echo 9.ok1
1789 if S
1790 echo 9.err2
1791 else
1792 echo 9.ok2
1793 endif
1794 echo 9.ok3
1795 endif
1796 # `elif'
1797 if $dietcurd == 'yohu'
1798 echo 10.err1
1799 elif $dietcurd == 'yoha'
1800 echo 10.err2
1801 elif $dietcurd == 'yohe'
1802 echo 10.err3
1803 elif $dietcurd == 'yoho'
1804 echo 10.ok1
1805 if $dietcurd == 'yohu'
1806 echo 10.err4
1807 elif $dietcurd == 'yoha'
1808 echo 10.err5
1809 elif $dietcurd == 'yohe'
1810 echo 10.err6
1811 elif $dietcurd == 'yoho'
1812 echo 10.ok2
1813 if $dietcurd == 'yohu'
1814 echo 10.err7
1815 elif $dietcurd == 'yoha'
1816 echo 10.err8
1817 elif $dietcurd == 'yohe'
1818 echo 10.err9
1819 elif $dietcurd == 'yoho'
1820 echo 10.ok3
1821 else
1822 echo 10.err10
1823 endif
1824 else
1825 echo 10.err11
1826 endif
1827 else
1828 echo 10.err12
1829 endif
1830 # integer
1831 set dietcurd=10
1832 if $dietcurd -lt 11
1833 echo 11.ok1
1834 if $dietcurd -gt 9
1835 echo 11.ok2
1836 else
1837 echo 11.err2
1838 endif
1839 if $dietcurd -eq 10
1840 echo 11.ok3
1841 else
1842 echo 11.err3
1843 endif
1844 if $dietcurd -ge 10
1845 echo 11.ok4
1846 else
1847 echo 11.err4
1848 endif
1849 if $dietcurd -le 10
1850 echo 11.ok5
1851 else
1852 echo 11.err5
1853 endif
1854 if $dietcurd -ge 11
1855 echo 11.err6
1856 else
1857 echo 11.ok6
1858 endif
1859 if $dietcurd -le 9
1860 echo 11.err7
1861 else
1862 echo 11.ok7
1863 endif
1864 else
1865 echo 11.err1
1866 endif
1867 set dietcurd=Abc
1868 if $dietcurd < aBd
1869 echo 12.ok1
1870 if $dietcurd >? abB
1871 echo 12.ok2
1872 else
1873 echo 12.err2
1874 endif
1875 if $dietcurd ==?case aBC
1876 echo 12.ok3
1877 else
1878 echo 12.err3
1879 endif
1880 if $dietcurd >=?ca AbC
1881 echo 12.ok4
1882 else
1883 echo 12.err4
1884 endif
1885 if $dietcurd <=? ABc
1886 echo 12.ok5
1887 else
1888 echo 12.err5
1889 endif
1890 if $dietcurd >=?case abd
1891 echo 12.err6
1892 else
1893 echo 12.ok6
1894 endif
1895 if $dietcurd <=? abb
1896 echo 12.err7
1897 else
1898 echo 12.ok7
1899 endif
1900 else
1901 echo 12.err1
1902 endif
1903 if $dietcurd < aBc
1904 echo 12-1.ok
1905 else
1906 echo 12-1.err
1907 endif
1908 if $dietcurd <? aBc
1909 echo 12-2.err
1910 else
1911 echo 12-2.ok
1912 endif
1913 if $dietcurd > ABc
1914 echo 12-3.ok
1915 else
1916 echo 12-3.err
1917 endif
1918 if $dietcurd >? ABc
1919 echo 12-3.err
1920 else
1921 echo 12-3.ok
1922 endif
1923 if $dietcurd =%?case aB
1924 echo 13.ok
1925 else
1926 echo 13.err
1927 endif
1928 if $dietcurd =% aB
1929 echo 13-1.err
1930 else
1931 echo 13-1.ok
1932 endif
1933 if $dietcurd =%? bC
1934 echo 14.ok
1935 else
1936 echo 14.err
1937 endif
1938 if $dietcurd !% aB
1939 echo 15-1.ok
1940 else
1941 echo 15-1.err
1942 endif
1943 if $dietcurd !%? aB
1944 echo 15-2.err
1945 else
1946 echo 15-2.ok
1947 endif
1948 if $dietcurd !% bC
1949 echo 15-3.ok
1950 else
1951 echo 15-3.err
1952 endif
1953 if $dietcurd !%? bC
1954 echo 15-4.err
1955 else
1956 echo 15-4.ok
1957 endif
1958 if $dietcurd =% Cd
1959 echo 16.err
1960 else
1961 echo 16.ok
1962 endif
1963 if $dietcurd !% Cd
1964 echo 17.ok
1965 else
1966 echo 17.err
1967 endif
1968 set diet=abc curd=abc
1969 if $diet == $curd
1970 echo 18.ok
1971 else
1972 echo 18.err
1973 endif
1974 set diet=abc curd=abcd
1975 if $diet != $curd
1976 echo 19.ok
1977 else
1978 echo 19.err
1979 endif
1980 # 1. Shitty grouping capabilities as of today
1981 unset diet curd ndefined
1982 if [ [ false ] || [ false ] || [ true ] ] && \
1983 [ [ false ] || [ true ] ] && \
1984 [ yes ]
1985 echo 20.ok
1986 else
1987 echo 20.err
1988 endif
1989 if [ [ [ [ 0 ] || [ 1 ] ] && [ [ 1 ] || [ 0 ] ] ] && [ 1 ] ] && [ yes ]
1990 echo 21.ok
1991 else
1992 echo 21.err
1993 endif
1994 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] ]
1995 echo 22.ok
1996 else
1997 echo 22.err
1998 endif
1999 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] ]
2000 echo 23.ok
2001 else
2002 echo 23.err
2003 endif
2004 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] && [ no ]
2005 echo 24.err
2006 else
2007 echo 24.ok
2008 endif
2009 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] \
2010 && [ no ] || [ yes ]
2011 echo 25.ok
2012 else
2013 echo 25.err
2014 endif
2015 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
2016 echo 26.ok
2017 else
2018 echo 26.err
2019 endif
2020 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 0 ] ]
2021 echo 27.err
2022 else
2023 echo 27.ok
2024 endif
2025 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 0 ] ] && [ 1 ] ] ] && [ 1 ] ]
2026 echo 28.err
2027 else
2028 echo 28.ok
2029 endif
2030 if [ [ [ [ [ [ [ 0 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
2031 echo 29.err
2032 else
2033 echo 29.ok
2034 endif
2035 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 0 ]
2036 echo 30.err
2037 else
2038 echo 30.ok
2039 endif
2040 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 1 ]
2041 echo 31.ok
2042 else
2043 echo 31.err
2044 endif
2045 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ]
2046 echo 32.err
2047 else
2048 echo 32.ok
2049 endif
2050 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 1 ]
2051 echo 33.ok
2052 else
2053 echo 33.err
2054 endif
2055 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 0 ]
2056 echo 34.err
2057 else
2058 echo 34.ok
2059 endif
2060 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 1 ]
2061 echo 35.ok
2062 else
2063 echo 35.err
2064 endif
2065 set diet=yo curd=ho
2066 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
2067 echo 36.err
2068 else
2069 echo 36.ok
2070 endif
2071 set ndefined
2072 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
2073 echo 37.ok
2074 else
2075 echo 37.err
2076 endif
2077 # 2. Shitty grouping capabilities as of today
2078 unset diet curd ndefined
2079 if [ false || false || true ] && [ false || true ] && yes
2080 echo 40.ok
2081 else
2082 echo 40.err
2083 endif
2084 if [ [ [ 0 || 1 ] && [ 1 || 0 ] ] && 1 ] && [ yes ]
2085 echo 41.ok
2086 else
2087 echo 41.err
2088 endif
2089 if [ 1 || 0 || 0 || 0 ]
2090 echo 42.ok
2091 else
2092 echo 42.err
2093 endif
2094 if [ 1 || 0 || 0 || 0 || [ 1 ] ]
2095 echo 43.ok
2096 else
2097 echo 43.err
2098 endif
2099 if [ 1 || 0 || 0 || 0 || [ 1 ] || 1 ] && no
2100 echo 44.err
2101 else
2102 echo 44.ok
2103 endif
2104 if [ 1 || 0 || 0 || 0 || 1 || [ 1 ] ] && no || [ yes ]
2105 echo 45.ok
2106 else
2107 echo 45.err
2108 endif
2109 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && 1 ] ] && [ 1 ] ]
2110 echo 46.ok
2111 else
2112 echo 46.err
2113 endif
2114 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && [ 1 ] ] ] && 0 ]
2115 echo 47.err
2116 else
2117 echo 47.ok
2118 endif
2119 if [ [ [ [ [ [ [ 1 ] ] && 1 ] && 0 ] && [ 1 ] ] ] && 1 ]
2120 echo 48.err
2121 else
2122 echo 48.ok
2123 endif
2124 if [ [ [ [ [ [ 0 ] && 1 ] && 1 ] && 1 ] ] && 1 ]
2125 echo 49.err
2126 else
2127 echo 49.ok
2128 endif
2129 if 1 || 0 || 0 || 0 && 0
2130 echo 50.err
2131 else
2132 echo 50.ok
2133 endif
2134 if 1 || 0 || 0 || 0 && 1
2135 echo 51.ok
2136 else
2137 echo 51.err
2138 endif
2139 if 0 || 0 || 0 || 1 && 0
2140 echo 52.err
2141 else
2142 echo 52.ok
2143 endif
2144 if 0 || 0 || 0 || 1 && 1
2145 echo 53.ok
2146 else
2147 echo 53.err
2148 endif
2149 if 0 || 0 || 0 || 1 && 0 || 1 && 0
2150 echo 54.err
2151 else
2152 echo 54.ok
2153 endif
2154 if 0 || 0 || 0 || 1 && 0 || 1 && 1
2155 echo 55.ok
2156 else
2157 echo 55.err
2158 endif
2159 set diet=yo curd=ho
2160 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
2161 echo 56.err
2162 else
2163 echo 56.ok
2164 endif
2165 if $diet == 'yo' && $curd == 'ho' && $ndefined
2166 echo 57.err
2167 else
2168 echo 57.ok
2169 endif
2170 set ndefined
2171 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
2172 echo 57.ok
2173 else
2174 echo 57.err
2175 endif
2176 if $diet == 'yo' && $curd == 'ho' && $ndefined
2177 echo 58.ok
2178 else
2179 echo 58.err
2180 endif
2181 if [ [ [ [ [ [ $diet == 'yo' && $curd == 'ho' && $ndefined ] ] ] ] ] ]
2182 echo 59.ok
2183 else
2184 echo 59.err
2185 endif
2186 # Some more en-braced variables
2187 set diet=yo curd=ho
2188 if ${diet} == ${curd}
2189 echo 70.err
2190 else
2191 echo 70.ok
2192 endif
2193 if ${diet} != ${curd}
2194 echo 71.ok
2195 else
2196 echo 71.err
2197 endif
2198 if $diet == ${curd}
2199 echo 72.err
2200 else
2201 echo 72.ok
2202 endif
2203 if ${diet} == $curd
2204 echo 73.err
2205 else
2206 echo 73.ok
2207 endif
2208 # Unary !
2209 if ! 0 && ! ! 1 && ! ! ! ! 2 && 3
2210 echo 80.ok
2211 else
2212 echo 80.err
2213 endif
2214 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ ! 2 ] ] ] && 3
2215 echo 81.ok
2216 else
2217 echo 81.err
2218 endif
2219 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
2220 echo 82.ok
2221 else
2222 echo 82.err
2223 endif
2224 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
2225 echo 83.err
2226 else
2227 echo 83.ok
2228 endif
2229 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
2230 echo 84.err
2231 else
2232 echo 84.ok
2233 endif
2234 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
2235 echo 85.err
2236 else
2237 echo 85.ok
2238 endif
2239 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
2240 echo 86.err
2241 else
2242 echo 86.ok
2243 endif
2244 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] || 3
2245 echo 87.ok
2246 else
2247 echo 87.err
2248 endif
2249 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! ! [ 2 ] ] ] ] ]
2250 echo 88.ok
2251 else
2252 echo 88.err
2253 endif
2254 # Unary !, odd
2255 if ! 0 && ! ! 1 && ! ! ! 0 && 3
2256 echo 90.ok
2257 else
2258 echo 90.err
2259 endif
2260 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ 0 ] ] ] && 3
2261 echo 91.ok
2262 else
2263 echo 91.err
2264 endif
2265 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ [ 0 ] ] ] ] ] && 3
2266 echo 92.ok
2267 else
2268 echo 92.err
2269 endif
2270 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! ! [ ! [ ! 0 ] ] ] ] && ! 3
2271 echo 93.err
2272 else
2273 echo 93.ok
2274 endif
2275 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ ! [ ! [ ! [ ! 0 ] ] ] ] && 3
2276 echo 94.ok
2277 else
2278 echo 94.err
2279 endif
2280 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! ! [ ! [ ! [ ! [ 0 ] ] ] ] ] && 3
2281 echo 95.err
2282 else
2283 echo 95.ok
2284 endif
2285 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! ! 0 ] ] ] ] && 3
2286 echo 96.err
2287 else
2288 echo 96.ok
2289 endif
2290 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ ! 0 ] ] ] ] ] || 3
2291 echo 97.ok
2292 else
2293 echo 97.err
2294 endif
2295 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! [ 0 ] ] ] ] ]
2296 echo 98.ok
2297 else
2298 echo 98.err
2299 endif
2300 __EOT
2302 check normal-old 0 "${MBOX}" '1688759742 719' # pre v15compat
2304 if have_feat regex; then
2305 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
2306 set dietcurd=yoho
2307 if $dietcurd =~ '^yo.*'
2308 echo 1.ok
2309 else
2310 echo 1.err
2311 endif
2312 if $dietcurd =~ '^Yo.*'
2313 echo 1-1.err
2314 else
2315 echo 1-1.ok
2316 endif
2317 if $dietcurd =~?case '^Yo.*'
2318 echo 1-2.ok
2319 else
2320 echo 1-2.err
2321 endif
2322 if $dietcurd =~ '^yOho.+'
2323 echo 2.err
2324 else
2325 echo 2.ok
2326 endif
2327 if $dietcurd !~? '.*Ho$'
2328 echo 3.err
2329 else
2330 echo 3.ok
2331 endif
2332 if $dietcurd !~ '.+yohO$'
2333 echo 4.ok
2334 else
2335 echo 4.err
2336 endif
2337 if [ $dietcurd !~?cas '.+yoho$' ]
2338 echo 5.ok
2339 else
2340 echo 5.err
2341 endif
2342 if ! [ $dietcurd =~?case '.+yoho$' ]
2343 echo 6.ok
2344 else
2345 echo 6.err
2346 endif
2347 if ! ! [ $dietcurd !~? '.+yoho$' ]
2348 echo 7.ok
2349 else
2350 echo 7.err
2351 endif
2352 if ! [ ! [ $dietcurd !~? '.+yoho$' ] ]
2353 echo 8.ok
2354 else
2355 echo 8.err
2356 endif
2357 if [ ! [ ! [ $dietcurd !~? '.+yoho$' ] ] ]
2358 echo 9.ok
2359 else
2360 echo 9.err
2361 endif
2362 if ! [ ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
2363 echo 10.err
2364 else
2365 echo 10.ok
2366 endif
2367 if ! ! ! $dietcurd !~ '.+yoho$'
2368 echo 11.err
2369 else
2370 echo 11.ok
2371 endif
2372 if ! ! ! $dietcurd =~ '.+yoho$'
2373 echo 12.ok
2374 else
2375 echo 12.err
2376 endif
2377 if ! [ ! ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
2378 echo 13.ok
2379 else
2380 echo 13.err
2381 endif
2382 set diet=abc curd='^abc$'
2383 if $diet =~ $curd
2384 echo 14.ok
2385 else
2386 echo 14.err
2387 endif
2388 set diet=abc curd='^abcd$'
2389 if $diet !~ $curd
2390 echo 15.ok
2391 else
2392 echo 15.err
2393 endif
2394 __EOT
2396 check regex-old 0 "${MBOX}" '1115671789 95' # pre v15compat
2397 else
2398 t_echoskip 'regex-old:[no regex option]'
2401 ## post v15compat
2403 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Sv15-compat=X > "${MBOX}"
2404 \if -N xyz; echo 1.err-1; \
2405 \elif ! -Z xyz;echo 1.err-2;\
2406 \elif -n "$xyz" ; echo 1.err-3 ; \
2407 \elif ! -z "$xyz" ; echo 1.err-4 ; \
2408 \else;echo 1.ok;\
2409 \end
2410 \set xyz
2411 \if ! -N xyz; echo 2.err-1; \
2412 \elif -Z xyz;echo 2.err-2;\
2413 \elif -n "$xyz" ; echo 2.err-3 ; \
2414 \elif ! -z "$xyz" ; echo 2.err-4 ; \
2415 \else;echo 2.ok;\
2416 \end
2417 \set xyz=notempty
2418 \if ! -N xyz; echo 3.err-1; \
2419 \elif -Z xyz;echo 3.err-2;\
2420 \elif ! -n "$xyz";echo 3.err-3;\
2421 \elif -z "$xyz";echo 3.err-4;\
2422 \else;echo 3.ok;\
2423 \end
2424 \if $xyz != notempty;echo 4.err-1;else;echo 4.ok;\end
2425 \if $xyz == notempty;echo 5.ok;else;echo 5.err-1;\end
2426 __EOT
2428 check NnZz_whiteout 0 "${MBOX}" '4280687462 25'
2430 # TODO t_ifelse: individual tests as for NnZz_whiteout
2431 # Nestable conditions test
2432 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Sv15-compat=x > "${MBOX}"
2433 if 0
2434 echo 1.err
2435 else
2436 echo 1.ok
2437 endif
2438 if 1
2439 echo 2.ok
2440 else
2441 echo 2.err
2442 endif
2443 if [ "$dietcurd" != "" ]
2444 echo 3.err
2445 else
2446 echo 3.ok
2447 endif
2448 set dietcurd=yoho
2449 if $'\$dietcurd' != ""
2450 echo 4.ok
2451 else
2452 echo 4.err
2453 endif
2454 if "$dietcurd" == 'yoho'
2455 echo 5.ok
2456 else
2457 echo 5.err
2458 endif
2459 if $'\$dietcurd' ==? 'Yoho'
2460 echo 5-1.ok
2461 else
2462 echo 5-1.err
2463 endif
2464 if $dietcurd == 'Yoho'
2465 echo 5-2.err
2466 else
2467 echo 5-2.ok
2468 endif
2469 if $dietcurd != 'yoho'
2470 echo 6.err
2471 else
2472 echo 6.ok
2473 endif
2474 if $dietcurd !=?case 'Yoho'
2475 echo 6-1.err
2476 else
2477 echo 6-1.ok
2478 endif
2479 if $dietcurd != 'Yoho'
2480 echo 6-2.ok
2481 else
2482 echo 6-2.err
2483 endif
2484 # Nesting
2485 if faLse
2486 echo 7.err1
2487 if tRue
2488 echo 7.err2
2489 if yEs
2490 echo 7.err3
2491 else
2492 echo 7.err4
2493 endif
2494 echo 7.err5
2495 endif
2496 echo 7.err6
2497 else
2498 echo 7.ok7
2499 if YeS
2500 echo 7.ok8
2501 if No
2502 echo 7.err9
2503 else
2504 echo 7.ok9
2505 endif
2506 echo 7.ok10
2507 else
2508 echo 7.err11
2509 if yeS
2510 echo 7.err12
2511 else
2512 echo 7.err13
2513 endif
2514 endif
2515 echo 7.ok14
2516 endif
2517 if r
2518 echo 8.ok1
2519 if R
2520 echo 8.ok2
2521 else
2522 echo 8.err2
2523 endif
2524 echo 8.ok3
2525 else
2526 echo 8.err1
2527 endif
2528 if s
2529 echo 9.err1
2530 else
2531 echo 9.ok1
2532 if S
2533 echo 9.err2
2534 else
2535 echo 9.ok2
2536 endif
2537 echo 9.ok3
2538 endif
2539 # `elif'
2540 if $dietcurd == 'yohu'
2541 echo 10.err1
2542 elif $dietcurd == 'yoha'
2543 echo 10.err2
2544 elif $dietcurd == 'yohe'
2545 echo 10.err3
2546 elif $dietcurd == 'yoho'
2547 echo 10.ok1
2548 if $dietcurd == 'yohu'
2549 echo 10.err4
2550 elif $dietcurd == 'yoha'
2551 echo 10.err5
2552 elif $dietcurd == 'yohe'
2553 echo 10.err6
2554 elif $dietcurd == 'yoho'
2555 echo 10.ok2
2556 if $dietcurd == 'yohu'
2557 echo 10.err7
2558 elif $dietcurd == 'yoha'
2559 echo 10.err8
2560 elif $dietcurd == 'yohe'
2561 echo 10.err9
2562 elif $dietcurd == 'yoho'
2563 echo 10.ok3
2564 else
2565 echo 10.err10
2566 endif
2567 else
2568 echo 10.err11
2569 endif
2570 else
2571 echo 10.err12
2572 endif
2573 # integer
2574 set dietcurd=10
2575 if $dietcurd -lt 11
2576 echo 11.ok1
2577 if $dietcurd -gt 9
2578 echo 11.ok2
2579 else
2580 echo 11.err2
2581 endif
2582 if $dietcurd -eq 10
2583 echo 11.ok3
2584 else
2585 echo 11.err3
2586 endif
2587 if $dietcurd -ge 10
2588 echo 11.ok4
2589 else
2590 echo 11.err4
2591 endif
2592 if $dietcurd -le 10
2593 echo 11.ok5
2594 else
2595 echo 11.err5
2596 endif
2597 if $dietcurd -ge 11
2598 echo 11.err6
2599 else
2600 echo 11.ok6
2601 endif
2602 if $dietcurd -ge?satu -0xFFFFFFFFFFFFFFFF1
2603 echo 11.err7
2604 else
2605 echo 11.ok7
2606 endif
2607 else
2608 echo 11.err1
2609 endif
2610 set dietcurd=Abc
2611 if $dietcurd < aBd
2612 echo 12.ok1
2613 if $dietcurd >? abB
2614 echo 12.ok2
2615 else
2616 echo 12.err2
2617 endif
2618 if $dietcurd ==?case aBC
2619 echo 12.ok3
2620 else
2621 echo 12.err3
2622 endif
2623 if $dietcurd >=?ca AbC
2624 echo 12.ok4
2625 else
2626 echo 12.err4
2627 endif
2628 if $dietcurd <=? ABc
2629 echo 12.ok5
2630 else
2631 echo 12.err5
2632 endif
2633 if $dietcurd >=?case abd
2634 echo 12.err6
2635 else
2636 echo 12.ok6
2637 endif
2638 if $dietcurd <=? abb
2639 echo 12.err7
2640 else
2641 echo 12.ok7
2642 endif
2643 else
2644 echo 12.err1
2645 endif
2646 if $dietcurd < aBc
2647 echo 12-1.ok
2648 else
2649 echo 12-1.err
2650 endif
2651 if $dietcurd <? aBc
2652 echo 12-2.err
2653 else
2654 echo 12-2.ok
2655 endif
2656 if $dietcurd > ABc
2657 echo 12-3.ok
2658 else
2659 echo 12-3.err
2660 endif
2661 if $dietcurd >? ABc
2662 echo 12-3.err
2663 else
2664 echo 12-3.ok
2665 endif
2666 if $dietcurd =%?case aB
2667 echo 13.ok
2668 else
2669 echo 13.err
2670 endif
2671 if $dietcurd =% aB
2672 echo 13-1.err
2673 else
2674 echo 13-1.ok
2675 endif
2676 if $dietcurd =%? bC
2677 echo 14.ok
2678 else
2679 echo 14.err
2680 endif
2681 if $dietcurd !% aB
2682 echo 15-1.ok
2683 else
2684 echo 15-1.err
2685 endif
2686 if $dietcurd !%? aB
2687 echo 15-2.err
2688 else
2689 echo 15-2.ok
2690 endif
2691 if $dietcurd !% bC
2692 echo 15-3.ok
2693 else
2694 echo 15-3.err
2695 endif
2696 if $dietcurd !%? bC
2697 echo 15-4.err
2698 else
2699 echo 15-4.ok
2700 endif
2701 if $dietcurd =% Cd
2702 echo 16.err
2703 else
2704 echo 16.ok
2705 endif
2706 if $dietcurd !% Cd
2707 echo 17.ok
2708 else
2709 echo 17.err
2710 endif
2711 set diet='ab c' curd='ab c'
2712 if "$diet" == "$curd"
2713 echo 18.ok
2714 else
2715 echo 18.err
2716 endif
2717 set diet='ab c' curd='ab cd'
2718 if "$diet" != "$curd"
2719 echo 19.ok
2720 else
2721 echo 19.err
2722 endif
2723 # 1. Shitty grouping capabilities as of today
2724 unset diet curd ndefined
2725 if [ [ false ] || [ false ] || [ true ] ] && \
2726 [ [ false ] || [ true ] ] && \
2727 [ yes ]
2728 echo 20.ok
2729 else
2730 echo 20.err
2731 endif
2732 if [ [ [ [ 0 ] || [ 1 ] ] && [ [ 1 ] || [ 0 ] ] ] && [ 1 ] ] && [ yes ]
2733 echo 21.ok
2734 else
2735 echo 21.err
2736 endif
2737 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] ]
2738 echo 22.ok
2739 else
2740 echo 22.err
2741 endif
2742 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] ]
2743 echo 23.ok
2744 else
2745 echo 23.err
2746 endif
2747 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] && [ no ]
2748 echo 24.err
2749 else
2750 echo 24.ok
2751 endif
2752 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] \
2753 && [ no ] || [ yes ]
2754 echo 25.ok
2755 else
2756 echo 25.err
2757 endif
2758 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
2759 echo 26.ok
2760 else
2761 echo 26.err
2762 endif
2763 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 0 ] ]
2764 echo 27.err
2765 else
2766 echo 27.ok
2767 endif
2768 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 0 ] ] && [ 1 ] ] ] && [ 1 ] ]
2769 echo 28.err
2770 else
2771 echo 28.ok
2772 endif
2773 if [ [ [ [ [ [ [ 0 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
2774 echo 29.err
2775 else
2776 echo 29.ok
2777 endif
2778 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 0 ]
2779 echo 30.err
2780 else
2781 echo 30.ok
2782 endif
2783 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 1 ]
2784 echo 31.ok
2785 else
2786 echo 31.err
2787 endif
2788 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ]
2789 echo 32.err
2790 else
2791 echo 32.ok
2792 endif
2793 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 1 ]
2794 echo 33.ok
2795 else
2796 echo 33.err
2797 endif
2798 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 0 ]
2799 echo 34.err
2800 else
2801 echo 34.ok
2802 endif
2803 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 1 ]
2804 echo 35.ok
2805 else
2806 echo 35.err
2807 endif
2808 set diet=yo curd=ho
2809 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && \
2810 [ -N ndefined || -n "$ndefined" || \
2811 ! -Z ndefined || ! -z "$ndefined" ]
2812 echo 36.err
2813 else
2814 echo 36.ok
2815 endif
2816 set ndefined
2817 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && \
2818 -N ndefined && ! -n "$ndefined" && \
2819 ! -Z ndefined && -z "$ndefined"
2820 echo 37.ok
2821 else
2822 echo 37.err
2823 endif
2824 # 2. Shitty grouping capabilities as of today
2825 unset diet curd ndefined
2826 if [ false || false || true ] && [ false || true ] && yes
2827 echo 40.ok
2828 else
2829 echo 40.err
2830 endif
2831 if [ [ [ 0 || 1 ] && [ 1 || 0 ] ] && 1 ] && [ yes ]
2832 echo 41.ok
2833 else
2834 echo 41.err
2835 endif
2836 if [ 1 || 0 || 0 || 0 ]
2837 echo 42.ok
2838 else
2839 echo 42.err
2840 endif
2841 if [ 1 || 0 || 0 || 0 || [ 1 ] ]
2842 echo 43.ok
2843 else
2844 echo 43.err
2845 endif
2846 if [ 1 || 0 || 0 || 0 || [ 1 ] || 1 ] && no
2847 echo 44.err
2848 else
2849 echo 44.ok
2850 endif
2851 if [ 1 || 0 || 0 || 0 || 1 || [ 1 ] ] && no || [ yes ]
2852 echo 45.ok
2853 else
2854 echo 45.err
2855 endif
2856 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && 1 ] ] && [ 1 ] ]
2857 echo 46.ok
2858 else
2859 echo 46.err
2860 endif
2861 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && [ 1 ] ] ] && 0 ]
2862 echo 47.err
2863 else
2864 echo 47.ok
2865 endif
2866 if [ [ [ [ [ [ [ 1 ] ] && 1 ] && 0 ] && [ 1 ] ] ] && 1 ]
2867 echo 48.err
2868 else
2869 echo 48.ok
2870 endif
2871 if [ [ [ [ [ [ 0 ] && 1 ] && 1 ] && 1 ] ] && 1 ]
2872 echo 49.err
2873 else
2874 echo 49.ok
2875 endif
2876 if 1 || 0 || 0 || 0 && 0
2877 echo 50.err
2878 else
2879 echo 50.ok
2880 endif
2881 if 1 || 0 || 0 || 0 && 1
2882 echo 51.ok
2883 else
2884 echo 51.err
2885 endif
2886 if 0 || 0 || 0 || 1 && 0
2887 echo 52.err
2888 else
2889 echo 52.ok
2890 endif
2891 if 0 || 0 || 0 || 1 && 1
2892 echo 53.ok
2893 else
2894 echo 53.err
2895 endif
2896 if 0 || 0 || 0 || 1 && 0 || 1 && 0
2897 echo 54.err
2898 else
2899 echo 54.ok
2900 endif
2901 if 0 || 0 || 0 || 1 && 0 || 1 && 1
2902 echo 55.ok
2903 else
2904 echo 55.err
2905 endif
2906 set diet=yo curd=ho
2907 if [ $diet == 'yo' && $curd == 'ho' ] && \
2908 [ -N ndefined || -n "$ndefined" || \
2909 ! -Z ndefined || ! -z "$ndefined" ]
2910 echo 56.err
2911 else
2912 echo 56.ok
2913 endif
2914 if [ $diet == 'yo' && $curd == 'ho' && \
2915 [ [ -N ndefined || -n "$ndefined" || \
2916 ! -Z ndefined || ! -z "$ndefined" ] ] ]
2917 echo 57.err
2918 else
2919 echo 57.ok
2920 endif
2921 set ndefined
2922 if [ $diet == 'yo' && $curd == 'ho' ] && \
2923 -N ndefined && ! -n "$ndefined" && \
2924 ! -Z ndefined && -z "$ndefined"
2925 echo 57.ok
2926 else
2927 echo 57.err
2928 endif
2929 if $diet == 'yo' && $curd == 'ho' && ! -Z ndefined
2930 echo 58.ok
2931 else
2932 echo 58.err
2933 endif
2934 if [ [ [ [ [ [ $diet == 'yo' && $curd == 'ho' && -N ndefined ] ] ] ] ] ]
2935 echo 59.ok
2936 else
2937 echo 59.err
2938 endif
2939 # Some more en-braced variables
2940 set diet=yo curd=ho
2941 if ${diet} == ${curd}
2942 echo 70.err
2943 else
2944 echo 70.ok
2945 endif
2946 if "${diet}" != "${curd}"
2947 echo 71.ok
2948 else
2949 echo 71.err
2950 endif
2951 if $diet == ${curd}
2952 echo 72.err
2953 else
2954 echo 72.ok
2955 endif
2956 if ${diet} == $curd
2957 echo 73.err
2958 else
2959 echo 73.ok
2960 endif
2961 # Unary !
2962 if ! 0 && ! ! 1 && ! ! ! ! 2 && 3
2963 echo 80.ok
2964 else
2965 echo 80.err
2966 endif
2967 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ ! 2 ] ] ] && 3
2968 echo 81.ok
2969 else
2970 echo 81.err
2971 endif
2972 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
2973 echo 82.ok
2974 else
2975 echo 82.err
2976 endif
2977 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
2978 echo 83.err
2979 else
2980 echo 83.ok
2981 endif
2982 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
2983 echo 84.err
2984 else
2985 echo 84.ok
2986 endif
2987 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
2988 echo 85.err
2989 else
2990 echo 85.ok
2991 endif
2992 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
2993 echo 86.err
2994 else
2995 echo 86.ok
2996 endif
2997 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] || 3
2998 echo 87.ok
2999 else
3000 echo 87.err
3001 endif
3002 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! ! [ 2 ] ] ] ] ]
3003 echo 88.ok
3004 else
3005 echo 88.err
3006 endif
3007 # Unary !, odd
3008 if ! 0 && ! ! 1 && ! ! ! 0 && 3
3009 echo 90.ok
3010 else
3011 echo 90.err
3012 endif
3013 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ 0 ] ] ] && 3
3014 echo 91.ok
3015 else
3016 echo 91.err
3017 endif
3018 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ [ 0 ] ] ] ] ] && 3
3019 echo 92.ok
3020 else
3021 echo 92.err
3022 endif
3023 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! ! [ ! [ ! 0 ] ] ] ] && ! 3
3024 echo 93.err
3025 else
3026 echo 93.ok
3027 endif
3028 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ ! [ ! [ ! [ ! 0 ] ] ] ] && 3
3029 echo 94.ok
3030 else
3031 echo 94.err
3032 endif
3033 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! ! [ ! [ ! [ ! [ 0 ] ] ] ] ] && 3
3034 echo 95.err
3035 else
3036 echo 95.ok
3037 endif
3038 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! ! 0 ] ] ] ] && 3
3039 echo 96.err
3040 else
3041 echo 96.ok
3042 endif
3043 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ ! 0 ] ] ] ] ] || 3
3044 echo 97.ok
3045 else
3046 echo 97.err
3047 endif
3048 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! [ 0 ] ] ] ] ]
3049 echo 98.ok
3050 else
3051 echo 98.err
3052 endif
3053 __EOT
3055 check normal 0 "${MBOX}" '1688759742 719'
3057 if have_feat regex; then
3058 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Sv15-compat=X > "${MBOX}"
3059 set dietcurd=yoho
3060 if $dietcurd =~ '^yo.*'
3061 echo 1.ok
3062 else
3063 echo 1.err
3064 endif
3065 if "$dietcurd" =~ '^Yo.*'
3066 echo 1-1.err
3067 else
3068 echo 1-1.ok
3069 endif
3070 if $dietcurd =~?case '^Yo.*'
3071 echo 1-2.ok
3072 else
3073 echo 1-2.err
3074 endif
3075 if $dietcurd =~ '^yOho.+'
3076 echo 2.err
3077 else
3078 echo 2.ok
3079 endif
3080 if $dietcurd !~? '.*Ho$'
3081 echo 3.err
3082 else
3083 echo 3.ok
3084 endif
3085 if $dietcurd !~ '.+yohO$'
3086 echo 4.ok
3087 else
3088 echo 4.err
3089 endif
3090 if [ $dietcurd !~?cas '.+yoho$' ]
3091 echo 5.ok
3092 else
3093 echo 5.err
3094 endif
3095 if ! [ "$dietcurd" =~?case '.+yoho$' ]
3096 echo 6.ok
3097 else
3098 echo 6.err
3099 endif
3100 if ! ! [ $'\$dietcurd' !~? '.+yoho$' ]
3101 echo 7.ok
3102 else
3103 echo 7.err
3104 endif
3105 if ! [ ! [ $dietcurd !~? '.+yoho$' ] ]
3106 echo 8.ok
3107 else
3108 echo 8.err
3109 endif
3110 if [ ! [ ! [ $dietcurd !~? '.+yoho$' ] ] ]
3111 echo 9.ok
3112 else
3113 echo 9.err
3114 endif
3115 if ! [ ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
3116 echo 10.err
3117 else
3118 echo 10.ok
3119 endif
3120 if ! ! ! $dietcurd !~ '.+yoho$'
3121 echo 11.err
3122 else
3123 echo 11.ok
3124 endif
3125 if ! ! ! $dietcurd =~ '.+yoho$'
3126 echo 12.ok
3127 else
3128 echo 12.err
3129 endif
3130 if ! [ ! ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
3131 echo 13.ok
3132 else
3133 echo 13.err
3134 endif
3135 set diet=abc curd='^abc$'
3136 if $diet =~ $curd
3137 echo 14.ok
3138 else
3139 echo 14.err
3140 endif
3141 set diet=abc curd='^abcd$'
3142 if "$diet" !~ $'\$curd'
3143 echo 15.ok
3144 else
3145 echo 15.err
3146 endif
3147 __EOT
3149 check regex 0 "${MBOX}" '1115671789 95'
3150 else
3151 t_echoskip 'regex:[!REGEX]'
3154 t_epilog "${@}"
3157 t_localopts() {
3158 t_prolog "${@}"
3160 # Nestable conditions test
3161 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
3162 define t2 {
3163 echo in: t2
3164 set t2=t2
3165 echo $t2
3167 define t1 {
3168 echo in: t1
3169 set gv1=gv1
3170 localopts on
3171 set lv1=lv1 lv2=lv2
3172 set lv3=lv3
3173 call t2
3174 localopts off
3175 set gv2=gv2
3176 echo $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2
3178 define t0 {
3179 echo in: t0
3180 call t1
3181 echo $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2
3182 echo "$gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2"
3184 account trouble {
3185 echo in: trouble
3186 call t0
3188 call t0
3189 unset gv1 gv2
3190 account trouble
3191 echo active trouble: $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t3
3192 account null
3193 echo active null: $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t3
3196 define ll2 {
3197 localopts $1
3198 set x=2
3199 echo ll2=$x
3201 define ll1 {
3202 wysh set y=$1; shift; eval localopts $y; localopts $1; shift
3203 set x=1
3204 echo ll1.1=$x
3205 call ll2 $1
3206 echo ll1.2=$x
3208 define ll0 {
3209 wysh set y=$1; shift; eval localopts $y; localopts $1; shift
3210 set x=0
3211 echo ll0.1=$x
3212 call ll1 $y "$@"
3213 echo ll0.2=$x
3215 define llx {
3216 echo ----- $1: $2 -> $3 -> $4
3217 echo ll-1.1=$x
3218 eval localopts $1
3219 call ll0 "$@"
3220 echo ll-1.2=$x
3221 unset x
3223 define lly {
3224 call llx 'call off' on on on
3225 call llx 'call off' off on on
3226 call llx 'call off' on off on
3227 call llx 'call off' on off off
3228 localopts call-fixate on
3229 call llx 'call-fixate on' on on on
3230 call llx 'call-fixate on' off on on
3231 call llx 'call-fixate on' on off on
3232 call llx 'call-fixate on' on off off
3233 unset x;localopts call on
3234 call llx 'call on' on on on
3235 call llx 'call on' off on on
3236 call llx 'call on' on off on
3237 call llx 'call on' on off off
3239 call lly
3240 __EOT
3242 check 1 0 "${MBOX}" '4016155249 1246'
3244 t_epilog "${@}"
3247 t_local() {
3248 t_prolog "${@}"
3250 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
3251 define du2 {
3252 echo du2-1 du=$du
3253 local set du=$1
3254 echo du2-2 du=$du
3255 local unset du
3256 echo du2-3 du=$du
3258 define du {
3259 local set du=dudu
3260 echo du-1 du=$du
3261 call du2 du2du2
3262 echo du-2 du=$du
3263 local set nodu
3264 echo du-3 du=$du
3266 define ich {
3267 echo ich-1 du=$du
3268 call du
3269 echo ich-2 du=$du
3271 define wir {
3272 localopts $1
3273 set du=wirwir
3274 echo wir-1 du=$du
3275 call ich
3276 echo wir-2 du=$du
3278 echo ------- global-1 du=$du
3279 call ich
3280 echo ------- global-2 du=$du
3281 set du=global
3282 call ich
3283 echo ------- global-3 du=$du
3284 call wir on
3285 echo ------- global-4 du=$du
3286 call wir off
3287 echo ------- global-5 du=$du
3288 __EOT
3289 check 1 0 "${MBOX}" '2411598140 641'
3292 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
3293 define z {
3294 echo z-1: x=$x y=$y z=$z crt=$crt
3295 local set z=1 y=2 crt=10
3296 echo z-2: x=$x y=$y z=$z crt=$crt
3298 define y {
3299 echo y-1: x=$x y=$y z=$z crt=$crt
3300 local set x=2 y=1 crt=5
3301 echo y-2: x=$x y=$y z=$z crt=$crt
3302 call z
3303 echo y-3: x=$x y=$y z=$z crt=$crt
3305 define x {
3306 echo x-1: x=$x y=$y z=$z crt=$crt
3307 local set x=1 crt=1
3308 echo x-2: x=$x y=$y z=$z crt=$crt
3309 call y
3310 echo x-3: x=$x y=$y z=$z crt=$crt
3312 set crt
3313 echo global-1: x=$x y=$y z=$z crt=$crt
3314 call x
3315 echo global-2: x=$x y=$y z=$z crt=$crt
3316 __EOT
3317 check 2 0 "${MBOX}" '2560788669 216'
3319 t_epilog "${@}"
3322 t_environ() {
3323 t_prolog "${@}"
3325 ${cat} <<- '__EOT' | EK1=EV1 EK2=EV2 ${MAILX} ${ARGS} > "${MBOX}" 2>&1
3326 echo "we: EK1<$EK1> EK2<$EK2> EK3<$EK3> EK4<$EK4> NEK5<$NEK5>"
3327 !echo "shell: EK1<$EK1> EK2<$EK2> EK3<$EK3> EK4<$EK4> NEK5<$NEK5>"
3328 varshow EK1 EK2 EK3 EK4 NEK5
3330 echo environ set EK3 EK4, set NEK5
3331 environ set EK3=EV3 EK4=EV4
3332 set NEK5=NEV5
3333 echo "we: EK1<$EK1> EK2<$EK2> EK3<$EK3> EK4<$EK4> NEK5<$NEK5>"
3334 !echo "shell: EK1<$EK1> EK2<$EK2> EK3<$EK3> EK4<$EK4> NEK5<$NEK5>"
3335 varshow EK1 EK2 EK3 EK4 NEK5
3337 echo removing NEK5 EK3
3338 unset NEK5
3339 environ unset EK3
3340 echo "we: EK1<$EK1> EK2<$EK2> EK3<$EK3> EK4<$EK4> NEK5<$NEK5>"
3341 !echo "shell: EK1<$EK1> EK2<$EK2> EK3<$EK3> EK4<$EK4> NEK5<$NEK5>"
3342 varshow EK1 EK2 EK3 EK4 NEK5
3344 echo changing EK1, EK4
3345 set EK1=EV1_CHANGED EK4=EV4_CHANGED
3346 echo "we: EK1<$EK1> EK2<$EK2> EK3<$EK3> EK4<$EK4> NEK5<$NEK5>"
3347 !echo "shell: EK1<$EK1> EK2<$EK2> EK3<$EK3> EK4<$EK4> NEK5<$NEK5>"
3348 varshow EK1 EK2 EK3 EK4 NEK5
3350 echo linking EK4, rechanging EK1, EK4
3351 environ link EK4
3352 set EK1=EV1 EK4=EV4
3353 echo "we: EK1<$EK1> EK2<$EK2> EK3<$EK3> EK4<$EK4> NEK5<$NEK5>"
3354 !echo "shell: EK1<$EK1> EK2<$EK2> EK3<$EK3> EK4<$EK4> NEK5<$NEK5>"
3355 varshow EK1 EK2 EK3 EK4 NEK5
3357 echo unset all
3358 unset EK1 EK2 EK4
3359 echo "we: EK1<$EK1> EK2<$EK2> EK3<$EK3> EK4<$EK4> NEK5<$NEK5>"
3360 !echo "shell: EK1<$EK1> EK2<$EK2> EK3<$EK3> EK4<$EK4> NEK5<$NEK5>"
3361 varshow EK1 EK2 EK3 EK4 NEK5
3362 __EOT
3364 check 1 0 "${MBOX}" '1685686686 1342'
3366 t_epilog "${@}"
3367 return
3370 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
3371 define l4 {
3372 echo '-------> L4 (environ unlink EK1, own localopts)'
3373 localopts yes
3374 environ unlink EK1
3375 set LK1=LK1_L4 EK1=EK1_L4
3376 echo "we: L4: LK1<$LK1> EK1<$EK1>"
3377 !echo "shell: L4: LK1<$LK1> EK1<$EK1>"
3378 varshow LK1 EK1
3379 echo '-------< L4'
3381 define l3 {
3382 echo '-------> L3'
3383 set LK1=LK1_L3 EK1=EK1_L3
3384 echo "we: L3-pre: LK1<$LK1> EK1<$EK1>"
3385 !echo "shell: L3-pre: LK1<$LK1> EK1<$EK1>"
3386 varshow LK1 EK1
3387 call l4
3388 echo "we: L3-post: LK1<$LK1> EK1<$EK1>"
3389 !echo "shell: L3-post: LK1<$LK1> EK1<$EK1>"
3390 varshow LK1 EK1
3391 echo '-------< L3'
3393 define l2 {
3394 echo '-------> L2'
3395 set LK1=LK1_L2 EK1=EK1_L2
3396 echo "we: L2-pre: LK1<$LK1> EK1<$EK1>"
3397 !echo "shell: L2-pre: LK1<$LK1> EK1<$EK1>"
3398 varshow LK1 EK1
3399 call l3
3400 echo "we: L2-post: LK1<$LK1> EK1<$EK1>"
3401 !echo "shell: L2-post: LK1<$LK1> EK1<$EK1>"
3402 varshow LK1 EK1
3403 echo '-------< L2'
3405 define l1 {
3406 echo '-------> L1 (environ link EK1; localopts call-fixate)'
3407 localopts call-fixate yes
3408 set LK1=LK1_L1 EK1=EK1_L1
3409 environ link EK1
3410 echo "we: L1-pre: LK1<$LK1> EK1<$EK1>"
3411 !echo "shell: L1-pre: LK1<$LK1> EK1<$EK1>"
3412 varshow LK1 EK1
3413 call l2
3414 echo "we: L1-post: LK1<$LK1> EK1<$EK1>"
3415 !echo "shell: L1-post: LK1<$LK1> EK1<$EK1>"
3416 varshow LK1 EK1
3417 echo '-------< L1'
3419 echo "we: outer-pre: LK1<$LK1> EK1<$EK1>"
3420 !echo "shell: outer-pre: LK1<$LK1> EK1<$EK1>"
3421 varshow LK1 EK1
3422 call l1
3423 echo "we: outer-post: LK1<$LK1> EK1<$EK1>"
3424 !echo "shell: outer-post: LK1<$LK1> EK1<$EK1>"
3425 varshow LK1 EK1
3426 __EOT
3428 check 2 0 "${MBOX}" '1903030743 1131'
3430 t_epilog "${@}"
3433 t_macro_param_shift() {
3434 t_prolog "${@}"
3436 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>>${ERR}
3437 define t2 {
3438 echo in: t2
3439 echo t2.0 has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
3440 localopts on
3441 wysh set ignerr=$1
3442 shift
3443 localopts off
3444 echo t2.1 has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
3445 if [ $# > 1 ] || [ $ignerr == '' ]
3446 shift 2
3447 else
3448 ignerr shift 2
3449 endif
3450 echo t2.2:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
3451 shift 0
3452 echo t2.3:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
3453 if [ $# > 0 ]
3454 shift
3455 endif
3456 echo t2.4:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
3458 define t1 {
3459 set errexit
3460 echo in: t1
3461 call t2 1 you get four args
3462 echo t1.1: $?';' ignerr ($ignerr) should not exist
3463 call t2 1 you get 'three args'
3464 echo t1.2: $?';' ignerr ($ignerr) should not exist
3465 call t2 1 you 'get two args'
3466 echo t1.3: $?';' ignerr ($ignerr) should not exist
3467 call t2 1 'you get one arg'
3468 echo t1.4: $?';' ignerr ($ignerr) should not exist
3469 ignerr call t2 '' 'you get one arg'
3470 echo t1.5: $?';' ignerr ($ignerr) should not exist
3472 call t1
3473 __EOT
3475 check 1 0 "${MBOX}" '1402489146 1682'
3477 t_epilog "${@}"
3480 t_addrcodec() {
3481 t_prolog "${@}"
3483 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
3484 commandalias x echo '$?/$^ERRNAME $res'
3485 vput addrcodec res e 1 <doog@def>
3487 eval vput addrcodec res d $res
3489 vput addrcodec res e 2 . <doog@def>
3491 eval vput addrcodec res d $res
3493 vput addrcodec res e 3 Sauer Dr. <doog@def>
3495 eval vput addrcodec res d $res
3497 vput addrcodec res e 3.50 Sauer (Ma) Dr. <doog@def>
3499 eval vput addrcodec res d $res
3501 vput addrcodec res e 3.51 Sauer (Ma) "Dr." <doog@def>
3503 eval vput addrcodec res d $res
3506 vput addrcodec res +e 4 Sauer (Ma) Dr. <doog@def>
3508 eval vput addrcodec res d $res
3510 vput addrcodec res +e 5 Sauer (Ma) Braten Dr. <doog@def>
3512 eval vput addrcodec res d $res
3514 vput addrcodec res +e 6 Sauer (Ma) Braten Dr. (Heu) <doog@def>
3516 eval vput addrcodec res d $res
3518 vput addrcodec res +e 7 Sauer (Ma) Braten Dr. (Heu) <doog@def> (bu)
3520 eval vput addrcodec res d $res
3522 vput addrcodec res +e 8 \
3523 Dr. Sauer (Ma) Braten Dr. (Heu) <doog@def> (bu) Boom. Boom
3525 eval vput addrcodec res d $res
3527 vput addrcodec res +e 9 Dr.Sauer(Ma)Braten Dr. (Heu) <doog@def>
3529 eval vput addrcodec res d $res
3531 vput addrcodec res +e 10 (Ma)Braten Dr. (Heu) <doog@def>
3533 eval vput addrcodec res d $res
3535 vput addrcodec res +e 11 (Ma)Braten Dr"." (Heu) <doog@def>
3537 eval vput addrcodec res d $res
3539 vput addrcodec res +e 12 Dr. Sauer (Ma) Braten Dr. (u) <doog@def>
3541 eval vput addrcodec res d $res
3543 vput addrcodec res +e 13(Ma)Braten Dr. (Heu) <doog@def>
3545 eval vput addrcodec res d $res
3547 vput addrcodec res +e 14 Hey, Du <doog@def> Wie() findet Dr. das? ()
3549 eval vput addrcodec res d $res
3551 vput addrcodec res +e 15 \
3552 Hey, Du <doog@def> Wie() findet "" Dr. "" das? ()
3554 eval vput addrcodec res d $res
3556 vput addrcodec res +e 16 \
3557 "Hey," "Du" <doog@def> "Wie()" findet "" Dr. "" das? ()
3559 eval vput addrcodec res d $res
3561 vput addrcodec res +e 17 \
3562 "Hey" Du <doog@def> "Wie() findet " " Dr. """ das? ()
3564 eval vput addrcodec res d $res
3566 vput addrcodec res +e 18 \
3567 <doog@def> "Hey" Du "Wie() findet " " Dr. """ das? ()
3569 eval vput addrcodec res d $res
3571 vput addrcodec res +e 19 Hey\,\" <doog@def> "Wie()" findet \" Dr. \" das?
3573 eval vput addrcodec res d $res
3576 vput addrcodec res ++e 20 Hey\,\" <doog@def> "Wie()" findet \" Dr. \" das?
3578 vput addrcodec res ++e 21 Hey\,\"" <doog@def> "Wie()" findet \" Dr. \" das?
3580 eval vput addrcodec res d $res
3583 vput addrcodec res \
3584 +++e 22 Hey\\,\" <doog@def> "Wie()" findet \" Dr. \" das?
3586 eval vput addrcodec res d $res
3589 vput addrcodec res s \
3590 "23 Hey\\,\\\" \"Wie" () "\" findet \\\" Dr. \\\" das?" <doog@def>
3593 # Fix for [f3852f88]
3594 vput addrcodec res ++e <from2@exam.ple> 100 (comment) "Quot(e)d"
3596 eval vput addrcodec res d $res
3598 vput addrcodec res e <from2@exam.ple> 100 (comment) "Quot(e)d"
3600 eval vput addrcodec res d $res
3602 __EOT
3604 check 1 0 "${MBOX}" '1047317989 2612'
3606 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
3607 commandalias x echo '$?/$^ERRNAME $res'
3608 mlist isa1@list
3609 mlsubscribe isa2@list
3611 vput addrcodec res skin Hey\\,\" <isa0@list> "Wie()" find \" Dr. \" das?
3613 vput addrcodec res skinlist Hey\\,\" <isa0@list> "Wie()" find \" Dr. \" das?
3615 vput addrcodec res skin Hey\\,\" <isa1@list> "Wie()" find \" Dr. \" das?
3617 vput addrcodec res skinlist Hey\\,\" <isa1@list> "Wie()" find \" Dr. \" das?
3619 vput addrcodec res skin Hey\\,\" <isa2@list> "Wie()" find \" Dr. \" das?
3621 vput addrcodec res skinlist Hey\\,\" <isa2@list> "Wie()" find \" Dr. \" das?
3623 __EOT
3625 check 2 0 "${MBOX}" '1391779299 104'
3627 if have_feat idna; then
3628 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} ${ADDARG_UNI} > "${MBOX}" 2>&1
3629 commandalias x echo '$?/$^ERRNAME $res'
3630 vput addrcodec res e (heu) <du@blödiän> "stroh" du
3632 eval vput addrcodec res d $res
3634 vput addrcodec res e <du@blödiän> du
3636 eval vput addrcodec res d $res
3638 vput addrcodec res e du <du@blödiän>
3640 eval vput addrcodec res d $res
3642 vput addrcodec res e <du@blödiän>
3644 eval vput addrcodec res d $res
3646 vput addrcodec res e du@blödiän
3648 eval vput addrcodec res d $res
3650 __EOT
3652 check idna 0 "${MBOX}" '498775983 326'
3653 else
3654 t_echoskip 'idna:[!IDNA]'
3657 t_epilog "${@}"
3660 t_csop() {
3661 t_prolog "${@}"
3663 if have_feat cmd-csop; then :; else
3664 t_echoskip '[!CMD_CSOP]'
3665 t_epilog "${@}"
3666 return
3669 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
3670 commandalias x echo '$?/$^ERRNAME :$res:'
3671 echo ' #-2'
3672 vput csop res find you y;x
3673 vput csop res find you o;x
3674 vput csop res find you u;x
3675 vput csop res find you yo;x
3676 vput csop res find you ou;x
3677 vput csop res find you you;x
3678 echo ' #-1'
3679 vput csop res find you Y;x
3680 vput csop res find? you Y;x
3681 vput csop res find?case you O;x
3682 vput csop res find? you U;x
3683 vput csop res find?ca you yO;x
3684 vput csop res find? you oU;x
3685 vput csop res find? you YoU;x
3686 echo ' #0'
3687 vput csop res find 'bananarama' 'nana';x
3688 vput csop res find 'bananarama' 'bana';x
3689 vput csop res find 'bananarama' 'Bana';x
3690 vput csop res find 'bananarama' 'rama';x
3691 echo ' #1'
3692 vput csop res find? 'bananarama' 'nana';x
3693 vput csop res find? 'bananarama' 'bana';x
3694 vput csop res find? 'bananarama' 'Bana';x
3695 vput csop res find? 'bananarama' 'rama';x
3696 echo ' #2'
3697 vput csop res substring 'bananarama' 1;x
3698 vput csop res substring 'bananarama' 3;x
3699 vput csop res substring 'bananarama' 5;x
3700 vput csop res substring 'bananarama' 7;x
3701 vput csop res substring 'bananarama' 9;x
3702 vput csop res substring 'bananarama' 10;x
3703 vput csop res substring 'bananarama' 1 3;x
3704 vput csop res substring 'bananarama' 3 3;x
3705 vput csop res substring 'bananarama' 5 3;x
3706 vput csop res substring 'bananarama' 7 3;x
3707 vput csop res substring 'bananarama' 9 3;x
3708 vput csop res substring 'bananarama' 10 3;x
3709 echo ' #3'
3710 vput csop res substring 'bananarama' -1;x
3711 vput csop res substring 'bananarama' -3;x
3712 vput csop res substring 'bananarama' -5;x
3713 vput csop res substring 'bananarama' -7;x
3714 vput csop res substring 'bananarama' -9;x
3715 vput csop res substring 'bananarama' -10;x
3716 vput csop res substring 'bananarama' 1 -3;x
3717 vput csop res substring 'bananarama' 3 -3;x
3718 vput csop res substring 'bananarama' 5 -3;x
3719 vput csop res substring 'bananarama' 7 -3;x
3720 vput csop res substring 'bananarama' 9 -3;x
3721 vput csop res substring 'bananarama' 10 -3;x
3722 echo ' #4'
3723 vput csop res trim 'Cocoon Cocoon';x
3724 vput csop res trim ' Cocoon Cocoon ';x
3725 vput csop res trim-front 'Cocoon Cocoon';x
3726 vput csop res trim-front ' Cocoon Cocoon ';x
3727 vput csop res trim-end 'Cocoon Cocoon';x
3728 vput csop res trim-end ' Cocoon Cocoon ';x
3729 __EOT
3731 check 1 0 "${MBOX}" '1892119538 755'
3733 t_epilog "${@}"
3736 t_vexpr() {
3737 t_prolog "${@}"
3739 if have_feat cmd-vexpr; then :; else
3740 t_echoskip '[!CMD_VEXPR]'
3741 t_epilog "${@}"
3742 return
3745 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>>${ERR}
3746 commandalias x echo '$?/$^ERRNAME $res'
3747 echo ' #0.0'
3748 vput vexpr res = 9223372036854775807;x
3749 vput vexpr res = 9223372036854775808;x
3750 vput vexpr res = u9223372036854775808;x
3751 vput vexpr res =? 9223372036854775808;x
3752 vput vexpr res = -9223372036854775808;x
3753 vput vexpr res = -9223372036854775809;x
3754 vput vexpr res =?saturated -9223372036854775809;x
3755 vput vexpr res = U9223372036854775809;x
3756 echo ' #0.1'
3757 vput vexpr res = \
3758 0b0111111111111111111111111111111111111111111111111111111111111111;x
3759 vput vexpr res = \
3760 S0b1000000000000000000000000000000000000000000000000000000000000000;x
3761 vput vexpr res =? \
3762 S0b1000000000000000000000000000000000000000000000000000000000000000;x
3763 vput vexpr res = \
3764 U0b1000000000000000000000000000000000000000000000000000000000000000;x
3765 vput vexpr res = \
3766 0b1000000000000000000000000000000000000000000000000000000000000000;x
3767 vput vexpr res =? \
3768 0b1000000000000000000000000000000000000000000000000000000000000000;x
3769 vput vexpr res = \
3770 -0b1000000000000000000000000000000000000000000000000000000000000000;x
3771 vput vexpr res = \
3772 S0b1000000000000000000000000000000000000000000000000000000000000001;x
3773 vput vexpr res =? \
3774 S0b1000000000000000000000000000000000000000000000000000000000000001;x
3775 vput vexpr res =? \
3776 -0b1000000000000000000000000000000000000000000000000000000000000001;x
3777 vput vexpr res = \
3778 U0b1000000000000000000000000000000000000000000000000000000000000001;x
3779 echo ' #0.2'
3780 vput vexpr res = 0777777777777777777777;x
3781 vput vexpr res = S01000000000000000000000;x
3782 vput vexpr res =? S01000000000000000000000;x
3783 vput vexpr res = U01000000000000000000000;x
3784 vput vexpr res = 01000000000000000000000;x
3785 vput vexpr res =?satur 01000000000000000000000;x
3786 vput vexpr res = -01000000000000000000000;x
3787 vput vexpr res = S01000000000000000000001;x
3788 vput vexpr res =?sat S01000000000000000000001;x
3789 vput vexpr res = -01000000000000000000001;x
3790 vput vexpr res = U01000000000000000000001;x
3791 echo ' #0.3'
3792 vput vexpr res = 0x7FFFFFFFFFFFFFFF;x
3793 vput vexpr res = S0x8000000000000000;x
3794 vput vexpr res =? S0x8000000000000000;x
3795 vput vexpr res = U0x8000000000000000;x
3796 vput vexpr res = 0x8000000000000000;x
3797 vput vexpr res =? 0x8000000000000000;x
3798 vput vexpr res = -0x8000000000000000;x
3799 vput vexpr res = S0x8000000000000001;x
3800 vput vexpr res =? S0x8000000000000001;x
3801 vput vexpr res = -0x8000000000000001;x
3802 vput vexpr res = u0x8000000000000001;x
3803 vput vexpr res = 9223372036854775809;x
3804 vput vexpr res =? 9223372036854775809;x
3805 vput vexpr res = u9223372036854775809;x
3806 echo ' #1'
3807 vput vexpr res ~ 0;x
3808 vput vexpr res ~ 1;x
3809 vput vexpr res ~ -1;x
3810 echo ' #1.1'
3811 vput vexpr res - 0;x
3812 vput vexpr res - 1;x
3813 vput vexpr res - -1;x
3814 vput vexpr res - -0xAFFE;x
3815 vput vexpr res - 0xAFFE;x
3816 vput vexpr res - u0x8000000000000001;x
3817 vput vexpr res - 0x8000000000000001;x
3818 vput vexpr res - 0x8000000000000001;x
3819 vput vexpr res - 9223372036854775809;x
3820 vput vexpr res -? 9223372036854775809;x
3821 echo ' #1.2'
3822 vput vexpr res + 0;x
3823 vput vexpr res + 1;x
3824 vput vexpr res + -1;x
3825 vput vexpr res + -0xAFFE;x
3826 vput vexpr res + 0xAFFE;x
3827 vput vexpr res + u0x8000000000000001;x
3828 vput vexpr res + 0x8000000000000001;x
3829 vput vexpr res + 9223372036854775809;x
3830 vput vexpr res +? 9223372036854775809;x
3831 echo ' #2'
3832 vput vexpr res + 0 0;x
3833 vput vexpr res + 0 1;x
3834 vput vexpr res + 1 1;x
3835 echo ' #3'
3836 vput vexpr res + 9223372036854775807 0;x
3837 vput vexpr res + 9223372036854775807 1;x
3838 vput vexpr res +? 9223372036854775807 1;x
3839 vput vexpr res + 0 9223372036854775807;x
3840 vput vexpr res + 1 9223372036854775807;x
3841 vput vexpr res +? 1 9223372036854775807;x
3842 echo ' #4'
3843 vput vexpr res + -9223372036854775808 0;x
3844 vput vexpr res + -9223372036854775808 -1;x
3845 vput vexpr res +? -9223372036854775808 -1;x
3846 vput vexpr res + 0 -9223372036854775808;x
3847 vput vexpr res + -1 -9223372036854775808;x
3848 vput vexpr res +? -1 -9223372036854775808;x
3849 echo ' #5'
3850 vput vexpr res - 0 0;x
3851 vput vexpr res - 0 1;x
3852 vput vexpr res - 1 1;x
3853 echo ' #6'
3854 vput vexpr res - 9223372036854775807 0;x
3855 vput vexpr res - 9223372036854775807 -1;x
3856 vput vexpr res -? 9223372036854775807 -1;x
3857 vput vexpr res - 0 9223372036854775807;x
3858 vput vexpr res - -1 9223372036854775807;x
3859 vput vexpr res - -2 9223372036854775807;x
3860 vput vexpr res -? -2 9223372036854775807;x
3861 echo ' #7'
3862 vput vexpr res - -9223372036854775808 +0;x
3863 vput vexpr res - -9223372036854775808 +1;x
3864 vput vexpr res -? -9223372036854775808 +1;x
3865 vput vexpr res - 0 -9223372036854775808;x
3866 vput vexpr res - +1 -9223372036854775808;x
3867 vput vexpr res -? +1 -9223372036854775808;x
3868 echo ' #8'
3869 vput vexpr res + -13 -2;x
3870 vput vexpr res - 0 0;x
3871 vput vexpr res - 0 1;x
3872 vput vexpr res - 1 1;x
3873 vput vexpr res - -13 -2;x
3874 echo ' #9'
3875 vput vexpr res * 0 0;x
3876 vput vexpr res * 0 1;x
3877 vput vexpr res * 1 1;x
3878 vput vexpr res * -13 -2;x
3879 echo ' #10'
3880 vput vexpr res / 0 0;x
3881 vput vexpr res / 0 1;x
3882 vput vexpr res / 1 1;x
3883 vput vexpr res / -13 -2;x
3884 echo ' #11'
3885 vput vexpr res % 0 0;x
3886 vput vexpr res % 0 1;x
3887 vput vexpr res % 1 1;x
3888 vput vexpr res % -13 -2;x
3889 echo ' #12'
3890 vput vexpr res pbase 10 u0x8000000000000001;x
3891 vput vexpr res pbase 16 0x8000000000000001;x
3892 vput vexpr res pbase 16 s0x8000000000000001;x
3893 vput vexpr res pbase 16 u0x8000000000000001;x
3894 vput vexpr res pbase 36 0x8000000000000001;x
3895 vput vexpr res pbase 36 u0x8000000000000001;x
3896 __EOT
3898 check numeric 0 "${MBOX}" '163128733 2519'
3900 if have_feat regex; then
3901 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
3902 commandalias x echo '$?/$^ERRNAME :$res:'
3903 echo ' #-2'
3904 vput vexpr res regex you y;x
3905 vput vexpr res regex you o;x
3906 vput vexpr res regex you u;x
3907 vput vexpr res regex you yo;x
3908 vput vexpr res regex you ou;x
3909 vput vexpr res regex you you;x
3910 echo ' #-1'
3911 vput vexpr res regex you Y;x
3912 vput vexpr res regex? you Y;x
3913 vput vexpr res regex? you O;x
3914 vput vexpr res regex? you U;x
3915 vput vexpr res regex? you yO;x
3916 vput vexpr res regex? you oU;x
3917 vput vexpr res regex? you YoU;x
3918 echo ' #0'
3919 vput vexpr res regex 'bananarama' 'nana';x
3920 vput vexpr res regex 'bananarama' 'bana';x
3921 vput vexpr res regex 'bananarama' 'Bana';x
3922 vput vexpr res regex 'bananarama' 'rama';x
3923 echo ' #1'
3924 vput vexpr res regex? 'bananarama' 'nana';x
3925 vput vexpr res regex? 'bananarama' 'bana';x
3926 vput vexpr res regex? 'bananarama' 'Bana';x
3927 vput vexpr res regex? 'bananarama' 'rama';x
3928 echo ' #2'
3929 vput vexpr res regex 'bananarama' '(.*)nana(.*)' '\${1}a\${0}u{\$2}';x
3930 vput vexpr res regex 'bananarama' '(.*)bana(.*)' '\${1}a\${0}u\$2';x
3931 vput vexpr res regex 'bananarama' 'Bana(.+)' '\$1\$0';x
3932 vput vexpr res regex 'bananarama' '(.+)rama' '\$1\$0';x
3933 echo ' #3'
3934 vput vexpr res regex? 'bananarama' '(.*)nana(.*)' '\${1}a\${0}u{\$2}';x
3935 vput vexpr res regex? 'bananarama' '(.*)bana(.*)' '\${1}a\${0}u\$2';x
3936 vput vexpr res regex? 'bananarama' 'Bana(.+)' '\$1\$0';x
3937 vput vexpr res regex? 'bananarama' '(.+)rama' '\$1\$0';x
3938 echo ' #4'
3939 vput vexpr res regex 'banana' '(club )?(.*)(nana)(.*)' \
3940 '\$1\${2}\$4\${3}rama';x
3941 vput vexpr res regex 'Banana' '(club )?(.*)(nana)(.*)' \
3942 '\$1\$2\${2}\$2\$4\${3}rama';x
3943 vput vexpr res regex 'Club banana' '(club )?(.*)(nana)(.*)' \
3944 '\$1\${2}\$4\${3}rama';x
3945 echo ' #5'
3946 __EOT
3948 check regex 0 "${MBOX}" '2831099111 542'
3949 else
3950 t_echoskip 'regex:[!REGEX]'
3953 t_epilog "${@}"
3956 t_call_ret() {
3957 t_prolog "${@}"
3959 if have_feat cmd-vexpr; then :; else
3960 t_echoskip '[!CMD_VEXPR]'
3961 t_epilog "${@}"
3962 return
3965 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Snomemdebug > "${MBOX}" 2>&1
3966 define w1 {
3967 echon ">$1 "
3968 vput vexpr i + $1 1
3969 if [ $i -le 42 ]
3970 vput vexpr j '&' $i 7
3971 if [ $j -eq 7 ]
3972 echo .
3974 call w1 $i
3975 wysh set i=$? k=$!
3976 vput vexpr j '&' $i 7
3977 echon "<$1/$i/$k "
3978 if [ $j -eq 7 ]
3979 echo .
3981 else
3982 echo ! The end for $1
3984 return $1
3986 # Transport $?/$! up the call chain
3987 define w2 {
3988 echon ">$1 "
3989 vput vexpr i + $1 1
3990 if [ $1 -lt 42 ]
3991 call w2 $i
3992 wysh set i=$? j=$! k=$^ERRNAME
3993 echon "<$1/$i/$k "
3994 return $i $j
3995 else
3996 echo ! The end for $1
3997 return $i $^ERR-BUSY
3999 echoerr au
4001 # Up and down it goes
4002 define w3 {
4003 echon ">$1/$2 "
4004 vput vexpr i + $1 1
4005 if [ $1 -lt 42 ]
4006 call w3 $i $2
4007 wysh set i=$? j=$!
4008 vput vexpr k - $1 $2
4009 if [ $k -eq 21 ]
4010 vput vexpr i + $1 1
4011 vput vexpr j + $2 1
4012 echo "# <$i/$j> .. "
4013 call w3 $i $j
4014 wysh set i=$? j=$!
4016 eval echon "<\$1=\$i/\$^ERRNAME-$j "
4017 return $i $j
4018 else
4019 echo ! The end for $1=$i/$2
4020 if [ "$2" != "" ]
4021 return $i $^ERR-DOM
4022 else
4023 return $i $^ERR-BUSY
4026 echoerr au
4029 call w1 0; echo ?=$? !=$!; echo -----;
4030 call w2 0; echo ?=$? !=$^ERRNAME; echo -----;
4031 call w3 0 1; echo ?=$? !=$^ERRNAME; echo -----;
4032 __EOT
4034 check 1 0 "${MBOX}" '1572045517 5922'
4036 t_epilog "${@}"
4039 t_xcall() {
4040 t_prolog "${@}"
4042 if have_feat cmd-vexpr; then :; else
4043 t_echoskip '[!CMD_VEXPR]'
4044 t_epilog "${@}"
4045 return
4048 ${cat} <<- '__EOT' | \
4049 ${MAILX} ${ARGS} -Snomemdebug \
4050 -Smax=${LOOPS_MAX} \
4051 > "${MBOX}" 2>&1
4052 define work {
4053 echon "$1 "
4054 vput vexpr i + $1 1
4055 if [ $i -le "$max" ]
4056 vput vexpr j '&' $i 7
4057 if [ $j -eq 7 ]
4058 echo .
4060 \xcall work $i $2
4062 echo ! The end for $1/$2
4063 if [ "$2" != "" ]
4064 return $i $^ERR-BUSY
4067 define xwork {
4068 \xcall work 0 $2
4070 call work 0
4071 echo ?=$? !=$!
4072 call xwork
4073 echo ?=$? !=$!
4074 xcall xwork
4075 echo ?=$? !=$^ERRNAME
4077 call work 0 yes
4078 echo ?=$? !=$^ERRNAME
4079 call xwork 0 yes
4080 echo ?=$? !=$^ERRNAME
4081 __EOT
4083 i=${?}
4084 if [ ${LOOPS_MAX} -eq ${LOOPS_BIG} ]; then
4085 check_ex0 1-${LOOPS_BIG} ${i}
4086 check 1-${LOOPS_BIG} - "${MBOX}" '1069764187 47161'
4087 else
4088 check_ex0 1-${LOOPS_SMALL} ${i}
4089 check 1-${LOOPS_SMALL} - "${MBOX}" '859201011 3894'
4094 if have_feat uistrings; then
4095 ${cat} <<- '__EOT' > "${BODY}"
4096 define __w {
4097 echon "$1 "
4098 vput vexpr i + $1 1
4099 if [ $i -le 111 ]
4100 vput vexpr j '&' $i 7
4101 if [ $j -eq 7 ]
4102 echo .
4104 \xcall __w $i $2
4106 echo ! The end for $1
4107 if [ $2 -eq 0 ]
4108 nonexistingcommand
4109 echo would be err with errexit
4110 return
4112 echo calling exit
4113 exit
4115 define work {
4116 echo eins
4117 call __w 0 0
4118 echo zwei, ?=$? !=$!
4119 localopts yes; set errexit
4120 ignerr call __w 0 0
4121 echo drei, ?=$? !=$^ERRNAME
4122 call __w 0 $1
4123 echo vier, ?=$? !=$^ERRNAME, this is an error
4125 ignerr call work 0
4126 echo outer 1, ?=$? !=$^ERRNAME
4127 xxxign call work 0
4128 echo outer 2, ?=$? !=$^ERRNAME, could be error if xxxign non-empty
4129 call work 1
4130 echo outer 3, ?=$? !=$^ERRNAME
4131 echo this is definitely an error
4132 __EOT
4134 < "${BODY}" ${MAILX} ${ARGS} -X'commandalias xxxign ignerr' \
4135 -Snomemdebug > "${MBOX}" 2>&1
4136 check 2 0 "${MBOX}" '4036613316 4184'
4138 < "${BODY}" ${MAILX} ${ARGS} -X'commandalias xxxign " "' \
4139 -Snomemdebug > "${MBOX}" 2>&1
4140 check 3 1 "${MBOX}" '3179757785 2787'
4141 else
4142 t_echoskip '2-3:[!UISTRINGS]'
4145 t_epilog "${@}"
4148 t_vpospar() {
4149 t_prolog "${@}"
4151 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
4152 vpospar set hey, "'you ", world!
4153 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4154 vput vpospar x quote; echo x<$x>
4155 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4156 vput vpospar y quote;echo y<$y>
4157 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4158 eval vpospar set ${y};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4159 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4161 define infun2 {
4162 echo infun2:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
4163 vput vpospar z quote;echo infun2:z<$z>
4166 define infun {
4167 echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
4168 vput vpospar y quote;echo infun:y<$y>
4169 eval vpospar set ${x};echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
4170 vpospar clear;echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
4171 eval call infun2 $x
4172 echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
4173 eval vpospar set ${y};echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
4176 call infun This "in a" fun
4177 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4178 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4179 __EOT
4180 check 1 0 "${MBOX}" '155175639 866'
4183 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
4184 set ifs=\'
4185 echo ifs<$ifs> ifs-ws<$ifs-ws>
4186 vpospar set hey, "'you ", world!
4187 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4188 vput vpospar x quote; echo x<$x>
4189 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4190 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4192 set ifs=,
4193 echo ifs<$ifs> ifs-ws<$ifs-ws>
4194 vpospar set hey, "'you ", world!
4195 unset ifs;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4196 set ifs=,
4197 vput vpospar x quote; echo x<$x>
4198 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4199 eval vpospar set ${x};\
4200 unset ifs;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4202 wysh set ifs=$',\t'
4203 echo ifs<$ifs> ifs-ws<$ifs-ws>
4204 vpospar set hey, "'you ", world!
4205 unset ifs; echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4206 wysh set ifs=$',\t'
4207 vput vpospar x quote; echo x<$x>
4208 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4209 eval vpospar set ${x};\
4210 unset ifs;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4211 __EOT
4212 check ifs 0 "${MBOX}" '2015927702 706'
4214 t_epilog "${@}"
4217 t_atxplode() {
4218 t_prolog "${@}"
4220 ${cat} > ./.t.sh <<- '___'; ${cat} > ./.t.rc <<- '___'
4221 x() { echo $#; }
4222 xxx() {
4223 printf " (1/$#: <$1>)"
4224 shift
4225 if [ $# -gt 0 ]; then
4226 xxx "$@"
4227 else
4228 echo
4231 yyy() {
4232 eval "$@ ' ball"
4234 set --
4235 x "$@"
4236 x "$@"''
4237 x " $@"
4238 x "$@ "
4239 printf yyy;yyy 'xxx' "b\$'\t'u ' "
4240 printf xxx;xxx arg ,b u.
4241 printf xxx;xxx arg , .
4242 printf xxx;xxx arg ,ball.
4244 define x {
4245 echo $#
4247 define xxx {
4248 echon " (1/$#: <$1>)"
4249 shift
4250 if [ $# -gt 0 ]
4251 \xcall xxx "$@"
4252 endif
4253 echo
4255 define yyy {
4256 eval "$@ ' ball"
4258 vpospar set
4259 call x "$@"
4260 call x "$@"''
4261 call x " $@"
4262 call x "$@ "
4263 echon yyy;call yyy '\call xxx' "b\$'\t'u ' "
4264 echon xxx;call xxx arg ,b u.
4265 echon xxx;call xxx arg , .
4266 echon xxx;call xxx arg ,ball.
4269 ${MAILX} ${ARGS} -X'source ./.t.rc' -Xx > "${MBOX}" 2>&1
4270 check 1 0 "${MBOX}" '41566293 164'
4272 #${SHELL} ./.t.sh > ./.tshout 2>&1
4273 #check disproof-1 0 ./.tshout '41566293 164'
4275 t_epilog "${@}"
4278 t_read() {
4279 t_prolog "${@}"
4281 ${cat} <<- '__EOT' > .tin
4282 hey1, "'you ", world!
4283 hey2, "'you ", bugs bunny!
4284 hey3, "'you ",
4285 hey4, "'you "
4286 __EOT
4288 ${cat} <<- '__EOT' |\
4289 ${MAILX} ${ARGS} -X'readctl create ./.tin' > "${MBOX}" 2>&1
4290 commandalias x echo '$?/$^ERRNAME / <$a><$b><$c>'
4291 read a b c;x
4292 read a b c;x
4293 read a b c;x
4294 read a b c;x
4295 unset a b c;read a b c;x
4296 readctl remove ./.tin;echo readctl remove:$?/$^ERRNAME
4297 __EOT
4298 check 1 0 "${MBOX}" '1527910147 173'
4300 ${cat} <<- '__EOT' > .tin2
4301 hey2.0,:"'you ",:world!:mars.:
4302 hey2.1,:"'you ",:world!
4303 hey2.2,:"'you ",:bugs bunny!
4304 hey2.3,:"'you ",:
4305 hey2.4,:"'you ":
4307 __EOT
4309 ${cat} <<- '__EOT' |\
4310 6< .tin2 ${MAILX} ${ARGS} -X 'readctl create 6' > "${MBOX}" 2>&1
4311 commandalias x echo '$?/$^ERRNAME / <$a><$b><$c>'
4312 set ifs=:
4313 read a b c;x
4314 read a b c;x
4315 read a b c;x
4316 read a b c;x
4317 read a b c;x
4318 read a b c;x
4319 unset a b c;read a b c;x
4320 read a b c;x
4321 readctl remove 6;echo readctl remove:$?/$^ERRNAME
4322 __EOT
4323 check ifs 0 "${MBOX}" '890153490 298'
4325 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
4326 commandalias x echo '$?/$^ERRNAME / <$d>'
4327 readctl create .tin
4328 readall d;x
4329 wysh set d;readall d;x
4330 readctl create .tin2
4331 readall d;x
4332 wysh set d;readall d;x
4333 readctl remove .tin;echo $?/$^ERRNAME;\
4334 readctl remove .tin2;echo $?/$^ERRNAME
4335 echo '### now with empty lines'
4336 ! printf 'one line\n\ntwo line\n\n' > ./.temptynl
4337 readctl create .temptynl;echo $?/$^ERRNAME
4338 readall d;x
4339 readctl remove .temptynl;echo $?/$^ERRNAME
4340 __EOT
4341 check readall 0 "${MBOX}" '4113506527 405'
4343 t_epilog "${@}"
4346 t_readsh() { # TODO not enough
4347 t_prolog "${@}"
4349 ${cat} <<- '__EOT' > .tin
4350 from@exam.ple ' diet spliced <from@exam.ple> ' 'a'
4351 from@exam.ple ' diet spliced <from@exam.ple> ' 'a'
4352 from@exam.ple ' diet spliced <from@exam.ple> ''a'
4353 from@exam.ple' diet spliced <from@exam.ple> ''a'
4354 __EOT
4356 ${cat} <<- '__EOT' |\
4357 ${MAILX} ${ARGS} -X'readctl create ./.tin' > "${MBOX}" 2>&1
4358 commandalias x echo '$?/$^ERRNAME / <$a><$b><$c>'
4359 readsh a b c;x
4360 readsh a b c;x
4361 readsh a b c;x
4362 readsh a b c;x
4363 unset a b c;read a b c;x
4364 readctl remove ./.tin;echo readctl remove:$?/$^ERRNAME
4365 __EOT
4366 check 1 0 "${MBOX}" '2955084684 291'
4368 t_epilog "${@}"
4371 t_headerpick() {
4372 t_prolog "${@}"
4374 t__x1_msg > ./.tmbox
4377 </dev/null ${MAILX} ${ARGS} -Rf -Y '# Do not care much on error UISTRINGS
4378 \echo --- 1
4379 \headerpick
4380 \echo --- $?/$^ERRNAME, 2
4381 \type
4382 \echo --- $?/$^ERRNAME, 3
4383 \if "$features" !% +uistrings,
4384 \echoerr reproducible_build: Invalid field name cannot be ignored: ba:l
4385 \endif
4386 \headerpick type ignore \
4387 from_ mail-followup-to in-reply-to DATE MESSAGE-ID STATUS ba:l
4388 \echo --- $?/$^ERRNAME, 4
4389 \if "$features" !% +uistrings,
4390 \echo "#headerpick type retain currently covers no fields"
4391 \endif
4392 \headerpick
4393 \echo --- $?/$^ERRNAME, 5
4394 \type
4395 \echo --- $?/$^ERRNAME, 6
4396 \unheaderpick type ignore from_ DATE STATUS
4397 \echo --- $?/$^ERRNAME, 7
4398 \if "$features" !% +uistrings,
4399 \echo "#headerpick type retain currently covers no fields"
4400 \endif
4401 \headerpick
4402 \echo --- $?/$^ERRNAME, 8
4403 \type
4404 \echo --- $?/$^ERRNAME, 9
4405 \if "$features" =% +uistrings,
4406 \unheaderpick type ignore from_ ba:l
4407 \wysh set x=$? y=$^ERRNAME
4408 \else
4409 \echoerr reproducible_build: Field not ignored: from_
4410 \echoerr reproducible_build: Field not ignored: ba:l
4411 \set x=1 y=INVAL
4412 \endif
4413 \echo --- $x/$y, 10
4414 \unheaderpick type ignore *
4415 \echo --- $?/$^ERRNAME, 11
4416 \if "$features" !% +uistrings,
4417 \echo "#headerpick type retain currently covers no fields"
4418 \echo "#headerpick type ignore currently covers no fields"
4419 \endif
4420 \headerpick
4421 \echo --- $?/$^ERRNAME, 12
4422 \type
4423 \echo --- $?/$^ERRNAME, 13 ---
4424 # ' ./.tmbox >./.tall 2>&1
4425 check 1 0 ./.tall '2481904228 2273'
4428 if have_feat uistrings; then
4429 have_feat regex && i='3515512395 2378' || i='4201290332 2378'
4430 </dev/null ${MAILX} ${ARGS} -Y '#
4431 \headerpick type retain \
4432 bcc cc date from sender subject to \
4433 message-id mail-followup-to reply-to user-agent
4434 \echo --- $?/$^ERRNAME, 1
4435 \headerpick forward retain \
4436 cc date from message-id list-id sender subject to \
4437 mail-followup-to reply-to
4438 \echo --- $?/$^ERRNAME, 2
4439 \headerpick save ignore ^Original-.*$ ^X-.*$ ^DKIM.*$
4440 \echo --- $?/$^ERRNAME, 3
4441 \headerpick top retain To Cc
4442 \echo --- $?/$^ERRNAME, 4 ---
4443 \headerpick
4444 \echo --- $?/$^ERRNAME, 5
4445 \headerpick type
4446 \echo --- $?/$^ERRNAME, 6
4447 \headerpick forward
4448 \echo --- $?/$^ERRNAME, 7
4449 \headerpick save
4450 \echo --- $?/$^ERRNAME, 8
4451 \headerpick top
4452 \echo --- $?/$^ERRNAME, 9 ---
4453 \unheaderpick type retain message-id mail-followup-to reply-to user-agent
4454 \echo --- $?/$^ERRNAME, 10
4455 \unheaderpick save ignore ^X-.*$ ^DKIM.*$
4456 \echo --- $?/$^ERRNAME, 11
4457 \unheaderpick forward retain *
4458 \echo --- $?/$^ERRNAME, 12 ---
4459 \headerpick
4460 \echo --- $?/$^ERRNAME, 13
4461 \headerpick type
4462 \echo --- $?/$^ERRNAME, 14
4463 \headerpick save
4464 \echo --- $?/$^ERRNAME, 15 --
4465 \unheaderpick type retain *
4466 \echo --- $?/$^ERRNAME, 16
4467 \unheaderpick forward retain *
4468 \echo --- $?/$^ERRNAME, 17
4469 \unheaderpick save ignore *
4470 \echo --- $?/$^ERRNAME, 18
4471 \unheaderpick top retain *
4472 \echo --- $?/$^ERRNAME, 19 --
4473 \headerpick
4474 \echo --- $?/$^ERRNAME, 20
4475 # ' >./.tall 2>&1
4476 check 2 0 ./.tall "${i}"
4477 else
4478 t_echoskip '2:[!UISTRINGS]'
4481 t_epilog "${@}"
4483 # }}}
4485 # Send/RFC absolute basics {{{
4486 t_can_send_rfc() { # {{{
4487 t_prolog "${@}"
4489 </dev/null ${MAILX} ${ARGS} -Smta=test://"$MBOX" -s Sub.1 \
4490 receiver@number.1 \
4491 > ./.terr 2>&1
4492 check 1 0 "${MBOX}" '550126528 126'
4493 check 1-err - .terr '4294967295 0'
4495 </dev/null ${MAILX} ${ARGS} -Smta=test://"$MBOX" -s Sub.2 \
4496 -b bcc@no.1 -b bcc@no.2 -b bcc@no.3 \
4497 -c cc@no.1 -c cc@no.2 -c cc@no.3 \
4498 to@no.1 to@no.2 to@no.3 \
4499 > ./.terr 2>&1
4500 check 2 0 "${MBOX}" '3259888945 324'
4501 check 2-err - .terr '4294967295 0'
4503 </dev/null ${MAILX} ${ARGS} -Smta=test://"$MBOX" -s Sub.2no \
4504 -b bcc@no.1\ \ bcc@no.2 -b bcc@no.3 \
4505 -c cc@no.1,cc@no.2 -c cc@no.3 \
4506 to@no.1,to@no.2 to@no.3 \
4507 > ./.terr 2>&1
4508 check 2no 4 "${MBOX}" '3350946897 468'
4509 if have_feat uistrings; then
4510 check 2no-err - .terr '3397557940 190'
4511 else
4512 check 2no-err - .terr '4294967295 0'
4515 # XXX NOTE we cannot test "cc@no1 <cc@no.2>" because our stupid parser
4516 # XXX would not treat that as a list but look for "," as a separator
4517 </dev/null ${MAILX} ${ARGS} -Smta=test://"$MBOX" -Sfullnames -s Sub.3 \
4518 -T 'bcc?single: bcc@no.1, <bcc@no.2>' -T bcc:\ bcc@no.3 \
4519 -T cc?si\ \ :\ \ 'cc@no.1, <cc@no.2>' -T cc:\ cc@no.3 \
4520 -T to?:\ to@no.1,'<to@no.2>' -T to:\ to@no.3 \
4521 > ./.terr 2>&1
4522 check 3 0 "${MBOX}" '1453534480 678'
4523 check 3-err - .terr '4294967295 0'
4525 </dev/null ${MAILX} ${ARGS} -Smta=test://"$MBOX" -Sfullnames -s Sub.4 \
4526 -T 'bcc: bcc@no.1, <bcc@no.2>' -T bcc:\ bcc@no.3 \
4527 -T cc:\ 'cc@no.1, <cc@no.2>' -T cc\ \ :\ \ cc@no.3 \
4528 -T to\ :to@no.1,'<to@no.2>' -T to:\ to@no.3 \
4529 > ./.terr 2>&1
4530 check 4 0 "${MBOX}" '535767201 882'
4531 check 4-err - .terr '4294967295 0'
4533 # Two test with a file-based MTA
4534 "${cat}" <<-_EOT > .tmta.sh
4535 #!${SHELL} -
4536 (echo 'From reproducible_build Wed Oct 2 01:50:07 1996' &&
4537 "${cat}" && echo pardauz && echo) > "${MBOX}"
4538 _EOT
4539 ${chmod} 0755 .tmta.sh
4541 </dev/null ${MAILX} ${ARGS} -Smta=./.tmta.sh -s Sub.mta-1 \
4542 receiver@number.1 > ./.terr 2>&1
4543 check 5 0 "${MBOX}" '2384401657 138'
4544 check 5-err - .terr '4294967295 0'
4546 </dev/null ${MAILX} ${ARGS} -Smta=file://./.tmta.sh -s Sub.mta-2 \
4547 receiver@number.1 > ./.terr 2>&1
4548 check 6 0 "${MBOX}" '3006460737 138'
4549 check 6-err - .terr '4294967295 0'
4551 # Command
4552 </dev/null ${MAILX} ${ARGS} -Smta=test \
4553 -Y '#
4554 mail hey@exam.ple
4555 ~s Subject 1
4556 Body1
4558 echo $?/$^ERRNAME
4560 # ' > ./.tall 2>&1
4561 check 7 0 ./.tall '951018449 138'
4563 ## *record*, *outfolder*, with and without *mta-bcc-ok*
4564 ${mkdir} .tfolder
4565 xfolder=`${pwd}`/.tfolder
4567 "${cat}" <<-_EOT > .tmta.sh
4568 #!${SHELL} -
4569 (echo 'From reproducible_build Wed Oct 2 01:50:07 1996' &&
4570 "${cat}" && echo 'ARGS: '"\${@}" && echo) > "${MBOX}"
4571 _EOT
4572 ${chmod} 0755 .tmta.sh
4574 t_it() {
4575 </dev/null ${MAILX} ${ARGS} -Smta=./.tmta.sh -Sfolder="${xfolder}" \
4576 "${@}" \
4577 -s Sub.mta-1 \
4578 -b bcc@no.1 -b bcc@no.2 -b bcc@no.3 \
4579 -c cc@no.1 -c cc@no.2 -c cc@no.3 \
4580 to@no.1 to@no.2 to@no.3 \
4581 receiver@number.1 > ./.terr 2>&1
4582 return ${?}
4585 t_it -Snomta-bcc-ok
4586 check 8 0 "${MBOX}" '1365032629 292'
4587 check 8-1 - .terr '4294967295 0'
4589 t_it -Snomta-bcc-ok -Srecord=.trec9
4590 check 9 0 "${MBOX}" '1365032629 292'
4591 check 9-1 - .terr '4294967295 0'
4592 check 9-2 - ./.trec9 '160206230 221'
4594 t_it -Srecord=.trec10
4595 check 10 0 "${MBOX}" '3085765596 326'
4596 check 10-1 - .terr '4294967295 0'
4597 check 10-2 - ./.trec10 '160206230 221'
4599 t_it -Snomta-bcc-ok -Srecord=.trec11 -Soutfolder
4600 check 11 0 "${MBOX}" '1365032629 292'
4601 check 11-1 - .terr '4294967295 0'
4602 check 11-2 - ./.tfolder/.trec11 '160206230 221'
4603 # That is appends to an MBOX
4604 t_it -Srecord=.trec11 -Soutfolder
4605 check 12 0 "${MBOX}" '3085765596 326'
4606 check 12-1 - .terr '4294967295 0'
4607 check 12-2 - ./.tfolder/.trec11 '1618754846 442'
4609 ### More RFC cases
4611 ## From: and Sender:
4612 </dev/null ${MAILX} ${ARGS} -s ubject \
4613 -S from=a@b.org,b@b.org,c@c.org -S sender=a@b.org \
4614 to@exam.ple > "${MBOX}" 2>&1
4615 check 13 0 "${MBOX}" '143390417 169'
4617 # ..if From: is single mailbox and Sender: is same, no Sender:
4618 </dev/null ${MAILX} ${ARGS} -s ubject \
4619 -S from=a@b.org -S sender=a@b.org \
4620 to@exam.ple > "${MBOX}" 2>&1
4621 check 14 0 "${MBOX}" '1604962737 135'
4623 t_epilog "${@}"
4624 } # }}}
4626 t_reply() { # {{{
4627 # Alternates and ML related address massage etc. somewhere else
4628 t_prolog "${@}"
4629 XARGS=${ARGS} # TODO v15-compat
4630 ARGS="${ARGS} -Sv15-compat=y"
4632 t__gen_msg subject reply from 1 to 2 cc 2 > "${MBOX}"
4634 ## Base (does not test "recipient record")
4635 t_it() {
4636 </dev/null ${MAILX} ${ARGS} -Rf \
4637 -Y "${2}${1}"'
4640 echo 1:$?/$^ERRNAME
4641 set fullnames escape=!; '${1}'
4642 r2 fullnames
4644 echo 2:$?/$^ERRNAME
4645 set recipients-in-cc nofullnames; '${1}'
4646 r3 recipients-in-cc
4648 echo 3:$?/$^ERRNAME
4649 unset recipients-in-cc; '${1}'
4652 echo 4:$?/$^ERRNAME
4653 #' \
4654 "${MBOX}" > ./.tall 2>&1
4655 return ${?}
4658 t_it reply
4659 check 1 0 ./.tall '4164251531 851'
4660 t_it Reply
4661 check 2 0 ./.tall '3034955332 591'
4662 t_it reply 'set flipr;'
4663 check 3 0 ./.tall '3034955332 591'
4664 t_it Reply 'set flipr;'
4665 check 4 0 ./.tall '4164251531 851'
4667 ## Dig the errors
4668 t__gen_msg subject reply-no-addr > ./.tnoaddr
4670 # MBOX will deduce addressee from From_ line..
4671 </dev/null ${MAILX} ${ARGS} -R -Sescape=! \
4672 -Y '#
4673 File ./.tnoaddr; reply # Takes addressee from From_ line :(
4674 body1
4676 echo 1:$?/$^ERRNAME
4677 File '"${MBOX}"'; set ea=$expandaddr expandaddr=-all; reply
4678 body2
4680 echo 2:$?/$^ERRNAME; set expandaddr=$ea; reply 10 # BADMSG
4681 echo 3:$?/$^ERRNAME; reply # cannot test IO,NOTSUP,INVAL
4682 body3
4684 echo 4:$?/$^ERRNAME
4685 #' \
4686 > ./.tall 2>./.terr
4687 check 5 0 ./.tall '3088217220 382'
4688 if have_feat uistrings; then
4689 check 6 - ./.terr '2514745519 544'
4690 else
4691 t_echoskip '6:[!UISTRINGS]'
4694 # ..but Maildir will not
4695 if have_feat maildir; then
4696 ${mkdir} -p .tdir .tdir/tmp .tdir/cur .tdir/new
4697 ${sed} 1d < ./.tnoaddr > .tdir/new/sillyname
4699 </dev/null ${MAILX} ${ARGS} -R -Sescape=! \
4700 -Y '#
4701 File ./.tdir; reply
4702 body1
4704 echo 1:$?/$^ERRNAME
4705 File '"${MBOX}"'; set ea=$expandaddr expandaddr=-all; reply
4706 body2
4708 echo 2:$?/$^ERRNAME; set expandaddr=$ea; reply 10 # BADMSG
4709 echo 3:$?/$^ERRNAME;reply # cannot test IO,NOTSUP,INVAL
4710 body3
4712 echo 4:$?/$^ERRNAME
4713 #' \
4714 > ./.tall 2>./.terr
4715 check 7 0 ./.tall '3631170341 244'
4716 if have_feat uistrings; then
4717 check 8 - ./.terr '1074346767 629'
4718 else
4719 t_echoskip '8:[!UISTRINGS]'
4723 ## Ensure action on multiple messages
4724 t__gen_msg subject reply2 from from2@exam.ple body body2 >> "${MBOX}"
4726 t_it() {
4727 </dev/null ${MAILX} ${ARGS} -Rf -Sescape=! \
4728 -Y '#
4729 '${1}' 1 2
4730 repbody1
4732 repbody2
4734 echo 1:$?/$^ERRNAME; '${2}' 1 2
4735 Repbody1
4737 echo 2:$?/$^ERRNAME
4738 #' \
4739 "${MBOX}" > ./.tall 2>&1
4740 check ${3} 0 ./.tall '283309820 502'
4741 if [ ${#} -eq 4 ]; then
4742 echo * > ./.tlst
4743 check ${3}-1 - ./.tlst '1649520021 12'
4744 check ${3}-2 - ./from1 '1501109193 347'
4745 check ${3}-3 - ./from2 '2154231432 137'
4749 t_it reply Reply 9
4750 t_it respond Respond 10
4751 t_it followup Followup 11 yes
4752 ${rm} -f from1 from2
4754 ## *record*, *outfolder* (reuses $MBOX)
4755 ${mkdir} .tfolder
4757 t_it() {
4758 </dev/null ${MAILX} ${ARGS} -Rf -Sescape=! -Sfolder=`${pwd}`/.tfolder \
4759 -Y '#
4760 '${1}' 1 2
4761 repbody1
4763 repbody2
4765 echo 1:$?/$^ERRNAME; '${2}' 1 2
4766 Repbody3
4768 echo 2:$?/$^ERRNAME; set record=.trec'${4}'; '${1}' 1 2
4769 repbody4
4771 repbody5
4773 echo 3:$?/$^ERRNAME; '${2}' 1 2
4774 Repbody6
4776 echo 4:$?/$^ERRNAME; set outfolder norecord
4777 '${1}' 1 2
4778 repbody1
4780 repbody2
4782 echo 1:$?/$^ERRNAME; '${2}' 1 2
4783 Repbody3
4785 echo 2:$?/$^ERRNAME; set record=.trec'${4}'; '${1}' 1 2
4786 repbody4
4788 repbody5
4790 echo 3:$?/$^ERRNAME; '${2}' 1 2
4791 Repbody6
4793 echo 4:$?/$^ERRNAME
4794 #' \
4795 "${MBOX}" > ./.tall 2>&1
4796 check ${3} 0 ./.tall '3410330303 2008'
4797 if [ ${#} -ne 5 ]; then
4798 check ${4} - ./.trec${4} '3044885336 484'
4799 check ${4}-1 - ./.tfolder/.trec${4} '3044885336 484'
4800 else
4801 [ -f ./.trec${4} ]; check_exn0 ${4}
4802 echo * > ./.tlst
4803 check ${4}-1 - ./.tlst '1649520021 12'
4804 check ${4}-2 - ./from1 '2668975631 694'
4805 check ${4}-3 - ./from2 '225462887 274'
4806 [ -f ./.tfolder/.trec${4} ]; check_exn0 ${4}-4
4807 ( cd .tfolder && echo * > ./.tlst )
4808 check ${4}-5 - ./.tfolder/.tlst '1649520021 12'
4809 check ${4}-6 - ./.tfolder/from1 '2668975631 694'
4810 check ${4}-7 - ./.tfolder/from2 '225462887 274'
4814 t_it reply Reply 12 13
4815 t_it respond Respond 14 15
4816 t_it followup Followup 16 17 yes
4817 #${rm} -f from1 from2
4819 ## Quoting (if not cmd_escapes related)
4820 ${rm} -f "${MBOX}"
4821 t__x2_msg > ./.tmbox
4823 printf '#
4824 set indentprefix=" |" quote
4825 reply
4828 set quote=noheading quote-inject-head
4829 reply
4832 headerpick type retain cc date from message-id reply-to subject to
4833 set quote=headers
4834 reply
4837 set quote=allheaders
4838 reply
4841 set quote-inject-head=%% quote-inject-tail=%% quote=headers
4842 reply
4845 set quote \\
4846 quote-inject-head='"\$'"'\\
4847 (%%%%a=%%a %%%%d=%%d %%%%f=%%f %%%%i=%%i %%%%n=%%n %%%%r=%%r)\\
4848 \\n'"'"' \\
4849 quote-inject-tail='"\$'"'\\
4850 (%%%%a=%%a %%%%d=%%d %%%%f=%%f %%%%i=%%i %%%%n=%%n %%%%r=%%r)\\
4851 \\n'"'"'
4852 reply
4855 set showname datefield=%%y nodatefield-markout-older indentprefix=\\ :
4856 reply
4859 ' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" -Rf \
4860 -Sescape=! -Sindentprefix=' >' \
4861 ./.tmbox >./.tall 2>&1
4862 check_ex0 18-estat
4863 ${cat} ./.tall >> "${MBOX}"
4864 check 18 - "${MBOX}" '385267528 3926'
4866 # quote-as-attachment, fullnames
4867 </dev/null ${MAILX} ${ARGS} -Rf \
4868 -Sescape=! \
4869 -S quote-as-attachment \
4870 -Y reply -Y yb1 -Y !. \
4871 -Y 'unset quote-as-attachment' \
4872 -Y 'reply;yb2' -Y !. \
4873 -Y 'set quote-as-attachment fullnames' \
4874 -Y ';reply;yb3' -Y !. \
4875 ./.tmbox >./.tall 2>&1
4876 check 19 0 ./.tall '2774517283 2571'
4878 # Moreover, quoting of several parts with all*
4879 t__gen_mimemsg from 'ex1@am.ple' subject for-repl > ./.tmbox
4880 check 20 0 ./.tmbox '1874764424 668'
4882 have_feat filter-html-tagsoup && ck='946925637 1105' || ck='3587432511 1165'
4883 </dev/null ${MAILX} ${ARGS} -Rf \
4884 -Sescape=! -Sindentprefix=' |' \
4885 -Y 'set quote=allheaders' \
4886 -Y reply -Y !. \
4887 -Y 'set quote=allbodies' \
4888 -Y reply -Y !. \
4889 -Y xit \
4890 ./.tmbox >./.tall 2>&1
4891 check 21 0 ./.tall "${ck}"
4893 ARGS=${XARGS} # TODO v15-compat
4894 t_epilog "${@}"
4895 } # }}}
4897 t_forward() { # {{{
4898 t_prolog "${@}"
4899 XARGS=${ARGS}
4900 ARGS="${ARGS} -Sv15-compat=y"
4902 t__gen_msg subject fwd1 body origb1 from 1 to 2 > "${MBOX}"
4903 t__gen_msg subject fwd2 body origb2 from 1 to 1 >> "${MBOX}"
4905 ## Base (does not test "recipient record")
4906 t_it() {
4907 </dev/null ${MAILX} ${ARGS} -Rf \
4908 -Y ${1}' . "du <ex1@am.ple>"
4911 echo 1:$?/$^ERRNAME; echoerr 1:done
4912 set fullnames escape=!
4913 '${1}' 1 "du <ex2@am.ple>"
4914 b2 fullnames
4916 echo 2:$?/$^ERRNAME; echoerr 2:done
4917 # Some errors
4918 set nofullnames ea=$expandaddr expandaddr=-all
4919 '${1}' ` "du <ex3@am.ple>"
4922 echo 3:$?/$^ERRNAME; echoerr 3:done
4923 set expandaddr=$ea
4924 '${1}' ` ex4-nono@am.ple ex4@am.ple # the first is a non-match msglist
4927 echo 4:$?/$^ERRNAME; echoerr 4:done
4928 '${1}' # TODO not yet possible b5 !.
4929 echo 5:$?/$^ERRNAME; echoerr 5:done
4930 set expandaddr=$ea
4931 '${1}' 1 2 ex6@am.ple
4932 b6-1
4934 b6-2
4936 echo 6:$?/$^ERRNAME; echoerr 6:done
4937 set forward-add-cc fullnames
4938 '${1}' . ex7@am.ple
4941 echo 7:$?/$^ERRNAME; echoerr 7:done
4942 set nofullnames
4943 '${1}' . ex8@am.ple
4946 echo 8:$?/$^ERRNAME; echoerr 8:done
4947 #' \
4948 "${MBOX}" > ./.tall 2>./.terr
4949 return ${?}
4952 t_it forward
4953 check 1 0 ./.tall '2356713156 2219'
4954 if have_feat uistrings && have_feat docstrings; then
4955 check 2 - ./.terr '3273108824 335'
4956 else
4957 t_echoskip '2:[!UISTRINGS]'
4960 t_it Forward
4961 check 3 0 ./.tall '2356713156 2219'
4962 if have_feat uistrings && have_feat docstrings; then
4963 check 4 - ./.terr '447176534 355'
4964 else
4965 t_echoskip '4:[!UISTRINGS]'
4967 ${rm} -f ex*
4969 ## *record*, *outfolder* (reuses $MBOX)
4970 ${mkdir} .tfolder
4972 t_it() {
4973 </dev/null ${MAILX} ${ARGS} -Rf -Sescape=! -Sfolder=`${pwd}`/.tfolder \
4974 -Y '#
4975 '${1}' 1 ex1@am.ple
4978 echo 1:$?/$^ERRNAME; set record=.trec'${2}'; '${1}' 1 ex2@am.ple
4981 echo 2:$?/$^ERRNAME; set outfolder norecord; '${1}' 2 ex1@am.ple
4984 echo 3:$?/$^ERRNAME; set record=.trec'${2}'; '${1}' 2 ex2@am.ple
4987 echo 4:$?/$^ERRNAME
4988 #' \
4989 "${MBOX}" > ./.tall 2>&1
4990 check ${2} 0 ./.tall '3180366037 1212'
4991 if [ ${#} -ne 4 ]; then
4992 check ${3}-1 - ./.trec${2} '1769129556 304'
4993 check ${3}-2 - ./.tfolder/.trec${2} '2335391111 284'
4994 else
4995 [ -f ./.trec${2} ]; check_exn0 ${3}
4996 echo * > ./.tlst
4997 check ${3}-1 - ./.tlst '2020171298 8'
4998 check ${3}-2 - ./ex1 '1512529673 304'
4999 check ${3}-3 - ./ex2 '1769129556 304'
5000 [ -f ./.tfolder/.trec${2} ]; check_exn0 ${3}-4
5001 ( cd .tfolder && echo * > ./.tlst )
5002 check ${3}-5 - ./.tfolder/.tlst '2020171298 8'
5003 check ${3}-6 - ./.tfolder/ex1 '2016773910 284'
5004 check ${3}-7 - ./.tfolder/ex2 '2335391111 284'
5008 t_it forward 5 6
5009 t_it Forward 7 8 yes
5010 #${rm} -f ex*
5012 ## Injections, headerpick selection
5013 ${rm} -f "${MBOX}"
5014 t__x2_msg > ./.tmbox
5016 printf '#
5017 set quote=noheading forward-inject-head
5018 forward 1 ex1@am.ple
5021 headerpick forward retain cc from subject to
5022 forward 1 ex1@am.ple
5025 unheaderpick forward retain *
5026 forward 1 ex1@am.ple
5029 headerpick forward ignore in-reply-to reply-to message-id status
5030 set forward-inject-head=%% forward-inject-tail=%%
5031 forward 1 ex1@am.ple
5034 set forward-inject-head='"\$'"'\\
5035 (%%%%a=%%a %%%%d=%%d %%%%f=%%f %%%%i=%%i %%%%n=%%n %%%%r=%%r)\\
5036 \\n'"'"' \\
5037 forward-inject-tail='"\$'"'\\
5038 (%%%%a=%%a %%%%d=%%d %%%%f=%%f %%%%i=%%i %%%%n=%%n %%%%r=%%r)\\
5039 \\n'"'"'
5040 forward 1 ex1@am.ple
5043 set showname datefield=%%y nodatefield-markout-older
5044 forward 1 ex1@am.ple
5047 ' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" -Rf \
5048 -Sescape=! \
5049 ./.tmbox >./.tall 2>&1
5050 check_ex0 9-estat
5051 ${cat} ./.tall >> "${MBOX}"
5052 check 9 - "${MBOX}" '2976943913 2916'
5054 # forward-as-attachment
5055 </dev/null ${MAILX} ${ARGS} -Rf \
5056 -Sescape=! \
5057 -S forward-inject-head=.head. \
5058 -S forward-inject-tail=.tail. \
5059 -S forward-as-attachment \
5060 -Y 'headerpick forward retain subject to from' \
5061 -Y 'forward ex1@am.ple' -Y b1 -Y !. \
5062 -Y 'unset forward-as-attachment' \
5063 -Y 'forward ex1@am.ple;b2' -Y !. \
5064 ./.tmbox >./.tall 2>&1
5065 check 10 0 ./.tall '799103633 1250'
5067 ARGS=${XARGS}
5068 t_epilog "${@}"
5069 } # }}}
5071 t_resend() { # {{{
5072 t_prolog "${@}"
5073 XARGS=${ARGS}
5074 ARGS="${ARGS} -Sv15-compat=y"
5076 t__gen_msg subject fwd1 body origb1 from 1 to 2 > "${MBOX}"
5077 t__gen_msg subject fwd2 body origb2 from 1 to 1 >> "${MBOX}"
5079 ## Base
5080 t_it() {
5081 </dev/null ${MAILX} ${ARGS} -Rf \
5082 -Y ${1}' . "du <ex1@am.ple>"
5083 echo 1:$?/$^ERRNAME; echoerr 1:done
5084 set fullnames escape=!
5085 '${1}' 1 "du , da <ex2@am.ple>"
5086 echo 2:$?/$^ERRNAME; echoerr 2:done
5087 # Some errors
5088 set nofullnames ea=$expandaddr expandaddr=-all
5089 '${1}' ` "du <ex3@am.ple>"
5090 echo 3:$?/$^ERRNAME; echoerr 3:done
5091 set expandaddr=$ea
5092 '${1}' ` ex4-nono@am.ple ex4@am.ple # the first is a non-match msglist
5093 echo 4:$?/$^ERRNAME; echoerr 4:done
5094 '${1}' # TODO not yet possible b5 !.
5095 echo 5:$?/$^ERRNAME; echoerr 5:done
5096 set expandaddr=$ea
5097 '${1}' 1 2 ex6@am.ple
5098 echo 6:$?/$^ERRNAME; echoerr 6:done
5099 #' \
5100 "${MBOX}" > ./.tall 2>./.terr
5101 return ${?}
5104 t_it resend
5105 check 1 0 ./.tall '1461006932 1305'
5106 if have_feat uistrings; then
5107 check 2 - ./.terr '138360532 210'
5108 else
5109 t_echoskip '2:[!UISTRINGS]'
5112 t_it Resend
5113 check 3 0 ./.tall '3674535444 958'
5114 if have_feat uistrings; then
5115 check 4 - ./.terr '138360532 210'
5116 else
5117 t_echoskip '4:[!UISTRINGS]'
5120 ## *record*, *outfolder* (reuses $MBOX)
5121 ${mkdir} .tfolder
5123 t_it() {
5124 </dev/null ${MAILX} ${ARGS} -Rf -Sescape=! -Sfolder=`${pwd}`/.tfolder \
5125 -Y '#
5126 set record=.trec'${2}'; '${1}' 1 ex1@am.ple
5127 echo 1:$?/$^ERRNAME; set record-resent; '${1}' 1 ex2@am.ple
5128 echo 2:$?/$^ERRNAME; set outfolder norecord-resent; '${1}' 2 ex1@am.ple
5129 echo 3:$?/$^ERRNAME; set record-resent; '${1}' 2 ex2@am.ple
5130 echo 4:$?/$^ERRNAME
5131 #' \
5132 "${MBOX}" > ./.tall 2>&1
5133 check_ex0 ${2}
5134 if [ ${#} -ne 3 ]; then
5135 check ${2} - ./.tall '1711347390 992'
5136 check ${3}-1 - ./.trec${2} '2840978700 249'
5137 check ${3}-2 - ./.tfolder/.trec${2} '3219997964 229'
5138 else
5139 check ${2} - ./.tall '1391418931 724'
5140 check ${3}-1 - ./.trec${2} '473817710 182'
5141 check ${3}-2 - ./.tfolder/.trec${2} '2174632404 162'
5145 t_it resend 5 6 yes
5146 t_it Resend 7 8
5148 ARGS=${XARGS}
5149 t_epilog "${@}"
5150 } # }}}
5151 # }}}
5153 # VFS {{{
5154 t_copy() { # {{{
5155 t_prolog "${@}"
5157 t__gen_msg subject Copy1 from 1 to 1 body 'Body1' > "${MBOX}"
5158 t__gen_msg subject Copy2 from 1 to 1 body 'Body2' >> "${MBOX}"
5159 check 1 - "${MBOX}" '137107341 324' # for flag test
5162 </dev/null ${MAILX} ${ARGS} -f \
5163 -Y '#
5164 headers
5165 copy 10 .tf1
5166 echo 0:$?/$^ERRNAME
5167 headers
5168 copy .tf1
5169 echo 1:$?/$^ERRNAME
5170 headers
5171 copy .tf1 # no auto-advance
5172 echo 2:$?/$^ERRNAME
5173 headers
5174 copy 2 .tf2
5175 echo 3:$?/$^ERRNAME
5176 headers
5177 copy 1 2 .tf3
5178 echo 4:$?/$^ERRNAME
5179 headers
5180 !'"${chmod}"' 0444 .tf3
5181 copy 1 2 .tf3
5182 echo 5:$?/$^ERRNAME
5183 #' \
5184 "${MBOX}" > ./.tallx 2>./.terr
5185 check_ex0 2
5187 if have_feat uistrings; then # TODO
5188 ${sed} -e '$bP' -e d -e :P < ./.tallx >> "${ERR}"
5189 ${sed} '$d' < ./.tallx > ./.tall
5190 else
5191 ${mv} ./.tallx ./.tall
5193 if [ -n "${HONOURS_READONLY}" ]; then
5194 n2_1=2-1 cs2_1='1913702840 1121'
5195 n2_4=2-4 cs2_4='3642131968 344'
5196 n2_5=2-5 cs2_5='2617612897 112'
5197 else
5198 n2_1=2-1-nrdonly cs2_1='1962556153 1146'
5199 n2_4=2-4-nrdonly cs2_4='3733058190 688'
5200 n2_5=2-5-nrdonly cs2_5='3989834342 80'
5202 check ${n2_1} - ./.tall "${cs2_1}"
5203 check 2-2 - ./.tf1 '686654461 334'
5204 check 2-3 - ./.tf2 '1931512953 162'
5205 check ${n2_4} - ./.tf3 "${cs2_4}"
5206 if have_feat uistrings; then
5207 check ${n2_5} - ./.terr "${cs2_5}"
5208 else
5209 t_echoskip '2-5:[!UISTRINGS]'
5213 check 3 - "${MBOX}" '1477662071 346'
5216 t_it() {
5217 t__gen_msg subject Copy1 from 1 to 1 body 'Body1' > "${MBOX}"
5218 t__gen_msg subject Copy2 from 1 to 1 body 'Body2' >> "${MBOX}"
5219 t__gen_msg subject Copy3 from ex@am.ple to 1 body 'Body3' >> "${MBOX}"
5220 check ${1} - "${MBOX}" '2667292819 473' # for flag test
5222 </dev/null ${MAILX} ${ARGS} -f \
5223 -Y "${3}"'
5224 '"${2}"'
5225 Copy
5226 echo 1:$?/$^ERRNAME
5227 '"${2}"'
5228 Copy
5229 echo 2:$?/$^ERRNAME
5230 '"${2}"'
5231 Copy 2
5232 echo 3:$?/$^ERRNAME
5233 '"${2}"'
5234 Copy 3
5235 echo 4:$?/$^ERRNAME
5236 '"${2}"'
5237 Copy *
5238 echo 5:$?/$^ERRNAME
5239 '"${2}"'
5240 #' \
5241 "${MBOX}" > ./.tallx 2>&1
5242 return ${?}
5245 t_it 5 headers '#'
5246 check_ex0 5-1
5247 if have_feat uistrings; then # TODO
5248 ${sed} -e '$bP' -e d -e :P < ./.tallx >> "${ERR}"
5249 ${sed} '$d' < ./.tallx > ./.tall
5250 else
5251 ${mv} ./.tallx ./.tall
5253 echo * > ./.tlst
5254 check 5-2 - ./.tlst '1058655452 9'
5255 check 5-3 - ./.tall '1543702808 1617'
5256 check 5-4 - ./from1 '1031912635 999'
5257 check 5-5 - ./ex '2400630246 149'
5258 ${rm} -f ./.tlst ./.tall ./from1 ./ex
5260 ${mkdir} .tfolder
5261 t_it 6 '#' 'set outfolder folder='"`${pwd}`"'/.tfolder'
5262 check_ex0 6-1
5263 if have_feat uistrings; then # TODO
5264 ${sed} -e '$bP' -e d -e :P < ./.tallx >> "${ERR}"
5265 ${sed} '$d' < ./.tallx > ./.tall
5266 else
5267 ${mv} ./.tallx ./.tall
5269 echo * .tfolder/* > ./.tlst
5270 check 6-2 - ./.tlst '1865898363 29'
5271 ${cat} ./.tall >> ${ERR} #check 6-3 - ./.tall # TODO due to folder echoes
5272 check 6-4 - .tfolder/from1 '1031912635 999'
5273 check 6-5 - .tfolder/ex '2400630246 149'
5276 t__x2_msg > ./.tmbox
5278 t_it() {
5279 printf '#
5280 '"${1}"'
5281 echo 1:$?/$^ERRNAME
5282 headerpick save retain cc date from subject to
5283 '"${1}"'
5284 echo 2:$?/$^ERRNAME
5285 unheaderpick save retain *
5286 '"${1}"'
5287 echo 3:$?/$^ERRNAME
5288 headerpick save ignore status in-reply-to
5289 '"${1}"'
5290 echo 4:$?/$^ERRNAME
5291 #' | ${MAILX} ${ARGS} -Rf ./.tmbox > ./.tall 2>&1
5292 return ${?}
5295 t_it 'copy ./.tout'
5296 check_ex0 7-estat
5297 check 7-1 - ./.tall '3805176908 152'
5298 check 7-2 - ./.tout '2447734879 1316'
5300 t_it Copy
5301 check_ex0 8-estat
5302 echo * > ./.tlst
5303 check 8-1 - ./.tall '1044700686 136'
5304 check 8-2 - ./mr2 '2447734879 1316'
5305 check 8-3 - ./.tlst '3190056903 4'
5307 t_epilog "${@}"
5308 } # }}}
5310 t_save() { # {{{
5311 t_prolog "${@}"
5313 t__gen_msg subject Save1 from 1 to 1 body 'Body1' > "${MBOX}"
5314 t__gen_msg subject Save2 from 1 to 1 body 'Body2' >> "${MBOX}"
5315 check 1 - "${MBOX}" '3634443864 324' # for flag test
5318 </dev/null ${MAILX} ${ARGS} -f \
5319 -Y '#
5320 headers
5321 save 10 .tf1
5322 echo 0:$?/$^ERRNAME
5323 headers
5324 save .tf1
5325 echo 1:$?/$^ERRNAME
5326 headers
5327 save .tf1 # no auto-advance
5328 echo 2:$?/$^ERRNAME
5329 headers
5330 save 2 .tf2
5331 echo 3:$?/$^ERRNAME
5332 headers
5333 save 1 2 .tf3
5334 echo 4:$?/$^ERRNAME
5335 headers
5336 !'"${chmod}"' 0444 .tf3
5337 save 1 2 .tf3
5338 echo 5:$?/$^ERRNAME
5339 #' \
5340 "${MBOX}" > ./.tallx 2>./.terr
5341 check_ex0 2
5343 if have_feat uistrings; then # TODO
5344 ${sed} -e '$bP' -e d -e :P < ./.tallx >> "${ERR}"
5345 ${sed} '$d' < ./.tallx > ./.tall
5346 else
5347 ${mv} ./.tallx ./.tall
5349 if [ -n "${HONOURS_READONLY}" ]; then
5350 n2_1=2-1 cs2_1='2335843514 1121'
5351 n2_4=2-4 cs2_4='970407001 344'
5352 n2_5=2-5 cs2_5='45116475 112'
5353 else
5354 n2_1=2-1-nrdonly cs2_1='1736244784 1146'
5355 n2_4=2-4-nrdonly cs2_4='3903872811 688'
5356 n2_5=2-5-nrdonly cs2_5='720724138 80'
5358 check ${n2_1} - ./.tall "${cs2_1}"
5359 check 2-2 - ./.tf1 '2435434321 334'
5360 check 2-3 - ./.tf2 '920652966 162'
5361 check ${n2_4} - ./.tf3 "${cs2_4}"
5362 if have_feat uistrings; then
5363 check ${n2_5} - ./.terr "${cs2_5}"
5364 else
5365 t_echoskip '2-5:[!UISTRINGS]'
5369 check 3 - "${MBOX}" '1219692400 346'
5372 t_it() {
5373 t__gen_msg subject Save1 from 1 to 1 body 'Body1' > "${MBOX}"
5374 t__gen_msg subject Save2 from 1 to 1 body 'Body2' >> "${MBOX}"
5375 t__gen_msg subject Save3 from ex@am.ple to 1 body 'Body3' >> "${MBOX}"
5376 check ${1} - "${MBOX}" '1391391227 473' # for flag test
5378 </dev/null ${MAILX} ${ARGS} -f \
5379 -Y "${3}"'
5380 '"${2}"'
5381 Save
5382 echo 1:$?/$^ERRNAME
5383 '"${2}"'
5384 Save
5385 echo 2:$?/$^ERRNAME
5386 '"${2}"'
5387 Save 2
5388 echo 3:$?/$^ERRNAME
5389 '"${2}"'
5390 Save 3
5391 echo 4:$?/$^ERRNAME
5392 '"${2}"'
5393 Save *
5394 echo 5:$?/$^ERRNAME
5395 '"${2}"'
5396 #' \
5397 "${MBOX}" > ./.tallx 2>&1
5398 return ${?}
5401 t_it 5 headers '#'
5402 check_ex0 5-1
5403 if have_feat uistrings; then # TODO
5404 ${sed} -e '$bP' -e d -e :P < ./.tallx >> "${ERR}"
5405 ${sed} '$d' < ./.tallx > ./.tall
5406 else
5407 ${mv} ./.tallx ./.tall
5409 echo * > ./.tlst
5410 check 5-2 - ./.tlst '1058655452 9'
5411 check 5-3 - ./.tall '3418590770 1617'
5412 check 5-4 - ./from1 '1462882526 999'
5413 check 5-5 - ./ex '2153575326 149'
5414 ${rm} -f ./.tlst ./.tall ./from1 ./ex
5416 ${mkdir} .tfolder
5417 t_it 6 '#' 'set outfolder folder='"`${pwd}`"'/.tfolder'
5418 check_ex0 6-1
5419 if have_feat uistrings; then # TODO
5420 ${sed} -e '$bP' -e d -e :P < ./.tallx >> "${ERR}"
5421 ${sed} '$d' < ./.tallx > ./.tall
5422 else
5423 ${mv} ./.tallx ./.tall
5425 echo * .tfolder/* > ./.tlst
5426 check 6-2 - ./.tlst '1865898363 29'
5427 ${cat} ./.tall >> ${ERR} #check 6-3 - ./.tall # TODO due to folder echoes
5428 check 6-4 - .tfolder/from1 '1462882526 999'
5429 check 6-5 - .tfolder/ex '2153575326 149'
5433 t_it() {
5434 t__x2_msg > ./.tmbox
5435 check ${1} - ./.tmbox '561523988 397'
5437 a='-Rf'
5438 [ ${#} -gt 2 ] && a='-S MBOX=./.tmboxx'
5439 [ ${#} -gt 3 ] && a="${a}"' -S inbox=./.tmbox'
5440 printf '#
5441 headers
5442 '"${2}"'
5443 echo 1:$?/$^ERRNAME
5444 headers
5445 headerpick save retain cc date from subject to
5446 '"${2}"'
5447 echo 2:$?/$^ERRNAME
5448 unheaderpick save retain *
5449 '"${2}"'
5450 echo 3:$?/$^ERRNAME
5451 headerpick save ignore status in-reply-to
5452 '"${2}"'
5453 echo 4:$?/$^ERRNAME
5454 #' | ${MAILX} ${ARGS} -f ${a} ./.tmbox > ./.tall 2>&1
5455 return ${?}
5458 t_it 7 'save ./.tout'
5459 check_ex0 7-estat
5460 check 7-1 - ./.tall '4190949581 312'
5461 check 7-2 - ./.tout '2447734879 1316'
5462 check 7-3 - ./.tmbox '561523988 397'
5464 t_it 8 Save
5465 check_ex0 8-estat
5466 echo * > ./.tlst
5467 check 8-1 - ./.tall '2109832180 296'
5468 check 8-2 - ./mr2 '2447734879 1316'
5469 check 8-3 - ./.tlst '3190056903 4'
5470 check 8-3 - ./.tmbox '561523988 397'
5472 # saves in $MBOX without argument
5473 t_it 9 save yes
5474 check_ex0 9-estat
5475 check 9-1 - ./.tall '652005824 320'
5476 check 9-2 - ./.tmboxx '2447734879 1316'
5477 check 9-3 - ./.tmbox '561523988 397'
5479 # and deletes if editing a primary mailbox
5480 ${rm} -f ./.tmboxx
5481 t_it 10 save yes yes
5482 check_ex0 10-estat
5483 check 10-1 - ./.tall '652005824 320'
5484 check 10-2 - ./.tmboxx '2447734879 1316'
5485 [ -f ./.tmbox ]; check_exn0 10-3
5487 t_epilog "${@}"
5488 } # }}}
5490 t_move() { # {{{
5491 t_prolog "${@}"
5493 t__gen_msg subject Move1 from 1 to 1 body 'Body1' > "${MBOX}"
5494 t__gen_msg subject Move2 from 1 to 1 body 'Body2' >> "${MBOX}"
5495 check 1 - "${MBOX}" '2967134193 324' # for flag test
5498 </dev/null ${MAILX} ${ARGS} -f \
5499 -Y '#
5500 headers
5501 move 10 .tf1
5502 echo 0:$?/$^ERRNAME
5503 headers
5504 move .tf1
5505 echo 1:$?/$^ERRNAME
5506 headers
5507 !touch .tf2; '"${chmod}"' 0444 .tf2
5508 move 2 .tf2
5509 echo 2:$?/$^ERRNAME
5510 !'"${chmod}"' 0644 .tf2
5511 move 2 .tf2
5512 echo 3:$?/$^ERRNAME
5513 headers
5514 #' \
5515 "${MBOX}" > ./.tallx 2>./.terr
5516 check_ex0 2
5518 if have_feat uistrings; then # TODO
5519 ${sed} -e '$bP' -e d -e :P < ./.tallx >> "${ERR}"
5520 ${sed} '$d' < ./.tallx > ./.tall
5521 else
5522 ${mv} ./.tallx ./.tall
5524 if [ -n "${HONOURS_READONLY}" ]; then
5525 n2_1=2-1 cs2_1='1641443074 491'
5526 n2_4=2-4 cs2_4='602144474 155'
5527 else
5528 n2_1=2-1-nrdonly cs2_1='3045412111 492'
5529 n2_4=2-4-nrdonly cs2_4='2197157669 201'
5531 check ${n2_1} - ./.tall "${cs2_1}"
5532 check 2-2 - ./.tf1 '1473857906 162'
5533 check 2-3 - ./.tf2 '331229810 162'
5534 if have_feat uistrings; then
5535 check ${n2_4} - ./.terr "${cs2_4}"
5536 else
5537 t_echoskip '2-4:[!UISTRINGS]'
5541 check 3 - "${MBOX}" '4294967295 0'
5544 t_it() {
5545 t__gen_msg subject Move1 from 1 to 1 body 'Body1' > "${MBOX}"
5546 t__gen_msg subject Move2 from 1 to 1 body 'Body2' >> "${MBOX}"
5547 t__gen_msg subject Move3 from ex@am.ple to 1 body 'Body3' >> "${MBOX}"
5548 check ${1} - "${MBOX}" '2826896131 473' # for flag test
5550 </dev/null ${MAILX} ${ARGS} -f \
5551 -Y "${3}"'
5552 '"${2}"'
5553 Move
5554 echo 1:$?/$^ERRNAME
5555 '"${2}"'
5556 Move 2
5557 echo 2:$?/$^ERRNAME
5558 '"${2}"'
5559 Move 3
5560 echo 3:$?/$^ERRNAME
5561 '"${2}"'
5562 undelete *
5563 echo 4:$?/$^ERRNAME
5564 '"${2}"'
5565 Move *
5566 echo 5:$?/$^ERRNAME
5567 '"${2}"'
5568 #' \
5569 "${MBOX}" > ./.tallx 2>./.terr
5570 return ${?}
5573 t_it 5 headers '#'
5574 check_ex0 5-1
5575 if have_feat uistrings; then # TODO
5576 ${sed} -e '$bP' -e d -e :P < ./.tallx >> "${ERR}"
5577 ${sed} '$d' < ./.tallx > ./.tall
5578 else
5579 ${mv} ./.tallx ./.tall
5581 echo * > ./.tlst
5582 check 5-2 - ./.tlst '1058655452 9'
5583 check 5-3 - ./.tall '419037676 870'
5584 if have_feat uistrings; then
5585 check 5-4 - ./.terr '1383646464 86'
5586 else
5587 t_echoskip '5-4:[!UISTRINGS]'
5589 check 5-5 - ./from1 '3719268580 827'
5590 check 5-6 - ./ex '4262925856 149'
5591 ${rm} -f ./.tlst ./.tall ./.terr ./from1 ./ex
5593 ${mkdir} .tfolder
5594 t_it 6 '#' 'set outfolder folder='"`${pwd}`"'/.tfolder'
5595 check_ex0 6-1
5596 if have_feat uistrings; then # TODO
5597 ${sed} -e '$bP' -e d -e :P < ./.tallx >> "${ERR}"
5598 ${sed} '$d' < ./.tallx > ./.tall
5599 else
5600 ${mv} ./.tallx ./.tall
5602 echo * .tfolder/* > ./.tlst
5603 check 6-2 - ./.tlst '1865898363 29'
5604 ${cat} ./.tall >> ${ERR} #check 6-3 - ./.tall # TODO due to folder echoes
5605 check 6-4 - .tfolder/from1 '3719268580 827'
5606 check 6-5 - .tfolder/ex '4262925856 149'
5609 t__x2_msg > ./.tmbox
5611 t_it() {
5612 printf '#
5613 '"${1}"'
5614 echo 1:$?/$^ERRNAME
5615 headerpick save retain cc date from subject to
5616 '"${1}"'
5617 echo 2:$?/$^ERRNAME
5618 unheaderpick save retain *
5619 '"${1}"'
5620 echo 3:$?/$^ERRNAME
5621 headerpick save ignore status in-reply-to
5622 '"${1}"'
5623 echo 4:$?/$^ERRNAME
5624 #' | ${MAILX} ${ARGS} -Rf ./.tmbox > ./.tall 2>&1
5625 return ${?}
5628 t_it 'move ./.tout'
5629 check_ex0 7-estat
5630 check 7-1 - ./.tall '3805176908 152'
5631 check 7-2 - ./.tout '2447734879 1316'
5633 t_it Move
5634 check_ex0 8-estat
5635 echo * > ./.tlst
5636 check 8-1 - ./.tall '1044700686 136'
5637 check 8-2 - ./mr2 '2447734879 1316'
5638 check 8-3 - ./.tlst '3190056903 4'
5640 t_epilog "${@}"
5641 } # }}}
5643 t_mbox() { # {{{
5644 t_prolog "${@}"
5648 while [ ${i} -lt 113 ]; do
5649 printf 'm file://%s\n~s Subject %s\nHello %s!\n~.\n' \
5650 "${MBOX}" "${i}" "${i}"
5651 i=`add ${i} 1`
5652 done
5653 ) | ${MAILX} ${ARGS} > .tall 2>&1
5654 check 1 0 "${MBOX}" '1785801373 13336'
5655 check 1-outerr - ./.tall '4294967295 0' # empty file
5657 printf 'File "%s"\ncopy * "%s"\nFile "%s"\nfrom*' "${MBOX}" .tmbox1 .tmbox1 |
5658 ${MAILX} ${ARGS} -Sshowlast > .tall 2>&1
5659 check 2 0 .tall '3467540956 8991'
5661 printf 'File "%s"\ncopy * "file://%s"\nFile "file://%s"\nfrom*' \
5662 "${MBOX}" .tmbox2 .tmbox2 | ${MAILX} ${ARGS} -Sshowlast > .tall 2>&1
5663 check 3 0 .tall '2410946529 8998'
5665 # copy only the odd (but the first), move the even
5667 printf 'File "file://%s"\ncopy ' .tmbox2
5669 while [ ${i} -lt 113 ]; do
5670 printf '%s ' "${i}"
5671 i=`add ${i} 2`
5672 done
5673 printf 'file://%s\nFile "file://%s"\nfrom*' .tmbox3 .tmbox3
5674 ) | ${MAILX} ${ARGS} -Sshowlast > .tall 2>&1
5675 check 4 0 .tmbox3 '2554734733 6666'
5676 check 5 - .tall '2062382804 4517'
5677 # ...
5679 printf 'file "file://%s"\nmove ' .tmbox2
5681 while [ ${i} -lt 113 ]; do
5682 printf '%s ' "${i}"
5683 i=`add ${i} 2`
5684 done
5685 printf 'file://%s\nFile "file://%s"\nfrom*\nFile "file://%s"\nfrom*' \
5686 .tmbox3 .tmbox3 .tmbox2
5687 ) | ${MAILX} ${ARGS} -Sshowlast > .tall 2>>${ERR}
5688 check 6 0 .tmbox3 '1429216753 13336'
5689 if have_feat uistrings; then
5690 ${sed} 2d < .tall > .tallx
5691 else
5692 ${cp} .tall .tallx
5694 check 7 - .tallx '169518319 13477'
5696 # Invalid MBOXes (after [f4db93b3])
5697 echo > .tinvmbox
5698 printf 'copy 1 ./.tinvmbox' | ${MAILX} ${ARGS} -Rf "${MBOX}" > .tall 2>&1
5699 check 8 0 .tinvmbox '2848412822 118'
5700 check 9 - ./.tall '461280182 33'
5702 echo ' ' > .tinvmbox
5703 printf 'copy 1 ./.tinvmbox' | ${MAILX} ${ARGS} -Rf "${MBOX}" > .tall 2>&1
5704 check 10 0 .tinvmbox '624770486 120'
5705 check 11 - ./.tall '461280182 33'
5707 { echo; echo; } > .tinvmbox # (not invalid)
5708 printf 'copy 1 ./.tinvmbox' | ${MAILX} ${ARGS} -Rf "${MBOX}" > .tall 2>&1
5709 check 12 0 .tinvmbox '1485640875 119'
5710 check 13 - ./.tall '461280182 33'
5712 # *mbox-rfc4155*, plus
5713 ${cat} <<-_EOT > ./.tinv1
5716 From MAILER-DAEMON-1 Wed Oct 2 01:50:07 1996
5717 Date: Wed, 02 Oct 1996 01:50:07 +0000
5719 Subject: Bad bad message 1
5721 From me to you, blinde Kuh!
5723 From MAILER-DAEMON-2 Wed Oct 2 01:50:07 1996
5724 Date: Wed, 02 Oct 1996 01:50:07 +0000
5726 Subject: Bad bad message 2
5728 From me to you, blindes Kalb!
5729 _EOT
5730 ${cp} ./.tinv1 ./.tinv2
5732 printf \
5733 'define mboxfix {
5734 \\localopts yes; \\wysh set mbox-rfc4155;\\wysh File "${1}";\\
5735 \\eval copy * "${2}"
5737 call mboxfix ./.tinv1 ./.tok' | ${MAILX} ${ARGS} > .tall 2>&1
5738 check_ex0 14-estat
5739 ${cat} ./.tinv1 ./.tok >> .tall
5740 check 14 - ./.tall '739301109 616'
5742 printf \
5743 'wysh file ./.tinv1 # ^From not repaired, but missing trailing NL is
5744 wysh File ./.tok # Just move away to nowhere
5745 set mbox-rfc4155
5746 wysh file ./.tinv2 # Fully repaired
5747 File ./.tok' | ${MAILX} ${ARGS} >>${ERR} 2>&1
5748 check_ex0 15-estat
5749 # Equal since [Auto-fix when MBOX had From_ errors on read (Dr. Werner
5750 # Fink).]
5751 check 15-1 - ./.tinv1 '4151504442 314'
5752 check 15-2 - ./.tinv2 '4151504442 314'
5754 # *mbox-fcc-and-pcc*
5755 ${cat} > ./.ttmpl <<-'_EOT'
5756 Fcc: ./.tfcc1
5757 Bcc: | cat >> ./.tpcc1
5758 Fcc: ./.tfcc2
5759 Subject: fcc and pcc, and *mbox-fcc-and-pcc*
5761 one line body
5762 _EOT
5764 < ./.ttmpl ${MAILX} ${ARGS} -t > "${MBOX}" 2>&1
5765 check 16 0 "${MBOX}" '4294967295 0'
5766 check 17 - ./.tfcc1 '2301294938 148'
5767 check 18 - ./.tfcc2 '2301294938 148'
5768 check 19 - ./.tpcc1 '2301294938 148'
5770 < ./.ttmpl ${MAILX} ${ARGS} -t -Snombox-fcc-and-pcc > "${MBOX}" 2>&1
5771 check 20 0 "${MBOX}" '4294967295 0'
5772 check 21 - ./.tfcc1 '3629108107 98'
5773 check 22 - ./.tfcc2 '3629108107 98'
5774 check 23 - ./.tpcc1 '2373220256 246'
5776 # More invalid: since in "copy * X" messages will be copied in `sort' order,
5777 # reordering may happen, and before ([f5db11fe] (a_cwrite_save1(): FIX:
5778 # ensure pre-v15 MBOX separation "in between" messages.., 2019-08-07) that
5779 # could still have created invalid MBOX files!
5780 ${cat} <<-_EOT > ./.tinv1
5783 From MAILER-DAEMON-4 Sun Oct 4 01:50:07 1998
5784 Date: Sun, 04 Oct 1998 01:50:07 +0000
5785 Subject: h4
5789 From MAILER-DAEMON-0 Fri Oct 28 21:02:21 2147483649
5790 Date: Nix, 01 Oct BAD 01:50:07 +0000
5791 Subject: hinvalid
5793 BINV
5795 From MAILER-DAEMON-3 Fri Oct 3 01:50:07 1997
5796 Date: Fri, 03 Oct 1997 01:50:07 +0000
5797 Subject: h3
5801 From MAILER-DAEMON-1 Sun Oct 1 01:50:07 1995
5802 Date: Sun, 01 Oct 1995 01:50:07 +0000
5803 Subject:h1
5808 From MAILER-DAEMON-2 Wed Oct 2 01:50:07 1996
5809 Date: Wed, 02 Oct 1996 01:50:07 +0000
5810 Subject: h2
5813 _EOT
5815 printf \
5816 'File ./.tinv1
5817 sort date
5818 remove ./.tinv2
5819 copy * ./.tinv2
5820 file ./.tinv1' | ${MAILX} ${ARGS} >>${ERR} 2>&1
5821 check 24 0 ./.tinv1 '104184185 560'
5822 check 25 - ./.tinv2 '853754737 510'
5824 t_epilog "${@}"
5825 } # }}}
5827 t_maildir() { # {{{
5828 t_prolog "${@}"
5830 if have_feat maildir; then :; else
5831 t_echoskip '[!MAILDIR]'
5832 t_epilog "${@}"
5833 return
5838 while [ ${i} -lt 112 ]; do
5839 printf 'm file://%s\n~s Subject %s\nHello %s!\n~.\n' \
5840 "${MBOX}" "${i}" "${i}"
5841 i=`add ${i} 1`
5842 done
5843 ) | ${MAILX} ${ARGS}
5844 check 1 0 "${MBOX}" '2366902811 13332'
5846 printf 'File "%s"
5847 copy * "%s"
5848 File "%s"
5849 from*
5850 ' "${MBOX}" .tmdir1 .tmdir1 |
5851 ${MAILX} ${ARGS} -Snewfolders=maildir -Sshowlast > .tlst
5852 check 2 0 .tlst '3442251309 8991'
5854 printf 'File "%s"
5855 copy * "maildir://%s"
5856 File "maildir://%s"
5857 from*
5858 ' "${MBOX}" .tmdir2 .tmdir2 |
5859 ${MAILX} ${ARGS} -Sshowlast > .tlst
5860 check 3 0 .tlst '3524806062 9001'
5862 printf 'File "maildir://%s"
5863 copy * "file://%s"
5864 File "file://%s"
5865 from*
5866 ' .tmdir2 .tmbox1 .tmbox1 |
5867 ${MAILX} ${ARGS} -Sshowlast > .tlst
5868 check 4 0 .tmbox1 '4096198846 12772'
5869 check 5 - .tlst '1262452287 8998'
5871 # only the odd (even)
5873 printf 'File "maildir://%s"
5874 copy ' .tmdir2
5876 while [ ${i} -lt 112 ]; do
5877 j=`modulo ${i} 2`
5878 [ ${j} -eq 1 ] && printf '%s ' "${i}"
5879 i=`add ${i} 1`
5880 done
5881 printf ' file://%s
5882 File "file://%s"
5883 from*
5884 ' .tmbox2 .tmbox2
5885 ) | ${MAILX} ${ARGS} -Sshowlast > .tlst
5886 check 6 0 .tmbox2 '4228337024 6386'
5887 check 7 - .tlst '2078821439 4517'
5888 # ...
5890 printf 'file "maildir://%s"
5891 move ' .tmdir2
5893 while [ ${i} -lt 112 ]; do
5894 j=`modulo ${i} 2`
5895 [ ${j} -eq 0 ] && [ ${i} -ne 0 ] && printf '%s ' "${i}"
5896 i=`add ${i} 1`
5897 done
5898 printf ' file://%s
5899 File "file://%s"
5900 from*
5901 File "maildir://%s"
5902 from*
5903 ' .tmbox2 .tmbox2 .tmdir2
5904 ) | ${MAILX} ${ARGS} -Sshowlast > .tlst
5905 check 8 0 .tmbox2 '978751761 12656'
5906 ${sed} 2d < .tlst > .tlstx
5907 check 9 - .tlstx '2172297531 13477'
5909 # More invalid: since in "copy * X" messages will be copied in `sort' order,
5910 # reordering may happen, and before ([f5db11fe] (a_cwrite_save1(): FIX:
5911 # ensure pre-v15 MBOX separation "in between" messages.., 2019-08-07) that
5912 # could still have created invalid MBOX files!
5913 ${cat} <<-_EOT > ./.tinv1
5916 From MAILER-DAEMON-4 Sun Oct 4 01:50:07 1998
5917 Date: Sun, 04 Oct 1998 01:50:07 +0000
5918 Subject: h4
5922 From MAILER-DAEMON-0 Fri Oct 28 21:02:21 2147483649
5923 Date: Nix, 01 Oct BAD 01:50:07 +0000
5924 Subject: hinvalid
5926 BINV
5928 From MAILER-DAEMON-3 Fri Oct 3 01:50:07 1997
5929 Date: Fri, 03 Oct 1997 01:50:07 +0000
5930 Subject: h3
5934 From MAILER-DAEMON-1 Sun Oct 1 01:50:07 1995
5935 Date: Sun, 01 Oct 1995 01:50:07 +0000
5936 Subject:h1
5941 From MAILER-DAEMON-2 Wed Oct 2 01:50:07 1996
5942 Date: Wed, 02 Oct 1996 01:50:07 +0000
5943 Subject: h2
5946 _EOT
5948 printf \
5949 'File ./.tinv1
5950 sort date
5951 copy * maildir://./.tmdir10
5952 !{ for f in ./.tmdir10/new/*; do echo ===; %s $f; done; } > ./.t11
5953 File ./.tmdir10
5954 sort date
5955 copy * ./.t10warp
5956 ' "${cat}" | ${MAILX} ${ARGS} >>${ERR} 2>&1
5957 # Note that substdate() fixes all but one From_ line to $SOURCE_DATE_EPOCH!
5958 check 10 0 ./.t10warp '3551111321 502'
5959 check 11 - ./.t11 '642719592 302'
5961 t_epilog "${@}"
5962 } # }}}
5963 # }}}
5965 # MIME and RFC basics {{{
5966 t_mime_if_not_ascii() {
5967 t_prolog "${@}"
5969 </dev/null ${MAILX} ${ARGS} -s Subject "${MBOX}" >> "${MBOX}" 2>&1
5970 check 1 0 "${MBOX}" '3647956381 106'
5972 </dev/null ${MAILX} ${ARGS} -Scharset-7bit=not-ascii -s Subject "${MBOX}" \
5973 >> "${MBOX}" 2>&1
5974 check 2 0 "${MBOX}" '3964303752 274'
5976 t_epilog "${@}"
5979 t_mime_encoding() {
5980 t_prolog "${@}"
5982 # 8B
5983 printf 'Hey, you.\nFrom me to you\nCiao\n' |
5984 ${MAILX} ${ARGS} -s Subject -Smime-encoding=8b "${MBOX}" \
5985 >> "${MBOX}" 2>&1
5986 check 1 0 "${MBOX}" '3835153597 136'
5987 printf 'Hey, you.\n\nFrom me to you\nCiao.\n' |
5988 ${MAILX} ${ARGS} -s Subject -Smime-encoding=8b "${MBOX}" \
5989 >> "${MBOX}" 2>&1
5990 check 2 0 "${MBOX}" '63875210 275'
5992 # QP
5993 printf 'Hey, you.\n From me to you\nCiao\n' |
5994 ${MAILX} ${ARGS} -s Subject -Smime-encoding=qp "${MBOX}" \
5995 >> "${MBOX}" 2>&1
5996 check 3 0 "${MBOX}" '465798521 412'
5997 printf 'Hey, you.\nFrom me to you\nCiao\n' |
5998 ${MAILX} ${ARGS} -s Subject -Smime-encoding=qp "${MBOX}" \
5999 >> "${MBOX}" 2>&1
6000 check 4 0 "${MBOX}" '2075263697 655'
6002 # B64
6003 printf 'Hey, you.\n From me to you\nCiao\n' |
6004 ${MAILX} ${ARGS} -s Subject -Smime-encoding=b64 "${MBOX}" \
6005 >> "${MBOX}" 2>&1
6006 check 5 0 "${MBOX}" '601672771 792'
6007 printf 'Hey, you.\nFrom me to you\nCiao\n' |
6008 ${MAILX} ${ARGS} -s Subject -Smime-encoding=b64 "${MBOX}" \
6009 >> "${MBOX}" 2>&1
6010 check 6 0 "${MBOX}" '3926760595 1034'
6012 t_epilog "${@}"
6015 t_xxxheads_rfc2047() {
6016 t_prolog "${@}"
6018 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
6019 -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̲' \
6020 "${MBOX}"
6021 check 1 0 "${MBOX}" '3422562347 371'
6023 # Single word (overlong line split -- bad standard! Requires injection of
6024 # artificial data!! But can be prevented by using RFC 2047 encoding)
6025 ${rm} "${MBOX}"
6026 i=`${awk} 'BEGIN{for(i=0; i<92; ++i) printf "0123456789_"}'`
6027 echo | ${MAILX} ${ARGS} -s "${i}" "${MBOX}"
6028 check 2 0 "${MBOX}" '3317256266 1714'
6030 # Combination of encoded words, space and tabs of varying sort
6031 ${rm} "${MBOX}"
6032 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
6033 -s "1Abrä Kaspas1 2Abra Katä b_kaspas2 \
6034 3Abrä Kaspas3 4Abrä Kaspas4 5Abrä Kaspas5 \
6035 6Abra Kaspas6 7Abrä Kaspas7 8Abra Kaspas8 \
6036 9Abra Kaspastäb4-3 10Abra Kaspas1 _ 11Abra Katäb1 \
6037 12Abra Kadabrä1 After Tab after Täb this is NUTS" \
6038 "${MBOX}"
6039 check 3 0 "${MBOX}" '786672837 587'
6041 # Overlong multibyte sequence that must be forcefully split
6042 # todo This works even before v15.0, but only by accident
6043 ${rm} "${MBOX}"
6044 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
6045 -s "✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
6046 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
6047 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄" \
6048 "${MBOX}"
6049 check 4 0 "${MBOX}" '2889557767 655'
6051 # Trailing WS
6052 ${rm} "${MBOX}"
6053 echo | ${MAILX} ${ARGS} \
6054 -s "1-1 B2 B3 B4 B5 B6 B\
6055 1-2 B2 B3 B4 B5 B6 B\
6056 1-3 B2 B3 B4 B5 B6 B\
6057 1-4 B2 B3 B4 B5 B6 B\
6058 1-5 B2 B3 B4 B5 B6 B\
6059 1-6 B2 B3 B4 B5 B6 " \
6060 "${MBOX}"
6061 check 5 0 "${MBOX}" '3135161683 293'
6063 # Leading and trailing WS
6064 ${rm} "${MBOX}"
6065 echo | ${MAILX} ${ARGS} \
6066 -s " 2-1 B2 B3 B4 B5 B6 B\
6067 1-2 B2 B3 B4 B5 B6 B\
6068 1-3 B2 B3 B4 B5 B6 B\
6069 1-4 B2 B3 B4 B5 B6 " \
6070 "${MBOX}"
6071 check 6 0 "${MBOX}" '3221845405 232'
6073 # RFC 2047 in an address field! (Missing test caused v14.9.6!)
6074 ${rm} "${MBOX}"
6075 echo "Dat Früchtchen riecht häußlich" |
6076 ${MAILX} ${ARGS} ${ADDARG_UNI} -Sfullnames -Smta=test://"$MBOX" \
6077 -s Hühöttchen \
6078 'Schnödes "Früchtchen" <do@du> (Hä!)'
6079 check 7 0 "${MBOX}" '3681801246 373'
6081 # RFC 2047 in an address field, and iconv involved
6082 if have_feat iconv; then
6083 ${rm} "${MBOX}"
6084 ${cat} > ./.trebox <<_EOT
6085 From zaza@exam.ple Fri Mar 2 21:31:56 2018
6086 Date: Fri, 2 Mar 2018 20:31:45 +0000
6087 From: z=?iso-8859-1?Q?=E1?=za <zaza@exam.ple>
6088 To: dude <dude@exam.ple>
6089 Subject: houston(...)
6090 Message-ID: <abra@1>
6091 MIME-Version: 1.0
6092 Content-Type: text/plain; charset=iso-8859-1
6093 Content-Disposition: inline
6094 Content-Transfer-Encoding: 8bit
6096 _EOT
6097 echo reply | ${MAILX} ${ARGS} ${ADDARG_UNI} \
6098 -Sfullnames -Sreply-in-same-charset \
6099 -Smta=test://"$MBOX" -Rf ./.trebox
6100 check 8 0 "${MBOX}" '3499372945 285'
6101 else
6102 t_echoskip '8:[!ICONV]'
6105 t_epilog "${@}"
6108 t_iconv_mbyte_base64() { # TODO uses sed(1) and special *headline*!!
6109 t_prolog "${@}"
6111 if [ -n "${UTF8_LOCALE}" ] && have_feat multibyte-charsets &&
6112 have_feat iconv; then
6113 if (</dev/null iconv -f ascii -t iso-2022-jp) >/dev/null 2>&1 ||
6114 (</dev/null iconv -f ascii -t euc-jp) >/dev/null 2>&1; then
6116 else
6117 t_echoskip '[ICONV/iconv(1):missing conversion(s)]'
6118 t_epilog "${@}"
6119 return
6121 else
6122 t_echoskip '[no UTF-8 locale or !MULTIBYTE-CHARSETS or !ICONV]'
6123 t_epilog "${@}"
6124 return
6127 if (</dev/null iconv -f ascii -t iso-2022-jp) >/dev/null 2>&1; then
6128 ${cat} <<-'_EOT' | LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} \
6129 -Smta=test://"$MBOX" \
6130 -Sescape=! -Smime-encoding=base64 2>./.terr
6131 set ttycharset=utf-8 sendcharsets=iso-2022-jp
6132 m t1@exam.ple
6133 !s Japanese from UTF-8 to ISO-2022-JP
6134 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
6136 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
6139 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
6141 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
6144 set ttycharset=iso-2022-jp charset-7bit=iso-2022-jp sendcharsets=utf-8
6145 m t2@exam.ple
6146 !s Japanese from ISO-2022-JP to UTF-8, eh, no, also ISO-2022-JP
6147 \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
6149 \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
6152 \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
6154 \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
6156 _EOT
6157 # May not presume iconv output as long as roundtrip possible [489a7122]
6158 check_ex0 1-estat
6159 ${awk} 'BEGIN{h=1}/^$/{++h;next}{if(h % 2 == 1)print}' \
6160 < "${MBOX}" > ./.tcksum
6161 check 1 - ./.tcksum '3314001564 516'
6162 check 2 - ./.terr '4294967295 0'
6164 printf 'eval f 1; eval write ./.twrite; eval type 1; eval type 2\n' |
6165 LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} \
6166 -S headline="%>%a%m %-18f %-16d %i%-s" \
6167 -Rf "${MBOX}" >./.tlog 2>&1
6168 check 3 0 ./.twrite '1259742080 686'
6169 #check 4 - ./.tlog '3214068822 2123'
6170 ${sed} -e '/^\[-- M/d' < ./.tlog > ./.txlog
6171 check 4 - ./.txlog '4083300132 2030'
6172 else
6173 t_echoskip '1-4:[ICONV/iconv(1):ISO-2022-JP unsupported]'
6176 if (</dev/null iconv -f ascii -t euc-jp) >/dev/null 2>&1; then
6177 ${rm} -f "${MBOX}" ./.twrite
6178 ${cat} <<-'_EOT' | LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} \
6179 -Smta=test://"$MBOX" \
6180 -Sescape=! -Smime-encoding=base64 2>./.terr
6181 set ttycharset=utf-8 sendcharsets=euc-jp
6182 m t1@exam.ple
6183 !s Japanese from UTF-8 to EUC-JP
6184 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
6186 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
6189 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
6191 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
6194 set ttycharset=EUC-JP sendcharsets=utf-8
6195 m t2@exam.ple
6196 !s Japanese from EUC-JP to UTF-8
6197 ¥·¥¸¥å¥¦¥«¥é²Ê¡Ê¥·¥¸¥å¥¦¥«¥é¤«¡¢³Ø̾ Paridae¡Ë¤Ï¡¢Ä»Îॹ¥º¥áÌܤβʤǤ¢¤ë¡£¥·¥¸¥å¥¦¥«¥é¡Ê»Í½½¿ý¡Ë¤ÈÁí¾Î¤µ¤ì¤ë¤¬¡¢¶¹µÁ¤Ë¤Ï¤³¤Î1¼ï¤ò¥·¥¸¥å¥¦¥«¥é¤È¸Æ¤Ö¡£
6199 ¥«¥ó¥à¥ê¥¬¥é¡Ê³Ø̾Parus cristatus¡Ë¤Ï¡¢¥¹¥º¥áÌÜ¥·¥¸¥å¥¦¥«¥é²Ê¤ËʬÎव¤ì¤ëÄ»Îà¤Î°ì¼ï¡£
6202 ¥«¥ó¥à¥ê¥¬¥é¡Ê³Ø̾Parus cristatus¡Ë¤Ï¡¢¥¹¥º¥áÌÜ¥·¥¸¥å¥¦¥«¥é²Ê¤ËʬÎव¤ì¤ëÄ»Îà¤Î°ì¼ï¡£
6204 ¥·¥¸¥å¥¦¥«¥é²Ê¡Ê¥·¥¸¥å¥¦¥«¥é¤«¡¢³Ø̾ Paridae¡Ë¤Ï¡¢Ä»Îॹ¥º¥áÌܤβʤǤ¢¤ë¡£¥·¥¸¥å¥¦¥«¥é¡Ê»Í½½¿ý¡Ë¤ÈÁí¾Î¤µ¤ì¤ë¤¬¡¢¶¹µÁ¤Ë¤Ï¤³¤Î1¼ï¤ò¥·¥¸¥å¥¦¥«¥é¤È¸Æ¤Ö¡£
6206 _EOT
6207 check_ex0 5-estat
6208 ${awk} 'BEGIN{h=1}/^$/{++h;next}{if(h % 2 == 1)print}' \
6209 < "${MBOX}" > ./.tcksum
6210 check 5 - ./.tcksum '1754179361 469'
6211 check 6 - ./.terr '4294967295 0'
6213 printf 'eval f 1; eval write ./.twrite; eval type 1; eval type 2\n' |
6214 LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} \
6215 -S headline="%>%a%m %-18f %-16d %i%-s" \
6216 -Rf "${MBOX}" >./.tlog 2>&1
6217 check 7 0 ./.twrite '1259742080 686'
6218 #check 8 - ./.tlog '2506063395 2075'
6219 ${sed} -e '/^\[-- M/d' < ./.tlog > ./.txlog
6220 check 8 - ./.txlog '3192017734 1983'
6221 else
6222 t_echoskip '5-8:[ICONV/iconv(1):EUC-JP unsupported]'
6225 t_epilog "${@}"
6228 t_iconv_mainbody() {
6229 t_prolog "${@}"
6231 if [ -n "${UTF8_LOCALE}" ] && have_feat iconv; then :; else
6232 t_echoskip '[no UTF-8 locale or !ICONV]'
6233 t_epilog "${@}"
6234 return
6237 printf '–' | ${MAILX} ${ARGS} ${ADDARG_UNI} -Smta=test://"$MBOX" \
6238 -S charset-7bit=us-ascii -S charset-8bit=utf-8 \
6239 -s '–' over-the@rain.bow 2>./.terr
6240 check 1 0 "${MBOX}" '3559538297 250'
6241 check 2 - ./.terr '4294967295 0'
6243 printf '–' | ${MAILX} ${ARGS} ${ADDARG_UNI} -Smta=test://"$MBOX" \
6244 -S charset-7bit=us-ascii -S charset-8bit=us-ascii \
6245 -s '–' over-the@rain.bow 2>./.terr
6246 check_exn0 3
6247 check 3 - "${MBOX}" '3559538297 250'
6248 if have_feat uistrings; then
6249 check 4 - ./.terr '271380835 121'
6250 else
6251 t_echoskip '4:[!UISTRINGS]'
6254 # The different iconv(3) implementations use different replacement sequence
6255 # types (character-wise, byte-wise, and the character(s) used differ)
6256 i="${MAILX_ICONV_MODE}"
6257 if [ -n "${i}" ]; then
6258 printf 'p\nx\n' | ${MAILX} ${ARGS} -Rf "${MBOX}" >./.tout 2>./.terr
6259 j=${?}
6260 check_ex0 5-1-estat ${j}
6261 check 5-1 - ./.terr '4294967295 0'
6262 if [ ${i} -eq 13 ]; then
6263 check 5-2 - ./.tout '189327996 283' # XXX old (before test MTA)
6264 elif [ ${i} -eq 12 ]; then
6265 check 5-3 - ./.tout '1959197095 283' # XXX old (before test MTA)
6266 elif [ ${i} -eq 3 ]; then
6267 check 5-4 - ./.tout '3544755786 278'
6268 else
6269 check 5-5 - ./.tout '2381160335 278'
6271 else
6272 t_echoskip '5:[test unsupported]'
6275 t_epilog "${@}"
6278 t_binary_mainbody() {
6279 t_prolog "${@}"
6281 printf 'abra\0\nka\r\ndabra' |
6282 ${MAILX} ${ARGS} ${ADDARG_UNI} -s 'binary with carriage-return!' \
6283 "${MBOX}" 2>./.terr
6284 check 1 0 "${MBOX}" '1629827 239'
6285 check 2 - ./.terr '4294967295 0'
6287 printf 'p\necho\necho writing now\nwrite ./.twrite\n' |
6288 ${MAILX} ${ARGS} -Rf \
6289 -Spipe-application/octet-stream="?* ${cat} > ./.tcat" \
6290 "${MBOX}" >./.tall 2>&1
6291 check 3 0 ./.tall '733582513 319'
6292 check 4 - ./.tcat '3817108933 15'
6293 check 5 - ./.twrite '3817108933 15'
6295 t_epilog "${@}"
6298 t_mime_force_sendout() {
6299 t_prolog "${@}"
6301 if have_feat iconv; then :; else
6302 t_echoskip '[!ICONV]'
6303 t_epilog "${@}"
6304 return
6307 printf '\150\303\274' > ./.tmba
6308 printf 'ha' > ./.tsba
6309 printf '' > "${MBOX}"
6311 printf '\150\303\244' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
6312 -s nogo \
6313 over-the@rain.bow 2>>${ERR}
6314 check 1 4 "${MBOX}" '4294967295 0'
6316 printf '\150\303\244' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
6317 -s go -Smime-force-sendout \
6318 over-the@rain.bow 2>>${ERR}
6319 check 2 0 "${MBOX}" '1866273282 219'
6321 printf ha | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
6322 -s nogo \
6323 -a ./.tmba over-the@rain.bow 2>>${ERR}
6324 check 3 4 "${MBOX}" '1866273282 219'
6326 printf ha | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
6327 -s go -Smime-force-sendout \
6328 -a ./.tmba over-the@rain.bow 2>>${ERR}
6329 check 4 0 "${MBOX}" '644433809 880'
6331 printf ha | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
6332 -s nogo \
6333 -a ./.tsba -a ./.tmba over-the@rain.bow 2>>${ERR}
6334 check 5 4 "${MBOX}" '644433809 880'
6336 printf ha | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
6337 -s go -Smime-force-sendout \
6338 -a ./.tsba -a ./.tmba over-the@rain.bow 2>>${ERR}
6339 check 6 0 "${MBOX}" '3172365123 1729'
6341 printf '\150\303\244' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
6342 -s nogo \
6343 -a ./.tsba -a ./.tmba over-the@rain.bow 2>>${ERR}
6344 check 7 4 "${MBOX}" '3172365123 1729'
6346 printf '\150\303\244' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
6347 -s go -Smime-force-sendout \
6348 -a ./.tsba -a ./.tmba over-the@rain.bow 2>>${ERR}
6349 check 8 0 "${MBOX}" '4002905306 2565'
6351 t_epilog "${@}"
6354 t_C_opt_customhdr() {
6355 t_prolog "${@}"
6357 echo bla |
6358 ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
6359 -C 'C-One : Custom One Body' \
6360 -C 'C-Two:CustomTwoBody' \
6361 -C 'C-Three: CustomThreeBody ' \
6362 -S customhdr='chdr1: chdr1 body, chdr2:chdr2 body, chdr3: chdr3 body ' \
6363 this-goes@nowhere >./.tall 2>&1
6364 check_ex0 1-estat
6365 ${cat} ./.tall >> "${MBOX}"
6366 check 1 0 "${MBOX}" '2535463301 238'
6368 ${rm} "${MBOX}"
6369 printf 'm this-goes@nowhere\nbody\n!.
6370 unset customhdr
6371 m this-goes2@nowhere\nbody2\n!.
6372 set customhdr=%ccustom1 : custom1 body%c
6373 m this-goes3@nowhere\nbody3\n!.
6374 set customhdr=%ccustom1 : custom1\\, body , \\
6375 custom2: custom2 body , custom-3 : custom3 body ,\\
6376 custom-4:custom4-body %c
6377 m this-goes4@nowhere\nbody4\n!.
6378 ' "'" "'" "'" "'" |
6379 ${MAILX} ${ARGS} -Smta=test://"$MBOX" -Sescape=! \
6380 -C 'C-One : Custom One Body' \
6381 -C 'C-Two:CustomTwoBody' \
6382 -C 'C-Three: CustomThreeBody ' \
6383 -C ' C-Four:CustomFourBody ' \
6384 -C 'C-Five:CustomFiveBody' \
6385 -S customhdr='ch1: b1 , ch2:b2, ch3:b3 ,ch4:b4, ch5: b5 ' \
6386 >./.tall 2>&1
6387 check_ex0 2-estat
6388 ${cat} ./.tall >> "${MBOX}"
6389 check 2 0 "${MBOX}" '544085062 1086'
6391 t_epilog "${@}"
6393 # }}}
6395 # Operational basics with trivial tests {{{
6396 t_alias() {
6397 t_prolog "${@}"
6399 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" > ./.tall 2>&1
6400 alias a1 ex1@a1.ple
6401 alias a1 ex2@a1.ple "EX3 <ex3@a1.ple>"
6402 alias a1 ex4@a1.ple
6403 alias a2 ex1@a2.ple ex2@a2.ple ex3@a2.ple ex4@a2.ple
6404 alias a3 a4
6405 alias a4 a5 ex1@a4.ple
6406 alias a5 a6
6407 alias a6 a7 ex1@a6.ple
6408 alias a7 a8
6409 alias a8 ex1@a8.ple
6410 alias a1
6411 alias a2
6412 alias a3
6413 m a1
6414 ~c a2
6415 ~b a3
6416 ~r - '_EOT'
6417 This body is!
6418 This also body is!!
6419 _EOT
6420 __EOT
6421 check 1 0 "${MBOX}" '139467786 277'
6422 check 2 - .tall '1598893942 133'
6424 if have_feat uistrings; then
6425 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
6426 commandalias x echo '$?/$^ERRNAME'
6427 echo 1
6428 alias a:bra! ha@m beb@ra ha@m '' zeb@ra ha@m; x
6429 alias a:bra!; x
6430 alias ha@m ham-expansion ha@m '';x
6431 alias ha@m;x
6432 alias beb@ra ceb@ra beb@ra1;x
6433 alias beb@ra;x
6434 alias ceb@ra ceb@ra1;x
6435 alias ceb@ra;x
6436 alias deb@ris '';x
6437 alias deb@ris;x
6438 echo 2
6439 alias - a:bra!;x
6440 alias - ha@m;x
6441 alias - beb@ra;x
6442 alias - ceb@ra;x
6443 alias - deb@ris;x
6444 echo 3
6445 unalias ha@m;x
6446 alias - a:bra!;x
6447 unalias beb@ra;x
6448 alias - a:bra!;x
6449 echo 4
6450 unalias*;x;alias;x
6451 echo 5
6452 \alias noexpa@and this@error1;x
6453 \alias ha@m '\noexp@and' expa@and \\noexp@and2;x
6454 \alias ha@m;x
6455 \alias - ha@m;x
6456 \alias noexpa@and2 this@error2;x
6457 \alias expa1@and this@error3;x
6458 \alias expa@and \\expa1@and;x
6459 \alias expa@and;x
6460 \alias - ha@m;x
6461 \alias - expa@and;x
6462 __EOT
6463 check 3 0 "${MBOX}" '1513155156 796'
6464 else
6465 t_echoskip '3:[!UISTRINGS]'
6468 # TODO t_alias: n_ALIAS_MAXEXP is compile-time constant,
6469 # TODO need to somehow provide its contents to the test, then test
6471 t_epilog "${@}"
6474 t_charsetalias() {
6475 t_prolog "${@}"
6477 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
6478 commandalias x echo '$?/$^ERRNAME'
6479 echo 1
6480 charsetalias latin1 latin15;x
6481 charsetalias latin1;x
6482 charsetalias - latin1;x
6483 echo 2
6484 charsetalias cp1252 latin1 latin15 utf8 utf8 utf16;x
6485 charsetalias cp1252;x
6486 charsetalias latin15;x
6487 charsetalias utf8;x
6488 echo 3
6489 charsetalias - cp1252;x
6490 charsetalias - latin15;x
6491 charsetalias - utf8;x
6492 echo 4
6493 charsetalias latin1;x
6494 charsetalias - latin1;x
6495 uncharsetalias latin15;x
6496 charsetalias latin1;x
6497 charsetalias - latin1;x
6498 __EOT
6499 check 1 0 "${MBOX}" '3551595280 433'
6501 t_epilog "${@}"
6504 t_shortcut() {
6505 t_prolog "${@}"
6507 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
6508 commandalias x echo '$?/$^ERRNAME'
6509 echo 1
6510 shortcut file1 expansion-of-file1;x
6511 shortcut file2 expansion-of-file2;x
6512 shortcut file3 expansion-of-file3;x
6513 shortcut file4 'expansion of file4' 'file 5' 'expansion of file5';x
6514 echo 2
6515 shortcut file1;x
6516 shortcut file2;x
6517 shortcut file3;x
6518 shortcut file4;x
6519 shortcut 'file 5';x
6520 echo 3
6521 shortcut;x
6522 __EOT
6523 check 1 0 "${MBOX}" '1970515669 430'
6525 t_epilog "${@}"
6528 t_netrc() {
6529 t_prolog "${@}"
6531 if have_feat netrc; then :; else
6532 t_echoskip '[!NETRC]'
6533 t_epilog "${@}"
6534 return
6537 printf '# comment
6538 machine x.local login a1 machine x.local login a2 password p2
6539 machine x.local login a3 password "p 3"
6540 machine
6541 pop.x.local
6542 login
6544 password
6545 p2-pop!
6546 machine *.x.local login a2 password p2-any!
6547 machine y.local login ausr password apass
6548 machine
6549 z.local password
6550 noupa
6551 # and unused default
6552 default login defacc password defpass
6553 ' > ./.tnetrc
6554 ${chmod} 0600 ./.tnetrc
6556 printf 'netrc;echo =$?;netrc c;echo =$?;netr loa;echo =$?;netr s;echo =$?' |
6557 NETRC=./.tnetrc ${MAILX} ${ARGS} > "${MBOX}" 2>&1
6558 check 1 0 "${MBOX}" '2911708535 542'
6560 have_feat uistrings && i='3076722625 893' || i='3808149439 645'
6561 printf '# Comment
6562 echo ==host
6563 netrc loo x.local
6564 netrc loo y.local
6565 netrc loo z.local
6566 echo ==(re)load cache
6567 netrc load;echo $?/$^ERRNAME
6568 echo ==usr@host
6569 netrc loo a1@x.local
6570 netrc loo a2@x.local
6571 netrc loo a3@x.local
6572 netrc loo a4@x.local
6573 echo ==clear cache
6574 netrc clear;echo $?/$^ERRNAME
6575 echo ==usr@x.host
6576 netrc loo a2@pop.x.local
6577 netrc loo a2@imap.x.local
6578 netrc loo a2@smtp.x.local
6579 echo ==usr@y.x.host
6580 netrc loo a2@nono.smtp.x.local
6581 echo ==[usr@]unknown-host
6582 netrc loo a.local
6583 netrc loo defacc@a.local
6584 netrc loo a1@a.local
6585 ' | NETRC=./.tnetrc ${MAILX} ${ARGS} > "${MBOX}" 2>&1
6586 check 2 0 "${MBOX}" "${i}"
6588 t_epilog "${@}"
6590 # }}}
6592 # Operational basics with easy tests {{{
6593 t_expandaddr() {
6594 # after: t_alias
6595 # MTA alias specific part in t_mta_aliases()
6596 # This only tests from command line, rest later on (iff any)
6597 t_prolog "${@}"
6599 if have_feat uistrings; then :; else
6600 t_echoskip '[!UISTRINGS]'
6601 t_epilog "${@}"
6602 return
6605 echo "${cat}" > ./.tcat
6606 ${chmod} 0755 ./.tcat
6609 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6610 -X'alias talias talias@exam.ple' \
6611 './.tfile' ' | ./.tcat > ./.tpipe' 'talias' 'taddr@exam.ple' \
6612 > ./.tall 2>&1
6613 check 1 4 "${MBOX}" '1216011460 138'
6614 check 2 - .tall '4169590008 162'
6617 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6618 -Sexpandaddr \
6619 -X'alias talias talias@exam.ple' \
6620 './.tfile' ' | ./.tcat >./.tpipe' 'talias' 'taddr@exam.ple' \
6621 > ./.tall 2>&1
6622 check 3 0 "${MBOX}" '847567042 276'
6623 check 4 - .tall '4294967295 0'
6624 check 5 - .tfile '1216011460 138'
6625 check 6 - .tpipe '1216011460 138'
6628 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6629 -Sexpandaddr=-all,+file,+pipe,+name,+addr \
6630 -X'alias talias talias@exam.ple' \
6631 './.tfile' ' | ./.tcat >./.tpipe' 'talias' 'taddr@exam.ple' \
6632 > ./.tall 2>&1
6633 check 7 0 "${MBOX}" '3682360102 414'
6634 check 8 - .tall '4294967295 0'
6635 check 9 - .tfile '847567042 276'
6636 check 10 - .tpipe '1216011460 138'
6639 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6640 -Sexpandaddr=-all,+file,-file,+pipe,+name,+addr \
6641 -X'alias talias talias@exam.ple' \
6642 './.tfile' ' | ./.tcat >./.tpipe' 'talias' 'taddr@exam.ple' \
6643 > ./.tall 2>&1
6644 check 11 4 "${MBOX}" '1010907786 552'
6645 check 12 - .tall '673208446 70'
6646 check 13 - .tfile '847567042 276'
6647 check 14 - .tpipe '1216011460 138'
6649 printf '' > ./.tpipe
6650 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6651 -Sexpandaddr=fail,-all,+file,-file,+pipe,+name,+addr \
6652 -X'alias talias talias@exam.ple' \
6653 './.tfile' ' | ./.tcat >./.tpipe' 'talias' 'taddr@exam.ple' \
6654 > ./.tall 2>&1
6655 check 15 4 "${MBOX}" '1010907786 552'
6656 check 16 - .tall '3280630252 179'
6657 check 17 - .tfile '847567042 276'
6658 check 18 - .tpipe '4294967295 0'
6661 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6662 -Sexpandaddr=-all,+file,+pipe,-pipe,+name,+addr \
6663 -X'alias talias talias@exam.ple' \
6664 './.tfile' ' | ./.tcat >./.tpipe' 'talias' 'taddr@exam.ple' \
6665 > ./.tall 2>&1
6666 check 19 4 "${MBOX}" '3359494254 690'
6667 check 20 - .tall '4052857227 91'
6668 check 21 - .tfile '3682360102 414'
6669 check 22 - .tpipe '4294967295 0'
6671 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6672 -Sexpandaddr=fail,-all,+file,+pipe,-pipe,+name,+addr \
6673 -X'alias talias talias@exam.ple' \
6674 './.tfile' ' | ./.tcat >./.tpipe' 'talias' 'taddr@exam.ple' \
6675 > ./.tall 2>&1
6676 check 23 4 "${MBOX}" '3359494254 690'
6677 check 24 - .tall '2168069102 200'
6678 check 25 - .tfile '3682360102 414'
6679 check 26 - .tpipe '4294967295 0'
6682 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6683 -Sexpandaddr=-all,+file,+pipe,+name,-name,+addr \
6684 -X'alias talias talias@exam.ple' \
6685 './.tfile' ' | ./.tcat >./.tpipe' 'talias' 'taddr@exam.ple' \
6686 > ./.tall 2>&1
6687 check 27 0 "${MBOX}" '3735108703 828'
6688 check 28 - .tall '4294967295 0'
6689 check 29 - .tfile '1010907786 552'
6690 check 30 - .tpipe '1216011460 138'
6692 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6693 -Sexpandaddr=-all,+file,+pipe,+name,-name,+addr \
6694 './.tfile' ' | ./.tcat >./.tpipe' 'talias' 'taddr@exam.ple' \
6695 > ./.tall 2>&1
6696 check 31 4 "${MBOX}" '4225234603 949'
6697 check 32 - .tall '3486613973 73'
6698 check 33 - .tfile '452731060 673'
6699 check 34 - .tpipe '1905076731 121'
6701 printf '' > ./.tpipe
6702 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6703 -Sexpandaddr=fail,-all,+file,+pipe,+name,-name,+addr \
6704 './.tfile' ' | ./.tcat >./.tpipe' 'talias' 'taddr@exam.ple' \
6705 > ./.tall 2>&1
6706 check 35 4 "${MBOX}" '4225234603 949'
6707 check 36 - .tall '3032065285 182'
6708 check 37 - .tfile '452731060 673'
6709 check 38 - .tpipe '4294967295 0'
6712 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6713 -Sexpandaddr=-all,+file,+pipe,+name,+addr,-addr \
6714 -X'alias talias talias@exam.ple' \
6715 './.tfile' ' | ./.tcat >./.tpipe' 'talias' 'taddr@exam.ple' \
6716 > ./.tall 2>&1
6717 check 39 4 "${MBOX}" '4225234603 949'
6718 check 40 - .tall '3863610168 169'
6719 check 41 - .tfile '1975297706 775'
6720 check 42 - .tpipe '130065764 102'
6722 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6723 -Sexpandaddr=-all,+file,+pipe,+name,+addr,-addr \
6724 -Sadd-file-recipients \
6725 -X'alias talias talias@exam.ple' \
6726 './.tfile' ' | ./.tcat >./.tpipe' 'talias' 'taddr@exam.ple' \
6727 > ./.tall 2>&1
6728 check 43 4 "${MBOX}" '4225234603 949'
6729 check 44 - .tall '3863610168 169'
6730 check 45 - .tfile '3291831864 911'
6731 check 46 - .tpipe '4072000848 136'
6733 printf '' > ./.tpipe
6734 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6735 -Sexpandaddr=fail,-all,+file,+pipe,+name,+addr,-addr \
6736 -Sadd-file-recipients \
6737 -X'alias talias talias@exam.ple' \
6738 './.tfile' ' | ./.tcat >./.tpipe' 'talias' 'taddr@exam.ple' \
6739 > ./.tall 2>&1
6740 check 47 4 "${MBOX}" '4225234603 949'
6741 check 48 - .tall '851041772 278'
6742 check 49 - .tfile '3291831864 911'
6743 check 50 - .tpipe '4294967295 0'
6746 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6747 -Sexpandaddr=-all,+addr \
6748 'taddr@exam.ple' 'this@@c.example' \
6749 > ./.tall 2>&1
6750 check 51 4 "${MBOX}" '473729143 1070'
6751 check 52 - .tall '2646392129 66'
6753 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6754 -Sexpandaddr=-all,failinvaddr \
6755 'taddr@exam.ple' 'this@@c.example' \
6756 > ./.tall 2>&1
6757 check 53 4 "${MBOX}" '473729143 1070'
6758 check 54 - .tall '887391555 175'
6761 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6762 -Sthis=taddr@exam.ple -Sexpandaddr \
6763 -c '\$this' -b '\$this' '\$this' \
6764 > ./.tall 2>&1
6765 check 55 4 "${MBOX}" '473729143 1070'
6766 check 56 - .tall '1144578880 139'
6768 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6769 -Sthis=taddr@exam.ple -Sexpandaddr=shquote \
6770 -c '\$this' -b '\$this' '\$this' \
6771 > ./.tall 2>&1
6772 check 57 0 "${MBOX}" '398243793 1191'
6773 check 58 - .tall '4294967295 0'
6776 printf '' > "${MBOX}"
6777 ${cat} <<-_EOT |\
6778 ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -t -ssub \
6779 -Sadd-file-recipients \
6780 -Sexpandaddr=-all,+fcc \
6781 > ./.tall 2>&1
6782 Fcc: .tfile1
6783 Fcc: .tfile2
6784 _EOT
6785 check 59 0 "${MBOX}" '4294967295 0'
6786 check 60 - .tall '4294967295 0'
6787 check 61 - .tfile1 '1067276522 124'
6788 check 62 - .tfile2 '1067276522 124'
6790 printf '' > "${MBOX}"
6791 ${cat} <<-_EOT |\
6792 ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -t -ssub \
6793 -Sadd-file-recipients \
6794 -Sexpandaddr=-all,+file \
6795 > ./.tall 2>&1
6796 Fcc: .tfile1
6797 Fcc: .tfile2
6798 _EOT
6799 check 63 0 "${MBOX}" '4294967295 0'
6800 check 64 - .tall '4294967295 0'
6801 check 65 - .tfile1 '2677253527 248'
6802 check 66 - .tfile2 '2677253527 248'
6804 printf '' > "${MBOX}"
6805 ${cat} <<-_EOT |\
6806 ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -t -ssub \
6807 -Sadd-file-recipients \
6808 -Sexpandaddr=-all,+file,-fcc \
6809 > ./.tall 2>&1
6810 Fcc: .tfile1
6811 Fcc: .tfile2
6812 _EOT
6813 check 67 0 "${MBOX}" '4294967295 0'
6814 check 68 - .tall '4294967295 0'
6815 check 69 - .tfile1 '3493511004 372'
6816 check 70 - .tfile2 '3493511004 372'
6818 printf '' > "${MBOX}"
6819 ${cat} <<-_EOT |\
6820 ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -t -ssub \
6821 -Sadd-file-recipients \
6822 -Sexpandaddr=-all,+fcc,-file \
6823 > ./.tall 2>&1
6824 Fcc: .tfile1
6825 Fcc: .tfile2
6826 _EOT
6827 check 71 4 "${MBOX}" '4294967295 0'
6828 check 72 - .tall '203687556 223'
6829 check 73 - .tfile1 '3493511004 372'
6830 check 74 - .tfile2 '3493511004 372'
6832 printf '' > "${MBOX}"
6833 ${cat} <<-_EOT |\
6834 ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -t -ssub \
6835 -Sadd-file-recipients \
6836 -Sexpandaddr=-all,fail,+addr \
6837 > ./.tall 2>&1
6838 Fcc: .tfile1
6839 Fcc: .tfile2
6840 To: never@exam.ple
6841 _EOT
6842 check 75 4 "${MBOX}" '4294967295 0'
6843 check 76 - .tall '4060426468 247'
6844 check 77 - .tfile1 '3493511004 372'
6845 check 78 - .tfile2 '3493511004 372'
6848 printf '' > "${MBOX}"
6849 ${cat} <<-_EOT |\
6850 ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -t -ssub \
6851 -Sexpandaddr=fail,domaincheck \
6852 > ./.tall 2>&1
6853 To: one@localhost
6854 _EOT
6855 check 79 0 "${MBOX}" '171635532 120'
6856 check 80 - .tall '4294967295 0'
6858 ${cat} <<-_EOT |\
6859 ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -t -ssub \
6860 -Sexpandaddr=domaincheck \
6861 > ./.tall 2>&1
6862 To: one@localhost , Hey two <two@exam.ple>, Trouble <three@tro.uble>
6863 _EOT
6864 check 81 4 "${MBOX}" '2659464839 240'
6865 check 82 - .tall '1119895397 158'
6867 ${cat} <<-_EOT |\
6868 ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -t -ssub \
6869 -Sexpandaddr=fail,domaincheck \
6870 > ./.tall 2>&1
6871 To: one@localhost , Hey two <two@exam.ple>, Trouble <three@tro.uble>
6872 _EOT
6873 check 83 4 "${MBOX}" '2659464839 240'
6874 check 84 - .tall '1577313789 267'
6876 ${cat} <<-_EOT |\
6877 ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -t -ssub \
6878 -Sexpandaddr=fail,domaincheck \
6879 -Sexpandaddr-domaincheck=exam.ple,tro.uble \
6880 > ./.tall 2>&1
6881 To: one@localhost , Hey two <two@exam.ple>, Trouble <three@tro.uble>
6882 _EOT
6883 check 85 0 "${MBOX}" '1670655701 410'
6884 check 86 - .tall '4294967295 0'
6886 t_epilog "${@}"
6889 t_mta_aliases() {
6890 # after: t_expandaddr
6891 t_prolog "${@}"
6893 if have_feat mta-aliases; then :; else
6894 t_echoskip '[!MTA_ALIASES]'
6895 t_epilog "${@}"
6896 return
6899 ${cat} > ./.tali <<- '__EOT'
6901 # Comment
6904 a1: ex1@a1.ple ,
6905 ex2@a1.ple, <ex3@a1.ple> ,
6906 ex4@a1.ple
6907 a2: ex1@a2.ple , ex2@a2.ple,a2_2
6908 a2_2:ex3@a2.ple,ex4@a2.ple
6909 a3: a4
6910 a4: a5,
6911 # Comment
6912 # More comment
6913 ex1@a4.ple
6914 # Comment
6915 a5: a6
6916 a6: a7 , ex1@a6.ple
6917 a7: a8,a9
6918 a8: ex1@a8.ple
6919 __EOT
6921 echo | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
6922 -Smta-aliases=./.tali \
6923 -b a3 -c a2 a1 > ./.tall 2>&1
6924 check 1 0 "${MBOX}" '1172368381 238'
6925 check 2 - .tall '4294967295 0'
6927 ## xxx The following are actually *expandaddr* tests!!
6929 # May not send plain names over SMTP!
6930 mtaali=
6931 if have_feat smtp; then
6932 echo | ${MAILX} ${ARGS} \
6933 -Smta=smtp://laber.backe -Ssmtp-auth=none \
6934 -Smta-aliases=./.tali \
6935 -b a3 -c a2 a1 > ./.tall 2>&1
6936 check_exn0 3
6937 check 4 - "${MBOX}" '1172368381 238'
6938 mtaali=1
6940 if [ -n "${mtaali}" ] && have_feat uistrings; then
6941 check 5 - .tall '771616226 179'
6942 else
6943 t_echoskip '5:[!SMTP/!UISTRINGS]'
6946 # xxx for false-positive SMTP test we would need some mocking
6947 echo | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
6948 -Sexpandaddr=fail,-name \
6949 -Smta-aliases=./.tali \
6950 -b a3 -c a2 a1 > ./.tall 2>&1
6951 check_exn0 6
6952 check 7 - "${MBOX}" '1172368381 238'
6953 if have_feat uistrings; then
6954 check 8 - .tall '2834389894 178'
6955 else
6956 t_echoskip '8:[!UISTRINGS]'
6959 echo | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
6960 -Sexpandaddr=-name \
6961 -Smta-aliases=./.tali \
6962 -b a3 -c a2 a1 > ./.tall 2>&1
6963 check 9 4 "${MBOX}" '2322273994 472'
6964 if have_feat uistrings; then
6965 check 10 - .tall '2136559508 69'
6966 else
6967 t_echoskip '10:[!UISTRINGS]'
6970 echo 'a9:nine@nine.nine' >> ./.tali
6972 echo | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
6973 -Sexpandaddr=fail,-name \
6974 -Smta-aliases=./.tali \
6975 -b a3 -c a2 a1 > ./.tall 2>&1
6976 check 11 0 "${MBOX}" '2422268299 722'
6977 check 12 - .tall '4294967295 0'
6979 printf '#
6980 set expandaddr=-name
6981 mail a1
6982 !c a2
6983 !:echo $?/$^ERRNAME
6984 !^header insert bcc a3
6985 !:echo $?/$^ERRNAME
6986 !:set expandaddr
6987 !t a1
6988 !c a2
6989 !:echo $?/$^ERRNAME
6990 !^header insert bcc a3
6991 !:echo $?/$^ERRNAME
6993 echo and, once again, check that cache is updated
6994 # Enclose one pipe in quotes: immense stress for our stupid address parser:(
6995 !echo "a10:./.tf1,|%s>./.tp1,\\"|%s > ./.tp2\\",./.tf2" >> ./.tali
6996 mtaaliases load
6997 mail a1
6998 !c a2
6999 !:echo $?/$^ERRNAME
7000 !^header insert bcc a3
7001 !:echo $?/$^ERRNAME
7003 echo trigger happiness
7004 mail a1
7005 !c a2
7006 !:echo $?/$^ERRNAME
7007 !^header insert bcc "a3 a10"
7008 !:echo $?/$^ERRNAME
7010 ' "${cat}" "${cat}" | ${MAILX} ${ARGS} -Smta=test://"$MBOX" -Sescape=! \
7011 -Smta-aliases=./.tali \
7012 > ./.tall 2>&1
7013 check 13 0 "${MBOX}" '550955032 1469'
7014 if have_feat uistrings; then
7015 check 14 - .tall '1795496020 473'
7016 else
7017 t_echoskip '14:[!UISTRINGS]'
7019 check 15 - .tf1 '3056269950 249'
7020 check 16 - .tp1 '3056269950 249'
7021 check 17 - .tp2 '3056269950 249'
7022 check 18 - .tf2 '3056269950 249'
7024 # TODO t_mta_aliases: n_ALIAS_MAXEXP is compile-time constant,
7025 # TODO need to somehow provide its contents to the test, then test
7027 t_epilog "${@}"
7030 t_filetype() {
7031 t_prolog "${@}"
7033 printf 'm m1@e.t\nL1\nHy1\n~.\nm m2@e.t\nL2\nHy2\n~@ %s\n~.\n' \
7034 "${TOPDIR}snailmail.jpg" | ${MAILX} ${ARGS} -Smta=test://"$MBOX"
7035 check 1 0 "${MBOX}" '1314354444 13536'
7037 if (echo | gzip -c) >/dev/null 2>&1; then
7039 printf 'File "%s"\ncopy 1 ./.t.mbox.gz\ncopy 2 ./.t.mbox.gz' \
7040 "${MBOX}" | ${MAILX} ${ARGS} \
7041 -X'filetype gz gzip\ -dc gzip\ -c'
7042 printf 'File ./.t.mbox.gz\ncopy * ./.t.mbox\n' |
7043 ${MAILX} ${ARGS} -X'filetype gz gzip\ -dc gzip\ -c'
7044 } > ./.t.out 2>&1
7045 check 2 - ./.t.mbox '1314354444 13536'
7046 check 3 - ./.t.out '635961640 103'
7047 else
7048 t_echoskip '2:[missing gzip(1)]'
7049 t_echoskip '3:[missing gzip(1)]'
7053 ${rm} ./.t.mbox*
7054 printf 'File "%s"\ncopy 1 ./.t.mbox.gz
7055 copy 2 ./.t.mbox.gz
7056 copy 1 ./.t.mbox.gz
7057 copy 2 ./.t.mbox.gz
7058 ' "${MBOX}" |
7059 ${MAILX} ${ARGS} \
7060 -X'filetype gz gzip\ -dc gzip\ -c' \
7061 -X'filetype mbox.gz "${sed} 1,3d|${cat}" \
7062 "echo eins;echo zwei;echo und mit ${sed} bist Du dabei;${cat}"'
7063 printf 'File ./.t.mbox.gz\ncopy * ./.t.mbox\n' |
7064 ${MAILX} ${ARGS} \
7065 -X'filetype gz gzip\ -dc gzip\ -c' \
7066 -X'filetype mbox.gz "${sed} 1,3d|${cat}" kill\ 0'
7067 } > ./.t.out 2>&1
7068 check 4 - ./.t.mbox '2687765142 27092'
7069 check 5 - ./.t.out '2230192693 173'
7071 t_epilog "${@}"
7074 t_e_H_L_opts() {
7075 t_prolog "${@}"
7077 touch ./.t.mbox
7078 ${MAILX} ${ARGS} -ef ./.t.mbox
7079 echo ${?} > "${MBOX}"
7081 printf 'm me@exam.ple\nLine 1.\nHello.\n~.\n' |
7082 ${MAILX} ${ARGS} -Smta=test://./.t.mbox
7083 printf 'm you@exam.ple\nLine 1.\nBye.\n~.\n' |
7084 ${MAILX} ${ARGS} -Smta=test://./.t.mbox
7086 ${MAILX} ${ARGS} -ef ./.t.mbox 2>> "${MBOX}"
7087 echo ${?} >> "${MBOX}"
7088 ${MAILX} ${ARGS} -efL @t@me ./.t.mbox 2>> "${MBOX}"
7089 echo ${?} >> "${MBOX}"
7090 ${MAILX} ${ARGS} -efL @t@you ./.t.mbox 2>> "${MBOX}"
7091 echo ${?} >> "${MBOX}"
7092 ${MAILX} ${ARGS} -efL '@>@Line 1' ./.t.mbox 2>> "${MBOX}"
7093 echo ${?} >> "${MBOX}"
7094 ${MAILX} ${ARGS} -efL '@>@Hello.' ./.t.mbox 2>> "${MBOX}"
7095 echo ${?} >> "${MBOX}"
7096 ${MAILX} ${ARGS} -efL '@>@Bye.' ./.t.mbox 2>> "${MBOX}"
7097 echo ${?} >> "${MBOX}"
7098 ${MAILX} ${ARGS} -efL '@>@Good bye.' ./.t.mbox 2>> "${MBOX}"
7099 echo ${?} >> "${MBOX}"
7101 ${MAILX} ${ARGS} -fH ./.t.mbox >> "${MBOX}" 2>&1
7102 echo ${?} >> "${MBOX}"
7103 ${MAILX} ${ARGS} -fL @t@me ./.t.mbox >> "${MBOX}" 2>&1
7104 echo ${?} >> "${MBOX}"
7105 ${MAILX} ${ARGS} -fL @t@you ./.t.mbox >> "${MBOX}" 2>&1
7106 echo ${?} >> "${MBOX}"
7107 ${MAILX} ${ARGS} -fL '@>@Line 1' ./.t.mbox >> "${MBOX}" 2>&1
7108 echo ${?} >> "${MBOX}"
7109 ${MAILX} ${ARGS} -fL '@>@Hello.' ./.t.mbox >> "${MBOX}" 2>&1
7110 echo ${?} >> "${MBOX}"
7111 ${MAILX} ${ARGS} -fL '@>@Bye.' ./.t.mbox >> "${MBOX}" 2>&1
7112 echo ${?} >> "${MBOX}"
7113 ${MAILX} ${ARGS} -fL '@>@Good bye.' ./.t.mbox >> "${MBOX}" 2>>${ERR}
7114 echo ${?} >> "${MBOX}"
7116 check 1 - "${MBOX}" '1369201287 670'
7120 printf 'm me1@exam.ple\n~s subject cab\nLine 1.\n~.\n' |
7121 ${MAILX} ${ARGS} -Smta=test://./.t.mbox \
7122 -r '' -X 'wysh set from=pony1@$LOGNAME'
7123 printf 'm me2@exam.ple\n~s subject bac\nLine 12.\n~.\n' |
7124 ${MAILX} ${ARGS} -Smta=test://./.t.mbox \
7125 -r '' -X 'wysh set from=pony2@$LOGNAME'
7126 printf 'm me3@exam.ple\n~s subject abc\nLine 123.\n~.\n' |
7127 ${MAILX} ${ARGS} -Smta=test://./.t.mbox \
7128 -r '' -X 'wysh set from=pony3@$LOGNAME'
7130 ${MAILX} ${ARGS} -S folder-hook=fh-test -X 'define fh-test {
7131 echo fh-test size; set autosort=size showname showto
7132 }' -fH ./.t.mbox > "${MBOX}" 2>&1
7133 check 2 0 "${MBOX}" '4286438644 413'
7135 ${MAILX} ${ARGS} -S folder-hook=fh-test -X 'define fh-test {
7136 echo fh-test subject; set autosort=subject showname showto
7137 }' -fH ./.t.mbox > "${MBOX}" 2>&1
7138 check 3 0 "${MBOX}" '3208053922 416'
7140 ${MAILX} ${ARGS} -S folder-hook=fh-test -X 'define fh-test {
7141 echo fh-test from; set autosort=from showto
7142 }' -fH ./.t.mbox > "${MBOX}" 2>&1
7143 check 4 0 "${MBOX}" '4209767839 413'
7145 ${MAILX} ${ARGS} -S folder-hook=fh-test -X 'define fh-test {
7146 echo fh-test to; set autosort=to showto
7147 }' -fH ./.t.mbox > "${MBOX}" 2>&1
7148 check 5 0 "${MBOX}" '2785342736 411'
7150 t_epilog "${@}"
7153 t_q_t_etc_opts() {
7154 # Simple, if we need more here, place in a later vim fold!
7155 t_prolog "${@}"
7157 # Three tests for MIME encoding and (a bit) content classification.
7158 # At the same time testing -q FILE, < FILE and -t FILE
7159 t__put_body > ./.tin
7161 < ./.tin ${MAILX} ${ARGS} ${ADDARG_UNI} \
7162 -a ./.tin -s "`t__put_subject`" "${MBOX}"
7163 check 1 0 "${MBOX}" '1088822685 6642'
7165 ${rm} "${MBOX}"
7166 < /dev/null ${MAILX} ${ARGS} ${ADDARG_UNI} \
7167 -a ./.tin -s "`t__put_subject`" -q ./.tin "${MBOX}"
7168 check 2 0 "${MBOX}" '1088822685 6642'
7170 ${rm} "${MBOX}"
7171 ( echo "To: ${MBOX}" && echo "Subject: `t__put_subject`" && echo &&
7172 ${cat} ./.tin
7173 ) | ${MAILX} ${ARGS} ${ADDARG_UNI} -Snodot -a ./.tin -t
7174 check 3 0 "${MBOX}" '1088822685 6642'
7176 # Check comments in the header
7177 ${rm} "${MBOX}"
7178 ${cat} <<-_EOT | ${MAILX} ${ARGS} -Snodot -t "${MBOX}"
7179 # Ein Kommentar
7180 From: du@da
7181 # Noch ein Kommentar
7182 Subject : hey you
7183 # Nachgestelltes Kommentar
7185 BOOOM
7186 _EOT
7187 check 4 0 "${MBOX}" '4161555890 124'
7189 # ?MODifier suffix
7190 printf '' > "${MBOX}"
7191 ( echo 'To?single : ./.tout1 .tout2 ' &&
7192 echo 'CC: ./.tcc1 ./.tcc2' &&
7193 echo 'BcC?sin : ./.tbcc1 .tbcc2 ' &&
7194 echo 'To? : ./.tout3 .tout4 ' &&
7195 echo &&
7196 echo body
7197 ) | ${MAILX} ${ARGS} ${ADDARG_UNI} -Snodot -t -Smta=test://"$MBOX"
7198 check 5 0 './.tout1 .tout2' '2948857341 94'
7199 check 6 - ./.tcc1 '2948857341 94'
7200 check 7 - ./.tcc2 '2948857341 94'
7201 check 8 - './.tbcc1 .tbcc2' '2948857341 94'
7202 check 9 - './.tout3 .tout4' '2948857341 94'
7203 check 10 - "${MBOX}" '4294967295 0'
7205 t_epilog "${@}"
7208 t_message_injections() {
7209 # Simple, if we need more here, place in a later vim fold!
7210 t_prolog "${@}"
7212 echo mysig > ./.tmysig
7214 echo some-body | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
7215 -Smessage-inject-head=head-inject \
7216 -Smessage-inject-tail="`${cat} ./.tmysig`"'\ntail-inject' \
7217 ex@am.ple > ./.tall 2>&1
7218 check 1 0 "${MBOX}" '701778583 143'
7219 check 2 - .tall '4294967295 0' # empty file
7221 ${rm} "${MBOX}"
7222 ${cat} <<-_EOT > ./.template
7223 From: me
7224 To: ex1@am.ple
7225 Cc: ex2@am.ple
7226 Subject: This subject is
7228 Body, body, body me.
7229 _EOT
7230 < ./.template ${MAILX} ${ARGS} -t -Smta=test://"$MBOX" \
7231 -Smessage-inject-head=head-inject \
7232 -Smessage-inject-tail="`${cat} ./.tmysig`\n"'tail-inject' \
7233 > ./.tall 2>&1
7234 check 3 0 "${MBOX}" '2189109479 207'
7235 check 4 - .tall '4294967295 0' # empty file
7237 t_epilog "${@}"
7240 t_attachments() {
7241 # TODO More should be in compose mode stuff aka digmsg
7242 t_prolog "${@}"
7244 ${cat} <<-_EOT > ./.tx
7245 From steffen Sun Feb 18 02:48:40 2018
7246 Date: Sun, 18 Feb 2018 02:48:40 +0100
7248 Subject: m1
7249 User-Agent: s-nail v14.9.7
7252 From steffen Sun Feb 18 02:48:42 2018
7253 Date: Sun, 18 Feb 2018 02:48:42 +0100
7255 Subject: m2
7256 User-Agent: s-nail v14.9.7
7259 _EOT
7260 echo att1 > ./.t1
7261 printf 'att2-1\natt2-2\natt2-4\n' > ./'.t 2'
7262 printf 'att3-1\natt3-2\natt3-4\n' > ./.t3
7263 printf 'att4-1\natt4-2\natt4-4\n' > './.t 4'
7265 printf \
7266 '!@ ./.t3 "./.t 4" ""
7269 ./.t3
7270 "./.t 2"
7273 !.' \
7274 | ${MAILX} ${ARGS} -Sescape=! -Smta=test://"$MBOX" \
7275 -a ./.t1 -a './.t 2' \
7276 -s attachment-test \
7277 ex@am.ple > ./.tall 2>&1
7278 check 1 0 "${MBOX}" '2484200149 644'
7279 if have_feat uistrings; then
7280 check 2 - .tall '1928331872 720'
7281 else
7282 t_echoskip '2:[!UISTRINGS]'
7285 ${rm} "${MBOX}"
7286 printf \
7287 'mail ex@amp.ple
7288 !s This the subject is
7289 !@ ./.t3 "#2" "./.t 4" "#1" ""
7292 "./.t 4"
7293 "#2"
7297 mail ex@amp.ple
7298 !s Subject two
7299 !@ ./.t3 "#2" "./.t 4" "#1" ""
7305 mail ex@amp.ple
7306 !s Subject three
7307 !@ ./.t3 "" "#2" "" "./.t 4" "" "#1" ""
7310 ./.t3
7314 mail ex@amp.ple
7315 !s Subject Four
7316 !@ ./.t3 "" "#2" "" "./.t 4" "" "#1" ""
7319 "#1"
7323 mail ex@amp.ple
7324 !s Subject Five
7326 "#2"
7329 !.' \
7330 | ${MAILX} ${ARGS} -Sescape=! -Smta=test://"$MBOX" -Rf ./.tx \
7331 > ./.tall 2>&1
7332 check 3 0 "${MBOX}" '3637385058 2335'
7333 if have_feat uistrings; then
7334 check 4 - .tall '2526106274 1910'
7335 else
7336 t_echoskip '4:[!UISTRINGS]'
7339 ${rm} "${MBOX}"
7340 printf \
7341 'mail ex@amp.ple
7342 !s Subject One
7343 !@ "#."
7344 Body one.
7347 from 2
7348 mail ex@amp.ple
7349 !s Subject Two
7351 "#."
7353 Body two.
7356 reply 1 2
7357 !@ "#."
7361 "#."
7364 !.' \
7365 | ${MAILX} ${ARGS} -Sescape=! -Smta=test://"$MBOX" -Rf ./.tx \
7366 > ./.tall 2>&1
7367 check 5 0 "${MBOX}" '1604688179 2316'
7368 if have_feat uistrings; then
7369 check 6 - .tall '1210753005 508'
7370 else
7371 t_echoskip '6:[!UISTRINGS]'
7376 # Content-ID:
7377 </dev/null ${MAILX} ${ARGS} -Smta=test \
7378 -Sstealthmua=noagent -Shostname \
7379 -a ./.t1 -a './.t 2' \
7380 -a ./.t3 -a './.t 4' \
7381 -s Y \
7382 ex@am.ple > ./.tall 2>&1
7383 check 7 0 .tall '1003537919 1262'
7385 # input charset
7386 </dev/null ${MAILX} ${ARGS} -Smta=test -Sttycharset=utf8 \
7387 -a ./.t1=ascii -a './.t 2'=LATin1 \
7388 -a ./.t3=UTF-8 -a './.t 4'=- \
7389 -s Y \
7390 ex@am.ple > ./.tall 2>&1
7391 check 8 0 .tall '361641281 921'
7393 # input+output charset, no iconv
7394 </dev/null ${MAILX} ${ARGS} -Smta=test \
7395 -a ./.t1=ascii#- -a './.t 2'=LATin1#- \
7396 -a ./.t3=UTF-8#- -a './.t 4'=utf8#- \
7397 -s Y \
7398 ex@am.ple > ./.tall 2>&1
7399 check 9 0 .tall '1357456844 933'
7401 if have_feat iconv; then
7402 printf 'ein \303\244ffchen und ein pferd\n' > .t10-f1
7403 if (< .t10-f1 iconv -f ascii -t utf8) >/dev/null 2>&1; then
7404 </dev/null ${MAILX} ${ARGS} --set mta=test \
7405 --set stealthmua=noagent --set hostname \
7406 --attach ./.t1=-#utf8 \
7407 --attach ./.t10-f1=utf8#latin1 \
7408 --subject Y \
7409 ex@am.ple > ./.tall 2>&1
7410 check 10 0 .tall '1257664842 877'
7411 else
7412 t_echoskip '10:[ICONV/iconv(1):missing conversion(1)]'
7414 else
7415 t_echoskip '10:[!ICONV]'
7418 t_epilog "${@}"
7421 t_rfc2231() {
7422 # (after attachments)
7423 t_prolog "${@}"
7426 mkdir ./.ttt || exit 1
7427 cd ./.ttt || exit 2
7428 : > "ma'ger.txt"
7429 : > "mä'ger.txt"
7430 : > 'diet\ is \curd.txt'
7431 : > 'diet "is" curd.txt'
7432 : > höde-tröge.txt
7433 : > 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
7434 : > höde__tröge__müde__dätte__hätte__vuelle__guelle__aese__aesse__sauerliche__kräuter__österliche__grüße__mäh.txt
7435 : > hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt
7436 : > ✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt
7438 echo bla | ${MAILX} ${ARGS} ${ADDARG_UNI} \
7439 -a "./.ttt/ma'ger.txt" -a "./.ttt/mä'ger.txt" \
7440 -a './.ttt/diet\ is \curd.txt' -a './.ttt/diet "is" curd.txt' \
7441 -a ./.ttt/höde-tröge.txt \
7442 -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 \
7443 -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 \
7444 -a ./.ttt/hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt \
7445 -a ./.ttt/✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt \
7446 "${MBOX}"
7447 check 1 0 "${MBOX}" '3720896054 3088'
7449 # `resend' test, reusing $MBOX
7450 printf "Resend ./.t2\nx\n" | ${MAILX} ${ARGS} -Rf "${MBOX}"
7451 check 2 0 ./.t2 '3720896054 3088'
7453 printf "resend ./.t3\nx\n" | ${MAILX} ${ARGS} -Rf "${MBOX}"
7454 check 3 0 ./.t3 '3979736592 3133'
7456 # And a primitive test for reading messages with invalid parameters
7457 ${cat} <<-_EOT > ./.tinv
7458 From a@b.invalid Wed May 15 12:43:00 2018
7459 MIME-Version: 1.0
7460 Content-Type: multipart/mixed; boundary="1"
7462 This is a multi-part message in MIME format.
7464 Content-Type: text/plain; charset=UTF-8
7465 Content-Transfer-Encoding: quoted-printable
7469 Content-Type: text/plain; name*17="na"; name*18="me-c-t"
7470 Content-Transfer-Encoding: 7bit
7471 Content-Disposition: inline
7474 --1--
7476 From a@b.invalid Wed May 15 12:43:00 2018
7477 MIME-Version: 1.0
7478 Content-Type: multipart/mixed; boundary="2"
7480 This is a multi-part message in MIME format.
7482 Content-Type: text/plain; charset=UTF-8
7483 Content-Transfer-Encoding: quoted-printable
7487 Content-Type: text/plain; name*17="na"; name*18="me-c-t"
7488 Content-Transfer-Encoding: 7bit
7489 Content-Disposition: inline;
7490 filename*0="na";
7491 filename*998999999999999999999999999999="me-c-d"
7494 --2--
7496 From a@b.invalid Wed May 15 12:43:00 2018
7497 MIME-Version: 1.0
7498 Content-Type: multipart/mixed; boundary="3"
7500 This is a multi-part message in MIME format.
7502 Content-Type: text/plain; charset=UTF-8
7503 Content-Transfer-Encoding: quoted-printable
7507 Content-Type: text/plain; name*17="na"; name*18="me-c-t"
7508 Content-Transfer-Encoding: 7bit
7509 Content-Disposition: inline;
7510 filename*0="na"; filename*998="me-c-d"
7513 --3--
7514 _EOT
7516 printf '\\#
7517 \\headerpick type ignore Content-Type Content-Disposition
7518 \\type 1 2 3
7519 \\xit
7520 ' | ${MAILX} ${ARGS} -Rf ./.tinv > ./.tall 2> ./.terr
7521 check 4 0 ./.tall '4094731083 905'
7522 if have_feat uistrings && have_feat iconv; then
7523 check 5 - ./.terr '3713266499 473'
7524 else
7525 t_echoskip '5:[!UISTRINGS or !ICONV]'
7528 t_epilog "${@}"
7531 t_mime_types_load_control() {
7532 t_prolog "${@}"
7534 if have_feat uistrings; then :; else
7535 t_echoskip '[!UISTRINGS]'
7536 t_epilog "${@}"
7537 return
7540 ${cat} <<-_EOT > ./.tmts1
7541 ? application/mathml+xml mathml
7542 _EOT
7543 ${cat} <<-_EOT > ./.tmts2
7544 ? x-conference/x-cooltalk ice
7545 ?t aga-aga aga
7546 ? application/aga-aga aga
7547 _EOT
7549 ${cat} <<-_EOT > ./.tmts1.mathml
7550 <head>nonsense ML</head>
7551 _EOT
7552 ${cat} <<-_EOT > ./.tmts2.ice
7553 Icy, icy road.
7554 _EOT
7555 printf 'of which the c\x01rack is coming soon' > ./.tmtsx.doom
7556 printf 'of which the c\x01rack is coming soon' > ./.tmtsx.aga
7558 printf '
7559 m %s
7560 Schub-di-du
7561 ~@ ./.tmts1.mathml
7562 ~@ ./.tmts2.ice
7563 ~@ ./.tmtsx.doom
7564 ~@ ./.tmtsx.aga
7566 File %s
7567 from*
7568 type
7570 ' "${MBOX}" "${MBOX}" |
7571 ${MAILX} ${ARGS} \
7572 -Smimetypes-load-control=f=./.tmts1,f=./.tmts2 \
7573 > ./.tout 2>&1
7574 check_ex0 1-estat
7575 ${cat} "${MBOX}" >> ./.tout
7576 check 1 - ./.tout '2128819500 2441'
7578 echo type | ${MAILX} ${ARGS} -R \
7579 -Smimetypes-load-control=f=./.tmts1,f=./.tmts3 \
7580 -f "${MBOX}" >> ./.tout 2>&1
7581 check 2 0 ./.tout '1125106528 3642'
7583 t_epilog "${@}"
7585 # }}}
7587 # Around state machine, after basics {{{
7588 t_alternates() {
7589 t_prolog "${@}"
7591 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" > ./.tall 2>&1
7592 commandalias x echo '$?/$^ERRNAME'
7593 commandalias y echo '$?/$^ERRNAME <$rv>'
7594 echo --0
7595 alternates;x
7596 alternates a1@b1 a2@b2 a3@b3;x
7597 alternates;x
7598 vput alternates rv;y
7600 echo --1
7601 unalternates a2@b2
7602 vput alternates rv;y
7603 unalternates a3@b3
7604 vput alternates rv;y
7605 unalternates a1@b1
7606 vput alternates rv;y
7608 echo --2
7609 unalternates *
7610 alternates a1@b1 a2@b2 a3@b3
7611 unalternates a3@b3
7612 vput alternates rv;y
7613 unalternates a2@b2
7614 vput alternates rv;y
7615 unalternates a1@b1
7616 vput alternates rv;y
7618 echo --3
7619 alternates a1@b1 a2@b2 a3@b3
7620 unalternates a1@b1
7621 vput alternates rv;y
7622 unalternates a2@b2
7623 vput alternates rv;y
7624 unalternates a3@b3
7625 vput alternates rv;y
7627 echo --4
7628 unalternates *
7629 alternates a1@b1 a2@b2 a3@b3
7630 unalternates *
7631 vput alternates rv;y
7633 echo --5
7634 unalternates *
7635 alternates a1@b1 a1@c1 a1@d1 a2@b2 a3@b3 a3@c3 a3@d3
7636 m a1@b1 a1@c1 a1@d1
7637 ~s all alternates, only a1@b1 remains
7638 ~c a2@b2
7639 ~b a3@b3 a3@c3 a3@d3
7640 ~r - '_EOT'
7641 This body is!
7642 This also body is!!
7643 _EOT
7646 echo --6
7647 unalternates *
7648 alternates a1@b1 a1@c1 a2@b2 a3@b3
7649 m a1@b1 a1@c1 a1@d1
7650 ~s a1@b1 a1@d1, and a3@c3 a3@d3 remain
7651 ~c a2@b2
7652 ~b a3@b3 a3@c3 a3@d3
7653 ~r - '_EOT'
7654 This body2 is!
7655 _EOT
7658 echo --7
7659 alternates a1@b1 a2@b2 a3; set allnet
7660 m a1@b1 a1@c1 a1@d1
7661 ~s all alternates via allnet, only a1@b1 remains
7662 ~c a2@b2
7663 ~b a3@b3 a3@c3 a3@d3
7664 ~r - '_EOT'
7665 This body3 is!
7666 _EOT
7669 echo --10
7670 unalternates *
7671 alternates a1@b1;x
7672 vput alternates rv;y
7673 alternates a2@b2;x
7674 vput alternates rv;y
7675 alternates a3@b3;x
7676 vput alternates rv;y
7677 alternates a4@b4;x
7678 vput alternates rv;y
7680 unalternates *
7681 vput alternates rv;y
7683 echo --11
7684 set posix
7685 alternates a1@b1 a2@b2;x
7686 vput alternates rv;y
7687 alternates a3@b3 a4@b4;x
7688 vput alternates rv;y
7689 __EOT
7691 check 1 0 "${MBOX}" '3901995195 542'
7692 if have_feat uistrings; then
7693 check 2 - .tall '1878598364 505'
7694 else
7695 t_echoskip '2:[!UISTRINGS]'
7698 # Automatic alternates, also from command line (freezing etc.)
7699 ${rm} "${MBOX}"
7700 ${cat} <<- __EOT > ./.tin
7701 From trouble-report@desy Wed Jun 6 20:19:28 2018
7702 Date: Wed, 06 Jun 2018 19:58:02 +0200
7703 From: a@b.org, b@b.org, c@c.org
7704 Sender: a@b.org
7705 To: b@b.org
7706 Cc: a@b.org, c@c.org
7707 Subject: test
7708 Message-ID: <20180606175802.dw-cn%a@b.org>
7710 sultry
7712 __EOT
7714 printf '#
7715 reply
7716 !^header remove to
7717 !^header remove cc
7718 !^header remove subject
7719 !^header insert to b@b.org
7720 !^header insert cc "a@b.org b@b.org c@c.org"
7721 my body
7723 ' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" -Sescape=! \
7724 -S from=a@b.org,b@b.org,c@c.org -S sender=a@b.org \
7725 -Rf ./.tin > ./.tall 2>&1
7726 check 3 0 "${MBOX}" '3184203976 265'
7727 check 4 - .tall '3604001424 44'
7729 # same, per command
7730 printf '#
7731 set from=a@b.org,b@b.org,c@c.org sender=a@b.org
7732 reply
7733 !^header remove to
7734 !^header remove cc
7735 !^header remove subject
7736 !^header insert to b@b.org
7737 !^header insert cc "a@b.org b@b.org c@c.org"
7738 my body
7740 ' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" -Sescape=! \
7741 -Rf ./.tin > ./.tall 2>&1
7742 check 5 0 "${MBOX}" '98184290 530'
7743 check 6 - .tall '3604001424 44'
7745 # And more, with/out -r (and that Sender: vanishs as necessary)
7746 # TODO -r should be the Sender:, which should automatically propagate to
7747 # TODO From: if possible and/or necessary. It should be possible to
7748 # TODO suppres -r stuff from From: and Sender:, but fallback to special -r
7749 # TODO arg as appropriate.
7750 # TODO For now we are a bit messy
7752 ${rm} "${MBOX}"
7753 </dev/null ${MAILX} ${ARGS} -Smta=test://"$MBOX" -s '-Sfrom + -r ++ test' \
7754 -c a@b.example -c b@b.example -c c@c.example \
7755 -S from=a@b.example,b@b.example,c@c.example \
7756 -S sender=a@b.example \
7757 -r a@b.example b@b.example ./.tout >./.tall 2>&1
7758 check 7 0 "${MBOX}" '4275947318 181'
7759 check 8 - .tout '4275947318 181'
7760 check 9 - .tall '4294967295 0'
7762 </dev/null ${MAILX} ${ARGS} -Smta=test://"$MBOX" -s '-Sfrom + -r ++ test' \
7763 -c a@b.example -c b@b.example -c c@c.example \
7764 -S from=a@b.example,b@b.example,c@c.example \
7765 -S sender=a2@b.example \
7766 -r a@b.example b@b.example ./.tout >./.tall 2>&1
7767 check 10 0 "${MBOX}" '1189494079 383'
7768 check 11 - .tout '1189494079 383'
7769 check 12 - .tall '4294967295 0'
7771 </dev/null ${MAILX} ${ARGS} -Smta=test://"$MBOX" -s '-Sfrom + -r ++ test' \
7772 -c a@b.example -c b@b.example -c c@c.example \
7773 -S from=a@b.example,b@b.example,c@c.example \
7774 -S sender=a@b.example \
7775 b@b.example >./.tall 2>&1
7776 check 13 0 "${MBOX}" '2253033142 610'
7777 check 14 - .tall '4294967295 0'
7779 t_epilog "${@}"
7782 t_cmd_escapes() {
7783 # quote and cmd escapes because this (since Mail times) is worked in the
7784 # big collect() monster of functions
7785 t_prolog "${@}"
7787 echo 'included file' > ./.ttxt
7788 { t__x1_msg && t__x2_msg && t__x3_msg &&
7789 t__gen_msg from 'ex4@am.ple' subject sub4 &&
7790 t__gen_msg from 'eximan <ex5@am.ple>' subject sub5 &&
7791 t__gen_mimemsg from 'ex6@am.ple' subject sub6; } > ./.tmbox
7792 check 1 - ./.tmbox '517368276 2182'
7794 # ~@ is tested with other attachment stuff, ~^ is in compose_edits + digmsg
7795 printf '#
7796 set Sign=SignVar sign=signvar DEAD=./.ttxt
7797 set forward-inject-head quote-inject-head
7798 headerpick type retain Subject
7799 headerpick forward retain Subject To
7800 reply 2
7801 !!1 Not escaped. And shell test last, right before !..
7802 !:echo 1
7803 !: echo 2 only echoed via colon
7804 !:echo 2:$?/$^ERRNAME
7805 !_ echo 3 only echoed via underscore
7806 !:echo 3:$?/$^ERRNAME
7807 !< ./.ttxt
7808 !:echo 4:$?/$^ERRNAME
7809 !<! echo 5 shell echo included
7810 !:echo 5:$?/$^ERRNAME
7811 !| echo 6 pipecmd-pre; cat; echo 6 pipecmd-post
7812 !:echo 6:$?/$^ERRNAME
7813 7 and 8 are ~A and ~a:
7815 !:echo 7:$?/$^ERRNAME
7817 !:echo 8:$?/$^ERRNAME
7818 !b 9 added ~b cc <ex1@am.ple>
7819 !:echo 9:$?/$^ERRNAME
7820 !c 10 added ~c c <ex2@am.ple>
7821 !:echo 10:$?/$^ERRNAME
7822 11 next ~d / $DEAD
7824 !:echo 11:$?/$^ERRNAME
7825 12: ~F
7827 !:echo 12:$?/$^ERRNAME
7828 13: ~F 1 3
7829 !F 1 3
7830 !:echo 13:$?/$^ERRNAME
7831 !F 1000
7832 !:echo 13-1:$?/$^ERRNAME; set posix
7833 14: ~f (headerpick: subject)
7835 !:echo 14:$?/$^ERRNAME; unset posix forward-inject-head quote-inject-head
7836 14.1: ~f (!posix: injections; headerpick: subject to)
7838 !:echo 14.1:$?/$^ERRNAME; set forward-add-cc
7839 14.2: ~f (!posix: headerpick: subject to; forward-add-cc adds mr3)
7840 !f 3
7841 !:echo 14.2:$?/$^ERRNAME; set fullnames
7842 14.3: ~f (!posix: headerpick: subject to; forward-add-cc adds mr1 fullname)
7843 !f 1
7844 !:echo 14.3:$?/$^ERRNAME; set nofullnames noforward-add-cc posix
7845 15: ~f 1
7846 !f 1
7847 !:echo 15:$?/$^ERRNAME
7848 15.5: nono: ~H, ~h
7850 !:echo 15.5-1:$?/$^ERRNAME
7852 !:echo 15.5-2:$?/$^ERRNAME
7853 16, 17: ~I Sign, ~i Sign
7854 !I Sign
7855 !:echo 16:$?/$^ERRNAME
7856 !i Sign
7857 !:echo 17:$?/$^ERRNAME
7858 18: ~M
7860 !:echo 18:$?/$^ERRNAME # XXX forward-add-cc: not expl. tested
7861 19: ~M 1
7862 !M 1
7863 !:echo 19:$?/$^ERRNAME
7864 20: ~m
7866 !:echo 20:$?/$^ERRNAME # XXX forward-add-cc: not expl. tested
7867 21: ~m 3
7868 !m 3
7869 !:echo 21:$?/$^ERRNAME
7870 !: # Initially ~Q was _exactly_ like
7871 28,29 nothing, 30-34: ~Q
7872 !:echo quote=<$quote>
7873 30: ~Q
7875 !:echo 30:$?/$^ERRNAME
7876 31: ~Q 1 3
7877 !Q 1 3
7878 !:echo 31:$?/$^ERRNAME
7879 set quote-inject-head quote-inject-tail indentprefix
7880 !:wysh set quote-inject-head=%%a quote-inject-tail=--%%r
7881 32: ~Q
7883 !:echo 32:$?/$^ERRNAME
7884 set noquote-inject-head noquote-inject-tail quote-add-cc
7885 !:set noquote-inject-head noquote-inject-tail quote-add-cc
7886 33: ~Q 4
7887 !Q 4
7888 !:echo 33:$?/$^ERRNAME
7889 set fullnames
7890 !:set fullnames
7891 34: ~Q 5
7892 !Q 5
7893 !:echo 34:$?/$^ERRNAME
7894 unset fullnames, quote stuff
7895 !:unset quote quote-add-cc fullnames
7896 22: ~R ./.ttxt
7897 !R ./.ttxt
7898 !:echo 22:$?/$^ERRNAME
7899 23: ~r ./.ttxt
7900 !r ./.ttxt
7901 !:echo 23:$?/$^ERRNAME
7902 24: ~s this new subject
7903 !s 24 did new ~s ubject
7904 !:echo 24:$?/$^ERRNAME
7905 !t 25 added ~t o <ex3@am.ple>
7906 !:echo 25:$?/$^ERRNAME
7907 26.1: ~U
7909 !:echo 26.1:$?/$^ERRNAME
7910 26.2: ~U 1
7911 !U 1
7912 !:echo 26.2:$?/$^ERRNAME # XXX forward-add-cc: not expl. tested
7913 27.1: ~u
7915 !:echo 27.1:$?/$^ERRNAME
7916 27.2: ~u 1
7917 !u 1
7918 !:echo 27.2:$?/$^ERRNAME # XXX forward-add-cc: not expl. tested
7919 and i ~w rite this out to ./.tmsg
7920 !w ./.tmsg
7921 !:echo i ~w:$?/$^ERRNAME
7922 !:wysh set x=$escape;set escape=~
7923 ~!echo shell command output
7924 ~:echo shell:$?/$^ERRNAME
7925 ~:wysh set escape=$x
7926 50:F
7927 !F 6
7928 !:echo 50 was F:$?/$^ERRNAME
7929 51:f
7930 !f 6
7931 !:echo 51 was f:$?/$^ERRNAME
7932 52:M
7933 !M 6
7934 !:echo 52 was M:$?/$^ERRNAME
7935 53:m
7936 !m 6
7937 !:echo 53 was m:$?/$^ERRNAME; set quote
7938 54:Q
7939 !Q 6
7940 !:echo 54 was Q:$?/$^ERRNAME
7941 55:U
7942 !U 6
7943 !:echo 55 was U:$?/$^ERRNAME
7944 56:u
7945 !u 6
7946 !:echo 56 was u:$?/$^ERRNAME
7948 ' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" -Rf \
7949 -Sescape=! -Sindentprefix=' |' \
7950 ./.tmbox >./.tall 2>./.terr
7951 check_ex0 2-estat
7952 ${cat} ./.tall >> "${MBOX}"
7953 have_feat filter-html-tagsoup && ck='3877629593 7699' ||
7954 ck='2138694045 7943'
7955 check 2 - "${MBOX}" "${ck}"
7957 if have_feat uistrings && have_feat iconv; then
7958 check 2-err - ./.terr '3575876476 49'
7959 else
7960 t_echoskip '2-err:[!UISTRINGS or !ICONV]'
7962 check 3 - ./.tmsg '3502750368 4445'
7964 # Simple return/error value after *expandaddr* failure test
7965 have_feat filter-html-tagsoup && ck='115245837 7900' ||
7966 ck='2245417271 8144'
7967 printf 'body
7968 !:echo --one
7969 !s This a new subject is
7970 !:set expandaddr=-name
7971 !t two@to.invalid
7972 !:echo $?/$^ERRNAME
7973 !:echo --two
7974 !c no-name-allowed
7975 !:echo $?/$^ERRNAME
7976 !c one@cc.invalid
7977 !:echo $?/$^ERRNAME
7978 !:echo --three
7979 !:alias abcc one@bcc.invalid
7980 !b abcc
7981 !:echo $?/$^ERRNAME
7982 !:set expandaddr=+addr
7983 !b abcc
7984 !:echo $!/$?/$^ERRNAME
7986 ' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
7987 -Sescape=! \
7988 -s testsub one@to.invalid >./.tall 2>&1
7989 check 4 0 "${MBOX}" "${ck}"
7990 if have_feat uistrings; then
7991 check 5 - ./.tall '2336041127 212'
7992 else
7993 check 5 - ./.tall '1818580177 59'
7996 # Modifiers and whitespace indulgence
7997 printf 'body
7998 !:remove '"${MBOX}"'
7999 ! :echo one
8000 ! <./.ttxts
8001 ! :echo two
8002 ! : set i=./.ttxts
8003 ! - $ < $i
8004 !:echo three
8005 ! : set \\
8006 errexit
8007 ! - $ < $i
8008 ! : echo four
8009 !$< ./.ttxts
8010 ! : echo five
8011 ' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
8012 -Sescape=! \
8013 -Spwd="`${pwd}`" \
8014 -s testsub one@to.invalid >./.tall 2>./.terr
8015 check 6 4 ./.tall '686767281 95'
8016 [ -f "${MBOX}" ]; check_exn0 7
8017 if have_feat uistrings; then
8018 check 8 - ./.terr '1304637795 199'
8019 else
8020 t_echoskip '8:[!UISTRINGS]'
8023 t_epilog "${@}"
8026 t_compose_edits() { # XXX very rudimentary
8027 # after: t_cmd_escapes
8028 t_prolog "${@}"
8030 # Something to use as "editor"
8031 ${cat} <<-_EOT > ./.ted.sh
8032 #!${SHELL}
8033 ${cat} <<-__EOT > \${1}
8034 Fcc: .tout1
8036 Fcc: .tout2
8037 Subject: Fcc test 1
8038 Fcc: .tout3
8040 A body
8041 __EOT
8042 exit 0
8043 _EOT
8044 ${chmod} 0755 .ted.sh
8046 # > All these are in-a-row!
8048 printf 'mail ./.tout\n~s This subject is\nThis body is\n~.' |
8049 ${MAILX} ${ARGS} -Seditheaders >./.tall 2>&1
8050 check 1 0 ./.tout '3993703854 127'
8051 check 2 - ./.tall '4294967295 0'
8053 ${mv} ./.tall ./.tout
8054 printf 'mail ./.tout\n~s This subject is\nThis body is\n~e\n~.' |
8055 ${MAILX} ${ARGS} -Seditheaders -SEDITOR=./.ted.sh >./.tall 2>&1
8056 check 3 0 ./.tout1 '285981670 116'
8057 check 4 - ./.tout2 '285981670 116'
8058 check 5 - ./.tout3 '285981670 116'
8059 check 6 - ./.tout '4294967295 0'
8060 check 7 - ./.tall '4294967295 0'
8061 ${rm} ./.tout1 ./.tout2 ./.tout3
8063 # Note t_compose_hooks adds ~^ stress tests
8064 ${mv} ./.tout ./.tout1
8065 ${mv} ./.tall ./.tout2
8066 printf '#
8067 mail ./.tout\n!s This subject is\nThis body is
8068 !^header
8069 !^header list
8070 !^header list fcc
8071 !^header show fcc
8072 !^header remove to
8073 !^header insert fcc ./.tout
8074 !^header insert fcc .tout1
8075 !^header insert fcc ./.tout2
8076 !^header list
8077 !^header show fcc
8078 !^header remove-at fcc 2
8079 !^header remove-at fcc 2
8080 !^header show fcc
8081 !^head remove fcc
8082 !^header show fcc
8083 !^header insert fcc ./.tout
8084 !^header show fcc
8085 !^header list
8087 ' | ${MAILX} ${ARGS} -Sescape=! >./.tall 2>&1
8088 check 8 0 ./.tout '3993703854 127'
8089 check 9 - ./.tout1 '4294967295 0'
8090 check 10 - ./.tout2 '4294967295 0'
8091 check 11 - ./.tall '1857504914 342'
8093 # < No longer in-a-row
8095 ${cat} <<-_EOT | ${MAILX} ${ARGS} -t >./.tall 2>&1
8096 Fcc: .ttout
8097 Subject: Fcc via -t test
8099 My body
8100 _EOT
8101 check 12 0 ./.ttout '1289478830 122'
8102 check 13 - ./.tall '4294967295 0'
8104 # This test assumes code of `^' and `digmsg' is shared: see t_digmsg()
8105 echo 'b 1' > ./.t' x 1'
8106 echo 'b 2' > ./.t' x 2'
8107 printf '#
8108 mail ./.tatt
8109 !^header insert subject subject
8110 !:set i="./.t x 1"
8111 !^header list
8112 !:echo =0
8113 !^attachment
8114 !:echo =1
8115 !^attachment insert "$i"
8116 !:echo =2
8117 !^attachment
8118 !:echo =3
8119 !^attachment list
8120 !:echo =4
8121 !^attachment insert '"'"'./.t x 2'"'"'
8122 !:echo =5
8123 !^attachment list
8124 !:echo =6
8125 !^attachment remove "$i"
8126 !:echo =7
8127 !^attachment list
8128 !:echo =8
8129 !^attachment insert $'"'"'\\$i'"'"'
8130 !:echo =10
8131 !^attachment list
8132 !:echo =11
8133 !^header list
8134 !:echo =12
8135 !^a a $i
8136 !:echo =13
8137 !^a attribute-set "$i" filenames " cannot wait for you "
8138 !:echo =14
8139 !^a a $i
8140 !:echo =15
8141 !^a attribute-set "$i" filename " cannot wait for you "
8142 !:echo =16
8143 !^a a $i
8144 !:echo =17
8145 !^a attribute-at 2
8146 !:echo =18
8147 !^a attribute-set-at 2 "filename" "private eyes"
8148 !:echo =19
8149 !^a attribute-at 2
8150 !:echo =20
8151 !^a attribute-set-at 2 content-description "private c-desc"
8152 !:echo =21
8153 !^a attribute-at 2
8154 !:echo =22
8155 !^a attribute-set-at 2 content-ID "priv invd c-id"
8156 !:echo =23
8157 !^a attribute-at 2
8158 !:echo =24
8159 !^a attribute-set-at 2 content-TyPE tExT/mARkLO
8160 !:echo =25
8161 !^a attribute-at 2
8162 !:echo =26
8163 !^a attribute-set-at 2 content-TyPE ""
8164 !:echo =27
8165 !^a attribute-at 2
8166 !:echo =28
8168 ' | ${MAILX} ${ARGS} -Sescape=! >./.tall 2>&1
8169 check 14 0 ./.tall '3491667030 1565'
8170 check 15 - ./.tatt '1685063733 636'
8172 t_epilog "${@}"
8175 t_digmsg() { # XXX rudimentary; <> compose_edits()?
8176 t_prolog "${@}"
8178 printf '#
8179 mail ./.tout\n!s This subject is\nThis body is
8180 !:echo --one
8181 !:digmsg create - -
8182 !:digmsg - header list
8183 !:digmsg - header show subject
8184 !:digmsg - header show to
8185 !:digmsg - header remove to
8186 !:digmsg - header list
8187 !:digmsg - header show to
8188 !:digmsg remove -
8189 !:echo --two
8190 !:digmsg create -
8191 !:digmsg - header list; readall x; echon "<$x>";
8192 !:digmsg - header show subject;readall x;echon "<$x>";;
8193 !:digmsg remove -
8194 !:echo --three
8195 !: # nothing here as is comment
8196 !^header insert fcc ./.tbox
8197 !:echo --four
8198 !:digmsg create - -
8199 !:digmsg - header list
8200 !:digmsg - header show fcc
8201 !:echo --five
8202 !^head remove fcc
8203 !:echo --six
8204 !:digmsg - header list
8205 !:digmsg - header show fcc
8206 !:digmsg - header insert fcc ./.tfcc
8207 !:echo --seven
8208 !:digmsg remove -
8209 !:echo bye
8211 echo --hello again
8212 File ./.tfcc
8213 echo --one
8214 digmsg create 1 -
8215 digmsg 1 header list
8216 digmsg 1 header show subject
8217 echo --two
8218 ! : > ./.tempty
8219 File ./.tempty
8220 echo --three
8221 digmsg 1 header list; echo $?/$^ERRNAME
8222 digmsg create -; echo $?/$^ERRNAME
8223 echo ==========
8224 ! %s ./.tfcc > ./.tcat
8225 ! %s "s/This subject is/There subject was/" < ./.tfcc >> ./.tcat
8226 File ./.tcat
8227 mail nowhere@exam.ple
8228 !:echo ===1
8229 !:digmsg create -; echo $?/$^ERRNAME;\\
8230 digmsg create 1; echo $?/$^ERRNAME;\\
8231 digmsg create 2; echo $?/$^ERRNAME
8232 !:echo ===2.1
8233 !:digmsg - h l;echo $?/$^ERRNAME;readall d;echo "$?/$^ERRNAME <$d>"
8234 !:echo =2.2
8235 !:digmsg 1 h l;echo $?/$^ERRNAME;readall d;echo "$?/$^ERRNAME <$d>"
8236 !:echo =2.3
8237 !^ h l
8238 !:echo =2.4
8239 !:digmsg 2 h l;echo $?/$^ERRNAME;readall d;echo "$?/$^ERRNAME <$d>"
8240 !:echo ===3.1
8241 !:digmsg - h s to;echo $?/$^ERRNAME;readall d;echo "$?/$^ERRNAME <$d>"
8242 !:echo =3.2
8243 !:digmsg 1 h s subject;echo $?/$^ERRNAME;readall d;echo "$?/$^ERRNAME <$d>"
8244 !:echo =3.3
8245 !^ h s to
8246 !:echo =3.4
8247 !:digmsg 2 h s subject;echo $?/$^ERRNAME;readall d;echo "$?/$^ERRNAME <$d>"
8248 !:echo ==4.1
8249 !:digmsg remove -; echo $?/$^ERRNAME;\\
8250 digmsg remove 1; echo $?/$^ERRNAME;\\
8251 digmsg remove 2; echo $?/$^ERRNAME;
8253 echo ======= new game new fun!
8254 mail one@to.invalid
8255 !s hossa
8256 !:set expandaddr=-name
8257 !:echo -oneo
8258 !^ header insert to two@to.invalid
8259 !:echo $?/$^ERRNAME
8260 !:echo --two
8261 !^ header insert cc no-name-allowed
8262 !:echo $?/$^ERRNAME
8263 !^ header insert cc one@cc.invalid
8264 !:echo $?/$^ERRNAME
8265 !:echo --three
8266 !:alias abcc one@bcc.invalid
8267 !^ header insert bcc abcc
8268 !:echo $?/$^ERRNAME
8269 !:set expandaddr=+addr
8270 !^ header insert bcc abcc
8271 !:echo $!/$?/$^ERRNAME
8273 echo --bye
8274 ' "${cat}" "${sed}" |
8275 ${MAILX} ${ARGS} -Smta=test://"$MBOX" -Sescape=! >./.tall 2>&1
8276 check 1 0 "$MBOX" '665881681 179'
8277 have_feat uistrings && i='4159482825 1372' || i='2254509488 1103'
8278 check 2 - ./.tall "${i}"
8279 check 3 - ./.tfcc '3993703854 127'
8280 check 4 - ./.tempty '4294967295 0'
8281 check 5 - ./.tcat '2157992522 256'
8283 t_epilog "${@}"
8286 t_on_main_loop_tick() {
8287 t_prolog "${@}"
8289 if have_feat cmd-vexpr; then :; else
8290 t_echoskip '[!CMD_VEXPR]'
8291 t_epilog "${@}"
8292 return
8295 printf '#
8296 echo hello; set i=1
8297 define bla {
8298 echo bla1
8299 echo bla2
8301 define omlt {
8302 echo in omlt: $i
8303 vput vexpr i + 1 $i
8305 echo one
8306 set on-main-loop-tick=omlt
8307 echo two
8308 echo three
8309 echo calling bla;call bla
8310 echo four
8311 echo --bye;xit' |
8312 ${MAILX} ${ARGS} -Smta=test://"$MBOX" -Sescape=! >./.tall 2>&1
8313 check 1 0 ./.tall '3697651500 130'
8315 t_epilog "${@}"
8318 t_on_program_exit() {
8319 t_prolog "${@}"
8321 ${MAILX} ${ARGS} \
8322 -X 'define x {' -X 'echo jay' -X '}' -X x -Son-program-exit=x \
8323 > ./.tall 2>&1
8324 check 1 0 ./.tall '2820891503 4'
8326 ${MAILX} ${ARGS} \
8327 -X 'define x {' -X 'echo jay' -X '}' -X q -Son-program-exit=x \
8328 > ./.tall 2>&1
8329 check 2 0 ./.tall '2820891503 4'
8331 </dev/null ${MAILX} ${ARGS} \
8332 -X 'define x {' -X 'echo jay' -X '}' -Son-program-exit=x \
8333 > ./.tall 2>&1
8334 check 3 0 ./.tall '2820891503 4'
8336 </dev/null ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
8337 -X 'define x {' -X 'echo jay' -X '}' -Son-program-exit=x \
8338 -s subject -. hey@you \
8339 > ./.tall 2>&1
8340 check 4 0 ./.tall '2820891503 4'
8341 check 5 - "$MBOX" '561900352 118'
8343 t_epilog "${@}"
8345 # }}}
8347 # Heavy use of/rely on state machine (behaviour) and basics {{{
8348 t_compose_hooks() { # {{{ TODO monster
8349 t_prolog "${@}"
8351 if have_feat uistrings &&
8352 have_feat cmd-csop && have_feat cmd-vexpr; then :; else
8353 t_echoskip '[!UISTRINGS/!CMD_CSOP/!CMD_VEXPR]'
8354 t_epilog "${@}"
8355 return
8358 (echo line one&&echo line two&&echo line three) > ./.treadctl
8359 (echo echo four&&echo echo five&&echo echo six) > ./.tattach
8361 # Supposed to extend t_compose_edits with ~^ stress tests!
8362 ${cat} <<'__EOT__' > ./.trc
8363 define bail {
8364 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
8366 define xerr {
8367 vput csop es substr "$1" 0 1
8368 if [ "$es" != 2 ]
8369 xcall bail "$2: $1"
8372 define read_mline_res {
8373 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
8374 echo $len/$es/$^ERRNAME: $hl
8375 if [ $es -ne $^ERR-NONE ]
8376 xcall bail read_mline_res
8377 elif [ $len -ne 0 ]
8378 \xcall read_mline_res
8381 define ins_addr {
8382 wysh set xh=$1
8383 echo "~^header list"; read hl; echo $hl;\
8384 call xerr "$hl" "in_addr ($xh) 0-1"
8386 echo "~^header insert $xh 'diet <$xh@exam.ple> spliced'";\
8387 read es; echo $es; call xerr "$es" "ins_addr $xh 1-1"
8388 echo "~^header insert $xh <${xh}2@exam.ple>";\
8389 read es; echo $es; call xerr "$es" "ins_addr $xh 1-2"
8390 echo "~^header insert $xh ${xh}3@exam.ple";\
8391 read es; echo $es; call xerr "$es" "ins_addr $xh 1-3"
8392 echo "~^header list $xh"; read hl; echo $hl;\
8393 call xerr "$hl" "ins_addr $xh 1-4"
8394 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 1-5"
8395 call read_mline_res
8397 if [ "$t_remove" == "" ]
8398 return
8401 echo "~^header remove $xh"; read es; call xerr $es "ins_addr $xh 2-1"
8402 echo "~^header remove $xh"; read es; vput csop es substr $es 0 3
8403 if [ $es != 501 ]
8404 xcall bail "ins_addr $xh 2-2"
8406 echo "~^header list $xh"; read es; vput csop es substr $es 0 3
8407 if [ $es != 501 ]
8408 xcall bail "ins_addr $xh 2-3"
8410 echo "~^header show $xh"; read es; vput csop es substr $es 0 3
8411 if [ $es != 501 ]
8412 xcall bail "ins_addr $xh 2-4"
8416 echo "~^header insert $xh 'diet <$xh@exam.ple> spliced'";\
8417 read es; echo $es; call xerr "$es" "ins_addr $xh 3-1"
8418 echo "~^header insert $xh <${xh}2@exam.ple>";\
8419 read es; echo $es; call xerr "$es" "ins_addr $xh 3-2"
8420 echo "~^header insert $xh ${xh}3@exam.ple";\
8421 read es; echo $es; call xerr "$es" "ins_addr $xh 3-3"
8422 echo "~^header list $xh"; read hl; echo $hl;\
8423 call xerr "$hl" "ins_addr $xh 3-4"
8424 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 3-5"
8425 call read_mline_res
8427 echo "~^header remove-at $xh 1"; read es;\
8428 call xerr $es "ins_addr $xh 3-6"
8429 echo "~^header remove-at $xh 1"; read es;\
8430 call xerr $es "ins_addr $xh 3-7"
8431 echo "~^header remove-at $xh 1"; read es;\
8432 call xerr $es "ins_addr $xh 3-8"
8433 echo "~^header remove-at $xh 1"; read es;\
8434 vput csop es substr $es 0 3
8435 if [ $es != 501 ]
8436 xcall bail "ins_addr $xh 3-9"
8438 echo "~^header remove-at $xh T"; read es;\
8439 vput csop es substr $es 0 3
8440 if [ $es != 505 ]
8441 xcall bail "ins_addr $xh 3-10"
8443 echo "~^header list $xh"; read es;\
8444 vput csop es substr $es 0 3
8445 if [ $es != 501 ]
8446 xcall bail "ins_addr $xh 3-11"
8448 echo "~^header show $xh"; read es;\
8449 vput csop es substr $es 0 3
8450 if [ $es != 501 ]
8451 xcall bail "ins_addr $xh 3-12"
8455 echo "~^header insert $xh 'diet <$xh@exam.ple> spliced'";\
8456 read es; echo $es; call xerr "$es" "ins_addr $xh 4-1"
8457 echo "~^header insert $xh <${xh}2@exam.ple>\ (comment)\ \\\"Quot(e)d\\\"";\
8458 read es; echo $es; call xerr "$es" "ins_addr $xh 4-2"
8459 echo "~^header insert $xh ${xh}3@exam.ple";\
8460 read es; echo $es; call xerr "$es" "ins_addr $xh 4-3"
8461 echo "~^header list $xh"; read hl; echo $hl;\
8462 call xerr "$hl" "header list $xh 3-4"
8463 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 4-5"
8464 call read_mline_res
8466 echo "~^header remove-at $xh 3"; read es;\
8467 call xerr $es "ins_addr $xh 4-6"
8468 echo "~^header remove-at $xh 2"; read es;\
8469 call xerr $es "ins_addr $xh 4-7"
8470 echo "~^header remove-at $xh 1"; read es;\
8471 call xerr $es "ins_addr $xh 4-8"
8472 echo "~^header remove-at $xh 1"; read es;\
8473 vput csop es substr $es 0 3
8474 if [ $es != 501 ]
8475 xcall bail "ins_addr $xh 4-9"
8477 echo "~^header remove-at $xh T"; read es;\
8478 vput csop es substr $es 0 3
8479 if [ $es != 505 ]
8480 xcall bail "ins_addr $xh 4-10"
8482 echo "~^header list $xh"; read es;\
8483 vput csop es substr $es 0 3
8484 if [ $es != 501 ]
8485 xcall bail "ins_addr $xh 4-11"
8487 echo "~^header show $xh"; read es;\
8488 vput csop es substr $es 0 3
8489 if [ $es != 501 ]
8490 xcall bail "ins_addr $xh 4-12"
8493 define ins_ref {
8494 wysh set xh=$1 mult=$2
8495 echo "~^header list"; read hl; echo $hl;\
8496 call xerr "$hl" "ins_ref ($xh) 0-1"
8498 echo "~^header insert $xh <$xh@exam.ple>";\
8499 read es; echo $es; call xerr "$es" "ins_ref $xh 1-1"
8500 if [ $mult -ne 0 ]
8501 echo "~^header insert $xh <${xh}2@exam.ple>";\
8502 read es; echo $es; call xerr "$es" "ins_ref $xh 1-2"
8503 echo "~^header insert $xh ${xh}3@exam.ple";\
8504 read es; echo $es; call xerr "$es" "ins_ref $xh 1-3"
8505 else
8506 echo "~^header insert $xh <${xh}2@exam.ple>"; read es;\
8507 vput csop es substr $es 0 3
8508 if [ $es != 506 ]
8509 xcall bail "ins_ref $xh 1-4"
8513 echo "~^header list $xh"; read hl; echo $hl;\
8514 call xerr "$hl" "ins_ref $xh 1-5"
8515 echo "~^header show $xh"; read es; call xerr $es "ins_ref $xh 1-6"
8516 call read_mline_res
8518 if [ "$t_remove" == "" ]
8519 return
8522 echo "~^header remove $xh"; read es;\
8523 call xerr $es "ins_ref $xh 2-1"
8524 echo "~^header remove $xh"; read es;\
8525 vput csop es substr $es 0 3
8526 if [ $es != 501 ]
8527 xcall bail "ins_ref $xh 2-2"
8529 echo "~^header list $xh"; read es;\
8530 vput csop es substr $es 0 3
8531 if [ $es != 501 ]
8532 xcall bail "$es ins_ref $xh 2-3"
8534 echo "~^header show $xh"; read es;\
8535 vput csop es substr $es 0 3
8536 if [ $es != 501 ]
8537 xcall bail "ins_ref $xh 2-4"
8541 echo "~^header insert $xh <$xh@exam.ple>";\
8542 read es; echo $es; call xerr "$es" "ins_ref $xh 3-1"
8543 if [ $mult -ne 0 ]
8544 echo "~^header insert $xh <${xh}2@exam.ple>";\
8545 read es; echo $es; call xerr "$es" "ins_ref $xh 3-2"
8546 echo "~^header insert $xh ${xh}3@exam.ple";\
8547 read es; echo $es; call xerr "$es" "ins_ref $xh 3-3"
8549 echo "~^header list $xh";\
8550 read hl; echo $hl; call xerr "$hl" "ins_ref $xh 3-4"
8551 echo "~^header show $xh";\
8552 read es; call xerr $es "ins_ref $xh 3-5"
8553 call read_mline_res
8555 echo "~^header remove-at $xh 1"; read es;\
8556 call xerr $es "ins_ref $xh 3-6"
8557 if [ $mult -ne 0 ] && [ $xh != subject ]
8558 echo "~^header remove-at $xh 1"; read es;\
8559 call xerr $es "ins_ref $xh 3-7"
8560 echo "~^header remove-at $xh 1"; read es;\
8561 call xerr $es "ins_ref $xh 3-8"
8563 echo "~^header remove-at $xh 1"; read es;\
8564 vput csop es substr $es 0 3
8565 if [ $es != 501 ]
8566 xcall bail "ins_ref $xh 3-9"
8568 echo "~^header remove-at $xh T"; read es;\
8569 vput csop es substr $es 0 3
8570 if [ $es != 505 ]
8571 xcall bail "ins_ref $xh 3-10"
8573 echo "~^header show $xh"; read es;\
8574 vput csop es substr $es 0 3
8575 if [ $es != 501 ]
8576 xcall bail "ins_ref $xh 3-11"
8580 echo "~^header insert $xh <$xh@exam.ple> ";\
8581 read es; echo $es; call xerr "$es" "ins_ref $xh 4-1"
8582 if [ $mult -ne 0 ]
8583 echo "~^header insert $xh <${xh}2@exam.ple> ";\
8584 read es; echo $es; call xerr "$es" "ins_ref $xh 4-2"
8585 echo "~^header insert $xh ${xh}3@exam.ple";\
8586 read es; echo $es; call xerr "$es" "ins_ref $xh 4-3"
8588 echo "~^header list $xh"; read hl; echo $hl;\
8589 call xerr "$hl" "ins_ref $xh 4-4"
8590 echo "~^header show $xh"; read es; call xerr $es "ins_ref $xh 4-5"
8591 call read_mline_res
8593 if [ $mult -ne 0 ] && [ $xh != subject ]
8594 echo "~^header remove-at $xh 3"; read es;\
8595 call xerr $es "ins_ref $xh 4-6"
8596 echo "~^header remove-at $xh 2"; read es;\
8597 call xerr $es "ins_ref $xh 4-7"
8599 echo "~^header remove-at $xh 1"; read es;\
8600 call xerr $es "ins_ref $xh 4-8"
8601 echo "~^header remove-at $xh 1"; read es;\
8602 vput csop es substr $es 0 3
8603 if [ $es != 501 ]
8604 xcall bail "ins_ref $xh 4-9"
8606 echo "~^header remove-at $xh T"; read es;\
8607 vput csop es substr $es 0 3
8608 if [ $es != 505 ]
8609 xcall bail "ins_ref $xh 4-10"
8611 echo "~^header show $xh"; read es;\
8612 vput csop es substr $es 0 3
8613 if [ $es != 501 ]
8614 xcall bail "ins_ref $xh 4-11"
8617 define t_header {
8618 echo t_header ENTER
8619 # In collect.c order
8620 call ins_addr from
8621 call ins_ref sender 0 # Not a "ref", but works
8622 call ins_addr To
8623 call ins_addr cC
8624 call ins_addr bCc
8625 call ins_addr reply-To
8626 call ins_addr mail-Followup-to
8627 call ins_ref messAge-id 0
8628 call ins_ref rEfErEncEs 1
8629 call ins_ref in-Reply-to 1
8630 call ins_ref subject 1 # Not a "ref", but works (with tweaks)
8631 call ins_addr freeForm1
8632 call ins_addr freeform2
8634 echo "~^header show MAILX-Command"; read es; call xerr $es "t_header 1000"
8635 call read_mline_res
8636 echo "~^header show MAILX-raw-TO"; read es; call xerr $es "t_header 1001"
8637 call read_mline_res
8639 echo t_header LEAVE
8641 define t_attach {
8642 echo t_attach ENTER
8644 echo "~^attachment";\
8645 read hl; echo $hl; vput csop es substr "$hl" 0 3
8646 if [ "$es" != 501 ]
8647 xcall bail "attach 0-1"
8650 echo "~^attach attribute ./.treadctl";\
8651 read hl; echo $hl; vput csop es substr "$hl" 0 3
8652 if [ "$es" != 501 ]
8653 xcall bail "attach 0-2"
8655 echo "~^attachment attribute-at 1";\
8656 read hl; echo $hl; vput csop es substr "$hl" 0 3
8657 if [ "$es" != 501 ]
8658 xcall bail "attach 0-3"
8661 echo "~^attachment insert ./.treadctl=ascii";\
8662 read hl; echo $hl; call xerr "$hl" "attach 1-1"
8663 echo "~^attachment list";\
8664 read es; echo $es;call xerr "$es" "attach 1-2"
8665 call read_mline_res
8666 echo "~^attachment attribute ./.treadctl";\
8667 read es; echo $es;call xerr "$es" "attach 1-3"
8668 call read_mline_res
8669 echo "~^attachment attribute .treadctl";\
8670 read es; echo $es;call xerr "$es" "attach 1-4"
8671 call read_mline_res
8672 echo "~^attachment attribute-at 1";\
8673 read es; echo $es;call xerr "$es" "attach 1-5"
8674 call read_mline_res
8676 echo "~^attachment attribute-set ./.treadctl filename rctl";\
8677 read es; echo $es;call xerr "$es" "attach 1-6"
8678 echo "~^attachment attribute-set .treadctl content-description Au";\
8679 read es; echo $es;call xerr "$es" "attach 1-7"
8680 echo "~^attachment attribute-set-at 1 content-id <10.du@ich>";\
8681 read es; echo $es;call xerr "$es" "attach 1-8"
8683 echo "~^attachment attribute ./.treadctl";\
8684 read es; echo $es;call xerr "$es" "attach 1-9"
8685 call read_mline_res
8686 echo "~^attachment attribute .treadctl";\
8687 read es; echo $es;call xerr "$es" "attach 1-10"
8688 call read_mline_res
8689 echo "~^attachment attribute rctl";\
8690 read es; echo $es;call xerr "$es" "attach 1-11"
8691 call read_mline_res
8692 echo "~^attachment attribute-at 1";\
8693 read es; echo $es;call xerr "$es" "attach 1-12"
8694 call read_mline_res
8697 echo "~^attachment insert ./.tattach=latin1";\
8698 read hl; echo $hl; call xerr "$hl" "attach 2-1"
8699 echo "~^attachment list";\
8700 read es; echo $es;call xerr "$es" "attach 2-2"
8701 call read_mline_res
8702 echo "~^attachment attribute ./.tattach";\
8703 read es; echo $es;call xerr "$es" "attach 2-3"
8704 call read_mline_res
8705 echo "~^attachment attribute .tattach";\
8706 read es; echo $es;call xerr "$es" "attach 2-4"
8707 call read_mline_res
8708 echo "~^attachment attribute-at 2";\
8709 read es; echo $es;call xerr "$es" "attach 2-5"
8710 call read_mline_res
8712 echo "~^attachment attribute-set ./.tattach filename tat";\
8713 read es; echo $es;call xerr "$es" "attach 2-6"
8714 echo \
8715 "~^attachment attribute-set .tattach content-description Au2";\
8716 read es; echo $es;call xerr "$es" "attach 2-7"
8717 echo "~^attachment attribute-set-at 2 content-id <20.du@wir>";\
8718 read es; echo $es;call xerr "$es" "attach 2-8"
8719 echo \
8720 "~^attachment attribute-set-at 2 content-type application/x-sh";\
8721 read es; echo $es;call xerr "$es" "attach 2-9"
8723 echo "~^attachment attribute ./.tattach";\
8724 read es; echo $es;call xerr "$es" "attach 2-10"
8725 call read_mline_res
8726 echo "~^attachment attribute .tattach";\
8727 read es; echo $es;call xerr "$es" "attach 2-11"
8728 call read_mline_res
8729 echo "~^attachment attribute tat";\
8730 read es; echo $es;call xerr "$es" "attach 2-12"
8731 call read_mline_res
8732 echo "~^attachment attribute-at 2";\
8733 read es; echo $es;call xerr "$es" "attach 2-13"
8734 call read_mline_res
8737 if [ "$t_remove" == "" ]
8738 return
8741 echo "~^attachment remove ./.treadctl"; read es;\
8742 call xerr $es "attach 3-1"
8743 echo "~^attachment remove ./.tattach"; read es;\
8744 call xerr $es "attach 3-2"
8745 echo "~^ attachment remove ./.treadctl"; read es;\
8746 vput csop es substr $es 0 3
8747 if [ $es != 501 ]
8748 xcall bail "attach 3-3"
8750 echo "~^ attachment remove ./.tattach"; read es;\
8751 vput csop es substr $es 0 3
8752 if [ $es != 501 ]
8753 xcall bail "attach 3-4"
8755 echo "~^attachment list"; read es;\
8756 vput csop es substr $es 0 3
8757 if [ $es != 501 ]
8758 xcall bail "attach 3-5"
8762 echo "~^attachment insert ./.tattach=latin1";\
8763 read hl; echo $hl; call xerr "$hl" "attach 4-1"
8764 echo "~^attachment insert ./.tattach=latin1";\
8765 read hl; echo $hl; call xerr "$hl" "attach 4-2"
8766 echo "~^attachment list";\
8767 read es; echo $es;call xerr "$es" "attach 4-3"
8768 call read_mline_res
8769 echo "~^ attachment remove .tattach"; read es;\
8770 vput csop es substr $es 0 3
8771 if [ $es != 506 ]
8772 xcall bail "attach 4-4 $es"
8774 echo "~^attachment remove-at T"; read es;\
8775 vput csop es substr $es 0 3
8776 if [ $es != 505 ]
8777 xcall bail "attach 4-5"
8779 echo "~^attachment remove ./.tattach"; read es;\
8780 call xerr $es "attach 4-6"
8781 echo "~^attachment remove ./.tattach"; read es;\
8782 call xerr $es "attach 4-7"
8783 echo "~^ attachment remove ./.tattach"; read es;\
8784 vput csop es substr $es 0 3
8785 if [ $es != 501 ]
8786 xcall bail "attach 4-8 $es"
8788 echo "~^attachment list"; read es;\
8789 vput csop es substr $es 0 3
8790 if [ $es != 501 ]
8791 xcall bail "attach 4-9"
8795 echo "~^attachment insert ./.tattach=latin1";\
8796 read hl; echo $hl; call xerr "$hl" "attach 5-1"
8797 echo "~^attachment insert ./.tattach=latin1";\
8798 read hl; echo $hl; call xerr "$hl" "attach 5-2"
8799 echo "~^attachment insert ./.tattach=latin1";\
8800 read hl; echo $hl; call xerr "$hl" "attach 5-3"
8801 echo "~^attachment list";\
8802 read es; echo $es;call xerr "$es" "attach 5-4"
8803 call read_mline_res
8805 echo "~^attachment remove-at 3"; read es;\
8806 call xerr $es "attach 5-5"
8807 echo "~^attachment remove-at 3"; read es;\
8808 vput csop es substr $es 0 3
8809 if [ $es != 501 ]
8810 xcall bail "attach 5-6"
8812 echo "~^attachment remove-at 2"; read es;\
8813 call xerr $es "attach 5-7"
8814 echo "~^attachment remove-at 2"; read es;\
8815 vput csop es substr $es 0 3
8816 if [ $es != 501 ]
8817 xcall bail "attach 5-8"
8819 echo "~^attachment remove-at 1"; read es;\
8820 call xerr $es "attach 5-9"
8821 echo "~^attachment remove-at 1"; read es;\
8822 vput csop es substr $es 0 3
8823 if [ $es != 501 ]
8824 xcall bail "attach 5-10"
8827 echo "~^attachment list"; read es;\
8828 vput csop es substr $es 0 3
8829 if [ $es != 501 ]
8830 xcall bail "attach 5-11"
8834 echo "~^attachment insert ./.tattach=latin1";\
8835 read hl; echo $hl; call xerr "$hl" "attach 6-1"
8836 echo "~^attachment insert ./.tattach=latin1";\
8837 read hl; echo $hl; call xerr "$hl" "attach 6-2"
8838 echo "~^attachment insert ./.tattach=latin1";\
8839 read hl; echo $hl; call xerr "$hl" "attach 6-3"
8840 echo "~^attachment list";\
8841 read es; echo $es;call xerr "$es" "attach 6-4"
8842 call read_mline_res
8844 echo "~^attachment remove-at 1"; read es;\
8845 call xerr $es "attach 6-5"
8846 echo "~^attachment remove-at 1"; read es;\
8847 call xerr $es "attach 6-6"
8848 echo "~^attachment remove-at 1"; read es;\
8849 call xerr $es "attach 6-7"
8850 echo "~^attachment remove-at 1"; read es;\
8851 vput csop es substr $es 0 3
8852 if [ $es != 501 ]
8853 xcall bail "attach 6-8"
8856 echo "~^attachment list"; read es;\
8857 vput csop es substr $es 0 3
8858 if [ $es != 501 ]
8859 xcall bail "attach 6-9"
8862 echo t_attach LEAVE
8864 define t_ocs {
8865 read ver
8866 echo t_ocs
8867 call t_header
8868 call t_attach
8870 define t_oce {
8871 echo on-compose-enter, mailx-command<$mailx-command>
8872 alternates alter1@exam.ple alter2@exam.ple
8873 alternates
8874 set autocc='alter1@exam.ple alter2@exam.ple'
8875 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
8876 echo mailx-subject<$mailx-subject>
8877 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
8878 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
8879 mailx-raw-bcc<$mailx-raw-bcc>
8880 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
8881 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
8882 digmsg create - -;echo $?/$!/$^ERRNAME;\
8883 digmsg - header list;\
8884 digmsg remove -;echo $?/$!/$^ERRNAME
8885 digmsg create -;echo $?/$!/$^ERRNAME;\
8886 digmsg - header list;readall x;echon $x;\
8887 digmsg remove -;echo $?/$!/$^ERRNAME
8889 define t_ocl {
8890 echo on-compose-leave, mailx-command<$mailx-command>
8891 vput alternates al
8892 eval alternates $al alter3@exam.ple alter4@exam.ple
8893 alternates
8894 set autobcc='alter3@exam.ple alter4@exam.ple'
8895 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
8896 echo mailx-subject<$mailx-subject>
8897 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
8898 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
8899 mailx-raw-bcc<$mailx-raw-bcc>
8900 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
8901 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
8902 digmsg create - -;echo $?/$!/$^ERRNAME;\
8903 digmsg - header list;\
8904 digmsg remove -;echo $?/$!/$^ERRNAME
8905 digmsg create -;echo $?/$!/$^ERRNAME;\
8906 digmsg - header list;readall x;echon $x;\
8907 digmsg remove -;echo $?/$!/$^ERRNAME
8909 define t_occ {
8910 echo on-compose-cleanup, mailx-command<$mailx-command>
8911 unalternates *
8912 alternates
8913 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
8914 echo mailx-subject<$mailx-subject>
8915 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
8916 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
8917 mailx-raw-bcc<$mailx-raw-bcc>
8918 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
8919 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
8920 # XXX error message variable digmsg create - -;echo $?/$!/$^ERRNAME;\
8921 digmsg - header list;\
8922 digmsg remove -;echo $?/$!/$^ERRNAME
8923 # ditto digmsg create -;echo $?/$!/$^ERRNAME;\
8924 digmsg - header list;readall x;echon $x;\
8925 digmsg remove -;echo $?/$!/$^ERRNAME
8927 wysh set on-compose-splice=t_ocs \
8928 on-compose-enter=t_oce on-compose-leave=t_ocl \
8929 on-compose-cleanup=t_occ
8930 __EOT__
8932 printf 'm this-goes@nowhere\nbody\n!.\n' |
8933 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
8934 -X'source ./.trc' -Smta=test://"$MBOX" \
8935 >./.tall 2>&1
8936 ${cat} ./.tall >> "${MBOX}"
8937 check 1 0 "${MBOX}" '1646284089 10565'
8939 ${rm} "${MBOX}"
8940 printf 'm this-goes@nowhere\nbody\n!.\n' |
8941 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
8942 -St_remove=1 -X'source ./.trc' -Smta=test://"$MBOX" \
8943 >./.tall 2>&1
8944 ${cat} ./.tall >> "${MBOX}"
8945 check 2 0 "${MBOX}" '700681006 12851'
8949 # Some state machine stress, shell compose hook, localopts for hook, etc.
8950 # readctl in child. ~r as HERE document
8951 ${rm} "${MBOX}"
8952 printf 'm ex@am.ple\nbody\n!.
8953 echon ${mailx-command}${mailx-subject}
8954 echon ${mailx-from}${mailx-sender}
8955 echon ${mailx-to}${mailx-cc}${mailx-bcc}
8956 echon ${mailx-raw-to}${mailx-raw-cc}${mailx-raw-bcc}
8957 echon ${mailx-orig-from}${mailx-orig-to}${mailx-orig-gcc}${mailx-orig-bcc}
8958 var t_oce t_ocs t_ocs_sh t_ocl t_occ autocc
8959 ' | ${MAILX} ${ARGS} -Snomemdebug -Sescape=! \
8960 -Smta=test://"$MBOX" \
8962 define bail {
8963 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
8965 define xerr {
8966 vput csop es substr "$1" 0 1
8967 if [ "$es" != 2 ]
8968 xcall bail "$2"
8971 define read_mline_res {
8972 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
8973 echo $len/$es/$^ERRNAME: $hl
8974 if [ $es -ne $^ERR-NONE ]
8975 xcall bail read_mline_res
8976 elif [ $len -ne 0 ]
8977 \xcall read_mline_res
8980 define _work {
8981 vput vexpr i + 1 "$2"
8982 if [ $i -lt 111 ]
8983 vput vexpr j % $i 10
8984 if [ $j -ne 0 ]
8985 set j=xcall
8986 else
8987 echon "$i.. "
8988 set j=call
8990 eval \\$j _work $1 $i
8991 return $?
8993 vput vexpr i + $i "$1"
8994 return $i
8996 define _read {
8997 wysh set line; read line;wysh set es=$? en=$^ERRNAME ;\
8998 echo read:$es/$en: $line
8999 if [ "${es}" -ne -1 ]
9000 xcall _read
9002 readctl remove $cwd/.treadctl; echo readctl remove:$?/$^ERRNAME
9004 define t_ocs {
9005 read ver
9006 echo t_ocs
9007 echo "~^header list"; read hl; echo $hl;\
9008 vput csop es substr "$hl" 0 1
9009 if [ "$es" != 2 ]
9010 xcall bail "header list"
9011 endif
9013 call _work 1; echo $?
9014 echo "~^header insert cc splicy\ diet\ <splice@exam.ple>\ spliced";\
9015 read es; echo $es; vput csop es substr "$es" 0 1
9016 if [ "$es" != 2 ]
9017 xcall bail "be diet"
9018 endif
9019 echo "~^header insert cc <splice2@exam.ple>";\
9020 read es; echo $es; vput csop es substr "$es" 0 1
9021 if [ "$es" != 2 ]
9022 xcall bail "be diet2"
9023 endif
9025 call _work 2; echo $?
9026 echo "~^header insert bcc juicy\ juice\ <juice@exam.ple>\ spliced";\
9027 read es; echo $es;vput csop es substr "$es" 0 1
9028 if [ "$es" != 2 ]
9029 xcall bail "be juicy"
9030 endif
9031 echo "~^header insert bcc juice2@exam.ple";\
9032 read es; echo $es;vput csop es substr "$es" 0 1
9033 if [ "$es" != 2 ]
9034 xcall bail "be juicy2"
9035 endif
9036 echo "~^header insert bcc juice3\ <juice3@exam.ple>";\
9037 read es; echo $es;vput csop es substr "$es" 0 1
9038 if [ "$es" != 2 ]
9039 xcall bail "be juicy3"
9040 endif
9041 echo "~^header insert bcc juice4@exam.ple";\
9042 read es; echo $es;vput csop es substr "$es" 0 1
9043 if [ "$es" != 2 ]
9044 xcall bail "be juicy4"
9045 endif
9047 echo "~^header remove-at bcc 3";\
9048 read es; echo $es;vput csop es substr "$es" 0 1
9049 if [ "$es" != 2 ]
9050 xcall bail "remove juicy5"
9051 endif
9052 echo "~^header remove-at bcc 2";\
9053 read es; echo $es;vput csop es substr "$es" 0 1
9054 if [ "$es" != 2 ]
9055 xcall bail "remove juicy6"
9056 endif
9057 echo "~^header remove-at bcc 3";\
9058 read es; echo $es;vput csop es substr "$es" 0 3
9059 if [ "$es" != 501 ]
9060 xcall bail "failed to remove-at"
9061 endif
9062 # Add duplicates which ought to be removed!
9063 echo "~^header insert bcc juice4@exam.ple";\
9064 read es; echo $es;vput csop es substr "$es" 0 1
9065 if [ "$es" != 2 ]
9066 xcall bail "be juicy4-1"
9067 endif
9068 echo "~^header insert bcc juice4@exam.ple";\
9069 read es; echo $es;vput csop es substr "$es" 0 1
9070 if [ "$es" != 2 ]
9071 xcall bail "be juicy4-2"
9072 endif
9073 echo "~^header insert bcc juice4@exam.ple";\
9074 read es; echo $es;vput csop es substr "$es" 0 1
9075 if [ "$es" != 2 ]
9076 xcall bail "be juicy4-3"
9077 endif
9078 echo "~:set t_ocs"
9081 call _work 3; echo $?
9082 echo "~r - '__EOT'"
9083 vput ! i echo just knock if you can hear me;\
9084 i=0;\
9085 while [ $i -lt 24 ]; do printf "%s " $i; i=`expr $i + 1`; done;\
9086 echo relax
9087 echon shell-cmd says $?/$^ERRNAME: $i
9088 echo "~x will not become interpreted, we are reading until __EOT"
9089 echo "__EOT"
9090 read r_status; echo "~~r status output: $r_status"
9091 echo "~:echo $? $! $^ERRNAME"
9092 read r_status
9093 echo "~~r status from parent: $r_status"
9096 call _work 4; echo $?
9097 vput cwd cwd;echo cwd:$?
9098 readctl create $cwd/.treadctl ;echo readctl:$?/$^ERRNAME;\
9099 call _read
9102 call _work 5; echo $?
9103 echo "~^header show MAILX-Command"; read es;\
9104 call xerr $es "t_header 1000"; call read_mline_res
9105 echo "~^header show MAILX-raw-TO"; read es;\
9106 call xerr $es "t_header 1001"; xcall read_mline_res
9108 echoerr IT IS WRONG IF YOU SEE THIS
9110 define t_oce {
9111 echo on-compose-enter, mailx-command<$mailx-command>
9112 set t_oce autobcc=oce@exam.ple
9113 alternates alter1@exam.ple alter2@exam.ple
9114 alternates
9115 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
9116 echo mailx-subject<$mailx-subject>
9117 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
9118 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
9119 mailx-raw-bcc<$mailx-raw-bcc>
9120 echo mailx-orig-from<$mailx-orig-from> \
9121 mailx-orig-to<$mailx-orig-to> \
9122 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
9124 define t_ocl {
9125 echo on-compose-leave, mailx-command<$mailx-command>
9126 set t_ocl autocc=ocl@exam.ple
9127 unalternates *
9128 alternates alter3@exam.ple alter4@exam.ple
9129 alternates
9130 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
9131 echo mailx-subject<$mailx-subject>
9132 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
9133 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
9134 mailx-raw-bcc<$mailx-raw-bcc>
9135 echo mailx-orig-from<$mailx-orig-from> \
9136 mailx-orig-to<$mailx-orig-to> \
9137 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
9139 define t_occ {
9140 echo on-compose-cleanup, mailx-command<$mailx-command>
9141 set t_occ autocc=occ@exam.ple
9142 unalternates *
9143 alternates
9144 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
9145 echo mailx-subject<$mailx-subject>
9146 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
9147 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
9148 mailx-raw-bcc<$mailx-raw-bcc>
9149 echo mailx-orig-from<$mailx-orig-from> \
9150 mailx-orig-to<$mailx-orig-to> \
9151 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
9153 wysh set on-compose-splice=t_ocs \
9154 on-compose-splice-shell="read ver;echo t_ocs-shell;\
9155 echo \"~t shell@exam.ple\"; echo \"~:set t_ocs_sh\"" \
9156 on-compose-enter=t_oce on-compose-leave=t_ocl \
9157 on-compose-cleanup=t_occ
9158 ' > ./.tnotes 2>&1
9159 check_ex0 3-estat
9160 ${cat} ./.tnotes >> "${MBOX}"
9161 check 3 - "${MBOX}" '3986011319 2437'
9163 # Reply, forward, resend, Resend
9165 ${rm} "${MBOX}"
9166 printf '#
9167 set from="f1@z"
9168 m t1@z
9171 set from="du <f2@z>" stealthmua=noagent
9172 m t2@z
9175 ' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" -Snomemdebug -Sescape=! \
9176 > ./.tnotes 2>&1
9177 check_ex0 4-intro-estat
9179 printf '
9180 echo start: $? $! $^ERRNAME
9181 File %s
9182 echo File: $? $! $^ERRNAME;echo;echo
9183 reply 1
9184 this is content of reply 1
9186 echo reply 1: $? $! $^ERRNAME;echo;echo
9187 Reply 1 2
9188 this is content of Reply 1 2
9190 echo Reply 1 2: $? $! $^ERRNAME;echo;echo
9191 forward 1 fwdex@am.ple
9192 this is content of forward 1
9194 echo forward 1: $? $! $^ERRNAME;echo;echo
9195 wysh set forward-inject-head=$'"'"'-- \\
9196 forward (%%a)(%%d)(%%f)(%%i)(%%n)(%%r) --\\n'"'"'
9197 wysh set forward-inject-tail=$'"'"'-- \\
9198 end of forward (%%i) --\\n'"'"'
9199 forward 2 fwdex@am.ple
9200 this is content of forward 2
9202 echo forward 2: $? $! $^ERRNAME;echo;echo
9203 set showname
9204 forward 2 fwdex2@am.ple
9205 this is content of forward 2, 2nd, with showname set
9207 echo forward 2, 2nd: $? $! $^ERRNAME;echo;echo
9208 resend 1 2 resendex@am.ple
9209 echo resend 1 2: $? $! $^ERRNAME;echo;echo
9210 Resend 1 2 Resendex@am.ple
9211 echo Resend 1 2: $? $! $^ERRNAME;echo;echo
9212 ' "${MBOX}" |
9213 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sfullnames \
9214 -Smta=test://"$MBOX" \
9216 define bail {
9217 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
9219 define xerr {
9220 vput csop es substr "$1" 0 1
9221 if [ "$es" != 2 ]
9222 xcall bail "$2"
9225 define read_mline_res {
9226 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
9227 echo mline_res:$len/$es/$^ERRNAME: $hl
9228 if [ $es -ne $^ERR-NONE ]
9229 xcall bail read_mline_res
9230 elif [ $len -ne 0 ]
9231 \xcall read_mline_res
9234 define work_hl {
9235 echo "~^header show $1"; read es;\
9236 call xerr $es "work_hl $1"; echo $1; call read_mline_res
9237 if [ $# -gt 1 ]
9238 shift
9239 xcall work_hl "$@"
9242 define t_ocs {
9243 read ver
9244 echo t_ocs version $ver
9245 echo "~^header list"; read hl; echo $hl;\
9246 echoerr the header list is $hl;\
9247 call xerr "$hl" "header list"
9248 eval vpospar set $hl
9249 shift
9250 xcall work_hl "$@"
9251 echoerr IT IS WRONG IF YOU SEE THIS
9253 define t_oce {
9254 echo on-XY-enter, mailx-command<$mailx-command>
9255 set t_oce autobcc=oce@exam.ple
9256 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
9257 echo mailx-subject<$mailx-subject>
9258 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
9259 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
9260 mailx-raw-bcc<$mailx-raw-bcc>
9261 echo mailx-orig-from<$mailx-orig-from> \
9262 mailx-orig-to<$mailx-orig-to> \
9263 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
9265 define t_ocl {
9266 echo on-XY-leave, mailx-command<$mailx-command>
9267 set t_ocl autocc=ocl@exam.ple
9268 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
9269 echo mailx-subject<$mailx-subject>
9270 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
9271 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
9272 mailx-raw-bcc<$mailx-raw-bcc>
9273 echo mailx-orig-from<$mailx-orig-from> \
9274 mailx-orig-to<$mailx-orig-to> \
9275 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
9277 define t_occ {
9278 echo on-XY-cleanup, mailx-command<$mailx-command>
9279 set t_occ autocc=occ@exam.ple
9280 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
9281 echo mailx-subject<$mailx-subject>
9282 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
9283 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
9284 mailx-raw-bcc<$mailx-raw-bcc>
9285 echo mailx-orig-from<$mailx-orig-from> \
9286 mailx-orig-to<$mailx-orig-to> \
9287 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
9289 wysh set on-compose-splice=t_ocs \
9290 on-compose-enter=t_oce on-compose-leave=t_ocl \
9291 on-compose-cleanup=t_occ \
9292 on-resend-enter=t_oce on-resend-cleanup=t_occ
9293 ' >> ./.tnotes 2>&1
9294 check_ex0 4-estat
9295 ${cat} ./.tnotes >> "${MBOX}"
9296 check 4 - "${MBOX}" '1850092468 11799'
9298 t_epilog "${@}"
9299 } # }}}
9301 t_mass_recipients() {
9302 t_prolog "${@}"
9304 if have_feat cmd-vexpr; then :; else
9305 t_echoskip '[!CMD_VEXPR]'
9306 t_epilog "${@}"
9307 return
9310 ${cat} <<'__EOT__' > ./.trc
9311 define bail {
9312 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
9314 define ins_addr {
9315 wysh set nr=$1 hn=$2
9316 echo "~$hn $hn$nr@$hn"; echo '~:echo $?'; read es
9317 if [ "$es" -ne 0 ]
9318 xcall bail "ins_addr $hn 1-$nr"
9320 vput vexpr nr + $nr 1
9321 if [ "$nr" -le "$maximum" ]
9322 xcall ins_addr $nr $hn
9325 define bld_alter {
9326 wysh set nr=$1 hn=$2
9327 alternates $hn$nr@$hn
9328 vput vexpr nr + $nr 2
9329 if [ "$nr" -le "$maximum" ]
9330 xcall bld_alter $nr $hn
9333 define t_ocs {
9334 read ver
9335 call ins_addr 1 t
9336 call ins_addr 1 c
9337 call ins_addr 1 b
9339 define t_ocl {
9340 if [ "$t_remove" != '' ]
9341 call bld_alter 1 t
9342 call bld_alter 2 c
9345 set on-compose-splice=t_ocs on-compose-leave=t_ocl
9346 __EOT__
9348 printf 'm this-goes@nowhere\nbody\n!.\n' |
9349 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
9350 -X'source ./.trc' -Smta=test://"$MBOX" -Smaximum=${LOOPS_MAX} \
9351 >./.tall 2>&1
9352 check_ex0 1-estat
9353 ${cat} ./.tall >> "${MBOX}"
9354 if [ ${LOOPS_MAX} -eq ${LOOPS_BIG} ]; then
9355 check 1-${LOOPS_BIG} - "${MBOX}" '3835365533 51534'
9356 elif [ ${LOOPS_MAX} -eq ${LOOPS_SMALL} ]; then
9357 check 1-${LOOPS_SMALL} - "${MBOX}" '3647549277 4686'
9360 ${rm} "${MBOX}"
9361 printf 'm this-goes@nowhere\nbody\n!.\n' |
9362 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
9363 -St_remove=1 -X'source ./.trc' -Smta=test://"$MBOX" \
9364 -Smaximum=${LOOPS_MAX} \
9365 >./.tall 2>&1
9366 check_ex0 2-estat
9367 ${cat} ./.tall >> "${MBOX}"
9368 if [ ${LOOPS_MAX} -eq ${LOOPS_BIG} ]; then
9369 check 2-${LOOPS_BIG} - "${MBOX}" '3768249992 34402'
9370 elif [ $LOOPS_MAX -eq ${LOOPS_SMALL} ]; then
9371 check 2-${LOOPS_SMALL} - "${MBOX}" '4042568441 3170'
9374 t_epilog "${@}"
9377 t_lreply_futh_rth_etc() {
9378 t_prolog "${@}"
9380 ${cat} <<-_EOT > ./.tmbox
9381 From neverneverland Sun Jul 23 13:46:25 2017
9382 Subject: Bugstop: five miles out 1
9383 Reply-To: mister originator2 <mr2@originator>, bugstop@five.miles.out
9384 From: mister originator <mr@originator>
9385 To: bugstop-commit@five.miles.out, laber@backe.eu
9386 Cc: is@a.list
9387 Mail-Followup-To: bugstop@five.miles.out, laber@backe.eu, is@a.list
9388 In-reply-to: <20170719111113.bkcMz%laber@backe.eu>
9389 Date: Wed, 19 Jul 2017 09:22:57 -0400
9390 Message-Id: <20170719132257.766AF781267@originator>
9391 Status: RO
9393 > |Sorry, I think I misunderstand something. I would think that
9395 That's appalling.
9397 From neverneverland Fri Jul 7 22:39:11 2017
9398 Subject: Bugstop: five miles out 2
9399 Reply-To: mister originator2<mr2@originator>,bugstop@five.miles.out,is@a.list
9400 Content-Transfer-Encoding: 7bit
9401 From: mister originator <mr@originator>
9402 To: bugstop-commit@five.miles.out
9403 Cc: is@a.list
9404 Message-ID: <149945963975.28888.6950788126957753723.reportbug@five.miles.out>
9405 Date: Fri, 07 Jul 2017 16:33:59 -0400
9406 Status: R
9408 capable of changing back.
9410 From neverneverland Fri Jul 7 22:42:00 2017
9411 Subject: Bugstop: five miles out 3
9412 Reply-To: mister originator2 <mr2@originator>, bugstop@five.miles.out
9413 Content-Transfer-Encoding: 7bit
9414 From: mister originator <mr@originator>
9415 To: bugstop-commit@five.miles.out
9416 Cc: is@a.list
9417 Message-ID: <149945963975.28888.6950788126957753746.reportbug@five.miles.out>
9418 Date: Fri, 07 Jul 2017 16:33:59 -0400
9419 List-Post: <mailto:bugstop@five.miles.out>
9420 Status: R
9422 are you ready, boots?
9424 From neverneverland Sat Aug 19 23:15:00 2017
9425 Subject: Bugstop: five miles out 4
9426 Reply-To: mister originator2 <mr2@originator>, bugstop@five.miles.out
9427 Content-Transfer-Encoding: 7bit
9428 From: mister originator <mr@originator>
9429 To: bugstop@five.miles.out
9430 Cc: is@a.list
9431 Message-ID: <149945963975.28888.6950788126qtewrqwer.reportbug@five.miles.out>
9432 Date: Fri, 07 Jul 2017 16:33:59 -0400
9433 List-Post: <mailto:bugstop@five.miles.out>
9434 Status: R
9436 are you ready, boots?
9437 _EOT
9441 ${cat} <<-'_EOT' | ${MAILX} ${ARGS} -Sescape=! -Smta=test://"$MBOX" \
9442 -Rf ./.tmbox >> "${MBOX}" 2>&1
9443 define r {
9444 wysh set m="This is text of \"reply ${1}."
9445 reply 1 2 3
9446 !I m
9449 !I m
9452 !I m
9455 echo -----After reply $1.1 - $1.3: $?/$^ERRNAME
9457 define R {
9458 wysh set m="This is text of \"Reply ${1}."
9459 eval Reply $2
9460 !I m
9461 !I 2
9464 echo -----After Reply $1.$2: $?/$^ERRNAME
9466 define _Lh {
9467 read protover
9468 echo '~I m'
9469 echo '~I n'
9470 echo '".'
9472 define _Ls {
9473 wysh set m="This is text of \"Lreply ${1}." on-compose-splice=_Lh n=$2
9474 eval Lreply $2
9476 define L {
9477 # We need two indirections for this test: one for the case that Lreply
9478 # fails because of missing recipients: we need to read EOF next, thus
9479 # place this in _Ls last; and second for the succeeding cases EOF is
9480 # not what these should read, so go over the backside and splice it in!
9481 # (A shame we do not have redirection++ as a Bourne/K/POSIX shell!)
9482 call _Ls "$@"
9483 echo -----After Lreply $1.$2: $?/$^ERRNAME
9485 define x {
9486 localopts call-fixate yes
9487 call r $1
9488 call R $1 1; call R $1 2; call R $1 3; call R $1 4
9489 call L $1 1; call L $1 2; call L $1 3
9491 define tweak {
9492 echo;echo '===== CHANGING === '"$*"' =====';echo
9493 eval "$@"
9496 set from=laber@backe.eu
9497 mlist is@a.list
9498 call x 1
9499 call tweak set reply-to-honour
9500 call x 2
9501 call tweak set followup-to
9502 call x 3
9503 call tweak set followup-to-honour
9504 call x 4
9505 call tweak mlist bugstop@five.miles.out
9506 call x 5
9507 call tweak mlsubscribe bugstop@five.miles.out
9508 call x 6
9509 call tweak set recipients-in-cc
9510 call x 7
9511 # While here, test that *fullnames* works (also here)
9512 call tweak set fullnames
9513 reply 1
9514 This message should have *fullnames* in the header.
9516 # Revert
9517 call tweak unmlsubscribe bugstop@five.miles.out';' \
9518 set followup-to-add-cc nofullnames
9519 call x 8
9520 call tweak mlsubscribe bugstop@five.miles.out
9521 call x 9
9522 _EOT
9524 check_ex0 1-estat
9525 if have_feat uistrings; then
9526 check 1 - "${MBOX}" '1519985418 39828'
9527 else
9528 t_echoskip '1:[!UISTRINGS]'
9533 ${cat} <<-_EOT > ./.tmbox
9534 From tom@i-i.example Thu Oct 26 03:15:55 2017
9535 Date: Wed, 25 Oct 2017 21:15:46 -0400
9536 From: tom <tom@i-i.example>
9537 To: Steffen Nurpmeso <steffen@sdaoden.eu>
9538 Cc: tom <tom@i-i.example>
9539 Subject: Re: xxxx yyyyyyyy configure does not really like a missing zzzzz
9540 Message-ID: <20171026011546.GA11643@i-i.example>
9541 Reply-To: tom@i-i.example
9542 References: <20171025214601.T2pNd%steffen@sdaoden.eu>
9543 In-Reply-To: <20171025214601.T2pNd%steffen@sdaoden.eu>
9544 Status: R
9546 The report's useful :-)
9547 _EOT
9549 # Let us test In-Reply-To: removal starts a new thread..
9550 # This needs adjustment of *stealthmua*
9551 argadd='-Sstealthmua=noagent -Shostname'
9553 ${rm} "${MBOX}"
9554 printf 'reply 1\nthread\n!.\n' |
9555 ${MAILX} ${ARGS} -Sescape=! -Smta=test://"$MBOX" -Sreply-to-honour \
9556 ${argadd} -Rf ./.tmbox > .tall 2>&1
9557 check 2 0 "${MBOX}" '841868335 433'
9558 check 3 - .tall '4294967295 0'
9560 printf 'reply 1\nnew <- thread!\n!||%s -e "%s"\n!.\n' \
9561 "${sed}" '/^In-Reply-To:/d' |
9562 ${MAILX} ${ARGS} -Sescape=! -Smta=test://"$MBOX" -Sreply-to-honour \
9563 ${argadd} -Rf "${MBOX}" > .tall 2>&1
9564 check 4 0 "${MBOX}" '3136957908 771'
9565 check 5 - .tall '4294967295 0'
9567 printf 'reply 2\nold <- new <- thread!\n!.\n' |
9568 ${MAILX} ${ARGS} -Sescape=! -Smta=test://"$MBOX" -Sreply-to-honour \
9569 ${argadd} -Rf "${MBOX}" > .tall 2>&1
9570 check 6 0 "${MBOX}" '3036449053 1231'
9571 check 7 - .tall '4294967295 0'
9573 printf 'reply 3\nnew <- old <- new <- thread!\n!|| %s -e "%s"\n!.\n' \
9574 "${sed}" '/^In-Reply-To:/d' |
9575 ${MAILX} ${ARGS} -Sescape=! -Smta=test://"$MBOX" -Sreply-to-honour \
9576 ${argadd} -Rf "${MBOX}" > .tall 2>&1
9577 check 8 0 "${MBOX}" '2069841383 1583'
9578 check 9 - .tall '4294967295 0'
9580 # And follow-up testing whether changing In-Reply-To: to - starts a new
9581 # thread with only the message being replied-to.
9583 printf 'reply 1\nthread with only one ref!\n!||%s -e "%s"\n!.\n' \
9584 "${sed}" 's/^In-Reply-To:.*$/In-Reply-To:-/' |
9585 ${MAILX} ${ARGS} -Sescape=! -Smta=test://"$MBOX" -Sreply-to-honour \
9586 ${argadd} -Rf "${MBOX}" > .tall 2>&1
9587 check 10 0 "${MBOX}" '3155846378 2047'
9588 check 11 - .tall '4294967295 0'
9590 t_epilog "${@}"
9593 t_pipe_handlers() {
9594 t_prolog "${@}"
9596 if have_feat cmd-vexpr; then :; else
9597 t_echoskip '[!CMD_VEXPR]'
9598 t_epilog "${@}"
9599 return
9602 # "Test for" [d6f316a] (Gavin Troy)
9603 printf "m ${MBOX}\n~s subject1\nEmail body\n~.\nfi ${MBOX}\np\nx\n" |
9604 ${MAILX} ${ARGS} ${ADDARG_UNI} -Spipe-text/plain="?* ${cat}" > "${BODY}"
9605 check 1 0 "${MBOX}" '3942990636 118'
9606 check 2 - "${BODY}" '3951695530 170'
9608 ${rm} "${MBOX}"
9609 printf "m %s\n~s subject2\n~@%s\nBody2\n~.\nFi %s\nmimeview\nx\n" \
9610 "${MBOX}" "${TOPDIR}snailmail.jpg" "${MBOX}" |
9611 ${MAILX} ${ARGS} ${ADDARG_UNI} \
9612 -S 'pipe-text/plain=?' \
9613 -S 'pipe-image/jpeg=?=&?'\
9614 'trap \"'"${rm}"' -f '\ '\\"${MAILX_FILENAME_TEMPORARY}\\"\" EXIT;'\
9615 'trap \"trap \\\"\\\" INT QUIT TERM; exit 1\" INT QUIT TERM;'\
9616 '{ echo C=$MAILX_CONTENT;'\
9617 'echo C-E=$MAILX_CONTENT_EVIDENCE;'\
9618 'echo E-B-U=$MAILX_EXTERNAL_BODY_URL;'\
9619 'echo F=$MAILX_FILENAME;'\
9620 'echo F-G=not testable MAILX_FILENAME_GENERATED;'\
9621 'echo F-T=not testable MAILX_FILENAME_TEMPORARY;'\
9622 ''"${cksum}"' < \"${MAILX_FILENAME_TEMPORARY}\" |'\
9623 ''"${sed}"' -e "s/[ ]\{1,\}/ /g"; } > ./.tax 2>&1;'"${mv}"' ./.tax ./.tay' \
9624 > "${BODY}" 2>&1
9625 check 3 0 "${MBOX}" '1933681911 13435'
9626 check 4 - "${BODY}" '2036666633 493'
9627 check 4-hdl - ./.tay '144517347 151' async
9629 # Keep $MBOX..
9630 if [ -z "${ln}" ]; then
9631 t_echoskip '5:[ln(1) not found]'
9632 else
9633 # Let us fill in tmpfile, test auto-deletion
9634 printf 'Fi %s\nmimeview\nvput vexpr v file-stat .t.one-link\n'\
9635 'eval wysh set $v;echo should be $st_nlink link\nx\n' "${MBOX}" |
9636 ${MAILX} ${ARGS} ${ADDARG_UNI} \
9637 -S 'pipe-text/plain=?' \
9638 -S 'pipe-image/jpeg=?=++?'\
9639 'echo C=$MAILX_CONTENT;'\
9640 'echo C-E=$MAILX_CONTENT_EVIDENCE;'\
9641 'echo E-B-U=$MAILX_EXTERNAL_BODY_URL;'\
9642 'echo F=$MAILX_FILENAME;'\
9643 'echo F-G=not testable MAILX_FILENAME_GENERATED;'\
9644 'echo F-T=not testable MAILX_FILENAME_TEMPORARY;'\
9645 "${ln}"' -f $MAILX_FILENAME_TEMPORARY .t.one-link;'\
9646 ''"${cksum}"' < \"${MAILX_FILENAME_TEMPORARY}\" |'\
9647 ''"${sed}"' -e "s/[ ]\{1,\}/ /g"' \
9648 > "${BODY}" 2>&1
9649 check 5 0 "${BODY}" '4260004050 661'
9651 # Fill in ourselfs, test auto-deletion
9652 printf 'Fi %s\nmimeview\nvput vexpr v file-stat .t.one-link\n'\
9653 'eval wysh set $v;echo should be $st_nlink link\nx\n' "${MBOX}" |
9654 ${MAILX} ${ARGS} ${ADDARG_UNI} \
9655 -S 'pipe-text/plain=?' \
9656 -S 'pipe-image/jpeg=?++?'\
9657 "${cat}"' > $MAILX_FILENAME_TEMPORARY;'\
9658 'echo C=$MAILX_CONTENT;'\
9659 'echo C-E=$MAILX_CONTENT_EVIDENCE;'\
9660 'echo E-B-U=$MAILX_EXTERNAL_BODY_URL;'\
9661 'echo F=$MAILX_FILENAME;'\
9662 'echo F-G=not testable MAILX_FILENAME_GENERATED;'\
9663 'echo F-T=not testable MAILX_FILENAME_TEMPORARY;'\
9664 ''"${cksum}"' < \"${MAILX_FILENAME_TEMPORARY}\" |'\
9665 ''"${sed}"' -e "s/[ ]\{1,\}/ /g"' \
9666 > "${BODY}" 2>&1
9667 check 6 0 "${BODY}" '4260004050 661'
9669 # And the same, via copiousoutput (fake)
9670 printf 'Fi %s\np\nvput vexpr v file-stat .t.one-link\n'\
9671 'eval wysh set $v;echo should be $st_nlink link\nx\n' "${MBOX}" |
9672 ${MAILX} ${ARGS} ${ADDARG_UNI} \
9673 -S 'pipe-text/plain=?' \
9674 -S 'pipe-image/jpeg=?*++?'\
9675 "${cat}"' > $MAILX_FILENAME_TEMPORARY;'\
9676 'echo C=$MAILX_CONTENT;'\
9677 'echo C-E=$MAILX_CONTENT_EVIDENCE;'\
9678 'echo E-B-U=$MAILX_EXTERNAL_BODY_URL;'\
9679 'echo F=$MAILX_FILENAME;'\
9680 'echo F-G=not testable MAILX_FILENAME_GENERATED;'\
9681 'echo F-T=not testable MAILX_FILENAME_TEMPORARY;'\
9682 "${ln}"' -f $MAILX_FILENAME_TEMPORARY .t.one-link;'\
9683 ''"${cksum}"' < \"${MAILX_FILENAME_TEMPORARY}\" |'\
9684 ''"${sed}"' -e "s/[ ]\{1,\}/ /g"' \
9685 > "${BODY}" 2>&1
9686 check 7 0 "${BODY}" '709946464 677'
9689 t_epilog "${@}"
9692 t_mailcap() {
9693 t_prolog "${@}"
9695 if have_feat mailcap; then :; else
9696 t_echoskip '[!MAILCAP]'
9697 t_epilog "${@}"
9698 return
9701 ${cat} <<-'_EOT' > ./.tmailcap
9702 text/html; lynx -dump %s; copiousoutput; nametemplate=%s.html
9703 application/pdf; /Applications/Preview.app/Contents/MacOS/Preview %s;\
9704 nametemplate=%s.pdf;\
9705 test = [ "${OSTYPE}" = darwin ]
9706 application/pdf;\
9707 infile=%s\;\
9708 trap "rm -f ${infile}" EXIT\;\
9709 trap "exit 75" INT QUIT TERM\;\
9710 mupdf "${infile}";\
9711 test = [ -n "${DISPLAY}" ];\
9712 nametemplate = %s.pdf; x-mailx-async
9713 application/pdf; pdftotext -layout %s -; nametemplate=%s.pdf; copiousoutput
9714 application/*; echo "This is \\"%t\\" but \
9715 is 50 \% Greek to me" \; < %s head -c 1024 | cat -vet; \
9716 description=" this is\;a \"wildcard\" match, no trailing quote! ;\
9717 copiousoutput; x-mailx-noquote
9721 bummer/hummer;;
9722 application/postscript; ps-to-terminal %s;\ needsterminal
9723 application/postscript; ps-to-terminal %s; \compose=idraw %s
9724 x-be2; the-cmd %s; \
9725 print=print-cmd %s ; \
9726 copiousoutput ; \
9727 compose=compose-cmd -d %s ; \
9728 textualnewlines; \
9729 composetyped = composetyped-cmd -dd %s ; \
9730 x-mailx-noquote ;\
9731 edit=edit-cmd -ddd %s; \
9732 description = a\;desc;\
9733 nametemplate=%s.be2;\
9734 test = this is "a" test ; \
9735 x-mailx-test-once ;\
9736 x11-bitmap = x11-bitmap.bpm;;;;;
9737 application/*; echo "is \"%t\" \
9738 50 \% Greek" \; cat %s; copiousoutput; \; description="catch-all buddy";
9739 audio/*; showaudio;compose=%n
9740 image/jpeg; showpicture -viewer xv %s
9741 image/*; showpicture %s
9742 message/partial; showpartial %s %{id} %{number} %{total}
9743 application/postscript ; lpr %s ; label="PS File";\
9744 compose="getx PS %s"
9745 application/atomicmail; atomicmail %s ; needsterminal
9746 application/andrew-inset; ezview %s ; copiousoutput;\
9747 edit=ez -d %s; compose="ez -d %s"; label="Andrew i/d"
9748 text/richtext; xy iso-8859-1 -e richtext -p %s; \
9749 test=test "`echo %{charset} | tr A-Z a-z`" = iso-8859-1; copiousoutput
9750 text/plain; xy iso-8859-1 %s;\
9751 test=test "`echo %{charset} | tr A-Z a-z`" = iso-8859-1; copiousoutput
9752 text/richtext; rich %s %{not-closed; copiousoutput
9753 default; cat %s; copiousoutput
9754 _EOT
9755 ${chmod} 0644 ./.tmailcap
9757 printf 'm;echo =1/$?;m c;echo =2/$?;
9758 mailca loa;echo =3/$?;mailc s;echo =4/$?' |
9759 MAILCAPS=./.tmailcap ${MAILX} -X'commandalias m mailcap' ${ARGS} \
9760 > ./.tall 2>./.terr
9761 check 1 0 ./.tall '2012114724 3064'
9762 have_feat uistrings && i='3903313993 2338' || i='4294967295 0'
9763 check 2 - ./.terr "${i}"
9767 echo 'From me with love' | ${MAILX} ${ARGS} -s sub1 "${MBOX}"
9768 check 3 0 "${MBOX}" '4224630386 228'
9770 # For reproducability, one pseudo check with cat(1) and mv(1)
9771 printf '#
9772 text/plain; echo p-1-1\\;< %%s cat\\;echo p-1-2;\\
9773 test=echo X >> ./.terrmc\\; [ -n "$XY" ];x-mailx-test-once
9774 text/plain; echo p-2-1\\;< %%s cat\\;echo p-2-2;\\
9775 test=echo Y >> ./.terrmc\\;[ -z "$XY" ]
9776 text/plain; { file=%%s\\; echo p-3-1 = ${file##*.}\\;\\
9777 </dev/null cat %%s\\;echo p-3-2\\; } > ./.tx\\; mv -f ./.tx ./.tasy;\\
9778 test=[ -n "$XY" ];nametemplate=%%s.txt;x-mailx-async
9779 text/plain; echo p-4-1\\;cat\\;echo p-4-2;copiousoutput
9780 ' > ./.tmailcap
9782 </dev/null MAILCAPS=./.tmailcap TMPDIR=`${pwd}` \
9783 ${MAILX} ${ARGS} -Snomailcap-disable \
9784 -Y '\mailcap' \
9785 -Rf "${MBOX}" > ./.tall 2>./.terr
9786 check 4.pre 0 ./.tall '1428075831 455'
9788 # Same with real programs
9789 printf '#
9790 text/plain; echo p-1-1\\;< %%s %s\\;echo p-1-2;\\
9791 test=echo X >> ./.terrmc\\; [ -n "$XY" ];x-mailx-test-once
9792 text/plain; echo p-2-1\\;< %%s %s\\;echo p-2-2;\\
9793 test=echo Y >> ./.terrmc\\;[ -z "$XY" ]
9794 text/plain; { file=%%s\\; echo p-3-1 = ${file##*.}\\;\\
9795 </dev/null %s %%s\\;echo p-3-2\\; } > ./.tx\\; %s -f ./.tx ./.tasy;\\
9796 test=[ -n "$XY" ];nametemplate=%%s.txt;x-mailx-async
9797 text/plain; echo p-4-1\\;%s\\;echo p-4-2;copiousoutput
9798 ' "${cat}" "${cat}" "${cat}" "${mv}" "${cat}" > ./.tmailcap
9800 </dev/null MAILCAPS=./.tmailcap TMPDIR=`${pwd}` \
9801 ${MAILX} ${ARGS} -Snomailcap-disable \
9802 -Y '#
9803 \echo =1
9804 \mimeview
9805 \echo =2
9806 \environ set XY=yes
9807 \mimeview
9808 \echo =3
9809 \type
9810 \echo =4
9812 -Rf "${MBOX}" > ./.tall 2>./.terr
9813 check 4 0 ./.tall '1912261831 831'
9814 check 5 - ./.terr '4294967295 0'
9815 check 6 - ./.terrmc '2376112102 6'
9816 check 7 - ./.tasy '3913344578 37' async
9818 # "Binary data"; ensure all possible temporary file / nametemplate
9819 # etc. paths are taken: avoid 2nd e7a60732c1906aefe4755fd61c5ffa81eeca0af0
9821 ${rm} -f "${MBOX}"
9822 printf 'du\x7fbo€o\bm' > ./.tatt.pdf
9823 printf 'du' | ${MAILX} ${ARGS} -a ./.tatt.pdf -s test "${MBOX}"
9824 check 8 0 "${MBOX}" '3444709420 644'
9826 printf '#
9827 # stdin
9828 application/pdf; echo p-1-1\\;%s\\;echo p-1-2; test=[ "$XY" = "" ]
9829 # tmpfile, no template
9830 application/pdf; echo p-2-1\\;< %%s %s\\;echo p-2-2; test = [ "$XY" = two ]
9831 # tmpfile, template
9832 application/pdf; echo p-3-1\\;< %%s %s\\;echo p-3-2; test=[ "$XY" = three ];\\
9833 nametemplate=%%s.txt
9834 # tmpfile, template, async
9835 application/pdf; { file=%%s \\; echo p-4-1 = ${file##*.}\\;\\
9836 </dev/null %s %%s\\;echo p-4-2\\; } > ./.tx\\; %s -f ./.tx ./.tasy;\\
9837 test=[ "$XY" = four ] ; nametemplate = %%s.txt ; x-mailx-async
9838 # copious,stdin
9839 application/pdf; echo p-5-1\\;%s\\;echo p-5-2; test=[ "$XY" = 1 ];\\
9840 copiousoutput
9841 # copious, tmpfile, no template
9842 application/pdf; echo p-6-1\\;< %%s %s\\;echo p-6-2; test = [ "$XY" = 2 ];\\
9843 copiousoutput
9844 # copious, tmpfile, template
9845 application/pdf; echo p-7-1\\;< %%s %s\\;echo p-7-2;test = [ "$XY" = 3 ];\\
9846 nametemplate=%%s.txt; copiousoutput
9847 ' "${cat}" "${cat}" "${cat}" "${cat}" "${mv}" "${cat}" "${cat}" "${cat}" \
9848 > ./.tmailcap
9850 </dev/null XY= MAILCAPS=./.tmailcap TMPDIR=`${pwd}` \
9851 ${MAILX} ${ARGS} -Snomailcap-disable \
9852 -Y '#
9853 \echo =1
9854 \mimeview
9855 \echo =2
9856 \environ set XY=two
9857 \mimeview
9858 \echo =3
9859 \environ set XY=three
9860 \mimeview
9861 \echo =4
9862 \environ set XY=four
9863 \mimeview
9864 \echo =5
9865 \environ set XY=1
9866 \type
9867 \echo =6
9868 \environ set XY=2
9869 \type
9870 \echo =7
9871 \environ set XY=3
9872 \type
9873 \echo =8
9875 -Rf "${MBOX}" > ./.tall 2>./.terr
9876 check 9 0 ./.tall '2388630345 3850'
9877 check 10 - ./.terr '4294967295 0'
9878 check 11 - ./.tasy '842146666 27' async
9880 # x-mailx-last-resort, x-mailx-ignore
9882 ${rm} -f "${MBOX}"
9883 printf 'in a pdf\n' > ./.tatt.pdf
9884 printf 'du\n' | ${MAILX} ${ARGS} -a ./.tatt.pdf -s test "${MBOX}"
9885 check 12 0 "${MBOX}" '3968874750 579'
9887 printf '#
9888 # stdin
9889 application/pdf;echo hidden;x-mailx-ignore
9890 application/pdf;echo hidden;copiousoutput;x-mailx-ignore
9891 application/pdf; echo pre\\;%s\\;echo post; x-mailx-last-resort
9892 ' "${cat}" > ./.tmailcap
9894 </dev/null XY= MAILCAPS=./.tmailcap TMPDIR=`${pwd}` \
9895 ${MAILX} ${ARGS} -Snomailcap-disable \
9896 -Y '#
9897 \echo =1
9898 \mimeview
9899 \echo =2
9900 \mimetype ?t application/pdf pdf
9901 \mimeview
9902 \echo =3
9903 \type
9904 \echo =4
9905 \unmimetype application/pdf
9906 \mimeview
9907 \echo =5
9909 -Rf "${MBOX}" > ./.tall 2>./.terr
9910 check 13 0 ./.tall '759843612 1961'
9911 check 14 - ./.terr '4294967295 0'
9913 t_epilog "${@}"
9915 # }}}
9917 # Unclassified rest {{{
9918 t_top() {
9919 t_prolog "${@}"
9921 t__gen_msg subject top1 to 1 from 1 cc 1 body 'body1-1
9922 body1-2
9924 body1-3
9925 body1-4
9928 body1-5
9929 ' > "${MBOX}"
9930 t__gen_msg subject top2 to 1 from 1 cc 1 body 'body2-1
9931 body2-2
9934 body2-3
9937 body2-4
9938 body2-5
9939 ' >> "${MBOX}"
9941 ${MAILX} ${ARGS} -Rf -Y '#
9942 \top 1
9943 \echo --- $?/$^ERRNAME, 1; \set toplines=10
9944 \top 1
9945 \echo --- $?/$^ERRNAME, 2; \set toplines=5
9946 \headerpick top retain subject # For top
9947 \headerpick type retain to subject # For Top
9948 \top 1
9949 \echo --- $?/$^ERRNAME, 3; \set topsqueeze
9950 \top 1 2
9951 \echo --- $?/$^ERRNAME, 4
9952 \Top 1
9953 \echo --- $?/$^ERRNAME, 5
9954 # ' "${MBOX}" > ./.tall 2>&1
9955 check 1 0 ./.tall '2556125754 705'
9957 t_epilog "${@}"
9960 t_s_mime() {
9961 t_prolog "${@}"
9963 if have_feat smime; then :; else
9964 t_echoskip '[!SMIME]'
9965 t_epilog "${@}"
9966 return
9969 ${cat} <<-_EOT > ./.t.conf
9970 [req]
9971 x509_extensions = extensions
9972 distinguished_name = req_distinguished_name
9973 attributes = req_attributes
9974 prompt = no
9975 output_password = Pacem_in_terris
9977 [extensions]
9978 basicConstraints = CA:FALSE
9979 # Needs a CA for that keyUsage = digitalSignature
9980 extendedKeyUsage = emailProtection
9982 [req_distinguished_name]
9983 C = GB
9984 ST = Over the
9985 L = rainbow
9986 O = S-nail
9987 OU = S-nail.smime
9988 CN = S-nail.test2
9989 emailAddress = test@localhost
9991 [req_attributes]
9992 challengePassword = hi ca it is me me me
9993 _EOT
9995 doit() {
9996 _z=${1}
9998 if [ "${_z}" = 0 ]; then
9999 _pass=
10000 _osslreq=-nodes
10001 _ossl=
10002 else
10003 _pass=Pacem_in_terris
10004 _osslreq=
10005 _ossl='-passin pass:'${_pass}
10008 ${rm} -f ./.VERIFY ./.ENCRYPT ./.DECRYPT
10010 openssl req ${_osslreq} ${_ossl} -x509 -days 3650 -config ./.t.conf \
10011 -newkey rsa:1024 -keyout ./.tkey.pem -out ./.tcert.pem >>${ERR} 2>&1
10012 check_ex0 ${_z}
10013 _z=`add ${_z} 1`
10015 ${cat} ./.tkey.pem ./.tcert.pem > ./.tpair.pem
10017 # Sign/verify
10018 echo bla | ${MAILX} ${ARGS} \
10019 -Ssmime-sign -Ssmime-sign-cert=./.tpair.pem -Sfrom=test@localhost \
10020 -Ssmime-sign-digest=sha1 \
10021 -S password-test@localhost.smime-cert-key=${_pass} \
10022 -s 'S/MIME test' ./.VERIFY >>${ERR} 2>&1
10023 check_ex0 ${_z}-estat
10024 ${awk} '
10025 BEGIN{ skip=0 }
10026 /^Content-Description: /{ skip = 2; print; next }
10027 /^$/{ if(skip) --skip }
10028 { if(!skip) print }
10030 < ./.VERIFY > "${MBOX}"
10031 check ${_z} - "${MBOX}" '335634014 644'
10032 _z=`add ${_z} 1`
10034 printf 'verify\nx\n' |
10035 ${MAILX} ${ARGS} -Ssmime-ca-file=./.tcert.pem -Serrexit \
10036 -R -f ./.VERIFY >>${ERR} 2>&1
10037 check_ex0 ${_z} # XXX pipe
10038 _z=`add ${_z} 1`
10040 openssl smime -verify -CAfile ./.tcert.pem -in ./.VERIFY >>${ERR} 2>&1
10041 check_ex0 ${_z}
10042 _z=`add ${_z} 1`
10044 # (signing +) encryption / decryption
10045 echo bla |
10046 ${MAILX} ${ARGS} \
10047 -Smta=test://./.ENCRYPT \
10048 -Ssmime-force-encryption -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
10049 -Ssmime-sign-digest=sha1 \
10050 -Ssmime-sign -Ssmime-sign-cert=./.tpair.pem -Sfrom=test@localhost \
10051 -S password-test@localhost.smime-cert-key=${_pass} \
10052 -s 'S/MIME test' recei@ver.com >>${ERR} 2>&1
10053 check_ex0 ${_z}-estat
10054 ${sed} -e '/^$/,$d' < ./.ENCRYPT > "${MBOX}"
10055 check ${_z} - "${MBOX}" '2359655411 336'
10056 _z=`add ${_z} 1`
10058 printf 'decrypt ./.DECRYPT\nfi ./.DECRYPT\nverify\nx\n' |
10059 ${MAILX} ${ARGS} \
10060 -Smta=test://./.ENCRYPT \
10061 -Ssmime-ca-file=./.tcert.pem \
10062 -Ssmime-sign-cert=./.tpair.pem \
10063 -Sfrom=test@localhost \
10064 -S password-test@localhost.smime-cert-key=${_pass} \
10065 -Serrexit -R -f ./.ENCRYPT >>${ERR} 2>&1
10066 check_ex0 ${_z}-estat
10067 ${awk} '
10068 BEGIN{ skip=0 }
10069 /^Content-Description: /{ skip = 2; print; next }
10070 /^$/{ if(skip) --skip }
10071 { if(!skip) print }
10073 < ./.DECRYPT > "${MBOX}"
10074 check ${_z} - "${MBOX}" '2602978204 940'
10075 _z=`add ${_z} 1`
10077 (openssl smime -decrypt ${_ossl} -inkey ./.tkey.pem -in ./.ENCRYPT |
10078 openssl smime -verify -CAfile ./.tcert.pem) >>${ERR} 2>&1
10079 check_ex0 ${_z} # XXX pipe..
10080 _z=`add ${_z} 1`
10082 ${rm} ./.ENCRYPT
10083 echo bla | ${MAILX} ${ARGS} \
10084 -Smta=test://./.ENCRYPT \
10085 -Ssmime-force-encryption -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
10086 -Sfrom=test@localhost \
10087 -S password-test@localhost.smime-cert-key=${_pass} \
10088 -s 'S/MIME test' recei@ver.com >>${ERR} 2>&1
10089 check_ex0 ${_z}-estat
10090 ${sed} -e '/^$/,$d' < ./.ENCRYPT > "${MBOX}"
10091 check ${_z} - "${MBOX}" '2359655411 336'
10092 _z=`add ${_z} 1`
10094 ${rm} ./.DECRYPT
10095 # Note: deduce from *sign-cert*, not from *from*!
10096 printf 'decrypt ./.DECRYPT\nx\n' | ${MAILX} ${ARGS} \
10097 -Smta=test://./.ENCRYPT \
10098 -Ssmime-sign-cert-recei@ver.com=./.tpair.pem \
10099 -S password-recei@ver.com.smime-cert-key=${_pass} \
10100 -Serrexit -R -f ./.ENCRYPT >>${ERR} 2>&1
10101 check ${_z} 0 ./.DECRYPT '2453471323 431'
10102 _z=`add ${_z} 1`
10104 openssl smime ${_ossl} -decrypt -inkey ./.tkey.pem -in ./.ENCRYPT \
10105 >>${ERR} 2>&1
10106 check_ex0 ${_z}
10108 unset _z _pass _osslreq _ossl
10111 doit 0
10112 doit 10
10114 t_epilog "${@}"
10116 # }}}
10118 # xxx Note: t_z() was the first test (series) written. Today many
10119 # xxx aspects are (better) covered by other tests above, some are not.
10120 # xxx At some future date and time, convert the last remains not covered
10121 # xxx elsewhere to a real t_* test and drop it
10122 t_z() {
10123 t_prolog "${@}"
10125 # Test for [260e19d] (Juergen Daubert)
10126 echo body | ${MAILX} ${ARGS} "${MBOX}"
10127 check 4 0 "${MBOX}" '2948857341 94'
10129 # "Test for" [c299c45] (Peter Hofmann) TODO shouldn't end up QP-encoded?
10130 ${rm} "${MBOX}"
10131 ${awk} 'BEGIN{
10132 for(i = 0; i < 10000; ++i)
10133 printf "\xC3\xBC"
10134 #printf "\xF0\x90\x87\x90"
10135 }' | ${MAILX} ${ARGS} ${ADDARG_UNI} -s TestSubject "${MBOX}"
10136 check 7 0 "${MBOX}" '1707496413 61812'
10138 t_epilog "${@}"
10141 # Test support {{{
10142 t__gen_msg() {
10143 t___gen_msg '' "${@}"
10146 t__gen_mimemsg() {
10147 t___gen_msg 1 "${@}"
10150 t___gen_msg() {
10151 ismime=${1}
10152 shift
10154 t___header() {
10155 printf '%s: ' ${1}
10156 case "${3}" in
10157 [0-9]*)
10158 ___hi=1
10159 while [ ${___hi} -le ${3} ]; do
10160 [ ${___hi} -gt 1 ] && printf ', '
10161 printf '%s%s <%s%s@exam.ple>' ${1} ${___hi} ${2} ${___hi}
10162 ___hi=`add ${___hi} 1`
10163 done
10166 printf '%s' "${3}"
10168 esac
10169 printf '\n'
10172 printf 'From reproducible_build Wed Oct 2 01:50:07 1996
10173 Date: Wed, 02 Oct 1996 01:50:07 +0000
10176 body=Body
10177 while [ ${#} -ge 2 ]; do
10178 case "${1}" in
10179 from) t___header From from "${2}";;
10180 to) t___header To to "${2}";;
10181 cc) t___header Cc cc "${2}";;
10182 bcc) t___header Bcc bcc "${2}";;
10183 subject) printf 'Subject: %s\n' "${2}";;
10184 body) body="${2}";;
10185 esac
10186 shift 2
10187 done
10189 if [ -z "${ismime}" ]; then
10190 printf '\n%s\n\n' "${body}"
10191 else
10192 printf 'MIME-Version: 1.0
10193 Message-ID: <20200204225307.FaKeD%%bo@oo>
10194 Content-Type: multipart/mixed; boundary="=BOUNDOUT="
10196 --=BOUNDOUT=
10197 Content-Type: multipart/alternative; boundary==BOUNDIN=
10199 --=BOUNDIN=
10200 Content-Type: text/plain; charset=utf-8
10201 Content-Transfer-Encoding: 8-bit
10205 --=BOUNDIN=
10206 Content-Type: text/html; charset=utf-8
10207 Content-Transfer-Encoding: 8-bit
10209 <HTML><BODY>%s<BR></BODY></HTML>
10211 --=BOUNDIN=--
10213 --=BOUNDOUT=
10214 Content-Type: text/troff
10216 Golden Brown
10218 --=BOUNDOUT=
10219 Content-Type: text/x-uuencode
10221 Aprendimos a quererte
10222 --=BOUNDOUT=--
10224 ' "${body}" "${body}"
10228 t__x1_msg() {
10229 ${cat} <<-_EOT
10230 From neverneverland Sun Jul 23 13:46:25 2017
10231 Subject: Bugstop: five miles out 1
10232 Reply-To: mister originator1 <mr1@originator>
10233 From: mister originator1 <mr1@originator>
10234 To: bugstop-commit@five.miles.out
10235 Cc: is1@a.list
10236 In-reply-to: <20170719111113.bkcMz%laber1@backe.eu>
10237 Date: Wed, 19 Jul 2017 09:22:57 -0400
10238 Message-Id: <20170719132257.766AF781267-1@originator>
10239 Mail-Followup-To: bugstop@five.miles.out, laber@backe.eu, is@a.list
10240 Status: RO
10242 That's appalling, I.
10244 _EOT
10247 t__x2_msg() {
10248 ${cat} <<-_EOT
10249 From neverneverland Sun Jul 23 13:47:25 2017
10250 Subject: Bugstop: five miles out 2
10251 Reply-To: mister originator2 <mr2@originator>
10252 From: mister originator2 <mr2@originator>
10253 To: bugstop-commit@five.miles.out
10254 Cc: is2@a.list
10255 In-reply-to: <20170719111113.bkcMz%laber2@backe.eu>
10256 Date: Wed, 19 Jul 2017 09:23:57 -0400
10257 Message-Id: <20170719132257.766AF781267-2@originator>
10258 Status: RO
10260 That's appalling, II.
10262 _EOT
10265 t__x3_msg() {
10266 ${cat} <<-_EOT
10267 From neverneverland Sun Jul 23 13:48:25 2017
10268 Subject: Bugstop: five miles out 3
10269 Reply-To: mister originator3 <mr3@originator>
10270 From: mister originator3 <mr3@originator>
10271 To: bugstop-commit@five.miles.out
10272 Cc: is3@a.list
10273 In-reply-to: <20170719111113.bkcMz%laber3@backe.eu>
10274 Date: Wed, 19 Jul 2017 09:24:57 -0400
10275 Message-Id: <20170719132257.766AF781267-3@originator>
10276 Status: RO
10278 That's appalling, III.
10280 _EOT
10283 t__put_subject() {
10284 # MIME encoding (QP) stress message subject
10285 printf 'Äbrä Kä?dä=brö Fü?di=bus? '\
10286 'adadaddsssssssddddddddddddddddddddd'\
10287 'ddddddddddddddddddddddddddddddddddd'\
10288 'ddddddddddddddddddddddddddddddddddd'\
10289 'dddddddddddddddddddd Hallelulja? Od'\
10290 'er?? eeeeeeeeeeeeeeeeeeeeeeeeeeeeee'\
10291 'eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'\
10292 'eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee f'\
10293 'fffffffffffffffffffffffffffffffffff'\
10294 'fffffffffffffffffffff ggggggggggggg'\
10295 'ggggggggggggggggggggggggggggggggggg'\
10296 'ggggggggggggggggggggggggggggggggggg'\
10297 'ggggggggggggggggggggggggggggggggggg'\
10298 'gggggggggggggggg'
10301 t__put_body() {
10302 # MIME encoding (QP) stress message body
10303 printf \
10304 'Ich bin eine DÖS-Datäi mit sehr langen Zeilen und auch '\
10305 'sonst bin ich ganz schön am Schleudern, da kannste denke '\
10306 "wasde willst, gelle, gelle, gelle, gelle, gelle.\r\n"\
10307 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst \r\n"\
10308 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1\r\n"\
10309 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12\r\n"\
10310 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123\r\n"\
10311 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1234\r\n"\
10312 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12345\r\n"\
10313 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123456\r\n"\
10314 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1234567\r\n"\
10315 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12345678\r\n"\
10316 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123456789\r\n"\
10317 "Unn ausserdem habe ich trailing SP/HT/SP/HT whitespace \r\n"\
10318 "Unn ausserdem habe ich trailing HT/SP/HT/SP whitespace \r\n"\
10319 "auf den zeilen vorher.\r\n"\
10320 "From am Zeilenbeginn und From der Mitte gibt es auch.\r\n"\
10321 ".\r\n"\
10322 "Die letzte Zeile war nur ein Punkt.\r\n"\
10323 "..\r\n"\
10324 "Das waren deren zwei.\r\n"\
10325 " \r\n"\
10326 "Die letzte Zeile war ein Leerschritt.\n"\
10327 "=VIER = EQUAL SIGNS=ON A LINE=\r\n"\
10328 "Prösterchen.\r\n"\
10329 ".\n"\
10330 "Die letzte Zeile war nur ein Punkt, mit Unix Zeilenende.\n"\
10331 "..\n"\
10332 "Das waren deren zwei. ditto.\n"\
10333 "Prösterchen.\n"\
10334 "Unn ausseerdem habe ich trailing SP/HT/SP/HT whitespace \n"\
10335 "Unn ausseerdem habe ich trailing HT/SP/HT/SP whitespace \n"\
10336 "auf den zeilen vorher.\n"\
10337 "ditto.\n"\
10338 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.\n"\
10339 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.1"\
10340 "\n"\
10341 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
10342 "\n"\
10343 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
10344 "3\n"\
10345 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
10346 "34\n"\
10347 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
10348 "345\n"\
10349 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
10350 "3456\n"\
10351 "QP am Zeilenende über soft-nl hinweg\n"\
10352 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
10353 "ö123\n"\
10354 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
10355 "1ö23\n"\
10356 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
10357 "12ö3\n"\
10358 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
10359 "123ö\n"\
10360 "=VIER = EQUAL SIGNS=ON A LINE=\n"\
10361 " \n"\
10362 "Die letzte Zeile war ein Leerschritt.\n"\
10365 # }}}
10367 # cc_all_configs() {{{
10368 # Test all configs TODO doesn't cover all *combinations*, stupid!
10369 cc_all_configs() {
10370 if [ ${MAXJOBS} -gt 1 ]; then
10371 MAXJOBS='-j '${MAXJOBS}
10372 else
10373 MAXJOBS=
10375 if [ -n "${NOCOLOUR}" ] || [ -n "${MAILX_CC_TEST_NO_COLOUR}" ]; then
10376 MAILX_CC_TEST_NO_COLOUR=1
10377 export MAILX_CC_TEST_NO_COLOUR
10380 < ${CONF} ${awk} '
10381 BEGIN{
10382 ALWAYS = "OPT_AUTOCC=1 OPT_AMALGAMATION=1"
10383 NOTME["OPT_AUTOCC_STACKPROT"] = 1
10384 NOTME["OPT_ALWAYS_UNICODE_LOCALE"] = 1
10385 NOTME["OPT_CROSS_BUILD"] = 1
10386 NOTME["OPT_AUTOCC"] = 1
10387 NOTME["OPT_AMALGAMATION"] = 1
10388 NOTME["OPT_DEBUG"] = 1
10389 NOTME["OPT_DEVEL"] = 1
10390 NOTME["OPT_ASAN_ADDRESS"] = 1
10391 NOTME["OPT_ASAN_MEMORY"] = 1
10392 NOTME["OPT_USAN"] = 1
10393 NOTME["OPT_NOMEMDBG"] = 1
10395 #OPTVALS
10396 OPTNO = 0
10398 MULCHOICE["OPT_ICONV"] = "VAL_ICONV"
10399 MULVALS["VAL_ICONV"] = 1
10400 MULCHOICE["OPT_IDNA"] = "VAL_IDNA"
10401 MULVALS["VAL_IDNA"] = 1
10403 #VALKEYS[0] = "VAL_RANDOM"
10404 VALVALS["VAL_RANDOM"] = 1
10405 VALNO = 0
10407 /^[ ]*OPT_/{
10408 sub(/^[ ]*/, "")
10409 # This bails for UnixWare 7.1.4 awk(1), but preceeding = with \
10410 # does not seem to be a compliant escape for =
10411 #sub(/=.*$/, "")
10412 $1 = substr($1, 1, index($1, "=") - 1)
10413 if(!NOTME[$1])
10414 OPTVALS[OPTNO++] = $1
10415 next
10417 /^[ ]*VAL_/{
10418 sub(/^[ ]*/, "")
10419 val = substr($0, index($0, "=") + 1)
10420 if(val ~ /^"/){
10421 val = substr(val, 2)
10422 val = substr(val, 1, length(val) - 1)
10424 $1 = substr($1, 1, index($1, "=") - 1)
10425 if(MULVALS[$1])
10426 MULVALS[$1] = val
10427 else if(VALVALS[$1]){
10428 VALKEYS[VALNO++] = $1
10429 VALVALS[$1] = val
10431 next
10433 function onepass(addons){
10434 a_onepass__worker(addons, "1", "0")
10435 a_onepass__worker(addons, "0", "1")
10437 function a_onepass__worker(addons, b0, b1){
10438 # Doing this completely sequentially and not doing make distclean in
10439 # between runs should effectively result in lesser compilations.
10440 # It is completely dumb nonetheless... TODO
10441 for(ono = 0; ono < OPTNO; ++ono){
10442 myconf = mula = ""
10443 for(i = 0; i < ono; ++i){
10444 myconf = myconf " " OPTVALS[i] "=" b0 " "
10445 if(b0 == "1"){
10446 j = MULCHOICE[OPTVALS[i]]
10447 if(j){
10448 if(i + 1 == ono)
10449 mula = j
10450 else
10451 myconf = myconf " " MULCHOICE[OPTVALS[i]] "=any "
10455 for(i = ono; i < OPTNO; ++i){
10456 myconf = myconf " " OPTVALS[i] "=" b1 " "
10457 if(b1 == "1"){
10458 j = MULCHOICE[OPTVALS[i]]
10459 if(j){
10460 if(i + 1 == OPTNO)
10461 mula = j;
10462 else
10463 myconf = myconf " " MULCHOICE[OPTVALS[i]] "=any "
10468 for(i in VALKEYS)
10469 myconf = VALKEYS[i] "=any " myconf
10471 myconf = myconf " " ALWAYS " " addons
10473 if(mula == "")
10474 print myconf
10475 else{
10476 i = split(MULVALS[mula], ia)
10477 j = "any"
10478 while(i >= 1){
10479 j = ia[i--] " " j
10480 print mula "=\"" j "\" " myconf
10485 END{
10486 # We cannot test NULL because of missing UI strings, which will end
10487 # up with different checksums
10488 print "CONFIG=NULLI OPT_AUTOCC=1"
10489 for(i in VALKEYS){
10490 j = split(VALVALS[VALKEYS[i]], ia)
10491 k = "any"
10492 while(j >= 1){
10493 k = ia[j--] " " k
10494 print VALKEYS[i] "=\"" k "\" CONFIG=NULLI OPT_AUTOCC=1"
10497 print "CONFIG=MINIMAL OPT_AUTOCC=1"
10498 print "CONFIG=NETSEND OPT_AUTOCC=1"
10499 print "CONFIG=MAXIMAL OPT_AUTOCC=1"
10500 for(i in VALKEYS){
10501 j = split(VALVALS[VALKEYS[i]], ia)
10502 k = "any"
10503 while(j >= 1){
10504 k = ia[j--] " " k
10505 print VALKEYS[i] "=\"" k "\" CONFIG=MAXIMAL OPT_AUTOCC=1"
10508 print "CONFIG=DEVEL OPT_AUTOCC=1"
10509 print "CONFIG=ODEVEL OPT_AUTOCC=1"
10511 print split_here
10513 onepass("OPT_DEBUG=1")
10514 onepass("")
10516 ' | while read c; do
10517 if [ "$c" = split_here ]; then
10518 printf 'Predefined configs done, now OPT_ combinations\n'
10519 printf 'Predefined configs done, now OPT_ combinations\n' >&2
10520 ${SHELL} -c "cd ../ && ${MAKE} distclean"
10521 continue
10523 [ -f mk-config.h ] && ${cp} mk-config.h .ccac.h
10524 printf "\n\n##########\n${MAKE} ${MAXJOBS} config $c\n"
10525 printf "\n\n##########\n${MAKE} ${MAXJOBS} config $c\n" >&2
10526 ${SHELL} -c "cd .. && ${MAKE} ${MAXJOBS} config ${c}"
10527 if [ -f .ccac.h ] && ${cmp} mk-config.h .ccac.h; then
10528 printf 'Skipping after config, nothing changed\n'
10529 printf 'Skipping after config, nothing changed\n' >&2
10530 continue
10532 ${SHELL} -c "cd ../ && ${MAKE} ${MAXJOBS} build test"
10533 done
10534 ${rm} -f .ccac.h
10535 cd .. && ${MAKE} distclean
10537 # }}}
10539 ssec=$SECONDS
10540 if [ -z "${CHECK}${RUN_TEST}" ]; then
10541 jobs_max
10542 cc_all_configs
10543 else
10544 if have_feat debug; then
10545 if have_feat devel; then
10546 JOBSYNC=1
10547 DEVELDIFF=y
10548 DUMPERR=y
10549 ARGS="${ARGS} -Smemdebug"
10550 JOBWAIT=`add $JOBWAIT $JOBWAIT`
10552 elif have_feat devel; then
10553 DEVELDIFF=y
10554 DUMPERR=y
10555 LOOPS_MAX=${LOOPS_BIG}
10557 color_init
10559 if [ -z "${RUN_TEST}" ] || [ ${#} -eq 0 ]; then
10560 jobs_max
10561 printf 'Will do up to %s tests in parallel, with a %s second timeout\n' \
10562 ${MAXJOBS} ${JOBWAIT}
10563 jobreaper_start
10564 t_all
10565 jobreaper_stop
10566 else
10567 MAXJOBS=1
10568 printf 'Tests have a %s second timeout\n' ${JOBWAIT}
10569 jobreaper_start
10570 while [ ${#} -gt 0 ]; do
10571 jspawn ${1}
10572 shift
10573 done
10574 jobreaper_stop
10578 esec=$SECONDS
10580 printf '%u tests: %s%u ok%s, %s%u failure(s)%s. %s%u test(s) skipped%s\n' \
10581 "${TESTS_PERFORMED}" "${COLOR_OK_ON}" "${TESTS_OK}" "${COLOR_OK_OFF}" \
10582 "${COLOR_ERR_ON}" "${TESTS_FAILED}" "${COLOR_ERR_OFF}" \
10583 "${COLOR_WARN_ON}" "${TESTS_SKIPPED}" "${COLOR_WARN_OFF}"
10584 if [ -n "${ssec}" ] && [ -n "${esec}" ]; then
10585 ( echo 'Elapsed seconds: '`$awk 'BEGIN{print '"${esec}"' - '"${ssec}"'}'` )
10588 exit ${ESTAT}
10589 # s-sh-mode