a_mime_write_tohdr(): FIX: do not RFC 2047 binary-encode " or ()
[s-mailx.git] / mx-test.sh
blob119dbcdc027b064e0eb18e9dea4df886379e265a
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 # C,POSIX last due to faulty localedef(1) result of GNU C lib 2.3[24]
285 # so here political friction for some decades, too
286 i=`</dev/null LC_ALL=de_DE.utf8 ${RAWMAILX} ${ARGS} -X '
287 \define cset_test {
288 \if "${ttycharset}" =%?case utf
289 \echo $LC_ALL
290 \xit 0
291 \end
292 \if "${#}" -gt 0
293 \wysh set LC_ALL=${1}
294 \shift
295 \xcall cset_test "${@}"
296 \end
297 \xit 1
299 \call cset_test \
300 de_DE.UTF-8 \
301 zh_CN.utf8 zh_CN.UTF-8 \
302 ru_RU.utf8 ru_RU.UTF-8 \
303 en_GB.utf8 en_GB.UTF-8 en_US.utf8 en_US.UTF-8 \
304 POSIX.utf8 POSIX.UTF-8 \
305 C.utf8 C.UTF-8
307 [ $? -eq 0 ] && UTF8_LOCALE=$i
310 if [ -z "${UTF8_LOCALE}" ] && (locale yesexpr) >/dev/null 2>&1; then
311 echo 'Trying to detect UTF-8 locale via locale -a'
312 UTF8_LOCALE=`locale -a | { m=
313 while read n; do
314 if { echo ${n} |
315 ${grep} -i -e utf8 -e utf-8; } >/dev/null 2>&1; then
316 m=${n}
317 if { echo ${n} |
318 ${grep} -e POSIX -e en_EN -e en_US; } \
319 >/dev/null 2>&1; then
320 break
323 done
324 echo ${m}
329 if [ -n "${UTF8_LOCALE}" ]; then
330 echo 'Using Unicode locale '"${UTF8_LOCALE}"
331 else
332 echo 'No Unicode locale found, disabling Unicode tests'
335 if [ -z "${HONOURS_READONLY}" ]; then
336 trap "${rm} -f ./.tisrdonly" EXIT
337 trap "exit 1" HUP INT TERM
338 printf '' > ./.tisrdonly
339 ${chmod} 0444 ./.tisrdonly
340 if (printf 'no\n' > ./.tisrdonly) >/dev/null 2>&1 &&
341 test -s ./.tisrdonly; then
342 HONOURS_READONLY=
343 else
344 HONOURS_READONLY=yes
346 ${rm} -f ./.tisrdonly
347 trap '' EXIT HUP INT TERM
351 export UTF8_LOCALE HONOURS_READONLY
352 # }}}
354 TESTS_PERFORMED=0 TESTS_OK=0 TESTS_FAILED=0 TESTS_SKIPPED=0
355 JOBS=0 JOBLIST= JOBREAPER= JOBSYNC=
356 SUBSECOND_SLEEP=
357 ( sleep .1 ) >/dev/null 2>&1 && SUBSECOND_SLEEP=y
359 COLOR_ERR_ON= COLOR_ERR_OFF= COLOR_DBGERR_ON= COLOR_DBGERR_OFF=
360 COLOR_WARN_ON= COLOR_WARN_OFF=
361 COLOR_OK_ON= COLOR_OK_OFF=
362 ESTAT=0
363 TEST_NAME=
365 trap "
366 jobreaper_stop
367 [ -z "${MAILX_CC_TEST_NO_CLEANUP}" ] &&
368 ${rm} -rf ./t.*.d ./t.*.io ./t.*.result ./t.time.out
369 " EXIT
370 trap "exit 1" HUP INT QUIT TERM
372 # JOBS {{{
373 if [ -n "${NOJOBS}" ]; then
374 jobs_max() { :; }
375 else
376 jobs_max() {
377 # The user desired variant
378 if ( echo "${MAKEFLAGS}" | ${grep} -- -j ) >/dev/null 2>&1; then
379 i=`echo "${MAKEFLAGS}" |
380 ${sed} -e 's/^.*-j[ ]*\([0-9]\{1,\}\).*$/\1/'`
381 if ( echo "${i}" | grep -q -e '^[0-9]\{1,\}$' ); then
382 printf 'Job number derived from MAKEFLAGS: %s\n' ${i}
383 MAXJOBS=${i}
384 [ "${MAXJOBS}" -eq 0 ] && MAXJOBS=1
385 return
389 # The actual hardware
390 printf 'all:\n' > t.mk.io
391 if ( ${MAKE} -j 10 -f t.mk.io ) >/dev/null 2>&1; then
392 if command -v nproc >/dev/null 2>&1; then
393 i=`nproc 2>/dev/null`
394 [ ${?} -eq 0 ] && MAXJOBS=${i}
395 else
396 i=`getconf _NPROCESSORS_ONLN 2>/dev/null`
397 j=${?}
398 if [ ${j} -ne 0 ]; then
399 i=`getconf NPROCESSORS_ONLN 2>/dev/null`
400 j=${?}
402 if [ ${j} -ne 0 ]; then
403 # SunOS 5.9 ++
404 if command -v kstat >/dev/null 2>&1; then
405 i=`PERL5OPT= kstat -p cpu | ${awk} '
406 BEGIN{no=0; FS=":"}
407 {if($2 > no) max = $2; next}
408 END{print ++max}
409 ' 2>/dev/null`
410 j=${?}
413 if [ ${j} -eq 0 ] && [ -n "${i}" ]; then
414 printf 'Job number derived from CPU number: %s\n' ${i}
415 MAXJOBS=${i}
418 [ "${MAXJOBS}" -eq 0 ] && MAXJOBS=1
423 jobreaper_start() {
424 case "${JOBMON}" in
425 [yY]*)
426 # There were problems when using monitor mode with mksh
427 i=`env -i ${SHELL} -c 'echo $KSH_VERSION'`
428 if [ -n "${i}" ]; then
429 if [ "${i}" != "${i#*MIRBSD}" ]; then
430 JOBMON=
434 if [ -n "${JOBMON}" ]; then
435 ( set -m ) </dev/null >/dev/null 2>&1 || JOBMON=
436 else
437 printf >&2 '%s! $JOBMON: $SHELL %s incapable, disabled!%s\n' \
438 "${COLOR_ERR_ON}" "${SHELL}" "${COLOR_ERR_OFF}"
439 printf >&2 '%s! No process groups available, killed tests may '\
440 'leave process "zombies"!%s\n' \
441 "${COLOR_ERR_ON}" "${COLOR_ERR_OFF}"
445 JOBMON=
447 esac
450 jobreaper_stop() {
451 if [ ${JOBS} -gt 0 ]; then
452 echo 'Cleaning up running jobs'
453 [ -n "${JOBREAPER}" ] && kill -KILL ${JOBREAPER} >/dev/null 2>&1
454 jtimeout
455 wait ${JOBLIST}
456 JOBLIST=
460 jspawn() {
461 if [ -n "${CHECK}" ] && [ -n "${SKIPTEST}" ]; then
462 i="${@}"
463 j="${1}"
465 set -- ${SKIPTEST}
466 SKIPTEST=
467 while [ ${#} -gt 0 ]; do
468 if [ "${1}" != "${j}" ]; then
469 SKIPTEST="${SKIPTEST} ${1}"
470 elif [ -z "${k}" ]; then
472 t_echoskip ${1}
474 shift
475 done
476 [ -n "${k}" ] && return
477 set -- "${i}"
480 if [ ${MAXJOBS} -gt 1 ]; then
481 # We are spawning multiple jobs..
482 [ ${JOBS} -eq 0 ] && printf '...'
483 JOBS=`add ${JOBS} 1`
484 printf ' [%s=%s]' ${JOBS} "${1}"
485 else
486 JOBS=1
487 # Assume problems exist, do not let user keep hanging on terminal
488 if [ -n "${RUN_TEST}" ]; then
489 printf '... [%s]\n' "${1}"
493 [ -n "${JOBMON}" ] && set -m >/dev/null 2>&1
494 ( # Place the job in its own directory to ease file management
495 trap '' EXIT HUP INT QUIT TERM USR1 USR2
496 ${mkdir} t.${JOBS}.d && cd t.${JOBS}.d &&
497 eval t_${1} ${JOBS} ${1} &&
498 ${rm} -f ../t.${JOBS}.id
499 ) > t.${JOBS}.io </dev/null & # 2>&1 </dev/null &
500 i=${!}
501 [ -n "${JOBMON}" ] && set +m >/dev/null 2>&1
502 JOBLIST="${JOBLIST} ${i}"
503 printf '%s\n%s\n' ${i} ${1} > t.${JOBS}.id
505 # ..until we should sync or reach the maximum concurrent number
506 [ ${JOBS} -lt ${MAXJOBS} ] && return
508 jsync 1
511 jsync() {
512 if [ ${JOBS} -eq 0 ]; then
513 [ -n "${TEST_ANY}" ] && printf '\n'
514 TEST_ANY=
515 return
517 [ -z "${JOBSYNC}" ] && [ ${#} -eq 0 ] && return
519 [ ${MAXJOBS} -ne 1 ] && printf ' .. waiting\n'
521 # Start an asynchronous notify process
522 ${rm} -f ./t.time.out
524 sleep ${JOBWAIT} &
525 sleeper=${!}
526 trap "kill -TERM ${sleeper}; exit 1" HUP INT TERM
527 wait ${sleeper}
528 trap '' HUP INT TERM
529 printf '' > ./t.time.out
530 ) </dev/null >/dev/null 2>&1 &
531 JOBREAPER=${!}
533 # Then loop a while, looking out for collecting tests
534 loops=0
535 while :; do
536 [ -f ./t.time.out ] && break
537 alldone=1
539 while [ ${i} -lt ${JOBS} ]; do
540 i=`add ${i} 1`
541 [ -f t.${i}.id ] || continue
542 alldone=
543 break
544 done
545 [ -n "${alldone}" ] && break
547 if [ -z "${SUBSECOND_SLEEP}" ]; then
548 loops=`add ${loops} 1`
549 [ ${loops} -lt 111 ] && continue
550 sleep 1 &
551 else
552 sleep .25 &
554 wait ${!}
555 done
557 if [ -f ./t.time.out ]; then
558 ${rm} -f ./t.time.out
559 jtimeout
560 else
561 kill -TERM ${JOBREAPER} >/dev/null 2>&1
563 wait ${JOBREAPER}
564 JOBREAPER=
566 # Now collect the zombies
567 wait ${JOBLIST}
568 JOBLIST=
570 # Update global counters
572 while [ ${i} -lt ${JOBS} ]; do
573 i=`add ${i} 1`
575 [ -s t.${i}.io ] && ${cat} t.${i}.io
576 if [ -n "${DUMPERR}" ] && [ -s ./t.${i}.d/${ERR} ]; then
577 printf '%s [Debug/Devel: nullified errors]\n' "${COLOR_DBGERR_ON}"
578 while read l; do
579 printf ' %s\n' "${l}"
580 done < t.${i}.d/${ERR}
581 printf '%s' "${COLOR_DBGERR_OFF}"
584 if [ -f t.${i}.id ]; then
585 { read pid; read desc; } < t.${i}.id
586 desc=${desc#${desc%%[! ]*}}
587 desc=${desc%${desc##*[! ]}}
588 [ -s t.${i}.io ] && printf >&2 '\n'
589 printf >&2 '%s!! Timeout: reaped job %s [%s]%s\n' \
590 "${COLOR_ERR_ON}" ${i} "${desc}" "${COLOR_ERR_OFF}"
591 TESTS_FAILED=`add ${TESTS_FAILED} 1`
592 elif [ -s t.${i}.result ]; then
593 read es tp to tf ts < t.${i}.result
594 TESTS_PERFORMED=`add ${TESTS_PERFORMED} ${tp}`
595 TESTS_OK=`add ${TESTS_OK} ${to}`
596 TESTS_FAILED=`add ${TESTS_FAILED} ${tf}`
597 TESTS_SKIPPED=`add ${TESTS_SKIPPED} ${ts}`
598 [ "${es}" != 0 ] && ESTAT=${es}
599 else
600 TESTS_FAILED=`add ${TESTS_FAILED} 1`
601 ESTAT=1
603 done
605 [ -z "${MAILX_CC_TEST_NO_CLEANUP}" ] &&
606 ${rm} -rf ./t.*.d ./t.*.id ./t.*.io t.*.result ./t.time.out
608 JOBS=0
611 jtimeout() {
613 while [ ${i} -lt ${JOBS} ]; do
614 i=`add ${i} 1`
615 if [ -f t.${i}.id ] &&
616 read pid < t.${i}.id >/dev/null 2>&1 &&
617 kill -0 ${pid} >/dev/null 2>&1; then
618 j=${pid}
619 [ -n "${JOBMON}" ] && j=-${j}
620 kill -KILL ${j} >/dev/null 2>&1
621 else
622 ${rm} -f t.${i}.id
624 done
626 # }}}
628 # echoes, checks, etc. {{{
629 t_prolog() {
630 shift
632 ESTAT=0 TESTS_PERFORMED=0 TESTS_OK=0 TESTS_FAILED=0 TESTS_SKIPPED=0 \
633 TEST_NAME=${1} TEST_ANY=
635 printf '%s[%s]%s\n' "" "${TEST_NAME}" ""
638 t_epilog() {
639 [ -n "${TEST_ANY}" ] && printf '\n'
641 printf '%s %s %s %s %s\n' \
642 ${ESTAT} \
643 ${TESTS_PERFORMED} ${TESTS_OK} ${TESTS_FAILED} ${TESTS_SKIPPED} \
644 > ../t.${1}.result
647 t_echo() {
648 [ -n "${TEST_ANY}" ] && __i__=' ' || __i__=
649 printf "${__i__}"'%s' "${*}"
650 TEST_ANY=1
653 t_echook() {
654 [ -n "${TEST_ANY}" ] && __i__=' ' || __i__=
655 printf "${__i__}"'%s%s:ok%s' "${COLOR_OK_ON}" "${*}" "${COLOR_OK_OFF}"
656 TEST_ANY=1
659 t_echoerr() {
660 ESTAT=1
661 t_echo0err "${@}"
664 t_echo0err() {
665 [ -n "${TEST_ANY}" ] && __i__="\n" || __i__=
666 printf "${__i__}"'%sERROR: %s%s\n' \
667 "${COLOR_ERR_ON}" "${*}" "${COLOR_ERR_OFF}"
668 TEST_ANY=
671 t_echowarn() {
672 [ -n "${TEST_ANY}" ] && __i__=' ' || __i__=
673 printf "${__i__}"'%s%s%s' "${COLOR_WARN_ON}" "${*}" "${COLOR_WARN_OFF}"
674 TEST_ANY=1
677 t_echoskip() {
678 [ -n "${TEST_ANY}" ] && __i__=' ' || __i__=
679 printf "${__i__}"'%s%s[skip]%s' \
680 "${COLOR_WARN_ON}" "${*}" "${COLOR_WARN_OFF}"
681 TEST_ANY=1
682 TESTS_SKIPPED=`add ${TESTS_SKIPPED} 1`
685 check() {
686 restat=${?} tid=${1} eestat=${2} f=${3} s=${4} optmode=${5}
688 TESTS_PERFORMED=`add ${TESTS_PERFORMED} 1`
690 case "${optmode}" in
691 '') ;;
692 async)
693 [ "$eestat" = - ] || exit 200
694 while :; do
695 [ -f "${f}" ] && break
696 t_echowarn "[${tid}:async=wait]"
697 sleep 1 &
698 wait ${!}
699 done
701 *) exit 222;;
702 esac
704 check__bad= check__runx=
706 if [ "${eestat}" != - ] && [ "${restat}" != "${eestat}" ]; then
707 ESTAT=1
708 t_echoerr "${tid}: bad-status: ${restat} != ${eestat}"
709 check__bad=1
712 csum="`${cksum} < "${f}" | ${sed} -e 's/[ ]\{1,\}/ /g'`"
713 if [ "${csum}" = "${s}" ]; then
714 t_echook "${tid}"
715 check__runx=${DEVELDIFF}
716 else
717 ESTAT=1
718 t_echoerr "${tid}: checksum mismatch (got ${csum})"
719 check__bad=1 check__runx=1
722 if [ -z "${check__bad}" ]; then
723 TESTS_OK=`add ${TESTS_OK} 1`
724 else
725 TESTS_FAILED=`add ${TESTS_FAILED} 1`
728 if [ -n "${CHECK}${RUN_TEST}" ]; then
729 x="t.${TEST_NAME}-${tid}"
730 if [ -n "${RUN_TEST}" ] ||
731 [ -n "${check__runx}" -a -n "${GIT_REPO}" ]; then
732 ${cp} -f "${f}" ../"${x}"
735 if [ -n "${check__runx}" ] && [ -n "${GIT_REPO}" ] &&
736 command -v diff >/dev/null 2>&1; then
737 y=test-out
738 if (git rev-parse --verify $y) >/dev/null 2>&1; then :; else
739 y=refs/remotes/origin/test-out
740 (git rev-parse --verify $y) >/dev/null 2>&1 || y=
742 if [ -n "${y}" ]; then
743 if GIT_CONFIG=/dev/null git show "${y}":"${x}" > \
744 ../"${x}".old 2>/dev/null; then
745 diff -ru ../"${x}".old ../"${x}" > ../"${x}".diff
746 if [ ${?} -eq 0 ]; then
747 [ -z "${MAILX_CC_TEST_NO_CLEANUP}" ] &&
748 ${rm} -f ../"${x}" ../"${x}".old ../"${x}".diff
749 elif [ -n "${MAILX_CC_ALL_TESTS_DUMPERR}" ]; then
750 while read l; do
751 printf 'ERROR-DIFF %s\n' "${l}"
752 done < ../"${x}".diff
754 else
755 t_echo0err "${tid}: misses [test-out] template"
762 check_ex0() {
763 # $1=test name [$2=status]
764 __qm__=${?}
765 [ ${#} -gt 1 ] && __qm__=${2}
767 TESTS_PERFORMED=`add ${TESTS_PERFORMED} 1`
769 if [ ${__qm__} -ne 0 ]; then
770 ESTAT=1
771 t_echoerr "${1}: unexpected non-0 exit status: ${__qm__}"
772 TESTS_FAILED=`add ${TESTS_FAILED} 1`
773 else
774 t_echook "${1}"
775 TESTS_OK=`add ${TESTS_OK} 1`
779 check_exn0() {
780 # $1=test name [$2=status]
781 __qm__=${?}
782 [ ${#} -gt 1 ] && __qm__=${2}
783 [ ${#} -gt 2 ] && __expect__=${3} || __expect__=
785 TESTS_PERFORMED=`add ${TESTS_PERFORMED} 1`
787 if [ ${__qm__} -eq 0 ]; then
788 ESTAT=1
789 t_echoerr "${1}: unexpected 0 exit status: ${__qm__}"
790 TESTS_FAILED=`add ${TESTS_FAILED} 1`
791 elif [ -n "${__expect__}" ] && [ ${__expect__} -ne ${__qm__} ]; then
792 ESTAT=1
793 t_echoerr "${1}: unexpected exit status: ${__qm__} != ${__expected__}"
794 TESTS_FAILED=`add ${TESTS_FAILED} 1`
795 else
796 t_echook "${1}"
797 TESTS_OK=`add ${TESTS_OK} 1`
800 # }}}
802 color_init() {
803 [ -n "${NOCOLOUR}" ] && return
804 [ -n "${MAILX_CC_TEST_NO_COLOUR}" ] && return
805 # We do not want color for "make test > .LOG"!
806 if [ -t 1 ] && command -v tput >/dev/null 2>&1; then
807 { sgr0=`tput sgr0`; } 2>/dev/null
808 [ $? -eq 0 ] || return
809 { saf1=`tput setaf 1`; } 2>/dev/null
810 [ $? -eq 0 ] || return
811 { saf2=`tput setaf 2`; } 2>/dev/null
812 [ $? -eq 0 ] || return
813 { saf3=`tput setaf 3`; } 2>/dev/null
814 [ $? -eq 0 ] || return
815 { saf5=`tput setaf 5`; } 2>/dev/null
816 [ $? -eq 0 ] || return
817 { b=`tput bold`; } 2>/dev/null
818 [ $? -eq 0 ] || return
820 COLOR_ERR_ON=${saf1}${b} COLOR_ERR_OFF=${sgr0}
821 COLOR_DBGERR_ON=${saf5} COLOR_DBGERR_OFF=${sgr0}
822 COLOR_WARN_ON=${saf3}${b} COLOR_WARN_OFF=${sgr0}
823 COLOR_OK_ON=${saf2} COLOR_OK_OFF=${sgr0}
824 unset saf1 saf2 saf3 b
828 if ( [ "$((1 + 1))" = 2 ] ) >/dev/null 2>&1; then
829 add() {
830 echo "$((${1} + ${2}))"
832 else
833 add() {
834 ${awk} 'BEGIN{print '${1}' + '${2}'}'
838 if ( [ "$((2 % 3))" = 2 ] ) >/dev/null 2>&1; then
839 modulo() {
840 echo "$((${1} % ${2}))"
842 else
843 modulo() {
844 ${awk} 'BEGIN{print '${1}' % '${2}'}'
848 have_feat() {
849 ( "${RAWMAILX}" ${ARGS} -X'echo $features' -Xx |
850 ${grep} ,+${1}, ) >/dev/null 2>&1
852 # }}}
854 # Absolute Basics {{{
855 t_X_Y_opt_input_go_stack() {
856 t_prolog "${@}"
858 ${cat} <<- '__EOT' > "${BODY}"
859 echo 1
860 define mac0 {
861 echo mac0-1 via1 $0
863 call mac0
864 echo 2
865 source '\
866 echo "define mac1 {";\
867 echo " echo mac1-1 via1 \$0";\
868 echo " call mac0";\
869 echo " echo mac1-2";\
870 echo " call mac2";\
871 echo " echo mac1-3";\
872 echo "}";\
873 echo "echo 1-1";\
874 echo "define mac2 {";\
875 echo " echo mac2-1 via1 \$0";\
876 echo " call mac0";\
877 echo " echo mac2-2";\
878 echo "}";\
879 echo "echo 1-2";\
880 echo "call mac1";\
881 echo "echo 1-3";\
882 echo "source \"\
883 echo echo 1-1-1 via1 \$0;\
884 echo call mac0;\
885 echo echo 1-1-2;\
886 | \"";\
887 echo "echo 1-4";\
889 echo 3
890 call mac2
891 echo 4
892 undefine *
893 __EOT
895 # The -X option supports multiline arguments, and those can internally use
896 # reverse solidus newline escaping. And all -X options are joined...
897 APO=\'
898 < "${BODY}" ${MAILX} ${ARGS} \
899 -X 'e\' \
900 -X ' c\' \
901 -X ' h\' \
902 -X ' o \' \
903 -X 1 \
905 define mac0 {
906 echo mac0-1 via2 $0
908 call mac0
909 echo 2
912 source '${APO}'\
913 echo "define mac1 {";\
914 echo " echo mac1-1 via2 \$0";\
915 echo " call mac0";\
916 echo " echo mac1-2";\
917 echo " call mac2";\
918 echo " echo mac1-3";\
919 echo "}";\
920 echo "echo 1-1";\
921 echo "define mac2 {";\
922 echo " echo mac2-1 via2 \$0";\
923 echo " call mac0";\
924 echo " echo mac2-2";\
925 echo "}";\
926 echo "echo 1-2";\
927 echo "call mac1";\
928 echo "echo 1-3";\
929 echo "source \"\
930 echo echo 1-1-1 via2 \$0;\
931 echo call mac0;\
932 echo echo 1-1-2;\
933 | \"";\
934 echo "echo 1-4";\
935 | '${APO}'
936 echo 3
939 call mac2
940 echo 4
941 undefine *
942 ' > "${MBOX}"
944 check 1 0 "${MBOX}" '1786542668 416'
946 # The -Y option supports multiline arguments, and those can internally use
947 # reverse solidus newline escaping.
948 APO=\'
949 < "${BODY}" ${MAILX} ${ARGS} \
950 -X 'echo FIRST_X' \
951 -X 'echo SECOND_X' \
952 -Y 'e\' \
953 -Y ' c\' \
954 -Y ' h\' \
955 -Y ' o \' \
956 -Y 1 \
958 define mac0 {
959 echo mac0-1 via2 $0
961 call mac0
962 echo 2
965 source '${APO}'\
966 echo "define mac1 {";\
967 echo " echo mac1-1 via2 \$0";\
968 echo " call mac0";\
969 echo " echo mac1-2";\
970 echo " call mac2";\
971 echo " echo mac1-3";\
972 echo "}";\
973 echo "echo 1-1";\
974 echo "define mac2 {";\
975 echo " echo mac2-1 via2 \$0";\
976 echo " call mac0";\
977 echo " echo mac2-2";\
978 echo "}";\
979 echo "echo 1-2";\
980 echo "call mac1";\
981 echo "echo 1-3";\
982 echo "source \"\
983 echo echo 1-1-1 via2 \$0;\
984 echo call mac0;\
985 echo echo 1-1-2;\
986 | \"";\
987 echo "echo 1-4";\
988 | '${APO}'
989 echo 3
992 call mac2
993 echo 4
994 undefine *
996 -Y 'echo LAST_Y' > "${MBOX}"
998 check 2 0 "${MBOX}" '1845176711 440'
1000 # Compose mode, too!
1001 </dev/null ${MAILX} ${ARGS} \
1002 -X 'echo X before compose mode' \
1003 -Y '~s Subject via -Y' \
1004 -Y 'Body via -Y' -. ./.tybox > "${MBOX}" 2>&1
1005 check 3 0 ./.tybox '264636255 125'
1006 check 4 - "${MBOX}" '467429373 22'
1008 ${cat} <<-_EOT | ${MAILX} ${ARGS} -t \
1009 -X 'echo X before compose mode' \
1010 -Y '~s Subject via -Y' \
1011 -Y 'Additional body via -Y' -. ./.tybox > "${MBOX}" 2>&1
1012 from: heya@exam.ple
1013 subject:diet not to be seen!
1015 this body via -t.
1016 _EOT
1017 check 5 0 ./.tybox '3313167452 299'
1018 check 6 - "${MBOX}" '467429373 22'
1021 printf 'this body via stdin pipe.\n' | ${MAILX} ${NOBATCH_ARGS} \
1022 -X 'echo X before compose mode' \
1023 -Y '~s Subject via -Y (not!)' \
1024 -Y 'Additional body via -Y, nobatch mode' -. ./.tybox > "${MBOX}" 2>&1
1025 check 7 0 ./.tybox '1561798488 476'
1026 check 8 - "${MBOX}" '467429373 22'
1028 printf 'this body via stdin pipe.\n' | ${MAILX} ${ARGS} \
1029 -X 'echo X before compose mode' \
1030 -Y '~s Subject via -Y' \
1031 -Y 'Additional body via -Y, batch mode' -. ./.tybox > "${MBOX}" 2>&1
1032 check 9 0 ./.tybox '3245082485 650'
1033 check 10 - "${MBOX}" '467429373 22'
1035 # Test for [8412796a] (n_cmd_arg_parse(): FIX token error -> crash, e.g.
1036 # "-RX 'bind;echo $?' -Xx".., 2018-08-02)
1037 ${MAILX} ${ARGS} -RX'call;echo $?' -Xx > ./.tall 2>&1
1038 ${MAILX} ${ARGS} -RX'call ;echo $?' -Xx >> ./.tall 2>&1
1039 ${MAILX} ${ARGS} -RX'call ;echo $?' -Xx >> ./.tall 2>&1
1040 ${MAILX} ${ARGS} -RX'call ;echo $?' -Xx >> ./.tall 2>&1
1041 check cmdline 0 ./.tall '1867586969 8'
1043 t_epilog "${@}"
1046 t_X_errexit() {
1047 t_prolog "${@}"
1049 if have_feat uistrings; then :; else
1050 t_echoskip '[!UISTRINGS]'
1051 t_epilog "${@}"
1052 return
1055 ${cat} <<- '__EOT' > "${BODY}"
1056 echo one
1057 echos nono
1058 echo two
1059 __EOT
1061 </dev/null ${MAILX} ${ARGS} -Snomemdebug \
1062 -X'echo one' -X' echos nono ' -X'echo two' \
1063 > "${MBOX}" 2>&1
1064 check 1 0 "${MBOX}" '2700500141 51'
1066 </dev/null ${MAILX} ${ARGS} -X'source '"${BODY}" -Snomemdebug \
1067 > "${MBOX}" 2>&1
1068 check 2 0 "${MBOX}" '2700500141 51'
1070 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Snomemdebug \
1071 > "${MBOX}" 2>&1
1072 check 3 0 "${MBOX}" '2700500141 51'
1076 </dev/null ${MAILX} ${ARGS} -Serrexit -Snomemdebug \
1077 -X'echo one' -X' echos nono ' -X'echo two' \
1078 > "${MBOX}" 2>&1
1079 check 4 1 "${MBOX}" '4096689457 47'
1081 </dev/null ${MAILX} ${ARGS} -X'source '"${BODY}" -Serrexit -Snomemdebug \
1082 > "${MBOX}" 2>&1
1083 check 5 1 "${MBOX}" '4096689457 47'
1085 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Serrexit -Snomemdebug \
1086 > "${MBOX}" 2>&1
1087 check 6 1 "${MBOX}" '1669262132 170'
1089 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Sposix -Snomemdebug \
1090 > "${MBOX}" 2>&1
1091 check 7 1 "${MBOX}" '1669262132 170'
1093 ## Repeat 4-7 with ignerr set
1095 ${sed} -e 's/^echos /ignerr echos /' < "${BODY}" > "${MBOX}"
1097 </dev/null ${MAILX} ${ARGS} -Serrexit -Snomemdebug \
1098 -X'echo one' -X'ignerr echos nono ' -X'echo two' \
1099 > "${BODY}" 2>&1
1100 check 8 0 "${BODY}" '2700500141 51'
1102 </dev/null ${MAILX} ${ARGS} -X'source '"${MBOX}" -Serrexit -Snomemdebug \
1103 > "${BODY}" 2>&1
1104 check 9 0 "${BODY}" '2700500141 51'
1106 </dev/null MAILRC="${MBOX}" ${MAILX} ${ARGS} -:u -Serrexit -Snomemdebug \
1107 > "${BODY}" 2>&1
1108 check 10 0 "${BODY}" '2700500141 51'
1110 </dev/null MAILRC="${MBOX}" ${MAILX} ${ARGS} -:u -Sposix -Snomemdebug \
1111 > "${BODY}" 2>&1
1112 check 11 0 "${BODY}" '2700500141 51'
1114 # Ensure "good-injection" in a deeper indirection does not cause trouble
1115 # This actually only works with MLE and HISTORY, and TODO needs a pseudo TTY
1116 # interaction so that we DO initialize our line editor...
1117 ${cat} <<- '__EOT' > "${BODY}"
1118 define oha {
1119 return 0
1121 define x {
1122 eval set $xarg
1123 echoes time
1124 return 0
1126 __EOT
1128 printf 'source %s\ncall x\necho au' "${BODY}" |
1129 ${MAILX} ${ARGS} -Snomemdebug -Sxarg=errexit > "${MBOX}" 2>&1
1130 check 12 1 "${MBOX}" '2908921993 44'
1132 printf 'source %s\nset on-history-addition=oha\ncall x\necho au' "${BODY}" |
1133 ${MAILX} ${ARGS} -Snomemdebug -Sxarg=errexit > "${MBOX}" 2>&1
1134 check 13 1 "${MBOX}" '2908921993 44'
1136 printf 'source %s\ncall x\necho au' "${BODY}" |
1137 ${MAILX} ${ARGS} -Snomemdebug -Sxarg=nowhere > "${MBOX}" 2>&1
1138 check 14 0 "${MBOX}" '2049365617 47'
1140 t_epilog "${@}"
1143 t_Y_errexit() {
1144 t_prolog "${@}"
1146 if have_feat uistrings; then :; else
1147 t_echoskip '[!UISTRINGS]'
1148 t_epilog "${@}"
1149 return
1152 ${cat} <<- '__EOT' > "${BODY}"
1153 echo one
1154 echos nono
1155 echo two
1156 __EOT
1158 </dev/null ${MAILX} ${ARGS} -Snomemdebug \
1159 -Y'echo one' -Y' echos nono ' -Y'echo two' \
1160 > "${MBOX}" 2>&1
1161 check 1 0 "${MBOX}" '2700500141 51'
1163 </dev/null ${MAILX} ${ARGS} -Y'source '"${BODY}" -Snomemdebug \
1164 > "${MBOX}" 2>&1
1165 check 2 0 "${MBOX}" '2700500141 51'
1169 </dev/null ${MAILX} ${ARGS} -Serrexit -Snomemdebug \
1170 -Y'echo one' -Y' echos nono ' -Y'echo two' \
1171 > "${MBOX}" 2>&1
1172 check 3 1 "${MBOX}" '4096689457 47'
1174 </dev/null ${MAILX} ${ARGS} -Y'source '"${BODY}" -Serrexit -Snomemdebug \
1175 > "${MBOX}" 2>&1
1176 check 4 1 "${MBOX}" '4096689457 47'
1178 ## Repeat 3-4 with ignerr set
1180 ${sed} -e 's/^echos /ignerr echos /' < "${BODY}" > "${MBOX}"
1182 </dev/null ${MAILX} ${ARGS} -Serrexit -Snomemdebug \
1183 -Y'echo one' -Y'ignerr echos nono ' -Y'echo two' \
1184 > "${BODY}" 2>&1
1185 check 5 0 "${BODY}" '2700500141 51'
1187 </dev/null ${MAILX} ${ARGS} -Y'source '"${MBOX}" -Serrexit -Snomemdebug \
1188 > "${BODY}" 2>&1
1189 check 6 0 "${BODY}" '2700500141 51'
1191 t_epilog "${@}"
1194 t_S_freeze() {
1195 t_prolog "${@}"
1196 oterm=$TERM
1197 unset TERM
1199 # Test basic assumption
1200 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} \
1201 -X'echo asksub<$asksub> dietcurd<$dietcurd>' \
1202 -Xx > "${MBOX}" 2>&1
1203 check 1 0 "${MBOX}" '270686329 21'
1206 ${cat} <<- '__EOT' > "${BODY}"
1207 echo asksub<$asksub>
1208 set asksub
1209 echo asksub<$asksub>
1210 __EOT
1211 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
1212 -Snoasksub -Sasksub -Snoasksub \
1213 -X'echo asksub<$asksub>' -X'set asksub' -X'echo asksub<$asksub>' \
1214 -Xx > "${MBOX}" 2>&1
1215 check 2 0 "${MBOX}" '3182942628 37'
1217 ${cat} <<- '__EOT' > "${BODY}"
1218 echo asksub<$asksub>
1219 unset asksub
1220 echo asksub<$asksub>
1221 __EOT
1222 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
1223 -Snoasksub -Sasksub \
1224 -X'echo asksub<$asksub>' -X'unset asksub' -X'echo asksub<$asksub>' \
1225 -Xx > "${MBOX}" 2>&1
1226 check 3 0 "${MBOX}" '2006554293 39'
1229 ${cat} <<- '__EOT' > "${BODY}"
1230 echo dietcurd<$dietcurd>
1231 set dietcurd=cherry
1232 echo dietcurd<$dietcurd>
1233 __EOT
1234 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
1235 -Sdietcurd=strawberry -Snodietcurd -Sdietcurd=vanilla \
1236 -X'echo dietcurd<$dietcurd>' -X'unset dietcurd' \
1237 -X'echo dietcurd<$dietcurd>' \
1238 -Xx > "${MBOX}" 2>&1
1239 check 4 0 "${MBOX}" '1985768109 65'
1241 ${cat} <<- '__EOT' > "${BODY}"
1242 echo dietcurd<$dietcurd>
1243 unset dietcurd
1244 echo dietcurd<$dietcurd>
1245 __EOT
1246 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
1247 -Sdietcurd=strawberry -Snodietcurd \
1248 -X'echo dietcurd<$dietcurd>' -X'set dietcurd=vanilla' \
1249 -X'echo dietcurd<$dietcurd>' \
1250 -Xx > "${MBOX}" 2>&1
1251 check 5 0 "${MBOX}" '151574279 51'
1253 # TODO once we have a detached one with env=1..
1254 if [ -n "`</dev/null ${MAILX} ${ARGS} -X'!echo \$TERM' -Xx`" ]; then
1255 t_echoskip 's_freeze-{6,7}:[shell sets $TERM]'
1256 else
1257 ${cat} <<- '__EOT' > "${BODY}"
1258 !echo "shell says TERM<$TERM>"
1259 echo TERM<$TERM>
1260 !echo "shell says TERM<$TERM>"
1261 set TERM=cherry
1262 !echo "shell says TERM<$TERM>"
1263 echo TERM<$TERM>
1264 !echo "shell says TERM<$TERM>"
1265 __EOT
1266 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
1267 -STERM=strawberry -SnoTERM -STERM=vanilla \
1268 -X'echo mail<$TERM>' -X'unset TERM' \
1269 -X'!echo "shell says TERM<$TERM>"' -X'echo TERM<$TERM>' \
1270 -Xx > "${MBOX}" 2>&1
1271 check 6 0 "${MBOX}" '1211476036 167'
1273 ${cat} <<- '__EOT' > "${BODY}"
1274 !echo "shell says TERM<$TERM>"
1275 echo TERM<$TERM>
1276 !echo "shell says TERM<$TERM>"
1277 set TERM=cherry
1278 !echo "shell says TERM<$TERM>"
1279 echo TERM<$TERM>
1280 !echo "shell says TERM<$TERM>"
1281 __EOT
1282 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
1283 -STERM=strawberry -SnoTERM \
1284 -X'echo TERM<$TERM>' -X'set TERM=vanilla' \
1285 -X'!echo "shell says TERM<$TERM>"' -X'echo TERM<$TERM>' \
1286 -Xx > "${MBOX}" 2>&1
1287 check 7 0 "${MBOX}" '3365080441 132'
1290 TERM=$oterm
1291 t_epilog "${@}"
1294 t_f_batch_order() {
1295 t_prolog "${@}"
1297 t__gen_msg subject f-batch-order > "${MBOX}"
1299 # This would exit 64 (EX_USAGE) from ? to [fbddb3b3] (FIX: -f: add
1300 # n_PO_f_FLAG to avoid that command line order matters)
1301 </dev/null ${MAILX} ${NOBATCH_ARGS} -R -f -# \
1302 -Y 'echo du;h;echo da;x' "${MBOX}" >./.tall 2>&1
1303 check 1 0 ./.tall '1690247457 86'
1305 # And this ever worked (hopefully)
1306 </dev/null ${MAILX} ${NOBATCH_ARGS} -R -# -f \
1307 -Y 'echo du;h;echo da;x' "${MBOX}" >./.tall 2>&1
1308 check 2 0 ./.tall '1690247457 86'
1310 t_epilog "${@}"
1313 t_input_inject_semicolon_seq() {
1314 t_prolog "${@}"
1316 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
1317 define mydeepmac {
1318 echon '(mydeepmac)';
1320 define mymac {
1321 echon this_is_mymac;call mydeepmac;echon ';';
1323 echon one';';call mymac;echon two";";call mymac;echo three$';';
1324 define mymac {
1325 echon this_is_mymac;call mydeepmac;echon ,TOO'!;';
1327 echon one';';call mymac;echon two";";call mymac;echo three$';';
1328 __EOT
1330 check 1 0 "${MBOX}" '512117110 140'
1332 t_epilog "${@}"
1335 t_wysh() {
1336 t_prolog "${@}"
1338 ${cat} <<- '__EOT' > "${BODY}"
1340 echo abcd
1341 echo a'b'c'd'
1342 echo a"b"c"d"
1343 echo a$'b'c$'d'
1344 echo 'abcd'
1345 echo "abcd"
1346 echo $'abcd'
1347 echo a\ b\ c\ d
1348 echo a 'b c' d
1349 echo a "b c" d
1350 echo a $'b c' d
1352 echo 'a$`"\'
1353 echo "a\$\`'\"\\"
1354 echo $'a\$`\'\"\\'
1355 echo $'a\$`\'"\\'
1356 # DIET=CURD TIED=
1357 echo 'a${DIET}b${TIED}c\${DIET}d\${TIED}e' # COMMENT
1358 echo "a${DIET}b${TIED}c\${DIET}d\${TIED}e"
1359 echo $'a${DIET}b${TIED}c\${DIET}d\${TIED}e'
1361 echo a$'\101\0101\x41\u0041\u41\U00000041\U41'c
1362 echo a$'\u0041\u41\u0C1\U00000041\U41'c
1363 echo a$'\377'c
1364 echo a$'\0377'c
1365 echo a$'\400'c
1366 echo a$'\0400'c
1367 echo a$'\U1100001'c
1369 echo a$'b\0c'd
1370 echo a$'b\00c'de
1371 echo a$'b\000c'df
1372 echo a$'b\0000c'dg
1373 echo a$'b\x0c'dh
1374 echo a$'b\x00c'di
1375 echo a$'b\u0'dj
1376 echo a$'b\u00'dk
1377 echo a$'b\u000'dl
1378 echo a$'b\u0000'dm
1379 echo a$'b\U0'dn
1380 echo a$'b\U00'do
1381 echo a$'b\U000'dp
1382 echo a$'b\U0000'dq
1383 echo a$'b\U00000'dr
1384 echo a$'b\U000000'ds
1385 echo a$'b\U0000000'dt
1386 echo a$'b\U00000000'du
1388 echo a$'\cI'b
1389 echo a$'\011'b
1390 echo a$'\x9'b
1391 echo a$'\u9'b
1392 echo a$'\U9'b
1393 echo a$'\c@'b c d
1394 __EOT
1396 if [ -z "${UTF8_LOCALE}" ]; then
1397 t_echoskip 'wysh-unicode:[no UTF-8 locale]'
1398 else
1399 < "${BODY}" DIET=CURD TIED= \
1400 LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} > "${MBOX}" 2>>${ERR}
1401 check unicode 0 "${MBOX}" '475805847 317'
1404 < "${BODY}" DIET=CURD TIED= ${MAILX} ${ARGS} > "${MBOX}" 2>>${ERR}
1405 check c 0 "${MBOX}" '1473887148 321'
1407 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
1408 wysh set mager='\hey\'
1409 varshow mager
1410 wysh set mager="\hey\\"
1411 varshow mager
1412 wysh set mager=$'\hey\\'
1413 varshow mager
1414 __EOT
1415 check 3 0 "${MBOX}" '1289698238 69'
1417 t_epilog "${@}"
1420 t_commandalias() {
1421 t_prolog "${@}"
1423 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
1424 commandalias echo echo hoho
1425 echo stop.
1426 commandalias X Xx
1427 commandalias Xx XxX
1428 commandalias XxX XxXx
1429 commandalias XxXx XxXxX
1430 commandalias XxXxX XxXxXx
1431 commandalias XxXxXx echo huhu
1432 commandalias XxXxXxX echo huhu
1434 commandalias XxXxXx XxXxXxX
1436 uncommandalias echo
1437 commandalias XxXxXx echo huhu
1439 __EOT
1441 check 1 0 "${MBOX}" '1638809585 36'
1443 t_epilog "${@}"
1446 t_posix_abbrev() {
1447 t_prolog "${@}"
1449 # In POSIX C181 standard order
1450 </dev/null ${MAILX} ${ARGS} \
1451 -Y 'echon alias/a\ ; ? a; echon group/g\ ; ?g' \
1452 -Y 'echon alternates/alt\ ; ? alt' \
1453 -Y 'echon chdir/ch\ ; ? ch' \
1454 -Y 'echon copy/c\ ; ? c; echon Copy/C\ ; ?C' \
1455 -Y 'echon delete/d\ ; ? d' \
1456 -Y 'echon discard/di\ ; ? di; echon ignore/ig\ ; ?ig' \
1457 -Y 'echon echo/ec\ ; ? ec' \
1458 -Y 'echon edit/e\ ; ? e' \
1459 -Y 'echon exit/ex\ ; ? ex; echon xit/x\ ; ?x' \
1460 -Y 'echon file/fi\ ; ? fi; echon folder/fold\ ; ? fold' \
1461 -Y 'echon followup/fo\ ; ? fo; echon Followup/F\ ; ?F' \
1462 -Y 'echon from/f\ ; ? f' \
1463 -Y 'echon headers/h\ ; ? h' \
1464 -Y 'echon help/hel\ ; ? hel' \
1465 -Y 'echon hold/ho\ ; ? ho; echon preserve/pre\ ; ? pre' \
1466 -Y 'echon if/i\ ; ? i; echon else/el\ ; ? el; echon endif/en\ ; ? en' \
1467 -Y 'echon list/l\ ; ? l' \
1468 -Y 'echon mail/m\ ; ? m' \
1469 -Y 'echon mbox/mb\ ; ? mb' \
1470 -Y 'echon next/n\ ; ? n' \
1471 -Y 'echon pipe/pi\ ; ? pi' \
1472 -Y 'echon Print/P\ ; ? P; echon Type/T\ ; ? T' \
1473 -Y 'echon print/p\ ; ? p; echon type/t\ ; ? t' \
1474 -Y 'echon quit/q\ ; ? q' \
1475 -Y 'echon Reply/R\ ; ? R' \
1476 -Y 'echon reply/r\ ; ? r' \
1477 -Y 'echon retain/ret\ ; ? ret' \
1478 -Y 'echon save/s\ ; ? s; echon Save/S\ ; ? S' \
1479 -Y 'echon set/se\ ; ? se' \
1480 -Y 'echon shell/sh\ ; ? sh' \
1481 -Y 'echon size/si\ ; ? si' \
1482 -Y 'echon source/so\ ; ? so' \
1483 -Y 'echon touch/tou\ ; ? tou' \
1484 -Y 'echon unalias/una\ ; ? una' \
1485 -Y 'echon undelete/u\ ; ? u' \
1486 -Y 'echon unset/uns\ ; ? uns' \
1487 -Y 'echon visual/v\ ; ? v' \
1488 -Y 'echon write/w\ ; ? w' \
1489 | ${sed} -e 's/:.*$//' > "${MBOX}"
1490 check 1 0 "${MBOX}" '1012680481 968'
1492 t_epilog "${@}"
1494 # }}}
1496 # Basics {{{
1497 t_shcodec() {
1498 t_prolog "${@}"
1500 # XXX the first needs to be checked, it is quite dumb as such
1501 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
1502 commandalias x echo '$?/$^ERRNAME'
1503 shcodec e abcd
1505 shcodec d abcd
1507 shcodec e a'b'c'd'
1509 shcodec d a'b'c'd'
1511 shcodec e a"b"c"d"
1513 shcodec d a"b"c"d"
1515 shcodec e a$'b'c$'d'
1517 shcodec d a$'b'c$'d'
1519 shcodec e 'abcd'
1521 shcodec d 'abcd'
1523 shcodec e "abcd"
1525 shcodec d "abcd"
1527 shcodec e $'abcd'
1529 shcodec d $'abcd'
1531 # same but with vput
1532 commandalias y echo '$?/$^ERRNAME $res'
1533 vput shcodec res e abcd
1535 eval shcodec d $res
1537 vput shcodec res d abcd
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 a$'b'c$'d'
1559 eval shcodec d $res
1561 vput shcodec res d a$'b'c$'d'
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
1581 vput shcodec res e $'abcd'
1583 eval shcodec d $res
1585 vput shcodec res d $'abcd'
1587 eval shcodec d $res
1590 vput shcodec res e a b\ c d
1592 eval shcodec d $res
1594 vput shcodec res d a b\ c d
1596 vput shcodec res e ab cd
1598 eval shcodec d $res
1600 vput shcodec res d 'ab cd'
1602 vput shcodec res e a 'b c' d
1604 eval shcodec d $res
1606 vput shcodec res d a 'b c' d
1608 vput shcodec res e a "b c" d
1610 eval shcodec d $res
1612 vput shcodec res d a "b c" d
1614 vput shcodec res e a $'b c' d
1616 eval shcodec d $res
1618 vput shcodec res d a $'b c' d
1621 vput shcodec res e 'a$`"\'
1623 eval shcodec d $res
1625 vput shcodec res d 'a$`"\'
1627 vput shcodec res e "a\$\`'\"\\"
1629 eval shcodec d $res
1631 vput shcodec res d "a\$\`'\"\\"
1633 vput shcodec res e $'a\$`\'\"\\'
1635 eval shcodec d $res
1637 vput shcodec res d $'a\$`\'\"\\'
1639 vput shcodec res e $'a\$`\'"\\'
1641 eval shcodec d $res
1643 vput shcodec res d $'a\$`\'"\\'
1646 set diet=curd
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 vput shcodec res e "a${diet}c"
1657 eval shcodec d $res
1659 eval vput shcodec res e "a${diet}c"
1661 eval shcodec d $res
1663 __EOT
1664 check 1 0 "${MBOX}" '3316745312 1241'
1666 if [ -z "${UTF8_LOCALE}" ]; then
1667 t_echoskip 'unicode:[no UTF-8 locale]'
1668 elif have_feat multibyte-charsets; then
1669 ${cat} <<- '__EOT' | LC_ALL=${UTF8_LOCALE} \
1670 ${MAILX} ${ARGS} > "${MBOX}" 2>>${ERR}
1672 shcodec e täst
1673 shcodec +e täst
1674 shcodec d $'t\u00E4st'
1675 shcodec e aՍc
1676 shcodec +e aՍc
1677 shcodec d $'a\u054Dc'
1678 shcodec e a𝕂c
1679 shcodec +e a𝕂c
1680 shcodec d $'a\U0001D542c'
1681 __EOT
1682 check unicode 0 "${MBOX}" '1175985867 77'
1683 else
1684 t_echoskip 'unicode:[!MULTIBYTE-CHARSETS]'
1687 t_epilog "${@}"
1690 t_ifelse() {
1691 t_prolog "${@}"
1693 # v15compat: old and new tests share the same result files!
1694 # v15compat: i.e., just throw away -old tests one day
1696 # Nestable conditions test
1697 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
1698 if 0
1699 echo 1.err
1700 else
1701 echo 1.ok
1702 endif
1703 if 1
1704 echo 2.ok
1705 else
1706 echo 2.err
1707 endif
1708 if $dietcurd
1709 echo 3.err
1710 else
1711 echo 3.ok
1712 endif
1713 set dietcurd=yoho
1714 if $dietcurd
1715 echo 4.ok
1716 else
1717 echo 4.err
1718 endif
1719 if $dietcurd == 'yoho'
1720 echo 5.ok
1721 else
1722 echo 5.err
1723 endif
1724 if $dietcurd ==? 'Yoho'
1725 echo 5-1.ok
1726 else
1727 echo 5-1.err
1728 endif
1729 if $dietcurd == 'Yoho'
1730 echo 5-2.err
1731 else
1732 echo 5-2.ok
1733 endif
1734 if $dietcurd != 'yoho'
1735 echo 6.err
1736 else
1737 echo 6.ok
1738 endif
1739 if $dietcurd !=?case 'Yoho'
1740 echo 6-1.err
1741 else
1742 echo 6-1.ok
1743 endif
1744 if $dietcurd != 'Yoho'
1745 echo 6-2.ok
1746 else
1747 echo 6-2.err
1748 endif
1749 # Nesting
1750 if faLse
1751 echo 7.err1
1752 if tRue
1753 echo 7.err2
1754 if yEs
1755 echo 7.err3
1756 else
1757 echo 7.err4
1758 endif
1759 echo 7.err5
1760 endif
1761 echo 7.err6
1762 else
1763 echo 7.ok7
1764 if YeS
1765 echo 7.ok8
1766 if No
1767 echo 7.err9
1768 else
1769 echo 7.ok9
1770 endif
1771 echo 7.ok10
1772 else
1773 echo 7.err11
1774 if yeS
1775 echo 7.err12
1776 else
1777 echo 7.err13
1778 endif
1779 endif
1780 echo 7.ok14
1781 endif
1782 if r
1783 echo 8.ok1
1784 if R
1785 echo 8.ok2
1786 else
1787 echo 8.err2
1788 endif
1789 echo 8.ok3
1790 else
1791 echo 8.err1
1792 endif
1793 if s
1794 echo 9.err1
1795 else
1796 echo 9.ok1
1797 if S
1798 echo 9.err2
1799 else
1800 echo 9.ok2
1801 endif
1802 echo 9.ok3
1803 endif
1804 # `elif'
1805 if $dietcurd == 'yohu'
1806 echo 10.err1
1807 elif $dietcurd == 'yoha'
1808 echo 10.err2
1809 elif $dietcurd == 'yohe'
1810 echo 10.err3
1811 elif $dietcurd == 'yoho'
1812 echo 10.ok1
1813 if $dietcurd == 'yohu'
1814 echo 10.err4
1815 elif $dietcurd == 'yoha'
1816 echo 10.err5
1817 elif $dietcurd == 'yohe'
1818 echo 10.err6
1819 elif $dietcurd == 'yoho'
1820 echo 10.ok2
1821 if $dietcurd == 'yohu'
1822 echo 10.err7
1823 elif $dietcurd == 'yoha'
1824 echo 10.err8
1825 elif $dietcurd == 'yohe'
1826 echo 10.err9
1827 elif $dietcurd == 'yoho'
1828 echo 10.ok3
1829 else
1830 echo 10.err10
1831 endif
1832 else
1833 echo 10.err11
1834 endif
1835 else
1836 echo 10.err12
1837 endif
1838 # integer
1839 set dietcurd=10
1840 if $dietcurd -lt 11
1841 echo 11.ok1
1842 if $dietcurd -gt 9
1843 echo 11.ok2
1844 else
1845 echo 11.err2
1846 endif
1847 if $dietcurd -eq 10
1848 echo 11.ok3
1849 else
1850 echo 11.err3
1851 endif
1852 if $dietcurd -ge 10
1853 echo 11.ok4
1854 else
1855 echo 11.err4
1856 endif
1857 if $dietcurd -le 10
1858 echo 11.ok5
1859 else
1860 echo 11.err5
1861 endif
1862 if $dietcurd -ge 11
1863 echo 11.err6
1864 else
1865 echo 11.ok6
1866 endif
1867 if $dietcurd -le 9
1868 echo 11.err7
1869 else
1870 echo 11.ok7
1871 endif
1872 else
1873 echo 11.err1
1874 endif
1875 set dietcurd=Abc
1876 if $dietcurd < aBd
1877 echo 12.ok1
1878 if $dietcurd >? abB
1879 echo 12.ok2
1880 else
1881 echo 12.err2
1882 endif
1883 if $dietcurd ==?case aBC
1884 echo 12.ok3
1885 else
1886 echo 12.err3
1887 endif
1888 if $dietcurd >=?ca AbC
1889 echo 12.ok4
1890 else
1891 echo 12.err4
1892 endif
1893 if $dietcurd <=? ABc
1894 echo 12.ok5
1895 else
1896 echo 12.err5
1897 endif
1898 if $dietcurd >=?case abd
1899 echo 12.err6
1900 else
1901 echo 12.ok6
1902 endif
1903 if $dietcurd <=? abb
1904 echo 12.err7
1905 else
1906 echo 12.ok7
1907 endif
1908 else
1909 echo 12.err1
1910 endif
1911 if $dietcurd < aBc
1912 echo 12-1.ok
1913 else
1914 echo 12-1.err
1915 endif
1916 if $dietcurd <? aBc
1917 echo 12-2.err
1918 else
1919 echo 12-2.ok
1920 endif
1921 if $dietcurd > ABc
1922 echo 12-3.ok
1923 else
1924 echo 12-3.err
1925 endif
1926 if $dietcurd >? ABc
1927 echo 12-3.err
1928 else
1929 echo 12-3.ok
1930 endif
1931 if $dietcurd =%?case aB
1932 echo 13.ok
1933 else
1934 echo 13.err
1935 endif
1936 if $dietcurd =% aB
1937 echo 13-1.err
1938 else
1939 echo 13-1.ok
1940 endif
1941 if $dietcurd =%? bC
1942 echo 14.ok
1943 else
1944 echo 14.err
1945 endif
1946 if $dietcurd !% aB
1947 echo 15-1.ok
1948 else
1949 echo 15-1.err
1950 endif
1951 if $dietcurd !%? aB
1952 echo 15-2.err
1953 else
1954 echo 15-2.ok
1955 endif
1956 if $dietcurd !% bC
1957 echo 15-3.ok
1958 else
1959 echo 15-3.err
1960 endif
1961 if $dietcurd !%? bC
1962 echo 15-4.err
1963 else
1964 echo 15-4.ok
1965 endif
1966 if $dietcurd =% Cd
1967 echo 16.err
1968 else
1969 echo 16.ok
1970 endif
1971 if $dietcurd !% Cd
1972 echo 17.ok
1973 else
1974 echo 17.err
1975 endif
1976 set diet=abc curd=abc
1977 if $diet == $curd
1978 echo 18.ok
1979 else
1980 echo 18.err
1981 endif
1982 set diet=abc curd=abcd
1983 if $diet != $curd
1984 echo 19.ok
1985 else
1986 echo 19.err
1987 endif
1988 # 1. Shitty grouping capabilities as of today
1989 unset diet curd ndefined
1990 if [ [ false ] || [ false ] || [ true ] ] && \
1991 [ [ false ] || [ true ] ] && \
1992 [ yes ]
1993 echo 20.ok
1994 else
1995 echo 20.err
1996 endif
1997 if [ [ [ [ 0 ] || [ 1 ] ] && [ [ 1 ] || [ 0 ] ] ] && [ 1 ] ] && [ yes ]
1998 echo 21.ok
1999 else
2000 echo 21.err
2001 endif
2002 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] ]
2003 echo 22.ok
2004 else
2005 echo 22.err
2006 endif
2007 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] ]
2008 echo 23.ok
2009 else
2010 echo 23.err
2011 endif
2012 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] && [ no ]
2013 echo 24.err
2014 else
2015 echo 24.ok
2016 endif
2017 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] \
2018 && [ no ] || [ yes ]
2019 echo 25.ok
2020 else
2021 echo 25.err
2022 endif
2023 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
2024 echo 26.ok
2025 else
2026 echo 26.err
2027 endif
2028 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 0 ] ]
2029 echo 27.err
2030 else
2031 echo 27.ok
2032 endif
2033 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 0 ] ] && [ 1 ] ] ] && [ 1 ] ]
2034 echo 28.err
2035 else
2036 echo 28.ok
2037 endif
2038 if [ [ [ [ [ [ [ 0 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
2039 echo 29.err
2040 else
2041 echo 29.ok
2042 endif
2043 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 0 ]
2044 echo 30.err
2045 else
2046 echo 30.ok
2047 endif
2048 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 1 ]
2049 echo 31.ok
2050 else
2051 echo 31.err
2052 endif
2053 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ]
2054 echo 32.err
2055 else
2056 echo 32.ok
2057 endif
2058 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 1 ]
2059 echo 33.ok
2060 else
2061 echo 33.err
2062 endif
2063 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 0 ]
2064 echo 34.err
2065 else
2066 echo 34.ok
2067 endif
2068 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 1 ]
2069 echo 35.ok
2070 else
2071 echo 35.err
2072 endif
2073 set diet=yo curd=ho
2074 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
2075 echo 36.err
2076 else
2077 echo 36.ok
2078 endif
2079 set ndefined
2080 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
2081 echo 37.ok
2082 else
2083 echo 37.err
2084 endif
2085 # 2. Shitty grouping capabilities as of today
2086 unset diet curd ndefined
2087 if [ false || false || true ] && [ false || true ] && yes
2088 echo 40.ok
2089 else
2090 echo 40.err
2091 endif
2092 if [ [ [ 0 || 1 ] && [ 1 || 0 ] ] && 1 ] && [ yes ]
2093 echo 41.ok
2094 else
2095 echo 41.err
2096 endif
2097 if [ 1 || 0 || 0 || 0 ]
2098 echo 42.ok
2099 else
2100 echo 42.err
2101 endif
2102 if [ 1 || 0 || 0 || 0 || [ 1 ] ]
2103 echo 43.ok
2104 else
2105 echo 43.err
2106 endif
2107 if [ 1 || 0 || 0 || 0 || [ 1 ] || 1 ] && no
2108 echo 44.err
2109 else
2110 echo 44.ok
2111 endif
2112 if [ 1 || 0 || 0 || 0 || 1 || [ 1 ] ] && no || [ yes ]
2113 echo 45.ok
2114 else
2115 echo 45.err
2116 endif
2117 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && 1 ] ] && [ 1 ] ]
2118 echo 46.ok
2119 else
2120 echo 46.err
2121 endif
2122 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && [ 1 ] ] ] && 0 ]
2123 echo 47.err
2124 else
2125 echo 47.ok
2126 endif
2127 if [ [ [ [ [ [ [ 1 ] ] && 1 ] && 0 ] && [ 1 ] ] ] && 1 ]
2128 echo 48.err
2129 else
2130 echo 48.ok
2131 endif
2132 if [ [ [ [ [ [ 0 ] && 1 ] && 1 ] && 1 ] ] && 1 ]
2133 echo 49.err
2134 else
2135 echo 49.ok
2136 endif
2137 if 1 || 0 || 0 || 0 && 0
2138 echo 50.err
2139 else
2140 echo 50.ok
2141 endif
2142 if 1 || 0 || 0 || 0 && 1
2143 echo 51.ok
2144 else
2145 echo 51.err
2146 endif
2147 if 0 || 0 || 0 || 1 && 0
2148 echo 52.err
2149 else
2150 echo 52.ok
2151 endif
2152 if 0 || 0 || 0 || 1 && 1
2153 echo 53.ok
2154 else
2155 echo 53.err
2156 endif
2157 if 0 || 0 || 0 || 1 && 0 || 1 && 0
2158 echo 54.err
2159 else
2160 echo 54.ok
2161 endif
2162 if 0 || 0 || 0 || 1 && 0 || 1 && 1
2163 echo 55.ok
2164 else
2165 echo 55.err
2166 endif
2167 set diet=yo curd=ho
2168 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
2169 echo 56.err
2170 else
2171 echo 56.ok
2172 endif
2173 if $diet == 'yo' && $curd == 'ho' && $ndefined
2174 echo 57.err
2175 else
2176 echo 57.ok
2177 endif
2178 set ndefined
2179 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
2180 echo 57.ok
2181 else
2182 echo 57.err
2183 endif
2184 if $diet == 'yo' && $curd == 'ho' && $ndefined
2185 echo 58.ok
2186 else
2187 echo 58.err
2188 endif
2189 if [ [ [ [ [ [ $diet == 'yo' && $curd == 'ho' && $ndefined ] ] ] ] ] ]
2190 echo 59.ok
2191 else
2192 echo 59.err
2193 endif
2194 # Some more en-braced variables
2195 set diet=yo curd=ho
2196 if ${diet} == ${curd}
2197 echo 70.err
2198 else
2199 echo 70.ok
2200 endif
2201 if ${diet} != ${curd}
2202 echo 71.ok
2203 else
2204 echo 71.err
2205 endif
2206 if $diet == ${curd}
2207 echo 72.err
2208 else
2209 echo 72.ok
2210 endif
2211 if ${diet} == $curd
2212 echo 73.err
2213 else
2214 echo 73.ok
2215 endif
2216 # Unary !
2217 if ! 0 && ! ! 1 && ! ! ! ! 2 && 3
2218 echo 80.ok
2219 else
2220 echo 80.err
2221 endif
2222 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ ! 2 ] ] ] && 3
2223 echo 81.ok
2224 else
2225 echo 81.err
2226 endif
2227 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
2228 echo 82.ok
2229 else
2230 echo 82.err
2231 endif
2232 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
2233 echo 83.err
2234 else
2235 echo 83.ok
2236 endif
2237 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
2238 echo 84.err
2239 else
2240 echo 84.ok
2241 endif
2242 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
2243 echo 85.err
2244 else
2245 echo 85.ok
2246 endif
2247 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
2248 echo 86.err
2249 else
2250 echo 86.ok
2251 endif
2252 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] || 3
2253 echo 87.ok
2254 else
2255 echo 87.err
2256 endif
2257 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! ! [ 2 ] ] ] ] ]
2258 echo 88.ok
2259 else
2260 echo 88.err
2261 endif
2262 # Unary !, odd
2263 if ! 0 && ! ! 1 && ! ! ! 0 && 3
2264 echo 90.ok
2265 else
2266 echo 90.err
2267 endif
2268 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ 0 ] ] ] && 3
2269 echo 91.ok
2270 else
2271 echo 91.err
2272 endif
2273 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ [ 0 ] ] ] ] ] && 3
2274 echo 92.ok
2275 else
2276 echo 92.err
2277 endif
2278 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! ! [ ! [ ! 0 ] ] ] ] && ! 3
2279 echo 93.err
2280 else
2281 echo 93.ok
2282 endif
2283 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ ! [ ! [ ! [ ! 0 ] ] ] ] && 3
2284 echo 94.ok
2285 else
2286 echo 94.err
2287 endif
2288 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! ! [ ! [ ! [ ! [ 0 ] ] ] ] ] && 3
2289 echo 95.err
2290 else
2291 echo 95.ok
2292 endif
2293 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! ! 0 ] ] ] ] && 3
2294 echo 96.err
2295 else
2296 echo 96.ok
2297 endif
2298 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ ! 0 ] ] ] ] ] || 3
2299 echo 97.ok
2300 else
2301 echo 97.err
2302 endif
2303 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! [ 0 ] ] ] ] ]
2304 echo 98.ok
2305 else
2306 echo 98.err
2307 endif
2308 __EOT
2310 check normal-old 0 "${MBOX}" '1688759742 719' # pre v15compat
2312 if have_feat regex; then
2313 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
2314 set dietcurd=yoho
2315 if $dietcurd =~ '^yo.*'
2316 echo 1.ok
2317 else
2318 echo 1.err
2319 endif
2320 if $dietcurd =~ '^Yo.*'
2321 echo 1-1.err
2322 else
2323 echo 1-1.ok
2324 endif
2325 if $dietcurd =~?case '^Yo.*'
2326 echo 1-2.ok
2327 else
2328 echo 1-2.err
2329 endif
2330 if $dietcurd =~ '^yOho.+'
2331 echo 2.err
2332 else
2333 echo 2.ok
2334 endif
2335 if $dietcurd !~? '.*Ho$'
2336 echo 3.err
2337 else
2338 echo 3.ok
2339 endif
2340 if $dietcurd !~ '.+yohO$'
2341 echo 4.ok
2342 else
2343 echo 4.err
2344 endif
2345 if [ $dietcurd !~?cas '.+yoho$' ]
2346 echo 5.ok
2347 else
2348 echo 5.err
2349 endif
2350 if ! [ $dietcurd =~?case '.+yoho$' ]
2351 echo 6.ok
2352 else
2353 echo 6.err
2354 endif
2355 if ! ! [ $dietcurd !~? '.+yoho$' ]
2356 echo 7.ok
2357 else
2358 echo 7.err
2359 endif
2360 if ! [ ! [ $dietcurd !~? '.+yoho$' ] ]
2361 echo 8.ok
2362 else
2363 echo 8.err
2364 endif
2365 if [ ! [ ! [ $dietcurd !~? '.+yoho$' ] ] ]
2366 echo 9.ok
2367 else
2368 echo 9.err
2369 endif
2370 if ! [ ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
2371 echo 10.err
2372 else
2373 echo 10.ok
2374 endif
2375 if ! ! ! $dietcurd !~ '.+yoho$'
2376 echo 11.err
2377 else
2378 echo 11.ok
2379 endif
2380 if ! ! ! $dietcurd =~ '.+yoho$'
2381 echo 12.ok
2382 else
2383 echo 12.err
2384 endif
2385 if ! [ ! ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
2386 echo 13.ok
2387 else
2388 echo 13.err
2389 endif
2390 set diet=abc curd='^abc$'
2391 if $diet =~ $curd
2392 echo 14.ok
2393 else
2394 echo 14.err
2395 endif
2396 set diet=abc curd='^abcd$'
2397 if $diet !~ $curd
2398 echo 15.ok
2399 else
2400 echo 15.err
2401 endif
2402 __EOT
2404 check regex-old 0 "${MBOX}" '1115671789 95' # pre v15compat
2405 else
2406 t_echoskip 'regex-old:[no regex option]'
2409 ## post v15compat
2411 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Sv15-compat=X > "${MBOX}"
2412 \if -N xyz; echo 1.err-1; \
2413 \elif ! -Z xyz;echo 1.err-2;\
2414 \elif -n "$xyz" ; echo 1.err-3 ; \
2415 \elif ! -z "$xyz" ; echo 1.err-4 ; \
2416 \else;echo 1.ok;\
2417 \end
2418 \set xyz
2419 \if ! -N xyz; echo 2.err-1; \
2420 \elif -Z xyz;echo 2.err-2;\
2421 \elif -n "$xyz" ; echo 2.err-3 ; \
2422 \elif ! -z "$xyz" ; echo 2.err-4 ; \
2423 \else;echo 2.ok;\
2424 \end
2425 \set xyz=notempty
2426 \if ! -N xyz; echo 3.err-1; \
2427 \elif -Z xyz;echo 3.err-2;\
2428 \elif ! -n "$xyz";echo 3.err-3;\
2429 \elif -z "$xyz";echo 3.err-4;\
2430 \else;echo 3.ok;\
2431 \end
2432 \if $xyz != notempty;echo 4.err-1;else;echo 4.ok;\end
2433 \if $xyz == notempty;echo 5.ok;else;echo 5.err-1;\end
2434 __EOT
2436 check NnZz_whiteout 0 "${MBOX}" '4280687462 25'
2438 # TODO t_ifelse: individual tests as for NnZz_whiteout
2439 # Nestable conditions test
2440 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Sv15-compat=x > "${MBOX}"
2441 if 0
2442 echo 1.err
2443 else
2444 echo 1.ok
2445 endif
2446 if 1
2447 echo 2.ok
2448 else
2449 echo 2.err
2450 endif
2451 if [ "$dietcurd" != "" ]
2452 echo 3.err
2453 else
2454 echo 3.ok
2455 endif
2456 set dietcurd=yoho
2457 if $'\$dietcurd' != ""
2458 echo 4.ok
2459 else
2460 echo 4.err
2461 endif
2462 if "$dietcurd" == 'yoho'
2463 echo 5.ok
2464 else
2465 echo 5.err
2466 endif
2467 if $'\$dietcurd' ==? 'Yoho'
2468 echo 5-1.ok
2469 else
2470 echo 5-1.err
2471 endif
2472 if $dietcurd == 'Yoho'
2473 echo 5-2.err
2474 else
2475 echo 5-2.ok
2476 endif
2477 if $dietcurd != 'yoho'
2478 echo 6.err
2479 else
2480 echo 6.ok
2481 endif
2482 if $dietcurd !=?case 'Yoho'
2483 echo 6-1.err
2484 else
2485 echo 6-1.ok
2486 endif
2487 if $dietcurd != 'Yoho'
2488 echo 6-2.ok
2489 else
2490 echo 6-2.err
2491 endif
2492 # Nesting
2493 if faLse
2494 echo 7.err1
2495 if tRue
2496 echo 7.err2
2497 if yEs
2498 echo 7.err3
2499 else
2500 echo 7.err4
2501 endif
2502 echo 7.err5
2503 endif
2504 echo 7.err6
2505 else
2506 echo 7.ok7
2507 if YeS
2508 echo 7.ok8
2509 if No
2510 echo 7.err9
2511 else
2512 echo 7.ok9
2513 endif
2514 echo 7.ok10
2515 else
2516 echo 7.err11
2517 if yeS
2518 echo 7.err12
2519 else
2520 echo 7.err13
2521 endif
2522 endif
2523 echo 7.ok14
2524 endif
2525 if r
2526 echo 8.ok1
2527 if R
2528 echo 8.ok2
2529 else
2530 echo 8.err2
2531 endif
2532 echo 8.ok3
2533 else
2534 echo 8.err1
2535 endif
2536 if s
2537 echo 9.err1
2538 else
2539 echo 9.ok1
2540 if S
2541 echo 9.err2
2542 else
2543 echo 9.ok2
2544 endif
2545 echo 9.ok3
2546 endif
2547 # `elif'
2548 if $dietcurd == 'yohu'
2549 echo 10.err1
2550 elif $dietcurd == 'yoha'
2551 echo 10.err2
2552 elif $dietcurd == 'yohe'
2553 echo 10.err3
2554 elif $dietcurd == 'yoho'
2555 echo 10.ok1
2556 if $dietcurd == 'yohu'
2557 echo 10.err4
2558 elif $dietcurd == 'yoha'
2559 echo 10.err5
2560 elif $dietcurd == 'yohe'
2561 echo 10.err6
2562 elif $dietcurd == 'yoho'
2563 echo 10.ok2
2564 if $dietcurd == 'yohu'
2565 echo 10.err7
2566 elif $dietcurd == 'yoha'
2567 echo 10.err8
2568 elif $dietcurd == 'yohe'
2569 echo 10.err9
2570 elif $dietcurd == 'yoho'
2571 echo 10.ok3
2572 else
2573 echo 10.err10
2574 endif
2575 else
2576 echo 10.err11
2577 endif
2578 else
2579 echo 10.err12
2580 endif
2581 # integer
2582 set dietcurd=10
2583 if $dietcurd -lt 11
2584 echo 11.ok1
2585 if $dietcurd -gt 9
2586 echo 11.ok2
2587 else
2588 echo 11.err2
2589 endif
2590 if $dietcurd -eq 10
2591 echo 11.ok3
2592 else
2593 echo 11.err3
2594 endif
2595 if $dietcurd -ge 10
2596 echo 11.ok4
2597 else
2598 echo 11.err4
2599 endif
2600 if $dietcurd -le 10
2601 echo 11.ok5
2602 else
2603 echo 11.err5
2604 endif
2605 if $dietcurd -ge 11
2606 echo 11.err6
2607 else
2608 echo 11.ok6
2609 endif
2610 if $dietcurd -ge?satu -0xFFFFFFFFFFFFFFFF1
2611 echo 11.err7
2612 else
2613 echo 11.ok7
2614 endif
2615 else
2616 echo 11.err1
2617 endif
2618 set dietcurd=Abc
2619 if $dietcurd < aBd
2620 echo 12.ok1
2621 if $dietcurd >? abB
2622 echo 12.ok2
2623 else
2624 echo 12.err2
2625 endif
2626 if $dietcurd ==?case aBC
2627 echo 12.ok3
2628 else
2629 echo 12.err3
2630 endif
2631 if $dietcurd >=?ca AbC
2632 echo 12.ok4
2633 else
2634 echo 12.err4
2635 endif
2636 if $dietcurd <=? ABc
2637 echo 12.ok5
2638 else
2639 echo 12.err5
2640 endif
2641 if $dietcurd >=?case abd
2642 echo 12.err6
2643 else
2644 echo 12.ok6
2645 endif
2646 if $dietcurd <=? abb
2647 echo 12.err7
2648 else
2649 echo 12.ok7
2650 endif
2651 else
2652 echo 12.err1
2653 endif
2654 if $dietcurd < aBc
2655 echo 12-1.ok
2656 else
2657 echo 12-1.err
2658 endif
2659 if $dietcurd <? aBc
2660 echo 12-2.err
2661 else
2662 echo 12-2.ok
2663 endif
2664 if $dietcurd > ABc
2665 echo 12-3.ok
2666 else
2667 echo 12-3.err
2668 endif
2669 if $dietcurd >? ABc
2670 echo 12-3.err
2671 else
2672 echo 12-3.ok
2673 endif
2674 if $dietcurd =%?case aB
2675 echo 13.ok
2676 else
2677 echo 13.err
2678 endif
2679 if $dietcurd =% aB
2680 echo 13-1.err
2681 else
2682 echo 13-1.ok
2683 endif
2684 if $dietcurd =%? bC
2685 echo 14.ok
2686 else
2687 echo 14.err
2688 endif
2689 if $dietcurd !% aB
2690 echo 15-1.ok
2691 else
2692 echo 15-1.err
2693 endif
2694 if $dietcurd !%? aB
2695 echo 15-2.err
2696 else
2697 echo 15-2.ok
2698 endif
2699 if $dietcurd !% bC
2700 echo 15-3.ok
2701 else
2702 echo 15-3.err
2703 endif
2704 if $dietcurd !%? bC
2705 echo 15-4.err
2706 else
2707 echo 15-4.ok
2708 endif
2709 if $dietcurd =% Cd
2710 echo 16.err
2711 else
2712 echo 16.ok
2713 endif
2714 if $dietcurd !% Cd
2715 echo 17.ok
2716 else
2717 echo 17.err
2718 endif
2719 set diet='ab c' curd='ab c'
2720 if "$diet" == "$curd"
2721 echo 18.ok
2722 else
2723 echo 18.err
2724 endif
2725 set diet='ab c' curd='ab cd'
2726 if "$diet" != "$curd"
2727 echo 19.ok
2728 else
2729 echo 19.err
2730 endif
2731 # 1. Shitty grouping capabilities as of today
2732 unset diet curd ndefined
2733 if [ [ false ] || [ false ] || [ true ] ] && \
2734 [ [ false ] || [ true ] ] && \
2735 [ yes ]
2736 echo 20.ok
2737 else
2738 echo 20.err
2739 endif
2740 if [ [ [ [ 0 ] || [ 1 ] ] && [ [ 1 ] || [ 0 ] ] ] && [ 1 ] ] && [ yes ]
2741 echo 21.ok
2742 else
2743 echo 21.err
2744 endif
2745 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] ]
2746 echo 22.ok
2747 else
2748 echo 22.err
2749 endif
2750 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] ]
2751 echo 23.ok
2752 else
2753 echo 23.err
2754 endif
2755 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] && [ no ]
2756 echo 24.err
2757 else
2758 echo 24.ok
2759 endif
2760 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] \
2761 && [ no ] || [ yes ]
2762 echo 25.ok
2763 else
2764 echo 25.err
2765 endif
2766 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
2767 echo 26.ok
2768 else
2769 echo 26.err
2770 endif
2771 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 0 ] ]
2772 echo 27.err
2773 else
2774 echo 27.ok
2775 endif
2776 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 0 ] ] && [ 1 ] ] ] && [ 1 ] ]
2777 echo 28.err
2778 else
2779 echo 28.ok
2780 endif
2781 if [ [ [ [ [ [ [ 0 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
2782 echo 29.err
2783 else
2784 echo 29.ok
2785 endif
2786 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 0 ]
2787 echo 30.err
2788 else
2789 echo 30.ok
2790 endif
2791 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 1 ]
2792 echo 31.ok
2793 else
2794 echo 31.err
2795 endif
2796 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ]
2797 echo 32.err
2798 else
2799 echo 32.ok
2800 endif
2801 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 1 ]
2802 echo 33.ok
2803 else
2804 echo 33.err
2805 endif
2806 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 0 ]
2807 echo 34.err
2808 else
2809 echo 34.ok
2810 endif
2811 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 1 ]
2812 echo 35.ok
2813 else
2814 echo 35.err
2815 endif
2816 set diet=yo curd=ho
2817 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && \
2818 [ -N ndefined || -n "$ndefined" || \
2819 ! -Z ndefined || ! -z "$ndefined" ]
2820 echo 36.err
2821 else
2822 echo 36.ok
2823 endif
2824 set ndefined
2825 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && \
2826 -N ndefined && ! -n "$ndefined" && \
2827 ! -Z ndefined && -z "$ndefined"
2828 echo 37.ok
2829 else
2830 echo 37.err
2831 endif
2832 # 2. Shitty grouping capabilities as of today
2833 unset diet curd ndefined
2834 if [ false || false || true ] && [ false || true ] && yes
2835 echo 40.ok
2836 else
2837 echo 40.err
2838 endif
2839 if [ [ [ 0 || 1 ] && [ 1 || 0 ] ] && 1 ] && [ yes ]
2840 echo 41.ok
2841 else
2842 echo 41.err
2843 endif
2844 if [ 1 || 0 || 0 || 0 ]
2845 echo 42.ok
2846 else
2847 echo 42.err
2848 endif
2849 if [ 1 || 0 || 0 || 0 || [ 1 ] ]
2850 echo 43.ok
2851 else
2852 echo 43.err
2853 endif
2854 if [ 1 || 0 || 0 || 0 || [ 1 ] || 1 ] && no
2855 echo 44.err
2856 else
2857 echo 44.ok
2858 endif
2859 if [ 1 || 0 || 0 || 0 || 1 || [ 1 ] ] && no || [ yes ]
2860 echo 45.ok
2861 else
2862 echo 45.err
2863 endif
2864 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && 1 ] ] && [ 1 ] ]
2865 echo 46.ok
2866 else
2867 echo 46.err
2868 endif
2869 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && [ 1 ] ] ] && 0 ]
2870 echo 47.err
2871 else
2872 echo 47.ok
2873 endif
2874 if [ [ [ [ [ [ [ 1 ] ] && 1 ] && 0 ] && [ 1 ] ] ] && 1 ]
2875 echo 48.err
2876 else
2877 echo 48.ok
2878 endif
2879 if [ [ [ [ [ [ 0 ] && 1 ] && 1 ] && 1 ] ] && 1 ]
2880 echo 49.err
2881 else
2882 echo 49.ok
2883 endif
2884 if 1 || 0 || 0 || 0 && 0
2885 echo 50.err
2886 else
2887 echo 50.ok
2888 endif
2889 if 1 || 0 || 0 || 0 && 1
2890 echo 51.ok
2891 else
2892 echo 51.err
2893 endif
2894 if 0 || 0 || 0 || 1 && 0
2895 echo 52.err
2896 else
2897 echo 52.ok
2898 endif
2899 if 0 || 0 || 0 || 1 && 1
2900 echo 53.ok
2901 else
2902 echo 53.err
2903 endif
2904 if 0 || 0 || 0 || 1 && 0 || 1 && 0
2905 echo 54.err
2906 else
2907 echo 54.ok
2908 endif
2909 if 0 || 0 || 0 || 1 && 0 || 1 && 1
2910 echo 55.ok
2911 else
2912 echo 55.err
2913 endif
2914 set diet=yo curd=ho
2915 if [ $diet == 'yo' && $curd == 'ho' ] && \
2916 [ -N ndefined || -n "$ndefined" || \
2917 ! -Z ndefined || ! -z "$ndefined" ]
2918 echo 56.err
2919 else
2920 echo 56.ok
2921 endif
2922 if [ $diet == 'yo' && $curd == 'ho' && \
2923 [ [ -N ndefined || -n "$ndefined" || \
2924 ! -Z ndefined || ! -z "$ndefined" ] ] ]
2925 echo 57.err
2926 else
2927 echo 57.ok
2928 endif
2929 set ndefined
2930 if [ $diet == 'yo' && $curd == 'ho' ] && \
2931 -N ndefined && ! -n "$ndefined" && \
2932 ! -Z ndefined && -z "$ndefined"
2933 echo 57.ok
2934 else
2935 echo 57.err
2936 endif
2937 if $diet == 'yo' && $curd == 'ho' && ! -Z ndefined
2938 echo 58.ok
2939 else
2940 echo 58.err
2941 endif
2942 if [ [ [ [ [ [ $diet == 'yo' && $curd == 'ho' && -N ndefined ] ] ] ] ] ]
2943 echo 59.ok
2944 else
2945 echo 59.err
2946 endif
2947 # Some more en-braced variables
2948 set diet=yo curd=ho
2949 if ${diet} == ${curd}
2950 echo 70.err
2951 else
2952 echo 70.ok
2953 endif
2954 if "${diet}" != "${curd}"
2955 echo 71.ok
2956 else
2957 echo 71.err
2958 endif
2959 if $diet == ${curd}
2960 echo 72.err
2961 else
2962 echo 72.ok
2963 endif
2964 if ${diet} == $curd
2965 echo 73.err
2966 else
2967 echo 73.ok
2968 endif
2969 # Unary !
2970 if ! 0 && ! ! 1 && ! ! ! ! 2 && 3
2971 echo 80.ok
2972 else
2973 echo 80.err
2974 endif
2975 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ ! 2 ] ] ] && 3
2976 echo 81.ok
2977 else
2978 echo 81.err
2979 endif
2980 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
2981 echo 82.ok
2982 else
2983 echo 82.err
2984 endif
2985 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
2986 echo 83.err
2987 else
2988 echo 83.ok
2989 endif
2990 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
2991 echo 84.err
2992 else
2993 echo 84.ok
2994 endif
2995 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
2996 echo 85.err
2997 else
2998 echo 85.ok
2999 endif
3000 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
3001 echo 86.err
3002 else
3003 echo 86.ok
3004 endif
3005 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] || 3
3006 echo 87.ok
3007 else
3008 echo 87.err
3009 endif
3010 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! ! [ 2 ] ] ] ] ]
3011 echo 88.ok
3012 else
3013 echo 88.err
3014 endif
3015 # Unary !, odd
3016 if ! 0 && ! ! 1 && ! ! ! 0 && 3
3017 echo 90.ok
3018 else
3019 echo 90.err
3020 endif
3021 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ 0 ] ] ] && 3
3022 echo 91.ok
3023 else
3024 echo 91.err
3025 endif
3026 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ [ 0 ] ] ] ] ] && 3
3027 echo 92.ok
3028 else
3029 echo 92.err
3030 endif
3031 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! ! [ ! [ ! 0 ] ] ] ] && ! 3
3032 echo 93.err
3033 else
3034 echo 93.ok
3035 endif
3036 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ ! [ ! [ ! [ ! 0 ] ] ] ] && 3
3037 echo 94.ok
3038 else
3039 echo 94.err
3040 endif
3041 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! ! [ ! [ ! [ ! [ 0 ] ] ] ] ] && 3
3042 echo 95.err
3043 else
3044 echo 95.ok
3045 endif
3046 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! ! 0 ] ] ] ] && 3
3047 echo 96.err
3048 else
3049 echo 96.ok
3050 endif
3051 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ ! 0 ] ] ] ] ] || 3
3052 echo 97.ok
3053 else
3054 echo 97.err
3055 endif
3056 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! [ 0 ] ] ] ] ]
3057 echo 98.ok
3058 else
3059 echo 98.err
3060 endif
3061 __EOT
3063 check normal 0 "${MBOX}" '1688759742 719'
3065 if have_feat regex; then
3066 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Sv15-compat=X > "${MBOX}"
3067 set dietcurd=yoho
3068 if $dietcurd =~ '^yo.*'
3069 echo 1.ok
3070 else
3071 echo 1.err
3072 endif
3073 if "$dietcurd" =~ '^Yo.*'
3074 echo 1-1.err
3075 else
3076 echo 1-1.ok
3077 endif
3078 if $dietcurd =~?case '^Yo.*'
3079 echo 1-2.ok
3080 else
3081 echo 1-2.err
3082 endif
3083 if $dietcurd =~ '^yOho.+'
3084 echo 2.err
3085 else
3086 echo 2.ok
3087 endif
3088 if $dietcurd !~? '.*Ho$'
3089 echo 3.err
3090 else
3091 echo 3.ok
3092 endif
3093 if $dietcurd !~ '.+yohO$'
3094 echo 4.ok
3095 else
3096 echo 4.err
3097 endif
3098 if [ $dietcurd !~?cas '.+yoho$' ]
3099 echo 5.ok
3100 else
3101 echo 5.err
3102 endif
3103 if ! [ "$dietcurd" =~?case '.+yoho$' ]
3104 echo 6.ok
3105 else
3106 echo 6.err
3107 endif
3108 if ! ! [ $'\$dietcurd' !~? '.+yoho$' ]
3109 echo 7.ok
3110 else
3111 echo 7.err
3112 endif
3113 if ! [ ! [ $dietcurd !~? '.+yoho$' ] ]
3114 echo 8.ok
3115 else
3116 echo 8.err
3117 endif
3118 if [ ! [ ! [ $dietcurd !~? '.+yoho$' ] ] ]
3119 echo 9.ok
3120 else
3121 echo 9.err
3122 endif
3123 if ! [ ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
3124 echo 10.err
3125 else
3126 echo 10.ok
3127 endif
3128 if ! ! ! $dietcurd !~ '.+yoho$'
3129 echo 11.err
3130 else
3131 echo 11.ok
3132 endif
3133 if ! ! ! $dietcurd =~ '.+yoho$'
3134 echo 12.ok
3135 else
3136 echo 12.err
3137 endif
3138 if ! [ ! ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
3139 echo 13.ok
3140 else
3141 echo 13.err
3142 endif
3143 set diet=abc curd='^abc$'
3144 if $diet =~ $curd
3145 echo 14.ok
3146 else
3147 echo 14.err
3148 endif
3149 set diet=abc curd='^abcd$'
3150 if "$diet" !~ $'\$curd'
3151 echo 15.ok
3152 else
3153 echo 15.err
3154 endif
3155 __EOT
3157 check regex 0 "${MBOX}" '1115671789 95'
3158 else
3159 t_echoskip 'regex:[!REGEX]'
3162 t_epilog "${@}"
3165 t_localopts() {
3166 t_prolog "${@}"
3168 # Nestable conditions test
3169 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
3170 define t2 {
3171 echo in: t2
3172 set t2=t2
3173 echo $t2
3175 define t1 {
3176 echo in: t1
3177 set gv1=gv1
3178 localopts on
3179 set lv1=lv1 lv2=lv2
3180 set lv3=lv3
3181 call t2
3182 localopts off
3183 set gv2=gv2
3184 echo $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2
3186 define t0 {
3187 echo in: t0
3188 call t1
3189 echo $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2
3190 echo "$gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2"
3192 account trouble {
3193 echo in: trouble
3194 call t0
3196 call t0
3197 unset gv1 gv2
3198 account trouble
3199 echo active trouble: $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t3
3200 account null
3201 echo active null: $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t3
3204 define ll2 {
3205 localopts $1
3206 set x=2
3207 echo ll2=$x
3209 define ll1 {
3210 wysh set y=$1; shift; eval localopts $y; localopts $1; shift
3211 set x=1
3212 echo ll1.1=$x
3213 call ll2 $1
3214 echo ll1.2=$x
3216 define ll0 {
3217 wysh set y=$1; shift; eval localopts $y; localopts $1; shift
3218 set x=0
3219 echo ll0.1=$x
3220 call ll1 $y "$@"
3221 echo ll0.2=$x
3223 define llx {
3224 echo ----- $1: $2 -> $3 -> $4
3225 echo ll-1.1=$x
3226 eval localopts $1
3227 call ll0 "$@"
3228 echo ll-1.2=$x
3229 unset x
3231 define lly {
3232 call llx 'call off' on on on
3233 call llx 'call off' off on on
3234 call llx 'call off' on off on
3235 call llx 'call off' on off off
3236 localopts call-fixate on
3237 call llx 'call-fixate on' on on on
3238 call llx 'call-fixate on' off on on
3239 call llx 'call-fixate on' on off on
3240 call llx 'call-fixate on' on off off
3241 unset x;localopts call on
3242 call llx 'call on' on on on
3243 call llx 'call on' off on on
3244 call llx 'call on' on off on
3245 call llx 'call on' on off off
3247 call lly
3248 __EOT
3250 check 1 0 "${MBOX}" '4016155249 1246'
3252 t_epilog "${@}"
3255 t_local() {
3256 t_prolog "${@}"
3258 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
3259 define du2 {
3260 echo du2-1 du=$du
3261 local set du=$1
3262 echo du2-2 du=$du
3263 local unset du
3264 echo du2-3 du=$du
3266 define du {
3267 local set du=dudu
3268 echo du-1 du=$du
3269 call du2 du2du2
3270 echo du-2 du=$du
3271 local set nodu
3272 echo du-3 du=$du
3274 define ich {
3275 echo ich-1 du=$du
3276 call du
3277 echo ich-2 du=$du
3279 define wir {
3280 localopts $1
3281 set du=wirwir
3282 echo wir-1 du=$du
3283 call ich
3284 echo wir-2 du=$du
3286 echo ------- global-1 du=$du
3287 call ich
3288 echo ------- global-2 du=$du
3289 set du=global
3290 call ich
3291 echo ------- global-3 du=$du
3292 call wir on
3293 echo ------- global-4 du=$du
3294 call wir off
3295 echo ------- global-5 du=$du
3296 __EOT
3297 check 1 0 "${MBOX}" '2411598140 641'
3300 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
3301 define z {
3302 echo z-1: x=$x y=$y z=$z crt=$crt
3303 local set z=1 y=2 crt=10
3304 echo z-2: x=$x y=$y z=$z crt=$crt
3306 define y {
3307 echo y-1: x=$x y=$y z=$z crt=$crt
3308 local set x=2 y=1 crt=5
3309 echo y-2: x=$x y=$y z=$z crt=$crt
3310 call z
3311 echo y-3: x=$x y=$y z=$z crt=$crt
3313 define x {
3314 echo x-1: x=$x y=$y z=$z crt=$crt
3315 local set x=1 crt=1
3316 echo x-2: x=$x y=$y z=$z crt=$crt
3317 call y
3318 echo x-3: x=$x y=$y z=$z crt=$crt
3320 set crt
3321 echo global-1: x=$x y=$y z=$z crt=$crt
3322 call x
3323 echo global-2: x=$x y=$y z=$z crt=$crt
3324 __EOT
3325 check 2 0 "${MBOX}" '2560788669 216'
3327 t_epilog "${@}"
3330 t_environ() {
3331 t_prolog "${@}"
3333 ${cat} <<- '__EOT' | EK1=EV1 EK2=EV2 ${MAILX} ${ARGS} > "${MBOX}" 2>&1
3334 echo "we: EK1<$EK1> EK2<$EK2> EK3<$EK3> EK4<$EK4> NEK5<$NEK5>"
3335 !echo "shell: EK1<$EK1> EK2<$EK2> EK3<$EK3> EK4<$EK4> NEK5<$NEK5>"
3336 varshow EK1 EK2 EK3 EK4 NEK5
3338 echo environ set EK3 EK4, set NEK5
3339 environ set EK3=EV3 EK4=EV4
3340 set NEK5=NEV5
3341 echo "we: EK1<$EK1> EK2<$EK2> EK3<$EK3> EK4<$EK4> NEK5<$NEK5>"
3342 !echo "shell: EK1<$EK1> EK2<$EK2> EK3<$EK3> EK4<$EK4> NEK5<$NEK5>"
3343 varshow EK1 EK2 EK3 EK4 NEK5
3345 echo removing NEK5 EK3
3346 unset NEK5
3347 environ unset EK3
3348 echo "we: EK1<$EK1> EK2<$EK2> EK3<$EK3> EK4<$EK4> NEK5<$NEK5>"
3349 !echo "shell: EK1<$EK1> EK2<$EK2> EK3<$EK3> EK4<$EK4> NEK5<$NEK5>"
3350 varshow EK1 EK2 EK3 EK4 NEK5
3352 echo changing EK1, EK4
3353 set EK1=EV1_CHANGED EK4=EV4_CHANGED
3354 echo "we: EK1<$EK1> EK2<$EK2> EK3<$EK3> EK4<$EK4> NEK5<$NEK5>"
3355 !echo "shell: EK1<$EK1> EK2<$EK2> EK3<$EK3> EK4<$EK4> NEK5<$NEK5>"
3356 varshow EK1 EK2 EK3 EK4 NEK5
3358 echo linking EK4, rechanging EK1, EK4
3359 environ link EK4
3360 set EK1=EV1 EK4=EV4
3361 echo "we: EK1<$EK1> EK2<$EK2> EK3<$EK3> EK4<$EK4> NEK5<$NEK5>"
3362 !echo "shell: EK1<$EK1> EK2<$EK2> EK3<$EK3> EK4<$EK4> NEK5<$NEK5>"
3363 varshow EK1 EK2 EK3 EK4 NEK5
3365 echo unset all
3366 unset EK1 EK2 EK4
3367 echo "we: EK1<$EK1> EK2<$EK2> EK3<$EK3> EK4<$EK4> NEK5<$NEK5>"
3368 !echo "shell: EK1<$EK1> EK2<$EK2> EK3<$EK3> EK4<$EK4> NEK5<$NEK5>"
3369 varshow EK1 EK2 EK3 EK4 NEK5
3370 __EOT
3372 check 1 0 "${MBOX}" '1685686686 1342'
3374 t_epilog "${@}"
3375 return
3378 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
3379 define l4 {
3380 echo '-------> L4 (environ unlink EK1, own localopts)'
3381 localopts yes
3382 environ unlink EK1
3383 set LK1=LK1_L4 EK1=EK1_L4
3384 echo "we: L4: LK1<$LK1> EK1<$EK1>"
3385 !echo "shell: L4: LK1<$LK1> EK1<$EK1>"
3386 varshow LK1 EK1
3387 echo '-------< L4'
3389 define l3 {
3390 echo '-------> L3'
3391 set LK1=LK1_L3 EK1=EK1_L3
3392 echo "we: L3-pre: LK1<$LK1> EK1<$EK1>"
3393 !echo "shell: L3-pre: LK1<$LK1> EK1<$EK1>"
3394 varshow LK1 EK1
3395 call l4
3396 echo "we: L3-post: LK1<$LK1> EK1<$EK1>"
3397 !echo "shell: L3-post: LK1<$LK1> EK1<$EK1>"
3398 varshow LK1 EK1
3399 echo '-------< L3'
3401 define l2 {
3402 echo '-------> L2'
3403 set LK1=LK1_L2 EK1=EK1_L2
3404 echo "we: L2-pre: LK1<$LK1> EK1<$EK1>"
3405 !echo "shell: L2-pre: LK1<$LK1> EK1<$EK1>"
3406 varshow LK1 EK1
3407 call l3
3408 echo "we: L2-post: LK1<$LK1> EK1<$EK1>"
3409 !echo "shell: L2-post: LK1<$LK1> EK1<$EK1>"
3410 varshow LK1 EK1
3411 echo '-------< L2'
3413 define l1 {
3414 echo '-------> L1 (environ link EK1; localopts call-fixate)'
3415 localopts call-fixate yes
3416 set LK1=LK1_L1 EK1=EK1_L1
3417 environ link EK1
3418 echo "we: L1-pre: LK1<$LK1> EK1<$EK1>"
3419 !echo "shell: L1-pre: LK1<$LK1> EK1<$EK1>"
3420 varshow LK1 EK1
3421 call l2
3422 echo "we: L1-post: LK1<$LK1> EK1<$EK1>"
3423 !echo "shell: L1-post: LK1<$LK1> EK1<$EK1>"
3424 varshow LK1 EK1
3425 echo '-------< L1'
3427 echo "we: outer-pre: LK1<$LK1> EK1<$EK1>"
3428 !echo "shell: outer-pre: LK1<$LK1> EK1<$EK1>"
3429 varshow LK1 EK1
3430 call l1
3431 echo "we: outer-post: LK1<$LK1> EK1<$EK1>"
3432 !echo "shell: outer-post: LK1<$LK1> EK1<$EK1>"
3433 varshow LK1 EK1
3434 __EOT
3436 check 2 0 "${MBOX}" '1903030743 1131'
3438 t_epilog "${@}"
3441 t_macro_param_shift() {
3442 t_prolog "${@}"
3444 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>>${ERR}
3445 define t2 {
3446 echo in: t2
3447 echo t2.0 has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
3448 localopts on
3449 wysh set ignerr=$1
3450 shift
3451 localopts off
3452 echo t2.1 has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
3453 if [ $# > 1 ] || [ $ignerr == '' ]
3454 shift 2
3455 else
3456 ignerr shift 2
3457 endif
3458 echo t2.2:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
3459 shift 0
3460 echo t2.3:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
3461 if [ $# > 0 ]
3462 shift
3463 endif
3464 echo t2.4:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
3466 define t1 {
3467 set errexit
3468 echo in: t1
3469 call t2 1 you get four args
3470 echo t1.1: $?';' ignerr ($ignerr) should not exist
3471 call t2 1 you get 'three args'
3472 echo t1.2: $?';' ignerr ($ignerr) should not exist
3473 call t2 1 you 'get two args'
3474 echo t1.3: $?';' ignerr ($ignerr) should not exist
3475 call t2 1 'you get one arg'
3476 echo t1.4: $?';' ignerr ($ignerr) should not exist
3477 ignerr call t2 '' 'you get one arg'
3478 echo t1.5: $?';' ignerr ($ignerr) should not exist
3480 call t1
3481 __EOT
3483 check 1 0 "${MBOX}" '1402489146 1682'
3485 t_epilog "${@}"
3488 t_addrcodec() {
3489 t_prolog "${@}"
3491 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
3492 commandalias x echo '$?/$^ERRNAME $res'
3493 vput addrcodec res e 1 <doog@def>
3495 eval vput addrcodec res d $res
3497 vput addrcodec res e 2 . <doog@def>
3499 eval vput addrcodec res d $res
3501 vput addrcodec res e 3 Sauer Dr. <doog@def>
3503 eval vput addrcodec res d $res
3505 vput addrcodec res e 3.50 Sauer (Ma) Dr. <doog@def>
3507 eval vput addrcodec res d $res
3509 vput addrcodec res e 3.51 Sauer (Ma) "Dr." <doog@def>
3511 eval vput addrcodec res d $res
3514 vput addrcodec res +e 4 Sauer (Ma) Dr. <doog@def>
3516 eval vput addrcodec res d $res
3518 vput addrcodec res +e 5 Sauer (Ma) Braten Dr. <doog@def>
3520 eval vput addrcodec res d $res
3522 vput addrcodec res +e 6 Sauer (Ma) Braten Dr. (Heu) <doog@def>
3524 eval vput addrcodec res d $res
3526 vput addrcodec res +e 7 Sauer (Ma) Braten Dr. (Heu) <doog@def> (bu)
3528 eval vput addrcodec res d $res
3530 vput addrcodec res +e 8 \
3531 Dr. Sauer (Ma) Braten Dr. (Heu) <doog@def> (bu) Boom. Boom
3533 eval vput addrcodec res d $res
3535 vput addrcodec res +e 9 Dr.Sauer(Ma)Braten Dr. (Heu) <doog@def>
3537 eval vput addrcodec res d $res
3539 vput addrcodec res +e 10 (Ma)Braten Dr. (Heu) <doog@def>
3541 eval vput addrcodec res d $res
3543 vput addrcodec res +e 11 (Ma)Braten Dr"." (Heu) <doog@def>
3545 eval vput addrcodec res d $res
3547 vput addrcodec res +e 12 Dr. Sauer (Ma) Braten Dr. (u) <doog@def>
3549 eval vput addrcodec res d $res
3551 vput addrcodec res +e 13(Ma)Braten Dr. (Heu) <doog@def>
3553 eval vput addrcodec res d $res
3555 vput addrcodec res +e 14 Hey, Du <doog@def> Wie() findet Dr. das? ()
3557 eval vput addrcodec res d $res
3559 vput addrcodec res +e 15 \
3560 Hey, Du <doog@def> Wie() findet "" Dr. "" das? ()
3562 eval vput addrcodec res d $res
3564 vput addrcodec res +e 16 \
3565 "Hey," "Du" <doog@def> "Wie()" findet "" Dr. "" das? ()
3567 eval vput addrcodec res d $res
3569 vput addrcodec res +e 17 \
3570 "Hey" Du <doog@def> "Wie() findet " " Dr. """ das? ()
3572 eval vput addrcodec res d $res
3574 vput addrcodec res +e 18 \
3575 <doog@def> "Hey" Du "Wie() findet " " Dr. """ das? ()
3577 eval vput addrcodec res d $res
3579 vput addrcodec res +e 19 Hey\,\" <doog@def> "Wie()" findet \" Dr. \" das?
3581 eval vput addrcodec res d $res
3584 vput addrcodec res ++e 20 Hey\,\" <doog@def> "Wie()" findet \" Dr. \" das?
3586 vput addrcodec res ++e 21 Hey\,\"" <doog@def> "Wie()" findet \" Dr. \" das?
3588 eval vput addrcodec res d $res
3591 vput addrcodec res \
3592 +++e 22 Hey\\,\" <doog@def> "Wie()" findet \" Dr. \" das?
3594 eval vput addrcodec res d $res
3597 vput addrcodec res s \
3598 "23 Hey\\,\\\" \"Wie" () "\" findet \\\" Dr. \\\" das?" <doog@def>
3601 # Fix for [f3852f88]
3602 vput addrcodec res ++e <from2@exam.ple> 100 (comment) "Quot(e)d"
3604 eval vput addrcodec res d $res
3606 vput addrcodec res e <from2@exam.ple> 100 (comment) "Quot(e)d"
3608 eval vput addrcodec res d $res
3610 __EOT
3612 check 1 0 "${MBOX}" '1047317989 2612'
3614 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
3615 commandalias x echo '$?/$^ERRNAME $res'
3616 mlist isa1@list
3617 mlsubscribe isa2@list
3619 vput addrcodec res skin Hey\\,\" <isa0@list> "Wie()" find \" Dr. \" das?
3621 vput addrcodec res skinlist Hey\\,\" <isa0@list> "Wie()" find \" Dr. \" das?
3623 vput addrcodec res skin Hey\\,\" <isa1@list> "Wie()" find \" Dr. \" das?
3625 vput addrcodec res skinlist Hey\\,\" <isa1@list> "Wie()" find \" Dr. \" das?
3627 vput addrcodec res skin Hey\\,\" <isa2@list> "Wie()" find \" Dr. \" das?
3629 vput addrcodec res skinlist Hey\\,\" <isa2@list> "Wie()" find \" Dr. \" das?
3631 __EOT
3633 check 2 0 "${MBOX}" '1391779299 104'
3635 if have_feat idna; then
3636 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} ${ADDARG_UNI} > "${MBOX}" 2>&1
3637 commandalias x echo '$?/$^ERRNAME $res'
3638 vput addrcodec res e (heu) <du@blödiän> "stroh" du
3640 eval vput addrcodec res d $res
3642 vput addrcodec res e <du@blödiän> du
3644 eval vput addrcodec res d $res
3646 vput addrcodec res e du <du@blödiän>
3648 eval vput addrcodec res d $res
3650 vput addrcodec res e <du@blödiän>
3652 eval vput addrcodec res d $res
3654 vput addrcodec res e du@blödiän
3656 eval vput addrcodec res d $res
3658 __EOT
3660 check idna 0 "${MBOX}" '498775983 326'
3661 else
3662 t_echoskip 'idna:[!IDNA]'
3665 t_epilog "${@}"
3668 t_csop() {
3669 t_prolog "${@}"
3671 if have_feat cmd-csop; then :; else
3672 t_echoskip '[!CMD_CSOP]'
3673 t_epilog "${@}"
3674 return
3677 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
3678 commandalias x echo '$?/$^ERRNAME :$res:'
3679 echo ' #-2'
3680 vput csop res find you y;x
3681 vput csop res find you o;x
3682 vput csop res find you u;x
3683 vput csop res find you yo;x
3684 vput csop res find you ou;x
3685 vput csop res find you you;x
3686 echo ' #-1'
3687 vput csop res find you Y;x
3688 vput csop res find? you Y;x
3689 vput csop res find?case you O;x
3690 vput csop res find? you U;x
3691 vput csop res find?ca you yO;x
3692 vput csop res find? you oU;x
3693 vput csop res find? you YoU;x
3694 echo ' #0'
3695 vput csop res find 'bananarama' 'nana';x
3696 vput csop res find 'bananarama' 'bana';x
3697 vput csop res find 'bananarama' 'Bana';x
3698 vput csop res find 'bananarama' 'rama';x
3699 echo ' #1'
3700 vput csop res find? 'bananarama' 'nana';x
3701 vput csop res find? 'bananarama' 'bana';x
3702 vput csop res find? 'bananarama' 'Bana';x
3703 vput csop res find? 'bananarama' 'rama';x
3704 echo ' #2'
3705 vput csop res substring 'bananarama' 1;x
3706 vput csop res substring 'bananarama' 3;x
3707 vput csop res substring 'bananarama' 5;x
3708 vput csop res substring 'bananarama' 7;x
3709 vput csop res substring 'bananarama' 9;x
3710 vput csop res substring 'bananarama' 10;x
3711 vput csop res substring 'bananarama' 1 3;x
3712 vput csop res substring 'bananarama' 3 3;x
3713 vput csop res substring 'bananarama' 5 3;x
3714 vput csop res substring 'bananarama' 7 3;x
3715 vput csop res substring 'bananarama' 9 3;x
3716 vput csop res substring 'bananarama' 10 3;x
3717 echo ' #3'
3718 vput csop res substring 'bananarama' -1;x
3719 vput csop res substring 'bananarama' -3;x
3720 vput csop res substring 'bananarama' -5;x
3721 vput csop res substring 'bananarama' -7;x
3722 vput csop res substring 'bananarama' -9;x
3723 vput csop res substring 'bananarama' -10;x
3724 vput csop res substring 'bananarama' 1 -3;x
3725 vput csop res substring 'bananarama' 3 -3;x
3726 vput csop res substring 'bananarama' 5 -3;x
3727 vput csop res substring 'bananarama' 7 -3;x
3728 vput csop res substring 'bananarama' 9 -3;x
3729 vput csop res substring 'bananarama' 10 -3;x
3730 echo ' #4'
3731 vput csop res trim 'Cocoon Cocoon';x
3732 vput csop res trim ' Cocoon Cocoon ';x
3733 vput csop res trim-front 'Cocoon Cocoon';x
3734 vput csop res trim-front ' Cocoon Cocoon ';x
3735 vput csop res trim-end 'Cocoon Cocoon';x
3736 vput csop res trim-end ' Cocoon Cocoon ';x
3737 __EOT
3739 check 1 0 "${MBOX}" '1892119538 755'
3741 t_epilog "${@}"
3744 t_vexpr() {
3745 t_prolog "${@}"
3747 if have_feat cmd-vexpr; then :; else
3748 t_echoskip '[!CMD_VEXPR]'
3749 t_epilog "${@}"
3750 return
3753 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>>${ERR}
3754 commandalias x echo '$?/$^ERRNAME $res'
3755 echo ' #0.0'
3756 vput vexpr res = 9223372036854775807;x
3757 vput vexpr res = 9223372036854775808;x
3758 vput vexpr res = u9223372036854775808;x
3759 vput vexpr res =? 9223372036854775808;x
3760 vput vexpr res = -9223372036854775808;x
3761 vput vexpr res = -9223372036854775809;x
3762 vput vexpr res =?saturated -9223372036854775809;x
3763 vput vexpr res = U9223372036854775809;x
3764 echo ' #0.1'
3765 vput vexpr res = \
3766 0b0111111111111111111111111111111111111111111111111111111111111111;x
3767 vput vexpr res = \
3768 S0b1000000000000000000000000000000000000000000000000000000000000000;x
3769 vput vexpr res =? \
3770 S0b1000000000000000000000000000000000000000000000000000000000000000;x
3771 vput vexpr res = \
3772 U0b1000000000000000000000000000000000000000000000000000000000000000;x
3773 vput vexpr res = \
3774 0b1000000000000000000000000000000000000000000000000000000000000000;x
3775 vput vexpr res =? \
3776 0b1000000000000000000000000000000000000000000000000000000000000000;x
3777 vput vexpr res = \
3778 -0b1000000000000000000000000000000000000000000000000000000000000000;x
3779 vput vexpr res = \
3780 S0b1000000000000000000000000000000000000000000000000000000000000001;x
3781 vput vexpr res =? \
3782 S0b1000000000000000000000000000000000000000000000000000000000000001;x
3783 vput vexpr res =? \
3784 -0b1000000000000000000000000000000000000000000000000000000000000001;x
3785 vput vexpr res = \
3786 U0b1000000000000000000000000000000000000000000000000000000000000001;x
3787 echo ' #0.2'
3788 vput vexpr res = 0777777777777777777777;x
3789 vput vexpr res = S01000000000000000000000;x
3790 vput vexpr res =? S01000000000000000000000;x
3791 vput vexpr res = U01000000000000000000000;x
3792 vput vexpr res = 01000000000000000000000;x
3793 vput vexpr res =?satur 01000000000000000000000;x
3794 vput vexpr res = -01000000000000000000000;x
3795 vput vexpr res = S01000000000000000000001;x
3796 vput vexpr res =?sat S01000000000000000000001;x
3797 vput vexpr res = -01000000000000000000001;x
3798 vput vexpr res = U01000000000000000000001;x
3799 echo ' #0.3'
3800 vput vexpr res = 0x7FFFFFFFFFFFFFFF;x
3801 vput vexpr res = S0x8000000000000000;x
3802 vput vexpr res =? S0x8000000000000000;x
3803 vput vexpr res = U0x8000000000000000;x
3804 vput vexpr res = 0x8000000000000000;x
3805 vput vexpr res =? 0x8000000000000000;x
3806 vput vexpr res = -0x8000000000000000;x
3807 vput vexpr res = S0x8000000000000001;x
3808 vput vexpr res =? S0x8000000000000001;x
3809 vput vexpr res = -0x8000000000000001;x
3810 vput vexpr res = u0x8000000000000001;x
3811 vput vexpr res = 9223372036854775809;x
3812 vput vexpr res =? 9223372036854775809;x
3813 vput vexpr res = u9223372036854775809;x
3814 echo ' #1'
3815 vput vexpr res ~ 0;x
3816 vput vexpr res ~ 1;x
3817 vput vexpr res ~ -1;x
3818 echo ' #1.1'
3819 vput vexpr res - 0;x
3820 vput vexpr res - 1;x
3821 vput vexpr res - -1;x
3822 vput vexpr res - -0xAFFE;x
3823 vput vexpr res - 0xAFFE;x
3824 vput vexpr res - u0x8000000000000001;x
3825 vput vexpr res - 0x8000000000000001;x
3826 vput vexpr res - 0x8000000000000001;x
3827 vput vexpr res - 9223372036854775809;x
3828 vput vexpr res -? 9223372036854775809;x
3829 echo ' #1.2'
3830 vput vexpr res + 0;x
3831 vput vexpr res + 1;x
3832 vput vexpr res + -1;x
3833 vput vexpr res + -0xAFFE;x
3834 vput vexpr res + 0xAFFE;x
3835 vput vexpr res + u0x8000000000000001;x
3836 vput vexpr res + 0x8000000000000001;x
3837 vput vexpr res + 9223372036854775809;x
3838 vput vexpr res +? 9223372036854775809;x
3839 echo ' #2'
3840 vput vexpr res + 0 0;x
3841 vput vexpr res + 0 1;x
3842 vput vexpr res + 1 1;x
3843 echo ' #3'
3844 vput vexpr res + 9223372036854775807 0;x
3845 vput vexpr res + 9223372036854775807 1;x
3846 vput vexpr res +? 9223372036854775807 1;x
3847 vput vexpr res + 0 9223372036854775807;x
3848 vput vexpr res + 1 9223372036854775807;x
3849 vput vexpr res +? 1 9223372036854775807;x
3850 echo ' #4'
3851 vput vexpr res + -9223372036854775808 0;x
3852 vput vexpr res + -9223372036854775808 -1;x
3853 vput vexpr res +? -9223372036854775808 -1;x
3854 vput vexpr res + 0 -9223372036854775808;x
3855 vput vexpr res + -1 -9223372036854775808;x
3856 vput vexpr res +? -1 -9223372036854775808;x
3857 echo ' #5'
3858 vput vexpr res - 0 0;x
3859 vput vexpr res - 0 1;x
3860 vput vexpr res - 1 1;x
3861 echo ' #6'
3862 vput vexpr res - 9223372036854775807 0;x
3863 vput vexpr res - 9223372036854775807 -1;x
3864 vput vexpr res -? 9223372036854775807 -1;x
3865 vput vexpr res - 0 9223372036854775807;x
3866 vput vexpr res - -1 9223372036854775807;x
3867 vput vexpr res - -2 9223372036854775807;x
3868 vput vexpr res -? -2 9223372036854775807;x
3869 echo ' #7'
3870 vput vexpr res - -9223372036854775808 +0;x
3871 vput vexpr res - -9223372036854775808 +1;x
3872 vput vexpr res -? -9223372036854775808 +1;x
3873 vput vexpr res - 0 -9223372036854775808;x
3874 vput vexpr res - +1 -9223372036854775808;x
3875 vput vexpr res -? +1 -9223372036854775808;x
3876 echo ' #8'
3877 vput vexpr res + -13 -2;x
3878 vput vexpr res - 0 0;x
3879 vput vexpr res - 0 1;x
3880 vput vexpr res - 1 1;x
3881 vput vexpr res - -13 -2;x
3882 echo ' #9'
3883 vput vexpr res * 0 0;x
3884 vput vexpr res * 0 1;x
3885 vput vexpr res * 1 1;x
3886 vput vexpr res * -13 -2;x
3887 echo ' #10'
3888 vput vexpr res / 0 0;x
3889 vput vexpr res / 0 1;x
3890 vput vexpr res / 1 1;x
3891 vput vexpr res / -13 -2;x
3892 echo ' #11'
3893 vput vexpr res % 0 0;x
3894 vput vexpr res % 0 1;x
3895 vput vexpr res % 1 1;x
3896 vput vexpr res % -13 -2;x
3897 echo ' #12'
3898 vput vexpr res pbase 10 u0x8000000000000001;x
3899 vput vexpr res pbase 16 0x8000000000000001;x
3900 vput vexpr res pbase 16 s0x8000000000000001;x
3901 vput vexpr res pbase 16 u0x8000000000000001;x
3902 vput vexpr res pbase 36 0x8000000000000001;x
3903 vput vexpr res pbase 36 u0x8000000000000001;x
3904 __EOT
3906 check numeric 0 "${MBOX}" '163128733 2519'
3908 if have_feat regex; then
3909 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
3910 commandalias x echo '$?/$^ERRNAME :$res:'
3911 echo ' #-2'
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 ' #-1'
3919 vput vexpr res regex you Y;x
3920 vput vexpr res regex? you Y;x
3921 vput vexpr res regex? you O;x
3922 vput vexpr res regex? you U;x
3923 vput vexpr res regex? you yO;x
3924 vput vexpr res regex? you oU;x
3925 vput vexpr res regex? you YoU;x
3926 echo ' #0'
3927 vput vexpr res regex 'bananarama' 'nana';x
3928 vput vexpr res regex 'bananarama' 'bana';x
3929 vput vexpr res regex 'bananarama' 'Bana';x
3930 vput vexpr res regex 'bananarama' 'rama';x
3931 echo ' #1'
3932 vput vexpr res regex? 'bananarama' 'nana';x
3933 vput vexpr res regex? 'bananarama' 'bana';x
3934 vput vexpr res regex? 'bananarama' 'Bana';x
3935 vput vexpr res regex? 'bananarama' 'rama';x
3936 echo ' #2'
3937 vput vexpr res regex 'bananarama' '(.*)nana(.*)' '\${1}a\${0}u{\$2}';x
3938 vput vexpr res regex 'bananarama' '(.*)bana(.*)' '\${1}a\${0}u\$2';x
3939 vput vexpr res regex 'bananarama' 'Bana(.+)' '\$1\$0';x
3940 vput vexpr res regex 'bananarama' '(.+)rama' '\$1\$0';x
3941 echo ' #3'
3942 vput vexpr res regex? 'bananarama' '(.*)nana(.*)' '\${1}a\${0}u{\$2}';x
3943 vput vexpr res regex? 'bananarama' '(.*)bana(.*)' '\${1}a\${0}u\$2';x
3944 vput vexpr res regex? 'bananarama' 'Bana(.+)' '\$1\$0';x
3945 vput vexpr res regex? 'bananarama' '(.+)rama' '\$1\$0';x
3946 echo ' #4'
3947 vput vexpr res regex 'banana' '(club )?(.*)(nana)(.*)' \
3948 '\$1\${2}\$4\${3}rama';x
3949 vput vexpr res regex 'Banana' '(club )?(.*)(nana)(.*)' \
3950 '\$1\$2\${2}\$2\$4\${3}rama';x
3951 vput vexpr res regex 'Club banana' '(club )?(.*)(nana)(.*)' \
3952 '\$1\${2}\$4\${3}rama';x
3953 echo ' #5'
3954 __EOT
3956 check regex 0 "${MBOX}" '2831099111 542'
3957 else
3958 t_echoskip 'regex:[!REGEX]'
3961 t_epilog "${@}"
3964 t_call_ret() {
3965 t_prolog "${@}"
3967 if have_feat cmd-vexpr; then :; else
3968 t_echoskip '[!CMD_VEXPR]'
3969 t_epilog "${@}"
3970 return
3973 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Snomemdebug > "${MBOX}" 2>&1
3974 define w1 {
3975 echon ">$1 "
3976 vput vexpr i + $1 1
3977 if [ $i -le 42 ]
3978 vput vexpr j '&' $i 7
3979 if [ $j -eq 7 ]
3980 echo .
3982 call w1 $i
3983 wysh set i=$? k=$!
3984 vput vexpr j '&' $i 7
3985 echon "<$1/$i/$k "
3986 if [ $j -eq 7 ]
3987 echo .
3989 else
3990 echo ! The end for $1
3992 return $1
3994 # Transport $?/$! up the call chain
3995 define w2 {
3996 echon ">$1 "
3997 vput vexpr i + $1 1
3998 if [ $1 -lt 42 ]
3999 call w2 $i
4000 wysh set i=$? j=$! k=$^ERRNAME
4001 echon "<$1/$i/$k "
4002 return $i $j
4003 else
4004 echo ! The end for $1
4005 return $i $^ERR-BUSY
4007 echoerr au
4009 # Up and down it goes
4010 define w3 {
4011 echon ">$1/$2 "
4012 vput vexpr i + $1 1
4013 if [ $1 -lt 42 ]
4014 call w3 $i $2
4015 wysh set i=$? j=$!
4016 vput vexpr k - $1 $2
4017 if [ $k -eq 21 ]
4018 vput vexpr i + $1 1
4019 vput vexpr j + $2 1
4020 echo "# <$i/$j> .. "
4021 call w3 $i $j
4022 wysh set i=$? j=$!
4024 eval echon "<\$1=\$i/\$^ERRNAME-$j "
4025 return $i $j
4026 else
4027 echo ! The end for $1=$i/$2
4028 if [ "$2" != "" ]
4029 return $i $^ERR-DOM
4030 else
4031 return $i $^ERR-BUSY
4034 echoerr au
4037 call w1 0; echo ?=$? !=$!; echo -----;
4038 call w2 0; echo ?=$? !=$^ERRNAME; echo -----;
4039 call w3 0 1; echo ?=$? !=$^ERRNAME; echo -----;
4040 __EOT
4042 check 1 0 "${MBOX}" '1572045517 5922'
4044 t_epilog "${@}"
4047 t_xcall() {
4048 t_prolog "${@}"
4050 if have_feat cmd-vexpr; then :; else
4051 t_echoskip '[!CMD_VEXPR]'
4052 t_epilog "${@}"
4053 return
4056 ${cat} <<- '__EOT' | \
4057 ${MAILX} ${ARGS} -Snomemdebug \
4058 -Smax=${LOOPS_MAX} \
4059 > "${MBOX}" 2>&1
4060 define work {
4061 echon "$1 "
4062 vput vexpr i + $1 1
4063 if [ $i -le "$max" ]
4064 vput vexpr j '&' $i 7
4065 if [ $j -eq 7 ]
4066 echo .
4068 \xcall work $i $2
4070 echo ! The end for $1/$2
4071 if [ "$2" != "" ]
4072 return $i $^ERR-BUSY
4075 define xwork {
4076 \xcall work 0 $2
4078 call work 0
4079 echo ?=$? !=$!
4080 call xwork
4081 echo ?=$? !=$!
4082 xcall xwork
4083 echo ?=$? !=$^ERRNAME
4085 call work 0 yes
4086 echo ?=$? !=$^ERRNAME
4087 call xwork 0 yes
4088 echo ?=$? !=$^ERRNAME
4089 __EOT
4091 i=${?}
4092 if [ ${LOOPS_MAX} -eq ${LOOPS_BIG} ]; then
4093 check_ex0 1-${LOOPS_BIG} ${i}
4094 check 1-${LOOPS_BIG} - "${MBOX}" '1069764187 47161'
4095 else
4096 check_ex0 1-${LOOPS_SMALL} ${i}
4097 check 1-${LOOPS_SMALL} - "${MBOX}" '859201011 3894'
4102 if have_feat uistrings; then
4103 ${cat} <<- '__EOT' > "${BODY}"
4104 define __w {
4105 echon "$1 "
4106 vput vexpr i + $1 1
4107 if [ $i -le 111 ]
4108 vput vexpr j '&' $i 7
4109 if [ $j -eq 7 ]
4110 echo .
4112 \xcall __w $i $2
4114 echo ! The end for $1
4115 if [ $2 -eq 0 ]
4116 nonexistingcommand
4117 echo would be err with errexit
4118 return
4120 echo calling exit
4121 exit
4123 define work {
4124 echo eins
4125 call __w 0 0
4126 echo zwei, ?=$? !=$!
4127 localopts yes; set errexit
4128 ignerr call __w 0 0
4129 echo drei, ?=$? !=$^ERRNAME
4130 call __w 0 $1
4131 echo vier, ?=$? !=$^ERRNAME, this is an error
4133 ignerr call work 0
4134 echo outer 1, ?=$? !=$^ERRNAME
4135 xxxign call work 0
4136 echo outer 2, ?=$? !=$^ERRNAME, could be error if xxxign non-empty
4137 call work 1
4138 echo outer 3, ?=$? !=$^ERRNAME
4139 echo this is definitely an error
4140 __EOT
4142 < "${BODY}" ${MAILX} ${ARGS} -X'commandalias xxxign ignerr' \
4143 -Snomemdebug > "${MBOX}" 2>&1
4144 check 2 0 "${MBOX}" '4036613316 4184'
4146 < "${BODY}" ${MAILX} ${ARGS} -X'commandalias xxxign " "' \
4147 -Snomemdebug > "${MBOX}" 2>&1
4148 check 3 1 "${MBOX}" '3179757785 2787'
4149 else
4150 t_echoskip '2-3:[!UISTRINGS]'
4153 t_epilog "${@}"
4156 t_vpospar() {
4157 t_prolog "${@}"
4159 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
4160 vpospar set hey, "'you ", world!
4161 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4162 vput vpospar x quote; echo x<$x>
4163 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4164 vput vpospar y quote;echo y<$y>
4165 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4166 eval vpospar set ${y};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4167 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4169 define infun2 {
4170 echo infun2:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
4171 vput vpospar z quote;echo infun2:z<$z>
4174 define infun {
4175 echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
4176 vput vpospar y quote;echo infun:y<$y>
4177 eval vpospar set ${x};echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
4178 vpospar clear;echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
4179 eval call infun2 $x
4180 echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
4181 eval vpospar set ${y};echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
4184 call infun This "in a" fun
4185 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4186 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4187 __EOT
4188 check 1 0 "${MBOX}" '155175639 866'
4191 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
4192 set ifs=\'
4193 echo ifs<$ifs> ifs-ws<$ifs-ws>
4194 vpospar set hey, "'you ", world!
4195 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4196 vput vpospar x quote; echo x<$x>
4197 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4198 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4200 set ifs=,
4201 echo ifs<$ifs> ifs-ws<$ifs-ws>
4202 vpospar set hey, "'you ", world!
4203 unset ifs;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4204 set ifs=,
4205 vput vpospar x quote; echo x<$x>
4206 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4207 eval vpospar set ${x};\
4208 unset ifs;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4210 wysh set ifs=$',\t'
4211 echo ifs<$ifs> ifs-ws<$ifs-ws>
4212 vpospar set hey, "'you ", world!
4213 unset ifs; echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4214 wysh set ifs=$',\t'
4215 vput vpospar x quote; echo x<$x>
4216 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4217 eval vpospar set ${x};\
4218 unset ifs;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4219 __EOT
4220 check ifs 0 "${MBOX}" '2015927702 706'
4222 t_epilog "${@}"
4225 t_atxplode() {
4226 t_prolog "${@}"
4228 ${cat} > ./.t.sh <<- '___'; ${cat} > ./.t.rc <<- '___'
4229 x() { echo $#; }
4230 xxx() {
4231 printf " (1/$#: <$1>)"
4232 shift
4233 if [ $# -gt 0 ]; then
4234 xxx "$@"
4235 else
4236 echo
4239 yyy() {
4240 eval "$@ ' ball"
4242 set --
4243 x "$@"
4244 x "$@"''
4245 x " $@"
4246 x "$@ "
4247 printf yyy;yyy 'xxx' "b\$'\t'u ' "
4248 printf xxx;xxx arg ,b u.
4249 printf xxx;xxx arg , .
4250 printf xxx;xxx arg ,ball.
4252 define x {
4253 echo $#
4255 define xxx {
4256 echon " (1/$#: <$1>)"
4257 shift
4258 if [ $# -gt 0 ]
4259 \xcall xxx "$@"
4260 endif
4261 echo
4263 define yyy {
4264 eval "$@ ' ball"
4266 vpospar set
4267 call x "$@"
4268 call x "$@"''
4269 call x " $@"
4270 call x "$@ "
4271 echon yyy;call yyy '\call xxx' "b\$'\t'u ' "
4272 echon xxx;call xxx arg ,b u.
4273 echon xxx;call xxx arg , .
4274 echon xxx;call xxx arg ,ball.
4277 ${MAILX} ${ARGS} -X'source ./.t.rc' -Xx > "${MBOX}" 2>&1
4278 check 1 0 "${MBOX}" '41566293 164'
4280 #${SHELL} ./.t.sh > ./.tshout 2>&1
4281 #check disproof-1 0 ./.tshout '41566293 164'
4283 t_epilog "${@}"
4286 t_read() {
4287 t_prolog "${@}"
4289 ${cat} <<- '__EOT' > .tin
4290 hey1, "'you ", world!
4291 hey2, "'you ", bugs bunny!
4292 hey3, "'you ",
4293 hey4, "'you "
4294 __EOT
4296 ${cat} <<- '__EOT' |\
4297 ${MAILX} ${ARGS} -X'readctl create ./.tin' > "${MBOX}" 2>&1
4298 commandalias x echo '$?/$^ERRNAME / <$a><$b><$c>'
4299 read a b c;x
4300 read a b c;x
4301 read a b c;x
4302 read a b c;x
4303 unset a b c;read a b c;x
4304 readctl remove ./.tin;echo readctl remove:$?/$^ERRNAME
4305 __EOT
4306 check 1 0 "${MBOX}" '1527910147 173'
4308 ${cat} <<- '__EOT' > .tin2
4309 hey2.0,:"'you ",:world!:mars.:
4310 hey2.1,:"'you ",:world!
4311 hey2.2,:"'you ",:bugs bunny!
4312 hey2.3,:"'you ",:
4313 hey2.4,:"'you ":
4315 __EOT
4317 ${cat} <<- '__EOT' |\
4318 6< .tin2 ${MAILX} ${ARGS} -X 'readctl create 6' > "${MBOX}" 2>&1
4319 commandalias x echo '$?/$^ERRNAME / <$a><$b><$c>'
4320 set ifs=:
4321 read a b c;x
4322 read a b c;x
4323 read a b c;x
4324 read a b c;x
4325 read a b c;x
4326 read a b c;x
4327 unset a b c;read a b c;x
4328 read a b c;x
4329 readctl remove 6;echo readctl remove:$?/$^ERRNAME
4330 __EOT
4331 check ifs 0 "${MBOX}" '890153490 298'
4333 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
4334 commandalias x echo '$?/$^ERRNAME / <$d>'
4335 readctl create .tin
4336 readall d;x
4337 wysh set d;readall d;x
4338 readctl create .tin2
4339 readall d;x
4340 wysh set d;readall d;x
4341 readctl remove .tin;echo $?/$^ERRNAME;\
4342 readctl remove .tin2;echo $?/$^ERRNAME
4343 echo '### now with empty lines'
4344 ! printf 'one line\n\ntwo line\n\n' > ./.temptynl
4345 readctl create .temptynl;echo $?/$^ERRNAME
4346 readall d;x
4347 readctl remove .temptynl;echo $?/$^ERRNAME
4348 __EOT
4349 check readall 0 "${MBOX}" '4113506527 405'
4351 t_epilog "${@}"
4354 t_readsh() { # TODO not enough
4355 t_prolog "${@}"
4357 ${cat} <<- '__EOT' > .tin
4358 from@exam.ple ' diet spliced <from@exam.ple> ' 'a'
4359 from@exam.ple ' diet spliced <from@exam.ple> ' 'a'
4360 from@exam.ple ' diet spliced <from@exam.ple> ''a'
4361 from@exam.ple' diet spliced <from@exam.ple> ''a'
4362 __EOT
4364 ${cat} <<- '__EOT' |\
4365 ${MAILX} ${ARGS} -X'readctl create ./.tin' > "${MBOX}" 2>&1
4366 commandalias x echo '$?/$^ERRNAME / <$a><$b><$c>'
4367 readsh a b c;x
4368 readsh a b c;x
4369 readsh a b c;x
4370 readsh a b c;x
4371 unset a b c;read a b c;x
4372 readctl remove ./.tin;echo readctl remove:$?/$^ERRNAME
4373 __EOT
4374 check 1 0 "${MBOX}" '2955084684 291'
4376 t_epilog "${@}"
4379 t_headerpick() {
4380 t_prolog "${@}"
4382 t__x1_msg > ./.tmbox
4385 </dev/null ${MAILX} ${ARGS} -Rf -Y '# Do not care much on error UISTRINGS
4386 \echo --- 1
4387 \headerpick
4388 \echo --- $?/$^ERRNAME, 2
4389 \type
4390 \echo --- $?/$^ERRNAME, 3
4391 \if "$features" !% +uistrings,
4392 \echoerr reproducible_build: Invalid field name cannot be ignored: ba:l
4393 \endif
4394 \headerpick type ignore \
4395 from_ mail-followup-to in-reply-to DATE MESSAGE-ID STATUS ba:l
4396 \echo --- $?/$^ERRNAME, 4
4397 \if "$features" !% +uistrings,
4398 \echo "#headerpick type retain currently covers no fields"
4399 \endif
4400 \headerpick
4401 \echo --- $?/$^ERRNAME, 5
4402 \type
4403 \echo --- $?/$^ERRNAME, 6
4404 \unheaderpick type ignore from_ DATE STATUS
4405 \echo --- $?/$^ERRNAME, 7
4406 \if "$features" !% +uistrings,
4407 \echo "#headerpick type retain currently covers no fields"
4408 \endif
4409 \headerpick
4410 \echo --- $?/$^ERRNAME, 8
4411 \type
4412 \echo --- $?/$^ERRNAME, 9
4413 \if "$features" =% +uistrings,
4414 \unheaderpick type ignore from_ ba:l
4415 \wysh set x=$? y=$^ERRNAME
4416 \else
4417 \echoerr reproducible_build: Field not ignored: from_
4418 \echoerr reproducible_build: Field not ignored: ba:l
4419 \set x=1 y=INVAL
4420 \endif
4421 \echo --- $x/$y, 10
4422 \unheaderpick type ignore *
4423 \echo --- $?/$^ERRNAME, 11
4424 \if "$features" !% +uistrings,
4425 \echo "#headerpick type retain currently covers no fields"
4426 \echo "#headerpick type ignore currently covers no fields"
4427 \endif
4428 \headerpick
4429 \echo --- $?/$^ERRNAME, 12
4430 \type
4431 \echo --- $?/$^ERRNAME, 13 ---
4432 # ' ./.tmbox >./.tall 2>&1
4433 check 1 0 ./.tall '2481904228 2273'
4436 if have_feat uistrings; then
4437 have_feat regex && i='3515512395 2378' || i='4201290332 2378'
4438 </dev/null ${MAILX} ${ARGS} -Y '#
4439 \headerpick type retain \
4440 bcc cc date from sender subject to \
4441 message-id mail-followup-to reply-to user-agent
4442 \echo --- $?/$^ERRNAME, 1
4443 \headerpick forward retain \
4444 cc date from message-id list-id sender subject to \
4445 mail-followup-to reply-to
4446 \echo --- $?/$^ERRNAME, 2
4447 \headerpick save ignore ^Original-.*$ ^X-.*$ ^DKIM.*$
4448 \echo --- $?/$^ERRNAME, 3
4449 \headerpick top retain To Cc
4450 \echo --- $?/$^ERRNAME, 4 ---
4451 \headerpick
4452 \echo --- $?/$^ERRNAME, 5
4453 \headerpick type
4454 \echo --- $?/$^ERRNAME, 6
4455 \headerpick forward
4456 \echo --- $?/$^ERRNAME, 7
4457 \headerpick save
4458 \echo --- $?/$^ERRNAME, 8
4459 \headerpick top
4460 \echo --- $?/$^ERRNAME, 9 ---
4461 \unheaderpick type retain message-id mail-followup-to reply-to user-agent
4462 \echo --- $?/$^ERRNAME, 10
4463 \unheaderpick save ignore ^X-.*$ ^DKIM.*$
4464 \echo --- $?/$^ERRNAME, 11
4465 \unheaderpick forward retain *
4466 \echo --- $?/$^ERRNAME, 12 ---
4467 \headerpick
4468 \echo --- $?/$^ERRNAME, 13
4469 \headerpick type
4470 \echo --- $?/$^ERRNAME, 14
4471 \headerpick save
4472 \echo --- $?/$^ERRNAME, 15 --
4473 \unheaderpick type retain *
4474 \echo --- $?/$^ERRNAME, 16
4475 \unheaderpick forward retain *
4476 \echo --- $?/$^ERRNAME, 17
4477 \unheaderpick save ignore *
4478 \echo --- $?/$^ERRNAME, 18
4479 \unheaderpick top retain *
4480 \echo --- $?/$^ERRNAME, 19 --
4481 \headerpick
4482 \echo --- $?/$^ERRNAME, 20
4483 # ' >./.tall 2>&1
4484 check 2 0 ./.tall "${i}"
4485 else
4486 t_echoskip '2:[!UISTRINGS]'
4489 t_epilog "${@}"
4491 # }}}
4493 # Send/RFC absolute basics {{{
4494 t_can_send_rfc() { # {{{
4495 t_prolog "${@}"
4497 </dev/null ${MAILX} ${ARGS} -Smta=test://"$MBOX" -s Sub.1 \
4498 receiver@number.1 \
4499 > ./.terr 2>&1
4500 check 1 0 "${MBOX}" '550126528 126'
4501 check 1-err - .terr '4294967295 0'
4503 </dev/null ${MAILX} ${ARGS} -Smta=test://"$MBOX" -s Sub.2 \
4504 -b bcc@no.1 -b bcc@no.2 -b bcc@no.3 \
4505 -c cc@no.1 -c cc@no.2 -c cc@no.3 \
4506 to@no.1 to@no.2 to@no.3 \
4507 > ./.terr 2>&1
4508 check 2 0 "${MBOX}" '3259888945 324'
4509 check 2-err - .terr '4294967295 0'
4511 </dev/null ${MAILX} ${ARGS} -Smta=test://"$MBOX" -s Sub.2no \
4512 -b bcc@no.1\ \ bcc@no.2 -b bcc@no.3 \
4513 -c cc@no.1,cc@no.2 -c cc@no.3 \
4514 to@no.1,to@no.2 to@no.3 \
4515 > ./.terr 2>&1
4516 check 2no 4 "${MBOX}" '3350946897 468'
4517 if have_feat uistrings; then
4518 check 2no-err - .terr '3397557940 190'
4519 else
4520 check 2no-err - .terr '4294967295 0'
4523 # XXX NOTE we cannot test "cc@no1 <cc@no.2>" because our stupid parser
4524 # XXX would not treat that as a list but look for "," as a separator
4525 </dev/null ${MAILX} ${ARGS} -Smta=test://"$MBOX" -Sfullnames -s Sub.3 \
4526 -T 'bcc?single: bcc@no.1, <bcc@no.2>' -T bcc:\ bcc@no.3 \
4527 -T cc?si\ \ :\ \ '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 3 0 "${MBOX}" '1453534480 678'
4531 check 3-err - .terr '4294967295 0'
4533 </dev/null ${MAILX} ${ARGS} -Smta=test://"$MBOX" -Sfullnames -s Sub.4 \
4534 -T 'bcc: bcc@no.1, <bcc@no.2>' -T bcc:\ bcc@no.3 \
4535 -T cc:\ 'cc@no.1, <cc@no.2>' -T cc\ \ :\ \ cc@no.3 \
4536 -T to\ :to@no.1,'<to@no.2>' -T to:\ to@no.3 \
4537 > ./.terr 2>&1
4538 check 4 0 "${MBOX}" '535767201 882'
4539 check 4-err - .terr '4294967295 0'
4541 # Two test with a file-based MTA
4542 "${cat}" <<-_EOT > .tmta.sh
4543 #!${SHELL} -
4544 (echo 'From reproducible_build Wed Oct 2 01:50:07 1996' &&
4545 "${cat}" && echo pardauz && echo) > "${MBOX}"
4546 _EOT
4547 ${chmod} 0755 .tmta.sh
4549 </dev/null ${MAILX} ${ARGS} -Smta=./.tmta.sh -s Sub.mta-1 \
4550 receiver@number.1 > ./.terr 2>&1
4551 check 5 0 "${MBOX}" '2384401657 138'
4552 check 5-err - .terr '4294967295 0'
4554 </dev/null ${MAILX} ${ARGS} -Smta=file://./.tmta.sh -s Sub.mta-2 \
4555 receiver@number.1 > ./.terr 2>&1
4556 check 6 0 "${MBOX}" '3006460737 138'
4557 check 6-err - .terr '4294967295 0'
4559 # Command
4560 </dev/null ${MAILX} ${ARGS} -Smta=test \
4561 -Y '#
4562 mail hey@exam.ple
4563 ~s Subject 1
4564 Body1
4566 echo $?/$^ERRNAME
4568 # ' > ./.tall 2>&1
4569 check 7 0 ./.tall '951018449 138'
4571 ## *record*, *outfolder*, with and without *mta-bcc-ok*
4572 ${mkdir} .tfolder
4573 xfolder=`${pwd}`/.tfolder
4575 "${cat}" <<-_EOT > .tmta.sh
4576 #!${SHELL} -
4577 (echo 'From reproducible_build Wed Oct 2 01:50:07 1996' &&
4578 "${cat}" && echo 'ARGS: '"\${@}" && echo) > "${MBOX}"
4579 _EOT
4580 ${chmod} 0755 .tmta.sh
4582 t_it() {
4583 </dev/null ${MAILX} ${ARGS} -Smta=./.tmta.sh -Sfolder="${xfolder}" \
4584 "${@}" \
4585 -s Sub.mta-1 \
4586 -b bcc@no.1 -b bcc@no.2 -b bcc@no.3 \
4587 -c cc@no.1 -c cc@no.2 -c cc@no.3 \
4588 to@no.1 to@no.2 to@no.3 \
4589 receiver@number.1 > ./.terr 2>&1
4590 return ${?}
4593 t_it -Snomta-bcc-ok
4594 check 8 0 "${MBOX}" '1365032629 292'
4595 check 8-1 - .terr '4294967295 0'
4597 t_it -Snomta-bcc-ok -Srecord=.trec9
4598 check 9 0 "${MBOX}" '1365032629 292'
4599 check 9-1 - .terr '4294967295 0'
4600 check 9-2 - ./.trec9 '160206230 221'
4602 t_it -Srecord=.trec10
4603 check 10 0 "${MBOX}" '3085765596 326'
4604 check 10-1 - .terr '4294967295 0'
4605 check 10-2 - ./.trec10 '160206230 221'
4607 t_it -Snomta-bcc-ok -Srecord=.trec11 -Soutfolder
4608 check 11 0 "${MBOX}" '1365032629 292'
4609 check 11-1 - .terr '4294967295 0'
4610 check 11-2 - ./.tfolder/.trec11 '160206230 221'
4611 # That is appends to an MBOX
4612 t_it -Srecord=.trec11 -Soutfolder
4613 check 12 0 "${MBOX}" '3085765596 326'
4614 check 12-1 - .terr '4294967295 0'
4615 check 12-2 - ./.tfolder/.trec11 '1618754846 442'
4617 ### More RFC cases
4619 ## From: and Sender:
4620 </dev/null ${MAILX} ${ARGS} -s ubject \
4621 -S from=a@b.org,b@b.org,c@c.org -S sender=a@b.org \
4622 to@exam.ple > "${MBOX}" 2>&1
4623 check 13 0 "${MBOX}" '143390417 169'
4625 # ..if From: is single mailbox and Sender: is same, no Sender:
4626 </dev/null ${MAILX} ${ARGS} -s ubject \
4627 -S from=a@b.org -S sender=a@b.org \
4628 to@exam.ple > "${MBOX}" 2>&1
4629 check 14 0 "${MBOX}" '1604962737 135'
4631 t_epilog "${@}"
4632 } # }}}
4634 t_reply() { # {{{
4635 # Alternates and ML related address massage etc. somewhere else
4636 t_prolog "${@}"
4637 XARGS=${ARGS} # TODO v15-compat
4638 ARGS="${ARGS} -Sv15-compat=y"
4640 t__gen_msg subject reply from 1 to 2 cc 2 > "${MBOX}"
4642 ## Base (does not test "recipient record")
4643 t_it() {
4644 </dev/null ${MAILX} ${ARGS} -Rf \
4645 -Y "${2}${1}"'
4648 echo 1:$?/$^ERRNAME
4649 set fullnames escape=!; '${1}'
4650 r2 fullnames
4652 echo 2:$?/$^ERRNAME
4653 set recipients-in-cc nofullnames; '${1}'
4654 r3 recipients-in-cc
4656 echo 3:$?/$^ERRNAME
4657 unset recipients-in-cc; '${1}'
4660 echo 4:$?/$^ERRNAME
4661 #' \
4662 "${MBOX}" > ./.tall 2>&1
4663 return ${?}
4666 t_it reply
4667 check 1 0 ./.tall '4164251531 851'
4668 t_it Reply
4669 check 2 0 ./.tall '3034955332 591'
4670 t_it reply 'set flipr;'
4671 check 3 0 ./.tall '3034955332 591'
4672 t_it Reply 'set flipr;'
4673 check 4 0 ./.tall '4164251531 851'
4675 ## Dig the errors
4676 t__gen_msg subject reply-no-addr > ./.tnoaddr
4678 # MBOX will deduce addressee from From_ line..
4679 </dev/null ${MAILX} ${ARGS} -R -Sescape=! \
4680 -Y '#
4681 File ./.tnoaddr; reply # Takes addressee from From_ line :(
4682 body1
4684 echo 1:$?/$^ERRNAME
4685 File '"${MBOX}"'; set ea=$expandaddr expandaddr=-all; reply
4686 body2
4688 echo 2:$?/$^ERRNAME; set expandaddr=$ea; reply 10 # BADMSG
4689 echo 3:$?/$^ERRNAME; reply # cannot test IO,NOTSUP,INVAL
4690 body3
4692 echo 4:$?/$^ERRNAME
4693 #' \
4694 > ./.tall 2>./.terr
4695 check 5 0 ./.tall '3088217220 382'
4696 if have_feat uistrings; then
4697 check 6 - ./.terr '2514745519 544'
4698 else
4699 t_echoskip '6:[!UISTRINGS]'
4702 # ..but Maildir will not
4703 if have_feat maildir; then
4704 ${mkdir} -p .tdir .tdir/tmp .tdir/cur .tdir/new
4705 ${sed} 1d < ./.tnoaddr > .tdir/new/sillyname
4707 </dev/null ${MAILX} ${ARGS} -R -Sescape=! \
4708 -Y '#
4709 File ./.tdir; reply
4710 body1
4712 echo 1:$?/$^ERRNAME
4713 File '"${MBOX}"'; set ea=$expandaddr expandaddr=-all; reply
4714 body2
4716 echo 2:$?/$^ERRNAME; set expandaddr=$ea; reply 10 # BADMSG
4717 echo 3:$?/$^ERRNAME;reply # cannot test IO,NOTSUP,INVAL
4718 body3
4720 echo 4:$?/$^ERRNAME
4721 #' \
4722 > ./.tall 2>./.terr
4723 check 7 0 ./.tall '3631170341 244'
4724 if have_feat uistrings; then
4725 check 8 - ./.terr '1074346767 629'
4726 else
4727 t_echoskip '8:[!UISTRINGS]'
4731 ## Ensure action on multiple messages
4732 t__gen_msg subject reply2 from from2@exam.ple body body2 >> "${MBOX}"
4734 t_it() {
4735 </dev/null ${MAILX} ${ARGS} -Rf -Sescape=! \
4736 -Y '#
4737 '${1}' 1 2
4738 repbody1
4740 repbody2
4742 echo 1:$?/$^ERRNAME; '${2}' 1 2
4743 Repbody1
4745 echo 2:$?/$^ERRNAME
4746 #' \
4747 "${MBOX}" > ./.tall 2>&1
4748 check ${3} 0 ./.tall '283309820 502'
4749 if [ ${#} -eq 4 ]; then
4750 echo * > ./.tlst
4751 check ${3}-1 - ./.tlst '1649520021 12'
4752 check ${3}-2 - ./from1 '1501109193 347'
4753 check ${3}-3 - ./from2 '2154231432 137'
4757 t_it reply Reply 9
4758 t_it respond Respond 10
4759 t_it followup Followup 11 yes
4760 ${rm} -f from1 from2
4762 ## *record*, *outfolder* (reuses $MBOX)
4763 ${mkdir} .tfolder
4765 t_it() {
4766 </dev/null ${MAILX} ${ARGS} -Rf -Sescape=! -Sfolder=`${pwd}`/.tfolder \
4767 -Y '#
4768 '${1}' 1 2
4769 repbody1
4771 repbody2
4773 echo 1:$?/$^ERRNAME; '${2}' 1 2
4774 Repbody3
4776 echo 2:$?/$^ERRNAME; set record=.trec'${4}'; '${1}' 1 2
4777 repbody4
4779 repbody5
4781 echo 3:$?/$^ERRNAME; '${2}' 1 2
4782 Repbody6
4784 echo 4:$?/$^ERRNAME; set outfolder norecord
4785 '${1}' 1 2
4786 repbody1
4788 repbody2
4790 echo 1:$?/$^ERRNAME; '${2}' 1 2
4791 Repbody3
4793 echo 2:$?/$^ERRNAME; set record=.trec'${4}'; '${1}' 1 2
4794 repbody4
4796 repbody5
4798 echo 3:$?/$^ERRNAME; '${2}' 1 2
4799 Repbody6
4801 echo 4:$?/$^ERRNAME
4802 #' \
4803 "${MBOX}" > ./.tall 2>&1
4804 check ${3} 0 ./.tall '3410330303 2008'
4805 if [ ${#} -ne 5 ]; then
4806 check ${4} - ./.trec${4} '3044885336 484'
4807 check ${4}-1 - ./.tfolder/.trec${4} '3044885336 484'
4808 else
4809 [ -f ./.trec${4} ]; check_exn0 ${4}
4810 echo * > ./.tlst
4811 check ${4}-1 - ./.tlst '1649520021 12'
4812 check ${4}-2 - ./from1 '2668975631 694'
4813 check ${4}-3 - ./from2 '225462887 274'
4814 [ -f ./.tfolder/.trec${4} ]; check_exn0 ${4}-4
4815 ( cd .tfolder && echo * > ./.tlst )
4816 check ${4}-5 - ./.tfolder/.tlst '1649520021 12'
4817 check ${4}-6 - ./.tfolder/from1 '2668975631 694'
4818 check ${4}-7 - ./.tfolder/from2 '225462887 274'
4822 t_it reply Reply 12 13
4823 t_it respond Respond 14 15
4824 t_it followup Followup 16 17 yes
4825 #${rm} -f from1 from2
4827 ## Quoting (if not cmd_escapes related)
4828 ${rm} -f "${MBOX}"
4829 t__x2_msg > ./.tmbox
4831 printf '#
4832 set indentprefix=" |" quote
4833 reply
4836 set quote=noheading quote-inject-head
4837 reply
4840 headerpick type retain cc date from message-id reply-to subject to
4841 set quote=headers
4842 reply
4845 set quote=allheaders
4846 reply
4849 set quote-inject-head=%% quote-inject-tail=%% quote=headers
4850 reply
4853 set quote \\
4854 quote-inject-head='"\$'"'\\
4855 (%%%%a=%%a %%%%d=%%d %%%%f=%%f %%%%i=%%i %%%%n=%%n %%%%r=%%r)\\
4856 \\n'"'"' \\
4857 quote-inject-tail='"\$'"'\\
4858 (%%%%a=%%a %%%%d=%%d %%%%f=%%f %%%%i=%%i %%%%n=%%n %%%%r=%%r)\\
4859 \\n'"'"'
4860 reply
4863 set showname datefield=%%y nodatefield-markout-older indentprefix=\\ :
4864 reply
4867 ' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" -Rf \
4868 -Sescape=! -Sindentprefix=' >' \
4869 ./.tmbox >./.tall 2>&1
4870 check_ex0 18-estat
4871 ${cat} ./.tall >> "${MBOX}"
4872 check 18 - "${MBOX}" '385267528 3926'
4874 # quote-as-attachment, fullnames
4875 </dev/null ${MAILX} ${ARGS} -Rf \
4876 -Sescape=! \
4877 -S quote-as-attachment \
4878 -Y reply -Y yb1 -Y !. \
4879 -Y 'unset quote-as-attachment' \
4880 -Y 'reply;yb2' -Y !. \
4881 -Y 'set quote-as-attachment fullnames' \
4882 -Y ';reply;yb3' -Y !. \
4883 ./.tmbox >./.tall 2>&1
4884 check 19 0 ./.tall '2774517283 2571'
4886 # Moreover, quoting of several parts with all*
4887 t__gen_mimemsg from 'ex1@am.ple' subject for-repl > ./.tmbox
4888 check 20 0 ./.tmbox '1874764424 668'
4890 have_feat filter-html-tagsoup && ck='946925637 1105' || ck='3587432511 1165'
4891 </dev/null ${MAILX} ${ARGS} -Rf \
4892 -Sescape=! -Sindentprefix=' |' \
4893 -Y 'set quote=allheaders' \
4894 -Y reply -Y !. \
4895 -Y 'set quote=allbodies' \
4896 -Y reply -Y !. \
4897 -Y xit \
4898 ./.tmbox >./.tall 2>&1
4899 check 21 0 ./.tall "${ck}"
4901 ARGS=${XARGS} # TODO v15-compat
4902 t_epilog "${@}"
4903 } # }}}
4905 t_forward() { # {{{
4906 t_prolog "${@}"
4907 XARGS=${ARGS}
4908 ARGS="${ARGS} -Sv15-compat=y"
4910 t__gen_msg subject fwd1 body origb1 from 1 to 2 > "${MBOX}"
4911 t__gen_msg subject fwd2 body origb2 from 1 to 1 >> "${MBOX}"
4913 ## Base (does not test "recipient record")
4914 t_it() {
4915 </dev/null ${MAILX} ${ARGS} -Rf \
4916 -Y ${1}' . "du <ex1@am.ple>"
4919 echo 1:$?/$^ERRNAME; echoerr 1:done
4920 set fullnames escape=!
4921 '${1}' 1 "du <ex2@am.ple>"
4922 b2 fullnames
4924 echo 2:$?/$^ERRNAME; echoerr 2:done
4925 # Some errors
4926 set nofullnames ea=$expandaddr expandaddr=-all
4927 '${1}' ` "du <ex3@am.ple>"
4930 echo 3:$?/$^ERRNAME; echoerr 3:done
4931 set expandaddr=$ea
4932 '${1}' ` ex4-nono@am.ple ex4@am.ple # the first is a non-match msglist
4935 echo 4:$?/$^ERRNAME; echoerr 4:done
4936 '${1}' # TODO not yet possible b5 !.
4937 echo 5:$?/$^ERRNAME; echoerr 5:done
4938 set expandaddr=$ea
4939 '${1}' 1 2 ex6@am.ple
4940 b6-1
4942 b6-2
4944 echo 6:$?/$^ERRNAME; echoerr 6:done
4945 set forward-add-cc fullnames
4946 '${1}' . ex7@am.ple
4949 echo 7:$?/$^ERRNAME; echoerr 7:done
4950 set nofullnames
4951 '${1}' . ex8@am.ple
4954 echo 8:$?/$^ERRNAME; echoerr 8:done
4955 #' \
4956 "${MBOX}" > ./.tall 2>./.terr
4957 return ${?}
4960 t_it forward
4961 check 1 0 ./.tall '2356713156 2219'
4962 if have_feat uistrings && have_feat docstrings; then
4963 check 2 - ./.terr '3273108824 335'
4964 else
4965 t_echoskip '2:[!UISTRINGS]'
4968 t_it Forward
4969 check 3 0 ./.tall '2356713156 2219'
4970 if have_feat uistrings && have_feat docstrings; then
4971 check 4 - ./.terr '447176534 355'
4972 else
4973 t_echoskip '4:[!UISTRINGS]'
4975 ${rm} -f ex*
4977 ## *record*, *outfolder* (reuses $MBOX)
4978 ${mkdir} .tfolder
4980 t_it() {
4981 </dev/null ${MAILX} ${ARGS} -Rf -Sescape=! -Sfolder=`${pwd}`/.tfolder \
4982 -Y '#
4983 '${1}' 1 ex1@am.ple
4986 echo 1:$?/$^ERRNAME; set record=.trec'${2}'; '${1}' 1 ex2@am.ple
4989 echo 2:$?/$^ERRNAME; set outfolder norecord; '${1}' 2 ex1@am.ple
4992 echo 3:$?/$^ERRNAME; set record=.trec'${2}'; '${1}' 2 ex2@am.ple
4995 echo 4:$?/$^ERRNAME
4996 #' \
4997 "${MBOX}" > ./.tall 2>&1
4998 check ${2} 0 ./.tall '3180366037 1212'
4999 if [ ${#} -ne 4 ]; then
5000 check ${3}-1 - ./.trec${2} '1769129556 304'
5001 check ${3}-2 - ./.tfolder/.trec${2} '2335391111 284'
5002 else
5003 [ -f ./.trec${2} ]; check_exn0 ${3}
5004 echo * > ./.tlst
5005 check ${3}-1 - ./.tlst '2020171298 8'
5006 check ${3}-2 - ./ex1 '1512529673 304'
5007 check ${3}-3 - ./ex2 '1769129556 304'
5008 [ -f ./.tfolder/.trec${2} ]; check_exn0 ${3}-4
5009 ( cd .tfolder && echo * > ./.tlst )
5010 check ${3}-5 - ./.tfolder/.tlst '2020171298 8'
5011 check ${3}-6 - ./.tfolder/ex1 '2016773910 284'
5012 check ${3}-7 - ./.tfolder/ex2 '2335391111 284'
5016 t_it forward 5 6
5017 t_it Forward 7 8 yes
5018 #${rm} -f ex*
5020 ## Injections, headerpick selection
5021 ${rm} -f "${MBOX}"
5022 t__x2_msg > ./.tmbox
5024 printf '#
5025 set quote=noheading forward-inject-head
5026 forward 1 ex1@am.ple
5029 headerpick forward retain cc from subject to
5030 forward 1 ex1@am.ple
5033 unheaderpick forward retain *
5034 forward 1 ex1@am.ple
5037 headerpick forward ignore in-reply-to reply-to message-id status
5038 set forward-inject-head=%% forward-inject-tail=%%
5039 forward 1 ex1@am.ple
5042 set forward-inject-head='"\$'"'\\
5043 (%%%%a=%%a %%%%d=%%d %%%%f=%%f %%%%i=%%i %%%%n=%%n %%%%r=%%r)\\
5044 \\n'"'"' \\
5045 forward-inject-tail='"\$'"'\\
5046 (%%%%a=%%a %%%%d=%%d %%%%f=%%f %%%%i=%%i %%%%n=%%n %%%%r=%%r)\\
5047 \\n'"'"'
5048 forward 1 ex1@am.ple
5051 set showname datefield=%%y nodatefield-markout-older
5052 forward 1 ex1@am.ple
5055 ' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" -Rf \
5056 -Sescape=! \
5057 ./.tmbox >./.tall 2>&1
5058 check_ex0 9-estat
5059 ${cat} ./.tall >> "${MBOX}"
5060 check 9 - "${MBOX}" '2976943913 2916'
5062 # forward-as-attachment
5063 </dev/null ${MAILX} ${ARGS} -Rf \
5064 -Sescape=! \
5065 -S forward-inject-head=.head. \
5066 -S forward-inject-tail=.tail. \
5067 -S forward-as-attachment \
5068 -Y 'headerpick forward retain subject to from' \
5069 -Y 'forward ex1@am.ple' -Y b1 -Y !. \
5070 -Y 'unset forward-as-attachment' \
5071 -Y 'forward ex1@am.ple;b2' -Y !. \
5072 ./.tmbox >./.tall 2>&1
5073 check 10 0 ./.tall '799103633 1250'
5075 ARGS=${XARGS}
5076 t_epilog "${@}"
5077 } # }}}
5079 t_resend() { # {{{
5080 t_prolog "${@}"
5081 XARGS=${ARGS}
5082 ARGS="${ARGS} -Sv15-compat=y"
5084 t__gen_msg subject fwd1 body origb1 from 1 to 2 > "${MBOX}"
5085 t__gen_msg subject fwd2 body origb2 from 1 to 1 >> "${MBOX}"
5087 ## Base
5088 t_it() {
5089 </dev/null ${MAILX} ${ARGS} -Rf \
5090 -Y ${1}' . "du <ex1@am.ple>"
5091 echo 1:$?/$^ERRNAME; echoerr 1:done
5092 set fullnames escape=!
5093 '${1}' 1 "du , da <ex2@am.ple>"
5094 echo 2:$?/$^ERRNAME; echoerr 2:done
5095 # Some errors
5096 set nofullnames ea=$expandaddr expandaddr=-all
5097 '${1}' ` "du <ex3@am.ple>"
5098 echo 3:$?/$^ERRNAME; echoerr 3:done
5099 set expandaddr=$ea
5100 '${1}' ` ex4-nono@am.ple ex4@am.ple # the first is a non-match msglist
5101 echo 4:$?/$^ERRNAME; echoerr 4:done
5102 '${1}' # TODO not yet possible b5 !.
5103 echo 5:$?/$^ERRNAME; echoerr 5:done
5104 set expandaddr=$ea
5105 '${1}' 1 2 ex6@am.ple
5106 echo 6:$?/$^ERRNAME; echoerr 6:done
5107 #' \
5108 "${MBOX}" > ./.tall 2>./.terr
5109 return ${?}
5112 t_it resend
5113 check 1 0 ./.tall '1461006932 1305'
5114 if have_feat uistrings; then
5115 check 2 - ./.terr '138360532 210'
5116 else
5117 t_echoskip '2:[!UISTRINGS]'
5120 t_it Resend
5121 check 3 0 ./.tall '3674535444 958'
5122 if have_feat uistrings; then
5123 check 4 - ./.terr '138360532 210'
5124 else
5125 t_echoskip '4:[!UISTRINGS]'
5128 ## *record*, *outfolder* (reuses $MBOX)
5129 ${mkdir} .tfolder
5131 t_it() {
5132 </dev/null ${MAILX} ${ARGS} -Rf -Sescape=! -Sfolder=`${pwd}`/.tfolder \
5133 -Y '#
5134 set record=.trec'${2}'; '${1}' 1 ex1@am.ple
5135 echo 1:$?/$^ERRNAME; set record-resent; '${1}' 1 ex2@am.ple
5136 echo 2:$?/$^ERRNAME; set outfolder norecord-resent; '${1}' 2 ex1@am.ple
5137 echo 3:$?/$^ERRNAME; set record-resent; '${1}' 2 ex2@am.ple
5138 echo 4:$?/$^ERRNAME
5139 #' \
5140 "${MBOX}" > ./.tall 2>&1
5141 check_ex0 ${2}
5142 if [ ${#} -ne 3 ]; then
5143 check ${2} - ./.tall '1711347390 992'
5144 check ${3}-1 - ./.trec${2} '2840978700 249'
5145 check ${3}-2 - ./.tfolder/.trec${2} '3219997964 229'
5146 else
5147 check ${2} - ./.tall '1391418931 724'
5148 check ${3}-1 - ./.trec${2} '473817710 182'
5149 check ${3}-2 - ./.tfolder/.trec${2} '2174632404 162'
5153 t_it resend 5 6 yes
5154 t_it Resend 7 8
5156 ARGS=${XARGS}
5157 t_epilog "${@}"
5158 } # }}}
5159 # }}}
5161 # VFS {{{
5162 t_copy() { # {{{
5163 t_prolog "${@}"
5165 t__gen_msg subject Copy1 from 1 to 1 body 'Body1' > "${MBOX}"
5166 t__gen_msg subject Copy2 from 1 to 1 body 'Body2' >> "${MBOX}"
5167 check 1 - "${MBOX}" '137107341 324' # for flag test
5170 </dev/null ${MAILX} ${ARGS} -f \
5171 -Y '#
5172 headers
5173 copy 10 .tf1
5174 echo 0:$?/$^ERRNAME
5175 headers
5176 copy .tf1
5177 echo 1:$?/$^ERRNAME
5178 headers
5179 copy .tf1 # no auto-advance
5180 echo 2:$?/$^ERRNAME
5181 headers
5182 copy 2 .tf2
5183 echo 3:$?/$^ERRNAME
5184 headers
5185 copy 1 2 .tf3
5186 echo 4:$?/$^ERRNAME
5187 headers
5188 !'"${chmod}"' 0444 .tf3
5189 copy 1 2 .tf3
5190 echo 5:$?/$^ERRNAME
5191 #' \
5192 "${MBOX}" > ./.tallx 2>./.terr
5193 check_ex0 2
5195 if have_feat uistrings; then # TODO
5196 ${sed} -e '$bP' -e d -e :P < ./.tallx >> "${ERR}"
5197 ${sed} '$d' < ./.tallx > ./.tall
5198 else
5199 ${mv} ./.tallx ./.tall
5201 if [ -n "${HONOURS_READONLY}" ]; then
5202 n2_1=2-1 cs2_1='1913702840 1121'
5203 n2_4=2-4 cs2_4='3642131968 344'
5204 n2_5=2-5 cs2_5='2617612897 112'
5205 else
5206 n2_1=2-1-nrdonly cs2_1='1962556153 1146'
5207 n2_4=2-4-nrdonly cs2_4='3733058190 688'
5208 n2_5=2-5-nrdonly cs2_5='3989834342 80'
5210 check ${n2_1} - ./.tall "${cs2_1}"
5211 check 2-2 - ./.tf1 '686654461 334'
5212 check 2-3 - ./.tf2 '1931512953 162'
5213 check ${n2_4} - ./.tf3 "${cs2_4}"
5214 if have_feat uistrings; then
5215 check ${n2_5} - ./.terr "${cs2_5}"
5216 else
5217 t_echoskip '2-5:[!UISTRINGS]'
5221 check 3 - "${MBOX}" '1477662071 346'
5224 t_it() {
5225 t__gen_msg subject Copy1 from 1 to 1 body 'Body1' > "${MBOX}"
5226 t__gen_msg subject Copy2 from 1 to 1 body 'Body2' >> "${MBOX}"
5227 t__gen_msg subject Copy3 from ex@am.ple to 1 body 'Body3' >> "${MBOX}"
5228 check ${1} - "${MBOX}" '2667292819 473' # for flag test
5230 </dev/null ${MAILX} ${ARGS} -f \
5231 -Y "${3}"'
5232 '"${2}"'
5233 Copy
5234 echo 1:$?/$^ERRNAME
5235 '"${2}"'
5236 Copy
5237 echo 2:$?/$^ERRNAME
5238 '"${2}"'
5239 Copy 2
5240 echo 3:$?/$^ERRNAME
5241 '"${2}"'
5242 Copy 3
5243 echo 4:$?/$^ERRNAME
5244 '"${2}"'
5245 Copy *
5246 echo 5:$?/$^ERRNAME
5247 '"${2}"'
5248 #' \
5249 "${MBOX}" > ./.tallx 2>&1
5250 return ${?}
5253 t_it 5 headers '#'
5254 check_ex0 5-1
5255 if have_feat uistrings; then # TODO
5256 ${sed} -e '$bP' -e d -e :P < ./.tallx >> "${ERR}"
5257 ${sed} '$d' < ./.tallx > ./.tall
5258 else
5259 ${mv} ./.tallx ./.tall
5261 echo * > ./.tlst
5262 check 5-2 - ./.tlst '1058655452 9'
5263 check 5-3 - ./.tall '1543702808 1617'
5264 check 5-4 - ./from1 '1031912635 999'
5265 check 5-5 - ./ex '2400630246 149'
5266 ${rm} -f ./.tlst ./.tall ./from1 ./ex
5268 ${mkdir} .tfolder
5269 t_it 6 '#' 'set outfolder folder='"`${pwd}`"'/.tfolder'
5270 check_ex0 6-1
5271 if have_feat uistrings; then # TODO
5272 ${sed} -e '$bP' -e d -e :P < ./.tallx >> "${ERR}"
5273 ${sed} '$d' < ./.tallx > ./.tall
5274 else
5275 ${mv} ./.tallx ./.tall
5277 echo * .tfolder/* > ./.tlst
5278 check 6-2 - ./.tlst '1865898363 29'
5279 ${cat} ./.tall >> ${ERR} #check 6-3 - ./.tall # TODO due to folder echoes
5280 check 6-4 - .tfolder/from1 '1031912635 999'
5281 check 6-5 - .tfolder/ex '2400630246 149'
5284 t__x2_msg > ./.tmbox
5286 t_it() {
5287 printf '#
5288 '"${1}"'
5289 echo 1:$?/$^ERRNAME
5290 headerpick save retain cc date from subject to
5291 '"${1}"'
5292 echo 2:$?/$^ERRNAME
5293 unheaderpick save retain *
5294 '"${1}"'
5295 echo 3:$?/$^ERRNAME
5296 headerpick save ignore status in-reply-to
5297 '"${1}"'
5298 echo 4:$?/$^ERRNAME
5299 #' | ${MAILX} ${ARGS} -Rf ./.tmbox > ./.tall 2>&1
5300 return ${?}
5303 t_it 'copy ./.tout'
5304 check_ex0 7-estat
5305 check 7-1 - ./.tall '3805176908 152'
5306 check 7-2 - ./.tout '2447734879 1316'
5308 t_it Copy
5309 check_ex0 8-estat
5310 echo * > ./.tlst
5311 check 8-1 - ./.tall '1044700686 136'
5312 check 8-2 - ./mr2 '2447734879 1316'
5313 check 8-3 - ./.tlst '3190056903 4'
5315 t_epilog "${@}"
5316 } # }}}
5318 t_save() { # {{{
5319 t_prolog "${@}"
5321 t__gen_msg subject Save1 from 1 to 1 body 'Body1' > "${MBOX}"
5322 t__gen_msg subject Save2 from 1 to 1 body 'Body2' >> "${MBOX}"
5323 check 1 - "${MBOX}" '3634443864 324' # for flag test
5326 </dev/null ${MAILX} ${ARGS} -f \
5327 -Y '#
5328 headers
5329 save 10 .tf1
5330 echo 0:$?/$^ERRNAME
5331 headers
5332 save .tf1
5333 echo 1:$?/$^ERRNAME
5334 headers
5335 save .tf1 # no auto-advance
5336 echo 2:$?/$^ERRNAME
5337 headers
5338 save 2 .tf2
5339 echo 3:$?/$^ERRNAME
5340 headers
5341 save 1 2 .tf3
5342 echo 4:$?/$^ERRNAME
5343 headers
5344 !'"${chmod}"' 0444 .tf3
5345 save 1 2 .tf3
5346 echo 5:$?/$^ERRNAME
5347 #' \
5348 "${MBOX}" > ./.tallx 2>./.terr
5349 check_ex0 2
5351 if have_feat uistrings; then # TODO
5352 ${sed} -e '$bP' -e d -e :P < ./.tallx >> "${ERR}"
5353 ${sed} '$d' < ./.tallx > ./.tall
5354 else
5355 ${mv} ./.tallx ./.tall
5357 if [ -n "${HONOURS_READONLY}" ]; then
5358 n2_1=2-1 cs2_1='2335843514 1121'
5359 n2_4=2-4 cs2_4='970407001 344'
5360 n2_5=2-5 cs2_5='45116475 112'
5361 else
5362 n2_1=2-1-nrdonly cs2_1='1736244784 1146'
5363 n2_4=2-4-nrdonly cs2_4='3903872811 688'
5364 n2_5=2-5-nrdonly cs2_5='720724138 80'
5366 check ${n2_1} - ./.tall "${cs2_1}"
5367 check 2-2 - ./.tf1 '2435434321 334'
5368 check 2-3 - ./.tf2 '920652966 162'
5369 check ${n2_4} - ./.tf3 "${cs2_4}"
5370 if have_feat uistrings; then
5371 check ${n2_5} - ./.terr "${cs2_5}"
5372 else
5373 t_echoskip '2-5:[!UISTRINGS]'
5377 check 3 - "${MBOX}" '1219692400 346'
5380 t_it() {
5381 t__gen_msg subject Save1 from 1 to 1 body 'Body1' > "${MBOX}"
5382 t__gen_msg subject Save2 from 1 to 1 body 'Body2' >> "${MBOX}"
5383 t__gen_msg subject Save3 from ex@am.ple to 1 body 'Body3' >> "${MBOX}"
5384 check ${1} - "${MBOX}" '1391391227 473' # for flag test
5386 </dev/null ${MAILX} ${ARGS} -f \
5387 -Y "${3}"'
5388 '"${2}"'
5389 Save
5390 echo 1:$?/$^ERRNAME
5391 '"${2}"'
5392 Save
5393 echo 2:$?/$^ERRNAME
5394 '"${2}"'
5395 Save 2
5396 echo 3:$?/$^ERRNAME
5397 '"${2}"'
5398 Save 3
5399 echo 4:$?/$^ERRNAME
5400 '"${2}"'
5401 Save *
5402 echo 5:$?/$^ERRNAME
5403 '"${2}"'
5404 #' \
5405 "${MBOX}" > ./.tallx 2>&1
5406 return ${?}
5409 t_it 5 headers '#'
5410 check_ex0 5-1
5411 if have_feat uistrings; then # TODO
5412 ${sed} -e '$bP' -e d -e :P < ./.tallx >> "${ERR}"
5413 ${sed} '$d' < ./.tallx > ./.tall
5414 else
5415 ${mv} ./.tallx ./.tall
5417 echo * > ./.tlst
5418 check 5-2 - ./.tlst '1058655452 9'
5419 check 5-3 - ./.tall '3418590770 1617'
5420 check 5-4 - ./from1 '1462882526 999'
5421 check 5-5 - ./ex '2153575326 149'
5422 ${rm} -f ./.tlst ./.tall ./from1 ./ex
5424 ${mkdir} .tfolder
5425 t_it 6 '#' 'set outfolder folder='"`${pwd}`"'/.tfolder'
5426 check_ex0 6-1
5427 if have_feat uistrings; then # TODO
5428 ${sed} -e '$bP' -e d -e :P < ./.tallx >> "${ERR}"
5429 ${sed} '$d' < ./.tallx > ./.tall
5430 else
5431 ${mv} ./.tallx ./.tall
5433 echo * .tfolder/* > ./.tlst
5434 check 6-2 - ./.tlst '1865898363 29'
5435 ${cat} ./.tall >> ${ERR} #check 6-3 - ./.tall # TODO due to folder echoes
5436 check 6-4 - .tfolder/from1 '1462882526 999'
5437 check 6-5 - .tfolder/ex '2153575326 149'
5441 t_it() {
5442 t__x2_msg > ./.tmbox
5443 check ${1} - ./.tmbox '561523988 397'
5445 a='-Rf'
5446 [ ${#} -gt 2 ] && a='-S MBOX=./.tmboxx'
5447 [ ${#} -gt 3 ] && a="${a}"' -S inbox=./.tmbox'
5448 printf '#
5449 headers
5450 '"${2}"'
5451 echo 1:$?/$^ERRNAME
5452 headers
5453 headerpick save retain cc date from subject to
5454 '"${2}"'
5455 echo 2:$?/$^ERRNAME
5456 unheaderpick save retain *
5457 '"${2}"'
5458 echo 3:$?/$^ERRNAME
5459 headerpick save ignore status in-reply-to
5460 '"${2}"'
5461 echo 4:$?/$^ERRNAME
5462 #' | ${MAILX} ${ARGS} -f ${a} ./.tmbox > ./.tall 2>&1
5463 return ${?}
5466 t_it 7 'save ./.tout'
5467 check_ex0 7-estat
5468 check 7-1 - ./.tall '4190949581 312'
5469 check 7-2 - ./.tout '2447734879 1316'
5470 check 7-3 - ./.tmbox '561523988 397'
5472 t_it 8 Save
5473 check_ex0 8-estat
5474 echo * > ./.tlst
5475 check 8-1 - ./.tall '2109832180 296'
5476 check 8-2 - ./mr2 '2447734879 1316'
5477 check 8-3 - ./.tlst '3190056903 4'
5478 check 8-3 - ./.tmbox '561523988 397'
5480 # saves in $MBOX without argument
5481 t_it 9 save yes
5482 check_ex0 9-estat
5483 check 9-1 - ./.tall '652005824 320'
5484 check 9-2 - ./.tmboxx '2447734879 1316'
5485 check 9-3 - ./.tmbox '561523988 397'
5487 # and deletes if editing a primary mailbox
5488 ${rm} -f ./.tmboxx
5489 t_it 10 save yes yes
5490 check_ex0 10-estat
5491 check 10-1 - ./.tall '652005824 320'
5492 check 10-2 - ./.tmboxx '2447734879 1316'
5493 [ -f ./.tmbox ]; check_exn0 10-3
5495 t_epilog "${@}"
5496 } # }}}
5498 t_move() { # {{{
5499 t_prolog "${@}"
5501 t__gen_msg subject Move1 from 1 to 1 body 'Body1' > "${MBOX}"
5502 t__gen_msg subject Move2 from 1 to 1 body 'Body2' >> "${MBOX}"
5503 check 1 - "${MBOX}" '2967134193 324' # for flag test
5506 </dev/null ${MAILX} ${ARGS} -f \
5507 -Y '#
5508 headers
5509 move 10 .tf1
5510 echo 0:$?/$^ERRNAME
5511 headers
5512 move .tf1
5513 echo 1:$?/$^ERRNAME
5514 headers
5515 !touch .tf2; '"${chmod}"' 0444 .tf2
5516 move 2 .tf2
5517 echo 2:$?/$^ERRNAME
5518 !'"${chmod}"' 0644 .tf2
5519 move 2 .tf2
5520 echo 3:$?/$^ERRNAME
5521 headers
5522 #' \
5523 "${MBOX}" > ./.tallx 2>./.terr
5524 check_ex0 2
5526 if have_feat uistrings; then # TODO
5527 ${sed} -e '$bP' -e d -e :P < ./.tallx >> "${ERR}"
5528 ${sed} '$d' < ./.tallx > ./.tall
5529 else
5530 ${mv} ./.tallx ./.tall
5532 if [ -n "${HONOURS_READONLY}" ]; then
5533 n2_1=2-1 cs2_1='1641443074 491'
5534 n2_4=2-4 cs2_4='602144474 155'
5535 else
5536 n2_1=2-1-nrdonly cs2_1='3045412111 492'
5537 n2_4=2-4-nrdonly cs2_4='2197157669 201'
5539 check ${n2_1} - ./.tall "${cs2_1}"
5540 check 2-2 - ./.tf1 '1473857906 162'
5541 check 2-3 - ./.tf2 '331229810 162'
5542 if have_feat uistrings; then
5543 check ${n2_4} - ./.terr "${cs2_4}"
5544 else
5545 t_echoskip '2-4:[!UISTRINGS]'
5549 check 3 - "${MBOX}" '4294967295 0'
5552 t_it() {
5553 t__gen_msg subject Move1 from 1 to 1 body 'Body1' > "${MBOX}"
5554 t__gen_msg subject Move2 from 1 to 1 body 'Body2' >> "${MBOX}"
5555 t__gen_msg subject Move3 from ex@am.ple to 1 body 'Body3' >> "${MBOX}"
5556 check ${1} - "${MBOX}" '2826896131 473' # for flag test
5558 </dev/null ${MAILX} ${ARGS} -f \
5559 -Y "${3}"'
5560 '"${2}"'
5561 Move
5562 echo 1:$?/$^ERRNAME
5563 '"${2}"'
5564 Move 2
5565 echo 2:$?/$^ERRNAME
5566 '"${2}"'
5567 Move 3
5568 echo 3:$?/$^ERRNAME
5569 '"${2}"'
5570 undelete *
5571 echo 4:$?/$^ERRNAME
5572 '"${2}"'
5573 Move *
5574 echo 5:$?/$^ERRNAME
5575 '"${2}"'
5576 #' \
5577 "${MBOX}" > ./.tallx 2>./.terr
5578 return ${?}
5581 t_it 5 headers '#'
5582 check_ex0 5-1
5583 if have_feat uistrings; then # TODO
5584 ${sed} -e '$bP' -e d -e :P < ./.tallx >> "${ERR}"
5585 ${sed} '$d' < ./.tallx > ./.tall
5586 else
5587 ${mv} ./.tallx ./.tall
5589 echo * > ./.tlst
5590 check 5-2 - ./.tlst '1058655452 9'
5591 check 5-3 - ./.tall '419037676 870'
5592 if have_feat uistrings; then
5593 check 5-4 - ./.terr '1383646464 86'
5594 else
5595 t_echoskip '5-4:[!UISTRINGS]'
5597 check 5-5 - ./from1 '3719268580 827'
5598 check 5-6 - ./ex '4262925856 149'
5599 ${rm} -f ./.tlst ./.tall ./.terr ./from1 ./ex
5601 ${mkdir} .tfolder
5602 t_it 6 '#' 'set outfolder folder='"`${pwd}`"'/.tfolder'
5603 check_ex0 6-1
5604 if have_feat uistrings; then # TODO
5605 ${sed} -e '$bP' -e d -e :P < ./.tallx >> "${ERR}"
5606 ${sed} '$d' < ./.tallx > ./.tall
5607 else
5608 ${mv} ./.tallx ./.tall
5610 echo * .tfolder/* > ./.tlst
5611 check 6-2 - ./.tlst '1865898363 29'
5612 ${cat} ./.tall >> ${ERR} #check 6-3 - ./.tall # TODO due to folder echoes
5613 check 6-4 - .tfolder/from1 '3719268580 827'
5614 check 6-5 - .tfolder/ex '4262925856 149'
5617 t__x2_msg > ./.tmbox
5619 t_it() {
5620 printf '#
5621 '"${1}"'
5622 echo 1:$?/$^ERRNAME
5623 headerpick save retain cc date from subject to
5624 '"${1}"'
5625 echo 2:$?/$^ERRNAME
5626 unheaderpick save retain *
5627 '"${1}"'
5628 echo 3:$?/$^ERRNAME
5629 headerpick save ignore status in-reply-to
5630 '"${1}"'
5631 echo 4:$?/$^ERRNAME
5632 #' | ${MAILX} ${ARGS} -Rf ./.tmbox > ./.tall 2>&1
5633 return ${?}
5636 t_it 'move ./.tout'
5637 check_ex0 7-estat
5638 check 7-1 - ./.tall '3805176908 152'
5639 check 7-2 - ./.tout '2447734879 1316'
5641 t_it Move
5642 check_ex0 8-estat
5643 echo * > ./.tlst
5644 check 8-1 - ./.tall '1044700686 136'
5645 check 8-2 - ./mr2 '2447734879 1316'
5646 check 8-3 - ./.tlst '3190056903 4'
5648 t_epilog "${@}"
5649 } # }}}
5651 t_mbox() { # {{{
5652 t_prolog "${@}"
5656 while [ ${i} -lt 113 ]; do
5657 printf 'm file://%s\n~s Subject %s\nHello %s!\n~.\n' \
5658 "${MBOX}" "${i}" "${i}"
5659 i=`add ${i} 1`
5660 done
5661 ) | ${MAILX} ${ARGS} > .tall 2>&1
5662 check 1 0 "${MBOX}" '1785801373 13336'
5663 check 1-outerr - ./.tall '4294967295 0' # empty file
5665 printf 'File "%s"\ncopy * "%s"\nFile "%s"\nfrom*' "${MBOX}" .tmbox1 .tmbox1 |
5666 ${MAILX} ${ARGS} -Sshowlast > .tall 2>&1
5667 check 2 0 .tall '3467540956 8991'
5669 printf 'File "%s"\ncopy * "file://%s"\nFile "file://%s"\nfrom*' \
5670 "${MBOX}" .tmbox2 .tmbox2 | ${MAILX} ${ARGS} -Sshowlast > .tall 2>&1
5671 check 3 0 .tall '2410946529 8998'
5673 # copy only the odd (but the first), move the even
5675 printf 'File "file://%s"\ncopy ' .tmbox2
5677 while [ ${i} -lt 113 ]; do
5678 printf '%s ' "${i}"
5679 i=`add ${i} 2`
5680 done
5681 printf 'file://%s\nFile "file://%s"\nfrom*' .tmbox3 .tmbox3
5682 ) | ${MAILX} ${ARGS} -Sshowlast > .tall 2>&1
5683 check 4 0 .tmbox3 '2554734733 6666'
5684 check 5 - .tall '2062382804 4517'
5685 # ...
5687 printf 'file "file://%s"\nmove ' .tmbox2
5689 while [ ${i} -lt 113 ]; do
5690 printf '%s ' "${i}"
5691 i=`add ${i} 2`
5692 done
5693 printf 'file://%s\nFile "file://%s"\nfrom*\nFile "file://%s"\nfrom*' \
5694 .tmbox3 .tmbox3 .tmbox2
5695 ) | ${MAILX} ${ARGS} -Sshowlast > .tall 2>>${ERR}
5696 check 6 0 .tmbox3 '1429216753 13336'
5697 if have_feat uistrings; then
5698 ${sed} 2d < .tall > .tallx
5699 else
5700 ${cp} .tall .tallx
5702 check 7 - .tallx '169518319 13477'
5704 # Invalid MBOXes (after [f4db93b3])
5705 echo > .tinvmbox
5706 printf 'copy 1 ./.tinvmbox' | ${MAILX} ${ARGS} -Rf "${MBOX}" > .tall 2>&1
5707 check 8 0 .tinvmbox '2848412822 118'
5708 check 9 - ./.tall '461280182 33'
5710 echo ' ' > .tinvmbox
5711 printf 'copy 1 ./.tinvmbox' | ${MAILX} ${ARGS} -Rf "${MBOX}" > .tall 2>&1
5712 check 10 0 .tinvmbox '624770486 120'
5713 check 11 - ./.tall '461280182 33'
5715 { echo; echo; } > .tinvmbox # (not invalid)
5716 printf 'copy 1 ./.tinvmbox' | ${MAILX} ${ARGS} -Rf "${MBOX}" > .tall 2>&1
5717 check 12 0 .tinvmbox '1485640875 119'
5718 check 13 - ./.tall '461280182 33'
5720 # *mbox-rfc4155*, plus
5721 ${cat} <<-_EOT > ./.tinv1
5724 From MAILER-DAEMON-1 Wed Oct 2 01:50:07 1996
5725 Date: Wed, 02 Oct 1996 01:50:07 +0000
5727 Subject: Bad bad message 1
5729 From me to you, blinde Kuh!
5731 From MAILER-DAEMON-2 Wed Oct 2 01:50:07 1996
5732 Date: Wed, 02 Oct 1996 01:50:07 +0000
5734 Subject: Bad bad message 2
5736 From me to you, blindes Kalb!
5737 _EOT
5738 ${cp} ./.tinv1 ./.tinv2
5740 printf \
5741 'define mboxfix {
5742 \\localopts yes; \\wysh set mbox-rfc4155;\\wysh File "${1}";\\
5743 \\eval copy * "${2}"
5745 call mboxfix ./.tinv1 ./.tok' | ${MAILX} ${ARGS} > .tall 2>&1
5746 check_ex0 14-estat
5747 ${cat} ./.tinv1 ./.tok >> .tall
5748 check 14 - ./.tall '739301109 616'
5750 printf \
5751 'wysh file ./.tinv1 # ^From not repaired, but missing trailing NL is
5752 wysh File ./.tok # Just move away to nowhere
5753 set mbox-rfc4155
5754 wysh file ./.tinv2 # Fully repaired
5755 File ./.tok' | ${MAILX} ${ARGS} >>${ERR} 2>&1
5756 check_ex0 15-estat
5757 # Equal since [Auto-fix when MBOX had From_ errors on read (Dr. Werner
5758 # Fink).]
5759 check 15-1 - ./.tinv1 '4151504442 314'
5760 check 15-2 - ./.tinv2 '4151504442 314'
5762 # *mbox-fcc-and-pcc*
5763 ${cat} > ./.ttmpl <<-'_EOT'
5764 Fcc: ./.tfcc1
5765 Bcc: | cat >> ./.tpcc1
5766 Fcc: ./.tfcc2
5767 Subject: fcc and pcc, and *mbox-fcc-and-pcc*
5769 one line body
5770 _EOT
5772 < ./.ttmpl ${MAILX} ${ARGS} -t > "${MBOX}" 2>&1
5773 check 16 0 "${MBOX}" '4294967295 0'
5774 check 17 - ./.tfcc1 '2301294938 148'
5775 check 18 - ./.tfcc2 '2301294938 148'
5776 check 19 - ./.tpcc1 '2301294938 148'
5778 < ./.ttmpl ${MAILX} ${ARGS} -t -Snombox-fcc-and-pcc > "${MBOX}" 2>&1
5779 check 20 0 "${MBOX}" '4294967295 0'
5780 check 21 - ./.tfcc1 '3629108107 98'
5781 check 22 - ./.tfcc2 '3629108107 98'
5782 check 23 - ./.tpcc1 '2373220256 246'
5784 # More invalid: since in "copy * X" messages will be copied in `sort' order,
5785 # reordering may happen, and before ([f5db11fe] (a_cwrite_save1(): FIX:
5786 # ensure pre-v15 MBOX separation "in between" messages.., 2019-08-07) that
5787 # could still have created invalid MBOX files!
5788 ${cat} <<-_EOT > ./.tinv1
5791 From MAILER-DAEMON-4 Sun Oct 4 01:50:07 1998
5792 Date: Sun, 04 Oct 1998 01:50:07 +0000
5793 Subject: h4
5797 From MAILER-DAEMON-0 Fri Oct 28 21:02:21 2147483649
5798 Date: Nix, 01 Oct BAD 01:50:07 +0000
5799 Subject: hinvalid
5801 BINV
5803 From MAILER-DAEMON-3 Fri Oct 3 01:50:07 1997
5804 Date: Fri, 03 Oct 1997 01:50:07 +0000
5805 Subject: h3
5809 From MAILER-DAEMON-1 Sun Oct 1 01:50:07 1995
5810 Date: Sun, 01 Oct 1995 01:50:07 +0000
5811 Subject:h1
5816 From MAILER-DAEMON-2 Wed Oct 2 01:50:07 1996
5817 Date: Wed, 02 Oct 1996 01:50:07 +0000
5818 Subject: h2
5821 _EOT
5823 printf \
5824 'File ./.tinv1
5825 sort date
5826 remove ./.tinv2
5827 copy * ./.tinv2
5828 file ./.tinv1' | ${MAILX} ${ARGS} >>${ERR} 2>&1
5829 check 24 0 ./.tinv1 '104184185 560'
5830 check 25 - ./.tinv2 '853754737 510'
5832 t_epilog "${@}"
5833 } # }}}
5835 t_maildir() { # {{{
5836 t_prolog "${@}"
5838 if have_feat maildir; then :; else
5839 t_echoskip '[!MAILDIR]'
5840 t_epilog "${@}"
5841 return
5846 while [ ${i} -lt 112 ]; do
5847 printf 'm file://%s\n~s Subject %s\nHello %s!\n~.\n' \
5848 "${MBOX}" "${i}" "${i}"
5849 i=`add ${i} 1`
5850 done
5851 ) | ${MAILX} ${ARGS}
5852 check 1 0 "${MBOX}" '2366902811 13332'
5854 printf 'File "%s"
5855 copy * "%s"
5856 File "%s"
5857 from*
5858 ' "${MBOX}" .tmdir1 .tmdir1 |
5859 ${MAILX} ${ARGS} -Snewfolders=maildir -Sshowlast > .tlst
5860 check 2 0 .tlst '3442251309 8991'
5862 printf 'File "%s"
5863 copy * "maildir://%s"
5864 File "maildir://%s"
5865 from*
5866 ' "${MBOX}" .tmdir2 .tmdir2 |
5867 ${MAILX} ${ARGS} -Sshowlast > .tlst
5868 check 3 0 .tlst '3524806062 9001'
5870 printf 'File "maildir://%s"
5871 copy * "file://%s"
5872 File "file://%s"
5873 from*
5874 ' .tmdir2 .tmbox1 .tmbox1 |
5875 ${MAILX} ${ARGS} -Sshowlast > .tlst
5876 check 4 0 .tmbox1 '4096198846 12772'
5877 check 5 - .tlst '1262452287 8998'
5879 # only the odd (even)
5881 printf 'File "maildir://%s"
5882 copy ' .tmdir2
5884 while [ ${i} -lt 112 ]; do
5885 j=`modulo ${i} 2`
5886 [ ${j} -eq 1 ] && printf '%s ' "${i}"
5887 i=`add ${i} 1`
5888 done
5889 printf ' file://%s
5890 File "file://%s"
5891 from*
5892 ' .tmbox2 .tmbox2
5893 ) | ${MAILX} ${ARGS} -Sshowlast > .tlst
5894 check 6 0 .tmbox2 '4228337024 6386'
5895 check 7 - .tlst '2078821439 4517'
5896 # ...
5898 printf 'file "maildir://%s"
5899 move ' .tmdir2
5901 while [ ${i} -lt 112 ]; do
5902 j=`modulo ${i} 2`
5903 [ ${j} -eq 0 ] && [ ${i} -ne 0 ] && printf '%s ' "${i}"
5904 i=`add ${i} 1`
5905 done
5906 printf ' file://%s
5907 File "file://%s"
5908 from*
5909 File "maildir://%s"
5910 from*
5911 ' .tmbox2 .tmbox2 .tmdir2
5912 ) | ${MAILX} ${ARGS} -Sshowlast > .tlst
5913 check 8 0 .tmbox2 '978751761 12656'
5914 ${sed} 2d < .tlst > .tlstx
5915 check 9 - .tlstx '2172297531 13477'
5917 # More invalid: since in "copy * X" messages will be copied in `sort' order,
5918 # reordering may happen, and before ([f5db11fe] (a_cwrite_save1(): FIX:
5919 # ensure pre-v15 MBOX separation "in between" messages.., 2019-08-07) that
5920 # could still have created invalid MBOX files!
5921 ${cat} <<-_EOT > ./.tinv1
5924 From MAILER-DAEMON-4 Sun Oct 4 01:50:07 1998
5925 Date: Sun, 04 Oct 1998 01:50:07 +0000
5926 Subject: h4
5930 From MAILER-DAEMON-0 Fri Oct 28 21:02:21 2147483649
5931 Date: Nix, 01 Oct BAD 01:50:07 +0000
5932 Subject: hinvalid
5934 BINV
5936 From MAILER-DAEMON-3 Fri Oct 3 01:50:07 1997
5937 Date: Fri, 03 Oct 1997 01:50:07 +0000
5938 Subject: h3
5942 From MAILER-DAEMON-1 Sun Oct 1 01:50:07 1995
5943 Date: Sun, 01 Oct 1995 01:50:07 +0000
5944 Subject:h1
5949 From MAILER-DAEMON-2 Wed Oct 2 01:50:07 1996
5950 Date: Wed, 02 Oct 1996 01:50:07 +0000
5951 Subject: h2
5954 _EOT
5956 printf \
5957 'File ./.tinv1
5958 sort date
5959 copy * maildir://./.tmdir10
5960 !{ for f in ./.tmdir10/new/*; do echo ===; %s $f; done; } > ./.t11
5961 File ./.tmdir10
5962 sort date
5963 copy * ./.t10warp
5964 ' "${cat}" | ${MAILX} ${ARGS} >>${ERR} 2>&1
5965 # Note that substdate() fixes all but one From_ line to $SOURCE_DATE_EPOCH!
5966 check 10 0 ./.t10warp '3551111321 502'
5967 check 11 - ./.t11 '642719592 302'
5969 t_epilog "${@}"
5970 } # }}}
5971 # }}}
5973 # MIME and RFC basics {{{
5974 t_mime_if_not_ascii() {
5975 t_prolog "${@}"
5977 </dev/null ${MAILX} ${ARGS} -s Subject "${MBOX}" >> "${MBOX}" 2>&1
5978 check 1 0 "${MBOX}" '3647956381 106'
5980 </dev/null ${MAILX} ${ARGS} -Scharset-7bit=not-ascii -s Subject "${MBOX}" \
5981 >> "${MBOX}" 2>&1
5982 check 2 0 "${MBOX}" '3964303752 274'
5984 t_epilog "${@}"
5987 t_mime_encoding() {
5988 t_prolog "${@}"
5990 # 8B
5991 printf 'Hey, you.\nFrom me to you\nCiao\n' |
5992 ${MAILX} ${ARGS} -s Subject -Smime-encoding=8b "${MBOX}" \
5993 >> "${MBOX}" 2>&1
5994 check 1 0 "${MBOX}" '3835153597 136'
5995 printf 'Hey, you.\n\nFrom me to you\nCiao.\n' |
5996 ${MAILX} ${ARGS} -s Subject -Smime-encoding=8b "${MBOX}" \
5997 >> "${MBOX}" 2>&1
5998 check 2 0 "${MBOX}" '63875210 275'
6000 # QP
6001 printf 'Hey, you.\n From me to you\nCiao\n' |
6002 ${MAILX} ${ARGS} -s Subject -Smime-encoding=qp "${MBOX}" \
6003 >> "${MBOX}" 2>&1
6004 check 3 0 "${MBOX}" '465798521 412'
6005 printf 'Hey, you.\nFrom me to you\nCiao\n' |
6006 ${MAILX} ${ARGS} -s Subject -Smime-encoding=qp "${MBOX}" \
6007 >> "${MBOX}" 2>&1
6008 check 4 0 "${MBOX}" '2075263697 655'
6010 # B64
6011 printf 'Hey, you.\n From me to you\nCiao\n' |
6012 ${MAILX} ${ARGS} -s Subject -Smime-encoding=b64 "${MBOX}" \
6013 >> "${MBOX}" 2>&1
6014 check 5 0 "${MBOX}" '601672771 792'
6015 printf 'Hey, you.\nFrom me to you\nCiao\n' |
6016 ${MAILX} ${ARGS} -s Subject -Smime-encoding=b64 "${MBOX}" \
6017 >> "${MBOX}" 2>&1
6018 check 6 0 "${MBOX}" '3926760595 1034'
6020 t_epilog "${@}"
6023 t_xxxheads_rfc2047() {
6024 t_prolog "${@}"
6026 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
6027 -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̲' \
6028 "${MBOX}"
6029 check 1 0 "${MBOX}" '3422562347 371'
6031 # Single word (overlong line split -- bad standard! Requires injection of
6032 # artificial data!! But can be prevented by using RFC 2047 encoding)
6033 ${rm} "${MBOX}"
6034 i=`${awk} 'BEGIN{for(i=0; i<92; ++i) printf "0123456789_"}'`
6035 echo | ${MAILX} ${ARGS} -s "${i}" "${MBOX}"
6036 check 2 0 "${MBOX}" '3317256266 1714'
6038 # Combination of encoded words, space and tabs of varying sort
6039 ${rm} "${MBOX}"
6040 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
6041 -s "1Abrä Kaspas1 2Abra Katä b_kaspas2 \
6042 3Abrä Kaspas3 4Abrä Kaspas4 5Abrä Kaspas5 \
6043 6Abra Kaspas6 7Abrä Kaspas7 8Abra Kaspas8 \
6044 9Abra Kaspastäb4-3 10Abra Kaspas1 _ 11Abra Katäb1 \
6045 12Abra Kadabrä1 After Tab after Täb this is NUTS" \
6046 "${MBOX}"
6047 check 3 0 "${MBOX}" '786672837 587'
6049 # Overlong multibyte sequence that must be forcefully split
6050 # todo This works even before v15.0, but only by accident
6051 ${rm} "${MBOX}"
6052 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
6053 -s "✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
6054 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
6055 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄" \
6056 "${MBOX}"
6057 check 4 0 "${MBOX}" '2889557767 655'
6059 # Trailing WS
6060 ${rm} "${MBOX}"
6061 echo | ${MAILX} ${ARGS} \
6062 -s "1-1 B2 B3 B4 B5 B6 B\
6063 1-2 B2 B3 B4 B5 B6 B\
6064 1-3 B2 B3 B4 B5 B6 B\
6065 1-4 B2 B3 B4 B5 B6 B\
6066 1-5 B2 B3 B4 B5 B6 B\
6067 1-6 B2 B3 B4 B5 B6 " \
6068 "${MBOX}"
6069 check 5 0 "${MBOX}" '3135161683 293'
6071 # Leading and trailing WS
6072 ${rm} "${MBOX}"
6073 echo | ${MAILX} ${ARGS} \
6074 -s " 2-1 B2 B3 B4 B5 B6 B\
6075 1-2 B2 B3 B4 B5 B6 B\
6076 1-3 B2 B3 B4 B5 B6 B\
6077 1-4 B2 B3 B4 B5 B6 " \
6078 "${MBOX}"
6079 check 6 0 "${MBOX}" '3221845405 232'
6081 # RFC 2047 in an address field! (Missing test caused v14.9.6!)
6082 ${rm} "${MBOX}"
6083 echo "Dat Früchtchen riecht häußlich" |
6084 ${MAILX} ${ARGS} ${ADDARG_UNI} -Sfullnames -Smta=test://"$MBOX" \
6085 -s Hühöttchen \
6086 'Schnödes "Früchtchen" <do@du> (Hä!)'
6087 check 7 0 "${MBOX}" '3681801246 373'
6089 # RFC 2047 in an address field, and iconv involved
6090 if have_feat iconv; then
6091 ${rm} "${MBOX}"
6092 ${cat} > ./.trebox <<_EOT
6093 From zaza@exam.ple Fri Mar 2 21:31:56 2018
6094 Date: Fri, 2 Mar 2018 20:31:45 +0000
6095 From: z=?iso-8859-1?Q?=E1?=za <zaza@exam.ple>
6096 To: dude <dude@exam.ple>
6097 Subject: houston(...)
6098 Message-ID: <abra@1>
6099 MIME-Version: 1.0
6100 Content-Type: text/plain; charset=iso-8859-1
6101 Content-Disposition: inline
6102 Content-Transfer-Encoding: 8bit
6104 _EOT
6105 echo reply | ${MAILX} ${ARGS} ${ADDARG_UNI} \
6106 -Sfullnames -Sreply-in-same-charset \
6107 -Smta=test://"$MBOX" -Rf ./.trebox
6108 check 8 0 "${MBOX}" '3499372945 285'
6109 else
6110 t_echoskip '8:[!ICONV]'
6113 t_epilog "${@}"
6116 t_iconv_mbyte_base64() { # TODO uses sed(1) and special *headline*!!
6117 t_prolog "${@}"
6119 if [ -n "${UTF8_LOCALE}" ] && have_feat multibyte-charsets &&
6120 have_feat iconv; then
6121 if (</dev/null iconv -f ascii -t iso-2022-jp) >/dev/null 2>&1 ||
6122 (</dev/null iconv -f ascii -t euc-jp) >/dev/null 2>&1; then
6124 else
6125 t_echoskip '[ICONV/iconv(1):missing conversion(s)]'
6126 t_epilog "${@}"
6127 return
6129 else
6130 t_echoskip '[no UTF-8 locale or !MULTIBYTE-CHARSETS or !ICONV]'
6131 t_epilog "${@}"
6132 return
6135 if (</dev/null iconv -f ascii -t iso-2022-jp) >/dev/null 2>&1; then
6136 ${cat} <<-'_EOT' | LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} \
6137 -Smta=test://"$MBOX" \
6138 -Sescape=! -Smime-encoding=base64 2>./.terr
6139 set ttycharset=utf-8 sendcharsets=iso-2022-jp
6140 m t1@exam.ple
6141 !s Japanese from UTF-8 to ISO-2022-JP
6142 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
6144 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
6147 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
6149 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
6152 set ttycharset=iso-2022-jp charset-7bit=iso-2022-jp sendcharsets=utf-8
6153 m t2@exam.ple
6154 !s Japanese from ISO-2022-JP to UTF-8, eh, no, also ISO-2022-JP
6155 \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
6157 \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
6160 \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
6162 \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
6164 _EOT
6165 # May not presume iconv output as long as roundtrip possible [489a7122]
6166 check_ex0 1-estat
6167 ${awk} 'BEGIN{h=1}/^$/{++h;next}{if(h % 2 == 1)print}' \
6168 < "${MBOX}" > ./.tcksum
6169 check 1 - ./.tcksum '3314001564 516'
6170 check 2 - ./.terr '4294967295 0'
6172 printf 'eval f 1; eval write ./.twrite; eval type 1; eval type 2\n' |
6173 LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} \
6174 -S headline="%>%a%m %-18f %-16d %i%-s" \
6175 -Rf "${MBOX}" >./.tlog 2>&1
6176 check 3 0 ./.twrite '1259742080 686'
6177 #check 4 - ./.tlog '3214068822 2123'
6178 ${sed} -e '/^\[-- M/d' < ./.tlog > ./.txlog
6179 check 4 - ./.txlog '4083300132 2030'
6180 else
6181 t_echoskip '1-4:[ICONV/iconv(1):ISO-2022-JP unsupported]'
6184 if (</dev/null iconv -f ascii -t euc-jp) >/dev/null 2>&1; then
6185 ${rm} -f "${MBOX}" ./.twrite
6186 ${cat} <<-'_EOT' | LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} \
6187 -Smta=test://"$MBOX" \
6188 -Sescape=! -Smime-encoding=base64 2>./.terr
6189 set ttycharset=utf-8 sendcharsets=euc-jp
6190 m t1@exam.ple
6191 !s Japanese from UTF-8 to EUC-JP
6192 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
6194 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
6197 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
6199 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
6202 set ttycharset=EUC-JP sendcharsets=utf-8
6203 m t2@exam.ple
6204 !s Japanese from EUC-JP to UTF-8
6205 ¥·¥¸¥å¥¦¥«¥é²Ê¡Ê¥·¥¸¥å¥¦¥«¥é¤«¡¢³Ø̾ Paridae¡Ë¤Ï¡¢Ä»Îॹ¥º¥áÌܤβʤǤ¢¤ë¡£¥·¥¸¥å¥¦¥«¥é¡Ê»Í½½¿ý¡Ë¤ÈÁí¾Î¤µ¤ì¤ë¤¬¡¢¶¹µÁ¤Ë¤Ï¤³¤Î1¼ï¤ò¥·¥¸¥å¥¦¥«¥é¤È¸Æ¤Ö¡£
6207 ¥«¥ó¥à¥ê¥¬¥é¡Ê³Ø̾Parus cristatus¡Ë¤Ï¡¢¥¹¥º¥áÌÜ¥·¥¸¥å¥¦¥«¥é²Ê¤ËʬÎव¤ì¤ëÄ»Îà¤Î°ì¼ï¡£
6210 ¥«¥ó¥à¥ê¥¬¥é¡Ê³Ø̾Parus cristatus¡Ë¤Ï¡¢¥¹¥º¥áÌÜ¥·¥¸¥å¥¦¥«¥é²Ê¤ËʬÎव¤ì¤ëÄ»Îà¤Î°ì¼ï¡£
6212 ¥·¥¸¥å¥¦¥«¥é²Ê¡Ê¥·¥¸¥å¥¦¥«¥é¤«¡¢³Ø̾ Paridae¡Ë¤Ï¡¢Ä»Îॹ¥º¥áÌܤβʤǤ¢¤ë¡£¥·¥¸¥å¥¦¥«¥é¡Ê»Í½½¿ý¡Ë¤ÈÁí¾Î¤µ¤ì¤ë¤¬¡¢¶¹µÁ¤Ë¤Ï¤³¤Î1¼ï¤ò¥·¥¸¥å¥¦¥«¥é¤È¸Æ¤Ö¡£
6214 _EOT
6215 check_ex0 5-estat
6216 ${awk} 'BEGIN{h=1}/^$/{++h;next}{if(h % 2 == 1)print}' \
6217 < "${MBOX}" > ./.tcksum
6218 check 5 - ./.tcksum '1754179361 469'
6219 check 6 - ./.terr '4294967295 0'
6221 printf 'eval f 1; eval write ./.twrite; eval type 1; eval type 2\n' |
6222 LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} \
6223 -S headline="%>%a%m %-18f %-16d %i%-s" \
6224 -Rf "${MBOX}" >./.tlog 2>&1
6225 check 7 0 ./.twrite '1259742080 686'
6226 #check 8 - ./.tlog '2506063395 2075'
6227 ${sed} -e '/^\[-- M/d' < ./.tlog > ./.txlog
6228 check 8 - ./.txlog '3192017734 1983'
6229 else
6230 t_echoskip '5-8:[ICONV/iconv(1):EUC-JP unsupported]'
6233 t_epilog "${@}"
6236 t_iconv_mainbody() {
6237 t_prolog "${@}"
6239 if [ -n "${UTF8_LOCALE}" ] && have_feat iconv; then :; else
6240 t_echoskip '[no UTF-8 locale or !ICONV]'
6241 t_epilog "${@}"
6242 return
6245 printf '–' | ${MAILX} ${ARGS} ${ADDARG_UNI} -Smta=test://"$MBOX" \
6246 -S charset-7bit=us-ascii -S charset-8bit=utf-8 \
6247 -s '–' over-the@rain.bow 2>./.terr
6248 check 1 0 "${MBOX}" '3559538297 250'
6249 check 2 - ./.terr '4294967295 0'
6251 printf '–' | ${MAILX} ${ARGS} ${ADDARG_UNI} -Smta=test://"$MBOX" \
6252 -S charset-7bit=us-ascii -S charset-8bit=us-ascii \
6253 -s '–' over-the@rain.bow 2>./.terr
6254 check_exn0 3
6255 check 3 - "${MBOX}" '3559538297 250'
6256 if have_feat uistrings; then
6257 check 4 - ./.terr '271380835 121'
6258 else
6259 t_echoskip '4:[!UISTRINGS]'
6262 # The different iconv(3) implementations use different replacement sequence
6263 # types (character-wise, byte-wise, and the character(s) used differ)
6264 i="${MAILX_ICONV_MODE}"
6265 if [ -n "${i}" ]; then
6266 printf 'p\nx\n' | ${MAILX} ${ARGS} -Rf "${MBOX}" >./.tout 2>./.terr
6267 j=${?}
6268 check_ex0 5-1-estat ${j}
6269 check 5-1 - ./.terr '4294967295 0'
6270 if [ ${i} -eq 13 ]; then
6271 check 5-2 - ./.tout '189327996 283' # XXX old (before test MTA)
6272 elif [ ${i} -eq 12 ]; then
6273 check 5-3 - ./.tout '1959197095 283' # XXX old (before test MTA)
6274 elif [ ${i} -eq 3 ]; then
6275 check 5-4 - ./.tout '3544755786 278'
6276 else
6277 check 5-5 - ./.tout '2381160335 278'
6279 else
6280 t_echoskip '5:[test unsupported]'
6283 t_epilog "${@}"
6286 t_binary_mainbody() {
6287 t_prolog "${@}"
6289 printf 'abra\0\nka\r\ndabra' |
6290 ${MAILX} ${ARGS} ${ADDARG_UNI} -s 'binary with carriage-return!' \
6291 "${MBOX}" 2>./.terr
6292 check 1 0 "${MBOX}" '1629827 239'
6293 check 2 - ./.terr '4294967295 0'
6295 printf 'p\necho\necho writing now\nwrite ./.twrite\n' |
6296 ${MAILX} ${ARGS} -Rf \
6297 -Spipe-application/octet-stream="?* ${cat} > ./.tcat" \
6298 "${MBOX}" >./.tall 2>&1
6299 check 3 0 ./.tall '733582513 319'
6300 check 4 - ./.tcat '3817108933 15'
6301 check 5 - ./.twrite '3817108933 15'
6303 t_epilog "${@}"
6306 t_mime_force_sendout() {
6307 t_prolog "${@}"
6309 if have_feat iconv; then :; else
6310 t_echoskip '[!ICONV]'
6311 t_epilog "${@}"
6312 return
6315 printf '\150\303\274' > ./.tmba
6316 printf 'ha' > ./.tsba
6317 printf '' > "${MBOX}"
6319 printf '\150\303\244' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
6320 -s nogo \
6321 over-the@rain.bow 2>>${ERR}
6322 check 1 4 "${MBOX}" '4294967295 0'
6324 printf '\150\303\244' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
6325 -s go -Smime-force-sendout \
6326 over-the@rain.bow 2>>${ERR}
6327 check 2 0 "${MBOX}" '1866273282 219'
6329 printf ha | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
6330 -s nogo \
6331 -a ./.tmba over-the@rain.bow 2>>${ERR}
6332 check 3 4 "${MBOX}" '1866273282 219'
6334 printf ha | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
6335 -s go -Smime-force-sendout \
6336 -a ./.tmba over-the@rain.bow 2>>${ERR}
6337 check 4 0 "${MBOX}" '644433809 880'
6339 printf ha | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
6340 -s nogo \
6341 -a ./.tsba -a ./.tmba over-the@rain.bow 2>>${ERR}
6342 check 5 4 "${MBOX}" '644433809 880'
6344 printf ha | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
6345 -s go -Smime-force-sendout \
6346 -a ./.tsba -a ./.tmba over-the@rain.bow 2>>${ERR}
6347 check 6 0 "${MBOX}" '3172365123 1729'
6349 printf '\150\303\244' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
6350 -s nogo \
6351 -a ./.tsba -a ./.tmba over-the@rain.bow 2>>${ERR}
6352 check 7 4 "${MBOX}" '3172365123 1729'
6354 printf '\150\303\244' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
6355 -s go -Smime-force-sendout \
6356 -a ./.tsba -a ./.tmba over-the@rain.bow 2>>${ERR}
6357 check 8 0 "${MBOX}" '4002905306 2565'
6359 t_epilog "${@}"
6362 t_C_opt_customhdr() {
6363 t_prolog "${@}"
6365 echo bla |
6366 ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
6367 -C 'C-One : Custom One Body' \
6368 -C 'C-Two:CustomTwoBody' \
6369 -C 'C-Three: CustomThreeBody ' \
6370 -S customhdr='chdr1: chdr1 body, chdr2:chdr2 body, chdr3: chdr3 body ' \
6371 this-goes@nowhere >./.tall 2>&1
6372 check_ex0 1-estat
6373 ${cat} ./.tall >> "${MBOX}"
6374 check 1 0 "${MBOX}" '2535463301 238'
6376 ${rm} "${MBOX}"
6377 printf 'm this-goes@nowhere\nbody\n!.
6378 unset customhdr
6379 m this-goes2@nowhere\nbody2\n!.
6380 set customhdr=%ccustom1 : custom1 body%c
6381 m this-goes3@nowhere\nbody3\n!.
6382 set customhdr=%ccustom1 : custom1\\, body , \\
6383 custom2: custom2 body , custom-3 : custom3 body ,\\
6384 custom-4:custom4-body %c
6385 m this-goes4@nowhere\nbody4\n!.
6386 ' "'" "'" "'" "'" |
6387 ${MAILX} ${ARGS} -Smta=test://"$MBOX" -Sescape=! \
6388 -C 'C-One : Custom One Body' \
6389 -C 'C-Two:CustomTwoBody' \
6390 -C 'C-Three: CustomThreeBody ' \
6391 -C ' C-Four:CustomFourBody ' \
6392 -C 'C-Five:CustomFiveBody' \
6393 -S customhdr='ch1: b1 , ch2:b2, ch3:b3 ,ch4:b4, ch5: b5 ' \
6394 >./.tall 2>&1
6395 check_ex0 2-estat
6396 ${cat} ./.tall >> "${MBOX}"
6397 check 2 0 "${MBOX}" '544085062 1086'
6399 t_epilog "${@}"
6401 # }}}
6403 # Operational basics with trivial tests {{{
6404 t_alias() {
6405 t_prolog "${@}"
6407 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" > ./.tall 2>&1
6408 alias a1 ex1@a1.ple
6409 alias a1 ex2@a1.ple "EX3 <ex3@a1.ple>"
6410 alias a1 ex4@a1.ple
6411 alias a2 ex1@a2.ple ex2@a2.ple ex3@a2.ple ex4@a2.ple
6412 alias a3 a4
6413 alias a4 a5 ex1@a4.ple
6414 alias a5 a6
6415 alias a6 a7 ex1@a6.ple
6416 alias a7 a8
6417 alias a8 ex1@a8.ple
6418 alias a1
6419 alias a2
6420 alias a3
6421 m a1
6422 ~c a2
6423 ~b a3
6424 ~r - '_EOT'
6425 This body is!
6426 This also body is!!
6427 _EOT
6428 __EOT
6429 check 1 0 "${MBOX}" '139467786 277'
6430 check 2 - .tall '1598893942 133'
6432 if have_feat uistrings; then
6433 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
6434 commandalias x echo '$?/$^ERRNAME'
6435 echo 1
6436 alias a:bra! ha@m beb@ra ha@m '' zeb@ra ha@m; x
6437 alias a:bra!; x
6438 alias ha@m ham-expansion ha@m '';x
6439 alias ha@m;x
6440 alias beb@ra ceb@ra beb@ra1;x
6441 alias beb@ra;x
6442 alias ceb@ra ceb@ra1;x
6443 alias ceb@ra;x
6444 alias deb@ris '';x
6445 alias deb@ris;x
6446 echo 2
6447 alias - a:bra!;x
6448 alias - ha@m;x
6449 alias - beb@ra;x
6450 alias - ceb@ra;x
6451 alias - deb@ris;x
6452 echo 3
6453 unalias ha@m;x
6454 alias - a:bra!;x
6455 unalias beb@ra;x
6456 alias - a:bra!;x
6457 echo 4
6458 unalias*;x;alias;x
6459 echo 5
6460 \alias noexpa@and this@error1;x
6461 \alias ha@m '\noexp@and' expa@and \\noexp@and2;x
6462 \alias ha@m;x
6463 \alias - ha@m;x
6464 \alias noexpa@and2 this@error2;x
6465 \alias expa1@and this@error3;x
6466 \alias expa@and \\expa1@and;x
6467 \alias expa@and;x
6468 \alias - ha@m;x
6469 \alias - expa@and;x
6470 __EOT
6471 check 3 0 "${MBOX}" '1513155156 796'
6472 else
6473 t_echoskip '3:[!UISTRINGS]'
6476 # TODO t_alias: n_ALIAS_MAXEXP is compile-time constant,
6477 # TODO need to somehow provide its contents to the test, then test
6479 t_epilog "${@}"
6482 t_charsetalias() {
6483 t_prolog "${@}"
6485 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
6486 commandalias x echo '$?/$^ERRNAME'
6487 echo 1
6488 charsetalias latin1 latin15;x
6489 charsetalias latin1;x
6490 charsetalias - latin1;x
6491 echo 2
6492 charsetalias cp1252 latin1 latin15 utf8 utf8 utf16;x
6493 charsetalias cp1252;x
6494 charsetalias latin15;x
6495 charsetalias utf8;x
6496 echo 3
6497 charsetalias - cp1252;x
6498 charsetalias - latin15;x
6499 charsetalias - utf8;x
6500 echo 4
6501 charsetalias latin1;x
6502 charsetalias - latin1;x
6503 uncharsetalias latin15;x
6504 charsetalias latin1;x
6505 charsetalias - latin1;x
6506 __EOT
6507 check 1 0 "${MBOX}" '3551595280 433'
6509 t_epilog "${@}"
6512 t_shortcut() {
6513 t_prolog "${@}"
6515 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
6516 commandalias x echo '$?/$^ERRNAME'
6517 echo 1
6518 shortcut file1 expansion-of-file1;x
6519 shortcut file2 expansion-of-file2;x
6520 shortcut file3 expansion-of-file3;x
6521 shortcut file4 'expansion of file4' 'file 5' 'expansion of file5';x
6522 echo 2
6523 shortcut file1;x
6524 shortcut file2;x
6525 shortcut file3;x
6526 shortcut file4;x
6527 shortcut 'file 5';x
6528 echo 3
6529 shortcut;x
6530 __EOT
6531 check 1 0 "${MBOX}" '1970515669 430'
6533 t_epilog "${@}"
6536 t_netrc() {
6537 t_prolog "${@}"
6539 if have_feat netrc; then :; else
6540 t_echoskip '[!NETRC]'
6541 t_epilog "${@}"
6542 return
6545 printf '# comment
6546 machine x.local login a1 machine x.local login a2 password p2
6547 machine x.local login a3 password "p 3"
6548 machine
6549 pop.x.local
6550 login
6552 password
6553 p2-pop!
6554 machine *.x.local login a2 password p2-any!
6555 machine y.local login ausr password apass
6556 machine
6557 z.local password
6558 noupa
6559 # and unused default
6560 default login defacc password defpass
6561 ' > ./.tnetrc
6562 ${chmod} 0600 ./.tnetrc
6564 printf 'netrc;echo =$?;netrc c;echo =$?;netr loa;echo =$?;netr s;echo =$?' |
6565 NETRC=./.tnetrc ${MAILX} ${ARGS} > "${MBOX}" 2>&1
6566 check 1 0 "${MBOX}" '2911708535 542'
6568 have_feat uistrings && i='3076722625 893' || i='3808149439 645'
6569 printf '# Comment
6570 echo ==host
6571 netrc loo x.local
6572 netrc loo y.local
6573 netrc loo z.local
6574 echo ==(re)load cache
6575 netrc load;echo $?/$^ERRNAME
6576 echo ==usr@host
6577 netrc loo a1@x.local
6578 netrc loo a2@x.local
6579 netrc loo a3@x.local
6580 netrc loo a4@x.local
6581 echo ==clear cache
6582 netrc clear;echo $?/$^ERRNAME
6583 echo ==usr@x.host
6584 netrc loo a2@pop.x.local
6585 netrc loo a2@imap.x.local
6586 netrc loo a2@smtp.x.local
6587 echo ==usr@y.x.host
6588 netrc loo a2@nono.smtp.x.local
6589 echo ==[usr@]unknown-host
6590 netrc loo a.local
6591 netrc loo defacc@a.local
6592 netrc loo a1@a.local
6593 ' | NETRC=./.tnetrc ${MAILX} ${ARGS} > "${MBOX}" 2>&1
6594 check 2 0 "${MBOX}" "${i}"
6596 t_epilog "${@}"
6598 # }}}
6600 # Operational basics with easy tests {{{
6601 t_expandaddr() {
6602 # after: t_alias
6603 # MTA alias specific part in t_mta_aliases()
6604 # This only tests from command line, rest later on (iff any)
6605 t_prolog "${@}"
6607 if have_feat uistrings; then :; else
6608 t_echoskip '[!UISTRINGS]'
6609 t_epilog "${@}"
6610 return
6613 echo "${cat}" > ./.tcat
6614 ${chmod} 0755 ./.tcat
6617 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6618 -X'alias talias talias@exam.ple' \
6619 './.tfile' ' | ./.tcat > ./.tpipe' 'talias' 'taddr@exam.ple' \
6620 > ./.tall 2>&1
6621 check 1 4 "${MBOX}" '1216011460 138'
6622 check 2 - .tall '4169590008 162'
6625 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6626 -Sexpandaddr \
6627 -X'alias talias talias@exam.ple' \
6628 './.tfile' ' | ./.tcat >./.tpipe' 'talias' 'taddr@exam.ple' \
6629 > ./.tall 2>&1
6630 check 3 0 "${MBOX}" '847567042 276'
6631 check 4 - .tall '4294967295 0'
6632 check 5 - .tfile '1216011460 138'
6633 check 6 - .tpipe '1216011460 138'
6636 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6637 -Sexpandaddr=-all,+file,+pipe,+name,+addr \
6638 -X'alias talias talias@exam.ple' \
6639 './.tfile' ' | ./.tcat >./.tpipe' 'talias' 'taddr@exam.ple' \
6640 > ./.tall 2>&1
6641 check 7 0 "${MBOX}" '3682360102 414'
6642 check 8 - .tall '4294967295 0'
6643 check 9 - .tfile '847567042 276'
6644 check 10 - .tpipe '1216011460 138'
6647 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6648 -Sexpandaddr=-all,+file,-file,+pipe,+name,+addr \
6649 -X'alias talias talias@exam.ple' \
6650 './.tfile' ' | ./.tcat >./.tpipe' 'talias' 'taddr@exam.ple' \
6651 > ./.tall 2>&1
6652 check 11 4 "${MBOX}" '1010907786 552'
6653 check 12 - .tall '673208446 70'
6654 check 13 - .tfile '847567042 276'
6655 check 14 - .tpipe '1216011460 138'
6657 printf '' > ./.tpipe
6658 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6659 -Sexpandaddr=fail,-all,+file,-file,+pipe,+name,+addr \
6660 -X'alias talias talias@exam.ple' \
6661 './.tfile' ' | ./.tcat >./.tpipe' 'talias' 'taddr@exam.ple' \
6662 > ./.tall 2>&1
6663 check 15 4 "${MBOX}" '1010907786 552'
6664 check 16 - .tall '3280630252 179'
6665 check 17 - .tfile '847567042 276'
6666 check 18 - .tpipe '4294967295 0'
6669 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6670 -Sexpandaddr=-all,+file,+pipe,-pipe,+name,+addr \
6671 -X'alias talias talias@exam.ple' \
6672 './.tfile' ' | ./.tcat >./.tpipe' 'talias' 'taddr@exam.ple' \
6673 > ./.tall 2>&1
6674 check 19 4 "${MBOX}" '3359494254 690'
6675 check 20 - .tall '4052857227 91'
6676 check 21 - .tfile '3682360102 414'
6677 check 22 - .tpipe '4294967295 0'
6679 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6680 -Sexpandaddr=fail,-all,+file,+pipe,-pipe,+name,+addr \
6681 -X'alias talias talias@exam.ple' \
6682 './.tfile' ' | ./.tcat >./.tpipe' 'talias' 'taddr@exam.ple' \
6683 > ./.tall 2>&1
6684 check 23 4 "${MBOX}" '3359494254 690'
6685 check 24 - .tall '2168069102 200'
6686 check 25 - .tfile '3682360102 414'
6687 check 26 - .tpipe '4294967295 0'
6690 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6691 -Sexpandaddr=-all,+file,+pipe,+name,-name,+addr \
6692 -X'alias talias talias@exam.ple' \
6693 './.tfile' ' | ./.tcat >./.tpipe' 'talias' 'taddr@exam.ple' \
6694 > ./.tall 2>&1
6695 check 27 0 "${MBOX}" '3735108703 828'
6696 check 28 - .tall '4294967295 0'
6697 check 29 - .tfile '1010907786 552'
6698 check 30 - .tpipe '1216011460 138'
6700 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6701 -Sexpandaddr=-all,+file,+pipe,+name,-name,+addr \
6702 './.tfile' ' | ./.tcat >./.tpipe' 'talias' 'taddr@exam.ple' \
6703 > ./.tall 2>&1
6704 check 31 4 "${MBOX}" '4225234603 949'
6705 check 32 - .tall '3486613973 73'
6706 check 33 - .tfile '452731060 673'
6707 check 34 - .tpipe '1905076731 121'
6709 printf '' > ./.tpipe
6710 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6711 -Sexpandaddr=fail,-all,+file,+pipe,+name,-name,+addr \
6712 './.tfile' ' | ./.tcat >./.tpipe' 'talias' 'taddr@exam.ple' \
6713 > ./.tall 2>&1
6714 check 35 4 "${MBOX}" '4225234603 949'
6715 check 36 - .tall '3032065285 182'
6716 check 37 - .tfile '452731060 673'
6717 check 38 - .tpipe '4294967295 0'
6720 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6721 -Sexpandaddr=-all,+file,+pipe,+name,+addr,-addr \
6722 -X'alias talias talias@exam.ple' \
6723 './.tfile' ' | ./.tcat >./.tpipe' 'talias' 'taddr@exam.ple' \
6724 > ./.tall 2>&1
6725 check 39 4 "${MBOX}" '4225234603 949'
6726 check 40 - .tall '3863610168 169'
6727 check 41 - .tfile '1975297706 775'
6728 check 42 - .tpipe '130065764 102'
6730 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6731 -Sexpandaddr=-all,+file,+pipe,+name,+addr,-addr \
6732 -Sadd-file-recipients \
6733 -X'alias talias talias@exam.ple' \
6734 './.tfile' ' | ./.tcat >./.tpipe' 'talias' 'taddr@exam.ple' \
6735 > ./.tall 2>&1
6736 check 43 4 "${MBOX}" '4225234603 949'
6737 check 44 - .tall '3863610168 169'
6738 check 45 - .tfile '3291831864 911'
6739 check 46 - .tpipe '4072000848 136'
6741 printf '' > ./.tpipe
6742 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6743 -Sexpandaddr=fail,-all,+file,+pipe,+name,+addr,-addr \
6744 -Sadd-file-recipients \
6745 -X'alias talias talias@exam.ple' \
6746 './.tfile' ' | ./.tcat >./.tpipe' 'talias' 'taddr@exam.ple' \
6747 > ./.tall 2>&1
6748 check 47 4 "${MBOX}" '4225234603 949'
6749 check 48 - .tall '851041772 278'
6750 check 49 - .tfile '3291831864 911'
6751 check 50 - .tpipe '4294967295 0'
6754 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6755 -Sexpandaddr=-all,+addr \
6756 'taddr@exam.ple' 'this@@c.example' \
6757 > ./.tall 2>&1
6758 check 51 4 "${MBOX}" '473729143 1070'
6759 check 52 - .tall '2646392129 66'
6761 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6762 -Sexpandaddr=-all,failinvaddr \
6763 'taddr@exam.ple' 'this@@c.example' \
6764 > ./.tall 2>&1
6765 check 53 4 "${MBOX}" '473729143 1070'
6766 check 54 - .tall '887391555 175'
6769 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6770 -Sthis=taddr@exam.ple -Sexpandaddr \
6771 -c '\$this' -b '\$this' '\$this' \
6772 > ./.tall 2>&1
6773 check 55 4 "${MBOX}" '473729143 1070'
6774 check 56 - .tall '1144578880 139'
6776 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6777 -Sthis=taddr@exam.ple -Sexpandaddr=shquote \
6778 -c '\$this' -b '\$this' '\$this' \
6779 > ./.tall 2>&1
6780 check 57 0 "${MBOX}" '398243793 1191'
6781 check 58 - .tall '4294967295 0'
6784 printf '' > "${MBOX}"
6785 ${cat} <<-_EOT |\
6786 ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -t -ssub \
6787 -Sadd-file-recipients \
6788 -Sexpandaddr=-all,+fcc \
6789 > ./.tall 2>&1
6790 Fcc: .tfile1
6791 Fcc: .tfile2
6792 _EOT
6793 check 59 0 "${MBOX}" '4294967295 0'
6794 check 60 - .tall '4294967295 0'
6795 check 61 - .tfile1 '1067276522 124'
6796 check 62 - .tfile2 '1067276522 124'
6798 printf '' > "${MBOX}"
6799 ${cat} <<-_EOT |\
6800 ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -t -ssub \
6801 -Sadd-file-recipients \
6802 -Sexpandaddr=-all,+file \
6803 > ./.tall 2>&1
6804 Fcc: .tfile1
6805 Fcc: .tfile2
6806 _EOT
6807 check 63 0 "${MBOX}" '4294967295 0'
6808 check 64 - .tall '4294967295 0'
6809 check 65 - .tfile1 '2677253527 248'
6810 check 66 - .tfile2 '2677253527 248'
6812 printf '' > "${MBOX}"
6813 ${cat} <<-_EOT |\
6814 ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -t -ssub \
6815 -Sadd-file-recipients \
6816 -Sexpandaddr=-all,+file,-fcc \
6817 > ./.tall 2>&1
6818 Fcc: .tfile1
6819 Fcc: .tfile2
6820 _EOT
6821 check 67 0 "${MBOX}" '4294967295 0'
6822 check 68 - .tall '4294967295 0'
6823 check 69 - .tfile1 '3493511004 372'
6824 check 70 - .tfile2 '3493511004 372'
6826 printf '' > "${MBOX}"
6827 ${cat} <<-_EOT |\
6828 ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -t -ssub \
6829 -Sadd-file-recipients \
6830 -Sexpandaddr=-all,+fcc,-file \
6831 > ./.tall 2>&1
6832 Fcc: .tfile1
6833 Fcc: .tfile2
6834 _EOT
6835 check 71 4 "${MBOX}" '4294967295 0'
6836 check 72 - .tall '203687556 223'
6837 check 73 - .tfile1 '3493511004 372'
6838 check 74 - .tfile2 '3493511004 372'
6840 printf '' > "${MBOX}"
6841 ${cat} <<-_EOT |\
6842 ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -t -ssub \
6843 -Sadd-file-recipients \
6844 -Sexpandaddr=-all,fail,+addr \
6845 > ./.tall 2>&1
6846 Fcc: .tfile1
6847 Fcc: .tfile2
6848 To: never@exam.ple
6849 _EOT
6850 check 75 4 "${MBOX}" '4294967295 0'
6851 check 76 - .tall '4060426468 247'
6852 check 77 - .tfile1 '3493511004 372'
6853 check 78 - .tfile2 '3493511004 372'
6856 printf '' > "${MBOX}"
6857 ${cat} <<-_EOT |\
6858 ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -t -ssub \
6859 -Sexpandaddr=fail,domaincheck \
6860 > ./.tall 2>&1
6861 To: one@localhost
6862 _EOT
6863 check 79 0 "${MBOX}" '171635532 120'
6864 check 80 - .tall '4294967295 0'
6866 ${cat} <<-_EOT |\
6867 ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -t -ssub \
6868 -Sexpandaddr=domaincheck \
6869 > ./.tall 2>&1
6870 To: one@localhost , Hey two <two@exam.ple>, Trouble <three@tro.uble>
6871 _EOT
6872 check 81 4 "${MBOX}" '2659464839 240'
6873 check 82 - .tall '1119895397 158'
6875 ${cat} <<-_EOT |\
6876 ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -t -ssub \
6877 -Sexpandaddr=fail,domaincheck \
6878 > ./.tall 2>&1
6879 To: one@localhost , Hey two <two@exam.ple>, Trouble <three@tro.uble>
6880 _EOT
6881 check 83 4 "${MBOX}" '2659464839 240'
6882 check 84 - .tall '1577313789 267'
6884 ${cat} <<-_EOT |\
6885 ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -t -ssub \
6886 -Sexpandaddr=fail,domaincheck \
6887 -Sexpandaddr-domaincheck=exam.ple,tro.uble \
6888 > ./.tall 2>&1
6889 To: one@localhost , Hey two <two@exam.ple>, Trouble <three@tro.uble>
6890 _EOT
6891 check 85 0 "${MBOX}" '1670655701 410'
6892 check 86 - .tall '4294967295 0'
6894 t_epilog "${@}"
6897 t_mta_aliases() {
6898 # after: t_expandaddr
6899 t_prolog "${@}"
6901 if have_feat mta-aliases; then :; else
6902 t_echoskip '[!MTA_ALIASES]'
6903 t_epilog "${@}"
6904 return
6907 ${cat} > ./.tali <<- '__EOT'
6909 # Comment
6912 a1: ex1@a1.ple ,
6913 ex2@a1.ple, <ex3@a1.ple> ,
6914 ex4@a1.ple
6915 a2: ex1@a2.ple , ex2@a2.ple,a2_2
6916 a2_2:ex3@a2.ple,ex4@a2.ple
6917 a3: a4
6918 a4: a5,
6919 # Comment
6920 # More comment
6921 ex1@a4.ple
6922 # Comment
6923 a5: a6
6924 a6: a7 , ex1@a6.ple
6925 a7: a8,a9
6926 a8: ex1@a8.ple
6927 __EOT
6929 echo | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
6930 -Smta-aliases=./.tali \
6931 -b a3 -c a2 a1 > ./.tall 2>&1
6932 check 1 0 "${MBOX}" '1172368381 238'
6933 check 2 - .tall '4294967295 0'
6935 ## xxx The following are actually *expandaddr* tests!!
6937 # May not send plain names over SMTP!
6938 mtaali=
6939 if have_feat smtp; then
6940 echo | ${MAILX} ${ARGS} \
6941 -Smta=smtp://laber.backe -Ssmtp-auth=none \
6942 -Smta-aliases=./.tali \
6943 -b a3 -c a2 a1 > ./.tall 2>&1
6944 check_exn0 3
6945 check 4 - "${MBOX}" '1172368381 238'
6946 mtaali=1
6948 if [ -n "${mtaali}" ] && have_feat uistrings; then
6949 check 5 - .tall '771616226 179'
6950 else
6951 t_echoskip '5:[!SMTP/!UISTRINGS]'
6954 # xxx for false-positive SMTP test we would need some mocking
6955 echo | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
6956 -Sexpandaddr=fail,-name \
6957 -Smta-aliases=./.tali \
6958 -b a3 -c a2 a1 > ./.tall 2>&1
6959 check_exn0 6
6960 check 7 - "${MBOX}" '1172368381 238'
6961 if have_feat uistrings; then
6962 check 8 - .tall '2834389894 178'
6963 else
6964 t_echoskip '8:[!UISTRINGS]'
6967 echo | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
6968 -Sexpandaddr=-name \
6969 -Smta-aliases=./.tali \
6970 -b a3 -c a2 a1 > ./.tall 2>&1
6971 check 9 4 "${MBOX}" '2322273994 472'
6972 if have_feat uistrings; then
6973 check 10 - .tall '2136559508 69'
6974 else
6975 t_echoskip '10:[!UISTRINGS]'
6978 echo 'a9:nine@nine.nine' >> ./.tali
6980 echo | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
6981 -Sexpandaddr=fail,-name \
6982 -Smta-aliases=./.tali \
6983 -b a3 -c a2 a1 > ./.tall 2>&1
6984 check 11 0 "${MBOX}" '2422268299 722'
6985 check 12 - .tall '4294967295 0'
6987 printf '#
6988 set expandaddr=-name
6989 mail a1
6990 !c a2
6991 !:echo $?/$^ERRNAME
6992 !^header insert bcc a3
6993 !:echo $?/$^ERRNAME
6994 !:set expandaddr
6995 !t a1
6996 !c a2
6997 !:echo $?/$^ERRNAME
6998 !^header insert bcc a3
6999 !:echo $?/$^ERRNAME
7001 echo and, once again, check that cache is updated
7002 # Enclose one pipe in quotes: immense stress for our stupid address parser:(
7003 !echo "a10:./.tf1,|%s>./.tp1,\\"|%s > ./.tp2\\",./.tf2" >> ./.tali
7004 mtaaliases load
7005 mail a1
7006 !c a2
7007 !:echo $?/$^ERRNAME
7008 !^header insert bcc a3
7009 !:echo $?/$^ERRNAME
7011 echo trigger happiness
7012 mail a1
7013 !c a2
7014 !:echo $?/$^ERRNAME
7015 !^header insert bcc "a3 a10"
7016 !:echo $?/$^ERRNAME
7018 ' "${cat}" "${cat}" | ${MAILX} ${ARGS} -Smta=test://"$MBOX" -Sescape=! \
7019 -Smta-aliases=./.tali \
7020 > ./.tall 2>&1
7021 check 13 0 "${MBOX}" '550955032 1469'
7022 if have_feat uistrings; then
7023 check 14 - .tall '1795496020 473'
7024 else
7025 t_echoskip '14:[!UISTRINGS]'
7027 check 15 - .tf1 '3056269950 249'
7028 check 16 - .tp1 '3056269950 249'
7029 check 17 - .tp2 '3056269950 249'
7030 check 18 - .tf2 '3056269950 249'
7032 # TODO t_mta_aliases: n_ALIAS_MAXEXP is compile-time constant,
7033 # TODO need to somehow provide its contents to the test, then test
7035 t_epilog "${@}"
7038 t_filetype() {
7039 t_prolog "${@}"
7041 printf 'm m1@e.t\nL1\nHy1\n~.\nm m2@e.t\nL2\nHy2\n~@ %s\n~.\n' \
7042 "${TOPDIR}snailmail.jpg" | ${MAILX} ${ARGS} -Smta=test://"$MBOX"
7043 check 1 0 "${MBOX}" '1314354444 13536'
7045 if (echo | gzip -c) >/dev/null 2>&1; then
7047 printf 'File "%s"\ncopy 1 ./.t.mbox.gz\ncopy 2 ./.t.mbox.gz' \
7048 "${MBOX}" | ${MAILX} ${ARGS} \
7049 -X'filetype gz gzip\ -dc gzip\ -c'
7050 printf 'File ./.t.mbox.gz\ncopy * ./.t.mbox\n' |
7051 ${MAILX} ${ARGS} -X'filetype gz gzip\ -dc gzip\ -c'
7052 } > ./.t.out 2>&1
7053 check 2 - ./.t.mbox '1314354444 13536'
7054 check 3 - ./.t.out '635961640 103'
7055 else
7056 t_echoskip '2:[missing gzip(1)]'
7057 t_echoskip '3:[missing gzip(1)]'
7061 ${rm} ./.t.mbox*
7062 printf 'File "%s"\ncopy 1 ./.t.mbox.gz
7063 copy 2 ./.t.mbox.gz
7064 copy 1 ./.t.mbox.gz
7065 copy 2 ./.t.mbox.gz
7066 ' "${MBOX}" |
7067 ${MAILX} ${ARGS} \
7068 -X'filetype gz gzip\ -dc gzip\ -c' \
7069 -X'filetype mbox.gz "${sed} 1,3d|${cat}" \
7070 "echo eins;echo zwei;echo und mit ${sed} bist Du dabei;${cat}"'
7071 printf 'File ./.t.mbox.gz\ncopy * ./.t.mbox\n' |
7072 ${MAILX} ${ARGS} \
7073 -X'filetype gz gzip\ -dc gzip\ -c' \
7074 -X'filetype mbox.gz "${sed} 1,3d|${cat}" kill\ 0'
7075 } > ./.t.out 2>&1
7076 check 4 - ./.t.mbox '2687765142 27092'
7077 check 5 - ./.t.out '2230192693 173'
7079 t_epilog "${@}"
7082 t_e_H_L_opts() {
7083 t_prolog "${@}"
7085 touch ./.t.mbox
7086 ${MAILX} ${ARGS} -ef ./.t.mbox
7087 echo ${?} > "${MBOX}"
7089 printf 'm me@exam.ple\nLine 1.\nHello.\n~.\n' |
7090 ${MAILX} ${ARGS} -Smta=test://./.t.mbox
7091 printf 'm you@exam.ple\nLine 1.\nBye.\n~.\n' |
7092 ${MAILX} ${ARGS} -Smta=test://./.t.mbox
7094 ${MAILX} ${ARGS} -ef ./.t.mbox 2>> "${MBOX}"
7095 echo ${?} >> "${MBOX}"
7096 ${MAILX} ${ARGS} -efL @t@me ./.t.mbox 2>> "${MBOX}"
7097 echo ${?} >> "${MBOX}"
7098 ${MAILX} ${ARGS} -efL @t@you ./.t.mbox 2>> "${MBOX}"
7099 echo ${?} >> "${MBOX}"
7100 ${MAILX} ${ARGS} -efL '@>@Line 1' ./.t.mbox 2>> "${MBOX}"
7101 echo ${?} >> "${MBOX}"
7102 ${MAILX} ${ARGS} -efL '@>@Hello.' ./.t.mbox 2>> "${MBOX}"
7103 echo ${?} >> "${MBOX}"
7104 ${MAILX} ${ARGS} -efL '@>@Bye.' ./.t.mbox 2>> "${MBOX}"
7105 echo ${?} >> "${MBOX}"
7106 ${MAILX} ${ARGS} -efL '@>@Good bye.' ./.t.mbox 2>> "${MBOX}"
7107 echo ${?} >> "${MBOX}"
7109 ${MAILX} ${ARGS} -fH ./.t.mbox >> "${MBOX}" 2>&1
7110 echo ${?} >> "${MBOX}"
7111 ${MAILX} ${ARGS} -fL @t@me ./.t.mbox >> "${MBOX}" 2>&1
7112 echo ${?} >> "${MBOX}"
7113 ${MAILX} ${ARGS} -fL @t@you ./.t.mbox >> "${MBOX}" 2>&1
7114 echo ${?} >> "${MBOX}"
7115 ${MAILX} ${ARGS} -fL '@>@Line 1' ./.t.mbox >> "${MBOX}" 2>&1
7116 echo ${?} >> "${MBOX}"
7117 ${MAILX} ${ARGS} -fL '@>@Hello.' ./.t.mbox >> "${MBOX}" 2>&1
7118 echo ${?} >> "${MBOX}"
7119 ${MAILX} ${ARGS} -fL '@>@Bye.' ./.t.mbox >> "${MBOX}" 2>&1
7120 echo ${?} >> "${MBOX}"
7121 ${MAILX} ${ARGS} -fL '@>@Good bye.' ./.t.mbox >> "${MBOX}" 2>>${ERR}
7122 echo ${?} >> "${MBOX}"
7124 check 1 - "${MBOX}" '1369201287 670'
7128 printf 'm me1@exam.ple\n~s subject cab\nLine 1.\n~.\n' |
7129 ${MAILX} ${ARGS} -Smta=test://./.t.mbox \
7130 -r '' -X 'wysh set from=pony1@$LOGNAME'
7131 printf 'm me2@exam.ple\n~s subject bac\nLine 12.\n~.\n' |
7132 ${MAILX} ${ARGS} -Smta=test://./.t.mbox \
7133 -r '' -X 'wysh set from=pony2@$LOGNAME'
7134 printf 'm me3@exam.ple\n~s subject abc\nLine 123.\n~.\n' |
7135 ${MAILX} ${ARGS} -Smta=test://./.t.mbox \
7136 -r '' -X 'wysh set from=pony3@$LOGNAME'
7138 ${MAILX} ${ARGS} -S folder-hook=fh-test -X 'define fh-test {
7139 echo fh-test size; set autosort=size showname showto
7140 }' -fH ./.t.mbox > "${MBOX}" 2>&1
7141 check 2 0 "${MBOX}" '4286438644 413'
7143 ${MAILX} ${ARGS} -S folder-hook=fh-test -X 'define fh-test {
7144 echo fh-test subject; set autosort=subject showname showto
7145 }' -fH ./.t.mbox > "${MBOX}" 2>&1
7146 check 3 0 "${MBOX}" '3208053922 416'
7148 ${MAILX} ${ARGS} -S folder-hook=fh-test -X 'define fh-test {
7149 echo fh-test from; set autosort=from showto
7150 }' -fH ./.t.mbox > "${MBOX}" 2>&1
7151 check 4 0 "${MBOX}" '4209767839 413'
7153 ${MAILX} ${ARGS} -S folder-hook=fh-test -X 'define fh-test {
7154 echo fh-test to; set autosort=to showto
7155 }' -fH ./.t.mbox > "${MBOX}" 2>&1
7156 check 5 0 "${MBOX}" '2785342736 411'
7158 t_epilog "${@}"
7161 t_q_t_etc_opts() {
7162 # Simple, if we need more here, place in a later vim fold!
7163 t_prolog "${@}"
7165 # Three tests for MIME encoding and (a bit) content classification.
7166 # At the same time testing -q FILE, < FILE and -t FILE
7167 t__put_body > ./.tin
7169 < ./.tin ${MAILX} ${ARGS} ${ADDARG_UNI} \
7170 -a ./.tin -s "`t__put_subject`" "${MBOX}"
7171 check 1 0 "${MBOX}" '1088822685 6642'
7173 ${rm} "${MBOX}"
7174 < /dev/null ${MAILX} ${ARGS} ${ADDARG_UNI} \
7175 -a ./.tin -s "`t__put_subject`" -q ./.tin "${MBOX}"
7176 check 2 0 "${MBOX}" '1088822685 6642'
7178 ${rm} "${MBOX}"
7179 ( echo "To: ${MBOX}" && echo "Subject: `t__put_subject`" && echo &&
7180 ${cat} ./.tin
7181 ) | ${MAILX} ${ARGS} ${ADDARG_UNI} -Snodot -a ./.tin -t
7182 check 3 0 "${MBOX}" '1088822685 6642'
7184 # Check comments in the header
7185 ${rm} "${MBOX}"
7186 ${cat} <<-_EOT | ${MAILX} ${ARGS} -Snodot -t "${MBOX}"
7187 # Ein Kommentar
7188 From: du@da
7189 # Noch ein Kommentar
7190 Subject : hey you
7191 # Nachgestelltes Kommentar
7193 BOOOM
7194 _EOT
7195 check 4 0 "${MBOX}" '4161555890 124'
7197 # ?MODifier suffix
7198 printf '' > "${MBOX}"
7199 ( echo 'To?single : ./.tout1 .tout2 ' &&
7200 echo 'CC: ./.tcc1 ./.tcc2' &&
7201 echo 'BcC?sin : ./.tbcc1 .tbcc2 ' &&
7202 echo 'To? : ./.tout3 .tout4 ' &&
7203 echo &&
7204 echo body
7205 ) | ${MAILX} ${ARGS} ${ADDARG_UNI} -Snodot -t -Smta=test://"$MBOX"
7206 check 5 0 './.tout1 .tout2' '2948857341 94'
7207 check 6 - ./.tcc1 '2948857341 94'
7208 check 7 - ./.tcc2 '2948857341 94'
7209 check 8 - './.tbcc1 .tbcc2' '2948857341 94'
7210 check 9 - './.tout3 .tout4' '2948857341 94'
7211 check 10 - "${MBOX}" '4294967295 0'
7213 t_epilog "${@}"
7216 t_message_injections() {
7217 # Simple, if we need more here, place in a later vim fold!
7218 t_prolog "${@}"
7220 echo mysig > ./.tmysig
7222 echo some-body | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
7223 -Smessage-inject-head=head-inject \
7224 -Smessage-inject-tail="`${cat} ./.tmysig`"'\ntail-inject' \
7225 ex@am.ple > ./.tall 2>&1
7226 check 1 0 "${MBOX}" '701778583 143'
7227 check 2 - .tall '4294967295 0' # empty file
7229 ${rm} "${MBOX}"
7230 ${cat} <<-_EOT > ./.template
7231 From: me
7232 To: ex1@am.ple
7233 Cc: ex2@am.ple
7234 Subject: This subject is
7236 Body, body, body me.
7237 _EOT
7238 < ./.template ${MAILX} ${ARGS} -t -Smta=test://"$MBOX" \
7239 -Smessage-inject-head=head-inject \
7240 -Smessage-inject-tail="`${cat} ./.tmysig`\n"'tail-inject' \
7241 > ./.tall 2>&1
7242 check 3 0 "${MBOX}" '2189109479 207'
7243 check 4 - .tall '4294967295 0' # empty file
7245 t_epilog "${@}"
7248 t_attachments() {
7249 # TODO More should be in compose mode stuff aka digmsg
7250 t_prolog "${@}"
7252 ${cat} <<-_EOT > ./.tx
7253 From steffen Sun Feb 18 02:48:40 2018
7254 Date: Sun, 18 Feb 2018 02:48:40 +0100
7256 Subject: m1
7257 User-Agent: s-nail v14.9.7
7260 From steffen Sun Feb 18 02:48:42 2018
7261 Date: Sun, 18 Feb 2018 02:48:42 +0100
7263 Subject: m2
7264 User-Agent: s-nail v14.9.7
7267 _EOT
7268 echo att1 > ./.t1
7269 printf 'att2-1\natt2-2\natt2-4\n' > ./'.t 2'
7270 printf 'att3-1\natt3-2\natt3-4\n' > ./.t3
7271 printf 'att4-1\natt4-2\natt4-4\n' > './.t 4'
7273 printf \
7274 '!@ ./.t3 "./.t 4" ""
7277 ./.t3
7278 "./.t 2"
7281 !.' \
7282 | ${MAILX} ${ARGS} -Sescape=! -Smta=test://"$MBOX" \
7283 -a ./.t1 -a './.t 2' \
7284 -s attachment-test \
7285 ex@am.ple > ./.tall 2>&1
7286 check 1 0 "${MBOX}" '2484200149 644'
7287 if have_feat uistrings; then
7288 check 2 - .tall '1928331872 720'
7289 else
7290 t_echoskip '2:[!UISTRINGS]'
7293 ${rm} "${MBOX}"
7294 printf \
7295 'mail ex@amp.ple
7296 !s This the subject is
7297 !@ ./.t3 "#2" "./.t 4" "#1" ""
7300 "./.t 4"
7301 "#2"
7305 mail ex@amp.ple
7306 !s Subject two
7307 !@ ./.t3 "#2" "./.t 4" "#1" ""
7313 mail ex@amp.ple
7314 !s Subject three
7315 !@ ./.t3 "" "#2" "" "./.t 4" "" "#1" ""
7318 ./.t3
7322 mail ex@amp.ple
7323 !s Subject Four
7324 !@ ./.t3 "" "#2" "" "./.t 4" "" "#1" ""
7327 "#1"
7331 mail ex@amp.ple
7332 !s Subject Five
7334 "#2"
7337 !.' \
7338 | ${MAILX} ${ARGS} -Sescape=! -Smta=test://"$MBOX" -Rf ./.tx \
7339 > ./.tall 2>&1
7340 check 3 0 "${MBOX}" '3637385058 2335'
7341 if have_feat uistrings; then
7342 check 4 - .tall '2526106274 1910'
7343 else
7344 t_echoskip '4:[!UISTRINGS]'
7347 ${rm} "${MBOX}"
7348 printf \
7349 'mail ex@amp.ple
7350 !s Subject One
7351 !@ "#."
7352 Body one.
7355 from 2
7356 mail ex@amp.ple
7357 !s Subject Two
7359 "#."
7361 Body two.
7364 reply 1 2
7365 !@ "#."
7369 "#."
7372 !.' \
7373 | ${MAILX} ${ARGS} -Sescape=! -Smta=test://"$MBOX" -Rf ./.tx \
7374 > ./.tall 2>&1
7375 check 5 0 "${MBOX}" '1604688179 2316'
7376 if have_feat uistrings; then
7377 check 6 - .tall '1210753005 508'
7378 else
7379 t_echoskip '6:[!UISTRINGS]'
7384 # Content-ID:
7385 </dev/null ${MAILX} ${ARGS} -Smta=test \
7386 -Sstealthmua=noagent -Shostname \
7387 -a ./.t1 -a './.t 2' \
7388 -a ./.t3 -a './.t 4' \
7389 -s Y \
7390 ex@am.ple > ./.tall 2>&1
7391 check 7 0 .tall '1003537919 1262'
7393 # input charset
7394 </dev/null ${MAILX} ${ARGS} -Smta=test -Sttycharset=utf8 \
7395 -a ./.t1=ascii -a './.t 2'=LATin1 \
7396 -a ./.t3=UTF-8 -a './.t 4'=- \
7397 -s Y \
7398 ex@am.ple > ./.tall 2>&1
7399 check 8 0 .tall '361641281 921'
7401 # input+output charset, no iconv
7402 </dev/null ${MAILX} ${ARGS} -Smta=test \
7403 -a ./.t1=ascii#- -a './.t 2'=LATin1#- \
7404 -a ./.t3=UTF-8#- -a './.t 4'=utf8#- \
7405 -s Y \
7406 ex@am.ple > ./.tall 2>&1
7407 check 9 0 .tall '1357456844 933'
7409 if have_feat iconv; then
7410 printf 'ein \303\244ffchen und ein pferd\n' > .t10-f1
7411 if (< .t10-f1 iconv -f ascii -t utf8) >/dev/null 2>&1; then
7412 </dev/null ${MAILX} ${ARGS} --set mta=test \
7413 --set stealthmua=noagent --set hostname \
7414 --attach ./.t1=-#utf8 \
7415 --attach ./.t10-f1=utf8#latin1 \
7416 --subject Y \
7417 ex@am.ple > ./.tall 2>&1
7418 check 10 0 .tall '1257664842 877'
7419 else
7420 t_echoskip '10:[ICONV/iconv(1):missing conversion(1)]'
7422 else
7423 t_echoskip '10:[!ICONV]'
7426 t_epilog "${@}"
7429 t_rfc2231() {
7430 # (after attachments)
7431 t_prolog "${@}"
7434 mkdir ./.ttt || exit 1
7435 cd ./.ttt || exit 2
7436 : > "ma'ger.txt"
7437 : > "mä'ger.txt"
7438 : > 'diet\ is \curd.txt'
7439 : > 'diet "is" curd.txt'
7440 : > höde-tröge.txt
7441 : > 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
7442 : > höde__tröge__müde__dätte__hätte__vuelle__guelle__aese__aesse__sauerliche__kräuter__österliche__grüße__mäh.txt
7443 : > hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt
7444 : > ✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt
7446 echo bla | ${MAILX} ${ARGS} ${ADDARG_UNI} \
7447 -a "./.ttt/ma'ger.txt" -a "./.ttt/mä'ger.txt" \
7448 -a './.ttt/diet\ is \curd.txt' -a './.ttt/diet "is" curd.txt' \
7449 -a ./.ttt/höde-tröge.txt \
7450 -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 \
7451 -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 \
7452 -a ./.ttt/hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt \
7453 -a ./.ttt/✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt \
7454 "${MBOX}"
7455 check 1 0 "${MBOX}" '3720896054 3088'
7457 # `resend' test, reusing $MBOX
7458 printf "Resend ./.t2\nx\n" | ${MAILX} ${ARGS} -Rf "${MBOX}"
7459 check 2 0 ./.t2 '3720896054 3088'
7461 printf "resend ./.t3\nx\n" | ${MAILX} ${ARGS} -Rf "${MBOX}"
7462 check 3 0 ./.t3 '3979736592 3133'
7464 # And a primitive test for reading messages with invalid parameters
7465 ${cat} <<-_EOT > ./.tinv
7466 From a@b.invalid Wed May 15 12:43:00 2018
7467 MIME-Version: 1.0
7468 Content-Type: multipart/mixed; boundary="1"
7470 This is a multi-part message in MIME format.
7472 Content-Type: text/plain; charset=UTF-8
7473 Content-Transfer-Encoding: quoted-printable
7477 Content-Type: text/plain; name*17="na"; name*18="me-c-t"
7478 Content-Transfer-Encoding: 7bit
7479 Content-Disposition: inline
7482 --1--
7484 From a@b.invalid Wed May 15 12:43:00 2018
7485 MIME-Version: 1.0
7486 Content-Type: multipart/mixed; boundary="2"
7488 This is a multi-part message in MIME format.
7490 Content-Type: text/plain; charset=UTF-8
7491 Content-Transfer-Encoding: quoted-printable
7495 Content-Type: text/plain; name*17="na"; name*18="me-c-t"
7496 Content-Transfer-Encoding: 7bit
7497 Content-Disposition: inline;
7498 filename*0="na";
7499 filename*998999999999999999999999999999="me-c-d"
7502 --2--
7504 From a@b.invalid Wed May 15 12:43:00 2018
7505 MIME-Version: 1.0
7506 Content-Type: multipart/mixed; boundary="3"
7508 This is a multi-part message in MIME format.
7510 Content-Type: text/plain; charset=UTF-8
7511 Content-Transfer-Encoding: quoted-printable
7515 Content-Type: text/plain; name*17="na"; name*18="me-c-t"
7516 Content-Transfer-Encoding: 7bit
7517 Content-Disposition: inline;
7518 filename*0="na"; filename*998="me-c-d"
7521 --3--
7522 _EOT
7524 printf '\\#
7525 \\headerpick type ignore Content-Type Content-Disposition
7526 \\type 1 2 3
7527 \\xit
7528 ' | ${MAILX} ${ARGS} -Rf ./.tinv > ./.tall 2> ./.terr
7529 check 4 0 ./.tall '4094731083 905'
7530 if have_feat uistrings && have_feat iconv; then
7531 check 5 - ./.terr '3713266499 473'
7532 else
7533 t_echoskip '5:[!UISTRINGS or !ICONV]'
7536 t_epilog "${@}"
7539 t_mime_types_load_control() {
7540 t_prolog "${@}"
7542 if have_feat uistrings; then :; else
7543 t_echoskip '[!UISTRINGS]'
7544 t_epilog "${@}"
7545 return
7548 ${cat} <<-_EOT > ./.tmts1
7549 ? application/mathml+xml mathml
7550 _EOT
7551 ${cat} <<-_EOT > ./.tmts2
7552 ? x-conference/x-cooltalk ice
7553 ?t aga-aga aga
7554 ? application/aga-aga aga
7555 _EOT
7557 ${cat} <<-_EOT > ./.tmts1.mathml
7558 <head>nonsense ML</head>
7559 _EOT
7560 ${cat} <<-_EOT > ./.tmts2.ice
7561 Icy, icy road.
7562 _EOT
7563 printf 'of which the c\x01rack is coming soon' > ./.tmtsx.doom
7564 printf 'of which the c\x01rack is coming soon' > ./.tmtsx.aga
7566 printf '
7567 m %s
7568 Schub-di-du
7569 ~@ ./.tmts1.mathml
7570 ~@ ./.tmts2.ice
7571 ~@ ./.tmtsx.doom
7572 ~@ ./.tmtsx.aga
7574 File %s
7575 from*
7576 type
7578 ' "${MBOX}" "${MBOX}" |
7579 ${MAILX} ${ARGS} \
7580 -Smimetypes-load-control=f=./.tmts1,f=./.tmts2 \
7581 > ./.tout 2>&1
7582 check_ex0 1-estat
7583 ${cat} "${MBOX}" >> ./.tout
7584 check 1 - ./.tout '2128819500 2441'
7586 echo type | ${MAILX} ${ARGS} -R \
7587 -Smimetypes-load-control=f=./.tmts1,f=./.tmts3 \
7588 -f "${MBOX}" >> ./.tout 2>&1
7589 check 2 0 ./.tout '1125106528 3642'
7591 t_epilog "${@}"
7593 # }}}
7595 # Around state machine, after basics {{{
7596 t_alternates() {
7597 t_prolog "${@}"
7599 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" > ./.tall 2>&1
7600 commandalias x echo '$?/$^ERRNAME'
7601 commandalias y echo '$?/$^ERRNAME <$rv>'
7602 echo --0
7603 alternates;x
7604 alternates a1@b1 a2@b2 a3@b3;x
7605 alternates;x
7606 vput alternates rv;y
7608 echo --1
7609 unalternates a2@b2
7610 vput alternates rv;y
7611 unalternates a3@b3
7612 vput alternates rv;y
7613 unalternates a1@b1
7614 vput alternates rv;y
7616 echo --2
7617 unalternates *
7618 alternates a1@b1 a2@b2 a3@b3
7619 unalternates a3@b3
7620 vput alternates rv;y
7621 unalternates a2@b2
7622 vput alternates rv;y
7623 unalternates a1@b1
7624 vput alternates rv;y
7626 echo --3
7627 alternates a1@b1 a2@b2 a3@b3
7628 unalternates a1@b1
7629 vput alternates rv;y
7630 unalternates a2@b2
7631 vput alternates rv;y
7632 unalternates a3@b3
7633 vput alternates rv;y
7635 echo --4
7636 unalternates *
7637 alternates a1@b1 a2@b2 a3@b3
7638 unalternates *
7639 vput alternates rv;y
7641 echo --5
7642 unalternates *
7643 alternates a1@b1 a1@c1 a1@d1 a2@b2 a3@b3 a3@c3 a3@d3
7644 m a1@b1 a1@c1 a1@d1
7645 ~s all alternates, only a1@b1 remains
7646 ~c a2@b2
7647 ~b a3@b3 a3@c3 a3@d3
7648 ~r - '_EOT'
7649 This body is!
7650 This also body is!!
7651 _EOT
7654 echo --6
7655 unalternates *
7656 alternates a1@b1 a1@c1 a2@b2 a3@b3
7657 m a1@b1 a1@c1 a1@d1
7658 ~s a1@b1 a1@d1, and a3@c3 a3@d3 remain
7659 ~c a2@b2
7660 ~b a3@b3 a3@c3 a3@d3
7661 ~r - '_EOT'
7662 This body2 is!
7663 _EOT
7666 echo --7
7667 alternates a1@b1 a2@b2 a3; set allnet
7668 m a1@b1 a1@c1 a1@d1
7669 ~s all alternates via allnet, only a1@b1 remains
7670 ~c a2@b2
7671 ~b a3@b3 a3@c3 a3@d3
7672 ~r - '_EOT'
7673 This body3 is!
7674 _EOT
7677 echo --10
7678 unalternates *
7679 alternates a1@b1;x
7680 vput alternates rv;y
7681 alternates a2@b2;x
7682 vput alternates rv;y
7683 alternates a3@b3;x
7684 vput alternates rv;y
7685 alternates a4@b4;x
7686 vput alternates rv;y
7688 unalternates *
7689 vput alternates rv;y
7691 echo --11
7692 set posix
7693 alternates a1@b1 a2@b2;x
7694 vput alternates rv;y
7695 alternates a3@b3 a4@b4;x
7696 vput alternates rv;y
7697 __EOT
7699 check 1 0 "${MBOX}" '3901995195 542'
7700 if have_feat uistrings; then
7701 check 2 - .tall '1878598364 505'
7702 else
7703 t_echoskip '2:[!UISTRINGS]'
7706 # Automatic alternates, also from command line (freezing etc.)
7707 ${rm} "${MBOX}"
7708 ${cat} <<- __EOT > ./.tin
7709 From trouble-report@desy Wed Jun 6 20:19:28 2018
7710 Date: Wed, 06 Jun 2018 19:58:02 +0200
7711 From: a@b.org, b@b.org, c@c.org
7712 Sender: a@b.org
7713 To: b@b.org
7714 Cc: a@b.org, c@c.org
7715 Subject: test
7716 Message-ID: <20180606175802.dw-cn%a@b.org>
7718 sultry
7720 __EOT
7722 printf '#
7723 reply
7724 !^header remove to
7725 !^header remove cc
7726 !^header remove subject
7727 !^header insert to b@b.org
7728 !^header insert cc "a@b.org b@b.org c@c.org"
7729 my body
7731 ' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" -Sescape=! \
7732 -S from=a@b.org,b@b.org,c@c.org -S sender=a@b.org \
7733 -Rf ./.tin > ./.tall 2>&1
7734 check 3 0 "${MBOX}" '3184203976 265'
7735 check 4 - .tall '3604001424 44'
7737 # same, per command
7738 printf '#
7739 set from=a@b.org,b@b.org,c@c.org sender=a@b.org
7740 reply
7741 !^header remove to
7742 !^header remove cc
7743 !^header remove subject
7744 !^header insert to b@b.org
7745 !^header insert cc "a@b.org b@b.org c@c.org"
7746 my body
7748 ' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" -Sescape=! \
7749 -Rf ./.tin > ./.tall 2>&1
7750 check 5 0 "${MBOX}" '98184290 530'
7751 check 6 - .tall '3604001424 44'
7753 # And more, with/out -r (and that Sender: vanishs as necessary)
7754 # TODO -r should be the Sender:, which should automatically propagate to
7755 # TODO From: if possible and/or necessary. It should be possible to
7756 # TODO suppres -r stuff from From: and Sender:, but fallback to special -r
7757 # TODO arg as appropriate.
7758 # TODO For now we are a bit messy
7760 ${rm} "${MBOX}"
7761 </dev/null ${MAILX} ${ARGS} -Smta=test://"$MBOX" -s '-Sfrom + -r ++ test' \
7762 -c a@b.example -c b@b.example -c c@c.example \
7763 -S from=a@b.example,b@b.example,c@c.example \
7764 -S sender=a@b.example \
7765 -r a@b.example b@b.example ./.tout >./.tall 2>&1
7766 check 7 0 "${MBOX}" '4275947318 181'
7767 check 8 - .tout '4275947318 181'
7768 check 9 - .tall '4294967295 0'
7770 </dev/null ${MAILX} ${ARGS} -Smta=test://"$MBOX" -s '-Sfrom + -r ++ test' \
7771 -c a@b.example -c b@b.example -c c@c.example \
7772 -S from=a@b.example,b@b.example,c@c.example \
7773 -S sender=a2@b.example \
7774 -r a@b.example b@b.example ./.tout >./.tall 2>&1
7775 check 10 0 "${MBOX}" '1189494079 383'
7776 check 11 - .tout '1189494079 383'
7777 check 12 - .tall '4294967295 0'
7779 </dev/null ${MAILX} ${ARGS} -Smta=test://"$MBOX" -s '-Sfrom + -r ++ test' \
7780 -c a@b.example -c b@b.example -c c@c.example \
7781 -S from=a@b.example,b@b.example,c@c.example \
7782 -S sender=a@b.example \
7783 b@b.example >./.tall 2>&1
7784 check 13 0 "${MBOX}" '2253033142 610'
7785 check 14 - .tall '4294967295 0'
7787 t_epilog "${@}"
7790 t_cmd_escapes() {
7791 # quote and cmd escapes because this (since Mail times) is worked in the
7792 # big collect() monster of functions
7793 t_prolog "${@}"
7795 echo 'included file' > ./.ttxt
7796 { t__x1_msg && t__x2_msg && t__x3_msg &&
7797 t__gen_msg from 'ex4@am.ple' subject sub4 &&
7798 t__gen_msg from 'eximan <ex5@am.ple>' subject sub5 &&
7799 t__gen_mimemsg from 'ex6@am.ple' subject sub6; } > ./.tmbox
7800 check 1 - ./.tmbox '517368276 2182'
7802 # ~@ is tested with other attachment stuff, ~^ is in compose_edits + digmsg
7803 printf '#
7804 set Sign=SignVar sign=signvar DEAD=./.ttxt
7805 set forward-inject-head quote-inject-head
7806 headerpick type retain Subject
7807 headerpick forward retain Subject To
7808 reply 2
7809 !!1 Not escaped. And shell test last, right before !..
7810 !:echo 1
7811 !: echo 2 only echoed via colon
7812 !:echo 2:$?/$^ERRNAME
7813 !_ echo 3 only echoed via underscore
7814 !:echo 3:$?/$^ERRNAME
7815 !< ./.ttxt
7816 !:echo 4:$?/$^ERRNAME
7817 !<! echo 5 shell echo included
7818 !:echo 5:$?/$^ERRNAME
7819 !| echo 6 pipecmd-pre; cat; echo 6 pipecmd-post
7820 !:echo 6:$?/$^ERRNAME
7821 7 and 8 are ~A and ~a:
7823 !:echo 7:$?/$^ERRNAME
7825 !:echo 8:$?/$^ERRNAME
7826 !b 9 added ~b cc <ex1@am.ple>
7827 !:echo 9:$?/$^ERRNAME
7828 !c 10 added ~c c <ex2@am.ple>
7829 !:echo 10:$?/$^ERRNAME
7830 11 next ~d / $DEAD
7832 !:echo 11:$?/$^ERRNAME
7833 12: ~F
7835 !:echo 12:$?/$^ERRNAME
7836 13: ~F 1 3
7837 !F 1 3
7838 !:echo 13:$?/$^ERRNAME
7839 !F 1000
7840 !:echo 13-1:$?/$^ERRNAME; set posix
7841 14: ~f (headerpick: subject)
7843 !:echo 14:$?/$^ERRNAME; unset posix forward-inject-head quote-inject-head
7844 14.1: ~f (!posix: injections; headerpick: subject to)
7846 !:echo 14.1:$?/$^ERRNAME; set forward-add-cc
7847 14.2: ~f (!posix: headerpick: subject to; forward-add-cc adds mr3)
7848 !f 3
7849 !:echo 14.2:$?/$^ERRNAME; set fullnames
7850 14.3: ~f (!posix: headerpick: subject to; forward-add-cc adds mr1 fullname)
7851 !f 1
7852 !:echo 14.3:$?/$^ERRNAME; set nofullnames noforward-add-cc posix
7853 15: ~f 1
7854 !f 1
7855 !:echo 15:$?/$^ERRNAME
7856 15.5: nono: ~H, ~h
7858 !:echo 15.5-1:$?/$^ERRNAME
7860 !:echo 15.5-2:$?/$^ERRNAME
7861 16, 17: ~I Sign, ~i Sign
7862 !I Sign
7863 !:echo 16:$?/$^ERRNAME
7864 !i Sign
7865 !:echo 17:$?/$^ERRNAME
7866 18: ~M
7868 !:echo 18:$?/$^ERRNAME # XXX forward-add-cc: not expl. tested
7869 19: ~M 1
7870 !M 1
7871 !:echo 19:$?/$^ERRNAME
7872 20: ~m
7874 !:echo 20:$?/$^ERRNAME # XXX forward-add-cc: not expl. tested
7875 21: ~m 3
7876 !m 3
7877 !:echo 21:$?/$^ERRNAME
7878 !: # Initially ~Q was _exactly_ like
7879 28,29 nothing, 30-34: ~Q
7880 !:echo quote=<$quote>
7881 30: ~Q
7883 !:echo 30:$?/$^ERRNAME
7884 31: ~Q 1 3
7885 !Q 1 3
7886 !:echo 31:$?/$^ERRNAME
7887 set quote-inject-head quote-inject-tail indentprefix
7888 !:wysh set quote-inject-head=%%a quote-inject-tail=--%%r
7889 32: ~Q
7891 !:echo 32:$?/$^ERRNAME
7892 set noquote-inject-head noquote-inject-tail quote-add-cc
7893 !:set noquote-inject-head noquote-inject-tail quote-add-cc
7894 33: ~Q 4
7895 !Q 4
7896 !:echo 33:$?/$^ERRNAME
7897 set fullnames
7898 !:set fullnames
7899 34: ~Q 5
7900 !Q 5
7901 !:echo 34:$?/$^ERRNAME
7902 unset fullnames, quote stuff
7903 !:unset quote quote-add-cc fullnames
7904 22: ~R ./.ttxt
7905 !R ./.ttxt
7906 !:echo 22:$?/$^ERRNAME
7907 23: ~r ./.ttxt
7908 !r ./.ttxt
7909 !:echo 23:$?/$^ERRNAME
7910 24: ~s this new subject
7911 !s 24 did new ~s ubject
7912 !:echo 24:$?/$^ERRNAME
7913 !t 25 added ~t o <ex3@am.ple>
7914 !:echo 25:$?/$^ERRNAME
7915 26.1: ~U
7917 !:echo 26.1:$?/$^ERRNAME
7918 26.2: ~U 1
7919 !U 1
7920 !:echo 26.2:$?/$^ERRNAME # XXX forward-add-cc: not expl. tested
7921 27.1: ~u
7923 !:echo 27.1:$?/$^ERRNAME
7924 27.2: ~u 1
7925 !u 1
7926 !:echo 27.2:$?/$^ERRNAME # XXX forward-add-cc: not expl. tested
7927 and i ~w rite this out to ./.tmsg
7928 !w ./.tmsg
7929 !:echo i ~w:$?/$^ERRNAME
7930 !:wysh set x=$escape;set escape=~
7931 ~!echo shell command output
7932 ~:echo shell:$?/$^ERRNAME
7933 ~:wysh set escape=$x
7934 50:F
7935 !F 6
7936 !:echo 50 was F:$?/$^ERRNAME
7937 51:f
7938 !f 6
7939 !:echo 51 was f:$?/$^ERRNAME
7940 52:M
7941 !M 6
7942 !:echo 52 was M:$?/$^ERRNAME
7943 53:m
7944 !m 6
7945 !:echo 53 was m:$?/$^ERRNAME; set quote
7946 54:Q
7947 !Q 6
7948 !:echo 54 was Q:$?/$^ERRNAME
7949 55:U
7950 !U 6
7951 !:echo 55 was U:$?/$^ERRNAME
7952 56:u
7953 !u 6
7954 !:echo 56 was u:$?/$^ERRNAME
7956 ' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" -Rf \
7957 -Sescape=! -Sindentprefix=' |' \
7958 ./.tmbox >./.tall 2>./.terr
7959 check_ex0 2-estat
7960 ${cat} ./.tall >> "${MBOX}"
7961 have_feat filter-html-tagsoup && ck='3877629593 7699' ||
7962 ck='2138694045 7943'
7963 check 2 - "${MBOX}" "${ck}"
7965 if have_feat uistrings && have_feat iconv; then
7966 check 2-err - ./.terr '3575876476 49'
7967 else
7968 t_echoskip '2-err:[!UISTRINGS or !ICONV]'
7970 check 3 - ./.tmsg '3502750368 4445'
7972 # Simple return/error value after *expandaddr* failure test
7973 have_feat filter-html-tagsoup && ck='115245837 7900' ||
7974 ck='2245417271 8144'
7975 printf 'body
7976 !:echo --one
7977 !s This a new subject is
7978 !:set expandaddr=-name
7979 !t two@to.invalid
7980 !:echo $?/$^ERRNAME
7981 !:echo --two
7982 !c no-name-allowed
7983 !:echo $?/$^ERRNAME
7984 !c one@cc.invalid
7985 !:echo $?/$^ERRNAME
7986 !:echo --three
7987 !:alias abcc one@bcc.invalid
7988 !b abcc
7989 !:echo $?/$^ERRNAME
7990 !:set expandaddr=+addr
7991 !b abcc
7992 !:echo $!/$?/$^ERRNAME
7994 ' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
7995 -Sescape=! \
7996 -s testsub one@to.invalid >./.tall 2>&1
7997 check 4 0 "${MBOX}" "${ck}"
7998 if have_feat uistrings; then
7999 check 5 - ./.tall '2336041127 212'
8000 else
8001 check 5 - ./.tall '1818580177 59'
8004 # Modifiers and whitespace indulgence
8005 printf 'body
8006 !:remove '"${MBOX}"'
8007 ! :echo one
8008 ! <./.ttxts
8009 ! :echo two
8010 ! : set i=./.ttxts
8011 ! - $ < $i
8012 !:echo three
8013 ! : set \\
8014 errexit
8015 ! - $ < $i
8016 ! : echo four
8017 !$< ./.ttxts
8018 ! : echo five
8019 ' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
8020 -Sescape=! \
8021 -Spwd="`${pwd}`" \
8022 -s testsub one@to.invalid >./.tall 2>./.terr
8023 check 6 4 ./.tall '686767281 95'
8024 [ -f "${MBOX}" ]; check_exn0 7
8025 if have_feat uistrings; then
8026 check 8 - ./.terr '1304637795 199'
8027 else
8028 t_echoskip '8:[!UISTRINGS]'
8031 t_epilog "${@}"
8034 t_compose_edits() { # XXX very rudimentary
8035 # after: t_cmd_escapes
8036 t_prolog "${@}"
8038 # Something to use as "editor"
8039 ${cat} <<-_EOT > ./.ted.sh
8040 #!${SHELL}
8041 ${cat} <<-__EOT > \${1}
8042 Fcc: .tout1
8044 Fcc: .tout2
8045 Subject: Fcc test 1
8046 Fcc: .tout3
8048 A body
8049 __EOT
8050 exit 0
8051 _EOT
8052 ${chmod} 0755 .ted.sh
8054 # > All these are in-a-row!
8056 printf 'mail ./.tout\n~s This subject is\nThis body is\n~.' |
8057 ${MAILX} ${ARGS} -Seditheaders >./.tall 2>&1
8058 check 1 0 ./.tout '3993703854 127'
8059 check 2 - ./.tall '4294967295 0'
8061 ${mv} ./.tall ./.tout
8062 printf 'mail ./.tout\n~s This subject is\nThis body is\n~e\n~.' |
8063 ${MAILX} ${ARGS} -Seditheaders -SEDITOR=./.ted.sh >./.tall 2>&1
8064 check 3 0 ./.tout1 '285981670 116'
8065 check 4 - ./.tout2 '285981670 116'
8066 check 5 - ./.tout3 '285981670 116'
8067 check 6 - ./.tout '4294967295 0'
8068 check 7 - ./.tall '4294967295 0'
8069 ${rm} ./.tout1 ./.tout2 ./.tout3
8071 # Note t_compose_hooks adds ~^ stress tests
8072 ${mv} ./.tout ./.tout1
8073 ${mv} ./.tall ./.tout2
8074 printf '#
8075 mail ./.tout\n!s This subject is\nThis body is
8076 !^header
8077 !^header list
8078 !^header list fcc
8079 !^header show fcc
8080 !^header remove to
8081 !^header insert fcc ./.tout
8082 !^header insert fcc .tout1
8083 !^header insert fcc ./.tout2
8084 !^header list
8085 !^header show fcc
8086 !^header remove-at fcc 2
8087 !^header remove-at fcc 2
8088 !^header show fcc
8089 !^head remove fcc
8090 !^header show fcc
8091 !^header insert fcc ./.tout
8092 !^header show fcc
8093 !^header list
8095 ' | ${MAILX} ${ARGS} -Sescape=! >./.tall 2>&1
8096 check 8 0 ./.tout '3993703854 127'
8097 check 9 - ./.tout1 '4294967295 0'
8098 check 10 - ./.tout2 '4294967295 0'
8099 check 11 - ./.tall '1857504914 342'
8101 # < No longer in-a-row
8103 ${cat} <<-_EOT | ${MAILX} ${ARGS} -t >./.tall 2>&1
8104 Fcc: .ttout
8105 Subject: Fcc via -t test
8107 My body
8108 _EOT
8109 check 12 0 ./.ttout '1289478830 122'
8110 check 13 - ./.tall '4294967295 0'
8112 # This test assumes code of `^' and `digmsg' is shared: see t_digmsg()
8113 echo 'b 1' > ./.t' x 1'
8114 echo 'b 2' > ./.t' x 2'
8115 printf '#
8116 mail ./.tatt
8117 !^header insert subject subject
8118 !:set i="./.t x 1"
8119 !^header list
8120 !:echo =0
8121 !^attachment
8122 !:echo =1
8123 !^attachment insert "$i"
8124 !:echo =2
8125 !^attachment
8126 !:echo =3
8127 !^attachment list
8128 !:echo =4
8129 !^attachment insert '"'"'./.t x 2'"'"'
8130 !:echo =5
8131 !^attachment list
8132 !:echo =6
8133 !^attachment remove "$i"
8134 !:echo =7
8135 !^attachment list
8136 !:echo =8
8137 !^attachment insert $'"'"'\\$i'"'"'
8138 !:echo =10
8139 !^attachment list
8140 !:echo =11
8141 !^header list
8142 !:echo =12
8143 !^a a $i
8144 !:echo =13
8145 !^a attribute-set "$i" filenames " cannot wait for you "
8146 !:echo =14
8147 !^a a $i
8148 !:echo =15
8149 !^a attribute-set "$i" filename " cannot wait for you "
8150 !:echo =16
8151 !^a a $i
8152 !:echo =17
8153 !^a attribute-at 2
8154 !:echo =18
8155 !^a attribute-set-at 2 "filename" "private eyes"
8156 !:echo =19
8157 !^a attribute-at 2
8158 !:echo =20
8159 !^a attribute-set-at 2 content-description "private c-desc"
8160 !:echo =21
8161 !^a attribute-at 2
8162 !:echo =22
8163 !^a attribute-set-at 2 content-ID "priv invd c-id"
8164 !:echo =23
8165 !^a attribute-at 2
8166 !:echo =24
8167 !^a attribute-set-at 2 content-TyPE tExT/mARkLO
8168 !:echo =25
8169 !^a attribute-at 2
8170 !:echo =26
8171 !^a attribute-set-at 2 content-TyPE ""
8172 !:echo =27
8173 !^a attribute-at 2
8174 !:echo =28
8176 ' | ${MAILX} ${ARGS} -Sescape=! >./.tall 2>&1
8177 check 14 0 ./.tall '3491667030 1565'
8178 check 15 - ./.tatt '1685063733 636'
8180 t_epilog "${@}"
8183 t_digmsg() { # XXX rudimentary; <> compose_edits()?
8184 t_prolog "${@}"
8186 printf '#
8187 mail ./.tout\n!s This subject is\nThis body is
8188 !:echo --one
8189 !:digmsg create - -
8190 !:digmsg - header list
8191 !:digmsg - header show subject
8192 !:digmsg - header show to
8193 !:digmsg - header remove to
8194 !:digmsg - header list
8195 !:digmsg - header show to
8196 !:digmsg remove -
8197 !:echo --two
8198 !:digmsg create -
8199 !:digmsg - header list; readall x; echon "<$x>";
8200 !:digmsg - header show subject;readall x;echon "<$x>";;
8201 !:digmsg remove -
8202 !:echo --three
8203 !: # nothing here as is comment
8204 !^header insert fcc ./.tbox
8205 !:echo --four
8206 !:digmsg create - -
8207 !:digmsg - header list
8208 !:digmsg - header show fcc
8209 !:echo --five
8210 !^head remove fcc
8211 !:echo --six
8212 !:digmsg - header list
8213 !:digmsg - header show fcc
8214 !:digmsg - header insert fcc ./.tfcc
8215 !:echo --seven
8216 !:digmsg remove -
8217 !:echo bye
8219 echo --hello again
8220 File ./.tfcc
8221 echo --one
8222 digmsg create 1 -
8223 digmsg 1 header list
8224 digmsg 1 header show subject
8225 echo --two
8226 ! : > ./.tempty
8227 File ./.tempty
8228 echo --three
8229 digmsg 1 header list; echo $?/$^ERRNAME
8230 digmsg create -; echo $?/$^ERRNAME
8231 echo ==========
8232 ! %s ./.tfcc > ./.tcat
8233 ! %s "s/This subject is/There subject was/" < ./.tfcc >> ./.tcat
8234 File ./.tcat
8235 mail nowhere@exam.ple
8236 !:echo ===1
8237 !:digmsg create -; echo $?/$^ERRNAME;\\
8238 digmsg create 1; echo $?/$^ERRNAME;\\
8239 digmsg create 2; echo $?/$^ERRNAME
8240 !:echo ===2.1
8241 !:digmsg - h l;echo $?/$^ERRNAME;readall d;echo "$?/$^ERRNAME <$d>"
8242 !:echo =2.2
8243 !:digmsg 1 h l;echo $?/$^ERRNAME;readall d;echo "$?/$^ERRNAME <$d>"
8244 !:echo =2.3
8245 !^ h l
8246 !:echo =2.4
8247 !:digmsg 2 h l;echo $?/$^ERRNAME;readall d;echo "$?/$^ERRNAME <$d>"
8248 !:echo ===3.1
8249 !:digmsg - h s to;echo $?/$^ERRNAME;readall d;echo "$?/$^ERRNAME <$d>"
8250 !:echo =3.2
8251 !:digmsg 1 h s subject;echo $?/$^ERRNAME;readall d;echo "$?/$^ERRNAME <$d>"
8252 !:echo =3.3
8253 !^ h s to
8254 !:echo =3.4
8255 !:digmsg 2 h s subject;echo $?/$^ERRNAME;readall d;echo "$?/$^ERRNAME <$d>"
8256 !:echo ==4.1
8257 !:digmsg remove -; echo $?/$^ERRNAME;\\
8258 digmsg remove 1; echo $?/$^ERRNAME;\\
8259 digmsg remove 2; echo $?/$^ERRNAME;
8261 echo ======= new game new fun!
8262 mail one@to.invalid
8263 !s hossa
8264 !:set expandaddr=-name
8265 !:echo -oneo
8266 !^ header insert to two@to.invalid
8267 !:echo $?/$^ERRNAME
8268 !:echo --two
8269 !^ header insert cc no-name-allowed
8270 !:echo $?/$^ERRNAME
8271 !^ header insert cc one@cc.invalid
8272 !:echo $?/$^ERRNAME
8273 !:echo --three
8274 !:alias abcc one@bcc.invalid
8275 !^ header insert bcc abcc
8276 !:echo $?/$^ERRNAME
8277 !:set expandaddr=+addr
8278 !^ header insert bcc abcc
8279 !:echo $!/$?/$^ERRNAME
8281 echo --bye
8282 ' "${cat}" "${sed}" |
8283 ${MAILX} ${ARGS} -Smta=test://"$MBOX" -Sescape=! >./.tall 2>&1
8284 check 1 0 "$MBOX" '665881681 179'
8285 have_feat uistrings && i='4159482825 1372' || i='2254509488 1103'
8286 check 2 - ./.tall "${i}"
8287 check 3 - ./.tfcc '3993703854 127'
8288 check 4 - ./.tempty '4294967295 0'
8289 check 5 - ./.tcat '2157992522 256'
8291 t_epilog "${@}"
8294 t_on_main_loop_tick() {
8295 t_prolog "${@}"
8297 if have_feat cmd-vexpr; then :; else
8298 t_echoskip '[!CMD_VEXPR]'
8299 t_epilog "${@}"
8300 return
8303 printf '#
8304 echo hello; set i=1
8305 define bla {
8306 echo bla1
8307 echo bla2
8309 define omlt {
8310 echo in omlt: $i
8311 vput vexpr i + 1 $i
8313 echo one
8314 set on-main-loop-tick=omlt
8315 echo two
8316 echo three
8317 echo calling bla;call bla
8318 echo four
8319 echo --bye;xit' |
8320 ${MAILX} ${ARGS} -Smta=test://"$MBOX" -Sescape=! >./.tall 2>&1
8321 check 1 0 ./.tall '3697651500 130'
8323 t_epilog "${@}"
8326 t_on_program_exit() {
8327 t_prolog "${@}"
8329 ${MAILX} ${ARGS} \
8330 -X 'define x {' -X 'echo jay' -X '}' -X x -Son-program-exit=x \
8331 > ./.tall 2>&1
8332 check 1 0 ./.tall '2820891503 4'
8334 ${MAILX} ${ARGS} \
8335 -X 'define x {' -X 'echo jay' -X '}' -X q -Son-program-exit=x \
8336 > ./.tall 2>&1
8337 check 2 0 ./.tall '2820891503 4'
8339 </dev/null ${MAILX} ${ARGS} \
8340 -X 'define x {' -X 'echo jay' -X '}' -Son-program-exit=x \
8341 > ./.tall 2>&1
8342 check 3 0 ./.tall '2820891503 4'
8344 </dev/null ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
8345 -X 'define x {' -X 'echo jay' -X '}' -Son-program-exit=x \
8346 -s subject -. hey@you \
8347 > ./.tall 2>&1
8348 check 4 0 ./.tall '2820891503 4'
8349 check 5 - "$MBOX" '561900352 118'
8351 t_epilog "${@}"
8353 # }}}
8355 # Heavy use of/rely on state machine (behaviour) and basics {{{
8356 t_compose_hooks() { # {{{ TODO monster
8357 t_prolog "${@}"
8359 if have_feat uistrings &&
8360 have_feat cmd-csop && have_feat cmd-vexpr; then :; else
8361 t_echoskip '[!UISTRINGS/!CMD_CSOP/!CMD_VEXPR]'
8362 t_epilog "${@}"
8363 return
8366 (echo line one&&echo line two&&echo line three) > ./.treadctl
8367 (echo echo four&&echo echo five&&echo echo six) > ./.tattach
8369 # Supposed to extend t_compose_edits with ~^ stress tests!
8370 ${cat} <<'__EOT__' > ./.trc
8371 define bail {
8372 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
8374 define xerr {
8375 vput csop es substr "$1" 0 1
8376 if [ "$es" != 2 ]
8377 xcall bail "$2: $1"
8380 define read_mline_res {
8381 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
8382 echo $len/$es/$^ERRNAME: $hl
8383 if [ $es -ne $^ERR-NONE ]
8384 xcall bail read_mline_res
8385 elif [ $len -ne 0 ]
8386 \xcall read_mline_res
8389 define ins_addr {
8390 wysh set xh=$1
8391 echo "~^header list"; read hl; echo $hl;\
8392 call xerr "$hl" "in_addr ($xh) 0-1"
8394 echo "~^header insert $xh 'diet <$xh@exam.ple> spliced'";\
8395 read es; echo $es; call xerr "$es" "ins_addr $xh 1-1"
8396 echo "~^header insert $xh <${xh}2@exam.ple>";\
8397 read es; echo $es; call xerr "$es" "ins_addr $xh 1-2"
8398 echo "~^header insert $xh ${xh}3@exam.ple";\
8399 read es; echo $es; call xerr "$es" "ins_addr $xh 1-3"
8400 echo "~^header list $xh"; read hl; echo $hl;\
8401 call xerr "$hl" "ins_addr $xh 1-4"
8402 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 1-5"
8403 call read_mline_res
8405 if [ "$t_remove" == "" ]
8406 return
8409 echo "~^header remove $xh"; read es; call xerr $es "ins_addr $xh 2-1"
8410 echo "~^header remove $xh"; read es; vput csop es substr $es 0 3
8411 if [ $es != 501 ]
8412 xcall bail "ins_addr $xh 2-2"
8414 echo "~^header list $xh"; read es; vput csop es substr $es 0 3
8415 if [ $es != 501 ]
8416 xcall bail "ins_addr $xh 2-3"
8418 echo "~^header show $xh"; read es; vput csop es substr $es 0 3
8419 if [ $es != 501 ]
8420 xcall bail "ins_addr $xh 2-4"
8424 echo "~^header insert $xh 'diet <$xh@exam.ple> spliced'";\
8425 read es; echo $es; call xerr "$es" "ins_addr $xh 3-1"
8426 echo "~^header insert $xh <${xh}2@exam.ple>";\
8427 read es; echo $es; call xerr "$es" "ins_addr $xh 3-2"
8428 echo "~^header insert $xh ${xh}3@exam.ple";\
8429 read es; echo $es; call xerr "$es" "ins_addr $xh 3-3"
8430 echo "~^header list $xh"; read hl; echo $hl;\
8431 call xerr "$hl" "ins_addr $xh 3-4"
8432 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 3-5"
8433 call read_mline_res
8435 echo "~^header remove-at $xh 1"; read es;\
8436 call xerr $es "ins_addr $xh 3-6"
8437 echo "~^header remove-at $xh 1"; read es;\
8438 call xerr $es "ins_addr $xh 3-7"
8439 echo "~^header remove-at $xh 1"; read es;\
8440 call xerr $es "ins_addr $xh 3-8"
8441 echo "~^header remove-at $xh 1"; read es;\
8442 vput csop es substr $es 0 3
8443 if [ $es != 501 ]
8444 xcall bail "ins_addr $xh 3-9"
8446 echo "~^header remove-at $xh T"; read es;\
8447 vput csop es substr $es 0 3
8448 if [ $es != 505 ]
8449 xcall bail "ins_addr $xh 3-10"
8451 echo "~^header list $xh"; read es;\
8452 vput csop es substr $es 0 3
8453 if [ $es != 501 ]
8454 xcall bail "ins_addr $xh 3-11"
8456 echo "~^header show $xh"; read es;\
8457 vput csop es substr $es 0 3
8458 if [ $es != 501 ]
8459 xcall bail "ins_addr $xh 3-12"
8463 echo "~^header insert $xh 'diet <$xh@exam.ple> spliced'";\
8464 read es; echo $es; call xerr "$es" "ins_addr $xh 4-1"
8465 echo "~^header insert $xh <${xh}2@exam.ple>\ (comment)\ \\\"Quot(e)d\\\"";\
8466 read es; echo $es; call xerr "$es" "ins_addr $xh 4-2"
8467 echo "~^header insert $xh ${xh}3@exam.ple";\
8468 read es; echo $es; call xerr "$es" "ins_addr $xh 4-3"
8469 echo "~^header list $xh"; read hl; echo $hl;\
8470 call xerr "$hl" "header list $xh 3-4"
8471 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 4-5"
8472 call read_mline_res
8474 echo "~^header remove-at $xh 3"; read es;\
8475 call xerr $es "ins_addr $xh 4-6"
8476 echo "~^header remove-at $xh 2"; read es;\
8477 call xerr $es "ins_addr $xh 4-7"
8478 echo "~^header remove-at $xh 1"; read es;\
8479 call xerr $es "ins_addr $xh 4-8"
8480 echo "~^header remove-at $xh 1"; read es;\
8481 vput csop es substr $es 0 3
8482 if [ $es != 501 ]
8483 xcall bail "ins_addr $xh 4-9"
8485 echo "~^header remove-at $xh T"; read es;\
8486 vput csop es substr $es 0 3
8487 if [ $es != 505 ]
8488 xcall bail "ins_addr $xh 4-10"
8490 echo "~^header list $xh"; read es;\
8491 vput csop es substr $es 0 3
8492 if [ $es != 501 ]
8493 xcall bail "ins_addr $xh 4-11"
8495 echo "~^header show $xh"; read es;\
8496 vput csop es substr $es 0 3
8497 if [ $es != 501 ]
8498 xcall bail "ins_addr $xh 4-12"
8501 define ins_ref {
8502 wysh set xh=$1 mult=$2
8503 echo "~^header list"; read hl; echo $hl;\
8504 call xerr "$hl" "ins_ref ($xh) 0-1"
8506 echo "~^header insert $xh <$xh@exam.ple>";\
8507 read es; echo $es; call xerr "$es" "ins_ref $xh 1-1"
8508 if [ $mult -ne 0 ]
8509 echo "~^header insert $xh <${xh}2@exam.ple>";\
8510 read es; echo $es; call xerr "$es" "ins_ref $xh 1-2"
8511 echo "~^header insert $xh ${xh}3@exam.ple";\
8512 read es; echo $es; call xerr "$es" "ins_ref $xh 1-3"
8513 else
8514 echo "~^header insert $xh <${xh}2@exam.ple>"; read es;\
8515 vput csop es substr $es 0 3
8516 if [ $es != 506 ]
8517 xcall bail "ins_ref $xh 1-4"
8521 echo "~^header list $xh"; read hl; echo $hl;\
8522 call xerr "$hl" "ins_ref $xh 1-5"
8523 echo "~^header show $xh"; read es; call xerr $es "ins_ref $xh 1-6"
8524 call read_mline_res
8526 if [ "$t_remove" == "" ]
8527 return
8530 echo "~^header remove $xh"; read es;\
8531 call xerr $es "ins_ref $xh 2-1"
8532 echo "~^header remove $xh"; read es;\
8533 vput csop es substr $es 0 3
8534 if [ $es != 501 ]
8535 xcall bail "ins_ref $xh 2-2"
8537 echo "~^header list $xh"; read es;\
8538 vput csop es substr $es 0 3
8539 if [ $es != 501 ]
8540 xcall bail "$es ins_ref $xh 2-3"
8542 echo "~^header show $xh"; read es;\
8543 vput csop es substr $es 0 3
8544 if [ $es != 501 ]
8545 xcall bail "ins_ref $xh 2-4"
8549 echo "~^header insert $xh <$xh@exam.ple>";\
8550 read es; echo $es; call xerr "$es" "ins_ref $xh 3-1"
8551 if [ $mult -ne 0 ]
8552 echo "~^header insert $xh <${xh}2@exam.ple>";\
8553 read es; echo $es; call xerr "$es" "ins_ref $xh 3-2"
8554 echo "~^header insert $xh ${xh}3@exam.ple";\
8555 read es; echo $es; call xerr "$es" "ins_ref $xh 3-3"
8557 echo "~^header list $xh";\
8558 read hl; echo $hl; call xerr "$hl" "ins_ref $xh 3-4"
8559 echo "~^header show $xh";\
8560 read es; call xerr $es "ins_ref $xh 3-5"
8561 call read_mline_res
8563 echo "~^header remove-at $xh 1"; read es;\
8564 call xerr $es "ins_ref $xh 3-6"
8565 if [ $mult -ne 0 ] && [ $xh != subject ]
8566 echo "~^header remove-at $xh 1"; read es;\
8567 call xerr $es "ins_ref $xh 3-7"
8568 echo "~^header remove-at $xh 1"; read es;\
8569 call xerr $es "ins_ref $xh 3-8"
8571 echo "~^header remove-at $xh 1"; read es;\
8572 vput csop es substr $es 0 3
8573 if [ $es != 501 ]
8574 xcall bail "ins_ref $xh 3-9"
8576 echo "~^header remove-at $xh T"; read es;\
8577 vput csop es substr $es 0 3
8578 if [ $es != 505 ]
8579 xcall bail "ins_ref $xh 3-10"
8581 echo "~^header show $xh"; read es;\
8582 vput csop es substr $es 0 3
8583 if [ $es != 501 ]
8584 xcall bail "ins_ref $xh 3-11"
8588 echo "~^header insert $xh <$xh@exam.ple> ";\
8589 read es; echo $es; call xerr "$es" "ins_ref $xh 4-1"
8590 if [ $mult -ne 0 ]
8591 echo "~^header insert $xh <${xh}2@exam.ple> ";\
8592 read es; echo $es; call xerr "$es" "ins_ref $xh 4-2"
8593 echo "~^header insert $xh ${xh}3@exam.ple";\
8594 read es; echo $es; call xerr "$es" "ins_ref $xh 4-3"
8596 echo "~^header list $xh"; read hl; echo $hl;\
8597 call xerr "$hl" "ins_ref $xh 4-4"
8598 echo "~^header show $xh"; read es; call xerr $es "ins_ref $xh 4-5"
8599 call read_mline_res
8601 if [ $mult -ne 0 ] && [ $xh != subject ]
8602 echo "~^header remove-at $xh 3"; read es;\
8603 call xerr $es "ins_ref $xh 4-6"
8604 echo "~^header remove-at $xh 2"; read es;\
8605 call xerr $es "ins_ref $xh 4-7"
8607 echo "~^header remove-at $xh 1"; read es;\
8608 call xerr $es "ins_ref $xh 4-8"
8609 echo "~^header remove-at $xh 1"; read es;\
8610 vput csop es substr $es 0 3
8611 if [ $es != 501 ]
8612 xcall bail "ins_ref $xh 4-9"
8614 echo "~^header remove-at $xh T"; read es;\
8615 vput csop es substr $es 0 3
8616 if [ $es != 505 ]
8617 xcall bail "ins_ref $xh 4-10"
8619 echo "~^header show $xh"; read es;\
8620 vput csop es substr $es 0 3
8621 if [ $es != 501 ]
8622 xcall bail "ins_ref $xh 4-11"
8625 define t_header {
8626 echo t_header ENTER
8627 # In collect.c order
8628 call ins_addr from
8629 call ins_ref sender 0 # Not a "ref", but works
8630 call ins_addr To
8631 call ins_addr cC
8632 call ins_addr bCc
8633 call ins_addr reply-To
8634 call ins_addr mail-Followup-to
8635 call ins_ref messAge-id 0
8636 call ins_ref rEfErEncEs 1
8637 call ins_ref in-Reply-to 1
8638 call ins_ref subject 1 # Not a "ref", but works (with tweaks)
8639 call ins_addr freeForm1
8640 call ins_addr freeform2
8642 echo "~^header show MAILX-Command"; read es; call xerr $es "t_header 1000"
8643 call read_mline_res
8644 echo "~^header show MAILX-raw-TO"; read es; call xerr $es "t_header 1001"
8645 call read_mline_res
8647 echo t_header LEAVE
8649 define t_attach {
8650 echo t_attach ENTER
8652 echo "~^attachment";\
8653 read hl; echo $hl; vput csop es substr "$hl" 0 3
8654 if [ "$es" != 501 ]
8655 xcall bail "attach 0-1"
8658 echo "~^attach attribute ./.treadctl";\
8659 read hl; echo $hl; vput csop es substr "$hl" 0 3
8660 if [ "$es" != 501 ]
8661 xcall bail "attach 0-2"
8663 echo "~^attachment attribute-at 1";\
8664 read hl; echo $hl; vput csop es substr "$hl" 0 3
8665 if [ "$es" != 501 ]
8666 xcall bail "attach 0-3"
8669 echo "~^attachment insert ./.treadctl=ascii";\
8670 read hl; echo $hl; call xerr "$hl" "attach 1-1"
8671 echo "~^attachment list";\
8672 read es; echo $es;call xerr "$es" "attach 1-2"
8673 call read_mline_res
8674 echo "~^attachment attribute ./.treadctl";\
8675 read es; echo $es;call xerr "$es" "attach 1-3"
8676 call read_mline_res
8677 echo "~^attachment attribute .treadctl";\
8678 read es; echo $es;call xerr "$es" "attach 1-4"
8679 call read_mline_res
8680 echo "~^attachment attribute-at 1";\
8681 read es; echo $es;call xerr "$es" "attach 1-5"
8682 call read_mline_res
8684 echo "~^attachment attribute-set ./.treadctl filename rctl";\
8685 read es; echo $es;call xerr "$es" "attach 1-6"
8686 echo "~^attachment attribute-set .treadctl content-description Au";\
8687 read es; echo $es;call xerr "$es" "attach 1-7"
8688 echo "~^attachment attribute-set-at 1 content-id <10.du@ich>";\
8689 read es; echo $es;call xerr "$es" "attach 1-8"
8691 echo "~^attachment attribute ./.treadctl";\
8692 read es; echo $es;call xerr "$es" "attach 1-9"
8693 call read_mline_res
8694 echo "~^attachment attribute .treadctl";\
8695 read es; echo $es;call xerr "$es" "attach 1-10"
8696 call read_mline_res
8697 echo "~^attachment attribute rctl";\
8698 read es; echo $es;call xerr "$es" "attach 1-11"
8699 call read_mline_res
8700 echo "~^attachment attribute-at 1";\
8701 read es; echo $es;call xerr "$es" "attach 1-12"
8702 call read_mline_res
8705 echo "~^attachment insert ./.tattach=latin1";\
8706 read hl; echo $hl; call xerr "$hl" "attach 2-1"
8707 echo "~^attachment list";\
8708 read es; echo $es;call xerr "$es" "attach 2-2"
8709 call read_mline_res
8710 echo "~^attachment attribute ./.tattach";\
8711 read es; echo $es;call xerr "$es" "attach 2-3"
8712 call read_mline_res
8713 echo "~^attachment attribute .tattach";\
8714 read es; echo $es;call xerr "$es" "attach 2-4"
8715 call read_mline_res
8716 echo "~^attachment attribute-at 2";\
8717 read es; echo $es;call xerr "$es" "attach 2-5"
8718 call read_mline_res
8720 echo "~^attachment attribute-set ./.tattach filename tat";\
8721 read es; echo $es;call xerr "$es" "attach 2-6"
8722 echo \
8723 "~^attachment attribute-set .tattach content-description Au2";\
8724 read es; echo $es;call xerr "$es" "attach 2-7"
8725 echo "~^attachment attribute-set-at 2 content-id <20.du@wir>";\
8726 read es; echo $es;call xerr "$es" "attach 2-8"
8727 echo \
8728 "~^attachment attribute-set-at 2 content-type application/x-sh";\
8729 read es; echo $es;call xerr "$es" "attach 2-9"
8731 echo "~^attachment attribute ./.tattach";\
8732 read es; echo $es;call xerr "$es" "attach 2-10"
8733 call read_mline_res
8734 echo "~^attachment attribute .tattach";\
8735 read es; echo $es;call xerr "$es" "attach 2-11"
8736 call read_mline_res
8737 echo "~^attachment attribute tat";\
8738 read es; echo $es;call xerr "$es" "attach 2-12"
8739 call read_mline_res
8740 echo "~^attachment attribute-at 2";\
8741 read es; echo $es;call xerr "$es" "attach 2-13"
8742 call read_mline_res
8745 if [ "$t_remove" == "" ]
8746 return
8749 echo "~^attachment remove ./.treadctl"; read es;\
8750 call xerr $es "attach 3-1"
8751 echo "~^attachment remove ./.tattach"; read es;\
8752 call xerr $es "attach 3-2"
8753 echo "~^ attachment remove ./.treadctl"; read es;\
8754 vput csop es substr $es 0 3
8755 if [ $es != 501 ]
8756 xcall bail "attach 3-3"
8758 echo "~^ attachment remove ./.tattach"; read es;\
8759 vput csop es substr $es 0 3
8760 if [ $es != 501 ]
8761 xcall bail "attach 3-4"
8763 echo "~^attachment list"; read es;\
8764 vput csop es substr $es 0 3
8765 if [ $es != 501 ]
8766 xcall bail "attach 3-5"
8770 echo "~^attachment insert ./.tattach=latin1";\
8771 read hl; echo $hl; call xerr "$hl" "attach 4-1"
8772 echo "~^attachment insert ./.tattach=latin1";\
8773 read hl; echo $hl; call xerr "$hl" "attach 4-2"
8774 echo "~^attachment list";\
8775 read es; echo $es;call xerr "$es" "attach 4-3"
8776 call read_mline_res
8777 echo "~^ attachment remove .tattach"; read es;\
8778 vput csop es substr $es 0 3
8779 if [ $es != 506 ]
8780 xcall bail "attach 4-4 $es"
8782 echo "~^attachment remove-at T"; read es;\
8783 vput csop es substr $es 0 3
8784 if [ $es != 505 ]
8785 xcall bail "attach 4-5"
8787 echo "~^attachment remove ./.tattach"; read es;\
8788 call xerr $es "attach 4-6"
8789 echo "~^attachment remove ./.tattach"; read es;\
8790 call xerr $es "attach 4-7"
8791 echo "~^ attachment remove ./.tattach"; read es;\
8792 vput csop es substr $es 0 3
8793 if [ $es != 501 ]
8794 xcall bail "attach 4-8 $es"
8796 echo "~^attachment list"; read es;\
8797 vput csop es substr $es 0 3
8798 if [ $es != 501 ]
8799 xcall bail "attach 4-9"
8803 echo "~^attachment insert ./.tattach=latin1";\
8804 read hl; echo $hl; call xerr "$hl" "attach 5-1"
8805 echo "~^attachment insert ./.tattach=latin1";\
8806 read hl; echo $hl; call xerr "$hl" "attach 5-2"
8807 echo "~^attachment insert ./.tattach=latin1";\
8808 read hl; echo $hl; call xerr "$hl" "attach 5-3"
8809 echo "~^attachment list";\
8810 read es; echo $es;call xerr "$es" "attach 5-4"
8811 call read_mline_res
8813 echo "~^attachment remove-at 3"; read es;\
8814 call xerr $es "attach 5-5"
8815 echo "~^attachment remove-at 3"; read es;\
8816 vput csop es substr $es 0 3
8817 if [ $es != 501 ]
8818 xcall bail "attach 5-6"
8820 echo "~^attachment remove-at 2"; read es;\
8821 call xerr $es "attach 5-7"
8822 echo "~^attachment remove-at 2"; read es;\
8823 vput csop es substr $es 0 3
8824 if [ $es != 501 ]
8825 xcall bail "attach 5-8"
8827 echo "~^attachment remove-at 1"; read es;\
8828 call xerr $es "attach 5-9"
8829 echo "~^attachment remove-at 1"; read es;\
8830 vput csop es substr $es 0 3
8831 if [ $es != 501 ]
8832 xcall bail "attach 5-10"
8835 echo "~^attachment list"; read es;\
8836 vput csop es substr $es 0 3
8837 if [ $es != 501 ]
8838 xcall bail "attach 5-11"
8842 echo "~^attachment insert ./.tattach=latin1";\
8843 read hl; echo $hl; call xerr "$hl" "attach 6-1"
8844 echo "~^attachment insert ./.tattach=latin1";\
8845 read hl; echo $hl; call xerr "$hl" "attach 6-2"
8846 echo "~^attachment insert ./.tattach=latin1";\
8847 read hl; echo $hl; call xerr "$hl" "attach 6-3"
8848 echo "~^attachment list";\
8849 read es; echo $es;call xerr "$es" "attach 6-4"
8850 call read_mline_res
8852 echo "~^attachment remove-at 1"; read es;\
8853 call xerr $es "attach 6-5"
8854 echo "~^attachment remove-at 1"; read es;\
8855 call xerr $es "attach 6-6"
8856 echo "~^attachment remove-at 1"; read es;\
8857 call xerr $es "attach 6-7"
8858 echo "~^attachment remove-at 1"; read es;\
8859 vput csop es substr $es 0 3
8860 if [ $es != 501 ]
8861 xcall bail "attach 6-8"
8864 echo "~^attachment list"; read es;\
8865 vput csop es substr $es 0 3
8866 if [ $es != 501 ]
8867 xcall bail "attach 6-9"
8870 echo t_attach LEAVE
8872 define t_ocs {
8873 read ver
8874 echo t_ocs
8875 call t_header
8876 call t_attach
8878 define t_oce {
8879 echo on-compose-enter, mailx-command<$mailx-command>
8880 alternates alter1@exam.ple alter2@exam.ple
8881 alternates
8882 set autocc='alter1@exam.ple alter2@exam.ple'
8883 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
8884 echo mailx-subject<$mailx-subject>
8885 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
8886 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
8887 mailx-raw-bcc<$mailx-raw-bcc>
8888 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
8889 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
8890 digmsg create - -;echo $?/$!/$^ERRNAME;\
8891 digmsg - header list;\
8892 digmsg remove -;echo $?/$!/$^ERRNAME
8893 digmsg create -;echo $?/$!/$^ERRNAME;\
8894 digmsg - header list;readall x;echon $x;\
8895 digmsg remove -;echo $?/$!/$^ERRNAME
8897 define t_ocl {
8898 echo on-compose-leave, mailx-command<$mailx-command>
8899 vput alternates al
8900 eval alternates $al alter3@exam.ple alter4@exam.ple
8901 alternates
8902 set autobcc='alter3@exam.ple alter4@exam.ple'
8903 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
8904 echo mailx-subject<$mailx-subject>
8905 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
8906 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
8907 mailx-raw-bcc<$mailx-raw-bcc>
8908 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
8909 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
8910 digmsg create - -;echo $?/$!/$^ERRNAME;\
8911 digmsg - header list;\
8912 digmsg remove -;echo $?/$!/$^ERRNAME
8913 digmsg create -;echo $?/$!/$^ERRNAME;\
8914 digmsg - header list;readall x;echon $x;\
8915 digmsg remove -;echo $?/$!/$^ERRNAME
8917 define t_occ {
8918 echo on-compose-cleanup, mailx-command<$mailx-command>
8919 unalternates *
8920 alternates
8921 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
8922 echo mailx-subject<$mailx-subject>
8923 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
8924 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
8925 mailx-raw-bcc<$mailx-raw-bcc>
8926 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
8927 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
8928 # XXX error message variable digmsg create - -;echo $?/$!/$^ERRNAME;\
8929 digmsg - header list;\
8930 digmsg remove -;echo $?/$!/$^ERRNAME
8931 # ditto digmsg create -;echo $?/$!/$^ERRNAME;\
8932 digmsg - header list;readall x;echon $x;\
8933 digmsg remove -;echo $?/$!/$^ERRNAME
8935 wysh set on-compose-splice=t_ocs \
8936 on-compose-enter=t_oce on-compose-leave=t_ocl \
8937 on-compose-cleanup=t_occ
8938 __EOT__
8940 printf 'm this-goes@nowhere\nbody\n!.\n' |
8941 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
8942 -X'source ./.trc' -Smta=test://"$MBOX" \
8943 >./.tall 2>&1
8944 ${cat} ./.tall >> "${MBOX}"
8945 check 1 0 "${MBOX}" '1646284089 10565'
8947 ${rm} "${MBOX}"
8948 printf 'm this-goes@nowhere\nbody\n!.\n' |
8949 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
8950 -St_remove=1 -X'source ./.trc' -Smta=test://"$MBOX" \
8951 >./.tall 2>&1
8952 ${cat} ./.tall >> "${MBOX}"
8953 check 2 0 "${MBOX}" '700681006 12851'
8957 # Some state machine stress, shell compose hook, localopts for hook, etc.
8958 # readctl in child. ~r as HERE document
8959 ${rm} "${MBOX}"
8960 printf 'm ex@am.ple\nbody\n!.
8961 echon ${mailx-command}${mailx-subject}
8962 echon ${mailx-from}${mailx-sender}
8963 echon ${mailx-to}${mailx-cc}${mailx-bcc}
8964 echon ${mailx-raw-to}${mailx-raw-cc}${mailx-raw-bcc}
8965 echon ${mailx-orig-from}${mailx-orig-to}${mailx-orig-gcc}${mailx-orig-bcc}
8966 var t_oce t_ocs t_ocs_sh t_ocl t_occ autocc
8967 ' | ${MAILX} ${ARGS} -Snomemdebug -Sescape=! \
8968 -Smta=test://"$MBOX" \
8970 define bail {
8971 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
8973 define xerr {
8974 vput csop es substr "$1" 0 1
8975 if [ "$es" != 2 ]
8976 xcall bail "$2"
8979 define read_mline_res {
8980 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
8981 echo $len/$es/$^ERRNAME: $hl
8982 if [ $es -ne $^ERR-NONE ]
8983 xcall bail read_mline_res
8984 elif [ $len -ne 0 ]
8985 \xcall read_mline_res
8988 define _work {
8989 vput vexpr i + 1 "$2"
8990 if [ $i -lt 111 ]
8991 vput vexpr j % $i 10
8992 if [ $j -ne 0 ]
8993 set j=xcall
8994 else
8995 echon "$i.. "
8996 set j=call
8998 eval \\$j _work $1 $i
8999 return $?
9001 vput vexpr i + $i "$1"
9002 return $i
9004 define _read {
9005 wysh set line; read line;wysh set es=$? en=$^ERRNAME ;\
9006 echo read:$es/$en: $line
9007 if [ "${es}" -ne -1 ]
9008 xcall _read
9010 readctl remove $cwd/.treadctl; echo readctl remove:$?/$^ERRNAME
9012 define t_ocs {
9013 read ver
9014 echo t_ocs
9015 echo "~^header list"; read hl; echo $hl;\
9016 vput csop es substr "$hl" 0 1
9017 if [ "$es" != 2 ]
9018 xcall bail "header list"
9019 endif
9021 call _work 1; echo $?
9022 echo "~^header insert cc splicy\ diet\ <splice@exam.ple>\ spliced";\
9023 read es; echo $es; vput csop es substr "$es" 0 1
9024 if [ "$es" != 2 ]
9025 xcall bail "be diet"
9026 endif
9027 echo "~^header insert cc <splice2@exam.ple>";\
9028 read es; echo $es; vput csop es substr "$es" 0 1
9029 if [ "$es" != 2 ]
9030 xcall bail "be diet2"
9031 endif
9033 call _work 2; echo $?
9034 echo "~^header insert bcc juicy\ juice\ <juice@exam.ple>\ spliced";\
9035 read es; echo $es;vput csop es substr "$es" 0 1
9036 if [ "$es" != 2 ]
9037 xcall bail "be juicy"
9038 endif
9039 echo "~^header insert bcc juice2@exam.ple";\
9040 read es; echo $es;vput csop es substr "$es" 0 1
9041 if [ "$es" != 2 ]
9042 xcall bail "be juicy2"
9043 endif
9044 echo "~^header insert bcc juice3\ <juice3@exam.ple>";\
9045 read es; echo $es;vput csop es substr "$es" 0 1
9046 if [ "$es" != 2 ]
9047 xcall bail "be juicy3"
9048 endif
9049 echo "~^header insert bcc juice4@exam.ple";\
9050 read es; echo $es;vput csop es substr "$es" 0 1
9051 if [ "$es" != 2 ]
9052 xcall bail "be juicy4"
9053 endif
9055 echo "~^header remove-at bcc 3";\
9056 read es; echo $es;vput csop es substr "$es" 0 1
9057 if [ "$es" != 2 ]
9058 xcall bail "remove juicy5"
9059 endif
9060 echo "~^header remove-at bcc 2";\
9061 read es; echo $es;vput csop es substr "$es" 0 1
9062 if [ "$es" != 2 ]
9063 xcall bail "remove juicy6"
9064 endif
9065 echo "~^header remove-at bcc 3";\
9066 read es; echo $es;vput csop es substr "$es" 0 3
9067 if [ "$es" != 501 ]
9068 xcall bail "failed to remove-at"
9069 endif
9070 # Add duplicates which ought to be removed!
9071 echo "~^header insert bcc juice4@exam.ple";\
9072 read es; echo $es;vput csop es substr "$es" 0 1
9073 if [ "$es" != 2 ]
9074 xcall bail "be juicy4-1"
9075 endif
9076 echo "~^header insert bcc juice4@exam.ple";\
9077 read es; echo $es;vput csop es substr "$es" 0 1
9078 if [ "$es" != 2 ]
9079 xcall bail "be juicy4-2"
9080 endif
9081 echo "~^header insert bcc juice4@exam.ple";\
9082 read es; echo $es;vput csop es substr "$es" 0 1
9083 if [ "$es" != 2 ]
9084 xcall bail "be juicy4-3"
9085 endif
9086 echo "~:set t_ocs"
9089 call _work 3; echo $?
9090 echo "~r - '__EOT'"
9091 vput ! i echo just knock if you can hear me;\
9092 i=0;\
9093 while [ $i -lt 24 ]; do printf "%s " $i; i=`expr $i + 1`; done;\
9094 echo relax
9095 echon shell-cmd says $?/$^ERRNAME: $i
9096 echo "~x will not become interpreted, we are reading until __EOT"
9097 echo "__EOT"
9098 read r_status; echo "~~r status output: $r_status"
9099 echo "~:echo $? $! $^ERRNAME"
9100 read r_status
9101 echo "~~r status from parent: $r_status"
9104 call _work 4; echo $?
9105 vput cwd cwd;echo cwd:$?
9106 readctl create $cwd/.treadctl ;echo readctl:$?/$^ERRNAME;\
9107 call _read
9110 call _work 5; echo $?
9111 echo "~^header show MAILX-Command"; read es;\
9112 call xerr $es "t_header 1000"; call read_mline_res
9113 echo "~^header show MAILX-raw-TO"; read es;\
9114 call xerr $es "t_header 1001"; xcall read_mline_res
9116 echoerr IT IS WRONG IF YOU SEE THIS
9118 define t_oce {
9119 echo on-compose-enter, mailx-command<$mailx-command>
9120 set t_oce autobcc=oce@exam.ple
9121 alternates alter1@exam.ple alter2@exam.ple
9122 alternates
9123 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
9124 echo mailx-subject<$mailx-subject>
9125 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
9126 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
9127 mailx-raw-bcc<$mailx-raw-bcc>
9128 echo mailx-orig-from<$mailx-orig-from> \
9129 mailx-orig-to<$mailx-orig-to> \
9130 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
9132 define t_ocl {
9133 echo on-compose-leave, mailx-command<$mailx-command>
9134 set t_ocl autocc=ocl@exam.ple
9135 unalternates *
9136 alternates alter3@exam.ple alter4@exam.ple
9137 alternates
9138 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
9139 echo mailx-subject<$mailx-subject>
9140 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
9141 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
9142 mailx-raw-bcc<$mailx-raw-bcc>
9143 echo mailx-orig-from<$mailx-orig-from> \
9144 mailx-orig-to<$mailx-orig-to> \
9145 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
9147 define t_occ {
9148 echo on-compose-cleanup, mailx-command<$mailx-command>
9149 set t_occ autocc=occ@exam.ple
9150 unalternates *
9151 alternates
9152 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
9153 echo mailx-subject<$mailx-subject>
9154 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
9155 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
9156 mailx-raw-bcc<$mailx-raw-bcc>
9157 echo mailx-orig-from<$mailx-orig-from> \
9158 mailx-orig-to<$mailx-orig-to> \
9159 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
9161 wysh set on-compose-splice=t_ocs \
9162 on-compose-splice-shell="read ver;echo t_ocs-shell;\
9163 echo \"~t shell@exam.ple\"; echo \"~:set t_ocs_sh\"" \
9164 on-compose-enter=t_oce on-compose-leave=t_ocl \
9165 on-compose-cleanup=t_occ
9166 ' > ./.tnotes 2>&1
9167 check_ex0 3-estat
9168 ${cat} ./.tnotes >> "${MBOX}"
9169 check 3 - "${MBOX}" '3986011319 2437'
9171 # Reply, forward, resend, Resend
9173 ${rm} "${MBOX}"
9174 printf '#
9175 set from="f1@z"
9176 m t1@z
9179 set from="du <f2@z>" stealthmua=noagent
9180 m t2@z
9183 ' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" -Snomemdebug -Sescape=! \
9184 > ./.tnotes 2>&1
9185 check_ex0 4-intro-estat
9187 printf '
9188 echo start: $? $! $^ERRNAME
9189 File %s
9190 echo File: $? $! $^ERRNAME;echo;echo
9191 reply 1
9192 this is content of reply 1
9194 echo reply 1: $? $! $^ERRNAME;echo;echo
9195 Reply 1 2
9196 this is content of Reply 1 2
9198 echo Reply 1 2: $? $! $^ERRNAME;echo;echo
9199 forward 1 fwdex@am.ple
9200 this is content of forward 1
9202 echo forward 1: $? $! $^ERRNAME;echo;echo
9203 wysh set forward-inject-head=$'"'"'-- \\
9204 forward (%%a)(%%d)(%%f)(%%i)(%%n)(%%r) --\\n'"'"'
9205 wysh set forward-inject-tail=$'"'"'-- \\
9206 end of forward (%%i) --\\n'"'"'
9207 forward 2 fwdex@am.ple
9208 this is content of forward 2
9210 echo forward 2: $? $! $^ERRNAME;echo;echo
9211 set showname
9212 forward 2 fwdex2@am.ple
9213 this is content of forward 2, 2nd, with showname set
9215 echo forward 2, 2nd: $? $! $^ERRNAME;echo;echo
9216 resend 1 2 resendex@am.ple
9217 echo resend 1 2: $? $! $^ERRNAME;echo;echo
9218 Resend 1 2 Resendex@am.ple
9219 echo Resend 1 2: $? $! $^ERRNAME;echo;echo
9220 ' "${MBOX}" |
9221 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sfullnames \
9222 -Smta=test://"$MBOX" \
9224 define bail {
9225 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
9227 define xerr {
9228 vput csop es substr "$1" 0 1
9229 if [ "$es" != 2 ]
9230 xcall bail "$2"
9233 define read_mline_res {
9234 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
9235 echo mline_res:$len/$es/$^ERRNAME: $hl
9236 if [ $es -ne $^ERR-NONE ]
9237 xcall bail read_mline_res
9238 elif [ $len -ne 0 ]
9239 \xcall read_mline_res
9242 define work_hl {
9243 echo "~^header show $1"; read es;\
9244 call xerr $es "work_hl $1"; echo $1; call read_mline_res
9245 if [ $# -gt 1 ]
9246 shift
9247 xcall work_hl "$@"
9250 define t_ocs {
9251 read ver
9252 echo t_ocs version $ver
9253 echo "~^header list"; read hl; echo $hl;\
9254 echoerr the header list is $hl;\
9255 call xerr "$hl" "header list"
9256 eval vpospar set $hl
9257 shift
9258 xcall work_hl "$@"
9259 echoerr IT IS WRONG IF YOU SEE THIS
9261 define t_oce {
9262 echo on-XY-enter, mailx-command<$mailx-command>
9263 set t_oce autobcc=oce@exam.ple
9264 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
9265 echo mailx-subject<$mailx-subject>
9266 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
9267 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
9268 mailx-raw-bcc<$mailx-raw-bcc>
9269 echo mailx-orig-from<$mailx-orig-from> \
9270 mailx-orig-to<$mailx-orig-to> \
9271 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
9273 define t_ocl {
9274 echo on-XY-leave, mailx-command<$mailx-command>
9275 set t_ocl autocc=ocl@exam.ple
9276 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
9277 echo mailx-subject<$mailx-subject>
9278 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
9279 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
9280 mailx-raw-bcc<$mailx-raw-bcc>
9281 echo mailx-orig-from<$mailx-orig-from> \
9282 mailx-orig-to<$mailx-orig-to> \
9283 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
9285 define t_occ {
9286 echo on-XY-cleanup, mailx-command<$mailx-command>
9287 set t_occ autocc=occ@exam.ple
9288 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
9289 echo mailx-subject<$mailx-subject>
9290 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
9291 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
9292 mailx-raw-bcc<$mailx-raw-bcc>
9293 echo mailx-orig-from<$mailx-orig-from> \
9294 mailx-orig-to<$mailx-orig-to> \
9295 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
9297 wysh set on-compose-splice=t_ocs \
9298 on-compose-enter=t_oce on-compose-leave=t_ocl \
9299 on-compose-cleanup=t_occ \
9300 on-resend-enter=t_oce on-resend-cleanup=t_occ
9301 ' >> ./.tnotes 2>&1
9302 check_ex0 4-estat
9303 ${cat} ./.tnotes >> "${MBOX}"
9304 check 4 - "${MBOX}" '1850092468 11799'
9306 t_epilog "${@}"
9307 } # }}}
9309 t_mass_recipients() {
9310 t_prolog "${@}"
9312 if have_feat cmd-vexpr; then :; else
9313 t_echoskip '[!CMD_VEXPR]'
9314 t_epilog "${@}"
9315 return
9318 ${cat} <<'__EOT__' > ./.trc
9319 define bail {
9320 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
9322 define ins_addr {
9323 wysh set nr=$1 hn=$2
9324 echo "~$hn $hn$nr@$hn"; echo '~:echo $?'; read es
9325 if [ "$es" -ne 0 ]
9326 xcall bail "ins_addr $hn 1-$nr"
9328 vput vexpr nr + $nr 1
9329 if [ "$nr" -le "$maximum" ]
9330 xcall ins_addr $nr $hn
9333 define bld_alter {
9334 wysh set nr=$1 hn=$2
9335 alternates $hn$nr@$hn
9336 vput vexpr nr + $nr 2
9337 if [ "$nr" -le "$maximum" ]
9338 xcall bld_alter $nr $hn
9341 define t_ocs {
9342 read ver
9343 call ins_addr 1 t
9344 call ins_addr 1 c
9345 call ins_addr 1 b
9347 define t_ocl {
9348 if [ "$t_remove" != '' ]
9349 call bld_alter 1 t
9350 call bld_alter 2 c
9353 set on-compose-splice=t_ocs on-compose-leave=t_ocl
9354 __EOT__
9356 printf 'm this-goes@nowhere\nbody\n!.\n' |
9357 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
9358 -X'source ./.trc' -Smta=test://"$MBOX" -Smaximum=${LOOPS_MAX} \
9359 >./.tall 2>&1
9360 check_ex0 1-estat
9361 ${cat} ./.tall >> "${MBOX}"
9362 if [ ${LOOPS_MAX} -eq ${LOOPS_BIG} ]; then
9363 check 1-${LOOPS_BIG} - "${MBOX}" '3835365533 51534'
9364 elif [ ${LOOPS_MAX} -eq ${LOOPS_SMALL} ]; then
9365 check 1-${LOOPS_SMALL} - "${MBOX}" '3647549277 4686'
9368 ${rm} "${MBOX}"
9369 printf 'm this-goes@nowhere\nbody\n!.\n' |
9370 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
9371 -St_remove=1 -X'source ./.trc' -Smta=test://"$MBOX" \
9372 -Smaximum=${LOOPS_MAX} \
9373 >./.tall 2>&1
9374 check_ex0 2-estat
9375 ${cat} ./.tall >> "${MBOX}"
9376 if [ ${LOOPS_MAX} -eq ${LOOPS_BIG} ]; then
9377 check 2-${LOOPS_BIG} - "${MBOX}" '3768249992 34402'
9378 elif [ $LOOPS_MAX -eq ${LOOPS_SMALL} ]; then
9379 check 2-${LOOPS_SMALL} - "${MBOX}" '4042568441 3170'
9382 t_epilog "${@}"
9385 t_lreply_futh_rth_etc() {
9386 t_prolog "${@}"
9388 ${cat} <<-_EOT > ./.tmbox
9389 From neverneverland Sun Jul 23 13:46:25 2017
9390 Subject: Bugstop: five miles out 1
9391 Reply-To: mister originator2 <mr2@originator>, bugstop@five.miles.out
9392 From: mister originator <mr@originator>
9393 To: bugstop-commit@five.miles.out, laber@backe.eu
9394 Cc: is@a.list
9395 Mail-Followup-To: bugstop@five.miles.out, laber@backe.eu, is@a.list
9396 In-reply-to: <20170719111113.bkcMz%laber@backe.eu>
9397 Date: Wed, 19 Jul 2017 09:22:57 -0400
9398 Message-Id: <20170719132257.766AF781267@originator>
9399 Status: RO
9401 > |Sorry, I think I misunderstand something. I would think that
9403 That's appalling.
9405 From neverneverland Fri Jul 7 22:39:11 2017
9406 Subject: Bugstop: five miles out 2
9407 Reply-To: mister originator2<mr2@originator>,bugstop@five.miles.out,is@a.list
9408 Content-Transfer-Encoding: 7bit
9409 From: mister originator <mr@originator>
9410 To: bugstop-commit@five.miles.out
9411 Cc: is@a.list
9412 Message-ID: <149945963975.28888.6950788126957753723.reportbug@five.miles.out>
9413 Date: Fri, 07 Jul 2017 16:33:59 -0400
9414 Status: R
9416 capable of changing back.
9418 From neverneverland Fri Jul 7 22:42:00 2017
9419 Subject: Bugstop: five miles out 3
9420 Reply-To: mister originator2 <mr2@originator>, bugstop@five.miles.out
9421 Content-Transfer-Encoding: 7bit
9422 From: mister originator <mr@originator>
9423 To: bugstop-commit@five.miles.out
9424 Cc: is@a.list
9425 Message-ID: <149945963975.28888.6950788126957753746.reportbug@five.miles.out>
9426 Date: Fri, 07 Jul 2017 16:33:59 -0400
9427 List-Post: <mailto:bugstop@five.miles.out>
9428 Status: R
9430 are you ready, boots?
9432 From neverneverland Sat Aug 19 23:15:00 2017
9433 Subject: Bugstop: five miles out 4
9434 Reply-To: mister originator2 <mr2@originator>, bugstop@five.miles.out
9435 Content-Transfer-Encoding: 7bit
9436 From: mister originator <mr@originator>
9437 To: bugstop@five.miles.out
9438 Cc: is@a.list
9439 Message-ID: <149945963975.28888.6950788126qtewrqwer.reportbug@five.miles.out>
9440 Date: Fri, 07 Jul 2017 16:33:59 -0400
9441 List-Post: <mailto:bugstop@five.miles.out>
9442 Status: R
9444 are you ready, boots?
9445 _EOT
9449 ${cat} <<-'_EOT' | ${MAILX} ${ARGS} -Sescape=! -Smta=test://"$MBOX" \
9450 -Rf ./.tmbox >> "${MBOX}" 2>&1
9451 define r {
9452 wysh set m="This is text of \"reply ${1}."
9453 reply 1 2 3
9454 !I m
9457 !I m
9460 !I m
9463 echo -----After reply $1.1 - $1.3: $?/$^ERRNAME
9465 define R {
9466 wysh set m="This is text of \"Reply ${1}."
9467 eval Reply $2
9468 !I m
9469 !I 2
9472 echo -----After Reply $1.$2: $?/$^ERRNAME
9474 define _Lh {
9475 read protover
9476 echo '~I m'
9477 echo '~I n'
9478 echo '".'
9480 define _Ls {
9481 wysh set m="This is text of \"Lreply ${1}." on-compose-splice=_Lh n=$2
9482 eval Lreply $2
9484 define L {
9485 # We need two indirections for this test: one for the case that Lreply
9486 # fails because of missing recipients: we need to read EOF next, thus
9487 # place this in _Ls last; and second for the succeeding cases EOF is
9488 # not what these should read, so go over the backside and splice it in!
9489 # (A shame we do not have redirection++ as a Bourne/K/POSIX shell!)
9490 call _Ls "$@"
9491 echo -----After Lreply $1.$2: $?/$^ERRNAME
9493 define x {
9494 localopts call-fixate yes
9495 call r $1
9496 call R $1 1; call R $1 2; call R $1 3; call R $1 4
9497 call L $1 1; call L $1 2; call L $1 3
9499 define tweak {
9500 echo;echo '===== CHANGING === '"$*"' =====';echo
9501 eval "$@"
9504 set from=laber@backe.eu
9505 mlist is@a.list
9506 call x 1
9507 call tweak set reply-to-honour
9508 call x 2
9509 call tweak set followup-to
9510 call x 3
9511 call tweak set followup-to-honour
9512 call x 4
9513 call tweak mlist bugstop@five.miles.out
9514 call x 5
9515 call tweak mlsubscribe bugstop@five.miles.out
9516 call x 6
9517 call tweak set recipients-in-cc
9518 call x 7
9519 # While here, test that *fullnames* works (also here)
9520 call tweak set fullnames
9521 reply 1
9522 This message should have *fullnames* in the header.
9524 # Revert
9525 call tweak unmlsubscribe bugstop@five.miles.out';' \
9526 set followup-to-add-cc nofullnames
9527 call x 8
9528 call tweak mlsubscribe bugstop@five.miles.out
9529 call x 9
9530 _EOT
9532 check_ex0 1-estat
9533 if have_feat uistrings; then
9534 check 1 - "${MBOX}" '1519985418 39828'
9535 else
9536 t_echoskip '1:[!UISTRINGS]'
9541 ${cat} <<-_EOT > ./.tmbox
9542 From tom@i-i.example Thu Oct 26 03:15:55 2017
9543 Date: Wed, 25 Oct 2017 21:15:46 -0400
9544 From: tom <tom@i-i.example>
9545 To: Steffen Nurpmeso <steffen@sdaoden.eu>
9546 Cc: tom <tom@i-i.example>
9547 Subject: Re: xxxx yyyyyyyy configure does not really like a missing zzzzz
9548 Message-ID: <20171026011546.GA11643@i-i.example>
9549 Reply-To: tom@i-i.example
9550 References: <20171025214601.T2pNd%steffen@sdaoden.eu>
9551 In-Reply-To: <20171025214601.T2pNd%steffen@sdaoden.eu>
9552 Status: R
9554 The report's useful :-)
9555 _EOT
9557 # Let us test In-Reply-To: removal starts a new thread..
9558 # This needs adjustment of *stealthmua*
9559 argadd='-Sstealthmua=noagent -Shostname'
9561 ${rm} "${MBOX}"
9562 printf 'reply 1\nthread\n!.\n' |
9563 ${MAILX} ${ARGS} -Sescape=! -Smta=test://"$MBOX" -Sreply-to-honour \
9564 ${argadd} -Rf ./.tmbox > .tall 2>&1
9565 check 2 0 "${MBOX}" '841868335 433'
9566 check 3 - .tall '4294967295 0'
9568 printf 'reply 1\nnew <- thread!\n!||%s -e "%s"\n!.\n' \
9569 "${sed}" '/^In-Reply-To:/d' |
9570 ${MAILX} ${ARGS} -Sescape=! -Smta=test://"$MBOX" -Sreply-to-honour \
9571 ${argadd} -Rf "${MBOX}" > .tall 2>&1
9572 check 4 0 "${MBOX}" '3136957908 771'
9573 check 5 - .tall '4294967295 0'
9575 printf 'reply 2\nold <- new <- thread!\n!.\n' |
9576 ${MAILX} ${ARGS} -Sescape=! -Smta=test://"$MBOX" -Sreply-to-honour \
9577 ${argadd} -Rf "${MBOX}" > .tall 2>&1
9578 check 6 0 "${MBOX}" '3036449053 1231'
9579 check 7 - .tall '4294967295 0'
9581 printf 'reply 3\nnew <- old <- new <- thread!\n!|| %s -e "%s"\n!.\n' \
9582 "${sed}" '/^In-Reply-To:/d' |
9583 ${MAILX} ${ARGS} -Sescape=! -Smta=test://"$MBOX" -Sreply-to-honour \
9584 ${argadd} -Rf "${MBOX}" > .tall 2>&1
9585 check 8 0 "${MBOX}" '2069841383 1583'
9586 check 9 - .tall '4294967295 0'
9588 # And follow-up testing whether changing In-Reply-To: to - starts a new
9589 # thread with only the message being replied-to.
9591 printf 'reply 1\nthread with only one ref!\n!||%s -e "%s"\n!.\n' \
9592 "${sed}" 's/^In-Reply-To:.*$/In-Reply-To:-/' |
9593 ${MAILX} ${ARGS} -Sescape=! -Smta=test://"$MBOX" -Sreply-to-honour \
9594 ${argadd} -Rf "${MBOX}" > .tall 2>&1
9595 check 10 0 "${MBOX}" '3155846378 2047'
9596 check 11 - .tall '4294967295 0'
9598 t_epilog "${@}"
9601 t_pipe_handlers() {
9602 t_prolog "${@}"
9604 if have_feat cmd-vexpr; then :; else
9605 t_echoskip '[!CMD_VEXPR]'
9606 t_epilog "${@}"
9607 return
9610 # "Test for" [d6f316a] (Gavin Troy)
9611 printf "m ${MBOX}\n~s subject1\nEmail body\n~.\nfi ${MBOX}\np\nx\n" |
9612 ${MAILX} ${ARGS} ${ADDARG_UNI} -Spipe-text/plain="?* ${cat}" > "${BODY}"
9613 check 1 0 "${MBOX}" '3942990636 118'
9614 check 2 - "${BODY}" '3951695530 170'
9616 ${rm} "${MBOX}"
9617 printf "m %s\n~s subject2\n~@%s\nBody2\n~.\nFi %s\nmimeview\nx\n" \
9618 "${MBOX}" "${TOPDIR}snailmail.jpg" "${MBOX}" |
9619 ${MAILX} ${ARGS} ${ADDARG_UNI} \
9620 -S 'pipe-text/plain=?' \
9621 -S 'pipe-image/jpeg=?=&?'\
9622 'trap \"'"${rm}"' -f '\ '\\"${MAILX_FILENAME_TEMPORARY}\\"\" EXIT;'\
9623 'trap \"trap \\\"\\\" INT QUIT TERM; exit 1\" INT QUIT TERM;'\
9624 '{ echo C=$MAILX_CONTENT;'\
9625 'echo C-E=$MAILX_CONTENT_EVIDENCE;'\
9626 'echo E-B-U=$MAILX_EXTERNAL_BODY_URL;'\
9627 'echo F=$MAILX_FILENAME;'\
9628 'echo F-G=not testable MAILX_FILENAME_GENERATED;'\
9629 'echo F-T=not testable MAILX_FILENAME_TEMPORARY;'\
9630 ''"${cksum}"' < \"${MAILX_FILENAME_TEMPORARY}\" |'\
9631 ''"${sed}"' -e "s/[ ]\{1,\}/ /g"; } > ./.tax 2>&1;'"${mv}"' ./.tax ./.tay' \
9632 > "${BODY}" 2>&1
9633 check 3 0 "${MBOX}" '1933681911 13435'
9634 check 4 - "${BODY}" '2036666633 493'
9635 check 4-hdl - ./.tay '144517347 151' async
9637 # Keep $MBOX..
9638 if [ -z "${ln}" ]; then
9639 t_echoskip '5:[ln(1) not found]'
9640 else
9641 # Let us fill in tmpfile, test auto-deletion
9642 printf 'Fi %s\nmimeview\nvput vexpr v file-stat .t.one-link\n'\
9643 'eval wysh set $v;echo should be $st_nlink link\nx\n' "${MBOX}" |
9644 ${MAILX} ${ARGS} ${ADDARG_UNI} \
9645 -S 'pipe-text/plain=?' \
9646 -S 'pipe-image/jpeg=?=++?'\
9647 'echo C=$MAILX_CONTENT;'\
9648 'echo C-E=$MAILX_CONTENT_EVIDENCE;'\
9649 'echo E-B-U=$MAILX_EXTERNAL_BODY_URL;'\
9650 'echo F=$MAILX_FILENAME;'\
9651 'echo F-G=not testable MAILX_FILENAME_GENERATED;'\
9652 'echo F-T=not testable MAILX_FILENAME_TEMPORARY;'\
9653 "${ln}"' -f $MAILX_FILENAME_TEMPORARY .t.one-link;'\
9654 ''"${cksum}"' < \"${MAILX_FILENAME_TEMPORARY}\" |'\
9655 ''"${sed}"' -e "s/[ ]\{1,\}/ /g"' \
9656 > "${BODY}" 2>&1
9657 check 5 0 "${BODY}" '4260004050 661'
9659 # Fill in ourselfs, test auto-deletion
9660 printf 'Fi %s\nmimeview\nvput vexpr v file-stat .t.one-link\n'\
9661 'eval wysh set $v;echo should be $st_nlink link\nx\n' "${MBOX}" |
9662 ${MAILX} ${ARGS} ${ADDARG_UNI} \
9663 -S 'pipe-text/plain=?' \
9664 -S 'pipe-image/jpeg=?++?'\
9665 "${cat}"' > $MAILX_FILENAME_TEMPORARY;'\
9666 'echo C=$MAILX_CONTENT;'\
9667 'echo C-E=$MAILX_CONTENT_EVIDENCE;'\
9668 'echo E-B-U=$MAILX_EXTERNAL_BODY_URL;'\
9669 'echo F=$MAILX_FILENAME;'\
9670 'echo F-G=not testable MAILX_FILENAME_GENERATED;'\
9671 'echo F-T=not testable MAILX_FILENAME_TEMPORARY;'\
9672 ''"${cksum}"' < \"${MAILX_FILENAME_TEMPORARY}\" |'\
9673 ''"${sed}"' -e "s/[ ]\{1,\}/ /g"' \
9674 > "${BODY}" 2>&1
9675 check 6 0 "${BODY}" '4260004050 661'
9677 # And the same, via copiousoutput (fake)
9678 printf 'Fi %s\np\nvput vexpr v file-stat .t.one-link\n'\
9679 'eval wysh set $v;echo should be $st_nlink link\nx\n' "${MBOX}" |
9680 ${MAILX} ${ARGS} ${ADDARG_UNI} \
9681 -S 'pipe-text/plain=?' \
9682 -S 'pipe-image/jpeg=?*++?'\
9683 "${cat}"' > $MAILX_FILENAME_TEMPORARY;'\
9684 'echo C=$MAILX_CONTENT;'\
9685 'echo C-E=$MAILX_CONTENT_EVIDENCE;'\
9686 'echo E-B-U=$MAILX_EXTERNAL_BODY_URL;'\
9687 'echo F=$MAILX_FILENAME;'\
9688 'echo F-G=not testable MAILX_FILENAME_GENERATED;'\
9689 'echo F-T=not testable MAILX_FILENAME_TEMPORARY;'\
9690 "${ln}"' -f $MAILX_FILENAME_TEMPORARY .t.one-link;'\
9691 ''"${cksum}"' < \"${MAILX_FILENAME_TEMPORARY}\" |'\
9692 ''"${sed}"' -e "s/[ ]\{1,\}/ /g"' \
9693 > "${BODY}" 2>&1
9694 check 7 0 "${BODY}" '709946464 677'
9697 t_epilog "${@}"
9700 t_mailcap() {
9701 t_prolog "${@}"
9703 if have_feat mailcap; then :; else
9704 t_echoskip '[!MAILCAP]'
9705 t_epilog "${@}"
9706 return
9709 ${cat} <<-'_EOT' > ./.tmailcap
9710 text/html; lynx -dump %s; copiousoutput; nametemplate=%s.html
9711 application/pdf; /Applications/Preview.app/Contents/MacOS/Preview %s;\
9712 nametemplate=%s.pdf;\
9713 test = [ "${OSTYPE}" = darwin ]
9714 application/pdf;\
9715 infile=%s\;\
9716 trap "rm -f ${infile}" EXIT\;\
9717 trap "exit 75" INT QUIT TERM\;\
9718 mupdf "${infile}";\
9719 test = [ -n "${DISPLAY}" ];\
9720 nametemplate = %s.pdf; x-mailx-async
9721 application/pdf; pdftotext -layout %s -; nametemplate=%s.pdf; copiousoutput
9722 application/*; echo "This is \\"%t\\" but \
9723 is 50 \% Greek to me" \; < %s head -c 1024 | cat -vet; \
9724 description=" this is\;a \"wildcard\" match, no trailing quote! ;\
9725 copiousoutput; x-mailx-noquote
9729 bummer/hummer;;
9730 application/postscript; ps-to-terminal %s;\ needsterminal
9731 application/postscript; ps-to-terminal %s; \compose=idraw %s
9732 x-be2; the-cmd %s; \
9733 print=print-cmd %s ; \
9734 copiousoutput ; \
9735 compose=compose-cmd -d %s ; \
9736 textualnewlines; \
9737 composetyped = composetyped-cmd -dd %s ; \
9738 x-mailx-noquote ;\
9739 edit=edit-cmd -ddd %s; \
9740 description = a\;desc;\
9741 nametemplate=%s.be2;\
9742 test = this is "a" test ; \
9743 x-mailx-test-once ;\
9744 x11-bitmap = x11-bitmap.bpm;;;;;
9745 application/*; echo "is \"%t\" \
9746 50 \% Greek" \; cat %s; copiousoutput; \; description="catch-all buddy";
9747 audio/*; showaudio;compose=%n
9748 image/jpeg; showpicture -viewer xv %s
9749 image/*; showpicture %s
9750 message/partial; showpartial %s %{id} %{number} %{total}
9751 application/postscript ; lpr %s ; label="PS File";\
9752 compose="getx PS %s"
9753 application/atomicmail; atomicmail %s ; needsterminal
9754 application/andrew-inset; ezview %s ; copiousoutput;\
9755 edit=ez -d %s; compose="ez -d %s"; label="Andrew i/d"
9756 text/richtext; xy iso-8859-1 -e richtext -p %s; \
9757 test=test "`echo %{charset} | tr A-Z a-z`" = iso-8859-1; copiousoutput
9758 text/plain; xy iso-8859-1 %s;\
9759 test=test "`echo %{charset} | tr A-Z a-z`" = iso-8859-1; copiousoutput
9760 text/richtext; rich %s %{not-closed; copiousoutput
9761 default; cat %s; copiousoutput
9762 _EOT
9763 ${chmod} 0644 ./.tmailcap
9765 printf 'm;echo =1/$?;m c;echo =2/$?;
9766 mailca loa;echo =3/$?;mailc s;echo =4/$?' |
9767 MAILCAPS=./.tmailcap ${MAILX} -X'commandalias m mailcap' ${ARGS} \
9768 > ./.tall 2>./.terr
9769 check 1 0 ./.tall '2012114724 3064'
9770 have_feat uistrings && i='3903313993 2338' || i='4294967295 0'
9771 check 2 - ./.terr "${i}"
9775 echo 'From me with love' | ${MAILX} ${ARGS} -s sub1 "${MBOX}"
9776 check 3 0 "${MBOX}" '4224630386 228'
9778 # For reproducability, one pseudo check with cat(1) and mv(1)
9779 printf '#
9780 text/plain; echo p-1-1\\;< %%s cat\\;echo p-1-2;\\
9781 test=echo X >> ./.terrmc\\; [ -n "$XY" ];x-mailx-test-once
9782 text/plain; echo p-2-1\\;< %%s cat\\;echo p-2-2;\\
9783 test=echo Y >> ./.terrmc\\;[ -z "$XY" ]
9784 text/plain; { file=%%s\\; echo p-3-1 = ${file##*.}\\;\\
9785 </dev/null cat %%s\\;echo p-3-2\\; } > ./.tx\\; mv -f ./.tx ./.tasy;\\
9786 test=[ -n "$XY" ];nametemplate=%%s.txt;x-mailx-async
9787 text/plain; echo p-4-1\\;cat\\;echo p-4-2;copiousoutput
9788 ' > ./.tmailcap
9790 </dev/null MAILCAPS=./.tmailcap TMPDIR=`${pwd}` \
9791 ${MAILX} ${ARGS} -Snomailcap-disable \
9792 -Y '\mailcap' \
9793 -Rf "${MBOX}" > ./.tall 2>./.terr
9794 check 4.pre 0 ./.tall '1428075831 455'
9796 # Same with real programs
9797 printf '#
9798 text/plain; echo p-1-1\\;< %%s %s\\;echo p-1-2;\\
9799 test=echo X >> ./.terrmc\\; [ -n "$XY" ];x-mailx-test-once
9800 text/plain; echo p-2-1\\;< %%s %s\\;echo p-2-2;\\
9801 test=echo Y >> ./.terrmc\\;[ -z "$XY" ]
9802 text/plain; { file=%%s\\; echo p-3-1 = ${file##*.}\\;\\
9803 </dev/null %s %%s\\;echo p-3-2\\; } > ./.tx\\; %s -f ./.tx ./.tasy;\\
9804 test=[ -n "$XY" ];nametemplate=%%s.txt;x-mailx-async
9805 text/plain; echo p-4-1\\;%s\\;echo p-4-2;copiousoutput
9806 ' "${cat}" "${cat}" "${cat}" "${mv}" "${cat}" > ./.tmailcap
9808 </dev/null MAILCAPS=./.tmailcap TMPDIR=`${pwd}` \
9809 ${MAILX} ${ARGS} -Snomailcap-disable \
9810 -Y '#
9811 \echo =1
9812 \mimeview
9813 \echo =2
9814 \environ set XY=yes
9815 \mimeview
9816 \echo =3
9817 \type
9818 \echo =4
9820 -Rf "${MBOX}" > ./.tall 2>./.terr
9821 check 4 0 ./.tall '1912261831 831'
9822 check 5 - ./.terr '4294967295 0'
9823 check 6 - ./.terrmc '2376112102 6'
9824 check 7 - ./.tasy '3913344578 37' async
9826 # "Binary data"; ensure all possible temporary file / nametemplate
9827 # etc. paths are taken: avoid 2nd e7a60732c1906aefe4755fd61c5ffa81eeca0af0
9829 ${rm} -f "${MBOX}"
9830 printf 'du\x7fbo€o\bm' > ./.tatt.pdf
9831 printf 'du' | ${MAILX} ${ARGS} -a ./.tatt.pdf -s test "${MBOX}"
9832 check 8 0 "${MBOX}" '3444709420 644'
9834 printf '#
9835 # stdin
9836 application/pdf; echo p-1-1\\;%s\\;echo p-1-2; test=[ "$XY" = "" ]
9837 # tmpfile, no template
9838 application/pdf; echo p-2-1\\;< %%s %s\\;echo p-2-2; test = [ "$XY" = two ]
9839 # tmpfile, template
9840 application/pdf; echo p-3-1\\;< %%s %s\\;echo p-3-2; test=[ "$XY" = three ];\\
9841 nametemplate=%%s.txt
9842 # tmpfile, template, async
9843 application/pdf; { file=%%s \\; echo p-4-1 = ${file##*.}\\;\\
9844 </dev/null %s %%s\\;echo p-4-2\\; } > ./.tx\\; %s -f ./.tx ./.tasy;\\
9845 test=[ "$XY" = four ] ; nametemplate = %%s.txt ; x-mailx-async
9846 # copious,stdin
9847 application/pdf; echo p-5-1\\;%s\\;echo p-5-2; test=[ "$XY" = 1 ];\\
9848 copiousoutput
9849 # copious, tmpfile, no template
9850 application/pdf; echo p-6-1\\;< %%s %s\\;echo p-6-2; test = [ "$XY" = 2 ];\\
9851 copiousoutput
9852 # copious, tmpfile, template
9853 application/pdf; echo p-7-1\\;< %%s %s\\;echo p-7-2;test = [ "$XY" = 3 ];\\
9854 nametemplate=%%s.txt; copiousoutput
9855 ' "${cat}" "${cat}" "${cat}" "${cat}" "${mv}" "${cat}" "${cat}" "${cat}" \
9856 > ./.tmailcap
9858 </dev/null XY= MAILCAPS=./.tmailcap TMPDIR=`${pwd}` \
9859 ${MAILX} ${ARGS} -Snomailcap-disable \
9860 -Y '#
9861 \echo =1
9862 \mimeview
9863 \echo =2
9864 \environ set XY=two
9865 \mimeview
9866 \echo =3
9867 \environ set XY=three
9868 \mimeview
9869 \echo =4
9870 \environ set XY=four
9871 \mimeview
9872 \echo =5
9873 \environ set XY=1
9874 \type
9875 \echo =6
9876 \environ set XY=2
9877 \type
9878 \echo =7
9879 \environ set XY=3
9880 \type
9881 \echo =8
9883 -Rf "${MBOX}" > ./.tall 2>./.terr
9884 check 9 0 ./.tall '2388630345 3850'
9885 check 10 - ./.terr '4294967295 0'
9886 check 11 - ./.tasy '842146666 27' async
9888 # x-mailx-last-resort, x-mailx-ignore
9890 ${rm} -f "${MBOX}"
9891 printf 'in a pdf\n' > ./.tatt.pdf
9892 printf 'du\n' | ${MAILX} ${ARGS} -a ./.tatt.pdf -s test "${MBOX}"
9893 check 12 0 "${MBOX}" '3968874750 579'
9895 printf '#
9896 # stdin
9897 application/pdf;echo hidden;x-mailx-ignore
9898 application/pdf;echo hidden;copiousoutput;x-mailx-ignore
9899 application/pdf; echo pre\\;%s\\;echo post; x-mailx-last-resort
9900 ' "${cat}" > ./.tmailcap
9902 </dev/null XY= MAILCAPS=./.tmailcap TMPDIR=`${pwd}` \
9903 ${MAILX} ${ARGS} -Snomailcap-disable \
9904 -Y '#
9905 \echo =1
9906 \mimeview
9907 \echo =2
9908 \mimetype ?t application/pdf pdf
9909 \mimeview
9910 \echo =3
9911 \type
9912 \echo =4
9913 \unmimetype application/pdf
9914 \mimeview
9915 \echo =5
9917 -Rf "${MBOX}" > ./.tall 2>./.terr
9918 check 13 0 ./.tall '759843612 1961'
9919 check 14 - ./.terr '4294967295 0'
9921 t_epilog "${@}"
9923 # }}}
9925 # Unclassified rest {{{
9926 t_top() {
9927 t_prolog "${@}"
9929 t__gen_msg subject top1 to 1 from 1 cc 1 body 'body1-1
9930 body1-2
9932 body1-3
9933 body1-4
9936 body1-5
9937 ' > "${MBOX}"
9938 t__gen_msg subject top2 to 1 from 1 cc 1 body 'body2-1
9939 body2-2
9942 body2-3
9945 body2-4
9946 body2-5
9947 ' >> "${MBOX}"
9949 ${MAILX} ${ARGS} -Rf -Y '#
9950 \top 1
9951 \echo --- $?/$^ERRNAME, 1; \set toplines=10
9952 \top 1
9953 \echo --- $?/$^ERRNAME, 2; \set toplines=5
9954 \headerpick top retain subject # For top
9955 \headerpick type retain to subject # For Top
9956 \top 1
9957 \echo --- $?/$^ERRNAME, 3; \set topsqueeze
9958 \top 1 2
9959 \echo --- $?/$^ERRNAME, 4
9960 \Top 1
9961 \echo --- $?/$^ERRNAME, 5
9962 # ' "${MBOX}" > ./.tall 2>&1
9963 check 1 0 ./.tall '2556125754 705'
9965 t_epilog "${@}"
9968 t_s_mime() {
9969 t_prolog "${@}"
9971 if have_feat smime; then :; else
9972 t_echoskip '[!SMIME]'
9973 t_epilog "${@}"
9974 return
9977 ${cat} <<-_EOT > ./.t.conf
9978 [req]
9979 x509_extensions = extensions
9980 distinguished_name = req_distinguished_name
9981 attributes = req_attributes
9982 prompt = no
9983 output_password = Pacem_in_terris
9985 [extensions]
9986 basicConstraints = CA:FALSE
9987 # Needs a CA for that keyUsage = digitalSignature
9988 extendedKeyUsage = emailProtection
9990 [req_distinguished_name]
9991 C = GB
9992 ST = Over the
9993 L = rainbow
9994 O = S-nail
9995 OU = S-nail.smime
9996 CN = S-nail.test2
9997 emailAddress = test@localhost
9999 [req_attributes]
10000 challengePassword = hi ca it is me me me
10001 _EOT
10003 doit() {
10004 _z=${1}
10006 if [ "${_z}" = 0 ]; then
10007 _pass=
10008 _osslreq=-nodes
10009 _ossl=
10010 else
10011 _pass=Pacem_in_terris
10012 _osslreq=
10013 _ossl='-passin pass:'${_pass}
10016 ${rm} -f ./.VERIFY ./.ENCRYPT ./.DECRYPT
10018 openssl req ${_osslreq} ${_ossl} -x509 -days 3650 -config ./.t.conf \
10019 -newkey rsa:1024 -keyout ./.tkey.pem -out ./.tcert.pem >>${ERR} 2>&1
10020 check_ex0 ${_z}
10021 _z=`add ${_z} 1`
10023 ${cat} ./.tkey.pem ./.tcert.pem > ./.tpair.pem
10025 # Sign/verify
10026 echo bla | ${MAILX} ${ARGS} \
10027 -Ssmime-sign -Ssmime-sign-cert=./.tpair.pem -Sfrom=test@localhost \
10028 -Ssmime-sign-digest=sha1 \
10029 -S password-test@localhost.smime-cert-key=${_pass} \
10030 -s 'S/MIME test' ./.VERIFY >>${ERR} 2>&1
10031 check_ex0 ${_z}-estat
10032 ${awk} '
10033 BEGIN{ skip=0 }
10034 /^Content-Description: /{ skip = 2; print; next }
10035 /^$/{ if(skip) --skip }
10036 { if(!skip) print }
10038 < ./.VERIFY > "${MBOX}"
10039 check ${_z} - "${MBOX}" '335634014 644'
10040 _z=`add ${_z} 1`
10042 printf 'verify\nx\n' |
10043 ${MAILX} ${ARGS} -Ssmime-ca-file=./.tcert.pem -Serrexit \
10044 -R -f ./.VERIFY >>${ERR} 2>&1
10045 check_ex0 ${_z} # XXX pipe
10046 _z=`add ${_z} 1`
10048 openssl smime -verify -CAfile ./.tcert.pem -in ./.VERIFY >>${ERR} 2>&1
10049 check_ex0 ${_z}
10050 _z=`add ${_z} 1`
10052 # (signing +) encryption / decryption
10053 echo bla |
10054 ${MAILX} ${ARGS} \
10055 -Smta=test://./.ENCRYPT \
10056 -Ssmime-force-encryption -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
10057 -Ssmime-sign-digest=sha1 \
10058 -Ssmime-sign -Ssmime-sign-cert=./.tpair.pem -Sfrom=test@localhost \
10059 -S password-test@localhost.smime-cert-key=${_pass} \
10060 -s 'S/MIME test' recei@ver.com >>${ERR} 2>&1
10061 check_ex0 ${_z}-estat
10062 ${sed} -e '/^$/,$d' < ./.ENCRYPT > "${MBOX}"
10063 check ${_z} - "${MBOX}" '2359655411 336'
10064 _z=`add ${_z} 1`
10066 printf 'decrypt ./.DECRYPT\nfi ./.DECRYPT\nverify\nx\n' |
10067 ${MAILX} ${ARGS} \
10068 -Smta=test://./.ENCRYPT \
10069 -Ssmime-ca-file=./.tcert.pem \
10070 -Ssmime-sign-cert=./.tpair.pem \
10071 -Sfrom=test@localhost \
10072 -S password-test@localhost.smime-cert-key=${_pass} \
10073 -Serrexit -R -f ./.ENCRYPT >>${ERR} 2>&1
10074 check_ex0 ${_z}-estat
10075 ${awk} '
10076 BEGIN{ skip=0 }
10077 /^Content-Description: /{ skip = 2; print; next }
10078 /^$/{ if(skip) --skip }
10079 { if(!skip) print }
10081 < ./.DECRYPT > "${MBOX}"
10082 check ${_z} - "${MBOX}" '2602978204 940'
10083 _z=`add ${_z} 1`
10085 (openssl smime -decrypt ${_ossl} -inkey ./.tkey.pem -in ./.ENCRYPT |
10086 openssl smime -verify -CAfile ./.tcert.pem) >>${ERR} 2>&1
10087 check_ex0 ${_z} # XXX pipe..
10088 _z=`add ${_z} 1`
10090 ${rm} ./.ENCRYPT
10091 echo bla | ${MAILX} ${ARGS} \
10092 -Smta=test://./.ENCRYPT \
10093 -Ssmime-force-encryption -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
10094 -Sfrom=test@localhost \
10095 -S password-test@localhost.smime-cert-key=${_pass} \
10096 -s 'S/MIME test' recei@ver.com >>${ERR} 2>&1
10097 check_ex0 ${_z}-estat
10098 ${sed} -e '/^$/,$d' < ./.ENCRYPT > "${MBOX}"
10099 check ${_z} - "${MBOX}" '2359655411 336'
10100 _z=`add ${_z} 1`
10102 ${rm} ./.DECRYPT
10103 # Note: deduce from *sign-cert*, not from *from*!
10104 printf 'decrypt ./.DECRYPT\nx\n' | ${MAILX} ${ARGS} \
10105 -Smta=test://./.ENCRYPT \
10106 -Ssmime-sign-cert-recei@ver.com=./.tpair.pem \
10107 -S password-recei@ver.com.smime-cert-key=${_pass} \
10108 -Serrexit -R -f ./.ENCRYPT >>${ERR} 2>&1
10109 check ${_z} 0 ./.DECRYPT '2453471323 431'
10110 _z=`add ${_z} 1`
10112 openssl smime ${_ossl} -decrypt -inkey ./.tkey.pem -in ./.ENCRYPT \
10113 >>${ERR} 2>&1
10114 check_ex0 ${_z}
10116 unset _z _pass _osslreq _ossl
10119 doit 0
10120 doit 10
10122 t_epilog "${@}"
10124 # }}}
10126 # xxx Note: t_z() was the first test (series) written. Today many
10127 # xxx aspects are (better) covered by other tests above, some are not.
10128 # xxx At some future date and time, convert the last remains not covered
10129 # xxx elsewhere to a real t_* test and drop it
10130 t_z() {
10131 t_prolog "${@}"
10133 # Test for [260e19d] (Juergen Daubert)
10134 echo body | ${MAILX} ${ARGS} "${MBOX}"
10135 check 4 0 "${MBOX}" '2948857341 94'
10137 # "Test for" [c299c45] (Peter Hofmann) TODO shouldn't end up QP-encoded?
10138 ${rm} "${MBOX}"
10139 ${awk} 'BEGIN{
10140 for(i = 0; i < 10000; ++i)
10141 printf "\xC3\xBC"
10142 #printf "\xF0\x90\x87\x90"
10143 }' | ${MAILX} ${ARGS} ${ADDARG_UNI} -s TestSubject "${MBOX}"
10144 check 7 0 "${MBOX}" '1707496413 61812'
10146 t_epilog "${@}"
10149 # Test support {{{
10150 t__gen_msg() {
10151 t___gen_msg '' "${@}"
10154 t__gen_mimemsg() {
10155 t___gen_msg 1 "${@}"
10158 t___gen_msg() {
10159 ismime=${1}
10160 shift
10162 t___header() {
10163 printf '%s: ' ${1}
10164 case "${3}" in
10165 [0-9]*)
10166 ___hi=1
10167 while [ ${___hi} -le ${3} ]; do
10168 [ ${___hi} -gt 1 ] && printf ', '
10169 printf '%s%s <%s%s@exam.ple>' ${1} ${___hi} ${2} ${___hi}
10170 ___hi=`add ${___hi} 1`
10171 done
10174 printf '%s' "${3}"
10176 esac
10177 printf '\n'
10180 printf 'From reproducible_build Wed Oct 2 01:50:07 1996
10181 Date: Wed, 02 Oct 1996 01:50:07 +0000
10184 body=Body
10185 while [ ${#} -ge 2 ]; do
10186 case "${1}" in
10187 from) t___header From from "${2}";;
10188 to) t___header To to "${2}";;
10189 cc) t___header Cc cc "${2}";;
10190 bcc) t___header Bcc bcc "${2}";;
10191 subject) printf 'Subject: %s\n' "${2}";;
10192 body) body="${2}";;
10193 esac
10194 shift 2
10195 done
10197 if [ -z "${ismime}" ]; then
10198 printf '\n%s\n\n' "${body}"
10199 else
10200 printf 'MIME-Version: 1.0
10201 Message-ID: <20200204225307.FaKeD%%bo@oo>
10202 Content-Type: multipart/mixed; boundary="=BOUNDOUT="
10204 --=BOUNDOUT=
10205 Content-Type: multipart/alternative; boundary==BOUNDIN=
10207 --=BOUNDIN=
10208 Content-Type: text/plain; charset=utf-8
10209 Content-Transfer-Encoding: 8-bit
10213 --=BOUNDIN=
10214 Content-Type: text/html; charset=utf-8
10215 Content-Transfer-Encoding: 8-bit
10217 <HTML><BODY>%s<BR></BODY></HTML>
10219 --=BOUNDIN=--
10221 --=BOUNDOUT=
10222 Content-Type: text/troff
10224 Golden Brown
10226 --=BOUNDOUT=
10227 Content-Type: text/x-uuencode
10229 Aprendimos a quererte
10230 --=BOUNDOUT=--
10232 ' "${body}" "${body}"
10236 t__x1_msg() {
10237 ${cat} <<-_EOT
10238 From neverneverland Sun Jul 23 13:46:25 2017
10239 Subject: Bugstop: five miles out 1
10240 Reply-To: mister originator1 <mr1@originator>
10241 From: mister originator1 <mr1@originator>
10242 To: bugstop-commit@five.miles.out
10243 Cc: is1@a.list
10244 In-reply-to: <20170719111113.bkcMz%laber1@backe.eu>
10245 Date: Wed, 19 Jul 2017 09:22:57 -0400
10246 Message-Id: <20170719132257.766AF781267-1@originator>
10247 Mail-Followup-To: bugstop@five.miles.out, laber@backe.eu, is@a.list
10248 Status: RO
10250 That's appalling, I.
10252 _EOT
10255 t__x2_msg() {
10256 ${cat} <<-_EOT
10257 From neverneverland Sun Jul 23 13:47:25 2017
10258 Subject: Bugstop: five miles out 2
10259 Reply-To: mister originator2 <mr2@originator>
10260 From: mister originator2 <mr2@originator>
10261 To: bugstop-commit@five.miles.out
10262 Cc: is2@a.list
10263 In-reply-to: <20170719111113.bkcMz%laber2@backe.eu>
10264 Date: Wed, 19 Jul 2017 09:23:57 -0400
10265 Message-Id: <20170719132257.766AF781267-2@originator>
10266 Status: RO
10268 That's appalling, II.
10270 _EOT
10273 t__x3_msg() {
10274 ${cat} <<-_EOT
10275 From neverneverland Sun Jul 23 13:48:25 2017
10276 Subject: Bugstop: five miles out 3
10277 Reply-To: mister originator3 <mr3@originator>
10278 From: mister originator3 <mr3@originator>
10279 To: bugstop-commit@five.miles.out
10280 Cc: is3@a.list
10281 In-reply-to: <20170719111113.bkcMz%laber3@backe.eu>
10282 Date: Wed, 19 Jul 2017 09:24:57 -0400
10283 Message-Id: <20170719132257.766AF781267-3@originator>
10284 Status: RO
10286 That's appalling, III.
10288 _EOT
10291 t__put_subject() {
10292 # MIME encoding (QP) stress message subject
10293 printf 'Äbrä Kä?dä=brö Fü?di=bus? '\
10294 'adadaddsssssssddddddddddddddddddddd'\
10295 'ddddddddddddddddddddddddddddddddddd'\
10296 'ddddddddddddddddddddddddddddddddddd'\
10297 'dddddddddddddddddddd Hallelulja? Od'\
10298 'er?? eeeeeeeeeeeeeeeeeeeeeeeeeeeeee'\
10299 'eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'\
10300 'eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee f'\
10301 'fffffffffffffffffffffffffffffffffff'\
10302 'fffffffffffffffffffff ggggggggggggg'\
10303 'ggggggggggggggggggggggggggggggggggg'\
10304 'ggggggggggggggggggggggggggggggggggg'\
10305 'ggggggggggggggggggggggggggggggggggg'\
10306 'gggggggggggggggg'
10309 t__put_body() {
10310 # MIME encoding (QP) stress message body
10311 printf \
10312 'Ich bin eine DÖS-Datäi mit sehr langen Zeilen und auch '\
10313 'sonst bin ich ganz schön am Schleudern, da kannste denke '\
10314 "wasde willst, gelle, gelle, gelle, gelle, gelle.\r\n"\
10315 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst \r\n"\
10316 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1\r\n"\
10317 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12\r\n"\
10318 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123\r\n"\
10319 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1234\r\n"\
10320 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12345\r\n"\
10321 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123456\r\n"\
10322 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1234567\r\n"\
10323 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12345678\r\n"\
10324 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123456789\r\n"\
10325 "Unn ausserdem habe ich trailing SP/HT/SP/HT whitespace \r\n"\
10326 "Unn ausserdem habe ich trailing HT/SP/HT/SP whitespace \r\n"\
10327 "auf den zeilen vorher.\r\n"\
10328 "From am Zeilenbeginn und From der Mitte gibt es auch.\r\n"\
10329 ".\r\n"\
10330 "Die letzte Zeile war nur ein Punkt.\r\n"\
10331 "..\r\n"\
10332 "Das waren deren zwei.\r\n"\
10333 " \r\n"\
10334 "Die letzte Zeile war ein Leerschritt.\n"\
10335 "=VIER = EQUAL SIGNS=ON A LINE=\r\n"\
10336 "Prösterchen.\r\n"\
10337 ".\n"\
10338 "Die letzte Zeile war nur ein Punkt, mit Unix Zeilenende.\n"\
10339 "..\n"\
10340 "Das waren deren zwei. ditto.\n"\
10341 "Prösterchen.\n"\
10342 "Unn ausseerdem habe ich trailing SP/HT/SP/HT whitespace \n"\
10343 "Unn ausseerdem habe ich trailing HT/SP/HT/SP whitespace \n"\
10344 "auf den zeilen vorher.\n"\
10345 "ditto.\n"\
10346 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.\n"\
10347 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.1"\
10348 "\n"\
10349 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
10350 "\n"\
10351 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
10352 "3\n"\
10353 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
10354 "34\n"\
10355 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
10356 "345\n"\
10357 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
10358 "3456\n"\
10359 "QP am Zeilenende über soft-nl hinweg\n"\
10360 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
10361 "ö123\n"\
10362 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
10363 "1ö23\n"\
10364 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
10365 "12ö3\n"\
10366 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
10367 "123ö\n"\
10368 "=VIER = EQUAL SIGNS=ON A LINE=\n"\
10369 " \n"\
10370 "Die letzte Zeile war ein Leerschritt.\n"\
10373 # }}}
10375 # cc_all_configs() {{{
10376 # Test all configs TODO doesn't cover all *combinations*, stupid!
10377 cc_all_configs() {
10378 if [ ${MAXJOBS} -gt 1 ]; then
10379 MAXJOBS='-j '${MAXJOBS}
10380 else
10381 MAXJOBS=
10383 if [ -n "${NOCOLOUR}" ] || [ -n "${MAILX_CC_TEST_NO_COLOUR}" ]; then
10384 MAILX_CC_TEST_NO_COLOUR=1
10385 export MAILX_CC_TEST_NO_COLOUR
10388 < ${CONF} ${awk} '
10389 BEGIN{
10390 ALWAYS = "OPT_AUTOCC=1 OPT_AMALGAMATION=1"
10391 NOTME["OPT_AUTOCC_STACKPROT"] = 1
10392 NOTME["OPT_ALWAYS_UNICODE_LOCALE"] = 1
10393 NOTME["OPT_CROSS_BUILD"] = 1
10394 NOTME["OPT_AUTOCC"] = 1
10395 NOTME["OPT_AMALGAMATION"] = 1
10396 NOTME["OPT_DEBUG"] = 1
10397 NOTME["OPT_DEVEL"] = 1
10398 NOTME["OPT_ASAN_ADDRESS"] = 1
10399 NOTME["OPT_ASAN_MEMORY"] = 1
10400 NOTME["OPT_USAN"] = 1
10401 NOTME["OPT_NOMEMDBG"] = 1
10403 #OPTVALS
10404 OPTNO = 0
10406 MULCHOICE["OPT_ICONV"] = "VAL_ICONV"
10407 MULVALS["VAL_ICONV"] = 1
10408 MULCHOICE["OPT_IDNA"] = "VAL_IDNA"
10409 MULVALS["VAL_IDNA"] = 1
10411 #VALKEYS[0] = "VAL_RANDOM"
10412 VALVALS["VAL_RANDOM"] = 1
10413 VALNO = 0
10415 /^[ ]*OPT_/{
10416 sub(/^[ ]*/, "")
10417 # This bails for UnixWare 7.1.4 awk(1), but preceeding = with \
10418 # does not seem to be a compliant escape for =
10419 #sub(/=.*$/, "")
10420 $1 = substr($1, 1, index($1, "=") - 1)
10421 if(!NOTME[$1])
10422 OPTVALS[OPTNO++] = $1
10423 next
10425 /^[ ]*VAL_/{
10426 sub(/^[ ]*/, "")
10427 val = substr($0, index($0, "=") + 1)
10428 if(val ~ /^"/){
10429 val = substr(val, 2)
10430 val = substr(val, 1, length(val) - 1)
10432 $1 = substr($1, 1, index($1, "=") - 1)
10433 if(MULVALS[$1])
10434 MULVALS[$1] = val
10435 else if(VALVALS[$1]){
10436 VALKEYS[VALNO++] = $1
10437 VALVALS[$1] = val
10439 next
10441 function onepass(addons){
10442 a_onepass__worker(addons, "1", "0")
10443 a_onepass__worker(addons, "0", "1")
10445 function a_onepass__worker(addons, b0, b1){
10446 # Doing this completely sequentially and not doing make distclean in
10447 # between runs should effectively result in lesser compilations.
10448 # It is completely dumb nonetheless... TODO
10449 for(ono = 0; ono < OPTNO; ++ono){
10450 myconf = mula = ""
10451 for(i = 0; i < ono; ++i){
10452 myconf = myconf " " OPTVALS[i] "=" b0 " "
10453 if(b0 == "1"){
10454 j = MULCHOICE[OPTVALS[i]]
10455 if(j){
10456 if(i + 1 == ono)
10457 mula = j
10458 else
10459 myconf = myconf " " MULCHOICE[OPTVALS[i]] "=any "
10463 for(i = ono; i < OPTNO; ++i){
10464 myconf = myconf " " OPTVALS[i] "=" b1 " "
10465 if(b1 == "1"){
10466 j = MULCHOICE[OPTVALS[i]]
10467 if(j){
10468 if(i + 1 == OPTNO)
10469 mula = j;
10470 else
10471 myconf = myconf " " MULCHOICE[OPTVALS[i]] "=any "
10476 for(i in VALKEYS)
10477 myconf = VALKEYS[i] "=any " myconf
10479 myconf = myconf " " ALWAYS " " addons
10481 if(mula == "")
10482 print myconf
10483 else{
10484 i = split(MULVALS[mula], ia)
10485 j = "any"
10486 while(i >= 1){
10487 j = ia[i--] " " j
10488 print mula "=\"" j "\" " myconf
10493 END{
10494 # We cannot test NULL because of missing UI strings, which will end
10495 # up with different checksums
10496 print "CONFIG=NULLI OPT_AUTOCC=1"
10497 for(i in VALKEYS){
10498 j = split(VALVALS[VALKEYS[i]], ia)
10499 k = "any"
10500 while(j >= 1){
10501 k = ia[j--] " " k
10502 print VALKEYS[i] "=\"" k "\" CONFIG=NULLI OPT_AUTOCC=1"
10505 print "CONFIG=MINIMAL OPT_AUTOCC=1"
10506 print "CONFIG=NETSEND OPT_AUTOCC=1"
10507 print "CONFIG=MAXIMAL OPT_AUTOCC=1"
10508 for(i in VALKEYS){
10509 j = split(VALVALS[VALKEYS[i]], ia)
10510 k = "any"
10511 while(j >= 1){
10512 k = ia[j--] " " k
10513 print VALKEYS[i] "=\"" k "\" CONFIG=MAXIMAL OPT_AUTOCC=1"
10516 print "CONFIG=DEVEL OPT_AUTOCC=1"
10517 print "CONFIG=ODEVEL OPT_AUTOCC=1"
10519 print split_here
10521 onepass("OPT_DEBUG=1")
10522 onepass("")
10524 ' | while read c; do
10525 if [ "$c" = split_here ]; then
10526 printf 'Predefined configs done, now OPT_ combinations\n'
10527 printf 'Predefined configs done, now OPT_ combinations\n' >&2
10528 ${SHELL} -c "cd ../ && ${MAKE} distclean"
10529 continue
10531 [ -f mk-config.h ] && ${cp} mk-config.h .ccac.h
10532 printf "\n\n##########\n${MAKE} ${MAXJOBS} config $c\n"
10533 printf "\n\n##########\n${MAKE} ${MAXJOBS} config $c\n" >&2
10534 ${SHELL} -c "cd .. && ${MAKE} ${MAXJOBS} config ${c}"
10535 if [ -f .ccac.h ] && ${cmp} mk-config.h .ccac.h; then
10536 printf 'Skipping after config, nothing changed\n'
10537 printf 'Skipping after config, nothing changed\n' >&2
10538 continue
10540 ${SHELL} -c "cd ../ && ${MAKE} ${MAXJOBS} build test"
10541 done
10542 ${rm} -f .ccac.h
10543 cd .. && ${MAKE} distclean
10545 # }}}
10547 ssec=$SECONDS
10548 if [ -z "${CHECK}${RUN_TEST}" ]; then
10549 jobs_max
10550 cc_all_configs
10551 else
10552 if have_feat debug; then
10553 if have_feat devel; then
10554 JOBSYNC=1
10555 DEVELDIFF=y
10556 DUMPERR=y
10557 ARGS="${ARGS} -Smemdebug"
10558 JOBWAIT=`add $JOBWAIT $JOBWAIT`
10560 elif have_feat devel; then
10561 DEVELDIFF=y
10562 DUMPERR=y
10563 LOOPS_MAX=${LOOPS_BIG}
10565 color_init
10567 if [ -z "${RUN_TEST}" ] || [ ${#} -eq 0 ]; then
10568 jobs_max
10569 printf 'Will do up to %s tests in parallel, with a %s second timeout\n' \
10570 ${MAXJOBS} ${JOBWAIT}
10571 jobreaper_start
10572 t_all
10573 jobreaper_stop
10574 else
10575 MAXJOBS=1
10576 printf 'Tests have a %s second timeout\n' ${JOBWAIT}
10577 jobreaper_start
10578 while [ ${#} -gt 0 ]; do
10579 jspawn ${1}
10580 shift
10581 done
10582 jobreaper_stop
10586 esec=$SECONDS
10588 printf '%u tests: %s%u ok%s, %s%u failure(s)%s. %s%u test(s) skipped%s\n' \
10589 "${TESTS_PERFORMED}" "${COLOR_OK_ON}" "${TESTS_OK}" "${COLOR_OK_OFF}" \
10590 "${COLOR_ERR_ON}" "${TESTS_FAILED}" "${COLOR_ERR_OFF}" \
10591 "${COLOR_WARN_ON}" "${TESTS_SKIPPED}" "${COLOR_WARN_OFF}"
10592 if [ -n "${ssec}" ] && [ -n "${esec}" ]; then
10593 ( echo 'Elapsed seconds: '`$awk 'BEGIN{print '"${esec}"' - '"${ssec}"'}'` )
10596 exit ${ESTAT}
10597 # s-sh-mode