mk/make-release.txt: mention key steffen.asc
[s-mailx.git] / mx-test.sh
blob02028ea5ca45678a657b9ef0418878c10ee932af
1 #!/bin/sh -
2 #@ Synopsis: [OBJDIR=XY] ./mx-test.sh --check mailx-binary [:SKIPTESTNAME:]
3 #@ [OBJDIR=XY] ./mx-test.sh --run-test mailx-binary [:TESTNAME:]
4 #@ [./mx-test.sh # Note: performs hundreds of compilations!]
5 #@ --no-jobs can be used to prevent spawning concurrent tests.
6 #@ --no-colour or $MAILX_CC_TEST_NO_COLOUR for not trying to use colour
7 #@ (then grep for ^ERROR, for example).
8 #@ The last mode also reacts on $MAILX_CC_ALL_TESTS_DUMPERR, for even easier
9 #@ grep ^ERROR handling.
10 #@ And setting $MAILX_CC_TEST_NO_CLEANUP keeps all test data around, fwiw:
11 #@ this works with --run-test only.
12 #@ $JOBWAIT, $JOBMON and $SKIPTEST are taken from environment when found.
14 # Public Domain
16 : ${OBJDIR:=.obj}
18 # Instead of figuring out the environment in here, require a configured build
19 # system and include that! Our makefile and configure ensure that this test
20 # does not run in the configured, but the user environment nonetheless!
22 while :; do
23 if [ -f ./mk-config.env ]; then
24 break
25 elif [ -f snailmail.jpg ] && [ -f "${OBJDIR}"/mk-config.env ]; then
26 i=`pwd`/ # not from environment, sic
27 cd "${OBJDIR}"
28 break
29 else
30 echo >&2 'S-nail/S-mailx is not configured.'
31 echo >&2 'This test script requires the shell environment that only the'
32 echo >&2 'configuration script can figure out, even if used to test'
33 echo >&2 'a different binary than the one that would be produced!'
34 echo >&2 '(The information will be in ${OBJDIR:=.obj}/mk-config.env.)'
35 echo >&2 'Hit RETURN to run "make config"'
36 read l
37 make config
39 done
40 . ./mk-config.env
41 if [ -z "${MAILX__CC_TEST_RUNNING}" ]; then
42 MAILX__CC_TEST_RUNNING=1
43 export MAILX__CC_TEST_RUNNING
44 exec "${SHELL}" "${i}${0}" "${@}"
47 # We need *stealthmua* regardless of $SOURCE_DATE_EPOCH, the program name as
48 # such is a compile-time variable
49 ARGS='-Sv15-compat -:/ -Sdotlock-disable -Smta=test -Smta-bcc-ok'
50 ARGS="${ARGS}"' -Smemdebug -Sstealthmua'
51 ARGS="${ARGS}"' -Smime-encoding=quoted-printable -Snosave'
52 ARGS="${ARGS}"' -Smailcap-disable -Smimetypes-load-control='
53 NOBATCH_ARGS="${ARGS}"' -Sexpandaddr'
54 ARGS="${ARGS}"' -Sexpandaddr=restrict -#'
55 ADDARG_UNI=-Sttycharset=UTF-8
56 CONF=../make.rc
57 BODY=./.cc-body.txt
58 MBOX=./.cc-test.mbox
59 ERR=./.cc-test.err # Covers some which cannot be checksummed; not quoted!
60 MAIL=/dev/null
61 #UTF8_LOCALE= HONOURS_READONLY= autodetected unless set
62 TMPDIR=`${pwd}`
64 # When testing mass mail/loops, maximum number of receivers/loops.
65 # TODO note we do not gracefully handle ARG_MAX excess yet!
66 # Those which use this have checksums for 2001 and 201.
67 # Some use the smaller automatically if +debug
68 LOOPS_BIG=2001 LOOPS_SMALL=201
69 LOOPS_MAX=$LOOPS_SMALL
71 # How long unless started tests get reaped (avoid endless looping)
72 : ${JOBWAIT:=42}
73 : ${JOBMON:=y}
74 : ${SKIPTEST:=}
76 # Note valgrind has problems with FDs in forked childs, which causes some tests
77 # to fail (the FD is rewound and thus will be dumped twice)
78 MEMTESTER=
79 #MEMTESTER='valgrind --leak-check=full --log-file=.vl-%p '
81 ## -- >8 -- 8< -- ##
83 t_all() {
84 # Absolute Basics
85 jspawn X_Y_opt_input_go_stack
86 jspawn X_errexit
87 jspawn Y_errexit
88 jspawn S_freeze
89 jspawn f_batch_order
90 jspawn input_inject_semicolon_seq
91 jspawn wysh
92 jspawn commandalias # test now, save space later on!
93 jspawn posix_abbrev
94 jsync
96 # Basics
97 jspawn shcodec
98 jspawn ifelse
99 jspawn localopts
100 jspawn local
101 jspawn environ
102 jspawn macro_param_shift
103 jspawn addrcodec
104 jspawn csop
105 jspawn vexpr
106 jspawn call_ret
107 jspawn xcall
108 jspawn vpospar
109 jspawn atxplode
110 jspawn read
111 jspawn readsh
112 jspawn headerpick # so we have a notion that it works a bit
113 jsync
115 # Send/RFC absolute basics
116 jspawn can_send_rfc
117 jspawn reply
118 jspawn forward
119 jspawn resend
120 jsync
122 # VFS
123 jspawn copy
124 jspawn save
125 jspawn move
126 jspawn mbox
127 jspawn maildir
128 jsync
130 # MIME and RFC basics
131 jspawn mime_if_not_ascii
132 jspawn mime_encoding
133 jspawn xxxheads_rfc2047
134 jspawn iconv_mbyte_base64
135 jspawn iconv_mainbody
136 jspawn mime_force_sendout
137 jspawn binary_mainbody
138 jspawn C_opt_customhdr
139 jsync
141 # Operational basics with trivial tests
142 jspawn alias
143 jspawn charsetalias
144 jspawn shortcut
145 jspawn netrc
146 jsync
148 # Operational basics with easy tests
149 jspawn expandaddr # (after t_alias)
150 jspawn mta_aliases # (after t_expandaddr)
151 jspawn filetype
152 jspawn e_H_L_opts
153 jspawn q_t_etc_opts
154 jspawn message_injections
155 jspawn attachments
156 jspawn rfc2231 # (after attachments)
157 jspawn mime_types_load_control
158 jsync
160 # Around state machine, after basics
161 jspawn alternates
162 jspawn cmd_escapes
163 jspawn compose_edits
164 jspawn digmsg
165 jspawn on_main_loop_tick
166 jspawn on_program_exit
167 jsync
169 # Heavy use of/rely on state machine (behaviour) and basics
170 jspawn compose_hooks
171 jspawn mass_recipients
172 jspawn lreply_futh_rth_etc
173 jspawn pipe_handlers
174 jspawn mailcap
175 jsync
177 # Unclassified rest
178 jspawn top
179 jspawn s_mime
180 jspawn z
181 jsync
183 jsync 1
186 ## Now it is getting really weird. You have been warned.
187 # Setup and support {{{
188 export ARGS ADDARG_UNI CONF BODY MBOX MAIL TMPDIR \
189 MAKE awk cat cksum rm sed grep
191 LC_ALL=C LANG=C
192 TZ=UTC
193 # Wed Oct 2 01:50:07 UTC 1996
194 SOURCE_DATE_EPOCH=844221007
196 export LC_ALL LANG TZ SOURCE_DATE_EPOCH
197 unset POSIXLY_CORRECT LOGNAME USER
199 # usage {{{
200 usage() {
201 ${cat} >&2 <<'_EOT'
202 Synopsis: [OBJDIR=x] mx-test.sh [--no-jobs] --check mailx-binary [:SKIPTEST:]
203 Synopsis: [OBJDIR=x] mx-test.sh [--no-jobs] --run-test mailx-binary [:TEST:]
204 Synopsis: [OBJDIR=x] mx-test.sh [--no-jobs]
206 --check EXE [:SKIPTEST:] run test series, exit success or error.
207 [:SKIPTEST:]s (and $SKIPTEST=) will be excluded.
208 --run-test EXE [:TEST:] run all or only the given TESTs, and create
209 test output data files; if run in a git(1)
210 checkout with the [test-out] branch available,
211 it will also create file diff(1)erences
212 --no-jobs do not spawn multiple jobs simultaneously
213 (dependent on make(1) and sh(1), pass JOBMON=n, too)
214 --no-colour or $MAILX_CC_TEST_NO_COLOUR: no colour
215 (for example to: grep ^ERROR)
216 $MAILX_CC_ALL_TESTS_DUMPER in addition for even
217 easier grep ^ERROR handling
219 The last invocation style will compile and test as many different
220 configurations as possible.
221 EXE should be absolute or relative to $OBJDIR, which can be may be set to the
222 location of the built objects etc.
223 $MAILX_CC_TEST_NO_CLEANUP skips deletion of test data (works only with
224 one test, aka --run-test).
225 $JOBWAIT could denote a timeout, $JOBMON controls usage of "set -m".
226 _EOT
227 exit 1
230 CHECK= RUN_TEST= MAILX=
231 DEVELDIFF= DUMPERR= GIT_REPO=
232 MAXJOBS=1 NOCOLOUR= NOJOBS=
233 while [ ${#} -gt 0 ]; do
234 if [ "${1}" = --no-jobs ]; then
235 NOJOBS=y
236 shift
237 elif [ "${1}" = --no-colour ]; then
238 NOCOLOUR=y
239 shift
240 elif [ "${1}" = -h ] || [ "${1}" = --help ]; then
241 usage
242 exit 0
243 else
244 break
246 done
248 if [ "${1}" = --check ]; then
249 CHECK=1 MAILX=${2}
250 [ -x "${MAILX}" ] || usage
251 shift 2
252 SKIPTEST="${@} ${SKIPTEST}"
253 [ -d ../.git ] && [ -z "${MAILX__CC_TEST_NO_DATA_FILES}" ] && GIT_REPO=1
254 echo 'Mode: --check, binary: '"${MAILX}"
255 elif [ "${1}" = --run-test ]; then
256 [ ${#} -ge 2 ] || usage
257 RUN_TEST=1 MAILX=${2}
258 [ -x "${MAILX}" ] || usage
259 shift 2
260 [ -d ../.git ] && GIT_REPO=1
261 echo 'Mode: --run-test, binary: '"${MAILX}"
262 else
263 [ ${#} -eq 0 ] || usage
264 echo 'Mode: full compile test, this will take a long time...'
265 MAILX__CC_TEST_NO_DATA_FILES=1
266 export MAILX__CC_TEST_NO_DATA_FILES
268 # }}}
270 # Since we invoke $MAILX from within several directories we need a fully
271 # qualified path. Or at least something similar.
272 { echo ${MAILX} | ${grep} -q ^/; } || MAILX="${TMPDIR}"/${MAILX}
273 RAWMAILX=${MAILX}
274 MAILX="${MEMTESTER}${MAILX}"
275 export RAWMAILX MAILX
277 # We want an UTF-8 locale, and HONOURS_READONLY {{{
278 if [ -n "${CHECK}${RUN_TEST}" ]; then
279 if [ -z "${UTF8_LOCALE}" ]; then
280 # Try ourselfs via nl_langinfo(CODESET) first (requires a new version)
281 if command -v "${RAWMAILX}" >/dev/null 2>&1 &&
282 ("${RAWMAILX}" -:/ -Xxit) >/dev/null 2>&1; then
283 echo 'Trying to detect UTF-8 locale via '"${RAWMAILX}"
284 i=`</dev/null LC_ALL=C.utf8 "${RAWMAILX}" ${ARGS} -X '
285 \define cset_test {
286 \if "${ttycharset}" =%?case utf
287 \echo $LC_ALL
288 \xit 0
289 \end
290 \if "${#}" -gt 0
291 \wysh set LC_ALL=${1}
292 \shift
293 \xcall cset_test "${@}"
294 \end
295 \xit 1
297 \# POSIX last (faulty localedef(1) result of GNU C lib 2.3[24])
298 \call cset_test C.UTF-8 \
299 en_EN.utf8 en_EN.UTF-8 en_US.utf8 en_US.UTF-8 \
300 POSIX.utf8 POSIX.UTF-8
302 [ $? -eq 0 ] && UTF8_LOCALE=$i
305 if [ -z "${UTF8_LOCALE}" ] && (locale yesexpr) >/dev/null 2>&1; then
306 echo 'Trying to detect UTF-8 locale via locale -a'
307 UTF8_LOCALE=`locale -a | { m=
308 while read n; do
309 if { echo ${n} |
310 ${grep} -i -e utf8 -e utf-8; } >/dev/null 2>&1; then
311 m=${n}
312 if { echo ${n} |
313 ${grep} -e POSIX -e en_EN -e en_US; } \
314 >/dev/null 2>&1; then
315 break
318 done
319 echo ${m}
324 if [ -n "${UTF8_LOCALE}" ]; then
325 echo 'Using Unicode locale '"${UTF8_LOCALE}"
326 else
327 echo 'No Unicode locale found, disabling Unicode tests'
330 if [ -z "${HONOURS_READONLY}" ]; then
331 trap "${rm} -f ./.tisrdonly" EXIT
332 trap "exit 1" HUP INT TERM
333 printf '' > ./.tisrdonly
334 ${chmod} 0444 ./.tisrdonly
335 if (printf 'no\n' > ./.tisrdonly) >/dev/null 2>&1 &&
336 test -s ./.tisrdonly; then
337 HONOURS_READONLY=
338 else
339 HONOURS_READONLY=yes
341 ${rm} -f ./.tisrdonly
342 trap '' EXIT HUP INT TERM
346 export UTF8_LOCALE HONOURS_READONLY
347 # }}}
349 TESTS_PERFORMED=0 TESTS_OK=0 TESTS_FAILED=0 TESTS_SKIPPED=0
350 JOBS=0 JOBLIST= JOBREAPER= JOBSYNC=
351 SUBSECOND_SLEEP=
352 ( sleep .1 ) >/dev/null 2>&1 && SUBSECOND_SLEEP=y
354 COLOR_ERR_ON= COLOR_ERR_OFF= COLOR_DBGERR_ON= COLOR_DBGERR_OFF=
355 COLOR_WARN_ON= COLOR_WARN_OFF=
356 COLOR_OK_ON= COLOR_OK_OFF=
357 ESTAT=0
358 TEST_NAME=
360 trap "
361 jobreaper_stop
362 [ -z "${MAILX_CC_TEST_NO_CLEANUP}" ] &&
363 ${rm} -rf ./t.*.d ./t.*.io ./t.*.result ./t.time.out
364 " EXIT
365 trap "exit 1" HUP INT QUIT TERM
367 # JOBS {{{
368 if [ -n "${NOJOBS}" ]; then
369 jobs_max() { :; }
370 else
371 jobs_max() {
372 # The user desired variant
373 if ( echo "${MAKEFLAGS}" | ${grep} -- -j ) >/dev/null 2>&1; then
374 i=`echo "${MAKEFLAGS}" |
375 ${sed} -e 's/^.*-j[ ]*\([0-9]\{1,\}\).*$/\1/'`
376 if ( echo "${i}" | grep -q -e '^[0-9]\{1,\}$' ); then
377 printf 'Job number derived from MAKEFLAGS: %s\n' ${i}
378 MAXJOBS=${i}
379 [ "${MAXJOBS}" -eq 0 ] && MAXJOBS=1
380 return
384 # The actual hardware
385 printf 'all:\n' > t.mk.io
386 if ( ${MAKE} -j 10 -f t.mk.io ) >/dev/null 2>&1; then
387 if command -v nproc >/dev/null 2>&1; then
388 i=`nproc 2>/dev/null`
389 [ ${?} -eq 0 ] && MAXJOBS=${i}
390 else
391 i=`getconf _NPROCESSORS_ONLN 2>/dev/null`
392 j=${?}
393 if [ ${j} -ne 0 ]; then
394 i=`getconf NPROCESSORS_ONLN 2>/dev/null`
395 j=${?}
397 if [ ${j} -ne 0 ]; then
398 # SunOS 5.9 ++
399 if command -v kstat >/dev/null 2>&1; then
400 i=`PERL5OPT= kstat -p cpu | ${awk} '
401 BEGIN{no=0; FS=":"}
402 {if($2 > no) max = $2; next}
403 END{print ++max}
404 ' 2>/dev/null`
405 j=${?}
408 if [ ${j} -eq 0 ] && [ -n "${i}" ]; then
409 printf 'Job number derived from CPU number: %s\n' ${i}
410 MAXJOBS=${i}
413 [ "${MAXJOBS}" -eq 0 ] && MAXJOBS=1
418 jobreaper_start() {
419 case "${JOBMON}" in
420 [yY]*)
421 # There were problems when using monitor mode with mksh
422 i=`env -i ${SHELL} -c 'echo $KSH_VERSION'`
423 if [ -n "${i}" ]; then
424 if [ "${i}" != "${i#*MIRBSD}" ]; then
425 JOBMON=
429 if [ -n "${JOBMON}" ]; then
430 ( set -m ) </dev/null >/dev/null 2>&1 || JOBMON=
431 else
432 printf >&2 '%s! $JOBMON: $SHELL %s incapable, disabled!%s\n' \
433 "${COLOR_ERR_ON}" "${SHELL}" "${COLOR_ERR_OFF}"
434 printf >&2 '%s! No process groups available, killed tests may '\
435 'leave process "zombies"!%s\n' \
436 "${COLOR_ERR_ON}" "${COLOR_ERR_OFF}"
440 JOBMON=
442 esac
445 jobreaper_stop() {
446 if [ ${JOBS} -gt 0 ]; then
447 echo 'Cleaning up running jobs'
448 [ -n "${JOBREAPER}" ] && kill -KILL ${JOBREAPER} >/dev/null 2>&1
449 jtimeout
450 wait ${JOBLIST}
451 JOBLIST=
455 jspawn() {
456 if [ -n "${CHECK}" ] && [ -n "${SKIPTEST}" ]; then
457 i="${@}"
458 j="${1}"
460 set -- ${SKIPTEST}
461 SKIPTEST=
462 while [ ${#} -gt 0 ]; do
463 if [ "${1}" != "${j}" ]; then
464 SKIPTEST="${SKIPTEST} ${1}"
465 elif [ -z "${k}" ]; then
467 t_echoskip ${1}
469 shift
470 done
471 [ -n "${k}" ] && return
472 set -- "${i}"
475 if [ ${MAXJOBS} -gt 1 ]; then
476 # We are spawning multiple jobs..
477 [ ${JOBS} -eq 0 ] && printf '...'
478 JOBS=`add ${JOBS} 1`
479 printf ' [%s=%s]' ${JOBS} "${1}"
480 else
481 JOBS=1
482 # Assume problems exist, do not let user keep hanging on terminal
483 if [ -n "${RUN_TEST}" ]; then
484 printf '... [%s]\n' "${1}"
488 [ -n "${JOBMON}" ] && set -m >/dev/null 2>&1
489 ( # Place the job in its own directory to ease file management
490 trap '' EXIT HUP INT QUIT TERM USR1 USR2
491 ${mkdir} t.${JOBS}.d && cd t.${JOBS}.d &&
492 eval t_${1} ${JOBS} ${1} &&
493 ${rm} -f ../t.${JOBS}.id
494 ) > t.${JOBS}.io </dev/null & # 2>&1 </dev/null &
495 i=${!}
496 [ -n "${JOBMON}" ] && set +m >/dev/null 2>&1
497 JOBLIST="${JOBLIST} ${i}"
498 printf '%s\n%s\n' ${i} ${1} > t.${JOBS}.id
500 # ..until we should sync or reach the maximum concurrent number
501 [ ${JOBS} -lt ${MAXJOBS} ] && return
503 jsync 1
506 jsync() {
507 if [ ${JOBS} -eq 0 ]; then
508 [ -n "${TEST_ANY}" ] && printf '\n'
509 TEST_ANY=
510 return
512 [ -z "${JOBSYNC}" ] && [ ${#} -eq 0 ] && return
514 [ ${MAXJOBS} -ne 1 ] && printf ' .. waiting\n'
516 # Start an asynchronous notify process
517 ${rm} -f ./t.time.out
519 sleep ${JOBWAIT} &
520 sleeper=${!}
521 trap "kill -TERM ${sleeper}; exit 1" HUP INT TERM
522 wait ${sleeper}
523 trap '' HUP INT TERM
524 printf '' > ./t.time.out
525 ) </dev/null >/dev/null 2>&1 &
526 JOBREAPER=${!}
528 # Then loop a while, looking out for collecting tests
529 loops=0
530 while :; do
531 [ -f ./t.time.out ] && break
532 alldone=1
534 while [ ${i} -lt ${JOBS} ]; do
535 i=`add ${i} 1`
536 [ -f t.${i}.id ] || continue
537 alldone=
538 break
539 done
540 [ -n "${alldone}" ] && break
542 if [ -z "${SUBSECOND_SLEEP}" ]; then
543 loops=`add ${loops} 1`
544 [ ${loops} -lt 111 ] && continue
545 sleep 1 &
546 else
547 sleep .25 &
549 wait ${!}
550 done
552 if [ -f ./t.time.out ]; then
553 ${rm} -f ./t.time.out
554 jtimeout
555 else
556 kill -TERM ${JOBREAPER} >/dev/null 2>&1
558 wait ${JOBREAPER}
559 JOBREAPER=
561 # Now collect the zombies
562 wait ${JOBLIST}
563 JOBLIST=
565 # Update global counters
567 while [ ${i} -lt ${JOBS} ]; do
568 i=`add ${i} 1`
570 [ -s t.${i}.io ] && ${cat} t.${i}.io
571 if [ -n "${DUMPERR}" ] && [ -s ./t.${i}.d/${ERR} ]; then
572 printf '%s [Debug/Devel: nullified errors]\n' "${COLOR_DBGERR_ON}"
573 while read l; do
574 printf ' %s\n' "${l}"
575 done < t.${i}.d/${ERR}
576 printf '%s' "${COLOR_DBGERR_OFF}"
579 if [ -f t.${i}.id ]; then
580 { read pid; read desc; } < t.${i}.id
581 desc=${desc#${desc%%[! ]*}}
582 desc=${desc%${desc##*[! ]}}
583 [ -s t.${i}.io ] && printf >&2 '\n'
584 printf >&2 '%s!! Timeout: reaped job %s [%s]%s\n' \
585 "${COLOR_ERR_ON}" ${i} "${desc}" "${COLOR_ERR_OFF}"
586 TESTS_FAILED=`add ${TESTS_FAILED} 1`
587 elif [ -s t.${i}.result ]; then
588 read es tp to tf ts < t.${i}.result
589 TESTS_PERFORMED=`add ${TESTS_PERFORMED} ${tp}`
590 TESTS_OK=`add ${TESTS_OK} ${to}`
591 TESTS_FAILED=`add ${TESTS_FAILED} ${tf}`
592 TESTS_SKIPPED=`add ${TESTS_SKIPPED} ${ts}`
593 [ "${es}" != 0 ] && ESTAT=${es}
594 else
595 TESTS_FAILED=`add ${TESTS_FAILED} 1`
596 ESTAT=1
598 done
600 [ -z "${MAILX_CC_TEST_NO_CLEANUP}" ] &&
601 ${rm} -rf ./t.*.d ./t.*.id ./t.*.io t.*.result ./t.time.out
603 JOBS=0
606 jtimeout() {
608 while [ ${i} -lt ${JOBS} ]; do
609 i=`add ${i} 1`
610 if [ -f t.${i}.id ] &&
611 read pid < t.${i}.id >/dev/null 2>&1 &&
612 kill -0 ${pid} >/dev/null 2>&1; then
613 j=${pid}
614 [ -n "${JOBMON}" ] && j=-${j}
615 kill -KILL ${j} >/dev/null 2>&1
616 else
617 ${rm} -f t.${i}.id
619 done
621 # }}}
623 # echoes, checks, etc. {{{
624 t_prolog() {
625 shift
627 ESTAT=0 TESTS_PERFORMED=0 TESTS_OK=0 TESTS_FAILED=0 TESTS_SKIPPED=0 \
628 TEST_NAME=${1} TEST_ANY=
630 printf '%s[%s]%s\n' "" "${TEST_NAME}" ""
633 t_epilog() {
634 [ -n "${TEST_ANY}" ] && printf '\n'
636 printf '%s %s %s %s %s\n' \
637 ${ESTAT} \
638 ${TESTS_PERFORMED} ${TESTS_OK} ${TESTS_FAILED} ${TESTS_SKIPPED} \
639 > ../t.${1}.result
642 t_echo() {
643 [ -n "${TEST_ANY}" ] && __i__=' ' || __i__=
644 printf "${__i__}"'%s' "${*}"
645 TEST_ANY=1
648 t_echook() {
649 [ -n "${TEST_ANY}" ] && __i__=' ' || __i__=
650 printf "${__i__}"'%s%s:ok%s' "${COLOR_OK_ON}" "${*}" "${COLOR_OK_OFF}"
651 TEST_ANY=1
654 t_echoerr() {
655 ESTAT=1
656 t_echo0err "${@}"
659 t_echo0err() {
660 [ -n "${TEST_ANY}" ] && __i__="\n" || __i__=
661 printf "${__i__}"'%sERROR: %s%s\n' \
662 "${COLOR_ERR_ON}" "${*}" "${COLOR_ERR_OFF}"
663 TEST_ANY=
666 t_echowarn() {
667 [ -n "${TEST_ANY}" ] && __i__=' ' || __i__=
668 printf "${__i__}"'%s%s%s' "${COLOR_WARN_ON}" "${*}" "${COLOR_WARN_OFF}"
669 TEST_ANY=1
672 t_echoskip() {
673 [ -n "${TEST_ANY}" ] && __i__=' ' || __i__=
674 printf "${__i__}"'%s%s[skip]%s' \
675 "${COLOR_WARN_ON}" "${*}" "${COLOR_WARN_OFF}"
676 TEST_ANY=1
677 TESTS_SKIPPED=`add ${TESTS_SKIPPED} 1`
680 check() {
681 restat=${?} tid=${1} eestat=${2} f=${3} s=${4} optmode=${5}
683 TESTS_PERFORMED=`add ${TESTS_PERFORMED} 1`
685 case "${optmode}" in
686 '') ;;
687 async)
688 [ "$eestat" = - ] || exit 200
689 while :; do
690 [ -f "${f}" ] && break
691 t_echowarn "[${tid}:async=wait]"
692 sleep 1 &
693 wait ${!}
694 done
696 *) exit 222;;
697 esac
699 check__bad= check__runx=
701 if [ "${eestat}" != - ] && [ "${restat}" != "${eestat}" ]; then
702 ESTAT=1
703 t_echoerr "${tid}: bad-status: ${restat} != ${eestat}"
704 check__bad=1
707 csum="`${cksum} < "${f}" | ${sed} -e 's/[ ]\{1,\}/ /g'`"
708 if [ "${csum}" = "${s}" ]; then
709 t_echook "${tid}"
710 check__runx=${DEVELDIFF}
711 else
712 ESTAT=1
713 t_echoerr "${tid}: checksum mismatch (got ${csum})"
714 check__bad=1 check__runx=1
717 if [ -z "${check__bad}" ]; then
718 TESTS_OK=`add ${TESTS_OK} 1`
719 else
720 TESTS_FAILED=`add ${TESTS_FAILED} 1`
723 if [ -n "${CHECK}${RUN_TEST}" ]; then
724 x="t.${TEST_NAME}-${tid}"
725 if [ -n "${RUN_TEST}" ] ||
726 [ -n "${check__runx}" -a -n "${GIT_REPO}" ]; then
727 ${cp} -f "${f}" ../"${x}"
730 if [ -n "${check__runx}" ] && [ -n "${GIT_REPO}" ] &&
731 command -v diff >/dev/null 2>&1; then
732 y=test-out
733 if (git rev-parse --verify $y) >/dev/null 2>&1; then :; else
734 y=refs/remotes/origin/test-out
735 (git rev-parse --verify $y) >/dev/null 2>&1 || y=
737 if [ -n "${y}" ]; then
738 if GIT_CONFIG=/dev/null git show "${y}":"${x}" > \
739 ../"${x}".old 2>/dev/null; then
740 diff -ru ../"${x}".old ../"${x}" > ../"${x}".diff
741 if [ ${?} -eq 0 ]; then
742 [ -z "${MAILX_CC_TEST_NO_CLEANUP}" ] &&
743 ${rm} -f ../"${x}" ../"${x}".old ../"${x}".diff
744 elif [ -n "${MAILX_CC_ALL_TESTS_DUMPERR}" ]; then
745 while read l; do
746 printf 'ERROR-DIFF %s\n' "${l}"
747 done < ../"${x}".diff
749 else
750 t_echo0err "${tid}: misses [test-out] template"
757 check_ex0() {
758 # $1=test name [$2=status]
759 __qm__=${?}
760 [ ${#} -gt 1 ] && __qm__=${2}
762 TESTS_PERFORMED=`add ${TESTS_PERFORMED} 1`
764 if [ ${__qm__} -ne 0 ]; then
765 ESTAT=1
766 t_echoerr "${1}: unexpected non-0 exit status: ${__qm__}"
767 TESTS_FAILED=`add ${TESTS_FAILED} 1`
768 else
769 t_echook "${1}"
770 TESTS_OK=`add ${TESTS_OK} 1`
774 check_exn0() {
775 # $1=test name [$2=status]
776 __qm__=${?}
777 [ ${#} -gt 1 ] && __qm__=${2}
778 [ ${#} -gt 2 ] && __expect__=${3} || __expect__=
780 TESTS_PERFORMED=`add ${TESTS_PERFORMED} 1`
782 if [ ${__qm__} -eq 0 ]; then
783 ESTAT=1
784 t_echoerr "${1}: unexpected 0 exit status: ${__qm__}"
785 TESTS_FAILED=`add ${TESTS_FAILED} 1`
786 elif [ -n "${__expect__}" ] && [ ${__expect__} -ne ${__qm__} ]; then
787 ESTAT=1
788 t_echoerr "${1}: unexpected exit status: ${__qm__} != ${__expected__}"
789 TESTS_FAILED=`add ${TESTS_FAILED} 1`
790 else
791 t_echook "${1}"
792 TESTS_OK=`add ${TESTS_OK} 1`
795 # }}}
797 color_init() {
798 [ -n "${NOCOLOUR}" ] && return
799 [ -n "${MAILX_CC_TEST_NO_COLOUR}" ] && return
800 # We do not want color for "make test > .LOG"!
801 if [ -t 1 ] && command -v tput >/dev/null 2>&1; then
802 { sgr0=`tput sgr0`; } 2>/dev/null
803 [ $? -eq 0 ] || return
804 { saf1=`tput setaf 1`; } 2>/dev/null
805 [ $? -eq 0 ] || return
806 { saf2=`tput setaf 2`; } 2>/dev/null
807 [ $? -eq 0 ] || return
808 { saf3=`tput setaf 3`; } 2>/dev/null
809 [ $? -eq 0 ] || return
810 { saf5=`tput setaf 5`; } 2>/dev/null
811 [ $? -eq 0 ] || return
812 { b=`tput bold`; } 2>/dev/null
813 [ $? -eq 0 ] || return
815 COLOR_ERR_ON=${saf1}${b} COLOR_ERR_OFF=${sgr0}
816 COLOR_DBGERR_ON=${saf5} COLOR_DBGERR_OFF=${sgr0}
817 COLOR_WARN_ON=${saf3}${b} COLOR_WARN_OFF=${sgr0}
818 COLOR_OK_ON=${saf2} COLOR_OK_OFF=${sgr0}
819 unset saf1 saf2 saf3 b
823 if ( [ "$((1 + 1))" = 2 ] ) >/dev/null 2>&1; then
824 add() {
825 echo "$((${1} + ${2}))"
827 else
828 add() {
829 ${awk} 'BEGIN{print '${1}' + '${2}'}'
833 if ( [ "$((2 % 3))" = 2 ] ) >/dev/null 2>&1; then
834 modulo() {
835 echo "$((${1} % ${2}))"
837 else
838 modulo() {
839 ${awk} 'BEGIN{print '${1}' % '${2}'}'
843 have_feat() {
844 ( "${RAWMAILX}" ${ARGS} -X'echo $features' -Xx |
845 ${grep} ,+${1}, ) >/dev/null 2>&1
847 # }}}
849 # Absolute Basics {{{
850 t_X_Y_opt_input_go_stack() {
851 t_prolog "${@}"
853 ${cat} <<- '__EOT' > "${BODY}"
854 echo 1
855 define mac0 {
856 echo mac0-1 via1 $0
858 call mac0
859 echo 2
860 source '\
861 echo "define mac1 {";\
862 echo " echo mac1-1 via1 \$0";\
863 echo " call mac0";\
864 echo " echo mac1-2";\
865 echo " call mac2";\
866 echo " echo mac1-3";\
867 echo "}";\
868 echo "echo 1-1";\
869 echo "define mac2 {";\
870 echo " echo mac2-1 via1 \$0";\
871 echo " call mac0";\
872 echo " echo mac2-2";\
873 echo "}";\
874 echo "echo 1-2";\
875 echo "call mac1";\
876 echo "echo 1-3";\
877 echo "source \"\
878 echo echo 1-1-1 via1 \$0;\
879 echo call mac0;\
880 echo echo 1-1-2;\
881 | \"";\
882 echo "echo 1-4";\
884 echo 3
885 call mac2
886 echo 4
887 undefine *
888 __EOT
890 # The -X option supports multiline arguments, and those can internally use
891 # reverse solidus newline escaping. And all -X options are joined...
892 APO=\'
893 < "${BODY}" ${MAILX} ${ARGS} \
894 -X 'e\' \
895 -X ' c\' \
896 -X ' h\' \
897 -X ' o \' \
898 -X 1 \
900 define mac0 {
901 echo mac0-1 via2 $0
903 call mac0
904 echo 2
907 source '${APO}'\
908 echo "define mac1 {";\
909 echo " echo mac1-1 via2 \$0";\
910 echo " call mac0";\
911 echo " echo mac1-2";\
912 echo " call mac2";\
913 echo " echo mac1-3";\
914 echo "}";\
915 echo "echo 1-1";\
916 echo "define mac2 {";\
917 echo " echo mac2-1 via2 \$0";\
918 echo " call mac0";\
919 echo " echo mac2-2";\
920 echo "}";\
921 echo "echo 1-2";\
922 echo "call mac1";\
923 echo "echo 1-3";\
924 echo "source \"\
925 echo echo 1-1-1 via2 \$0;\
926 echo call mac0;\
927 echo echo 1-1-2;\
928 | \"";\
929 echo "echo 1-4";\
930 | '${APO}'
931 echo 3
934 call mac2
935 echo 4
936 undefine *
937 ' > "${MBOX}"
939 check 1 0 "${MBOX}" '1786542668 416'
941 # The -Y option supports multiline arguments, and those can internally use
942 # reverse solidus newline escaping.
943 APO=\'
944 < "${BODY}" ${MAILX} ${ARGS} \
945 -X 'echo FIRST_X' \
946 -X 'echo SECOND_X' \
947 -Y 'e\' \
948 -Y ' c\' \
949 -Y ' h\' \
950 -Y ' o \' \
951 -Y 1 \
953 define mac0 {
954 echo mac0-1 via2 $0
956 call mac0
957 echo 2
960 source '${APO}'\
961 echo "define mac1 {";\
962 echo " echo mac1-1 via2 \$0";\
963 echo " call mac0";\
964 echo " echo mac1-2";\
965 echo " call mac2";\
966 echo " echo mac1-3";\
967 echo "}";\
968 echo "echo 1-1";\
969 echo "define mac2 {";\
970 echo " echo mac2-1 via2 \$0";\
971 echo " call mac0";\
972 echo " echo mac2-2";\
973 echo "}";\
974 echo "echo 1-2";\
975 echo "call mac1";\
976 echo "echo 1-3";\
977 echo "source \"\
978 echo echo 1-1-1 via2 \$0;\
979 echo call mac0;\
980 echo echo 1-1-2;\
981 | \"";\
982 echo "echo 1-4";\
983 | '${APO}'
984 echo 3
987 call mac2
988 echo 4
989 undefine *
991 -Y 'echo LAST_Y' > "${MBOX}"
993 check 2 0 "${MBOX}" '1845176711 440'
995 # Compose mode, too!
996 </dev/null ${MAILX} ${ARGS} \
997 -X 'echo X before compose mode' \
998 -Y '~s Subject via -Y' \
999 -Y 'Body via -Y' -. ./.tybox > "${MBOX}" 2>&1
1000 check 3 0 ./.tybox '264636255 125'
1001 check 4 - "${MBOX}" '467429373 22'
1003 ${cat} <<-_EOT | ${MAILX} ${ARGS} -t \
1004 -X 'echo X before compose mode' \
1005 -Y '~s Subject via -Y' \
1006 -Y 'Additional body via -Y' -. ./.tybox > "${MBOX}" 2>&1
1007 from: heya@exam.ple
1008 subject:diet not to be seen!
1010 this body via -t.
1011 _EOT
1012 check 5 0 ./.tybox '3313167452 299'
1013 check 6 - "${MBOX}" '467429373 22'
1016 printf 'this body via stdin pipe.\n' | ${MAILX} ${NOBATCH_ARGS} \
1017 -X 'echo X before compose mode' \
1018 -Y '~s Subject via -Y (not!)' \
1019 -Y 'Additional body via -Y, nobatch mode' -. ./.tybox > "${MBOX}" 2>&1
1020 check 7 0 ./.tybox '1561798488 476'
1021 check 8 - "${MBOX}" '467429373 22'
1023 printf 'this body via stdin pipe.\n' | ${MAILX} ${ARGS} \
1024 -X 'echo X before compose mode' \
1025 -Y '~s Subject via -Y' \
1026 -Y 'Additional body via -Y, batch mode' -. ./.tybox > "${MBOX}" 2>&1
1027 check 9 0 ./.tybox '3245082485 650'
1028 check 10 - "${MBOX}" '467429373 22'
1030 # Test for [8412796a] (n_cmd_arg_parse(): FIX token error -> crash, e.g.
1031 # "-RX 'bind;echo $?' -Xx".., 2018-08-02)
1032 ${MAILX} ${ARGS} -RX'call;echo $?' -Xx > ./.tall 2>&1
1033 ${MAILX} ${ARGS} -RX'call ;echo $?' -Xx >> ./.tall 2>&1
1034 ${MAILX} ${ARGS} -RX'call ;echo $?' -Xx >> ./.tall 2>&1
1035 ${MAILX} ${ARGS} -RX'call ;echo $?' -Xx >> ./.tall 2>&1
1036 check cmdline 0 ./.tall '1867586969 8'
1038 t_epilog "${@}"
1041 t_X_errexit() {
1042 t_prolog "${@}"
1044 if have_feat uistrings; then :; else
1045 t_echoskip '[!UISTRINGS]'
1046 t_epilog "${@}"
1047 return
1050 ${cat} <<- '__EOT' > "${BODY}"
1051 echo one
1052 echos nono
1053 echo two
1054 __EOT
1056 </dev/null ${MAILX} ${ARGS} -Snomemdebug \
1057 -X'echo one' -X' echos nono ' -X'echo two' \
1058 > "${MBOX}" 2>&1
1059 check 1 0 "${MBOX}" '2700500141 51'
1061 </dev/null ${MAILX} ${ARGS} -X'source '"${BODY}" -Snomemdebug \
1062 > "${MBOX}" 2>&1
1063 check 2 0 "${MBOX}" '2700500141 51'
1065 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Snomemdebug \
1066 > "${MBOX}" 2>&1
1067 check 3 0 "${MBOX}" '2700500141 51'
1071 </dev/null ${MAILX} ${ARGS} -Serrexit -Snomemdebug \
1072 -X'echo one' -X' echos nono ' -X'echo two' \
1073 > "${MBOX}" 2>&1
1074 check 4 1 "${MBOX}" '4096689457 47'
1076 </dev/null ${MAILX} ${ARGS} -X'source '"${BODY}" -Serrexit -Snomemdebug \
1077 > "${MBOX}" 2>&1
1078 check 5 1 "${MBOX}" '4096689457 47'
1080 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Serrexit -Snomemdebug \
1081 > "${MBOX}" 2>&1
1082 check 6 1 "${MBOX}" '1669262132 170'
1084 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Sposix -Snomemdebug \
1085 > "${MBOX}" 2>&1
1086 check 7 1 "${MBOX}" '1669262132 170'
1088 ## Repeat 4-7 with ignerr set
1090 ${sed} -e 's/^echos /ignerr echos /' < "${BODY}" > "${MBOX}"
1092 </dev/null ${MAILX} ${ARGS} -Serrexit -Snomemdebug \
1093 -X'echo one' -X'ignerr echos nono ' -X'echo two' \
1094 > "${BODY}" 2>&1
1095 check 8 0 "${BODY}" '2700500141 51'
1097 </dev/null ${MAILX} ${ARGS} -X'source '"${MBOX}" -Serrexit -Snomemdebug \
1098 > "${BODY}" 2>&1
1099 check 9 0 "${BODY}" '2700500141 51'
1101 </dev/null MAILRC="${MBOX}" ${MAILX} ${ARGS} -:u -Serrexit -Snomemdebug \
1102 > "${BODY}" 2>&1
1103 check 10 0 "${BODY}" '2700500141 51'
1105 </dev/null MAILRC="${MBOX}" ${MAILX} ${ARGS} -:u -Sposix -Snomemdebug \
1106 > "${BODY}" 2>&1
1107 check 11 0 "${BODY}" '2700500141 51'
1109 # Ensure "good-injection" in a deeper indirection does not cause trouble
1110 # This actually only works with MLE and HISTORY, and TODO needs a pseudo TTY
1111 # interaction so that we DO initialize our line editor...
1112 ${cat} <<- '__EOT' > "${BODY}"
1113 define oha {
1114 return 0
1116 define x {
1117 eval set $xarg
1118 echoes time
1119 return 0
1121 __EOT
1123 printf 'source %s\ncall x\necho au' "${BODY}" |
1124 ${MAILX} ${ARGS} -Snomemdebug -Sxarg=errexit > "${MBOX}" 2>&1
1125 check 12 1 "${MBOX}" '2908921993 44'
1127 printf 'source %s\nset on-history-addition=oha\ncall x\necho au' "${BODY}" |
1128 ${MAILX} ${ARGS} -Snomemdebug -Sxarg=errexit > "${MBOX}" 2>&1
1129 check 13 1 "${MBOX}" '2908921993 44'
1131 printf 'source %s\ncall x\necho au' "${BODY}" |
1132 ${MAILX} ${ARGS} -Snomemdebug -Sxarg=nowhere > "${MBOX}" 2>&1
1133 check 14 0 "${MBOX}" '2049365617 47'
1135 t_epilog "${@}"
1138 t_Y_errexit() {
1139 t_prolog "${@}"
1141 if have_feat uistrings; then :; else
1142 t_echoskip '[!UISTRINGS]'
1143 t_epilog "${@}"
1144 return
1147 ${cat} <<- '__EOT' > "${BODY}"
1148 echo one
1149 echos nono
1150 echo two
1151 __EOT
1153 </dev/null ${MAILX} ${ARGS} -Snomemdebug \
1154 -Y'echo one' -Y' echos nono ' -Y'echo two' \
1155 > "${MBOX}" 2>&1
1156 check 1 0 "${MBOX}" '2700500141 51'
1158 </dev/null ${MAILX} ${ARGS} -Y'source '"${BODY}" -Snomemdebug \
1159 > "${MBOX}" 2>&1
1160 check 2 0 "${MBOX}" '2700500141 51'
1164 </dev/null ${MAILX} ${ARGS} -Serrexit -Snomemdebug \
1165 -Y'echo one' -Y' echos nono ' -Y'echo two' \
1166 > "${MBOX}" 2>&1
1167 check 3 1 "${MBOX}" '4096689457 47'
1169 </dev/null ${MAILX} ${ARGS} -Y'source '"${BODY}" -Serrexit -Snomemdebug \
1170 > "${MBOX}" 2>&1
1171 check 4 1 "${MBOX}" '4096689457 47'
1173 ## Repeat 3-4 with ignerr set
1175 ${sed} -e 's/^echos /ignerr echos /' < "${BODY}" > "${MBOX}"
1177 </dev/null ${MAILX} ${ARGS} -Serrexit -Snomemdebug \
1178 -Y'echo one' -Y'ignerr echos nono ' -Y'echo two' \
1179 > "${BODY}" 2>&1
1180 check 5 0 "${BODY}" '2700500141 51'
1182 </dev/null ${MAILX} ${ARGS} -Y'source '"${MBOX}" -Serrexit -Snomemdebug \
1183 > "${BODY}" 2>&1
1184 check 6 0 "${BODY}" '2700500141 51'
1186 t_epilog "${@}"
1189 t_S_freeze() {
1190 t_prolog "${@}"
1191 oterm=$TERM
1192 unset TERM
1194 # Test basic assumption
1195 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} \
1196 -X'echo asksub<$asksub> dietcurd<$dietcurd>' \
1197 -Xx > "${MBOX}" 2>&1
1198 check 1 0 "${MBOX}" '270686329 21'
1201 ${cat} <<- '__EOT' > "${BODY}"
1202 echo asksub<$asksub>
1203 set asksub
1204 echo asksub<$asksub>
1205 __EOT
1206 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
1207 -Snoasksub -Sasksub -Snoasksub \
1208 -X'echo asksub<$asksub>' -X'set asksub' -X'echo asksub<$asksub>' \
1209 -Xx > "${MBOX}" 2>&1
1210 check 2 0 "${MBOX}" '3182942628 37'
1212 ${cat} <<- '__EOT' > "${BODY}"
1213 echo asksub<$asksub>
1214 unset asksub
1215 echo asksub<$asksub>
1216 __EOT
1217 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
1218 -Snoasksub -Sasksub \
1219 -X'echo asksub<$asksub>' -X'unset asksub' -X'echo asksub<$asksub>' \
1220 -Xx > "${MBOX}" 2>&1
1221 check 3 0 "${MBOX}" '2006554293 39'
1224 ${cat} <<- '__EOT' > "${BODY}"
1225 echo dietcurd<$dietcurd>
1226 set dietcurd=cherry
1227 echo dietcurd<$dietcurd>
1228 __EOT
1229 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
1230 -Sdietcurd=strawberry -Snodietcurd -Sdietcurd=vanilla \
1231 -X'echo dietcurd<$dietcurd>' -X'unset dietcurd' \
1232 -X'echo dietcurd<$dietcurd>' \
1233 -Xx > "${MBOX}" 2>&1
1234 check 4 0 "${MBOX}" '1985768109 65'
1236 ${cat} <<- '__EOT' > "${BODY}"
1237 echo dietcurd<$dietcurd>
1238 unset dietcurd
1239 echo dietcurd<$dietcurd>
1240 __EOT
1241 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
1242 -Sdietcurd=strawberry -Snodietcurd \
1243 -X'echo dietcurd<$dietcurd>' -X'set dietcurd=vanilla' \
1244 -X'echo dietcurd<$dietcurd>' \
1245 -Xx > "${MBOX}" 2>&1
1246 check 5 0 "${MBOX}" '151574279 51'
1248 # TODO once we have a detached one with env=1..
1249 if [ -n "`</dev/null ${MAILX} ${ARGS} -X'!echo \$TERM' -Xx`" ]; then
1250 t_echoskip 's_freeze-{6,7}:[shell sets $TERM]'
1251 else
1252 ${cat} <<- '__EOT' > "${BODY}"
1253 !echo "shell says TERM<$TERM>"
1254 echo TERM<$TERM>
1255 !echo "shell says TERM<$TERM>"
1256 set TERM=cherry
1257 !echo "shell says TERM<$TERM>"
1258 echo TERM<$TERM>
1259 !echo "shell says TERM<$TERM>"
1260 __EOT
1261 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
1262 -STERM=strawberry -SnoTERM -STERM=vanilla \
1263 -X'echo mail<$TERM>' -X'unset TERM' \
1264 -X'!echo "shell says TERM<$TERM>"' -X'echo TERM<$TERM>' \
1265 -Xx > "${MBOX}" 2>&1
1266 check 6 0 "${MBOX}" '1211476036 167'
1268 ${cat} <<- '__EOT' > "${BODY}"
1269 !echo "shell says TERM<$TERM>"
1270 echo TERM<$TERM>
1271 !echo "shell says TERM<$TERM>"
1272 set TERM=cherry
1273 !echo "shell says TERM<$TERM>"
1274 echo TERM<$TERM>
1275 !echo "shell says TERM<$TERM>"
1276 __EOT
1277 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
1278 -STERM=strawberry -SnoTERM \
1279 -X'echo TERM<$TERM>' -X'set TERM=vanilla' \
1280 -X'!echo "shell says TERM<$TERM>"' -X'echo TERM<$TERM>' \
1281 -Xx > "${MBOX}" 2>&1
1282 check 7 0 "${MBOX}" '3365080441 132'
1285 TERM=$oterm
1286 t_epilog "${@}"
1289 t_f_batch_order() {
1290 t_prolog "${@}"
1292 t__gen_msg subject f-batch-order > "${MBOX}"
1294 # This would exit 64 (EX_USAGE) from ? to [fbddb3b3] (FIX: -f: add
1295 # n_PO_f_FLAG to avoid that command line order matters)
1296 </dev/null ${MAILX} ${NOBATCH_ARGS} -R -f -# \
1297 -Y 'echo du;h;echo da;x' "${MBOX}" >./.tall 2>&1
1298 check 1 0 ./.tall '1690247457 86'
1300 # And this ever worked (hopefully)
1301 </dev/null ${MAILX} ${NOBATCH_ARGS} -R -# -f \
1302 -Y 'echo du;h;echo da;x' "${MBOX}" >./.tall 2>&1
1303 check 2 0 ./.tall '1690247457 86'
1305 t_epilog "${@}"
1308 t_input_inject_semicolon_seq() {
1309 t_prolog "${@}"
1311 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
1312 define mydeepmac {
1313 echon '(mydeepmac)';
1315 define mymac {
1316 echon this_is_mymac;call mydeepmac;echon ';';
1318 echon one';';call mymac;echon two";";call mymac;echo three$';';
1319 define mymac {
1320 echon this_is_mymac;call mydeepmac;echon ,TOO'!;';
1322 echon one';';call mymac;echon two";";call mymac;echo three$';';
1323 __EOT
1325 check 1 0 "${MBOX}" '512117110 140'
1327 t_epilog "${@}"
1330 t_wysh() {
1331 t_prolog "${@}"
1333 ${cat} <<- '__EOT' > "${BODY}"
1335 echo abcd
1336 echo a'b'c'd'
1337 echo a"b"c"d"
1338 echo a$'b'c$'d'
1339 echo 'abcd'
1340 echo "abcd"
1341 echo $'abcd'
1342 echo a\ b\ c\ d
1343 echo a 'b c' d
1344 echo a "b c" d
1345 echo a $'b c' d
1347 echo 'a$`"\'
1348 echo "a\$\`'\"\\"
1349 echo $'a\$`\'\"\\'
1350 echo $'a\$`\'"\\'
1351 # DIET=CURD TIED=
1352 echo 'a${DIET}b${TIED}c\${DIET}d\${TIED}e' # COMMENT
1353 echo "a${DIET}b${TIED}c\${DIET}d\${TIED}e"
1354 echo $'a${DIET}b${TIED}c\${DIET}d\${TIED}e'
1356 echo a$'\101\0101\x41\u0041\u41\U00000041\U41'c
1357 echo a$'\u0041\u41\u0C1\U00000041\U41'c
1358 echo a$'\377'c
1359 echo a$'\0377'c
1360 echo a$'\400'c
1361 echo a$'\0400'c
1362 echo a$'\U1100001'c
1364 echo a$'b\0c'd
1365 echo a$'b\00c'de
1366 echo a$'b\000c'df
1367 echo a$'b\0000c'dg
1368 echo a$'b\x0c'dh
1369 echo a$'b\x00c'di
1370 echo a$'b\u0'dj
1371 echo a$'b\u00'dk
1372 echo a$'b\u000'dl
1373 echo a$'b\u0000'dm
1374 echo a$'b\U0'dn
1375 echo a$'b\U00'do
1376 echo a$'b\U000'dp
1377 echo a$'b\U0000'dq
1378 echo a$'b\U00000'dr
1379 echo a$'b\U000000'ds
1380 echo a$'b\U0000000'dt
1381 echo a$'b\U00000000'du
1383 echo a$'\cI'b
1384 echo a$'\011'b
1385 echo a$'\x9'b
1386 echo a$'\u9'b
1387 echo a$'\U9'b
1388 echo a$'\c@'b c d
1389 __EOT
1391 if [ -z "${UTF8_LOCALE}" ]; then
1392 t_echoskip 'wysh-unicode:[no UTF-8 locale]'
1393 else
1394 < "${BODY}" DIET=CURD TIED= \
1395 LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} > "${MBOX}" 2>>${ERR}
1396 check unicode 0 "${MBOX}" '475805847 317'
1399 < "${BODY}" DIET=CURD TIED= ${MAILX} ${ARGS} > "${MBOX}" 2>>${ERR}
1400 check c 0 "${MBOX}" '1473887148 321'
1402 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
1403 wysh set mager='\hey\'
1404 varshow mager
1405 wysh set mager="\hey\\"
1406 varshow mager
1407 wysh set mager=$'\hey\\'
1408 varshow mager
1409 __EOT
1410 check 3 0 "${MBOX}" '1289698238 69'
1412 t_epilog "${@}"
1415 t_commandalias() {
1416 t_prolog "${@}"
1418 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
1419 commandalias echo echo hoho
1420 echo stop.
1421 commandalias X Xx
1422 commandalias Xx XxX
1423 commandalias XxX XxXx
1424 commandalias XxXx XxXxX
1425 commandalias XxXxX XxXxXx
1426 commandalias XxXxXx echo huhu
1427 commandalias XxXxXxX echo huhu
1429 commandalias XxXxXx XxXxXxX
1431 uncommandalias echo
1432 commandalias XxXxXx echo huhu
1434 __EOT
1436 check 1 0 "${MBOX}" '1638809585 36'
1438 t_epilog "${@}"
1441 t_posix_abbrev() {
1442 t_prolog "${@}"
1444 # In POSIX C181 standard order
1445 </dev/null ${MAILX} ${ARGS} \
1446 -Y 'echon alias/a\ ; ? a; echon group/g\ ; ?g' \
1447 -Y 'echon alternates/alt\ ; ? alt' \
1448 -Y 'echon chdir/ch\ ; ? ch' \
1449 -Y 'echon copy/c\ ; ? c; echon Copy/C\ ; ?C' \
1450 -Y 'echon delete/d\ ; ? d' \
1451 -Y 'echon discard/di\ ; ? di; echon ignore/ig\ ; ?ig' \
1452 -Y 'echon echo/ec\ ; ? ec' \
1453 -Y 'echon edit/e\ ; ? e' \
1454 -Y 'echon exit/ex\ ; ? ex; echon xit/x\ ; ?x' \
1455 -Y 'echon file/fi\ ; ? fi; echon folder/fold\ ; ? fold' \
1456 -Y 'echon followup/fo\ ; ? fo; echon Followup/F\ ; ?F' \
1457 -Y 'echon from/f\ ; ? f' \
1458 -Y 'echon headers/h\ ; ? h' \
1459 -Y 'echon help/hel\ ; ? hel' \
1460 -Y 'echon hold/ho\ ; ? ho; echon preserve/pre\ ; ? pre' \
1461 -Y 'echon if/i\ ; ? i; echon else/el\ ; ? el; echon endif/en\ ; ? en' \
1462 -Y 'echon list/l\ ; ? l' \
1463 -Y 'echon mail/m\ ; ? m' \
1464 -Y 'echon mbox/mb\ ; ? mb' \
1465 -Y 'echon next/n\ ; ? n' \
1466 -Y 'echon pipe/pi\ ; ? pi' \
1467 -Y 'echon Print/P\ ; ? P; echon Type/T\ ; ? T' \
1468 -Y 'echon print/p\ ; ? p; echon type/t\ ; ? t' \
1469 -Y 'echon quit/q\ ; ? q' \
1470 -Y 'echon Reply/R\ ; ? R' \
1471 -Y 'echon reply/r\ ; ? r' \
1472 -Y 'echon retain/ret\ ; ? ret' \
1473 -Y 'echon save/s\ ; ? s; echon Save/S\ ; ? S' \
1474 -Y 'echon set/se\ ; ? se' \
1475 -Y 'echon shell/sh\ ; ? sh' \
1476 -Y 'echon size/si\ ; ? si' \
1477 -Y 'echon source/so\ ; ? so' \
1478 -Y 'echon touch/tou\ ; ? tou' \
1479 -Y 'echon unalias/una\ ; ? una' \
1480 -Y 'echon undelete/u\ ; ? u' \
1481 -Y 'echon unset/uns\ ; ? uns' \
1482 -Y 'echon visual/v\ ; ? v' \
1483 -Y 'echon write/w\ ; ? w' \
1484 | ${sed} -e 's/:.*$//' > "${MBOX}"
1485 check 1 0 "${MBOX}" '1012680481 968'
1487 t_epilog "${@}"
1489 # }}}
1491 # Basics {{{
1492 t_shcodec() {
1493 t_prolog "${@}"
1495 # XXX the first needs to be checked, it is quite dumb as such
1496 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
1497 commandalias x echo '$?/$^ERRNAME'
1498 shcodec e abcd
1500 shcodec d abcd
1502 shcodec e a'b'c'd'
1504 shcodec d a'b'c'd'
1506 shcodec e a"b"c"d"
1508 shcodec d a"b"c"d"
1510 shcodec e a$'b'c$'d'
1512 shcodec d a$'b'c$'d'
1514 shcodec e 'abcd'
1516 shcodec d 'abcd'
1518 shcodec e "abcd"
1520 shcodec d "abcd"
1522 shcodec e $'abcd'
1524 shcodec d $'abcd'
1526 # same but with vput
1527 commandalias y echo '$?/$^ERRNAME $res'
1528 vput shcodec res e abcd
1530 eval shcodec d $res
1532 vput shcodec res d abcd
1534 eval shcodec d $res
1536 vput shcodec res e a'b'c'd'
1538 eval shcodec d $res
1540 vput shcodec res d a'b'c'd'
1542 eval shcodec d $res
1544 vput shcodec res e a"b"c"d"
1546 eval shcodec d $res
1548 vput shcodec res d a"b"c"d"
1550 eval shcodec d $res
1552 vput shcodec res e a$'b'c$'d'
1554 eval shcodec d $res
1556 vput shcodec res d a$'b'c$'d'
1558 eval shcodec d $res
1560 vput shcodec res e 'abcd'
1562 eval shcodec d $res
1564 vput shcodec res d 'abcd'
1566 eval shcodec d $res
1568 vput shcodec res e "abcd"
1570 eval shcodec d $res
1572 vput shcodec res d "abcd"
1574 eval shcodec d $res
1576 vput shcodec res e $'abcd'
1578 eval shcodec d $res
1580 vput shcodec res d $'abcd'
1582 eval shcodec d $res
1585 vput shcodec res e a b\ c d
1587 eval shcodec d $res
1589 vput shcodec res d a b\ c d
1591 vput shcodec res e ab cd
1593 eval shcodec d $res
1595 vput shcodec res d 'ab cd'
1597 vput shcodec res e a 'b c' d
1599 eval shcodec d $res
1601 vput shcodec res d a 'b c' d
1603 vput shcodec res e a "b c" d
1605 eval shcodec d $res
1607 vput shcodec res d a "b c" d
1609 vput shcodec res e a $'b c' d
1611 eval shcodec d $res
1613 vput shcodec res d a $'b c' d
1616 vput shcodec res e 'a$`"\'
1618 eval shcodec d $res
1620 vput shcodec res d 'a$`"\'
1622 vput shcodec res e "a\$\`'\"\\"
1624 eval shcodec d $res
1626 vput shcodec res d "a\$\`'\"\\"
1628 vput shcodec res e $'a\$`\'\"\\'
1630 eval shcodec d $res
1632 vput shcodec res d $'a\$`\'\"\\'
1634 vput shcodec res e $'a\$`\'"\\'
1636 eval shcodec d $res
1638 vput shcodec res d $'a\$`\'"\\'
1641 set diet=curd
1642 vput shcodec res e a${diet}c
1644 eval shcodec d $res
1646 eval vput shcodec res e a${diet}c
1648 eval shcodec d $res
1650 vput shcodec res e "a${diet}c"
1652 eval shcodec d $res
1654 eval vput shcodec res e "a${diet}c"
1656 eval shcodec d $res
1658 __EOT
1659 check 1 0 "${MBOX}" '3316745312 1241'
1661 if [ -z "${UTF8_LOCALE}" ]; then
1662 t_echoskip 'unicode:[no UTF-8 locale]'
1663 elif have_feat multibyte-charsets; then
1664 ${cat} <<- '__EOT' | LC_ALL=${UTF8_LOCALE} \
1665 ${MAILX} ${ARGS} > "${MBOX}" 2>>${ERR}
1667 shcodec e täst
1668 shcodec +e täst
1669 shcodec d $'t\u00E4st'
1670 shcodec e aՍc
1671 shcodec +e aՍc
1672 shcodec d $'a\u054Dc'
1673 shcodec e a𝕂c
1674 shcodec +e a𝕂c
1675 shcodec d $'a\U0001D542c'
1676 __EOT
1677 check unicode 0 "${MBOX}" '1175985867 77'
1678 else
1679 t_echoskip 'unicode:[!MULTIBYTE-CHARSETS]'
1682 t_epilog "${@}"
1685 t_ifelse() {
1686 t_prolog "${@}"
1688 # v15compat: old and new tests share the same result files!
1689 # v15compat: i.e., just throw away -old tests one day
1691 # Nestable conditions test
1692 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
1693 if 0
1694 echo 1.err
1695 else
1696 echo 1.ok
1697 endif
1698 if 1
1699 echo 2.ok
1700 else
1701 echo 2.err
1702 endif
1703 if $dietcurd
1704 echo 3.err
1705 else
1706 echo 3.ok
1707 endif
1708 set dietcurd=yoho
1709 if $dietcurd
1710 echo 4.ok
1711 else
1712 echo 4.err
1713 endif
1714 if $dietcurd == 'yoho'
1715 echo 5.ok
1716 else
1717 echo 5.err
1718 endif
1719 if $dietcurd ==? 'Yoho'
1720 echo 5-1.ok
1721 else
1722 echo 5-1.err
1723 endif
1724 if $dietcurd == 'Yoho'
1725 echo 5-2.err
1726 else
1727 echo 5-2.ok
1728 endif
1729 if $dietcurd != 'yoho'
1730 echo 6.err
1731 else
1732 echo 6.ok
1733 endif
1734 if $dietcurd !=?case 'Yoho'
1735 echo 6-1.err
1736 else
1737 echo 6-1.ok
1738 endif
1739 if $dietcurd != 'Yoho'
1740 echo 6-2.ok
1741 else
1742 echo 6-2.err
1743 endif
1744 # Nesting
1745 if faLse
1746 echo 7.err1
1747 if tRue
1748 echo 7.err2
1749 if yEs
1750 echo 7.err3
1751 else
1752 echo 7.err4
1753 endif
1754 echo 7.err5
1755 endif
1756 echo 7.err6
1757 else
1758 echo 7.ok7
1759 if YeS
1760 echo 7.ok8
1761 if No
1762 echo 7.err9
1763 else
1764 echo 7.ok9
1765 endif
1766 echo 7.ok10
1767 else
1768 echo 7.err11
1769 if yeS
1770 echo 7.err12
1771 else
1772 echo 7.err13
1773 endif
1774 endif
1775 echo 7.ok14
1776 endif
1777 if r
1778 echo 8.ok1
1779 if R
1780 echo 8.ok2
1781 else
1782 echo 8.err2
1783 endif
1784 echo 8.ok3
1785 else
1786 echo 8.err1
1787 endif
1788 if s
1789 echo 9.err1
1790 else
1791 echo 9.ok1
1792 if S
1793 echo 9.err2
1794 else
1795 echo 9.ok2
1796 endif
1797 echo 9.ok3
1798 endif
1799 # `elif'
1800 if $dietcurd == 'yohu'
1801 echo 10.err1
1802 elif $dietcurd == 'yoha'
1803 echo 10.err2
1804 elif $dietcurd == 'yohe'
1805 echo 10.err3
1806 elif $dietcurd == 'yoho'
1807 echo 10.ok1
1808 if $dietcurd == 'yohu'
1809 echo 10.err4
1810 elif $dietcurd == 'yoha'
1811 echo 10.err5
1812 elif $dietcurd == 'yohe'
1813 echo 10.err6
1814 elif $dietcurd == 'yoho'
1815 echo 10.ok2
1816 if $dietcurd == 'yohu'
1817 echo 10.err7
1818 elif $dietcurd == 'yoha'
1819 echo 10.err8
1820 elif $dietcurd == 'yohe'
1821 echo 10.err9
1822 elif $dietcurd == 'yoho'
1823 echo 10.ok3
1824 else
1825 echo 10.err10
1826 endif
1827 else
1828 echo 10.err11
1829 endif
1830 else
1831 echo 10.err12
1832 endif
1833 # integer
1834 set dietcurd=10
1835 if $dietcurd -lt 11
1836 echo 11.ok1
1837 if $dietcurd -gt 9
1838 echo 11.ok2
1839 else
1840 echo 11.err2
1841 endif
1842 if $dietcurd -eq 10
1843 echo 11.ok3
1844 else
1845 echo 11.err3
1846 endif
1847 if $dietcurd -ge 10
1848 echo 11.ok4
1849 else
1850 echo 11.err4
1851 endif
1852 if $dietcurd -le 10
1853 echo 11.ok5
1854 else
1855 echo 11.err5
1856 endif
1857 if $dietcurd -ge 11
1858 echo 11.err6
1859 else
1860 echo 11.ok6
1861 endif
1862 if $dietcurd -le 9
1863 echo 11.err7
1864 else
1865 echo 11.ok7
1866 endif
1867 else
1868 echo 11.err1
1869 endif
1870 set dietcurd=Abc
1871 if $dietcurd < aBd
1872 echo 12.ok1
1873 if $dietcurd >? abB
1874 echo 12.ok2
1875 else
1876 echo 12.err2
1877 endif
1878 if $dietcurd ==?case aBC
1879 echo 12.ok3
1880 else
1881 echo 12.err3
1882 endif
1883 if $dietcurd >=?ca AbC
1884 echo 12.ok4
1885 else
1886 echo 12.err4
1887 endif
1888 if $dietcurd <=? ABc
1889 echo 12.ok5
1890 else
1891 echo 12.err5
1892 endif
1893 if $dietcurd >=?case abd
1894 echo 12.err6
1895 else
1896 echo 12.ok6
1897 endif
1898 if $dietcurd <=? abb
1899 echo 12.err7
1900 else
1901 echo 12.ok7
1902 endif
1903 else
1904 echo 12.err1
1905 endif
1906 if $dietcurd < aBc
1907 echo 12-1.ok
1908 else
1909 echo 12-1.err
1910 endif
1911 if $dietcurd <? aBc
1912 echo 12-2.err
1913 else
1914 echo 12-2.ok
1915 endif
1916 if $dietcurd > ABc
1917 echo 12-3.ok
1918 else
1919 echo 12-3.err
1920 endif
1921 if $dietcurd >? ABc
1922 echo 12-3.err
1923 else
1924 echo 12-3.ok
1925 endif
1926 if $dietcurd =%?case aB
1927 echo 13.ok
1928 else
1929 echo 13.err
1930 endif
1931 if $dietcurd =% aB
1932 echo 13-1.err
1933 else
1934 echo 13-1.ok
1935 endif
1936 if $dietcurd =%? bC
1937 echo 14.ok
1938 else
1939 echo 14.err
1940 endif
1941 if $dietcurd !% aB
1942 echo 15-1.ok
1943 else
1944 echo 15-1.err
1945 endif
1946 if $dietcurd !%? aB
1947 echo 15-2.err
1948 else
1949 echo 15-2.ok
1950 endif
1951 if $dietcurd !% bC
1952 echo 15-3.ok
1953 else
1954 echo 15-3.err
1955 endif
1956 if $dietcurd !%? bC
1957 echo 15-4.err
1958 else
1959 echo 15-4.ok
1960 endif
1961 if $dietcurd =% Cd
1962 echo 16.err
1963 else
1964 echo 16.ok
1965 endif
1966 if $dietcurd !% Cd
1967 echo 17.ok
1968 else
1969 echo 17.err
1970 endif
1971 set diet=abc curd=abc
1972 if $diet == $curd
1973 echo 18.ok
1974 else
1975 echo 18.err
1976 endif
1977 set diet=abc curd=abcd
1978 if $diet != $curd
1979 echo 19.ok
1980 else
1981 echo 19.err
1982 endif
1983 # 1. Shitty grouping capabilities as of today
1984 unset diet curd ndefined
1985 if [ [ false ] || [ false ] || [ true ] ] && \
1986 [ [ false ] || [ true ] ] && \
1987 [ yes ]
1988 echo 20.ok
1989 else
1990 echo 20.err
1991 endif
1992 if [ [ [ [ 0 ] || [ 1 ] ] && [ [ 1 ] || [ 0 ] ] ] && [ 1 ] ] && [ yes ]
1993 echo 21.ok
1994 else
1995 echo 21.err
1996 endif
1997 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] ]
1998 echo 22.ok
1999 else
2000 echo 22.err
2001 endif
2002 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] ]
2003 echo 23.ok
2004 else
2005 echo 23.err
2006 endif
2007 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] && [ no ]
2008 echo 24.err
2009 else
2010 echo 24.ok
2011 endif
2012 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] \
2013 && [ no ] || [ yes ]
2014 echo 25.ok
2015 else
2016 echo 25.err
2017 endif
2018 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
2019 echo 26.ok
2020 else
2021 echo 26.err
2022 endif
2023 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 0 ] ]
2024 echo 27.err
2025 else
2026 echo 27.ok
2027 endif
2028 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 0 ] ] && [ 1 ] ] ] && [ 1 ] ]
2029 echo 28.err
2030 else
2031 echo 28.ok
2032 endif
2033 if [ [ [ [ [ [ [ 0 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
2034 echo 29.err
2035 else
2036 echo 29.ok
2037 endif
2038 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 0 ]
2039 echo 30.err
2040 else
2041 echo 30.ok
2042 endif
2043 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 1 ]
2044 echo 31.ok
2045 else
2046 echo 31.err
2047 endif
2048 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ]
2049 echo 32.err
2050 else
2051 echo 32.ok
2052 endif
2053 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 1 ]
2054 echo 33.ok
2055 else
2056 echo 33.err
2057 endif
2058 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 0 ]
2059 echo 34.err
2060 else
2061 echo 34.ok
2062 endif
2063 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 1 ]
2064 echo 35.ok
2065 else
2066 echo 35.err
2067 endif
2068 set diet=yo curd=ho
2069 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
2070 echo 36.err
2071 else
2072 echo 36.ok
2073 endif
2074 set ndefined
2075 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
2076 echo 37.ok
2077 else
2078 echo 37.err
2079 endif
2080 # 2. Shitty grouping capabilities as of today
2081 unset diet curd ndefined
2082 if [ false || false || true ] && [ false || true ] && yes
2083 echo 40.ok
2084 else
2085 echo 40.err
2086 endif
2087 if [ [ [ 0 || 1 ] && [ 1 || 0 ] ] && 1 ] && [ yes ]
2088 echo 41.ok
2089 else
2090 echo 41.err
2091 endif
2092 if [ 1 || 0 || 0 || 0 ]
2093 echo 42.ok
2094 else
2095 echo 42.err
2096 endif
2097 if [ 1 || 0 || 0 || 0 || [ 1 ] ]
2098 echo 43.ok
2099 else
2100 echo 43.err
2101 endif
2102 if [ 1 || 0 || 0 || 0 || [ 1 ] || 1 ] && no
2103 echo 44.err
2104 else
2105 echo 44.ok
2106 endif
2107 if [ 1 || 0 || 0 || 0 || 1 || [ 1 ] ] && no || [ yes ]
2108 echo 45.ok
2109 else
2110 echo 45.err
2111 endif
2112 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && 1 ] ] && [ 1 ] ]
2113 echo 46.ok
2114 else
2115 echo 46.err
2116 endif
2117 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && [ 1 ] ] ] && 0 ]
2118 echo 47.err
2119 else
2120 echo 47.ok
2121 endif
2122 if [ [ [ [ [ [ [ 1 ] ] && 1 ] && 0 ] && [ 1 ] ] ] && 1 ]
2123 echo 48.err
2124 else
2125 echo 48.ok
2126 endif
2127 if [ [ [ [ [ [ 0 ] && 1 ] && 1 ] && 1 ] ] && 1 ]
2128 echo 49.err
2129 else
2130 echo 49.ok
2131 endif
2132 if 1 || 0 || 0 || 0 && 0
2133 echo 50.err
2134 else
2135 echo 50.ok
2136 endif
2137 if 1 || 0 || 0 || 0 && 1
2138 echo 51.ok
2139 else
2140 echo 51.err
2141 endif
2142 if 0 || 0 || 0 || 1 && 0
2143 echo 52.err
2144 else
2145 echo 52.ok
2146 endif
2147 if 0 || 0 || 0 || 1 && 1
2148 echo 53.ok
2149 else
2150 echo 53.err
2151 endif
2152 if 0 || 0 || 0 || 1 && 0 || 1 && 0
2153 echo 54.err
2154 else
2155 echo 54.ok
2156 endif
2157 if 0 || 0 || 0 || 1 && 0 || 1 && 1
2158 echo 55.ok
2159 else
2160 echo 55.err
2161 endif
2162 set diet=yo curd=ho
2163 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
2164 echo 56.err
2165 else
2166 echo 56.ok
2167 endif
2168 if $diet == 'yo' && $curd == 'ho' && $ndefined
2169 echo 57.err
2170 else
2171 echo 57.ok
2172 endif
2173 set ndefined
2174 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
2175 echo 57.ok
2176 else
2177 echo 57.err
2178 endif
2179 if $diet == 'yo' && $curd == 'ho' && $ndefined
2180 echo 58.ok
2181 else
2182 echo 58.err
2183 endif
2184 if [ [ [ [ [ [ $diet == 'yo' && $curd == 'ho' && $ndefined ] ] ] ] ] ]
2185 echo 59.ok
2186 else
2187 echo 59.err
2188 endif
2189 # Some more en-braced variables
2190 set diet=yo curd=ho
2191 if ${diet} == ${curd}
2192 echo 70.err
2193 else
2194 echo 70.ok
2195 endif
2196 if ${diet} != ${curd}
2197 echo 71.ok
2198 else
2199 echo 71.err
2200 endif
2201 if $diet == ${curd}
2202 echo 72.err
2203 else
2204 echo 72.ok
2205 endif
2206 if ${diet} == $curd
2207 echo 73.err
2208 else
2209 echo 73.ok
2210 endif
2211 # Unary !
2212 if ! 0 && ! ! 1 && ! ! ! ! 2 && 3
2213 echo 80.ok
2214 else
2215 echo 80.err
2216 endif
2217 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ ! 2 ] ] ] && 3
2218 echo 81.ok
2219 else
2220 echo 81.err
2221 endif
2222 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
2223 echo 82.ok
2224 else
2225 echo 82.err
2226 endif
2227 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
2228 echo 83.err
2229 else
2230 echo 83.ok
2231 endif
2232 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
2233 echo 84.err
2234 else
2235 echo 84.ok
2236 endif
2237 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
2238 echo 85.err
2239 else
2240 echo 85.ok
2241 endif
2242 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
2243 echo 86.err
2244 else
2245 echo 86.ok
2246 endif
2247 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] || 3
2248 echo 87.ok
2249 else
2250 echo 87.err
2251 endif
2252 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! ! [ 2 ] ] ] ] ]
2253 echo 88.ok
2254 else
2255 echo 88.err
2256 endif
2257 # Unary !, odd
2258 if ! 0 && ! ! 1 && ! ! ! 0 && 3
2259 echo 90.ok
2260 else
2261 echo 90.err
2262 endif
2263 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ 0 ] ] ] && 3
2264 echo 91.ok
2265 else
2266 echo 91.err
2267 endif
2268 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ [ 0 ] ] ] ] ] && 3
2269 echo 92.ok
2270 else
2271 echo 92.err
2272 endif
2273 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! ! [ ! [ ! 0 ] ] ] ] && ! 3
2274 echo 93.err
2275 else
2276 echo 93.ok
2277 endif
2278 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ ! [ ! [ ! [ ! 0 ] ] ] ] && 3
2279 echo 94.ok
2280 else
2281 echo 94.err
2282 endif
2283 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! ! [ ! [ ! [ ! [ 0 ] ] ] ] ] && 3
2284 echo 95.err
2285 else
2286 echo 95.ok
2287 endif
2288 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! ! 0 ] ] ] ] && 3
2289 echo 96.err
2290 else
2291 echo 96.ok
2292 endif
2293 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ ! 0 ] ] ] ] ] || 3
2294 echo 97.ok
2295 else
2296 echo 97.err
2297 endif
2298 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! [ 0 ] ] ] ] ]
2299 echo 98.ok
2300 else
2301 echo 98.err
2302 endif
2303 __EOT
2305 check normal-old 0 "${MBOX}" '1688759742 719' # pre v15compat
2307 if have_feat regex; then
2308 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
2309 set dietcurd=yoho
2310 if $dietcurd =~ '^yo.*'
2311 echo 1.ok
2312 else
2313 echo 1.err
2314 endif
2315 if $dietcurd =~ '^Yo.*'
2316 echo 1-1.err
2317 else
2318 echo 1-1.ok
2319 endif
2320 if $dietcurd =~?case '^Yo.*'
2321 echo 1-2.ok
2322 else
2323 echo 1-2.err
2324 endif
2325 if $dietcurd =~ '^yOho.+'
2326 echo 2.err
2327 else
2328 echo 2.ok
2329 endif
2330 if $dietcurd !~? '.*Ho$'
2331 echo 3.err
2332 else
2333 echo 3.ok
2334 endif
2335 if $dietcurd !~ '.+yohO$'
2336 echo 4.ok
2337 else
2338 echo 4.err
2339 endif
2340 if [ $dietcurd !~?cas '.+yoho$' ]
2341 echo 5.ok
2342 else
2343 echo 5.err
2344 endif
2345 if ! [ $dietcurd =~?case '.+yoho$' ]
2346 echo 6.ok
2347 else
2348 echo 6.err
2349 endif
2350 if ! ! [ $dietcurd !~? '.+yoho$' ]
2351 echo 7.ok
2352 else
2353 echo 7.err
2354 endif
2355 if ! [ ! [ $dietcurd !~? '.+yoho$' ] ]
2356 echo 8.ok
2357 else
2358 echo 8.err
2359 endif
2360 if [ ! [ ! [ $dietcurd !~? '.+yoho$' ] ] ]
2361 echo 9.ok
2362 else
2363 echo 9.err
2364 endif
2365 if ! [ ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
2366 echo 10.err
2367 else
2368 echo 10.ok
2369 endif
2370 if ! ! ! $dietcurd !~ '.+yoho$'
2371 echo 11.err
2372 else
2373 echo 11.ok
2374 endif
2375 if ! ! ! $dietcurd =~ '.+yoho$'
2376 echo 12.ok
2377 else
2378 echo 12.err
2379 endif
2380 if ! [ ! ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
2381 echo 13.ok
2382 else
2383 echo 13.err
2384 endif
2385 set diet=abc curd='^abc$'
2386 if $diet =~ $curd
2387 echo 14.ok
2388 else
2389 echo 14.err
2390 endif
2391 set diet=abc curd='^abcd$'
2392 if $diet !~ $curd
2393 echo 15.ok
2394 else
2395 echo 15.err
2396 endif
2397 __EOT
2399 check regex-old 0 "${MBOX}" '1115671789 95' # pre v15compat
2400 else
2401 t_echoskip 'regex-old:[no regex option]'
2404 ## post v15compat
2406 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Sv15-compat=X > "${MBOX}"
2407 \if -N xyz; echo 1.err-1; \
2408 \elif ! -Z xyz;echo 1.err-2;\
2409 \elif -n "$xyz" ; echo 1.err-3 ; \
2410 \elif ! -z "$xyz" ; echo 1.err-4 ; \
2411 \else;echo 1.ok;\
2412 \end
2413 \set xyz
2414 \if ! -N xyz; echo 2.err-1; \
2415 \elif -Z xyz;echo 2.err-2;\
2416 \elif -n "$xyz" ; echo 2.err-3 ; \
2417 \elif ! -z "$xyz" ; echo 2.err-4 ; \
2418 \else;echo 2.ok;\
2419 \end
2420 \set xyz=notempty
2421 \if ! -N xyz; echo 3.err-1; \
2422 \elif -Z xyz;echo 3.err-2;\
2423 \elif ! -n "$xyz";echo 3.err-3;\
2424 \elif -z "$xyz";echo 3.err-4;\
2425 \else;echo 3.ok;\
2426 \end
2427 \if $xyz != notempty;echo 4.err-1;else;echo 4.ok;\end
2428 \if $xyz == notempty;echo 5.ok;else;echo 5.err-1;\end
2429 __EOT
2431 check NnZz_whiteout 0 "${MBOX}" '4280687462 25'
2433 # TODO t_ifelse: individual tests as for NnZz_whiteout
2434 # Nestable conditions test
2435 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Sv15-compat=x > "${MBOX}"
2436 if 0
2437 echo 1.err
2438 else
2439 echo 1.ok
2440 endif
2441 if 1
2442 echo 2.ok
2443 else
2444 echo 2.err
2445 endif
2446 if [ "$dietcurd" != "" ]
2447 echo 3.err
2448 else
2449 echo 3.ok
2450 endif
2451 set dietcurd=yoho
2452 if $'\$dietcurd' != ""
2453 echo 4.ok
2454 else
2455 echo 4.err
2456 endif
2457 if "$dietcurd" == 'yoho'
2458 echo 5.ok
2459 else
2460 echo 5.err
2461 endif
2462 if $'\$dietcurd' ==? 'Yoho'
2463 echo 5-1.ok
2464 else
2465 echo 5-1.err
2466 endif
2467 if $dietcurd == 'Yoho'
2468 echo 5-2.err
2469 else
2470 echo 5-2.ok
2471 endif
2472 if $dietcurd != 'yoho'
2473 echo 6.err
2474 else
2475 echo 6.ok
2476 endif
2477 if $dietcurd !=?case 'Yoho'
2478 echo 6-1.err
2479 else
2480 echo 6-1.ok
2481 endif
2482 if $dietcurd != 'Yoho'
2483 echo 6-2.ok
2484 else
2485 echo 6-2.err
2486 endif
2487 # Nesting
2488 if faLse
2489 echo 7.err1
2490 if tRue
2491 echo 7.err2
2492 if yEs
2493 echo 7.err3
2494 else
2495 echo 7.err4
2496 endif
2497 echo 7.err5
2498 endif
2499 echo 7.err6
2500 else
2501 echo 7.ok7
2502 if YeS
2503 echo 7.ok8
2504 if No
2505 echo 7.err9
2506 else
2507 echo 7.ok9
2508 endif
2509 echo 7.ok10
2510 else
2511 echo 7.err11
2512 if yeS
2513 echo 7.err12
2514 else
2515 echo 7.err13
2516 endif
2517 endif
2518 echo 7.ok14
2519 endif
2520 if r
2521 echo 8.ok1
2522 if R
2523 echo 8.ok2
2524 else
2525 echo 8.err2
2526 endif
2527 echo 8.ok3
2528 else
2529 echo 8.err1
2530 endif
2531 if s
2532 echo 9.err1
2533 else
2534 echo 9.ok1
2535 if S
2536 echo 9.err2
2537 else
2538 echo 9.ok2
2539 endif
2540 echo 9.ok3
2541 endif
2542 # `elif'
2543 if $dietcurd == 'yohu'
2544 echo 10.err1
2545 elif $dietcurd == 'yoha'
2546 echo 10.err2
2547 elif $dietcurd == 'yohe'
2548 echo 10.err3
2549 elif $dietcurd == 'yoho'
2550 echo 10.ok1
2551 if $dietcurd == 'yohu'
2552 echo 10.err4
2553 elif $dietcurd == 'yoha'
2554 echo 10.err5
2555 elif $dietcurd == 'yohe'
2556 echo 10.err6
2557 elif $dietcurd == 'yoho'
2558 echo 10.ok2
2559 if $dietcurd == 'yohu'
2560 echo 10.err7
2561 elif $dietcurd == 'yoha'
2562 echo 10.err8
2563 elif $dietcurd == 'yohe'
2564 echo 10.err9
2565 elif $dietcurd == 'yoho'
2566 echo 10.ok3
2567 else
2568 echo 10.err10
2569 endif
2570 else
2571 echo 10.err11
2572 endif
2573 else
2574 echo 10.err12
2575 endif
2576 # integer
2577 set dietcurd=10
2578 if $dietcurd -lt 11
2579 echo 11.ok1
2580 if $dietcurd -gt 9
2581 echo 11.ok2
2582 else
2583 echo 11.err2
2584 endif
2585 if $dietcurd -eq 10
2586 echo 11.ok3
2587 else
2588 echo 11.err3
2589 endif
2590 if $dietcurd -ge 10
2591 echo 11.ok4
2592 else
2593 echo 11.err4
2594 endif
2595 if $dietcurd -le 10
2596 echo 11.ok5
2597 else
2598 echo 11.err5
2599 endif
2600 if $dietcurd -ge 11
2601 echo 11.err6
2602 else
2603 echo 11.ok6
2604 endif
2605 if $dietcurd -ge?satu -0xFFFFFFFFFFFFFFFF1
2606 echo 11.err7
2607 else
2608 echo 11.ok7
2609 endif
2610 else
2611 echo 11.err1
2612 endif
2613 set dietcurd=Abc
2614 if $dietcurd < aBd
2615 echo 12.ok1
2616 if $dietcurd >? abB
2617 echo 12.ok2
2618 else
2619 echo 12.err2
2620 endif
2621 if $dietcurd ==?case aBC
2622 echo 12.ok3
2623 else
2624 echo 12.err3
2625 endif
2626 if $dietcurd >=?ca AbC
2627 echo 12.ok4
2628 else
2629 echo 12.err4
2630 endif
2631 if $dietcurd <=? ABc
2632 echo 12.ok5
2633 else
2634 echo 12.err5
2635 endif
2636 if $dietcurd >=?case abd
2637 echo 12.err6
2638 else
2639 echo 12.ok6
2640 endif
2641 if $dietcurd <=? abb
2642 echo 12.err7
2643 else
2644 echo 12.ok7
2645 endif
2646 else
2647 echo 12.err1
2648 endif
2649 if $dietcurd < aBc
2650 echo 12-1.ok
2651 else
2652 echo 12-1.err
2653 endif
2654 if $dietcurd <? aBc
2655 echo 12-2.err
2656 else
2657 echo 12-2.ok
2658 endif
2659 if $dietcurd > ABc
2660 echo 12-3.ok
2661 else
2662 echo 12-3.err
2663 endif
2664 if $dietcurd >? ABc
2665 echo 12-3.err
2666 else
2667 echo 12-3.ok
2668 endif
2669 if $dietcurd =%?case aB
2670 echo 13.ok
2671 else
2672 echo 13.err
2673 endif
2674 if $dietcurd =% aB
2675 echo 13-1.err
2676 else
2677 echo 13-1.ok
2678 endif
2679 if $dietcurd =%? bC
2680 echo 14.ok
2681 else
2682 echo 14.err
2683 endif
2684 if $dietcurd !% aB
2685 echo 15-1.ok
2686 else
2687 echo 15-1.err
2688 endif
2689 if $dietcurd !%? aB
2690 echo 15-2.err
2691 else
2692 echo 15-2.ok
2693 endif
2694 if $dietcurd !% bC
2695 echo 15-3.ok
2696 else
2697 echo 15-3.err
2698 endif
2699 if $dietcurd !%? bC
2700 echo 15-4.err
2701 else
2702 echo 15-4.ok
2703 endif
2704 if $dietcurd =% Cd
2705 echo 16.err
2706 else
2707 echo 16.ok
2708 endif
2709 if $dietcurd !% Cd
2710 echo 17.ok
2711 else
2712 echo 17.err
2713 endif
2714 set diet='ab c' curd='ab c'
2715 if "$diet" == "$curd"
2716 echo 18.ok
2717 else
2718 echo 18.err
2719 endif
2720 set diet='ab c' curd='ab cd'
2721 if "$diet" != "$curd"
2722 echo 19.ok
2723 else
2724 echo 19.err
2725 endif
2726 # 1. Shitty grouping capabilities as of today
2727 unset diet curd ndefined
2728 if [ [ false ] || [ false ] || [ true ] ] && \
2729 [ [ false ] || [ true ] ] && \
2730 [ yes ]
2731 echo 20.ok
2732 else
2733 echo 20.err
2734 endif
2735 if [ [ [ [ 0 ] || [ 1 ] ] && [ [ 1 ] || [ 0 ] ] ] && [ 1 ] ] && [ yes ]
2736 echo 21.ok
2737 else
2738 echo 21.err
2739 endif
2740 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] ]
2741 echo 22.ok
2742 else
2743 echo 22.err
2744 endif
2745 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] ]
2746 echo 23.ok
2747 else
2748 echo 23.err
2749 endif
2750 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] && [ no ]
2751 echo 24.err
2752 else
2753 echo 24.ok
2754 endif
2755 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] \
2756 && [ no ] || [ yes ]
2757 echo 25.ok
2758 else
2759 echo 25.err
2760 endif
2761 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
2762 echo 26.ok
2763 else
2764 echo 26.err
2765 endif
2766 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 0 ] ]
2767 echo 27.err
2768 else
2769 echo 27.ok
2770 endif
2771 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 0 ] ] && [ 1 ] ] ] && [ 1 ] ]
2772 echo 28.err
2773 else
2774 echo 28.ok
2775 endif
2776 if [ [ [ [ [ [ [ 0 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
2777 echo 29.err
2778 else
2779 echo 29.ok
2780 endif
2781 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 0 ]
2782 echo 30.err
2783 else
2784 echo 30.ok
2785 endif
2786 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 1 ]
2787 echo 31.ok
2788 else
2789 echo 31.err
2790 endif
2791 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ]
2792 echo 32.err
2793 else
2794 echo 32.ok
2795 endif
2796 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 1 ]
2797 echo 33.ok
2798 else
2799 echo 33.err
2800 endif
2801 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 0 ]
2802 echo 34.err
2803 else
2804 echo 34.ok
2805 endif
2806 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 1 ]
2807 echo 35.ok
2808 else
2809 echo 35.err
2810 endif
2811 set diet=yo curd=ho
2812 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && \
2813 [ -N ndefined || -n "$ndefined" || \
2814 ! -Z ndefined || ! -z "$ndefined" ]
2815 echo 36.err
2816 else
2817 echo 36.ok
2818 endif
2819 set ndefined
2820 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && \
2821 -N ndefined && ! -n "$ndefined" && \
2822 ! -Z ndefined && -z "$ndefined"
2823 echo 37.ok
2824 else
2825 echo 37.err
2826 endif
2827 # 2. Shitty grouping capabilities as of today
2828 unset diet curd ndefined
2829 if [ false || false || true ] && [ false || true ] && yes
2830 echo 40.ok
2831 else
2832 echo 40.err
2833 endif
2834 if [ [ [ 0 || 1 ] && [ 1 || 0 ] ] && 1 ] && [ yes ]
2835 echo 41.ok
2836 else
2837 echo 41.err
2838 endif
2839 if [ 1 || 0 || 0 || 0 ]
2840 echo 42.ok
2841 else
2842 echo 42.err
2843 endif
2844 if [ 1 || 0 || 0 || 0 || [ 1 ] ]
2845 echo 43.ok
2846 else
2847 echo 43.err
2848 endif
2849 if [ 1 || 0 || 0 || 0 || [ 1 ] || 1 ] && no
2850 echo 44.err
2851 else
2852 echo 44.ok
2853 endif
2854 if [ 1 || 0 || 0 || 0 || 1 || [ 1 ] ] && no || [ yes ]
2855 echo 45.ok
2856 else
2857 echo 45.err
2858 endif
2859 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && 1 ] ] && [ 1 ] ]
2860 echo 46.ok
2861 else
2862 echo 46.err
2863 endif
2864 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && [ 1 ] ] ] && 0 ]
2865 echo 47.err
2866 else
2867 echo 47.ok
2868 endif
2869 if [ [ [ [ [ [ [ 1 ] ] && 1 ] && 0 ] && [ 1 ] ] ] && 1 ]
2870 echo 48.err
2871 else
2872 echo 48.ok
2873 endif
2874 if [ [ [ [ [ [ 0 ] && 1 ] && 1 ] && 1 ] ] && 1 ]
2875 echo 49.err
2876 else
2877 echo 49.ok
2878 endif
2879 if 1 || 0 || 0 || 0 && 0
2880 echo 50.err
2881 else
2882 echo 50.ok
2883 endif
2884 if 1 || 0 || 0 || 0 && 1
2885 echo 51.ok
2886 else
2887 echo 51.err
2888 endif
2889 if 0 || 0 || 0 || 1 && 0
2890 echo 52.err
2891 else
2892 echo 52.ok
2893 endif
2894 if 0 || 0 || 0 || 1 && 1
2895 echo 53.ok
2896 else
2897 echo 53.err
2898 endif
2899 if 0 || 0 || 0 || 1 && 0 || 1 && 0
2900 echo 54.err
2901 else
2902 echo 54.ok
2903 endif
2904 if 0 || 0 || 0 || 1 && 0 || 1 && 1
2905 echo 55.ok
2906 else
2907 echo 55.err
2908 endif
2909 set diet=yo curd=ho
2910 if [ $diet == 'yo' && $curd == 'ho' ] && \
2911 [ -N ndefined || -n "$ndefined" || \
2912 ! -Z ndefined || ! -z "$ndefined" ]
2913 echo 56.err
2914 else
2915 echo 56.ok
2916 endif
2917 if [ $diet == 'yo' && $curd == 'ho' && \
2918 [ [ -N ndefined || -n "$ndefined" || \
2919 ! -Z ndefined || ! -z "$ndefined" ] ] ]
2920 echo 57.err
2921 else
2922 echo 57.ok
2923 endif
2924 set ndefined
2925 if [ $diet == 'yo' && $curd == 'ho' ] && \
2926 -N ndefined && ! -n "$ndefined" && \
2927 ! -Z ndefined && -z "$ndefined"
2928 echo 57.ok
2929 else
2930 echo 57.err
2931 endif
2932 if $diet == 'yo' && $curd == 'ho' && ! -Z ndefined
2933 echo 58.ok
2934 else
2935 echo 58.err
2936 endif
2937 if [ [ [ [ [ [ $diet == 'yo' && $curd == 'ho' && -N ndefined ] ] ] ] ] ]
2938 echo 59.ok
2939 else
2940 echo 59.err
2941 endif
2942 # Some more en-braced variables
2943 set diet=yo curd=ho
2944 if ${diet} == ${curd}
2945 echo 70.err
2946 else
2947 echo 70.ok
2948 endif
2949 if "${diet}" != "${curd}"
2950 echo 71.ok
2951 else
2952 echo 71.err
2953 endif
2954 if $diet == ${curd}
2955 echo 72.err
2956 else
2957 echo 72.ok
2958 endif
2959 if ${diet} == $curd
2960 echo 73.err
2961 else
2962 echo 73.ok
2963 endif
2964 # Unary !
2965 if ! 0 && ! ! 1 && ! ! ! ! 2 && 3
2966 echo 80.ok
2967 else
2968 echo 80.err
2969 endif
2970 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ ! 2 ] ] ] && 3
2971 echo 81.ok
2972 else
2973 echo 81.err
2974 endif
2975 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
2976 echo 82.ok
2977 else
2978 echo 82.err
2979 endif
2980 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
2981 echo 83.err
2982 else
2983 echo 83.ok
2984 endif
2985 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
2986 echo 84.err
2987 else
2988 echo 84.ok
2989 endif
2990 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
2991 echo 85.err
2992 else
2993 echo 85.ok
2994 endif
2995 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
2996 echo 86.err
2997 else
2998 echo 86.ok
2999 endif
3000 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] || 3
3001 echo 87.ok
3002 else
3003 echo 87.err
3004 endif
3005 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! ! [ 2 ] ] ] ] ]
3006 echo 88.ok
3007 else
3008 echo 88.err
3009 endif
3010 # Unary !, odd
3011 if ! 0 && ! ! 1 && ! ! ! 0 && 3
3012 echo 90.ok
3013 else
3014 echo 90.err
3015 endif
3016 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ 0 ] ] ] && 3
3017 echo 91.ok
3018 else
3019 echo 91.err
3020 endif
3021 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ [ 0 ] ] ] ] ] && 3
3022 echo 92.ok
3023 else
3024 echo 92.err
3025 endif
3026 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! ! [ ! [ ! 0 ] ] ] ] && ! 3
3027 echo 93.err
3028 else
3029 echo 93.ok
3030 endif
3031 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ ! [ ! [ ! [ ! 0 ] ] ] ] && 3
3032 echo 94.ok
3033 else
3034 echo 94.err
3035 endif
3036 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! ! [ ! [ ! [ ! [ 0 ] ] ] ] ] && 3
3037 echo 95.err
3038 else
3039 echo 95.ok
3040 endif
3041 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! ! 0 ] ] ] ] && 3
3042 echo 96.err
3043 else
3044 echo 96.ok
3045 endif
3046 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ ! 0 ] ] ] ] ] || 3
3047 echo 97.ok
3048 else
3049 echo 97.err
3050 endif
3051 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! [ 0 ] ] ] ] ]
3052 echo 98.ok
3053 else
3054 echo 98.err
3055 endif
3056 __EOT
3058 check normal 0 "${MBOX}" '1688759742 719'
3060 if have_feat regex; then
3061 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Sv15-compat=X > "${MBOX}"
3062 set dietcurd=yoho
3063 if $dietcurd =~ '^yo.*'
3064 echo 1.ok
3065 else
3066 echo 1.err
3067 endif
3068 if "$dietcurd" =~ '^Yo.*'
3069 echo 1-1.err
3070 else
3071 echo 1-1.ok
3072 endif
3073 if $dietcurd =~?case '^Yo.*'
3074 echo 1-2.ok
3075 else
3076 echo 1-2.err
3077 endif
3078 if $dietcurd =~ '^yOho.+'
3079 echo 2.err
3080 else
3081 echo 2.ok
3082 endif
3083 if $dietcurd !~? '.*Ho$'
3084 echo 3.err
3085 else
3086 echo 3.ok
3087 endif
3088 if $dietcurd !~ '.+yohO$'
3089 echo 4.ok
3090 else
3091 echo 4.err
3092 endif
3093 if [ $dietcurd !~?cas '.+yoho$' ]
3094 echo 5.ok
3095 else
3096 echo 5.err
3097 endif
3098 if ! [ "$dietcurd" =~?case '.+yoho$' ]
3099 echo 6.ok
3100 else
3101 echo 6.err
3102 endif
3103 if ! ! [ $'\$dietcurd' !~? '.+yoho$' ]
3104 echo 7.ok
3105 else
3106 echo 7.err
3107 endif
3108 if ! [ ! [ $dietcurd !~? '.+yoho$' ] ]
3109 echo 8.ok
3110 else
3111 echo 8.err
3112 endif
3113 if [ ! [ ! [ $dietcurd !~? '.+yoho$' ] ] ]
3114 echo 9.ok
3115 else
3116 echo 9.err
3117 endif
3118 if ! [ ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
3119 echo 10.err
3120 else
3121 echo 10.ok
3122 endif
3123 if ! ! ! $dietcurd !~ '.+yoho$'
3124 echo 11.err
3125 else
3126 echo 11.ok
3127 endif
3128 if ! ! ! $dietcurd =~ '.+yoho$'
3129 echo 12.ok
3130 else
3131 echo 12.err
3132 endif
3133 if ! [ ! ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
3134 echo 13.ok
3135 else
3136 echo 13.err
3137 endif
3138 set diet=abc curd='^abc$'
3139 if $diet =~ $curd
3140 echo 14.ok
3141 else
3142 echo 14.err
3143 endif
3144 set diet=abc curd='^abcd$'
3145 if "$diet" !~ $'\$curd'
3146 echo 15.ok
3147 else
3148 echo 15.err
3149 endif
3150 __EOT
3152 check regex 0 "${MBOX}" '1115671789 95'
3153 else
3154 t_echoskip 'regex:[!REGEX]'
3157 t_epilog "${@}"
3160 t_localopts() {
3161 t_prolog "${@}"
3163 # Nestable conditions test
3164 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
3165 define t2 {
3166 echo in: t2
3167 set t2=t2
3168 echo $t2
3170 define t1 {
3171 echo in: t1
3172 set gv1=gv1
3173 localopts on
3174 set lv1=lv1 lv2=lv2
3175 set lv3=lv3
3176 call t2
3177 localopts off
3178 set gv2=gv2
3179 echo $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2
3181 define t0 {
3182 echo in: t0
3183 call t1
3184 echo $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2
3185 echo "$gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2"
3187 account trouble {
3188 echo in: trouble
3189 call t0
3191 call t0
3192 unset gv1 gv2
3193 account trouble
3194 echo active trouble: $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t3
3195 account null
3196 echo active null: $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t3
3199 define ll2 {
3200 localopts $1
3201 set x=2
3202 echo ll2=$x
3204 define ll1 {
3205 wysh set y=$1; shift; eval localopts $y; localopts $1; shift
3206 set x=1
3207 echo ll1.1=$x
3208 call ll2 $1
3209 echo ll1.2=$x
3211 define ll0 {
3212 wysh set y=$1; shift; eval localopts $y; localopts $1; shift
3213 set x=0
3214 echo ll0.1=$x
3215 call ll1 $y "$@"
3216 echo ll0.2=$x
3218 define llx {
3219 echo ----- $1: $2 -> $3 -> $4
3220 echo ll-1.1=$x
3221 eval localopts $1
3222 call ll0 "$@"
3223 echo ll-1.2=$x
3224 unset x
3226 define lly {
3227 call llx 'call off' on on on
3228 call llx 'call off' off on on
3229 call llx 'call off' on off on
3230 call llx 'call off' on off off
3231 localopts call-fixate on
3232 call llx 'call-fixate on' on on on
3233 call llx 'call-fixate on' off on on
3234 call llx 'call-fixate on' on off on
3235 call llx 'call-fixate on' on off off
3236 unset x;localopts call on
3237 call llx 'call on' on on on
3238 call llx 'call on' off on on
3239 call llx 'call on' on off on
3240 call llx 'call on' on off off
3242 call lly
3243 __EOT
3245 check 1 0 "${MBOX}" '4016155249 1246'
3247 t_epilog "${@}"
3250 t_local() {
3251 t_prolog "${@}"
3253 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
3254 define du2 {
3255 echo du2-1 du=$du
3256 local set du=$1
3257 echo du2-2 du=$du
3258 local unset du
3259 echo du2-3 du=$du
3261 define du {
3262 local set du=dudu
3263 echo du-1 du=$du
3264 call du2 du2du2
3265 echo du-2 du=$du
3266 local set nodu
3267 echo du-3 du=$du
3269 define ich {
3270 echo ich-1 du=$du
3271 call du
3272 echo ich-2 du=$du
3274 define wir {
3275 localopts $1
3276 set du=wirwir
3277 echo wir-1 du=$du
3278 call ich
3279 echo wir-2 du=$du
3281 echo ------- global-1 du=$du
3282 call ich
3283 echo ------- global-2 du=$du
3284 set du=global
3285 call ich
3286 echo ------- global-3 du=$du
3287 call wir on
3288 echo ------- global-4 du=$du
3289 call wir off
3290 echo ------- global-5 du=$du
3291 __EOT
3292 check 1 0 "${MBOX}" '2411598140 641'
3295 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
3296 define z {
3297 echo z-1: x=$x y=$y z=$z crt=$crt
3298 local set z=1 y=2 crt=10
3299 echo z-2: x=$x y=$y z=$z crt=$crt
3301 define y {
3302 echo y-1: x=$x y=$y z=$z crt=$crt
3303 local set x=2 y=1 crt=5
3304 echo y-2: x=$x y=$y z=$z crt=$crt
3305 call z
3306 echo y-3: x=$x y=$y z=$z crt=$crt
3308 define x {
3309 echo x-1: x=$x y=$y z=$z crt=$crt
3310 local set x=1 crt=1
3311 echo x-2: x=$x y=$y z=$z crt=$crt
3312 call y
3313 echo x-3: x=$x y=$y z=$z crt=$crt
3315 set crt
3316 echo global-1: x=$x y=$y z=$z crt=$crt
3317 call x
3318 echo global-2: x=$x y=$y z=$z crt=$crt
3319 __EOT
3320 check 2 0 "${MBOX}" '2560788669 216'
3322 t_epilog "${@}"
3325 t_environ() {
3326 t_prolog "${@}"
3328 ${cat} <<- '__EOT' | EK1=EV1 EK2=EV2 ${MAILX} ${ARGS} > "${MBOX}" 2>&1
3329 echo "we: EK1<$EK1> EK2<$EK2> EK3<$EK3> EK4<$EK4> NEK5<$NEK5>"
3330 !echo "shell: EK1<$EK1> EK2<$EK2> EK3<$EK3> EK4<$EK4> NEK5<$NEK5>"
3331 varshow EK1 EK2 EK3 EK4 NEK5
3333 echo environ set EK3 EK4, set NEK5
3334 environ set EK3=EV3 EK4=EV4
3335 set NEK5=NEV5
3336 echo "we: EK1<$EK1> EK2<$EK2> EK3<$EK3> EK4<$EK4> NEK5<$NEK5>"
3337 !echo "shell: EK1<$EK1> EK2<$EK2> EK3<$EK3> EK4<$EK4> NEK5<$NEK5>"
3338 varshow EK1 EK2 EK3 EK4 NEK5
3340 echo removing NEK5 EK3
3341 unset NEK5
3342 environ unset EK3
3343 echo "we: EK1<$EK1> EK2<$EK2> EK3<$EK3> EK4<$EK4> NEK5<$NEK5>"
3344 !echo "shell: EK1<$EK1> EK2<$EK2> EK3<$EK3> EK4<$EK4> NEK5<$NEK5>"
3345 varshow EK1 EK2 EK3 EK4 NEK5
3347 echo changing EK1, EK4
3348 set EK1=EV1_CHANGED EK4=EV4_CHANGED
3349 echo "we: EK1<$EK1> EK2<$EK2> EK3<$EK3> EK4<$EK4> NEK5<$NEK5>"
3350 !echo "shell: EK1<$EK1> EK2<$EK2> EK3<$EK3> EK4<$EK4> NEK5<$NEK5>"
3351 varshow EK1 EK2 EK3 EK4 NEK5
3353 echo linking EK4, rechanging EK1, EK4
3354 environ link EK4
3355 set EK1=EV1 EK4=EV4
3356 echo "we: EK1<$EK1> EK2<$EK2> EK3<$EK3> EK4<$EK4> NEK5<$NEK5>"
3357 !echo "shell: EK1<$EK1> EK2<$EK2> EK3<$EK3> EK4<$EK4> NEK5<$NEK5>"
3358 varshow EK1 EK2 EK3 EK4 NEK5
3360 echo unset all
3361 unset EK1 EK2 EK4
3362 echo "we: EK1<$EK1> EK2<$EK2> EK3<$EK3> EK4<$EK4> NEK5<$NEK5>"
3363 !echo "shell: EK1<$EK1> EK2<$EK2> EK3<$EK3> EK4<$EK4> NEK5<$NEK5>"
3364 varshow EK1 EK2 EK3 EK4 NEK5
3365 __EOT
3367 check 1 0 "${MBOX}" '1685686686 1342'
3369 t_epilog "${@}"
3370 return
3373 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
3374 define l4 {
3375 echo '-------> L4 (environ unlink EK1, own localopts)'
3376 localopts yes
3377 environ unlink EK1
3378 set LK1=LK1_L4 EK1=EK1_L4
3379 echo "we: L4: LK1<$LK1> EK1<$EK1>"
3380 !echo "shell: L4: LK1<$LK1> EK1<$EK1>"
3381 varshow LK1 EK1
3382 echo '-------< L4'
3384 define l3 {
3385 echo '-------> L3'
3386 set LK1=LK1_L3 EK1=EK1_L3
3387 echo "we: L3-pre: LK1<$LK1> EK1<$EK1>"
3388 !echo "shell: L3-pre: LK1<$LK1> EK1<$EK1>"
3389 varshow LK1 EK1
3390 call l4
3391 echo "we: L3-post: LK1<$LK1> EK1<$EK1>"
3392 !echo "shell: L3-post: LK1<$LK1> EK1<$EK1>"
3393 varshow LK1 EK1
3394 echo '-------< L3'
3396 define l2 {
3397 echo '-------> L2'
3398 set LK1=LK1_L2 EK1=EK1_L2
3399 echo "we: L2-pre: LK1<$LK1> EK1<$EK1>"
3400 !echo "shell: L2-pre: LK1<$LK1> EK1<$EK1>"
3401 varshow LK1 EK1
3402 call l3
3403 echo "we: L2-post: LK1<$LK1> EK1<$EK1>"
3404 !echo "shell: L2-post: LK1<$LK1> EK1<$EK1>"
3405 varshow LK1 EK1
3406 echo '-------< L2'
3408 define l1 {
3409 echo '-------> L1 (environ link EK1; localopts call-fixate)'
3410 localopts call-fixate yes
3411 set LK1=LK1_L1 EK1=EK1_L1
3412 environ link EK1
3413 echo "we: L1-pre: LK1<$LK1> EK1<$EK1>"
3414 !echo "shell: L1-pre: LK1<$LK1> EK1<$EK1>"
3415 varshow LK1 EK1
3416 call l2
3417 echo "we: L1-post: LK1<$LK1> EK1<$EK1>"
3418 !echo "shell: L1-post: LK1<$LK1> EK1<$EK1>"
3419 varshow LK1 EK1
3420 echo '-------< L1'
3422 echo "we: outer-pre: LK1<$LK1> EK1<$EK1>"
3423 !echo "shell: outer-pre: LK1<$LK1> EK1<$EK1>"
3424 varshow LK1 EK1
3425 call l1
3426 echo "we: outer-post: LK1<$LK1> EK1<$EK1>"
3427 !echo "shell: outer-post: LK1<$LK1> EK1<$EK1>"
3428 varshow LK1 EK1
3429 __EOT
3431 check 2 0 "${MBOX}" '1903030743 1131'
3433 t_epilog "${@}"
3436 t_macro_param_shift() {
3437 t_prolog "${@}"
3439 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>>${ERR}
3440 define t2 {
3441 echo in: t2
3442 echo t2.0 has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
3443 localopts on
3444 wysh set ignerr=$1
3445 shift
3446 localopts off
3447 echo t2.1 has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
3448 if [ $# > 1 ] || [ $ignerr == '' ]
3449 shift 2
3450 else
3451 ignerr shift 2
3452 endif
3453 echo t2.2:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
3454 shift 0
3455 echo t2.3:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
3456 if [ $# > 0 ]
3457 shift
3458 endif
3459 echo t2.4:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
3461 define t1 {
3462 set errexit
3463 echo in: t1
3464 call t2 1 you get four args
3465 echo t1.1: $?';' ignerr ($ignerr) should not exist
3466 call t2 1 you get 'three args'
3467 echo t1.2: $?';' ignerr ($ignerr) should not exist
3468 call t2 1 you 'get two args'
3469 echo t1.3: $?';' ignerr ($ignerr) should not exist
3470 call t2 1 'you get one arg'
3471 echo t1.4: $?';' ignerr ($ignerr) should not exist
3472 ignerr call t2 '' 'you get one arg'
3473 echo t1.5: $?';' ignerr ($ignerr) should not exist
3475 call t1
3476 __EOT
3478 check 1 0 "${MBOX}" '1402489146 1682'
3480 t_epilog "${@}"
3483 t_addrcodec() {
3484 t_prolog "${@}"
3486 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
3487 commandalias x echo '$?/$^ERRNAME $res'
3488 vput addrcodec res e 1 <doog@def>
3490 eval vput addrcodec res d $res
3492 vput addrcodec res e 2 . <doog@def>
3494 eval vput addrcodec res d $res
3496 vput addrcodec res e 3 Sauer Dr. <doog@def>
3498 eval vput addrcodec res d $res
3500 vput addrcodec res e 3.50 Sauer (Ma) Dr. <doog@def>
3502 eval vput addrcodec res d $res
3504 vput addrcodec res e 3.51 Sauer (Ma) "Dr." <doog@def>
3506 eval vput addrcodec res d $res
3509 vput addrcodec res +e 4 Sauer (Ma) Dr. <doog@def>
3511 eval vput addrcodec res d $res
3513 vput addrcodec res +e 5 Sauer (Ma) Braten Dr. <doog@def>
3515 eval vput addrcodec res d $res
3517 vput addrcodec res +e 6 Sauer (Ma) Braten Dr. (Heu) <doog@def>
3519 eval vput addrcodec res d $res
3521 vput addrcodec res +e 7 Sauer (Ma) Braten Dr. (Heu) <doog@def> (bu)
3523 eval vput addrcodec res d $res
3525 vput addrcodec res +e 8 \
3526 Dr. Sauer (Ma) Braten Dr. (Heu) <doog@def> (bu) Boom. Boom
3528 eval vput addrcodec res d $res
3530 vput addrcodec res +e 9 Dr.Sauer(Ma)Braten Dr. (Heu) <doog@def>
3532 eval vput addrcodec res d $res
3534 vput addrcodec res +e 10 (Ma)Braten Dr. (Heu) <doog@def>
3536 eval vput addrcodec res d $res
3538 vput addrcodec res +e 11 (Ma)Braten Dr"." (Heu) <doog@def>
3540 eval vput addrcodec res d $res
3542 vput addrcodec res +e 12 Dr. Sauer (Ma) Braten Dr. (u) <doog@def>
3544 eval vput addrcodec res d $res
3546 vput addrcodec res +e 13(Ma)Braten Dr. (Heu) <doog@def>
3548 eval vput addrcodec res d $res
3550 vput addrcodec res +e 14 Hey, Du <doog@def> Wie() findet Dr. das? ()
3552 eval vput addrcodec res d $res
3554 vput addrcodec res +e 15 \
3555 Hey, Du <doog@def> Wie() findet "" Dr. "" das? ()
3557 eval vput addrcodec res d $res
3559 vput addrcodec res +e 16 \
3560 "Hey," "Du" <doog@def> "Wie()" findet "" Dr. "" das? ()
3562 eval vput addrcodec res d $res
3564 vput addrcodec res +e 17 \
3565 "Hey" Du <doog@def> "Wie() findet " " Dr. """ das? ()
3567 eval vput addrcodec res d $res
3569 vput addrcodec res +e 18 \
3570 <doog@def> "Hey" Du "Wie() findet " " Dr. """ das? ()
3572 eval vput addrcodec res d $res
3574 vput addrcodec res +e 19 Hey\,\" <doog@def> "Wie()" findet \" Dr. \" das?
3576 eval vput addrcodec res d $res
3579 vput addrcodec res ++e 20 Hey\,\" <doog@def> "Wie()" findet \" Dr. \" das?
3581 vput addrcodec res ++e 21 Hey\,\"" <doog@def> "Wie()" findet \" Dr. \" das?
3583 eval vput addrcodec res d $res
3586 vput addrcodec res \
3587 +++e 22 Hey\\,\" <doog@def> "Wie()" findet \" Dr. \" das?
3589 eval vput addrcodec res d $res
3592 vput addrcodec res s \
3593 "23 Hey\\,\\\" \"Wie" () "\" findet \\\" Dr. \\\" das?" <doog@def>
3596 # Fix for [f3852f88]
3597 vput addrcodec res ++e <from2@exam.ple> 100 (comment) "Quot(e)d"
3599 eval vput addrcodec res d $res
3601 vput addrcodec res e <from2@exam.ple> 100 (comment) "Quot(e)d"
3603 eval vput addrcodec res d $res
3605 __EOT
3607 check 1 0 "${MBOX}" '1047317989 2612'
3609 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
3610 commandalias x echo '$?/$^ERRNAME $res'
3611 mlist isa1@list
3612 mlsubscribe isa2@list
3614 vput addrcodec res skin Hey\\,\" <isa0@list> "Wie()" find \" Dr. \" das?
3616 vput addrcodec res skinlist Hey\\,\" <isa0@list> "Wie()" find \" Dr. \" das?
3618 vput addrcodec res skin Hey\\,\" <isa1@list> "Wie()" find \" Dr. \" das?
3620 vput addrcodec res skinlist Hey\\,\" <isa1@list> "Wie()" find \" Dr. \" das?
3622 vput addrcodec res skin Hey\\,\" <isa2@list> "Wie()" find \" Dr. \" das?
3624 vput addrcodec res skinlist Hey\\,\" <isa2@list> "Wie()" find \" Dr. \" das?
3626 __EOT
3628 check 2 0 "${MBOX}" '1391779299 104'
3630 if have_feat idna; then
3631 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} ${ADDARG_UNI} > "${MBOX}" 2>&1
3632 commandalias x echo '$?/$^ERRNAME $res'
3633 vput addrcodec res e (heu) <du@blödiän> "stroh" du
3635 eval vput addrcodec res d $res
3637 vput addrcodec res e <du@blödiän> du
3639 eval vput addrcodec res d $res
3641 vput addrcodec res e du <du@blödiän>
3643 eval vput addrcodec res d $res
3645 vput addrcodec res e <du@blödiän>
3647 eval vput addrcodec res d $res
3649 vput addrcodec res e du@blödiän
3651 eval vput addrcodec res d $res
3653 __EOT
3655 check idna 0 "${MBOX}" '498775983 326'
3656 else
3657 t_echoskip 'idna:[!IDNA]'
3660 t_epilog "${@}"
3663 t_csop() {
3664 t_prolog "${@}"
3666 if have_feat cmd-csop; then :; else
3667 t_echoskip '[!CMD_CSOP]'
3668 t_epilog "${@}"
3669 return
3672 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
3673 commandalias x echo '$?/$^ERRNAME :$res:'
3674 echo ' #-2'
3675 vput csop res find you y;x
3676 vput csop res find you o;x
3677 vput csop res find you u;x
3678 vput csop res find you yo;x
3679 vput csop res find you ou;x
3680 vput csop res find you you;x
3681 echo ' #-1'
3682 vput csop res find you Y;x
3683 vput csop res find? you Y;x
3684 vput csop res find?case you O;x
3685 vput csop res find? you U;x
3686 vput csop res find?ca you yO;x
3687 vput csop res find? you oU;x
3688 vput csop res find? you YoU;x
3689 echo ' #0'
3690 vput csop res find 'bananarama' 'nana';x
3691 vput csop res find 'bananarama' 'bana';x
3692 vput csop res find 'bananarama' 'Bana';x
3693 vput csop res find 'bananarama' 'rama';x
3694 echo ' #1'
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 ' #2'
3700 vput csop res substring 'bananarama' 1;x
3701 vput csop res substring 'bananarama' 3;x
3702 vput csop res substring 'bananarama' 5;x
3703 vput csop res substring 'bananarama' 7;x
3704 vput csop res substring 'bananarama' 9;x
3705 vput csop res substring 'bananarama' 10;x
3706 vput csop res substring 'bananarama' 1 3;x
3707 vput csop res substring 'bananarama' 3 3;x
3708 vput csop res substring 'bananarama' 5 3;x
3709 vput csop res substring 'bananarama' 7 3;x
3710 vput csop res substring 'bananarama' 9 3;x
3711 vput csop res substring 'bananarama' 10 3;x
3712 echo ' #3'
3713 vput csop res substring 'bananarama' -1;x
3714 vput csop res substring 'bananarama' -3;x
3715 vput csop res substring 'bananarama' -5;x
3716 vput csop res substring 'bananarama' -7;x
3717 vput csop res substring 'bananarama' -9;x
3718 vput csop res substring 'bananarama' -10;x
3719 vput csop res substring 'bananarama' 1 -3;x
3720 vput csop res substring 'bananarama' 3 -3;x
3721 vput csop res substring 'bananarama' 5 -3;x
3722 vput csop res substring 'bananarama' 7 -3;x
3723 vput csop res substring 'bananarama' 9 -3;x
3724 vput csop res substring 'bananarama' 10 -3;x
3725 echo ' #4'
3726 vput csop res trim 'Cocoon Cocoon';x
3727 vput csop res trim ' Cocoon Cocoon ';x
3728 vput csop res trim-front 'Cocoon Cocoon';x
3729 vput csop res trim-front ' Cocoon Cocoon ';x
3730 vput csop res trim-end 'Cocoon Cocoon';x
3731 vput csop res trim-end ' Cocoon Cocoon ';x
3732 __EOT
3734 check 1 0 "${MBOX}" '1892119538 755'
3736 t_epilog "${@}"
3739 t_vexpr() {
3740 t_prolog "${@}"
3742 if have_feat cmd-vexpr; then :; else
3743 t_echoskip '[!CMD_VEXPR]'
3744 t_epilog "${@}"
3745 return
3748 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>>${ERR}
3749 commandalias x echo '$?/$^ERRNAME $res'
3750 echo ' #0.0'
3751 vput vexpr res = 9223372036854775807;x
3752 vput vexpr res = 9223372036854775808;x
3753 vput vexpr res = u9223372036854775808;x
3754 vput vexpr res =? 9223372036854775808;x
3755 vput vexpr res = -9223372036854775808;x
3756 vput vexpr res = -9223372036854775809;x
3757 vput vexpr res =?saturated -9223372036854775809;x
3758 vput vexpr res = U9223372036854775809;x
3759 echo ' #0.1'
3760 vput vexpr res = \
3761 0b0111111111111111111111111111111111111111111111111111111111111111;x
3762 vput vexpr res = \
3763 S0b1000000000000000000000000000000000000000000000000000000000000000;x
3764 vput vexpr res =? \
3765 S0b1000000000000000000000000000000000000000000000000000000000000000;x
3766 vput vexpr res = \
3767 U0b1000000000000000000000000000000000000000000000000000000000000000;x
3768 vput vexpr res = \
3769 0b1000000000000000000000000000000000000000000000000000000000000000;x
3770 vput vexpr res =? \
3771 0b1000000000000000000000000000000000000000000000000000000000000000;x
3772 vput vexpr res = \
3773 -0b1000000000000000000000000000000000000000000000000000000000000000;x
3774 vput vexpr res = \
3775 S0b1000000000000000000000000000000000000000000000000000000000000001;x
3776 vput vexpr res =? \
3777 S0b1000000000000000000000000000000000000000000000000000000000000001;x
3778 vput vexpr res =? \
3779 -0b1000000000000000000000000000000000000000000000000000000000000001;x
3780 vput vexpr res = \
3781 U0b1000000000000000000000000000000000000000000000000000000000000001;x
3782 echo ' #0.2'
3783 vput vexpr res = 0777777777777777777777;x
3784 vput vexpr res = S01000000000000000000000;x
3785 vput vexpr res =? S01000000000000000000000;x
3786 vput vexpr res = U01000000000000000000000;x
3787 vput vexpr res = 01000000000000000000000;x
3788 vput vexpr res =?satur 01000000000000000000000;x
3789 vput vexpr res = -01000000000000000000000;x
3790 vput vexpr res = S01000000000000000000001;x
3791 vput vexpr res =?sat S01000000000000000000001;x
3792 vput vexpr res = -01000000000000000000001;x
3793 vput vexpr res = U01000000000000000000001;x
3794 echo ' #0.3'
3795 vput vexpr res = 0x7FFFFFFFFFFFFFFF;x
3796 vput vexpr res = S0x8000000000000000;x
3797 vput vexpr res =? S0x8000000000000000;x
3798 vput vexpr res = U0x8000000000000000;x
3799 vput vexpr res = 0x8000000000000000;x
3800 vput vexpr res =? 0x8000000000000000;x
3801 vput vexpr res = -0x8000000000000000;x
3802 vput vexpr res = S0x8000000000000001;x
3803 vput vexpr res =? S0x8000000000000001;x
3804 vput vexpr res = -0x8000000000000001;x
3805 vput vexpr res = u0x8000000000000001;x
3806 vput vexpr res = 9223372036854775809;x
3807 vput vexpr res =? 9223372036854775809;x
3808 vput vexpr res = u9223372036854775809;x
3809 echo ' #1'
3810 vput vexpr res ~ 0;x
3811 vput vexpr res ~ 1;x
3812 vput vexpr res ~ -1;x
3813 echo ' #1.1'
3814 vput vexpr res - 0;x
3815 vput vexpr res - 1;x
3816 vput vexpr res - -1;x
3817 vput vexpr res - -0xAFFE;x
3818 vput vexpr res - 0xAFFE;x
3819 vput vexpr res - u0x8000000000000001;x
3820 vput vexpr res - 0x8000000000000001;x
3821 vput vexpr res - 0x8000000000000001;x
3822 vput vexpr res - 9223372036854775809;x
3823 vput vexpr res -? 9223372036854775809;x
3824 echo ' #1.2'
3825 vput vexpr res + 0;x
3826 vput vexpr res + 1;x
3827 vput vexpr res + -1;x
3828 vput vexpr res + -0xAFFE;x
3829 vput vexpr res + 0xAFFE;x
3830 vput vexpr res + u0x8000000000000001;x
3831 vput vexpr res + 0x8000000000000001;x
3832 vput vexpr res + 9223372036854775809;x
3833 vput vexpr res +? 9223372036854775809;x
3834 echo ' #2'
3835 vput vexpr res + 0 0;x
3836 vput vexpr res + 0 1;x
3837 vput vexpr res + 1 1;x
3838 echo ' #3'
3839 vput vexpr res + 9223372036854775807 0;x
3840 vput vexpr res + 9223372036854775807 1;x
3841 vput vexpr res +? 9223372036854775807 1;x
3842 vput vexpr res + 0 9223372036854775807;x
3843 vput vexpr res + 1 9223372036854775807;x
3844 vput vexpr res +? 1 9223372036854775807;x
3845 echo ' #4'
3846 vput vexpr res + -9223372036854775808 0;x
3847 vput vexpr res + -9223372036854775808 -1;x
3848 vput vexpr res +? -9223372036854775808 -1;x
3849 vput vexpr res + 0 -9223372036854775808;x
3850 vput vexpr res + -1 -9223372036854775808;x
3851 vput vexpr res +? -1 -9223372036854775808;x
3852 echo ' #5'
3853 vput vexpr res - 0 0;x
3854 vput vexpr res - 0 1;x
3855 vput vexpr res - 1 1;x
3856 echo ' #6'
3857 vput vexpr res - 9223372036854775807 0;x
3858 vput vexpr res - 9223372036854775807 -1;x
3859 vput vexpr res -? 9223372036854775807 -1;x
3860 vput vexpr res - 0 9223372036854775807;x
3861 vput vexpr res - -1 9223372036854775807;x
3862 vput vexpr res - -2 9223372036854775807;x
3863 vput vexpr res -? -2 9223372036854775807;x
3864 echo ' #7'
3865 vput vexpr res - -9223372036854775808 +0;x
3866 vput vexpr res - -9223372036854775808 +1;x
3867 vput vexpr res -? -9223372036854775808 +1;x
3868 vput vexpr res - 0 -9223372036854775808;x
3869 vput vexpr res - +1 -9223372036854775808;x
3870 vput vexpr res -? +1 -9223372036854775808;x
3871 echo ' #8'
3872 vput vexpr res + -13 -2;x
3873 vput vexpr res - 0 0;x
3874 vput vexpr res - 0 1;x
3875 vput vexpr res - 1 1;x
3876 vput vexpr res - -13 -2;x
3877 echo ' #9'
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 ' #10'
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 ' #11'
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 ' #12'
3893 vput vexpr res pbase 10 u0x8000000000000001;x
3894 vput vexpr res pbase 16 0x8000000000000001;x
3895 vput vexpr res pbase 16 s0x8000000000000001;x
3896 vput vexpr res pbase 16 u0x8000000000000001;x
3897 vput vexpr res pbase 36 0x8000000000000001;x
3898 vput vexpr res pbase 36 u0x8000000000000001;x
3899 __EOT
3901 check numeric 0 "${MBOX}" '163128733 2519'
3903 if have_feat regex; then
3904 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
3905 commandalias x echo '$?/$^ERRNAME :$res:'
3906 echo ' #-2'
3907 vput vexpr res regex you y;x
3908 vput vexpr res regex you o;x
3909 vput vexpr res regex you u;x
3910 vput vexpr res regex you yo;x
3911 vput vexpr res regex you ou;x
3912 vput vexpr res regex you you;x
3913 echo ' #-1'
3914 vput vexpr res regex you Y;x
3915 vput vexpr res regex? you Y;x
3916 vput vexpr res regex? you O;x
3917 vput vexpr res regex? you U;x
3918 vput vexpr res regex? you yO;x
3919 vput vexpr res regex? you oU;x
3920 vput vexpr res regex? you YoU;x
3921 echo ' #0'
3922 vput vexpr res regex 'bananarama' 'nana';x
3923 vput vexpr res regex 'bananarama' 'bana';x
3924 vput vexpr res regex 'bananarama' 'Bana';x
3925 vput vexpr res regex 'bananarama' 'rama';x
3926 echo ' #1'
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 ' #2'
3932 vput vexpr res regex 'bananarama' '(.*)nana(.*)' '\${1}a\${0}u{\$2}';x
3933 vput vexpr res regex 'bananarama' '(.*)bana(.*)' '\${1}a\${0}u\$2';x
3934 vput vexpr res regex 'bananarama' 'Bana(.+)' '\$1\$0';x
3935 vput vexpr res regex 'bananarama' '(.+)rama' '\$1\$0';x
3936 echo ' #3'
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 ' #4'
3942 vput vexpr res regex 'banana' '(club )?(.*)(nana)(.*)' \
3943 '\$1\${2}\$4\${3}rama';x
3944 vput vexpr res regex 'Banana' '(club )?(.*)(nana)(.*)' \
3945 '\$1\$2\${2}\$2\$4\${3}rama';x
3946 vput vexpr res regex 'Club banana' '(club )?(.*)(nana)(.*)' \
3947 '\$1\${2}\$4\${3}rama';x
3948 echo ' #5'
3949 __EOT
3951 check regex 0 "${MBOX}" '2831099111 542'
3952 else
3953 t_echoskip 'regex:[!REGEX]'
3956 t_epilog "${@}"
3959 t_call_ret() {
3960 t_prolog "${@}"
3962 if have_feat cmd-vexpr; then :; else
3963 t_echoskip '[!CMD_VEXPR]'
3964 t_epilog "${@}"
3965 return
3968 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Snomemdebug > "${MBOX}" 2>&1
3969 define w1 {
3970 echon ">$1 "
3971 vput vexpr i + $1 1
3972 if [ $i -le 42 ]
3973 vput vexpr j '&' $i 7
3974 if [ $j -eq 7 ]
3975 echo .
3977 call w1 $i
3978 wysh set i=$? k=$!
3979 vput vexpr j '&' $i 7
3980 echon "<$1/$i/$k "
3981 if [ $j -eq 7 ]
3982 echo .
3984 else
3985 echo ! The end for $1
3987 return $1
3989 # Transport $?/$! up the call chain
3990 define w2 {
3991 echon ">$1 "
3992 vput vexpr i + $1 1
3993 if [ $1 -lt 42 ]
3994 call w2 $i
3995 wysh set i=$? j=$! k=$^ERRNAME
3996 echon "<$1/$i/$k "
3997 return $i $j
3998 else
3999 echo ! The end for $1
4000 return $i $^ERR-BUSY
4002 echoerr au
4004 # Up and down it goes
4005 define w3 {
4006 echon ">$1/$2 "
4007 vput vexpr i + $1 1
4008 if [ $1 -lt 42 ]
4009 call w3 $i $2
4010 wysh set i=$? j=$!
4011 vput vexpr k - $1 $2
4012 if [ $k -eq 21 ]
4013 vput vexpr i + $1 1
4014 vput vexpr j + $2 1
4015 echo "# <$i/$j> .. "
4016 call w3 $i $j
4017 wysh set i=$? j=$!
4019 eval echon "<\$1=\$i/\$^ERRNAME-$j "
4020 return $i $j
4021 else
4022 echo ! The end for $1=$i/$2
4023 if [ "$2" != "" ]
4024 return $i $^ERR-DOM
4025 else
4026 return $i $^ERR-BUSY
4029 echoerr au
4032 call w1 0; echo ?=$? !=$!; echo -----;
4033 call w2 0; echo ?=$? !=$^ERRNAME; echo -----;
4034 call w3 0 1; echo ?=$? !=$^ERRNAME; echo -----;
4035 __EOT
4037 check 1 0 "${MBOX}" '1572045517 5922'
4039 t_epilog "${@}"
4042 t_xcall() {
4043 t_prolog "${@}"
4045 if have_feat cmd-vexpr; then :; else
4046 t_echoskip '[!CMD_VEXPR]'
4047 t_epilog "${@}"
4048 return
4051 ${cat} <<- '__EOT' | \
4052 ${MAILX} ${ARGS} -Snomemdebug \
4053 -Smax=${LOOPS_MAX} \
4054 > "${MBOX}" 2>&1
4055 define work {
4056 echon "$1 "
4057 vput vexpr i + $1 1
4058 if [ $i -le "$max" ]
4059 vput vexpr j '&' $i 7
4060 if [ $j -eq 7 ]
4061 echo .
4063 \xcall work $i $2
4065 echo ! The end for $1/$2
4066 if [ "$2" != "" ]
4067 return $i $^ERR-BUSY
4070 define xwork {
4071 \xcall work 0 $2
4073 call work 0
4074 echo ?=$? !=$!
4075 call xwork
4076 echo ?=$? !=$!
4077 xcall xwork
4078 echo ?=$? !=$^ERRNAME
4080 call work 0 yes
4081 echo ?=$? !=$^ERRNAME
4082 call xwork 0 yes
4083 echo ?=$? !=$^ERRNAME
4084 __EOT
4086 i=${?}
4087 if [ ${LOOPS_MAX} -eq ${LOOPS_BIG} ]; then
4088 check_ex0 1-${LOOPS_BIG} ${i}
4089 check 1-${LOOPS_BIG} - "${MBOX}" '1069764187 47161'
4090 else
4091 check_ex0 1-${LOOPS_SMALL} ${i}
4092 check 1-${LOOPS_SMALL} - "${MBOX}" '859201011 3894'
4097 if have_feat uistrings; then
4098 ${cat} <<- '__EOT' > "${BODY}"
4099 define __w {
4100 echon "$1 "
4101 vput vexpr i + $1 1
4102 if [ $i -le 111 ]
4103 vput vexpr j '&' $i 7
4104 if [ $j -eq 7 ]
4105 echo .
4107 \xcall __w $i $2
4109 echo ! The end for $1
4110 if [ $2 -eq 0 ]
4111 nonexistingcommand
4112 echo would be err with errexit
4113 return
4115 echo calling exit
4116 exit
4118 define work {
4119 echo eins
4120 call __w 0 0
4121 echo zwei, ?=$? !=$!
4122 localopts yes; set errexit
4123 ignerr call __w 0 0
4124 echo drei, ?=$? !=$^ERRNAME
4125 call __w 0 $1
4126 echo vier, ?=$? !=$^ERRNAME, this is an error
4128 ignerr call work 0
4129 echo outer 1, ?=$? !=$^ERRNAME
4130 xxxign call work 0
4131 echo outer 2, ?=$? !=$^ERRNAME, could be error if xxxign non-empty
4132 call work 1
4133 echo outer 3, ?=$? !=$^ERRNAME
4134 echo this is definitely an error
4135 __EOT
4137 < "${BODY}" ${MAILX} ${ARGS} -X'commandalias xxxign ignerr' \
4138 -Snomemdebug > "${MBOX}" 2>&1
4139 check 2 0 "${MBOX}" '4036613316 4184'
4141 < "${BODY}" ${MAILX} ${ARGS} -X'commandalias xxxign " "' \
4142 -Snomemdebug > "${MBOX}" 2>&1
4143 check 3 1 "${MBOX}" '3179757785 2787'
4144 else
4145 t_echoskip '2-3:[!UISTRINGS]'
4148 t_epilog "${@}"
4151 t_vpospar() {
4152 t_prolog "${@}"
4154 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
4155 vpospar set hey, "'you ", world!
4156 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4157 vput vpospar x quote; echo x<$x>
4158 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4159 vput vpospar y quote;echo y<$y>
4160 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4161 eval vpospar set ${y};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4162 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4164 define infun2 {
4165 echo infun2:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
4166 vput vpospar z quote;echo infun2:z<$z>
4169 define infun {
4170 echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
4171 vput vpospar y quote;echo infun:y<$y>
4172 eval vpospar set ${x};echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
4173 vpospar clear;echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
4174 eval call infun2 $x
4175 echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
4176 eval vpospar set ${y};echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
4179 call infun This "in a" fun
4180 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4181 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4182 __EOT
4183 check 1 0 "${MBOX}" '155175639 866'
4186 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
4187 set ifs=\'
4188 echo ifs<$ifs> ifs-ws<$ifs-ws>
4189 vpospar set hey, "'you ", world!
4190 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4191 vput vpospar x quote; echo x<$x>
4192 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4193 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4195 set ifs=,
4196 echo ifs<$ifs> ifs-ws<$ifs-ws>
4197 vpospar set hey, "'you ", world!
4198 unset ifs;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4199 set ifs=,
4200 vput vpospar x quote; echo x<$x>
4201 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4202 eval vpospar set ${x};\
4203 unset ifs;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4205 wysh set ifs=$',\t'
4206 echo ifs<$ifs> ifs-ws<$ifs-ws>
4207 vpospar set hey, "'you ", world!
4208 unset ifs; echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4209 wysh set ifs=$',\t'
4210 vput vpospar x quote; echo x<$x>
4211 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4212 eval vpospar set ${x};\
4213 unset ifs;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4214 __EOT
4215 check ifs 0 "${MBOX}" '2015927702 706'
4217 t_epilog "${@}"
4220 t_atxplode() {
4221 t_prolog "${@}"
4223 ${cat} > ./.t.sh <<- '___'; ${cat} > ./.t.rc <<- '___'
4224 x() { echo $#; }
4225 xxx() {
4226 printf " (1/$#: <$1>)"
4227 shift
4228 if [ $# -gt 0 ]; then
4229 xxx "$@"
4230 else
4231 echo
4234 yyy() {
4235 eval "$@ ' ball"
4237 set --
4238 x "$@"
4239 x "$@"''
4240 x " $@"
4241 x "$@ "
4242 printf yyy;yyy 'xxx' "b\$'\t'u ' "
4243 printf xxx;xxx arg ,b u.
4244 printf xxx;xxx arg , .
4245 printf xxx;xxx arg ,ball.
4247 define x {
4248 echo $#
4250 define xxx {
4251 echon " (1/$#: <$1>)"
4252 shift
4253 if [ $# -gt 0 ]
4254 \xcall xxx "$@"
4255 endif
4256 echo
4258 define yyy {
4259 eval "$@ ' ball"
4261 vpospar set
4262 call x "$@"
4263 call x "$@"''
4264 call x " $@"
4265 call x "$@ "
4266 echon yyy;call yyy '\call xxx' "b\$'\t'u ' "
4267 echon xxx;call xxx arg ,b u.
4268 echon xxx;call xxx arg , .
4269 echon xxx;call xxx arg ,ball.
4272 ${MAILX} ${ARGS} -X'source ./.t.rc' -Xx > "${MBOX}" 2>&1
4273 check 1 0 "${MBOX}" '41566293 164'
4275 #${SHELL} ./.t.sh > ./.tshout 2>&1
4276 #check disproof-1 0 ./.tshout '41566293 164'
4278 t_epilog "${@}"
4281 t_read() {
4282 t_prolog "${@}"
4284 ${cat} <<- '__EOT' > .tin
4285 hey1, "'you ", world!
4286 hey2, "'you ", bugs bunny!
4287 hey3, "'you ",
4288 hey4, "'you "
4289 __EOT
4291 ${cat} <<- '__EOT' |\
4292 ${MAILX} ${ARGS} -X'readctl create ./.tin' > "${MBOX}" 2>&1
4293 commandalias x echo '$?/$^ERRNAME / <$a><$b><$c>'
4294 read a b c;x
4295 read a b c;x
4296 read a b c;x
4297 read a b c;x
4298 unset a b c;read a b c;x
4299 readctl remove ./.tin;echo readctl remove:$?/$^ERRNAME
4300 __EOT
4301 check 1 0 "${MBOX}" '1527910147 173'
4303 ${cat} <<- '__EOT' > .tin2
4304 hey2.0,:"'you ",:world!:mars.:
4305 hey2.1,:"'you ",:world!
4306 hey2.2,:"'you ",:bugs bunny!
4307 hey2.3,:"'you ",:
4308 hey2.4,:"'you ":
4310 __EOT
4312 ${cat} <<- '__EOT' |\
4313 6< .tin2 ${MAILX} ${ARGS} -X 'readctl create 6' > "${MBOX}" 2>&1
4314 commandalias x echo '$?/$^ERRNAME / <$a><$b><$c>'
4315 set ifs=:
4316 read a b c;x
4317 read a b c;x
4318 read a b c;x
4319 read a b c;x
4320 read a b c;x
4321 read a b c;x
4322 unset a b c;read a b c;x
4323 read a b c;x
4324 readctl remove 6;echo readctl remove:$?/$^ERRNAME
4325 __EOT
4326 check ifs 0 "${MBOX}" '890153490 298'
4328 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
4329 commandalias x echo '$?/$^ERRNAME / <$d>'
4330 readctl create .tin
4331 readall d;x
4332 wysh set d;readall d;x
4333 readctl create .tin2
4334 readall d;x
4335 wysh set d;readall d;x
4336 readctl remove .tin;echo $?/$^ERRNAME;\
4337 readctl remove .tin2;echo $?/$^ERRNAME
4338 echo '### now with empty lines'
4339 ! printf 'one line\n\ntwo line\n\n' > ./.temptynl
4340 readctl create .temptynl;echo $?/$^ERRNAME
4341 readall d;x
4342 readctl remove .temptynl;echo $?/$^ERRNAME
4343 __EOT
4344 check readall 0 "${MBOX}" '4113506527 405'
4346 t_epilog "${@}"
4349 t_readsh() { # TODO not enough
4350 t_prolog "${@}"
4352 ${cat} <<- '__EOT' > .tin
4353 from@exam.ple ' diet spliced <from@exam.ple> ' 'a'
4354 from@exam.ple ' diet spliced <from@exam.ple> ' 'a'
4355 from@exam.ple ' diet spliced <from@exam.ple> ''a'
4356 from@exam.ple' diet spliced <from@exam.ple> ''a'
4357 __EOT
4359 ${cat} <<- '__EOT' |\
4360 ${MAILX} ${ARGS} -X'readctl create ./.tin' > "${MBOX}" 2>&1
4361 commandalias x echo '$?/$^ERRNAME / <$a><$b><$c>'
4362 readsh a b c;x
4363 readsh a b c;x
4364 readsh a b c;x
4365 readsh a b c;x
4366 unset a b c;read a b c;x
4367 readctl remove ./.tin;echo readctl remove:$?/$^ERRNAME
4368 __EOT
4369 check 1 0 "${MBOX}" '2955084684 291'
4371 t_epilog "${@}"
4374 t_headerpick() {
4375 t_prolog "${@}"
4377 t__x1_msg > ./.tmbox
4380 </dev/null ${MAILX} ${ARGS} -Rf -Y '# Do not care much on error UISTRINGS
4381 \echo --- 1
4382 \headerpick
4383 \echo --- $?/$^ERRNAME, 2
4384 \type
4385 \echo --- $?/$^ERRNAME, 3
4386 \if "$features" !% +uistrings,
4387 \echoerr reproducible_build: Invalid field name cannot be ignored: ba:l
4388 \endif
4389 \headerpick type ignore \
4390 from_ mail-followup-to in-reply-to DATE MESSAGE-ID STATUS ba:l
4391 \echo --- $?/$^ERRNAME, 4
4392 \if "$features" !% +uistrings,
4393 \echo "#headerpick type retain currently covers no fields"
4394 \endif
4395 \headerpick
4396 \echo --- $?/$^ERRNAME, 5
4397 \type
4398 \echo --- $?/$^ERRNAME, 6
4399 \unheaderpick type ignore from_ DATE STATUS
4400 \echo --- $?/$^ERRNAME, 7
4401 \if "$features" !% +uistrings,
4402 \echo "#headerpick type retain currently covers no fields"
4403 \endif
4404 \headerpick
4405 \echo --- $?/$^ERRNAME, 8
4406 \type
4407 \echo --- $?/$^ERRNAME, 9
4408 \if "$features" =% +uistrings,
4409 \unheaderpick type ignore from_ ba:l
4410 \wysh set x=$? y=$^ERRNAME
4411 \else
4412 \echoerr reproducible_build: Field not ignored: from_
4413 \echoerr reproducible_build: Field not ignored: ba:l
4414 \set x=1 y=INVAL
4415 \endif
4416 \echo --- $x/$y, 10
4417 \unheaderpick type ignore *
4418 \echo --- $?/$^ERRNAME, 11
4419 \if "$features" !% +uistrings,
4420 \echo "#headerpick type retain currently covers no fields"
4421 \echo "#headerpick type ignore currently covers no fields"
4422 \endif
4423 \headerpick
4424 \echo --- $?/$^ERRNAME, 12
4425 \type
4426 \echo --- $?/$^ERRNAME, 13 ---
4427 # ' ./.tmbox >./.tall 2>&1
4428 check 1 0 ./.tall '2481904228 2273'
4431 if have_feat uistrings; then
4432 have_feat regex && i='3515512395 2378' || i='4201290332 2378'
4433 </dev/null ${MAILX} ${ARGS} -Y '#
4434 \headerpick type retain \
4435 bcc cc date from sender subject to \
4436 message-id mail-followup-to reply-to user-agent
4437 \echo --- $?/$^ERRNAME, 1
4438 \headerpick forward retain \
4439 cc date from message-id list-id sender subject to \
4440 mail-followup-to reply-to
4441 \echo --- $?/$^ERRNAME, 2
4442 \headerpick save ignore ^Original-.*$ ^X-.*$ ^DKIM.*$
4443 \echo --- $?/$^ERRNAME, 3
4444 \headerpick top retain To Cc
4445 \echo --- $?/$^ERRNAME, 4 ---
4446 \headerpick
4447 \echo --- $?/$^ERRNAME, 5
4448 \headerpick type
4449 \echo --- $?/$^ERRNAME, 6
4450 \headerpick forward
4451 \echo --- $?/$^ERRNAME, 7
4452 \headerpick save
4453 \echo --- $?/$^ERRNAME, 8
4454 \headerpick top
4455 \echo --- $?/$^ERRNAME, 9 ---
4456 \unheaderpick type retain message-id mail-followup-to reply-to user-agent
4457 \echo --- $?/$^ERRNAME, 10
4458 \unheaderpick save ignore ^X-.*$ ^DKIM.*$
4459 \echo --- $?/$^ERRNAME, 11
4460 \unheaderpick forward retain *
4461 \echo --- $?/$^ERRNAME, 12 ---
4462 \headerpick
4463 \echo --- $?/$^ERRNAME, 13
4464 \headerpick type
4465 \echo --- $?/$^ERRNAME, 14
4466 \headerpick save
4467 \echo --- $?/$^ERRNAME, 15 --
4468 \unheaderpick type retain *
4469 \echo --- $?/$^ERRNAME, 16
4470 \unheaderpick forward retain *
4471 \echo --- $?/$^ERRNAME, 17
4472 \unheaderpick save ignore *
4473 \echo --- $?/$^ERRNAME, 18
4474 \unheaderpick top retain *
4475 \echo --- $?/$^ERRNAME, 19 --
4476 \headerpick
4477 \echo --- $?/$^ERRNAME, 20
4478 # ' >./.tall 2>&1
4479 check 2 0 ./.tall "${i}"
4480 else
4481 t_echoskip '2:[!UISTRINGS]'
4484 t_epilog "${@}"
4486 # }}}
4488 # Send/RFC absolute basics {{{
4489 t_can_send_rfc() { # {{{
4490 t_prolog "${@}"
4492 </dev/null ${MAILX} ${ARGS} -Smta=test://"$MBOX" -s Sub.1 \
4493 receiver@number.1 \
4494 > ./.terr 2>&1
4495 check 1 0 "${MBOX}" '550126528 126'
4496 check 1-err - .terr '4294967295 0'
4498 </dev/null ${MAILX} ${ARGS} -Smta=test://"$MBOX" -s Sub.2 \
4499 -b bcc@no.1 -b bcc@no.2 -b bcc@no.3 \
4500 -c cc@no.1 -c cc@no.2 -c cc@no.3 \
4501 to@no.1 to@no.2 to@no.3 \
4502 > ./.terr 2>&1
4503 check 2 0 "${MBOX}" '3259888945 324'
4504 check 2-err - .terr '4294967295 0'
4506 </dev/null ${MAILX} ${ARGS} -Smta=test://"$MBOX" -s Sub.2no \
4507 -b bcc@no.1\ \ bcc@no.2 -b bcc@no.3 \
4508 -c cc@no.1,cc@no.2 -c cc@no.3 \
4509 to@no.1,to@no.2 to@no.3 \
4510 > ./.terr 2>&1
4511 check 2no 4 "${MBOX}" '3350946897 468'
4512 if have_feat uistrings; then
4513 check 2no-err - .terr '3397557940 190'
4514 else
4515 check 2no-err - .terr '4294967295 0'
4518 # XXX NOTE we cannot test "cc@no1 <cc@no.2>" because our stupid parser
4519 # XXX would not treat that as a list but look for "," as a separator
4520 </dev/null ${MAILX} ${ARGS} -Smta=test://"$MBOX" -Sfullnames -s Sub.3 \
4521 -T 'bcc?single: bcc@no.1, <bcc@no.2>' -T bcc:\ bcc@no.3 \
4522 -T cc?si\ \ :\ \ 'cc@no.1, <cc@no.2>' -T cc:\ cc@no.3 \
4523 -T to?:\ to@no.1,'<to@no.2>' -T to:\ to@no.3 \
4524 > ./.terr 2>&1
4525 check 3 0 "${MBOX}" '1453534480 678'
4526 check 3-err - .terr '4294967295 0'
4528 </dev/null ${MAILX} ${ARGS} -Smta=test://"$MBOX" -Sfullnames -s Sub.4 \
4529 -T 'bcc: bcc@no.1, <bcc@no.2>' -T bcc:\ bcc@no.3 \
4530 -T cc:\ 'cc@no.1, <cc@no.2>' -T cc\ \ :\ \ cc@no.3 \
4531 -T to\ :to@no.1,'<to@no.2>' -T to:\ to@no.3 \
4532 > ./.terr 2>&1
4533 check 4 0 "${MBOX}" '535767201 882'
4534 check 4-err - .terr '4294967295 0'
4536 # Two test with a file-based MTA
4537 "${cat}" <<-_EOT > .tmta.sh
4538 #!${SHELL} -
4539 (echo 'From reproducible_build Wed Oct 2 01:50:07 1996' &&
4540 "${cat}" && echo pardauz && echo) > "${MBOX}"
4541 _EOT
4542 ${chmod} 0755 .tmta.sh
4544 </dev/null ${MAILX} ${ARGS} -Smta=./.tmta.sh -s Sub.mta-1 \
4545 receiver@number.1 > ./.terr 2>&1
4546 check 5 0 "${MBOX}" '2384401657 138'
4547 check 5-err - .terr '4294967295 0'
4549 </dev/null ${MAILX} ${ARGS} -Smta=file://./.tmta.sh -s Sub.mta-2 \
4550 receiver@number.1 > ./.terr 2>&1
4551 check 6 0 "${MBOX}" '3006460737 138'
4552 check 6-err - .terr '4294967295 0'
4554 # Command
4555 </dev/null ${MAILX} ${ARGS} -Smta=test \
4556 -Y '#
4557 mail hey@exam.ple
4558 ~s Subject 1
4559 Body1
4561 echo $?/$^ERRNAME
4563 # ' > ./.tall 2>&1
4564 check 7 0 ./.tall '951018449 138'
4566 ## *record*, *outfolder*, with and without *mta-bcc-ok*
4567 ${mkdir} .tfolder
4568 xfolder=`${pwd}`/.tfolder
4570 "${cat}" <<-_EOT > .tmta.sh
4571 #!${SHELL} -
4572 (echo 'From reproducible_build Wed Oct 2 01:50:07 1996' &&
4573 "${cat}" && echo 'ARGS: '"\${@}" && echo) > "${MBOX}"
4574 _EOT
4575 ${chmod} 0755 .tmta.sh
4577 t_it() {
4578 </dev/null ${MAILX} ${ARGS} -Smta=./.tmta.sh -Sfolder="${xfolder}" \
4579 "${@}" \
4580 -s Sub.mta-1 \
4581 -b bcc@no.1 -b bcc@no.2 -b bcc@no.3 \
4582 -c cc@no.1 -c cc@no.2 -c cc@no.3 \
4583 to@no.1 to@no.2 to@no.3 \
4584 receiver@number.1 > ./.terr 2>&1
4585 return ${?}
4588 t_it -Snomta-bcc-ok
4589 check 8 0 "${MBOX}" '1365032629 292'
4590 check 8-1 - .terr '4294967295 0'
4592 t_it -Snomta-bcc-ok -Srecord=.trec9
4593 check 9 0 "${MBOX}" '1365032629 292'
4594 check 9-1 - .terr '4294967295 0'
4595 check 9-2 - ./.trec9 '160206230 221'
4597 t_it -Srecord=.trec10
4598 check 10 0 "${MBOX}" '3085765596 326'
4599 check 10-1 - .terr '4294967295 0'
4600 check 10-2 - ./.trec10 '160206230 221'
4602 t_it -Snomta-bcc-ok -Srecord=.trec11 -Soutfolder
4603 check 11 0 "${MBOX}" '1365032629 292'
4604 check 11-1 - .terr '4294967295 0'
4605 check 11-2 - ./.tfolder/.trec11 '160206230 221'
4606 # That is appends to an MBOX
4607 t_it -Srecord=.trec11 -Soutfolder
4608 check 12 0 "${MBOX}" '3085765596 326'
4609 check 12-1 - .terr '4294967295 0'
4610 check 12-2 - ./.tfolder/.trec11 '1618754846 442'
4612 ### More RFC cases
4614 ## From: and Sender:
4615 </dev/null ${MAILX} ${ARGS} -s ubject \
4616 -S from=a@b.org,b@b.org,c@c.org -S sender=a@b.org \
4617 to@exam.ple > "${MBOX}" 2>&1
4618 check 13 0 "${MBOX}" '143390417 169'
4620 # ..if From: is single mailbox and Sender: is same, no Sender:
4621 </dev/null ${MAILX} ${ARGS} -s ubject \
4622 -S from=a@b.org -S sender=a@b.org \
4623 to@exam.ple > "${MBOX}" 2>&1
4624 check 14 0 "${MBOX}" '1604962737 135'
4626 t_epilog "${@}"
4627 } # }}}
4629 t_reply() { # {{{
4630 # Alternates and ML related address massage etc. somewhere else
4631 t_prolog "${@}"
4632 XARGS=${ARGS} # TODO v15-compat
4633 ARGS="${ARGS} -Sv15-compat=y"
4635 t__gen_msg subject reply from 1 to 2 cc 2 > "${MBOX}"
4637 ## Base (does not test "recipient record")
4638 t_it() {
4639 </dev/null ${MAILX} ${ARGS} -Rf \
4640 -Y "${2}${1}"'
4643 echo 1:$?/$^ERRNAME
4644 set fullnames escape=!; '${1}'
4645 r2 fullnames
4647 echo 2:$?/$^ERRNAME
4648 set recipients-in-cc nofullnames; '${1}'
4649 r3 recipients-in-cc
4651 echo 3:$?/$^ERRNAME
4652 unset recipients-in-cc; '${1}'
4655 echo 4:$?/$^ERRNAME
4656 #' \
4657 "${MBOX}" > ./.tall 2>&1
4658 return ${?}
4661 t_it reply
4662 check 1 0 ./.tall '4164251531 851'
4663 t_it Reply
4664 check 2 0 ./.tall '3034955332 591'
4665 t_it reply 'set flipr;'
4666 check 3 0 ./.tall '3034955332 591'
4667 t_it Reply 'set flipr;'
4668 check 4 0 ./.tall '4164251531 851'
4670 ## Dig the errors
4671 t__gen_msg subject reply-no-addr > ./.tnoaddr
4673 # MBOX will deduce addressee from From_ line..
4674 </dev/null ${MAILX} ${ARGS} -R -Sescape=! \
4675 -Y '#
4676 File ./.tnoaddr; reply # Takes addressee from From_ line :(
4677 body1
4679 echo 1:$?/$^ERRNAME
4680 File '"${MBOX}"'; set ea=$expandaddr expandaddr=-all; reply
4681 body2
4683 echo 2:$?/$^ERRNAME; set expandaddr=$ea; reply 10 # BADMSG
4684 echo 3:$?/$^ERRNAME; reply # cannot test IO,NOTSUP,INVAL
4685 body3
4687 echo 4:$?/$^ERRNAME
4688 #' \
4689 > ./.tall 2>./.terr
4690 check 5 0 ./.tall '3088217220 382'
4691 if have_feat uistrings; then
4692 check 6 - ./.terr '2514745519 544'
4693 else
4694 t_echoskip '6:[!UISTRINGS]'
4697 # ..but Maildir will not
4698 if have_feat maildir; then
4699 ${mkdir} -p .tdir .tdir/tmp .tdir/cur .tdir/new
4700 ${sed} 1d < ./.tnoaddr > .tdir/new/sillyname
4702 </dev/null ${MAILX} ${ARGS} -R -Sescape=! \
4703 -Y '#
4704 File ./.tdir; reply
4705 body1
4707 echo 1:$?/$^ERRNAME
4708 File '"${MBOX}"'; set ea=$expandaddr expandaddr=-all; reply
4709 body2
4711 echo 2:$?/$^ERRNAME; set expandaddr=$ea; reply 10 # BADMSG
4712 echo 3:$?/$^ERRNAME;reply # cannot test IO,NOTSUP,INVAL
4713 body3
4715 echo 4:$?/$^ERRNAME
4716 #' \
4717 > ./.tall 2>./.terr
4718 check 7 0 ./.tall '3631170341 244'
4719 if have_feat uistrings; then
4720 check 8 - ./.terr '1074346767 629'
4721 else
4722 t_echoskip '8:[!UISTRINGS]'
4726 ## Ensure action on multiple messages
4727 t__gen_msg subject reply2 from from2@exam.ple body body2 >> "${MBOX}"
4729 t_it() {
4730 </dev/null ${MAILX} ${ARGS} -Rf -Sescape=! \
4731 -Y '#
4732 '${1}' 1 2
4733 repbody1
4735 repbody2
4737 echo 1:$?/$^ERRNAME; '${2}' 1 2
4738 Repbody1
4740 echo 2:$?/$^ERRNAME
4741 #' \
4742 "${MBOX}" > ./.tall 2>&1
4743 check ${3} 0 ./.tall '283309820 502'
4744 if [ ${#} -eq 4 ]; then
4745 echo * > ./.tlst
4746 check ${3}-1 - ./.tlst '1649520021 12'
4747 check ${3}-2 - ./from1 '1501109193 347'
4748 check ${3}-3 - ./from2 '2154231432 137'
4752 t_it reply Reply 9
4753 t_it respond Respond 10
4754 t_it followup Followup 11 yes
4755 ${rm} -f from1 from2
4757 ## *record*, *outfolder* (reuses $MBOX)
4758 ${mkdir} .tfolder
4760 t_it() {
4761 </dev/null ${MAILX} ${ARGS} -Rf -Sescape=! -Sfolder=`${pwd}`/.tfolder \
4762 -Y '#
4763 '${1}' 1 2
4764 repbody1
4766 repbody2
4768 echo 1:$?/$^ERRNAME; '${2}' 1 2
4769 Repbody3
4771 echo 2:$?/$^ERRNAME; set record=.trec'${4}'; '${1}' 1 2
4772 repbody4
4774 repbody5
4776 echo 3:$?/$^ERRNAME; '${2}' 1 2
4777 Repbody6
4779 echo 4:$?/$^ERRNAME; set outfolder norecord
4780 '${1}' 1 2
4781 repbody1
4783 repbody2
4785 echo 1:$?/$^ERRNAME; '${2}' 1 2
4786 Repbody3
4788 echo 2:$?/$^ERRNAME; set record=.trec'${4}'; '${1}' 1 2
4789 repbody4
4791 repbody5
4793 echo 3:$?/$^ERRNAME; '${2}' 1 2
4794 Repbody6
4796 echo 4:$?/$^ERRNAME
4797 #' \
4798 "${MBOX}" > ./.tall 2>&1
4799 check ${3} 0 ./.tall '3410330303 2008'
4800 if [ ${#} -ne 5 ]; then
4801 check ${4} - ./.trec${4} '3044885336 484'
4802 check ${4}-1 - ./.tfolder/.trec${4} '3044885336 484'
4803 else
4804 [ -f ./.trec${4} ]; check_exn0 ${4}
4805 echo * > ./.tlst
4806 check ${4}-1 - ./.tlst '1649520021 12'
4807 check ${4}-2 - ./from1 '2668975631 694'
4808 check ${4}-3 - ./from2 '225462887 274'
4809 [ -f ./.tfolder/.trec${4} ]; check_exn0 ${4}-4
4810 ( cd .tfolder && echo * > ./.tlst )
4811 check ${4}-5 - ./.tfolder/.tlst '1649520021 12'
4812 check ${4}-6 - ./.tfolder/from1 '2668975631 694'
4813 check ${4}-7 - ./.tfolder/from2 '225462887 274'
4817 t_it reply Reply 12 13
4818 t_it respond Respond 14 15
4819 t_it followup Followup 16 17 yes
4820 #${rm} -f from1 from2
4822 ## Quoting (if not cmd_escapes related)
4823 ${rm} -f "${MBOX}"
4824 t__x2_msg > ./.tmbox
4826 printf '#
4827 set indentprefix=" |" quote
4828 reply
4831 set quote=noheading quote-inject-head
4832 reply
4835 headerpick type retain cc date from message-id reply-to subject to
4836 set quote=headers
4837 reply
4840 set quote=allheaders
4841 reply
4844 set quote-inject-head=%% quote-inject-tail=%% quote=headers
4845 reply
4848 set quote \\
4849 quote-inject-head='"\$'"'\\
4850 (%%%%a=%%a %%%%d=%%d %%%%f=%%f %%%%i=%%i %%%%n=%%n %%%%r=%%r)\\
4851 \\n'"'"' \\
4852 quote-inject-tail='"\$'"'\\
4853 (%%%%a=%%a %%%%d=%%d %%%%f=%%f %%%%i=%%i %%%%n=%%n %%%%r=%%r)\\
4854 \\n'"'"'
4855 reply
4858 set showname datefield=%%y nodatefield-markout-older indentprefix=\\ :
4859 reply
4862 ' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" -Rf \
4863 -Sescape=! -Sindentprefix=' >' \
4864 ./.tmbox >./.tall 2>&1
4865 check_ex0 18-estat
4866 ${cat} ./.tall >> "${MBOX}"
4867 check 18 - "${MBOX}" '385267528 3926'
4869 # quote-as-attachment, fullnames
4870 </dev/null ${MAILX} ${ARGS} -Rf \
4871 -Sescape=! \
4872 -S quote-as-attachment \
4873 -Y reply -Y yb1 -Y !. \
4874 -Y 'unset quote-as-attachment' \
4875 -Y 'reply;yb2' -Y !. \
4876 -Y 'set quote-as-attachment fullnames' \
4877 -Y ';reply;yb3' -Y !. \
4878 ./.tmbox >./.tall 2>&1
4879 check 19 0 ./.tall '2774517283 2571'
4881 # Moreover, quoting of several parts with all*
4882 t__gen_mimemsg from 'ex1@am.ple' subject for-repl > ./.tmbox
4883 check 20 0 ./.tmbox '1874764424 668'
4885 have_feat filter-html-tagsoup && ck='946925637 1105' || ck='3587432511 1165'
4886 </dev/null ${MAILX} ${ARGS} -Rf \
4887 -Sescape=! -Sindentprefix=' |' \
4888 -Y 'set quote=allheaders' \
4889 -Y reply -Y !. \
4890 -Y 'set quote=allbodies' \
4891 -Y reply -Y !. \
4892 -Y xit \
4893 ./.tmbox >./.tall 2>&1
4894 check 21 0 ./.tall "${ck}"
4896 ARGS=${XARGS} # TODO v15-compat
4897 t_epilog "${@}"
4898 } # }}}
4900 t_forward() { # {{{
4901 t_prolog "${@}"
4902 XARGS=${ARGS}
4903 ARGS="${ARGS} -Sv15-compat=y"
4905 t__gen_msg subject fwd1 body origb1 from 1 to 2 > "${MBOX}"
4906 t__gen_msg subject fwd2 body origb2 from 1 to 1 >> "${MBOX}"
4908 ## Base (does not test "recipient record")
4909 t_it() {
4910 </dev/null ${MAILX} ${ARGS} -Rf \
4911 -Y ${1}' . "du <ex1@am.ple>"
4914 echo 1:$?/$^ERRNAME; echoerr 1:done
4915 set fullnames escape=!
4916 '${1}' 1 "du <ex2@am.ple>"
4917 b2 fullnames
4919 echo 2:$?/$^ERRNAME; echoerr 2:done
4920 # Some errors
4921 set nofullnames ea=$expandaddr expandaddr=-all
4922 '${1}' ` "du <ex3@am.ple>"
4925 echo 3:$?/$^ERRNAME; echoerr 3:done
4926 set expandaddr=$ea
4927 '${1}' ` ex4-nono@am.ple ex4@am.ple # the first is a non-match msglist
4930 echo 4:$?/$^ERRNAME; echoerr 4:done
4931 '${1}' # TODO not yet possible b5 !.
4932 echo 5:$?/$^ERRNAME; echoerr 5:done
4933 set expandaddr=$ea
4934 '${1}' 1 2 ex6@am.ple
4935 b6-1
4937 b6-2
4939 echo 6:$?/$^ERRNAME; echoerr 6:done
4940 set forward-add-cc fullnames
4941 '${1}' . ex7@am.ple
4944 echo 7:$?/$^ERRNAME; echoerr 7:done
4945 set nofullnames
4946 '${1}' . ex8@am.ple
4949 echo 8:$?/$^ERRNAME; echoerr 8:done
4950 #' \
4951 "${MBOX}" > ./.tall 2>./.terr
4952 return ${?}
4955 t_it forward
4956 check 1 0 ./.tall '2356713156 2219'
4957 if have_feat uistrings && have_feat docstrings; then
4958 check 2 - ./.terr '3273108824 335'
4959 else
4960 t_echoskip '2:[!UISTRINGS]'
4963 t_it Forward
4964 check 3 0 ./.tall '2356713156 2219'
4965 if have_feat uistrings && have_feat docstrings; then
4966 check 4 - ./.terr '447176534 355'
4967 else
4968 t_echoskip '4:[!UISTRINGS]'
4970 ${rm} -f ex*
4972 ## *record*, *outfolder* (reuses $MBOX)
4973 ${mkdir} .tfolder
4975 t_it() {
4976 </dev/null ${MAILX} ${ARGS} -Rf -Sescape=! -Sfolder=`${pwd}`/.tfolder \
4977 -Y '#
4978 '${1}' 1 ex1@am.ple
4981 echo 1:$?/$^ERRNAME; set record=.trec'${2}'; '${1}' 1 ex2@am.ple
4984 echo 2:$?/$^ERRNAME; set outfolder norecord; '${1}' 2 ex1@am.ple
4987 echo 3:$?/$^ERRNAME; set record=.trec'${2}'; '${1}' 2 ex2@am.ple
4990 echo 4:$?/$^ERRNAME
4991 #' \
4992 "${MBOX}" > ./.tall 2>&1
4993 check ${2} 0 ./.tall '3180366037 1212'
4994 if [ ${#} -ne 4 ]; then
4995 check ${3}-1 - ./.trec${2} '1769129556 304'
4996 check ${3}-2 - ./.tfolder/.trec${2} '2335391111 284'
4997 else
4998 [ -f ./.trec${2} ]; check_exn0 ${3}
4999 echo * > ./.tlst
5000 check ${3}-1 - ./.tlst '2020171298 8'
5001 check ${3}-2 - ./ex1 '1512529673 304'
5002 check ${3}-3 - ./ex2 '1769129556 304'
5003 [ -f ./.tfolder/.trec${2} ]; check_exn0 ${3}-4
5004 ( cd .tfolder && echo * > ./.tlst )
5005 check ${3}-5 - ./.tfolder/.tlst '2020171298 8'
5006 check ${3}-6 - ./.tfolder/ex1 '2016773910 284'
5007 check ${3}-7 - ./.tfolder/ex2 '2335391111 284'
5011 t_it forward 5 6
5012 t_it Forward 7 8 yes
5013 #${rm} -f ex*
5015 ## Injections, headerpick selection
5016 ${rm} -f "${MBOX}"
5017 t__x2_msg > ./.tmbox
5019 printf '#
5020 set quote=noheading forward-inject-head
5021 forward 1 ex1@am.ple
5024 headerpick forward retain cc from subject to
5025 forward 1 ex1@am.ple
5028 unheaderpick forward retain *
5029 forward 1 ex1@am.ple
5032 headerpick forward ignore in-reply-to reply-to message-id status
5033 set forward-inject-head=%% forward-inject-tail=%%
5034 forward 1 ex1@am.ple
5037 set forward-inject-head='"\$'"'\\
5038 (%%%%a=%%a %%%%d=%%d %%%%f=%%f %%%%i=%%i %%%%n=%%n %%%%r=%%r)\\
5039 \\n'"'"' \\
5040 forward-inject-tail='"\$'"'\\
5041 (%%%%a=%%a %%%%d=%%d %%%%f=%%f %%%%i=%%i %%%%n=%%n %%%%r=%%r)\\
5042 \\n'"'"'
5043 forward 1 ex1@am.ple
5046 set showname datefield=%%y nodatefield-markout-older
5047 forward 1 ex1@am.ple
5050 ' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" -Rf \
5051 -Sescape=! \
5052 ./.tmbox >./.tall 2>&1
5053 check_ex0 9-estat
5054 ${cat} ./.tall >> "${MBOX}"
5055 check 9 - "${MBOX}" '2976943913 2916'
5057 # forward-as-attachment
5058 </dev/null ${MAILX} ${ARGS} -Rf \
5059 -Sescape=! \
5060 -S forward-inject-head=.head. \
5061 -S forward-inject-tail=.tail. \
5062 -S forward-as-attachment \
5063 -Y 'headerpick forward retain subject to from' \
5064 -Y 'forward ex1@am.ple' -Y b1 -Y !. \
5065 -Y 'unset forward-as-attachment' \
5066 -Y 'forward ex1@am.ple;b2' -Y !. \
5067 ./.tmbox >./.tall 2>&1
5068 check 10 0 ./.tall '799103633 1250'
5070 ARGS=${XARGS}
5071 t_epilog "${@}"
5072 } # }}}
5074 t_resend() { # {{{
5075 t_prolog "${@}"
5076 XARGS=${ARGS}
5077 ARGS="${ARGS} -Sv15-compat=y"
5079 t__gen_msg subject fwd1 body origb1 from 1 to 2 > "${MBOX}"
5080 t__gen_msg subject fwd2 body origb2 from 1 to 1 >> "${MBOX}"
5082 ## Base
5083 t_it() {
5084 </dev/null ${MAILX} ${ARGS} -Rf \
5085 -Y ${1}' . "du <ex1@am.ple>"
5086 echo 1:$?/$^ERRNAME; echoerr 1:done
5087 set fullnames escape=!
5088 '${1}' 1 "du , da <ex2@am.ple>"
5089 echo 2:$?/$^ERRNAME; echoerr 2:done
5090 # Some errors
5091 set nofullnames ea=$expandaddr expandaddr=-all
5092 '${1}' ` "du <ex3@am.ple>"
5093 echo 3:$?/$^ERRNAME; echoerr 3:done
5094 set expandaddr=$ea
5095 '${1}' ` ex4-nono@am.ple ex4@am.ple # the first is a non-match msglist
5096 echo 4:$?/$^ERRNAME; echoerr 4:done
5097 '${1}' # TODO not yet possible b5 !.
5098 echo 5:$?/$^ERRNAME; echoerr 5:done
5099 set expandaddr=$ea
5100 '${1}' 1 2 ex6@am.ple
5101 echo 6:$?/$^ERRNAME; echoerr 6:done
5102 #' \
5103 "${MBOX}" > ./.tall 2>./.terr
5104 return ${?}
5107 t_it resend
5108 check 1 0 ./.tall '1461006932 1305'
5109 if have_feat uistrings; then
5110 check 2 - ./.terr '138360532 210'
5111 else
5112 t_echoskip '2:[!UISTRINGS]'
5115 t_it Resend
5116 check 3 0 ./.tall '3674535444 958'
5117 if have_feat uistrings; then
5118 check 4 - ./.terr '138360532 210'
5119 else
5120 t_echoskip '4:[!UISTRINGS]'
5123 ## *record*, *outfolder* (reuses $MBOX)
5124 ${mkdir} .tfolder
5126 t_it() {
5127 </dev/null ${MAILX} ${ARGS} -Rf -Sescape=! -Sfolder=`${pwd}`/.tfolder \
5128 -Y '#
5129 set record=.trec'${2}'; '${1}' 1 ex1@am.ple
5130 echo 1:$?/$^ERRNAME; set record-resent; '${1}' 1 ex2@am.ple
5131 echo 2:$?/$^ERRNAME; set outfolder norecord-resent; '${1}' 2 ex1@am.ple
5132 echo 3:$?/$^ERRNAME; set record-resent; '${1}' 2 ex2@am.ple
5133 echo 4:$?/$^ERRNAME
5134 #' \
5135 "${MBOX}" > ./.tall 2>&1
5136 check_ex0 ${2}
5137 if [ ${#} -ne 3 ]; then
5138 check ${2} - ./.tall '1711347390 992'
5139 check ${3}-1 - ./.trec${2} '2840978700 249'
5140 check ${3}-2 - ./.tfolder/.trec${2} '3219997964 229'
5141 else
5142 check ${2} - ./.tall '1391418931 724'
5143 check ${3}-1 - ./.trec${2} '473817710 182'
5144 check ${3}-2 - ./.tfolder/.trec${2} '2174632404 162'
5148 t_it resend 5 6 yes
5149 t_it Resend 7 8
5151 ARGS=${XARGS}
5152 t_epilog "${@}"
5153 } # }}}
5154 # }}}
5156 # VFS {{{
5157 t_copy() { # {{{
5158 t_prolog "${@}"
5160 t__gen_msg subject Copy1 from 1 to 1 body 'Body1' > "${MBOX}"
5161 t__gen_msg subject Copy2 from 1 to 1 body 'Body2' >> "${MBOX}"
5162 check 1 - "${MBOX}" '137107341 324' # for flag test
5165 </dev/null ${MAILX} ${ARGS} -f \
5166 -Y '#
5167 headers
5168 copy 10 .tf1
5169 echo 0:$?/$^ERRNAME
5170 headers
5171 copy .tf1
5172 echo 1:$?/$^ERRNAME
5173 headers
5174 copy .tf1 # no auto-advance
5175 echo 2:$?/$^ERRNAME
5176 headers
5177 copy 2 .tf2
5178 echo 3:$?/$^ERRNAME
5179 headers
5180 copy 1 2 .tf3
5181 echo 4:$?/$^ERRNAME
5182 headers
5183 !'"${chmod}"' 0444 .tf3
5184 copy 1 2 .tf3
5185 echo 5:$?/$^ERRNAME
5186 #' \
5187 "${MBOX}" > ./.tallx 2>./.terr
5188 check_ex0 2
5190 if have_feat uistrings; then # TODO
5191 ${sed} -e '$bP' -e d -e :P < ./.tallx >> "${ERR}"
5192 ${sed} '$d' < ./.tallx > ./.tall
5193 else
5194 ${mv} ./.tallx ./.tall
5196 if [ -n "${HONOURS_READONLY}" ]; then
5197 n2_1=2-1 cs2_1='1913702840 1121'
5198 n2_4=2-4 cs2_4='3642131968 344'
5199 n2_5=2-5 cs2_5='2617612897 112'
5200 else
5201 n2_1=2-1-nrdonly cs2_1='1962556153 1146'
5202 n2_4=2-4-nrdonly cs2_4='3733058190 688'
5203 n2_5=2-5-nrdonly cs2_5='3989834342 80'
5205 check ${n2_1} - ./.tall "${cs2_1}"
5206 check 2-2 - ./.tf1 '686654461 334'
5207 check 2-3 - ./.tf2 '1931512953 162'
5208 check ${n2_4} - ./.tf3 "${cs2_4}"
5209 if have_feat uistrings; then
5210 check ${n2_5} - ./.terr "${cs2_5}"
5211 else
5212 t_echoskip '2-5:[!UISTRINGS]'
5216 check 3 - "${MBOX}" '1477662071 346'
5219 t_it() {
5220 t__gen_msg subject Copy1 from 1 to 1 body 'Body1' > "${MBOX}"
5221 t__gen_msg subject Copy2 from 1 to 1 body 'Body2' >> "${MBOX}"
5222 t__gen_msg subject Copy3 from ex@am.ple to 1 body 'Body3' >> "${MBOX}"
5223 check ${1} - "${MBOX}" '2667292819 473' # for flag test
5225 </dev/null ${MAILX} ${ARGS} -f \
5226 -Y "${3}"'
5227 '"${2}"'
5228 Copy
5229 echo 1:$?/$^ERRNAME
5230 '"${2}"'
5231 Copy
5232 echo 2:$?/$^ERRNAME
5233 '"${2}"'
5234 Copy 2
5235 echo 3:$?/$^ERRNAME
5236 '"${2}"'
5237 Copy 3
5238 echo 4:$?/$^ERRNAME
5239 '"${2}"'
5240 Copy *
5241 echo 5:$?/$^ERRNAME
5242 '"${2}"'
5243 #' \
5244 "${MBOX}" > ./.tallx 2>&1
5245 return ${?}
5248 t_it 5 headers '#'
5249 check_ex0 5-1
5250 if have_feat uistrings; then # TODO
5251 ${sed} -e '$bP' -e d -e :P < ./.tallx >> "${ERR}"
5252 ${sed} '$d' < ./.tallx > ./.tall
5253 else
5254 ${mv} ./.tallx ./.tall
5256 echo * > ./.tlst
5257 check 5-2 - ./.tlst '1058655452 9'
5258 check 5-3 - ./.tall '1543702808 1617'
5259 check 5-4 - ./from1 '1031912635 999'
5260 check 5-5 - ./ex '2400630246 149'
5261 ${rm} -f ./.tlst ./.tall ./from1 ./ex
5263 ${mkdir} .tfolder
5264 t_it 6 '#' 'set outfolder folder='"`${pwd}`"'/.tfolder'
5265 check_ex0 6-1
5266 if have_feat uistrings; then # TODO
5267 ${sed} -e '$bP' -e d -e :P < ./.tallx >> "${ERR}"
5268 ${sed} '$d' < ./.tallx > ./.tall
5269 else
5270 ${mv} ./.tallx ./.tall
5272 echo * .tfolder/* > ./.tlst
5273 check 6-2 - ./.tlst '1865898363 29'
5274 ${cat} ./.tall >> ${ERR} #check 6-3 - ./.tall # TODO due to folder echoes
5275 check 6-4 - .tfolder/from1 '1031912635 999'
5276 check 6-5 - .tfolder/ex '2400630246 149'
5279 t__x2_msg > ./.tmbox
5281 t_it() {
5282 printf '#
5283 '"${1}"'
5284 echo 1:$?/$^ERRNAME
5285 headerpick save retain cc date from subject to
5286 '"${1}"'
5287 echo 2:$?/$^ERRNAME
5288 unheaderpick save retain *
5289 '"${1}"'
5290 echo 3:$?/$^ERRNAME
5291 headerpick save ignore status in-reply-to
5292 '"${1}"'
5293 echo 4:$?/$^ERRNAME
5294 #' | ${MAILX} ${ARGS} -Rf ./.tmbox > ./.tall 2>&1
5295 return ${?}
5298 t_it 'copy ./.tout'
5299 check_ex0 7-estat
5300 check 7-1 - ./.tall '3805176908 152'
5301 check 7-2 - ./.tout '2447734879 1316'
5303 t_it Copy
5304 check_ex0 8-estat
5305 echo * > ./.tlst
5306 check 8-1 - ./.tall '1044700686 136'
5307 check 8-2 - ./mr2 '2447734879 1316'
5308 check 8-3 - ./.tlst '3190056903 4'
5310 t_epilog "${@}"
5311 } # }}}
5313 t_save() { # {{{
5314 t_prolog "${@}"
5316 t__gen_msg subject Save1 from 1 to 1 body 'Body1' > "${MBOX}"
5317 t__gen_msg subject Save2 from 1 to 1 body 'Body2' >> "${MBOX}"
5318 check 1 - "${MBOX}" '3634443864 324' # for flag test
5321 </dev/null ${MAILX} ${ARGS} -f \
5322 -Y '#
5323 headers
5324 save 10 .tf1
5325 echo 0:$?/$^ERRNAME
5326 headers
5327 save .tf1
5328 echo 1:$?/$^ERRNAME
5329 headers
5330 save .tf1 # no auto-advance
5331 echo 2:$?/$^ERRNAME
5332 headers
5333 save 2 .tf2
5334 echo 3:$?/$^ERRNAME
5335 headers
5336 save 1 2 .tf3
5337 echo 4:$?/$^ERRNAME
5338 headers
5339 !'"${chmod}"' 0444 .tf3
5340 save 1 2 .tf3
5341 echo 5:$?/$^ERRNAME
5342 #' \
5343 "${MBOX}" > ./.tallx 2>./.terr
5344 check_ex0 2
5346 if have_feat uistrings; then # TODO
5347 ${sed} -e '$bP' -e d -e :P < ./.tallx >> "${ERR}"
5348 ${sed} '$d' < ./.tallx > ./.tall
5349 else
5350 ${mv} ./.tallx ./.tall
5352 if [ -n "${HONOURS_READONLY}" ]; then
5353 n2_1=2-1 cs2_1='2335843514 1121'
5354 n2_4=2-4 cs2_4='970407001 344'
5355 n2_5=2-5 cs2_5='45116475 112'
5356 else
5357 n2_1=2-1-nrdonly cs2_1='1736244784 1146'
5358 n2_4=2-4-nrdonly cs2_4='3903872811 688'
5359 n2_5=2-5-nrdonly cs2_5='720724138 80'
5361 check ${n2_1} - ./.tall "${cs2_1}"
5362 check 2-2 - ./.tf1 '2435434321 334'
5363 check 2-3 - ./.tf2 '920652966 162'
5364 check ${n2_4} - ./.tf3 "${cs2_4}"
5365 if have_feat uistrings; then
5366 check ${n2_5} - ./.terr "${cs2_5}"
5367 else
5368 t_echoskip '2-5:[!UISTRINGS]'
5372 check 3 - "${MBOX}" '1219692400 346'
5375 t_it() {
5376 t__gen_msg subject Save1 from 1 to 1 body 'Body1' > "${MBOX}"
5377 t__gen_msg subject Save2 from 1 to 1 body 'Body2' >> "${MBOX}"
5378 t__gen_msg subject Save3 from ex@am.ple to 1 body 'Body3' >> "${MBOX}"
5379 check ${1} - "${MBOX}" '1391391227 473' # for flag test
5381 </dev/null ${MAILX} ${ARGS} -f \
5382 -Y "${3}"'
5383 '"${2}"'
5384 Save
5385 echo 1:$?/$^ERRNAME
5386 '"${2}"'
5387 Save
5388 echo 2:$?/$^ERRNAME
5389 '"${2}"'
5390 Save 2
5391 echo 3:$?/$^ERRNAME
5392 '"${2}"'
5393 Save 3
5394 echo 4:$?/$^ERRNAME
5395 '"${2}"'
5396 Save *
5397 echo 5:$?/$^ERRNAME
5398 '"${2}"'
5399 #' \
5400 "${MBOX}" > ./.tallx 2>&1
5401 return ${?}
5404 t_it 5 headers '#'
5405 check_ex0 5-1
5406 if have_feat uistrings; then # TODO
5407 ${sed} -e '$bP' -e d -e :P < ./.tallx >> "${ERR}"
5408 ${sed} '$d' < ./.tallx > ./.tall
5409 else
5410 ${mv} ./.tallx ./.tall
5412 echo * > ./.tlst
5413 check 5-2 - ./.tlst '1058655452 9'
5414 check 5-3 - ./.tall '3418590770 1617'
5415 check 5-4 - ./from1 '1462882526 999'
5416 check 5-5 - ./ex '2153575326 149'
5417 ${rm} -f ./.tlst ./.tall ./from1 ./ex
5419 ${mkdir} .tfolder
5420 t_it 6 '#' 'set outfolder folder='"`${pwd}`"'/.tfolder'
5421 check_ex0 6-1
5422 if have_feat uistrings; then # TODO
5423 ${sed} -e '$bP' -e d -e :P < ./.tallx >> "${ERR}"
5424 ${sed} '$d' < ./.tallx > ./.tall
5425 else
5426 ${mv} ./.tallx ./.tall
5428 echo * .tfolder/* > ./.tlst
5429 check 6-2 - ./.tlst '1865898363 29'
5430 ${cat} ./.tall >> ${ERR} #check 6-3 - ./.tall # TODO due to folder echoes
5431 check 6-4 - .tfolder/from1 '1462882526 999'
5432 check 6-5 - .tfolder/ex '2153575326 149'
5436 t_it() {
5437 t__x2_msg > ./.tmbox
5438 check ${1} - ./.tmbox '561523988 397'
5440 a='-Rf'
5441 [ ${#} -gt 2 ] && a='-S MBOX=./.tmboxx'
5442 [ ${#} -gt 3 ] && a="${a}"' -S inbox=./.tmbox'
5443 printf '#
5444 headers
5445 '"${2}"'
5446 echo 1:$?/$^ERRNAME
5447 headers
5448 headerpick save retain cc date from subject to
5449 '"${2}"'
5450 echo 2:$?/$^ERRNAME
5451 unheaderpick save retain *
5452 '"${2}"'
5453 echo 3:$?/$^ERRNAME
5454 headerpick save ignore status in-reply-to
5455 '"${2}"'
5456 echo 4:$?/$^ERRNAME
5457 #' | ${MAILX} ${ARGS} -f ${a} ./.tmbox > ./.tall 2>&1
5458 return ${?}
5461 t_it 7 'save ./.tout'
5462 check_ex0 7-estat
5463 check 7-1 - ./.tall '4190949581 312'
5464 check 7-2 - ./.tout '2447734879 1316'
5465 check 7-3 - ./.tmbox '561523988 397'
5467 t_it 8 Save
5468 check_ex0 8-estat
5469 echo * > ./.tlst
5470 check 8-1 - ./.tall '2109832180 296'
5471 check 8-2 - ./mr2 '2447734879 1316'
5472 check 8-3 - ./.tlst '3190056903 4'
5473 check 8-3 - ./.tmbox '561523988 397'
5475 # saves in $MBOX without argument
5476 t_it 9 save yes
5477 check_ex0 9-estat
5478 check 9-1 - ./.tall '652005824 320'
5479 check 9-2 - ./.tmboxx '2447734879 1316'
5480 check 9-3 - ./.tmbox '561523988 397'
5482 # and deletes if editing a primary mailbox
5483 ${rm} -f ./.tmboxx
5484 t_it 10 save yes yes
5485 check_ex0 10-estat
5486 check 10-1 - ./.tall '652005824 320'
5487 check 10-2 - ./.tmboxx '2447734879 1316'
5488 [ -f ./.tmbox ]; check_exn0 10-3
5490 t_epilog "${@}"
5491 } # }}}
5493 t_move() { # {{{
5494 t_prolog "${@}"
5496 t__gen_msg subject Move1 from 1 to 1 body 'Body1' > "${MBOX}"
5497 t__gen_msg subject Move2 from 1 to 1 body 'Body2' >> "${MBOX}"
5498 check 1 - "${MBOX}" '2967134193 324' # for flag test
5501 </dev/null ${MAILX} ${ARGS} -f \
5502 -Y '#
5503 headers
5504 move 10 .tf1
5505 echo 0:$?/$^ERRNAME
5506 headers
5507 move .tf1
5508 echo 1:$?/$^ERRNAME
5509 headers
5510 !touch .tf2; '"${chmod}"' 0444 .tf2
5511 move 2 .tf2
5512 echo 2:$?/$^ERRNAME
5513 !'"${chmod}"' 0644 .tf2
5514 move 2 .tf2
5515 echo 3:$?/$^ERRNAME
5516 headers
5517 #' \
5518 "${MBOX}" > ./.tallx 2>./.terr
5519 check_ex0 2
5521 if have_feat uistrings; then # TODO
5522 ${sed} -e '$bP' -e d -e :P < ./.tallx >> "${ERR}"
5523 ${sed} '$d' < ./.tallx > ./.tall
5524 else
5525 ${mv} ./.tallx ./.tall
5527 if [ -n "${HONOURS_READONLY}" ]; then
5528 n2_1=2-1 cs2_1='1641443074 491'
5529 n2_4=2-4 cs2_4='602144474 155'
5530 else
5531 n2_1=2-1-nrdonly cs2_1='3045412111 492'
5532 n2_4=2-4-nrdonly cs2_4='2197157669 201'
5534 check ${n2_1} - ./.tall "${cs2_1}"
5535 check 2-2 - ./.tf1 '1473857906 162'
5536 check 2-3 - ./.tf2 '331229810 162'
5537 if have_feat uistrings; then
5538 check ${n2_4} - ./.terr "${cs2_4}"
5539 else
5540 t_echoskip '2-4:[!UISTRINGS]'
5544 check 3 - "${MBOX}" '4294967295 0'
5547 t_it() {
5548 t__gen_msg subject Move1 from 1 to 1 body 'Body1' > "${MBOX}"
5549 t__gen_msg subject Move2 from 1 to 1 body 'Body2' >> "${MBOX}"
5550 t__gen_msg subject Move3 from ex@am.ple to 1 body 'Body3' >> "${MBOX}"
5551 check ${1} - "${MBOX}" '2826896131 473' # for flag test
5553 </dev/null ${MAILX} ${ARGS} -f \
5554 -Y "${3}"'
5555 '"${2}"'
5556 Move
5557 echo 1:$?/$^ERRNAME
5558 '"${2}"'
5559 Move 2
5560 echo 2:$?/$^ERRNAME
5561 '"${2}"'
5562 Move 3
5563 echo 3:$?/$^ERRNAME
5564 '"${2}"'
5565 undelete *
5566 echo 4:$?/$^ERRNAME
5567 '"${2}"'
5568 Move *
5569 echo 5:$?/$^ERRNAME
5570 '"${2}"'
5571 #' \
5572 "${MBOX}" > ./.tallx 2>./.terr
5573 return ${?}
5576 t_it 5 headers '#'
5577 check_ex0 5-1
5578 if have_feat uistrings; then # TODO
5579 ${sed} -e '$bP' -e d -e :P < ./.tallx >> "${ERR}"
5580 ${sed} '$d' < ./.tallx > ./.tall
5581 else
5582 ${mv} ./.tallx ./.tall
5584 echo * > ./.tlst
5585 check 5-2 - ./.tlst '1058655452 9'
5586 check 5-3 - ./.tall '419037676 870'
5587 if have_feat uistrings; then
5588 check 5-4 - ./.terr '1383646464 86'
5589 else
5590 t_echoskip '5-4:[!UISTRINGS]'
5592 check 5-5 - ./from1 '3719268580 827'
5593 check 5-6 - ./ex '4262925856 149'
5594 ${rm} -f ./.tlst ./.tall ./.terr ./from1 ./ex
5596 ${mkdir} .tfolder
5597 t_it 6 '#' 'set outfolder folder='"`${pwd}`"'/.tfolder'
5598 check_ex0 6-1
5599 if have_feat uistrings; then # TODO
5600 ${sed} -e '$bP' -e d -e :P < ./.tallx >> "${ERR}"
5601 ${sed} '$d' < ./.tallx > ./.tall
5602 else
5603 ${mv} ./.tallx ./.tall
5605 echo * .tfolder/* > ./.tlst
5606 check 6-2 - ./.tlst '1865898363 29'
5607 ${cat} ./.tall >> ${ERR} #check 6-3 - ./.tall # TODO due to folder echoes
5608 check 6-4 - .tfolder/from1 '3719268580 827'
5609 check 6-5 - .tfolder/ex '4262925856 149'
5612 t__x2_msg > ./.tmbox
5614 t_it() {
5615 printf '#
5616 '"${1}"'
5617 echo 1:$?/$^ERRNAME
5618 headerpick save retain cc date from subject to
5619 '"${1}"'
5620 echo 2:$?/$^ERRNAME
5621 unheaderpick save retain *
5622 '"${1}"'
5623 echo 3:$?/$^ERRNAME
5624 headerpick save ignore status in-reply-to
5625 '"${1}"'
5626 echo 4:$?/$^ERRNAME
5627 #' | ${MAILX} ${ARGS} -Rf ./.tmbox > ./.tall 2>&1
5628 return ${?}
5631 t_it 'move ./.tout'
5632 check_ex0 7-estat
5633 check 7-1 - ./.tall '3805176908 152'
5634 check 7-2 - ./.tout '2447734879 1316'
5636 t_it Move
5637 check_ex0 8-estat
5638 echo * > ./.tlst
5639 check 8-1 - ./.tall '1044700686 136'
5640 check 8-2 - ./mr2 '2447734879 1316'
5641 check 8-3 - ./.tlst '3190056903 4'
5643 t_epilog "${@}"
5644 } # }}}
5646 t_mbox() { # {{{
5647 t_prolog "${@}"
5651 while [ ${i} -lt 113 ]; do
5652 printf 'm file://%s\n~s Subject %s\nHello %s!\n~.\n' \
5653 "${MBOX}" "${i}" "${i}"
5654 i=`add ${i} 1`
5655 done
5656 ) | ${MAILX} ${ARGS} > .tall 2>&1
5657 check 1 0 "${MBOX}" '1785801373 13336'
5658 check 1-outerr - ./.tall '4294967295 0' # empty file
5660 printf 'File "%s"\ncopy * "%s"\nFile "%s"\nfrom*' "${MBOX}" .tmbox1 .tmbox1 |
5661 ${MAILX} ${ARGS} -Sshowlast > .tall 2>&1
5662 check 2 0 .tall '3467540956 8991'
5664 printf 'File "%s"\ncopy * "file://%s"\nFile "file://%s"\nfrom*' \
5665 "${MBOX}" .tmbox2 .tmbox2 | ${MAILX} ${ARGS} -Sshowlast > .tall 2>&1
5666 check 3 0 .tall '2410946529 8998'
5668 # copy only the odd (but the first), move the even
5670 printf 'File "file://%s"\ncopy ' .tmbox2
5672 while [ ${i} -lt 113 ]; do
5673 printf '%s ' "${i}"
5674 i=`add ${i} 2`
5675 done
5676 printf 'file://%s\nFile "file://%s"\nfrom*' .tmbox3 .tmbox3
5677 ) | ${MAILX} ${ARGS} -Sshowlast > .tall 2>&1
5678 check 4 0 .tmbox3 '2554734733 6666'
5679 check 5 - .tall '2062382804 4517'
5680 # ...
5682 printf 'file "file://%s"\nmove ' .tmbox2
5684 while [ ${i} -lt 113 ]; do
5685 printf '%s ' "${i}"
5686 i=`add ${i} 2`
5687 done
5688 printf 'file://%s\nFile "file://%s"\nfrom*\nFile "file://%s"\nfrom*' \
5689 .tmbox3 .tmbox3 .tmbox2
5690 ) | ${MAILX} ${ARGS} -Sshowlast > .tall 2>>${ERR}
5691 check 6 0 .tmbox3 '1429216753 13336'
5692 if have_feat uistrings; then
5693 ${sed} 2d < .tall > .tallx
5694 else
5695 ${cp} .tall .tallx
5697 check 7 - .tallx '169518319 13477'
5699 # Invalid MBOXes (after [f4db93b3])
5700 echo > .tinvmbox
5701 printf 'copy 1 ./.tinvmbox' | ${MAILX} ${ARGS} -Rf "${MBOX}" > .tall 2>&1
5702 check 8 0 .tinvmbox '2848412822 118'
5703 check 9 - ./.tall '461280182 33'
5705 echo ' ' > .tinvmbox
5706 printf 'copy 1 ./.tinvmbox' | ${MAILX} ${ARGS} -Rf "${MBOX}" > .tall 2>&1
5707 check 10 0 .tinvmbox '624770486 120'
5708 check 11 - ./.tall '461280182 33'
5710 { echo; echo; } > .tinvmbox # (not invalid)
5711 printf 'copy 1 ./.tinvmbox' | ${MAILX} ${ARGS} -Rf "${MBOX}" > .tall 2>&1
5712 check 12 0 .tinvmbox '1485640875 119'
5713 check 13 - ./.tall '461280182 33'
5715 # *mbox-rfc4155*, plus
5716 ${cat} <<-_EOT > ./.tinv1
5719 From MAILER-DAEMON-1 Wed Oct 2 01:50:07 1996
5720 Date: Wed, 02 Oct 1996 01:50:07 +0000
5722 Subject: Bad bad message 1
5724 From me to you, blinde Kuh!
5726 From MAILER-DAEMON-2 Wed Oct 2 01:50:07 1996
5727 Date: Wed, 02 Oct 1996 01:50:07 +0000
5729 Subject: Bad bad message 2
5731 From me to you, blindes Kalb!
5732 _EOT
5733 ${cp} ./.tinv1 ./.tinv2
5735 printf \
5736 'define mboxfix {
5737 \\localopts yes; \\wysh set mbox-rfc4155;\\wysh File "${1}";\\
5738 \\eval copy * "${2}"
5740 call mboxfix ./.tinv1 ./.tok' | ${MAILX} ${ARGS} > .tall 2>&1
5741 check_ex0 14-estat
5742 ${cat} ./.tinv1 ./.tok >> .tall
5743 check 14 - ./.tall '739301109 616'
5745 printf \
5746 'wysh file ./.tinv1 # ^From not repaired, but missing trailing NL is
5747 wysh File ./.tok # Just move away to nowhere
5748 set mbox-rfc4155
5749 wysh file ./.tinv2 # Fully repaired
5750 File ./.tok' | ${MAILX} ${ARGS} >>${ERR} 2>&1
5751 check_ex0 15-estat
5752 # Equal since [Auto-fix when MBOX had From_ errors on read (Dr. Werner
5753 # Fink).]
5754 check 15-1 - ./.tinv1 '4151504442 314'
5755 check 15-2 - ./.tinv2 '4151504442 314'
5757 # *mbox-fcc-and-pcc*
5758 ${cat} > ./.ttmpl <<-'_EOT'
5759 Fcc: ./.tfcc1
5760 Bcc: | cat >> ./.tpcc1
5761 Fcc: ./.tfcc2
5762 Subject: fcc and pcc, and *mbox-fcc-and-pcc*
5764 one line body
5765 _EOT
5767 < ./.ttmpl ${MAILX} ${ARGS} -t > "${MBOX}" 2>&1
5768 check 16 0 "${MBOX}" '4294967295 0'
5769 check 17 - ./.tfcc1 '2301294938 148'
5770 check 18 - ./.tfcc2 '2301294938 148'
5771 check 19 - ./.tpcc1 '2301294938 148'
5773 < ./.ttmpl ${MAILX} ${ARGS} -t -Snombox-fcc-and-pcc > "${MBOX}" 2>&1
5774 check 20 0 "${MBOX}" '4294967295 0'
5775 check 21 - ./.tfcc1 '3629108107 98'
5776 check 22 - ./.tfcc2 '3629108107 98'
5777 check 23 - ./.tpcc1 '2373220256 246'
5779 # More invalid: since in "copy * X" messages will be copied in `sort' order,
5780 # reordering may happen, and before ([f5db11fe] (a_cwrite_save1(): FIX:
5781 # ensure pre-v15 MBOX separation "in between" messages.., 2019-08-07) that
5782 # could still have created invalid MBOX files!
5783 ${cat} <<-_EOT > ./.tinv1
5786 From MAILER-DAEMON-4 Sun Oct 4 01:50:07 1998
5787 Date: Sun, 04 Oct 1998 01:50:07 +0000
5788 Subject: h4
5792 From MAILER-DAEMON-0 Fri Oct 28 21:02:21 2147483649
5793 Date: Nix, 01 Oct BAD 01:50:07 +0000
5794 Subject: hinvalid
5796 BINV
5798 From MAILER-DAEMON-3 Fri Oct 3 01:50:07 1997
5799 Date: Fri, 03 Oct 1997 01:50:07 +0000
5800 Subject: h3
5804 From MAILER-DAEMON-1 Sun Oct 1 01:50:07 1995
5805 Date: Sun, 01 Oct 1995 01:50:07 +0000
5806 Subject:h1
5811 From MAILER-DAEMON-2 Wed Oct 2 01:50:07 1996
5812 Date: Wed, 02 Oct 1996 01:50:07 +0000
5813 Subject: h2
5816 _EOT
5818 printf \
5819 'File ./.tinv1
5820 sort date
5821 remove ./.tinv2
5822 copy * ./.tinv2
5823 file ./.tinv1' | ${MAILX} ${ARGS} >>${ERR} 2>&1
5824 check 24 0 ./.tinv1 '104184185 560'
5825 check 25 - ./.tinv2 '853754737 510'
5827 t_epilog "${@}"
5828 } # }}}
5830 t_maildir() { # {{{
5831 t_prolog "${@}"
5833 if have_feat maildir; then :; else
5834 t_echoskip '[!MAILDIR]'
5835 t_epilog "${@}"
5836 return
5841 while [ ${i} -lt 112 ]; do
5842 printf 'm file://%s\n~s Subject %s\nHello %s!\n~.\n' \
5843 "${MBOX}" "${i}" "${i}"
5844 i=`add ${i} 1`
5845 done
5846 ) | ${MAILX} ${ARGS}
5847 check 1 0 "${MBOX}" '2366902811 13332'
5849 printf 'File "%s"
5850 copy * "%s"
5851 File "%s"
5852 from*
5853 ' "${MBOX}" .tmdir1 .tmdir1 |
5854 ${MAILX} ${ARGS} -Snewfolders=maildir -Sshowlast > .tlst
5855 check 2 0 .tlst '3442251309 8991'
5857 printf 'File "%s"
5858 copy * "maildir://%s"
5859 File "maildir://%s"
5860 from*
5861 ' "${MBOX}" .tmdir2 .tmdir2 |
5862 ${MAILX} ${ARGS} -Sshowlast > .tlst
5863 check 3 0 .tlst '3524806062 9001'
5865 printf 'File "maildir://%s"
5866 copy * "file://%s"
5867 File "file://%s"
5868 from*
5869 ' .tmdir2 .tmbox1 .tmbox1 |
5870 ${MAILX} ${ARGS} -Sshowlast > .tlst
5871 check 4 0 .tmbox1 '4096198846 12772'
5872 check 5 - .tlst '1262452287 8998'
5874 # only the odd (even)
5876 printf 'File "maildir://%s"
5877 copy ' .tmdir2
5879 while [ ${i} -lt 112 ]; do
5880 j=`modulo ${i} 2`
5881 [ ${j} -eq 1 ] && printf '%s ' "${i}"
5882 i=`add ${i} 1`
5883 done
5884 printf ' file://%s
5885 File "file://%s"
5886 from*
5887 ' .tmbox2 .tmbox2
5888 ) | ${MAILX} ${ARGS} -Sshowlast > .tlst
5889 check 6 0 .tmbox2 '4228337024 6386'
5890 check 7 - .tlst '2078821439 4517'
5891 # ...
5893 printf 'file "maildir://%s"
5894 move ' .tmdir2
5896 while [ ${i} -lt 112 ]; do
5897 j=`modulo ${i} 2`
5898 [ ${j} -eq 0 ] && [ ${i} -ne 0 ] && printf '%s ' "${i}"
5899 i=`add ${i} 1`
5900 done
5901 printf ' file://%s
5902 File "file://%s"
5903 from*
5904 File "maildir://%s"
5905 from*
5906 ' .tmbox2 .tmbox2 .tmdir2
5907 ) | ${MAILX} ${ARGS} -Sshowlast > .tlst
5908 check 8 0 .tmbox2 '978751761 12656'
5909 ${sed} 2d < .tlst > .tlstx
5910 check 9 - .tlstx '2172297531 13477'
5912 # More invalid: since in "copy * X" messages will be copied in `sort' order,
5913 # reordering may happen, and before ([f5db11fe] (a_cwrite_save1(): FIX:
5914 # ensure pre-v15 MBOX separation "in between" messages.., 2019-08-07) that
5915 # could still have created invalid MBOX files!
5916 ${cat} <<-_EOT > ./.tinv1
5919 From MAILER-DAEMON-4 Sun Oct 4 01:50:07 1998
5920 Date: Sun, 04 Oct 1998 01:50:07 +0000
5921 Subject: h4
5925 From MAILER-DAEMON-0 Fri Oct 28 21:02:21 2147483649
5926 Date: Nix, 01 Oct BAD 01:50:07 +0000
5927 Subject: hinvalid
5929 BINV
5931 From MAILER-DAEMON-3 Fri Oct 3 01:50:07 1997
5932 Date: Fri, 03 Oct 1997 01:50:07 +0000
5933 Subject: h3
5937 From MAILER-DAEMON-1 Sun Oct 1 01:50:07 1995
5938 Date: Sun, 01 Oct 1995 01:50:07 +0000
5939 Subject:h1
5944 From MAILER-DAEMON-2 Wed Oct 2 01:50:07 1996
5945 Date: Wed, 02 Oct 1996 01:50:07 +0000
5946 Subject: h2
5949 _EOT
5951 printf \
5952 'File ./.tinv1
5953 sort date
5954 copy * maildir://./.tmdir10
5955 !{ for f in ./.tmdir10/new/*; do echo ===; %s $f; done; } > ./.t11
5956 File ./.tmdir10
5957 sort date
5958 copy * ./.t10warp
5959 ' "${cat}" | ${MAILX} ${ARGS} >>${ERR} 2>&1
5960 # Note that substdate() fixes all but one From_ line to $SOURCE_DATE_EPOCH!
5961 check 10 0 ./.t10warp '3551111321 502'
5962 check 11 - ./.t11 '642719592 302'
5964 t_epilog "${@}"
5965 } # }}}
5966 # }}}
5968 # MIME and RFC basics {{{
5969 t_mime_if_not_ascii() {
5970 t_prolog "${@}"
5972 </dev/null ${MAILX} ${ARGS} -s Subject "${MBOX}" >> "${MBOX}" 2>&1
5973 check 1 0 "${MBOX}" '3647956381 106'
5975 </dev/null ${MAILX} ${ARGS} -Scharset-7bit=not-ascii -s Subject "${MBOX}" \
5976 >> "${MBOX}" 2>&1
5977 check 2 0 "${MBOX}" '3964303752 274'
5979 t_epilog "${@}"
5982 t_mime_encoding() {
5983 t_prolog "${@}"
5985 # 8B
5986 printf 'Hey, you.\nFrom me to you\nCiao\n' |
5987 ${MAILX} ${ARGS} -s Subject -Smime-encoding=8b "${MBOX}" \
5988 >> "${MBOX}" 2>&1
5989 check 1 0 "${MBOX}" '3835153597 136'
5990 printf 'Hey, you.\n\nFrom me to you\nCiao.\n' |
5991 ${MAILX} ${ARGS} -s Subject -Smime-encoding=8b "${MBOX}" \
5992 >> "${MBOX}" 2>&1
5993 check 2 0 "${MBOX}" '63875210 275'
5995 # QP
5996 printf 'Hey, you.\n From me to you\nCiao\n' |
5997 ${MAILX} ${ARGS} -s Subject -Smime-encoding=qp "${MBOX}" \
5998 >> "${MBOX}" 2>&1
5999 check 3 0 "${MBOX}" '465798521 412'
6000 printf 'Hey, you.\nFrom me to you\nCiao\n' |
6001 ${MAILX} ${ARGS} -s Subject -Smime-encoding=qp "${MBOX}" \
6002 >> "${MBOX}" 2>&1
6003 check 4 0 "${MBOX}" '2075263697 655'
6005 # B64
6006 printf 'Hey, you.\n From me to you\nCiao\n' |
6007 ${MAILX} ${ARGS} -s Subject -Smime-encoding=b64 "${MBOX}" \
6008 >> "${MBOX}" 2>&1
6009 check 5 0 "${MBOX}" '601672771 792'
6010 printf 'Hey, you.\nFrom me to you\nCiao\n' |
6011 ${MAILX} ${ARGS} -s Subject -Smime-encoding=b64 "${MBOX}" \
6012 >> "${MBOX}" 2>&1
6013 check 6 0 "${MBOX}" '3926760595 1034'
6015 t_epilog "${@}"
6018 t_xxxheads_rfc2047() {
6019 t_prolog "${@}"
6021 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
6022 -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̲' \
6023 "${MBOX}"
6024 check 1 0 "${MBOX}" '3422562347 371'
6026 # Single word (overlong line split -- bad standard! Requires injection of
6027 # artificial data!! But can be prevented by using RFC 2047 encoding)
6028 ${rm} "${MBOX}"
6029 i=`${awk} 'BEGIN{for(i=0; i<92; ++i) printf "0123456789_"}'`
6030 echo | ${MAILX} ${ARGS} -s "${i}" "${MBOX}"
6031 check 2 0 "${MBOX}" '3317256266 1714'
6033 # Combination of encoded words, space and tabs of varying sort
6034 ${rm} "${MBOX}"
6035 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
6036 -s "1Abrä Kaspas1 2Abra Katä b_kaspas2 \
6037 3Abrä Kaspas3 4Abrä Kaspas4 5Abrä Kaspas5 \
6038 6Abra Kaspas6 7Abrä Kaspas7 8Abra Kaspas8 \
6039 9Abra Kaspastäb4-3 10Abra Kaspas1 _ 11Abra Katäb1 \
6040 12Abra Kadabrä1 After Tab after Täb this is NUTS" \
6041 "${MBOX}"
6042 check 3 0 "${MBOX}" '786672837 587'
6044 # Overlong multibyte sequence that must be forcefully split
6045 # todo This works even before v15.0, but only by accident
6046 ${rm} "${MBOX}"
6047 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
6048 -s "✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
6049 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
6050 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄" \
6051 "${MBOX}"
6052 check 4 0 "${MBOX}" '2889557767 655'
6054 # Trailing WS
6055 ${rm} "${MBOX}"
6056 echo | ${MAILX} ${ARGS} \
6057 -s "1-1 B2 B3 B4 B5 B6 B\
6058 1-2 B2 B3 B4 B5 B6 B\
6059 1-3 B2 B3 B4 B5 B6 B\
6060 1-4 B2 B3 B4 B5 B6 B\
6061 1-5 B2 B3 B4 B5 B6 B\
6062 1-6 B2 B3 B4 B5 B6 " \
6063 "${MBOX}"
6064 check 5 0 "${MBOX}" '3135161683 293'
6066 # Leading and trailing WS
6067 ${rm} "${MBOX}"
6068 echo | ${MAILX} ${ARGS} \
6069 -s " 2-1 B2 B3 B4 B5 B6 B\
6070 1-2 B2 B3 B4 B5 B6 B\
6071 1-3 B2 B3 B4 B5 B6 B\
6072 1-4 B2 B3 B4 B5 B6 " \
6073 "${MBOX}"
6074 check 6 0 "${MBOX}" '3221845405 232'
6076 # RFC 2047 in an address field! (Missing test caused v14.9.6!)
6077 ${rm} "${MBOX}"
6078 echo "Dat Früchtchen riecht häußlich" |
6079 ${MAILX} ${ARGS} ${ADDARG_UNI} -Sfullnames -Smta=test://"$MBOX" \
6080 -s Hühöttchen \
6081 'Schnödes "Früchtchen" <do@du> (Hä!)'
6082 check 7 0 "${MBOX}" '3681801246 373'
6084 # RFC 2047 in an address field, and iconv involved
6085 if have_feat iconv; then
6086 ${rm} "${MBOX}"
6087 ${cat} > ./.trebox <<_EOT
6088 From zaza@exam.ple Fri Mar 2 21:31:56 2018
6089 Date: Fri, 2 Mar 2018 20:31:45 +0000
6090 From: z=?iso-8859-1?Q?=E1?=za <zaza@exam.ple>
6091 To: dude <dude@exam.ple>
6092 Subject: houston(...)
6093 Message-ID: <abra@1>
6094 MIME-Version: 1.0
6095 Content-Type: text/plain; charset=iso-8859-1
6096 Content-Disposition: inline
6097 Content-Transfer-Encoding: 8bit
6099 _EOT
6100 echo reply | ${MAILX} ${ARGS} ${ADDARG_UNI} \
6101 -Sfullnames -Sreply-in-same-charset \
6102 -Smta=test://"$MBOX" -Rf ./.trebox
6103 check 8 0 "${MBOX}" '3499372945 285'
6104 else
6105 t_echoskip '8:[!ICONV]'
6108 t_epilog "${@}"
6111 t_iconv_mbyte_base64() { # TODO uses sed(1) and special *headline*!!
6112 t_prolog "${@}"
6114 if [ -n "${UTF8_LOCALE}" ] && have_feat multibyte-charsets &&
6115 have_feat iconv; then
6116 if (</dev/null iconv -f ascii -t iso-2022-jp) >/dev/null 2>&1 ||
6117 (</dev/null iconv -f ascii -t euc-jp) >/dev/null 2>&1; then
6119 else
6120 t_echoskip '[ICONV/iconv(1):missing conversion(s)]'
6121 t_epilog "${@}"
6122 return
6124 else
6125 t_echoskip '[no UTF-8 locale or !MULTIBYTE-CHARSETS or !ICONV]'
6126 t_epilog "${@}"
6127 return
6130 if (</dev/null iconv -f ascii -t iso-2022-jp) >/dev/null 2>&1; then
6131 ${cat} <<-'_EOT' | LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} \
6132 -Smta=test://"$MBOX" \
6133 -Sescape=! -Smime-encoding=base64 2>./.terr
6134 set ttycharset=utf-8 sendcharsets=iso-2022-jp
6135 m t1@exam.ple
6136 !s Japanese from UTF-8 to ISO-2022-JP
6137 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
6139 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
6142 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
6144 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
6147 set ttycharset=iso-2022-jp charset-7bit=iso-2022-jp sendcharsets=utf-8
6148 m t2@exam.ple
6149 !s Japanese from ISO-2022-JP to UTF-8, eh, no, also ISO-2022-JP
6150 \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
6152 \e$B%+%s%`%j%,%i!J3XL>\e(BParus cristatus\e$B!K$O!"%9%:%aL\%7%8%e%&%+%i2J$KJ,N`$5$l$kD;N`$N0l<o!#\e(B
6155 \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
6157 \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
6159 _EOT
6160 # May not presume iconv output as long as roundtrip possible [489a7122]
6161 check_ex0 1-estat
6162 ${awk} 'BEGIN{h=1}/^$/{++h;next}{if(h % 2 == 1)print}' \
6163 < "${MBOX}" > ./.tcksum
6164 check 1 - ./.tcksum '3314001564 516'
6165 check 2 - ./.terr '4294967295 0'
6167 printf 'eval f 1; eval write ./.twrite; eval type 1; eval type 2\n' |
6168 LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} \
6169 -S headline="%>%a%m %-18f %-16d %i%-s" \
6170 -Rf "${MBOX}" >./.tlog 2>&1
6171 check 3 0 ./.twrite '1259742080 686'
6172 #check 4 - ./.tlog '3214068822 2123'
6173 ${sed} -e '/^\[-- M/d' < ./.tlog > ./.txlog
6174 check 4 - ./.txlog '4083300132 2030'
6175 else
6176 t_echoskip '1-4:[ICONV/iconv(1):ISO-2022-JP unsupported]'
6179 if (</dev/null iconv -f ascii -t euc-jp) >/dev/null 2>&1; then
6180 ${rm} -f "${MBOX}" ./.twrite
6181 ${cat} <<-'_EOT' | LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} \
6182 -Smta=test://"$MBOX" \
6183 -Sescape=! -Smime-encoding=base64 2>./.terr
6184 set ttycharset=utf-8 sendcharsets=euc-jp
6185 m t1@exam.ple
6186 !s Japanese from UTF-8 to EUC-JP
6187 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
6189 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
6192 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
6194 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
6197 set ttycharset=EUC-JP sendcharsets=utf-8
6198 m t2@exam.ple
6199 !s Japanese from EUC-JP to UTF-8
6200 ¥·¥¸¥å¥¦¥«¥é²Ê¡Ê¥·¥¸¥å¥¦¥«¥é¤«¡¢³Ø̾ Paridae¡Ë¤Ï¡¢Ä»Îॹ¥º¥áÌܤβʤǤ¢¤ë¡£¥·¥¸¥å¥¦¥«¥é¡Ê»Í½½¿ý¡Ë¤ÈÁí¾Î¤µ¤ì¤ë¤¬¡¢¶¹µÁ¤Ë¤Ï¤³¤Î1¼ï¤ò¥·¥¸¥å¥¦¥«¥é¤È¸Æ¤Ö¡£
6202 ¥«¥ó¥à¥ê¥¬¥é¡Ê³Ø̾Parus cristatus¡Ë¤Ï¡¢¥¹¥º¥áÌÜ¥·¥¸¥å¥¦¥«¥é²Ê¤ËʬÎव¤ì¤ëÄ»Îà¤Î°ì¼ï¡£
6205 ¥«¥ó¥à¥ê¥¬¥é¡Ê³Ø̾Parus cristatus¡Ë¤Ï¡¢¥¹¥º¥áÌÜ¥·¥¸¥å¥¦¥«¥é²Ê¤ËʬÎव¤ì¤ëÄ»Îà¤Î°ì¼ï¡£
6207 ¥·¥¸¥å¥¦¥«¥é²Ê¡Ê¥·¥¸¥å¥¦¥«¥é¤«¡¢³Ø̾ Paridae¡Ë¤Ï¡¢Ä»Îॹ¥º¥áÌܤβʤǤ¢¤ë¡£¥·¥¸¥å¥¦¥«¥é¡Ê»Í½½¿ý¡Ë¤ÈÁí¾Î¤µ¤ì¤ë¤¬¡¢¶¹µÁ¤Ë¤Ï¤³¤Î1¼ï¤ò¥·¥¸¥å¥¦¥«¥é¤È¸Æ¤Ö¡£
6209 _EOT
6210 check_ex0 5-estat
6211 ${awk} 'BEGIN{h=1}/^$/{++h;next}{if(h % 2 == 1)print}' \
6212 < "${MBOX}" > ./.tcksum
6213 check 5 - ./.tcksum '1754179361 469'
6214 check 6 - ./.terr '4294967295 0'
6216 printf 'eval f 1; eval write ./.twrite; eval type 1; eval type 2\n' |
6217 LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} \
6218 -S headline="%>%a%m %-18f %-16d %i%-s" \
6219 -Rf "${MBOX}" >./.tlog 2>&1
6220 check 7 0 ./.twrite '1259742080 686'
6221 #check 8 - ./.tlog '2506063395 2075'
6222 ${sed} -e '/^\[-- M/d' < ./.tlog > ./.txlog
6223 check 8 - ./.txlog '3192017734 1983'
6224 else
6225 t_echoskip '5-8:[ICONV/iconv(1):EUC-JP unsupported]'
6228 t_epilog "${@}"
6231 t_iconv_mainbody() {
6232 t_prolog "${@}"
6234 if [ -n "${UTF8_LOCALE}" ] && have_feat iconv; then :; else
6235 t_echoskip '[no UTF-8 locale or !ICONV]'
6236 t_epilog "${@}"
6237 return
6240 printf '–' | ${MAILX} ${ARGS} ${ADDARG_UNI} -Smta=test://"$MBOX" \
6241 -S charset-7bit=us-ascii -S charset-8bit=utf-8 \
6242 -s '–' over-the@rain.bow 2>./.terr
6243 check 1 0 "${MBOX}" '3559538297 250'
6244 check 2 - ./.terr '4294967295 0'
6246 printf '–' | ${MAILX} ${ARGS} ${ADDARG_UNI} -Smta=test://"$MBOX" \
6247 -S charset-7bit=us-ascii -S charset-8bit=us-ascii \
6248 -s '–' over-the@rain.bow 2>./.terr
6249 check_exn0 3
6250 check 3 - "${MBOX}" '3559538297 250'
6251 if have_feat uistrings; then
6252 check 4 - ./.terr '271380835 121'
6253 else
6254 t_echoskip '4:[!UISTRINGS]'
6257 # The different iconv(3) implementations use different replacement sequence
6258 # types (character-wise, byte-wise, and the character(s) used differ)
6259 i="${MAILX_ICONV_MODE}"
6260 if [ -n "${i}" ]; then
6261 printf 'p\nx\n' | ${MAILX} ${ARGS} -Rf "${MBOX}" >./.tout 2>./.terr
6262 j=${?}
6263 check_ex0 5-1-estat ${j}
6264 check 5-1 - ./.terr '4294967295 0'
6265 if [ ${i} -eq 13 ]; then
6266 check 5-2 - ./.tout '189327996 283' # XXX old (before test MTA)
6267 elif [ ${i} -eq 12 ]; then
6268 check 5-3 - ./.tout '1959197095 283' # XXX old (before test MTA)
6269 elif [ ${i} -eq 3 ]; then
6270 check 5-4 - ./.tout '3544755786 278'
6271 else
6272 check 5-5 - ./.tout '2381160335 278'
6274 else
6275 t_echoskip '5:[test unsupported]'
6278 t_epilog "${@}"
6281 t_binary_mainbody() {
6282 t_prolog "${@}"
6284 printf 'abra\0\nka\r\ndabra' |
6285 ${MAILX} ${ARGS} ${ADDARG_UNI} -s 'binary with carriage-return!' \
6286 "${MBOX}" 2>./.terr
6287 check 1 0 "${MBOX}" '1629827 239'
6288 check 2 - ./.terr '4294967295 0'
6290 printf 'p\necho\necho writing now\nwrite ./.twrite\n' |
6291 ${MAILX} ${ARGS} -Rf \
6292 -Spipe-application/octet-stream="?* ${cat} > ./.tcat" \
6293 "${MBOX}" >./.tall 2>&1
6294 check 3 0 ./.tall '733582513 319'
6295 check 4 - ./.tcat '3817108933 15'
6296 check 5 - ./.twrite '3817108933 15'
6298 t_epilog "${@}"
6301 t_mime_force_sendout() {
6302 t_prolog "${@}"
6304 if have_feat iconv; then :; else
6305 t_echoskip '[!ICONV]'
6306 t_epilog "${@}"
6307 return
6310 printf '\150\303\274' > ./.tmba
6311 printf 'ha' > ./.tsba
6312 printf '' > "${MBOX}"
6314 printf '\150\303\244' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
6315 -s nogo \
6316 over-the@rain.bow 2>>${ERR}
6317 check 1 4 "${MBOX}" '4294967295 0'
6319 printf '\150\303\244' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
6320 -s go -Smime-force-sendout \
6321 over-the@rain.bow 2>>${ERR}
6322 check 2 0 "${MBOX}" '1866273282 219'
6324 printf ha | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
6325 -s nogo \
6326 -a ./.tmba over-the@rain.bow 2>>${ERR}
6327 check 3 4 "${MBOX}" '1866273282 219'
6329 printf ha | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
6330 -s go -Smime-force-sendout \
6331 -a ./.tmba over-the@rain.bow 2>>${ERR}
6332 check 4 0 "${MBOX}" '644433809 880'
6334 printf ha | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
6335 -s nogo \
6336 -a ./.tsba -a ./.tmba over-the@rain.bow 2>>${ERR}
6337 check 5 4 "${MBOX}" '644433809 880'
6339 printf ha | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
6340 -s go -Smime-force-sendout \
6341 -a ./.tsba -a ./.tmba over-the@rain.bow 2>>${ERR}
6342 check 6 0 "${MBOX}" '3172365123 1729'
6344 printf '\150\303\244' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
6345 -s nogo \
6346 -a ./.tsba -a ./.tmba over-the@rain.bow 2>>${ERR}
6347 check 7 4 "${MBOX}" '3172365123 1729'
6349 printf '\150\303\244' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
6350 -s go -Smime-force-sendout \
6351 -a ./.tsba -a ./.tmba over-the@rain.bow 2>>${ERR}
6352 check 8 0 "${MBOX}" '4002905306 2565'
6354 t_epilog "${@}"
6357 t_C_opt_customhdr() {
6358 t_prolog "${@}"
6360 echo bla |
6361 ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
6362 -C 'C-One : Custom One Body' \
6363 -C 'C-Two:CustomTwoBody' \
6364 -C 'C-Three: CustomThreeBody ' \
6365 -S customhdr='chdr1: chdr1 body, chdr2:chdr2 body, chdr3: chdr3 body ' \
6366 this-goes@nowhere >./.tall 2>&1
6367 check_ex0 1-estat
6368 ${cat} ./.tall >> "${MBOX}"
6369 check 1 0 "${MBOX}" '2535463301 238'
6371 ${rm} "${MBOX}"
6372 printf 'm this-goes@nowhere\nbody\n!.
6373 unset customhdr
6374 m this-goes2@nowhere\nbody2\n!.
6375 set customhdr=%ccustom1 : custom1 body%c
6376 m this-goes3@nowhere\nbody3\n!.
6377 set customhdr=%ccustom1 : custom1\\, body , \\
6378 custom2: custom2 body , custom-3 : custom3 body ,\\
6379 custom-4:custom4-body %c
6380 m this-goes4@nowhere\nbody4\n!.
6381 ' "'" "'" "'" "'" |
6382 ${MAILX} ${ARGS} -Smta=test://"$MBOX" -Sescape=! \
6383 -C 'C-One : Custom One Body' \
6384 -C 'C-Two:CustomTwoBody' \
6385 -C 'C-Three: CustomThreeBody ' \
6386 -C ' C-Four:CustomFourBody ' \
6387 -C 'C-Five:CustomFiveBody' \
6388 -S customhdr='ch1: b1 , ch2:b2, ch3:b3 ,ch4:b4, ch5: b5 ' \
6389 >./.tall 2>&1
6390 check_ex0 2-estat
6391 ${cat} ./.tall >> "${MBOX}"
6392 check 2 0 "${MBOX}" '544085062 1086'
6394 t_epilog "${@}"
6396 # }}}
6398 # Operational basics with trivial tests {{{
6399 t_alias() {
6400 t_prolog "${@}"
6402 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" > ./.tall 2>&1
6403 alias a1 ex1@a1.ple
6404 alias a1 ex2@a1.ple "EX3 <ex3@a1.ple>"
6405 alias a1 ex4@a1.ple
6406 alias a2 ex1@a2.ple ex2@a2.ple ex3@a2.ple ex4@a2.ple
6407 alias a3 a4
6408 alias a4 a5 ex1@a4.ple
6409 alias a5 a6
6410 alias a6 a7 ex1@a6.ple
6411 alias a7 a8
6412 alias a8 ex1@a8.ple
6413 alias a1
6414 alias a2
6415 alias a3
6416 m a1
6417 ~c a2
6418 ~b a3
6419 ~r - '_EOT'
6420 This body is!
6421 This also body is!!
6422 _EOT
6423 __EOT
6424 check 1 0 "${MBOX}" '139467786 277'
6425 check 2 - .tall '1598893942 133'
6427 if have_feat uistrings; then
6428 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
6429 commandalias x echo '$?/$^ERRNAME'
6430 echo 1
6431 alias a:bra! ha@m beb@ra ha@m '' zeb@ra ha@m; x
6432 alias a:bra!; x
6433 alias ha@m ham-expansion ha@m '';x
6434 alias ha@m;x
6435 alias beb@ra ceb@ra beb@ra1;x
6436 alias beb@ra;x
6437 alias ceb@ra ceb@ra1;x
6438 alias ceb@ra;x
6439 alias deb@ris '';x
6440 alias deb@ris;x
6441 echo 2
6442 alias - a:bra!;x
6443 alias - ha@m;x
6444 alias - beb@ra;x
6445 alias - ceb@ra;x
6446 alias - deb@ris;x
6447 echo 3
6448 unalias ha@m;x
6449 alias - a:bra!;x
6450 unalias beb@ra;x
6451 alias - a:bra!;x
6452 echo 4
6453 unalias*;x;alias;x
6454 echo 5
6455 \alias noexpa@and this@error1;x
6456 \alias ha@m '\noexp@and' expa@and \\noexp@and2;x
6457 \alias ha@m;x
6458 \alias - ha@m;x
6459 \alias noexpa@and2 this@error2;x
6460 \alias expa1@and this@error3;x
6461 \alias expa@and \\expa1@and;x
6462 \alias expa@and;x
6463 \alias - ha@m;x
6464 \alias - expa@and;x
6465 __EOT
6466 check 3 0 "${MBOX}" '1513155156 796'
6467 else
6468 t_echoskip '3:[!UISTRINGS]'
6471 # TODO t_alias: n_ALIAS_MAXEXP is compile-time constant,
6472 # TODO need to somehow provide its contents to the test, then test
6474 t_epilog "${@}"
6477 t_charsetalias() {
6478 t_prolog "${@}"
6480 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
6481 commandalias x echo '$?/$^ERRNAME'
6482 echo 1
6483 charsetalias latin1 latin15;x
6484 charsetalias latin1;x
6485 charsetalias - latin1;x
6486 echo 2
6487 charsetalias cp1252 latin1 latin15 utf8 utf8 utf16;x
6488 charsetalias cp1252;x
6489 charsetalias latin15;x
6490 charsetalias utf8;x
6491 echo 3
6492 charsetalias - cp1252;x
6493 charsetalias - latin15;x
6494 charsetalias - utf8;x
6495 echo 4
6496 charsetalias latin1;x
6497 charsetalias - latin1;x
6498 uncharsetalias latin15;x
6499 charsetalias latin1;x
6500 charsetalias - latin1;x
6501 __EOT
6502 check 1 0 "${MBOX}" '3551595280 433'
6504 t_epilog "${@}"
6507 t_shortcut() {
6508 t_prolog "${@}"
6510 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
6511 commandalias x echo '$?/$^ERRNAME'
6512 echo 1
6513 shortcut file1 expansion-of-file1;x
6514 shortcut file2 expansion-of-file2;x
6515 shortcut file3 expansion-of-file3;x
6516 shortcut file4 'expansion of file4' 'file 5' 'expansion of file5';x
6517 echo 2
6518 shortcut file1;x
6519 shortcut file2;x
6520 shortcut file3;x
6521 shortcut file4;x
6522 shortcut 'file 5';x
6523 echo 3
6524 shortcut;x
6525 __EOT
6526 check 1 0 "${MBOX}" '1970515669 430'
6528 t_epilog "${@}"
6531 t_netrc() {
6532 t_prolog "${@}"
6534 if have_feat netrc; then :; else
6535 t_echoskip '[!NETRC]'
6536 t_epilog "${@}"
6537 return
6540 printf '# comment
6541 machine x.local login a1 machine x.local login a2 password p2
6542 machine x.local login a3 password "p 3"
6543 machine
6544 pop.x.local
6545 login
6547 password
6548 p2-pop!
6549 machine *.x.local login a2 password p2-any!
6550 machine y.local login ausr password apass
6551 machine
6552 z.local password
6553 noupa
6554 # and unused default
6555 default login defacc password defpass
6556 ' > ./.tnetrc
6557 ${chmod} 0600 ./.tnetrc
6559 printf 'netrc;echo =$?;netrc c;echo =$?;netr loa;echo =$?;netr s;echo =$?' |
6560 NETRC=./.tnetrc ${MAILX} ${ARGS} > "${MBOX}" 2>&1
6561 check 1 0 "${MBOX}" '2911708535 542'
6563 have_feat uistrings && i='3076722625 893' || i='3808149439 645'
6564 printf '# Comment
6565 echo ==host
6566 netrc loo x.local
6567 netrc loo y.local
6568 netrc loo z.local
6569 echo ==(re)load cache
6570 netrc load;echo $?/$^ERRNAME
6571 echo ==usr@host
6572 netrc loo a1@x.local
6573 netrc loo a2@x.local
6574 netrc loo a3@x.local
6575 netrc loo a4@x.local
6576 echo ==clear cache
6577 netrc clear;echo $?/$^ERRNAME
6578 echo ==usr@x.host
6579 netrc loo a2@pop.x.local
6580 netrc loo a2@imap.x.local
6581 netrc loo a2@smtp.x.local
6582 echo ==usr@y.x.host
6583 netrc loo a2@nono.smtp.x.local
6584 echo ==[usr@]unknown-host
6585 netrc loo a.local
6586 netrc loo defacc@a.local
6587 netrc loo a1@a.local
6588 ' | NETRC=./.tnetrc ${MAILX} ${ARGS} > "${MBOX}" 2>&1
6589 check 2 0 "${MBOX}" "${i}"
6591 t_epilog "${@}"
6593 # }}}
6595 # Operational basics with easy tests {{{
6596 t_expandaddr() {
6597 # after: t_alias
6598 # MTA alias specific part in t_mta_aliases()
6599 # This only tests from command line, rest later on (iff any)
6600 t_prolog "${@}"
6602 if have_feat uistrings; then :; else
6603 t_echoskip '[!UISTRINGS]'
6604 t_epilog "${@}"
6605 return
6608 echo "${cat}" > ./.tcat
6609 ${chmod} 0755 ./.tcat
6612 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6613 -X'alias talias talias@exam.ple' \
6614 './.tfile' ' | ./.tcat > ./.tpipe' 'talias' 'taddr@exam.ple' \
6615 > ./.tall 2>&1
6616 check 1 4 "${MBOX}" '1216011460 138'
6617 check 2 - .tall '4169590008 162'
6620 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6621 -Sexpandaddr \
6622 -X'alias talias talias@exam.ple' \
6623 './.tfile' ' | ./.tcat >./.tpipe' 'talias' 'taddr@exam.ple' \
6624 > ./.tall 2>&1
6625 check 3 0 "${MBOX}" '847567042 276'
6626 check 4 - .tall '4294967295 0'
6627 check 5 - .tfile '1216011460 138'
6628 check 6 - .tpipe '1216011460 138'
6631 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6632 -Sexpandaddr=-all,+file,+pipe,+name,+addr \
6633 -X'alias talias talias@exam.ple' \
6634 './.tfile' ' | ./.tcat >./.tpipe' 'talias' 'taddr@exam.ple' \
6635 > ./.tall 2>&1
6636 check 7 0 "${MBOX}" '3682360102 414'
6637 check 8 - .tall '4294967295 0'
6638 check 9 - .tfile '847567042 276'
6639 check 10 - .tpipe '1216011460 138'
6642 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6643 -Sexpandaddr=-all,+file,-file,+pipe,+name,+addr \
6644 -X'alias talias talias@exam.ple' \
6645 './.tfile' ' | ./.tcat >./.tpipe' 'talias' 'taddr@exam.ple' \
6646 > ./.tall 2>&1
6647 check 11 4 "${MBOX}" '1010907786 552'
6648 check 12 - .tall '673208446 70'
6649 check 13 - .tfile '847567042 276'
6650 check 14 - .tpipe '1216011460 138'
6652 printf '' > ./.tpipe
6653 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6654 -Sexpandaddr=fail,-all,+file,-file,+pipe,+name,+addr \
6655 -X'alias talias talias@exam.ple' \
6656 './.tfile' ' | ./.tcat >./.tpipe' 'talias' 'taddr@exam.ple' \
6657 > ./.tall 2>&1
6658 check 15 4 "${MBOX}" '1010907786 552'
6659 check 16 - .tall '3280630252 179'
6660 check 17 - .tfile '847567042 276'
6661 check 18 - .tpipe '4294967295 0'
6664 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6665 -Sexpandaddr=-all,+file,+pipe,-pipe,+name,+addr \
6666 -X'alias talias talias@exam.ple' \
6667 './.tfile' ' | ./.tcat >./.tpipe' 'talias' 'taddr@exam.ple' \
6668 > ./.tall 2>&1
6669 check 19 4 "${MBOX}" '3359494254 690'
6670 check 20 - .tall '4052857227 91'
6671 check 21 - .tfile '3682360102 414'
6672 check 22 - .tpipe '4294967295 0'
6674 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6675 -Sexpandaddr=fail,-all,+file,+pipe,-pipe,+name,+addr \
6676 -X'alias talias talias@exam.ple' \
6677 './.tfile' ' | ./.tcat >./.tpipe' 'talias' 'taddr@exam.ple' \
6678 > ./.tall 2>&1
6679 check 23 4 "${MBOX}" '3359494254 690'
6680 check 24 - .tall '2168069102 200'
6681 check 25 - .tfile '3682360102 414'
6682 check 26 - .tpipe '4294967295 0'
6685 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6686 -Sexpandaddr=-all,+file,+pipe,+name,-name,+addr \
6687 -X'alias talias talias@exam.ple' \
6688 './.tfile' ' | ./.tcat >./.tpipe' 'talias' 'taddr@exam.ple' \
6689 > ./.tall 2>&1
6690 check 27 0 "${MBOX}" '3735108703 828'
6691 check 28 - .tall '4294967295 0'
6692 check 29 - .tfile '1010907786 552'
6693 check 30 - .tpipe '1216011460 138'
6695 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6696 -Sexpandaddr=-all,+file,+pipe,+name,-name,+addr \
6697 './.tfile' ' | ./.tcat >./.tpipe' 'talias' 'taddr@exam.ple' \
6698 > ./.tall 2>&1
6699 check 31 4 "${MBOX}" '4225234603 949'
6700 check 32 - .tall '3486613973 73'
6701 check 33 - .tfile '452731060 673'
6702 check 34 - .tpipe '1905076731 121'
6704 printf '' > ./.tpipe
6705 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6706 -Sexpandaddr=fail,-all,+file,+pipe,+name,-name,+addr \
6707 './.tfile' ' | ./.tcat >./.tpipe' 'talias' 'taddr@exam.ple' \
6708 > ./.tall 2>&1
6709 check 35 4 "${MBOX}" '4225234603 949'
6710 check 36 - .tall '3032065285 182'
6711 check 37 - .tfile '452731060 673'
6712 check 38 - .tpipe '4294967295 0'
6715 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6716 -Sexpandaddr=-all,+file,+pipe,+name,+addr,-addr \
6717 -X'alias talias talias@exam.ple' \
6718 './.tfile' ' | ./.tcat >./.tpipe' 'talias' 'taddr@exam.ple' \
6719 > ./.tall 2>&1
6720 check 39 4 "${MBOX}" '4225234603 949'
6721 check 40 - .tall '3863610168 169'
6722 check 41 - .tfile '1975297706 775'
6723 check 42 - .tpipe '130065764 102'
6725 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6726 -Sexpandaddr=-all,+file,+pipe,+name,+addr,-addr \
6727 -Sadd-file-recipients \
6728 -X'alias talias talias@exam.ple' \
6729 './.tfile' ' | ./.tcat >./.tpipe' 'talias' 'taddr@exam.ple' \
6730 > ./.tall 2>&1
6731 check 43 4 "${MBOX}" '4225234603 949'
6732 check 44 - .tall '3863610168 169'
6733 check 45 - .tfile '3291831864 911'
6734 check 46 - .tpipe '4072000848 136'
6736 printf '' > ./.tpipe
6737 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6738 -Sexpandaddr=fail,-all,+file,+pipe,+name,+addr,-addr \
6739 -Sadd-file-recipients \
6740 -X'alias talias talias@exam.ple' \
6741 './.tfile' ' | ./.tcat >./.tpipe' 'talias' 'taddr@exam.ple' \
6742 > ./.tall 2>&1
6743 check 47 4 "${MBOX}" '4225234603 949'
6744 check 48 - .tall '851041772 278'
6745 check 49 - .tfile '3291831864 911'
6746 check 50 - .tpipe '4294967295 0'
6749 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6750 -Sexpandaddr=-all,+addr \
6751 'taddr@exam.ple' 'this@@c.example' \
6752 > ./.tall 2>&1
6753 check 51 4 "${MBOX}" '473729143 1070'
6754 check 52 - .tall '2646392129 66'
6756 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6757 -Sexpandaddr=-all,failinvaddr \
6758 'taddr@exam.ple' 'this@@c.example' \
6759 > ./.tall 2>&1
6760 check 53 4 "${MBOX}" '473729143 1070'
6761 check 54 - .tall '887391555 175'
6764 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6765 -Sthis=taddr@exam.ple -Sexpandaddr \
6766 -c '\$this' -b '\$this' '\$this' \
6767 > ./.tall 2>&1
6768 check 55 4 "${MBOX}" '473729143 1070'
6769 check 56 - .tall '1144578880 139'
6771 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6772 -Sthis=taddr@exam.ple -Sexpandaddr=shquote \
6773 -c '\$this' -b '\$this' '\$this' \
6774 > ./.tall 2>&1
6775 check 57 0 "${MBOX}" '398243793 1191'
6776 check 58 - .tall '4294967295 0'
6779 printf '' > "${MBOX}"
6780 ${cat} <<-_EOT |\
6781 ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -t -ssub \
6782 -Sadd-file-recipients \
6783 -Sexpandaddr=-all,+fcc \
6784 > ./.tall 2>&1
6785 Fcc: .tfile1
6786 Fcc: .tfile2
6787 _EOT
6788 check 59 0 "${MBOX}" '4294967295 0'
6789 check 60 - .tall '4294967295 0'
6790 check 61 - .tfile1 '1067276522 124'
6791 check 62 - .tfile2 '1067276522 124'
6793 printf '' > "${MBOX}"
6794 ${cat} <<-_EOT |\
6795 ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -t -ssub \
6796 -Sadd-file-recipients \
6797 -Sexpandaddr=-all,+file \
6798 > ./.tall 2>&1
6799 Fcc: .tfile1
6800 Fcc: .tfile2
6801 _EOT
6802 check 63 0 "${MBOX}" '4294967295 0'
6803 check 64 - .tall '4294967295 0'
6804 check 65 - .tfile1 '2677253527 248'
6805 check 66 - .tfile2 '2677253527 248'
6807 printf '' > "${MBOX}"
6808 ${cat} <<-_EOT |\
6809 ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -t -ssub \
6810 -Sadd-file-recipients \
6811 -Sexpandaddr=-all,+file,-fcc \
6812 > ./.tall 2>&1
6813 Fcc: .tfile1
6814 Fcc: .tfile2
6815 _EOT
6816 check 67 0 "${MBOX}" '4294967295 0'
6817 check 68 - .tall '4294967295 0'
6818 check 69 - .tfile1 '3493511004 372'
6819 check 70 - .tfile2 '3493511004 372'
6821 printf '' > "${MBOX}"
6822 ${cat} <<-_EOT |\
6823 ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -t -ssub \
6824 -Sadd-file-recipients \
6825 -Sexpandaddr=-all,+fcc,-file \
6826 > ./.tall 2>&1
6827 Fcc: .tfile1
6828 Fcc: .tfile2
6829 _EOT
6830 check 71 4 "${MBOX}" '4294967295 0'
6831 check 72 - .tall '203687556 223'
6832 check 73 - .tfile1 '3493511004 372'
6833 check 74 - .tfile2 '3493511004 372'
6835 printf '' > "${MBOX}"
6836 ${cat} <<-_EOT |\
6837 ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -t -ssub \
6838 -Sadd-file-recipients \
6839 -Sexpandaddr=-all,fail,+addr \
6840 > ./.tall 2>&1
6841 Fcc: .tfile1
6842 Fcc: .tfile2
6843 To: never@exam.ple
6844 _EOT
6845 check 75 4 "${MBOX}" '4294967295 0'
6846 check 76 - .tall '4060426468 247'
6847 check 77 - .tfile1 '3493511004 372'
6848 check 78 - .tfile2 '3493511004 372'
6851 printf '' > "${MBOX}"
6852 ${cat} <<-_EOT |\
6853 ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -t -ssub \
6854 -Sexpandaddr=fail,domaincheck \
6855 > ./.tall 2>&1
6856 To: one@localhost
6857 _EOT
6858 check 79 0 "${MBOX}" '171635532 120'
6859 check 80 - .tall '4294967295 0'
6861 ${cat} <<-_EOT |\
6862 ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -t -ssub \
6863 -Sexpandaddr=domaincheck \
6864 > ./.tall 2>&1
6865 To: one@localhost , Hey two <two@exam.ple>, Trouble <three@tro.uble>
6866 _EOT
6867 check 81 4 "${MBOX}" '2659464839 240'
6868 check 82 - .tall '1119895397 158'
6870 ${cat} <<-_EOT |\
6871 ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -t -ssub \
6872 -Sexpandaddr=fail,domaincheck \
6873 > ./.tall 2>&1
6874 To: one@localhost , Hey two <two@exam.ple>, Trouble <three@tro.uble>
6875 _EOT
6876 check 83 4 "${MBOX}" '2659464839 240'
6877 check 84 - .tall '1577313789 267'
6879 ${cat} <<-_EOT |\
6880 ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -t -ssub \
6881 -Sexpandaddr=fail,domaincheck \
6882 -Sexpandaddr-domaincheck=exam.ple,tro.uble \
6883 > ./.tall 2>&1
6884 To: one@localhost , Hey two <two@exam.ple>, Trouble <three@tro.uble>
6885 _EOT
6886 check 85 0 "${MBOX}" '1670655701 410'
6887 check 86 - .tall '4294967295 0'
6889 t_epilog "${@}"
6892 t_mta_aliases() {
6893 # after: t_expandaddr
6894 t_prolog "${@}"
6896 if have_feat mta-aliases; then :; else
6897 t_echoskip '[!MTA_ALIASES]'
6898 t_epilog "${@}"
6899 return
6902 ${cat} > ./.tali <<- '__EOT'
6904 # Comment
6907 a1: ex1@a1.ple ,
6908 ex2@a1.ple, <ex3@a1.ple> ,
6909 ex4@a1.ple
6910 a2: ex1@a2.ple , ex2@a2.ple,a2_2
6911 a2_2:ex3@a2.ple,ex4@a2.ple
6912 a3: a4
6913 a4: a5,
6914 # Comment
6915 # More comment
6916 ex1@a4.ple
6917 # Comment
6918 a5: a6
6919 a6: a7 , ex1@a6.ple
6920 a7: a8,a9
6921 a8: ex1@a8.ple
6922 __EOT
6924 echo | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
6925 -Smta-aliases=./.tali \
6926 -b a3 -c a2 a1 > ./.tall 2>&1
6927 check 1 0 "${MBOX}" '1172368381 238'
6928 check 2 - .tall '4294967295 0'
6930 ## xxx The following are actually *expandaddr* tests!!
6932 # May not send plain names over SMTP!
6933 mtaali=
6934 if have_feat smtp; then
6935 echo | ${MAILX} ${ARGS} \
6936 -Smta=smtp://laber.backe -Ssmtp-auth=none \
6937 -Smta-aliases=./.tali \
6938 -b a3 -c a2 a1 > ./.tall 2>&1
6939 check_exn0 3
6940 check 4 - "${MBOX}" '1172368381 238'
6941 mtaali=1
6943 if [ -n "${mtaali}" ] && have_feat uistrings; then
6944 check 5 - .tall '771616226 179'
6945 else
6946 t_echoskip '5:[!SMTP/!UISTRINGS]'
6949 # xxx for false-positive SMTP test we would need some mocking
6950 echo | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
6951 -Sexpandaddr=fail,-name \
6952 -Smta-aliases=./.tali \
6953 -b a3 -c a2 a1 > ./.tall 2>&1
6954 check_exn0 6
6955 check 7 - "${MBOX}" '1172368381 238'
6956 if have_feat uistrings; then
6957 check 8 - .tall '2834389894 178'
6958 else
6959 t_echoskip '8:[!UISTRINGS]'
6962 echo | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
6963 -Sexpandaddr=-name \
6964 -Smta-aliases=./.tali \
6965 -b a3 -c a2 a1 > ./.tall 2>&1
6966 check 9 4 "${MBOX}" '2322273994 472'
6967 if have_feat uistrings; then
6968 check 10 - .tall '2136559508 69'
6969 else
6970 t_echoskip '10:[!UISTRINGS]'
6973 echo 'a9:nine@nine.nine' >> ./.tali
6975 echo | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
6976 -Sexpandaddr=fail,-name \
6977 -Smta-aliases=./.tali \
6978 -b a3 -c a2 a1 > ./.tall 2>&1
6979 check 11 0 "${MBOX}" '2422268299 722'
6980 check 12 - .tall '4294967295 0'
6982 printf '#
6983 set expandaddr=-name
6984 mail a1
6985 !c a2
6986 !:echo $?/$^ERRNAME
6987 !^header insert bcc a3
6988 !:echo $?/$^ERRNAME
6989 !:set expandaddr
6990 !t a1
6991 !c a2
6992 !:echo $?/$^ERRNAME
6993 !^header insert bcc a3
6994 !:echo $?/$^ERRNAME
6996 echo and, once again, check that cache is updated
6997 # Enclose one pipe in quotes: immense stress for our stupid address parser:(
6998 !echo "a10:./.tf1,|%s>./.tp1,\\"|%s > ./.tp2\\",./.tf2" >> ./.tali
6999 mtaaliases load
7000 mail a1
7001 !c a2
7002 !:echo $?/$^ERRNAME
7003 !^header insert bcc a3
7004 !:echo $?/$^ERRNAME
7006 echo trigger happiness
7007 mail a1
7008 !c a2
7009 !:echo $?/$^ERRNAME
7010 !^header insert bcc "a3 a10"
7011 !:echo $?/$^ERRNAME
7013 ' "${cat}" "${cat}" | ${MAILX} ${ARGS} -Smta=test://"$MBOX" -Sescape=! \
7014 -Smta-aliases=./.tali \
7015 > ./.tall 2>&1
7016 check 13 0 "${MBOX}" '550955032 1469'
7017 if have_feat uistrings; then
7018 check 14 - .tall '1795496020 473'
7019 else
7020 t_echoskip '14:[!UISTRINGS]'
7022 check 15 - .tf1 '3056269950 249'
7023 check 16 - .tp1 '3056269950 249'
7024 check 17 - .tp2 '3056269950 249'
7025 check 18 - .tf2 '3056269950 249'
7027 # TODO t_mta_aliases: n_ALIAS_MAXEXP is compile-time constant,
7028 # TODO need to somehow provide its contents to the test, then test
7030 t_epilog "${@}"
7033 t_filetype() {
7034 t_prolog "${@}"
7036 printf 'm m1@e.t\nL1\nHy1\n~.\nm m2@e.t\nL2\nHy2\n~@ %s\n~.\n' \
7037 "${TOPDIR}snailmail.jpg" | ${MAILX} ${ARGS} -Smta=test://"$MBOX"
7038 check 1 0 "${MBOX}" '1314354444 13536'
7040 if (echo | gzip -c) >/dev/null 2>&1; then
7042 printf 'File "%s"\ncopy 1 ./.t.mbox.gz\ncopy 2 ./.t.mbox.gz' \
7043 "${MBOX}" | ${MAILX} ${ARGS} \
7044 -X'filetype gz gzip\ -dc gzip\ -c'
7045 printf 'File ./.t.mbox.gz\ncopy * ./.t.mbox\n' |
7046 ${MAILX} ${ARGS} -X'filetype gz gzip\ -dc gzip\ -c'
7047 } > ./.t.out 2>&1
7048 check 2 - ./.t.mbox '1314354444 13536'
7049 check 3 - ./.t.out '635961640 103'
7050 else
7051 t_echoskip '2:[missing gzip(1)]'
7052 t_echoskip '3:[missing gzip(1)]'
7056 ${rm} ./.t.mbox*
7057 printf 'File "%s"\ncopy 1 ./.t.mbox.gz
7058 copy 2 ./.t.mbox.gz
7059 copy 1 ./.t.mbox.gz
7060 copy 2 ./.t.mbox.gz
7061 ' "${MBOX}" |
7062 ${MAILX} ${ARGS} \
7063 -X'filetype gz gzip\ -dc gzip\ -c' \
7064 -X'filetype mbox.gz "${sed} 1,3d|${cat}" \
7065 "echo eins;echo zwei;echo und mit ${sed} bist Du dabei;${cat}"'
7066 printf 'File ./.t.mbox.gz\ncopy * ./.t.mbox\n' |
7067 ${MAILX} ${ARGS} \
7068 -X'filetype gz gzip\ -dc gzip\ -c' \
7069 -X'filetype mbox.gz "${sed} 1,3d|${cat}" kill\ 0'
7070 } > ./.t.out 2>&1
7071 check 4 - ./.t.mbox '2687765142 27092'
7072 check 5 - ./.t.out '2230192693 173'
7074 t_epilog "${@}"
7077 t_e_H_L_opts() {
7078 t_prolog "${@}"
7080 touch ./.t.mbox
7081 ${MAILX} ${ARGS} -ef ./.t.mbox
7082 echo ${?} > "${MBOX}"
7084 printf 'm me@exam.ple\nLine 1.\nHello.\n~.\n' |
7085 ${MAILX} ${ARGS} -Smta=test://./.t.mbox
7086 printf 'm you@exam.ple\nLine 1.\nBye.\n~.\n' |
7087 ${MAILX} ${ARGS} -Smta=test://./.t.mbox
7089 ${MAILX} ${ARGS} -ef ./.t.mbox 2>> "${MBOX}"
7090 echo ${?} >> "${MBOX}"
7091 ${MAILX} ${ARGS} -efL @t@me ./.t.mbox 2>> "${MBOX}"
7092 echo ${?} >> "${MBOX}"
7093 ${MAILX} ${ARGS} -efL @t@you ./.t.mbox 2>> "${MBOX}"
7094 echo ${?} >> "${MBOX}"
7095 ${MAILX} ${ARGS} -efL '@>@Line 1' ./.t.mbox 2>> "${MBOX}"
7096 echo ${?} >> "${MBOX}"
7097 ${MAILX} ${ARGS} -efL '@>@Hello.' ./.t.mbox 2>> "${MBOX}"
7098 echo ${?} >> "${MBOX}"
7099 ${MAILX} ${ARGS} -efL '@>@Bye.' ./.t.mbox 2>> "${MBOX}"
7100 echo ${?} >> "${MBOX}"
7101 ${MAILX} ${ARGS} -efL '@>@Good bye.' ./.t.mbox 2>> "${MBOX}"
7102 echo ${?} >> "${MBOX}"
7104 ${MAILX} ${ARGS} -fH ./.t.mbox >> "${MBOX}" 2>&1
7105 echo ${?} >> "${MBOX}"
7106 ${MAILX} ${ARGS} -fL @t@me ./.t.mbox >> "${MBOX}" 2>&1
7107 echo ${?} >> "${MBOX}"
7108 ${MAILX} ${ARGS} -fL @t@you ./.t.mbox >> "${MBOX}" 2>&1
7109 echo ${?} >> "${MBOX}"
7110 ${MAILX} ${ARGS} -fL '@>@Line 1' ./.t.mbox >> "${MBOX}" 2>&1
7111 echo ${?} >> "${MBOX}"
7112 ${MAILX} ${ARGS} -fL '@>@Hello.' ./.t.mbox >> "${MBOX}" 2>&1
7113 echo ${?} >> "${MBOX}"
7114 ${MAILX} ${ARGS} -fL '@>@Bye.' ./.t.mbox >> "${MBOX}" 2>&1
7115 echo ${?} >> "${MBOX}"
7116 ${MAILX} ${ARGS} -fL '@>@Good bye.' ./.t.mbox >> "${MBOX}" 2>>${ERR}
7117 echo ${?} >> "${MBOX}"
7119 check 1 - "${MBOX}" '1369201287 670'
7123 printf 'm me1@exam.ple\n~s subject cab\nLine 1.\n~.\n' |
7124 ${MAILX} ${ARGS} -Smta=test://./.t.mbox \
7125 -r '' -X 'wysh set from=pony1@$LOGNAME'
7126 printf 'm me2@exam.ple\n~s subject bac\nLine 12.\n~.\n' |
7127 ${MAILX} ${ARGS} -Smta=test://./.t.mbox \
7128 -r '' -X 'wysh set from=pony2@$LOGNAME'
7129 printf 'm me3@exam.ple\n~s subject abc\nLine 123.\n~.\n' |
7130 ${MAILX} ${ARGS} -Smta=test://./.t.mbox \
7131 -r '' -X 'wysh set from=pony3@$LOGNAME'
7133 ${MAILX} ${ARGS} -S folder-hook=fh-test -X 'define fh-test {
7134 echo fh-test size; set autosort=size showname showto
7135 }' -fH ./.t.mbox > "${MBOX}" 2>&1
7136 check 2 0 "${MBOX}" '4286438644 413'
7138 ${MAILX} ${ARGS} -S folder-hook=fh-test -X 'define fh-test {
7139 echo fh-test subject; set autosort=subject showname showto
7140 }' -fH ./.t.mbox > "${MBOX}" 2>&1
7141 check 3 0 "${MBOX}" '3208053922 416'
7143 ${MAILX} ${ARGS} -S folder-hook=fh-test -X 'define fh-test {
7144 echo fh-test from; set autosort=from showto
7145 }' -fH ./.t.mbox > "${MBOX}" 2>&1
7146 check 4 0 "${MBOX}" '4209767839 413'
7148 ${MAILX} ${ARGS} -S folder-hook=fh-test -X 'define fh-test {
7149 echo fh-test to; set autosort=to showto
7150 }' -fH ./.t.mbox > "${MBOX}" 2>&1
7151 check 5 0 "${MBOX}" '2785342736 411'
7153 t_epilog "${@}"
7156 t_q_t_etc_opts() {
7157 # Simple, if we need more here, place in a later vim fold!
7158 t_prolog "${@}"
7160 # Three tests for MIME encoding and (a bit) content classification.
7161 # At the same time testing -q FILE, < FILE and -t FILE
7162 t__put_body > ./.tin
7164 < ./.tin ${MAILX} ${ARGS} ${ADDARG_UNI} \
7165 -a ./.tin -s "`t__put_subject`" "${MBOX}"
7166 check 1 0 "${MBOX}" '1088822685 6642'
7168 ${rm} "${MBOX}"
7169 < /dev/null ${MAILX} ${ARGS} ${ADDARG_UNI} \
7170 -a ./.tin -s "`t__put_subject`" -q ./.tin "${MBOX}"
7171 check 2 0 "${MBOX}" '1088822685 6642'
7173 ${rm} "${MBOX}"
7174 ( echo "To: ${MBOX}" && echo "Subject: `t__put_subject`" && echo &&
7175 ${cat} ./.tin
7176 ) | ${MAILX} ${ARGS} ${ADDARG_UNI} -Snodot -a ./.tin -t
7177 check 3 0 "${MBOX}" '1088822685 6642'
7179 # Check comments in the header
7180 ${rm} "${MBOX}"
7181 ${cat} <<-_EOT | ${MAILX} ${ARGS} -Snodot -t "${MBOX}"
7182 # Ein Kommentar
7183 From: du@da
7184 # Noch ein Kommentar
7185 Subject : hey you
7186 # Nachgestelltes Kommentar
7188 BOOOM
7189 _EOT
7190 check 4 0 "${MBOX}" '4161555890 124'
7192 # ?MODifier suffix
7193 printf '' > "${MBOX}"
7194 ( echo 'To?single : ./.tout1 .tout2 ' &&
7195 echo 'CC: ./.tcc1 ./.tcc2' &&
7196 echo 'BcC?sin : ./.tbcc1 .tbcc2 ' &&
7197 echo 'To? : ./.tout3 .tout4 ' &&
7198 echo &&
7199 echo body
7200 ) | ${MAILX} ${ARGS} ${ADDARG_UNI} -Snodot -t -Smta=test://"$MBOX"
7201 check 5 0 './.tout1 .tout2' '2948857341 94'
7202 check 6 - ./.tcc1 '2948857341 94'
7203 check 7 - ./.tcc2 '2948857341 94'
7204 check 8 - './.tbcc1 .tbcc2' '2948857341 94'
7205 check 9 - './.tout3 .tout4' '2948857341 94'
7206 check 10 - "${MBOX}" '4294967295 0'
7208 t_epilog "${@}"
7211 t_message_injections() {
7212 # Simple, if we need more here, place in a later vim fold!
7213 t_prolog "${@}"
7215 echo mysig > ./.tmysig
7217 echo some-body | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
7218 -Smessage-inject-head=head-inject \
7219 -Smessage-inject-tail="`${cat} ./.tmysig`"'\ntail-inject' \
7220 ex@am.ple > ./.tall 2>&1
7221 check 1 0 "${MBOX}" '701778583 143'
7222 check 2 - .tall '4294967295 0' # empty file
7224 ${rm} "${MBOX}"
7225 ${cat} <<-_EOT > ./.template
7226 From: me
7227 To: ex1@am.ple
7228 Cc: ex2@am.ple
7229 Subject: This subject is
7231 Body, body, body me.
7232 _EOT
7233 < ./.template ${MAILX} ${ARGS} -t -Smta=test://"$MBOX" \
7234 -Smessage-inject-head=head-inject \
7235 -Smessage-inject-tail="`${cat} ./.tmysig`\n"'tail-inject' \
7236 > ./.tall 2>&1
7237 check 3 0 "${MBOX}" '2189109479 207'
7238 check 4 - .tall '4294967295 0' # empty file
7240 t_epilog "${@}"
7243 t_attachments() {
7244 # TODO More should be in compose mode stuff aka digmsg
7245 t_prolog "${@}"
7247 ${cat} <<-_EOT > ./.tx
7248 From steffen Sun Feb 18 02:48:40 2018
7249 Date: Sun, 18 Feb 2018 02:48:40 +0100
7251 Subject: m1
7252 User-Agent: s-nail v14.9.7
7255 From steffen Sun Feb 18 02:48:42 2018
7256 Date: Sun, 18 Feb 2018 02:48:42 +0100
7258 Subject: m2
7259 User-Agent: s-nail v14.9.7
7262 _EOT
7263 echo att1 > ./.t1
7264 printf 'att2-1\natt2-2\natt2-4\n' > ./'.t 2'
7265 printf 'att3-1\natt3-2\natt3-4\n' > ./.t3
7266 printf 'att4-1\natt4-2\natt4-4\n' > './.t 4'
7268 printf \
7269 '!@ ./.t3 "./.t 4" ""
7272 ./.t3
7273 "./.t 2"
7276 !.' \
7277 | ${MAILX} ${ARGS} -Sescape=! -Smta=test://"$MBOX" \
7278 -a ./.t1 -a './.t 2' \
7279 -s attachment-test \
7280 ex@am.ple > ./.tall 2>&1
7281 check 1 0 "${MBOX}" '2484200149 644'
7282 if have_feat uistrings; then
7283 check 2 - .tall '1928331872 720'
7284 else
7285 t_echoskip '2:[!UISTRINGS]'
7288 ${rm} "${MBOX}"
7289 printf \
7290 'mail ex@amp.ple
7291 !s This the subject is
7292 !@ ./.t3 "#2" "./.t 4" "#1" ""
7295 "./.t 4"
7296 "#2"
7300 mail ex@amp.ple
7301 !s Subject two
7302 !@ ./.t3 "#2" "./.t 4" "#1" ""
7308 mail ex@amp.ple
7309 !s Subject three
7310 !@ ./.t3 "" "#2" "" "./.t 4" "" "#1" ""
7313 ./.t3
7317 mail ex@amp.ple
7318 !s Subject Four
7319 !@ ./.t3 "" "#2" "" "./.t 4" "" "#1" ""
7322 "#1"
7326 mail ex@amp.ple
7327 !s Subject Five
7329 "#2"
7332 !.' \
7333 | ${MAILX} ${ARGS} -Sescape=! -Smta=test://"$MBOX" -Rf ./.tx \
7334 > ./.tall 2>&1
7335 check 3 0 "${MBOX}" '3637385058 2335'
7336 if have_feat uistrings; then
7337 check 4 - .tall '2526106274 1910'
7338 else
7339 t_echoskip '4:[!UISTRINGS]'
7342 ${rm} "${MBOX}"
7343 printf \
7344 'mail ex@amp.ple
7345 !s Subject One
7346 !@ "#."
7347 Body one.
7350 from 2
7351 mail ex@amp.ple
7352 !s Subject Two
7354 "#."
7356 Body two.
7359 reply 1 2
7360 !@ "#."
7364 "#."
7367 !.' \
7368 | ${MAILX} ${ARGS} -Sescape=! -Smta=test://"$MBOX" -Rf ./.tx \
7369 > ./.tall 2>&1
7370 check 5 0 "${MBOX}" '1604688179 2316'
7371 if have_feat uistrings; then
7372 check 6 - .tall '1210753005 508'
7373 else
7374 t_echoskip '6:[!UISTRINGS]'
7379 # Content-ID:
7380 </dev/null ${MAILX} ${ARGS} -Smta=test \
7381 -Sstealthmua=noagent -Shostname \
7382 -a ./.t1 -a './.t 2' \
7383 -a ./.t3 -a './.t 4' \
7384 -s Y \
7385 ex@am.ple > ./.tall 2>&1
7386 check 7 0 .tall '1003537919 1262'
7388 # input charset
7389 </dev/null ${MAILX} ${ARGS} -Smta=test -Sttycharset=utf8 \
7390 -a ./.t1=ascii -a './.t 2'=LATin1 \
7391 -a ./.t3=UTF-8 -a './.t 4'=- \
7392 -s Y \
7393 ex@am.ple > ./.tall 2>&1
7394 check 8 0 .tall '361641281 921'
7396 # input+output charset, no iconv
7397 </dev/null ${MAILX} ${ARGS} -Smta=test \
7398 -a ./.t1=ascii#- -a './.t 2'=LATin1#- \
7399 -a ./.t3=UTF-8#- -a './.t 4'=utf8#- \
7400 -s Y \
7401 ex@am.ple > ./.tall 2>&1
7402 check 9 0 .tall '1357456844 933'
7404 if have_feat iconv; then
7405 printf 'ein \303\244ffchen und ein pferd\n' > .t10-f1
7406 if (< .t10-f1 iconv -f ascii -t utf8) >/dev/null 2>&1; then
7407 </dev/null ${MAILX} ${ARGS} --set mta=test \
7408 --set stealthmua=noagent --set hostname \
7409 --attach ./.t1=-#utf8 \
7410 --attach ./.t10-f1=utf8#latin1 \
7411 --subject Y \
7412 ex@am.ple > ./.tall 2>&1
7413 check 10 0 .tall '1257664842 877'
7414 else
7415 t_echoskip '10:[ICONV/iconv(1):missing conversion(1)]'
7417 else
7418 t_echoskip '10:[!ICONV]'
7421 t_epilog "${@}"
7424 t_rfc2231() {
7425 # (after attachments)
7426 t_prolog "${@}"
7429 mkdir ./.ttt || exit 1
7430 cd ./.ttt || exit 2
7431 : > "ma'ger.txt"
7432 : > "mä'ger.txt"
7433 : > 'diet\ is \curd.txt'
7434 : > 'diet "is" curd.txt'
7435 : > höde-tröge.txt
7436 : > 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
7437 : > höde__tröge__müde__dätte__hätte__vuelle__guelle__aese__aesse__sauerliche__kräuter__österliche__grüße__mäh.txt
7438 : > hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt
7439 : > ✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt
7441 echo bla | ${MAILX} ${ARGS} ${ADDARG_UNI} \
7442 -a "./.ttt/ma'ger.txt" -a "./.ttt/mä'ger.txt" \
7443 -a './.ttt/diet\ is \curd.txt' -a './.ttt/diet "is" curd.txt' \
7444 -a ./.ttt/höde-tröge.txt \
7445 -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 \
7446 -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 \
7447 -a ./.ttt/hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt \
7448 -a ./.ttt/✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt \
7449 "${MBOX}"
7450 check 1 0 "${MBOX}" '3720896054 3088'
7452 # `resend' test, reusing $MBOX
7453 printf "Resend ./.t2\nx\n" | ${MAILX} ${ARGS} -Rf "${MBOX}"
7454 check 2 0 ./.t2 '3720896054 3088'
7456 printf "resend ./.t3\nx\n" | ${MAILX} ${ARGS} -Rf "${MBOX}"
7457 check 3 0 ./.t3 '3979736592 3133'
7459 # And a primitive test for reading messages with invalid parameters
7460 ${cat} <<-_EOT > ./.tinv
7461 From a@b.invalid Wed May 15 12:43:00 2018
7462 MIME-Version: 1.0
7463 Content-Type: multipart/mixed; boundary="1"
7465 This is a multi-part message in MIME format.
7467 Content-Type: text/plain; charset=UTF-8
7468 Content-Transfer-Encoding: quoted-printable
7472 Content-Type: text/plain; name*17="na"; name*18="me-c-t"
7473 Content-Transfer-Encoding: 7bit
7474 Content-Disposition: inline
7477 --1--
7479 From a@b.invalid Wed May 15 12:43:00 2018
7480 MIME-Version: 1.0
7481 Content-Type: multipart/mixed; boundary="2"
7483 This is a multi-part message in MIME format.
7485 Content-Type: text/plain; charset=UTF-8
7486 Content-Transfer-Encoding: quoted-printable
7490 Content-Type: text/plain; name*17="na"; name*18="me-c-t"
7491 Content-Transfer-Encoding: 7bit
7492 Content-Disposition: inline;
7493 filename*0="na";
7494 filename*998999999999999999999999999999="me-c-d"
7497 --2--
7499 From a@b.invalid Wed May 15 12:43:00 2018
7500 MIME-Version: 1.0
7501 Content-Type: multipart/mixed; boundary="3"
7503 This is a multi-part message in MIME format.
7505 Content-Type: text/plain; charset=UTF-8
7506 Content-Transfer-Encoding: quoted-printable
7510 Content-Type: text/plain; name*17="na"; name*18="me-c-t"
7511 Content-Transfer-Encoding: 7bit
7512 Content-Disposition: inline;
7513 filename*0="na"; filename*998="me-c-d"
7516 --3--
7517 _EOT
7519 printf '\\#
7520 \\headerpick type ignore Content-Type Content-Disposition
7521 \\type 1 2 3
7522 \\xit
7523 ' | ${MAILX} ${ARGS} -Rf ./.tinv > ./.tall 2> ./.terr
7524 check 4 0 ./.tall '4094731083 905'
7525 if have_feat uistrings && have_feat iconv; then
7526 check 5 - ./.terr '3713266499 473'
7527 else
7528 t_echoskip '5:[!UISTRINGS or !ICONV]'
7531 t_epilog "${@}"
7534 t_mime_types_load_control() {
7535 t_prolog "${@}"
7537 if have_feat uistrings; then :; else
7538 t_echoskip '[!UISTRINGS]'
7539 t_epilog "${@}"
7540 return
7543 ${cat} <<-_EOT > ./.tmts1
7544 ? application/mathml+xml mathml
7545 _EOT
7546 ${cat} <<-_EOT > ./.tmts2
7547 ? x-conference/x-cooltalk ice
7548 ?t aga-aga aga
7549 ? application/aga-aga aga
7550 _EOT
7552 ${cat} <<-_EOT > ./.tmts1.mathml
7553 <head>nonsense ML</head>
7554 _EOT
7555 ${cat} <<-_EOT > ./.tmts2.ice
7556 Icy, icy road.
7557 _EOT
7558 printf 'of which the c\x01rack is coming soon' > ./.tmtsx.doom
7559 printf 'of which the c\x01rack is coming soon' > ./.tmtsx.aga
7561 printf '
7562 m %s
7563 Schub-di-du
7564 ~@ ./.tmts1.mathml
7565 ~@ ./.tmts2.ice
7566 ~@ ./.tmtsx.doom
7567 ~@ ./.tmtsx.aga
7569 File %s
7570 from*
7571 type
7573 ' "${MBOX}" "${MBOX}" |
7574 ${MAILX} ${ARGS} \
7575 -Smimetypes-load-control=f=./.tmts1,f=./.tmts2 \
7576 > ./.tout 2>&1
7577 check_ex0 1-estat
7578 ${cat} "${MBOX}" >> ./.tout
7579 check 1 - ./.tout '2128819500 2441'
7581 echo type | ${MAILX} ${ARGS} -R \
7582 -Smimetypes-load-control=f=./.tmts1,f=./.tmts3 \
7583 -f "${MBOX}" >> ./.tout 2>&1
7584 check 2 0 ./.tout '1125106528 3642'
7586 t_epilog "${@}"
7588 # }}}
7590 # Around state machine, after basics {{{
7591 t_alternates() {
7592 t_prolog "${@}"
7594 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" > ./.tall 2>&1
7595 commandalias x echo '$?/$^ERRNAME'
7596 commandalias y echo '$?/$^ERRNAME <$rv>'
7597 echo --0
7598 alternates;x
7599 alternates a1@b1 a2@b2 a3@b3;x
7600 alternates;x
7601 vput alternates rv;y
7603 echo --1
7604 unalternates a2@b2
7605 vput alternates rv;y
7606 unalternates a3@b3
7607 vput alternates rv;y
7608 unalternates a1@b1
7609 vput alternates rv;y
7611 echo --2
7612 unalternates *
7613 alternates a1@b1 a2@b2 a3@b3
7614 unalternates a3@b3
7615 vput alternates rv;y
7616 unalternates a2@b2
7617 vput alternates rv;y
7618 unalternates a1@b1
7619 vput alternates rv;y
7621 echo --3
7622 alternates a1@b1 a2@b2 a3@b3
7623 unalternates a1@b1
7624 vput alternates rv;y
7625 unalternates a2@b2
7626 vput alternates rv;y
7627 unalternates a3@b3
7628 vput alternates rv;y
7630 echo --4
7631 unalternates *
7632 alternates a1@b1 a2@b2 a3@b3
7633 unalternates *
7634 vput alternates rv;y
7636 echo --5
7637 unalternates *
7638 alternates a1@b1 a1@c1 a1@d1 a2@b2 a3@b3 a3@c3 a3@d3
7639 m a1@b1 a1@c1 a1@d1
7640 ~s all alternates, only a1@b1 remains
7641 ~c a2@b2
7642 ~b a3@b3 a3@c3 a3@d3
7643 ~r - '_EOT'
7644 This body is!
7645 This also body is!!
7646 _EOT
7649 echo --6
7650 unalternates *
7651 alternates a1@b1 a1@c1 a2@b2 a3@b3
7652 m a1@b1 a1@c1 a1@d1
7653 ~s a1@b1 a1@d1, and a3@c3 a3@d3 remain
7654 ~c a2@b2
7655 ~b a3@b3 a3@c3 a3@d3
7656 ~r - '_EOT'
7657 This body2 is!
7658 _EOT
7661 echo --7
7662 alternates a1@b1 a2@b2 a3; set allnet
7663 m a1@b1 a1@c1 a1@d1
7664 ~s all alternates via allnet, only a1@b1 remains
7665 ~c a2@b2
7666 ~b a3@b3 a3@c3 a3@d3
7667 ~r - '_EOT'
7668 This body3 is!
7669 _EOT
7672 echo --10
7673 unalternates *
7674 alternates a1@b1;x
7675 vput alternates rv;y
7676 alternates a2@b2;x
7677 vput alternates rv;y
7678 alternates a3@b3;x
7679 vput alternates rv;y
7680 alternates a4@b4;x
7681 vput alternates rv;y
7683 unalternates *
7684 vput alternates rv;y
7686 echo --11
7687 set posix
7688 alternates a1@b1 a2@b2;x
7689 vput alternates rv;y
7690 alternates a3@b3 a4@b4;x
7691 vput alternates rv;y
7692 __EOT
7694 check 1 0 "${MBOX}" '3901995195 542'
7695 if have_feat uistrings; then
7696 check 2 - .tall '1878598364 505'
7697 else
7698 t_echoskip '2:[!UISTRINGS]'
7701 # Automatic alternates, also from command line (freezing etc.)
7702 ${rm} "${MBOX}"
7703 ${cat} <<- __EOT > ./.tin
7704 From trouble-report@desy Wed Jun 6 20:19:28 2018
7705 Date: Wed, 06 Jun 2018 19:58:02 +0200
7706 From: a@b.org, b@b.org, c@c.org
7707 Sender: a@b.org
7708 To: b@b.org
7709 Cc: a@b.org, c@c.org
7710 Subject: test
7711 Message-ID: <20180606175802.dw-cn%a@b.org>
7713 sultry
7715 __EOT
7717 printf '#
7718 reply
7719 !^header remove to
7720 !^header remove cc
7721 !^header remove subject
7722 !^header insert to b@b.org
7723 !^header insert cc "a@b.org b@b.org c@c.org"
7724 my body
7726 ' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" -Sescape=! \
7727 -S from=a@b.org,b@b.org,c@c.org -S sender=a@b.org \
7728 -Rf ./.tin > ./.tall 2>&1
7729 check 3 0 "${MBOX}" '3184203976 265'
7730 check 4 - .tall '3604001424 44'
7732 # same, per command
7733 printf '#
7734 set from=a@b.org,b@b.org,c@c.org sender=a@b.org
7735 reply
7736 !^header remove to
7737 !^header remove cc
7738 !^header remove subject
7739 !^header insert to b@b.org
7740 !^header insert cc "a@b.org b@b.org c@c.org"
7741 my body
7743 ' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" -Sescape=! \
7744 -Rf ./.tin > ./.tall 2>&1
7745 check 5 0 "${MBOX}" '98184290 530'
7746 check 6 - .tall '3604001424 44'
7748 # And more, with/out -r (and that Sender: vanishs as necessary)
7749 # TODO -r should be the Sender:, which should automatically propagate to
7750 # TODO From: if possible and/or necessary. It should be possible to
7751 # TODO suppres -r stuff from From: and Sender:, but fallback to special -r
7752 # TODO arg as appropriate.
7753 # TODO For now we are a bit messy
7755 ${rm} "${MBOX}"
7756 </dev/null ${MAILX} ${ARGS} -Smta=test://"$MBOX" -s '-Sfrom + -r ++ test' \
7757 -c a@b.example -c b@b.example -c c@c.example \
7758 -S from=a@b.example,b@b.example,c@c.example \
7759 -S sender=a@b.example \
7760 -r a@b.example b@b.example ./.tout >./.tall 2>&1
7761 check 7 0 "${MBOX}" '4275947318 181'
7762 check 8 - .tout '4275947318 181'
7763 check 9 - .tall '4294967295 0'
7765 </dev/null ${MAILX} ${ARGS} -Smta=test://"$MBOX" -s '-Sfrom + -r ++ test' \
7766 -c a@b.example -c b@b.example -c c@c.example \
7767 -S from=a@b.example,b@b.example,c@c.example \
7768 -S sender=a2@b.example \
7769 -r a@b.example b@b.example ./.tout >./.tall 2>&1
7770 check 10 0 "${MBOX}" '1189494079 383'
7771 check 11 - .tout '1189494079 383'
7772 check 12 - .tall '4294967295 0'
7774 </dev/null ${MAILX} ${ARGS} -Smta=test://"$MBOX" -s '-Sfrom + -r ++ test' \
7775 -c a@b.example -c b@b.example -c c@c.example \
7776 -S from=a@b.example,b@b.example,c@c.example \
7777 -S sender=a@b.example \
7778 b@b.example >./.tall 2>&1
7779 check 13 0 "${MBOX}" '2253033142 610'
7780 check 14 - .tall '4294967295 0'
7782 t_epilog "${@}"
7785 t_cmd_escapes() {
7786 # quote and cmd escapes because this (since Mail times) is worked in the
7787 # big collect() monster of functions
7788 t_prolog "${@}"
7790 echo 'included file' > ./.ttxt
7791 { t__x1_msg && t__x2_msg && t__x3_msg &&
7792 t__gen_msg from 'ex4@am.ple' subject sub4 &&
7793 t__gen_msg from 'eximan <ex5@am.ple>' subject sub5 &&
7794 t__gen_mimemsg from 'ex6@am.ple' subject sub6; } > ./.tmbox
7795 check 1 - ./.tmbox '517368276 2182'
7797 # ~@ is tested with other attachment stuff, ~^ is in compose_edits + digmsg
7798 printf '#
7799 set Sign=SignVar sign=signvar DEAD=./.ttxt
7800 set forward-inject-head quote-inject-head
7801 headerpick type retain Subject
7802 headerpick forward retain Subject To
7803 reply 2
7804 !!1 Not escaped. And shell test last, right before !..
7805 !:echo 1
7806 !: echo 2 only echoed via colon
7807 !:echo 2:$?/$^ERRNAME
7808 !_ echo 3 only echoed via underscore
7809 !:echo 3:$?/$^ERRNAME
7810 !< ./.ttxt
7811 !:echo 4:$?/$^ERRNAME
7812 !<! echo 5 shell echo included
7813 !:echo 5:$?/$^ERRNAME
7814 !| echo 6 pipecmd-pre; cat; echo 6 pipecmd-post
7815 !:echo 6:$?/$^ERRNAME
7816 7 and 8 are ~A and ~a:
7818 !:echo 7:$?/$^ERRNAME
7820 !:echo 8:$?/$^ERRNAME
7821 !b 9 added ~b cc <ex1@am.ple>
7822 !:echo 9:$?/$^ERRNAME
7823 !c 10 added ~c c <ex2@am.ple>
7824 !:echo 10:$?/$^ERRNAME
7825 11 next ~d / $DEAD
7827 !:echo 11:$?/$^ERRNAME
7828 12: ~F
7830 !:echo 12:$?/$^ERRNAME
7831 13: ~F 1 3
7832 !F 1 3
7833 !:echo 13:$?/$^ERRNAME
7834 !F 1000
7835 !:echo 13-1:$?/$^ERRNAME; set posix
7836 14: ~f (headerpick: subject)
7838 !:echo 14:$?/$^ERRNAME; unset posix forward-inject-head quote-inject-head
7839 14.1: ~f (!posix: injections; headerpick: subject to)
7841 !:echo 14.1:$?/$^ERRNAME; set forward-add-cc
7842 14.2: ~f (!posix: headerpick: subject to; forward-add-cc adds mr3)
7843 !f 3
7844 !:echo 14.2:$?/$^ERRNAME; set fullnames
7845 14.3: ~f (!posix: headerpick: subject to; forward-add-cc adds mr1 fullname)
7846 !f 1
7847 !:echo 14.3:$?/$^ERRNAME; set nofullnames noforward-add-cc posix
7848 15: ~f 1
7849 !f 1
7850 !:echo 15:$?/$^ERRNAME
7851 15.5: nono: ~H, ~h
7853 !:echo 15.5-1:$?/$^ERRNAME
7855 !:echo 15.5-2:$?/$^ERRNAME
7856 16, 17: ~I Sign, ~i Sign
7857 !I Sign
7858 !:echo 16:$?/$^ERRNAME
7859 !i Sign
7860 !:echo 17:$?/$^ERRNAME
7861 18: ~M
7863 !:echo 18:$?/$^ERRNAME # XXX forward-add-cc: not expl. tested
7864 19: ~M 1
7865 !M 1
7866 !:echo 19:$?/$^ERRNAME
7867 20: ~m
7869 !:echo 20:$?/$^ERRNAME # XXX forward-add-cc: not expl. tested
7870 21: ~m 3
7871 !m 3
7872 !:echo 21:$?/$^ERRNAME
7873 !: # Initially ~Q was _exactly_ like
7874 28,29 nothing, 30-34: ~Q
7875 !:echo quote=<$quote>
7876 30: ~Q
7878 !:echo 30:$?/$^ERRNAME
7879 31: ~Q 1 3
7880 !Q 1 3
7881 !:echo 31:$?/$^ERRNAME
7882 set quote-inject-head quote-inject-tail indentprefix
7883 !:wysh set quote-inject-head=%%a quote-inject-tail=--%%r
7884 32: ~Q
7886 !:echo 32:$?/$^ERRNAME
7887 set noquote-inject-head noquote-inject-tail quote-add-cc
7888 !:set noquote-inject-head noquote-inject-tail quote-add-cc
7889 33: ~Q 4
7890 !Q 4
7891 !:echo 33:$?/$^ERRNAME
7892 set fullnames
7893 !:set fullnames
7894 34: ~Q 5
7895 !Q 5
7896 !:echo 34:$?/$^ERRNAME
7897 unset fullnames, quote stuff
7898 !:unset quote quote-add-cc fullnames
7899 22: ~R ./.ttxt
7900 !R ./.ttxt
7901 !:echo 22:$?/$^ERRNAME
7902 23: ~r ./.ttxt
7903 !r ./.ttxt
7904 !:echo 23:$?/$^ERRNAME
7905 24: ~s this new subject
7906 !s 24 did new ~s ubject
7907 !:echo 24:$?/$^ERRNAME
7908 !t 25 added ~t o <ex3@am.ple>
7909 !:echo 25:$?/$^ERRNAME
7910 26.1: ~U
7912 !:echo 26.1:$?/$^ERRNAME
7913 26.2: ~U 1
7914 !U 1
7915 !:echo 26.2:$?/$^ERRNAME # XXX forward-add-cc: not expl. tested
7916 27.1: ~u
7918 !:echo 27.1:$?/$^ERRNAME
7919 27.2: ~u 1
7920 !u 1
7921 !:echo 27.2:$?/$^ERRNAME # XXX forward-add-cc: not expl. tested
7922 and i ~w rite this out to ./.tmsg
7923 !w ./.tmsg
7924 !:echo i ~w:$?/$^ERRNAME
7925 !:wysh set x=$escape;set escape=~
7926 ~!echo shell command output
7927 ~:echo shell:$?/$^ERRNAME
7928 ~:wysh set escape=$x
7929 50:F
7930 !F 6
7931 !:echo 50 was F:$?/$^ERRNAME
7932 51:f
7933 !f 6
7934 !:echo 51 was f:$?/$^ERRNAME
7935 52:M
7936 !M 6
7937 !:echo 52 was M:$?/$^ERRNAME
7938 53:m
7939 !m 6
7940 !:echo 53 was m:$?/$^ERRNAME; set quote
7941 54:Q
7942 !Q 6
7943 !:echo 54 was Q:$?/$^ERRNAME
7944 55:U
7945 !U 6
7946 !:echo 55 was U:$?/$^ERRNAME
7947 56:u
7948 !u 6
7949 !:echo 56 was u:$?/$^ERRNAME
7951 ' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" -Rf \
7952 -Sescape=! -Sindentprefix=' |' \
7953 ./.tmbox >./.tall 2>./.terr
7954 check_ex0 2-estat
7955 ${cat} ./.tall >> "${MBOX}"
7956 have_feat filter-html-tagsoup && ck='3877629593 7699' ||
7957 ck='2138694045 7943'
7958 check 2 - "${MBOX}" "${ck}"
7960 if have_feat uistrings && have_feat iconv; then
7961 check 2-err - ./.terr '3575876476 49'
7962 else
7963 t_echoskip '2-err:[!UISTRINGS or !ICONV]'
7965 check 3 - ./.tmsg '3502750368 4445'
7967 # Simple return/error value after *expandaddr* failure test
7968 have_feat filter-html-tagsoup && ck='115245837 7900' ||
7969 ck='2245417271 8144'
7970 printf 'body
7971 !:echo --one
7972 !s This a new subject is
7973 !:set expandaddr=-name
7974 !t two@to.invalid
7975 !:echo $?/$^ERRNAME
7976 !:echo --two
7977 !c no-name-allowed
7978 !:echo $?/$^ERRNAME
7979 !c one@cc.invalid
7980 !:echo $?/$^ERRNAME
7981 !:echo --three
7982 !:alias abcc one@bcc.invalid
7983 !b abcc
7984 !:echo $?/$^ERRNAME
7985 !:set expandaddr=+addr
7986 !b abcc
7987 !:echo $!/$?/$^ERRNAME
7989 ' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
7990 -Sescape=! \
7991 -s testsub one@to.invalid >./.tall 2>&1
7992 check 4 0 "${MBOX}" "${ck}"
7993 if have_feat uistrings; then
7994 check 5 - ./.tall '2336041127 212'
7995 else
7996 check 5 - ./.tall '1818580177 59'
7999 # Modifiers and whitespace indulgence
8000 printf 'body
8001 !:remove '"${MBOX}"'
8002 ! :echo one
8003 ! <./.ttxts
8004 ! :echo two
8005 ! : set i=./.ttxts
8006 ! - $ < $i
8007 !:echo three
8008 ! : set \\
8009 errexit
8010 ! - $ < $i
8011 ! : echo four
8012 !$< ./.ttxts
8013 ! : echo five
8014 ' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
8015 -Sescape=! \
8016 -Spwd="`${pwd}`" \
8017 -s testsub one@to.invalid >./.tall 2>./.terr
8018 check 6 4 ./.tall '686767281 95'
8019 [ -f "${MBOX}" ]; check_exn0 7
8020 if have_feat uistrings; then
8021 check 8 - ./.terr '1304637795 199'
8022 else
8023 t_echoskip '8:[!UISTRINGS]'
8026 t_epilog "${@}"
8029 t_compose_edits() { # XXX very rudimentary
8030 # after: t_cmd_escapes
8031 t_prolog "${@}"
8033 # Something to use as "editor"
8034 ${cat} <<-_EOT > ./.ted.sh
8035 #!${SHELL}
8036 ${cat} <<-__EOT > \${1}
8037 Fcc: .tout1
8039 Fcc: .tout2
8040 Subject: Fcc test 1
8041 Fcc: .tout3
8043 A body
8044 __EOT
8045 exit 0
8046 _EOT
8047 ${chmod} 0755 .ted.sh
8049 # > All these are in-a-row!
8051 printf 'mail ./.tout\n~s This subject is\nThis body is\n~.' |
8052 ${MAILX} ${ARGS} -Seditheaders >./.tall 2>&1
8053 check 1 0 ./.tout '3993703854 127'
8054 check 2 - ./.tall '4294967295 0'
8056 ${mv} ./.tall ./.tout
8057 printf 'mail ./.tout\n~s This subject is\nThis body is\n~e\n~.' |
8058 ${MAILX} ${ARGS} -Seditheaders -SEDITOR=./.ted.sh >./.tall 2>&1
8059 check 3 0 ./.tout1 '285981670 116'
8060 check 4 - ./.tout2 '285981670 116'
8061 check 5 - ./.tout3 '285981670 116'
8062 check 6 - ./.tout '4294967295 0'
8063 check 7 - ./.tall '4294967295 0'
8064 ${rm} ./.tout1 ./.tout2 ./.tout3
8066 # Note t_compose_hooks adds ~^ stress tests
8067 ${mv} ./.tout ./.tout1
8068 ${mv} ./.tall ./.tout2
8069 printf '#
8070 mail ./.tout\n!s This subject is\nThis body is
8071 !^header
8072 !^header list
8073 !^header list fcc
8074 !^header show fcc
8075 !^header remove to
8076 !^header insert fcc ./.tout
8077 !^header insert fcc .tout1
8078 !^header insert fcc ./.tout2
8079 !^header list
8080 !^header show fcc
8081 !^header remove-at fcc 2
8082 !^header remove-at fcc 2
8083 !^header show fcc
8084 !^head remove fcc
8085 !^header show fcc
8086 !^header insert fcc ./.tout
8087 !^header show fcc
8088 !^header list
8090 ' | ${MAILX} ${ARGS} -Sescape=! >./.tall 2>&1
8091 check 8 0 ./.tout '3993703854 127'
8092 check 9 - ./.tout1 '4294967295 0'
8093 check 10 - ./.tout2 '4294967295 0'
8094 check 11 - ./.tall '1857504914 342'
8096 # < No longer in-a-row
8098 ${cat} <<-_EOT | ${MAILX} ${ARGS} -t >./.tall 2>&1
8099 Fcc: .ttout
8100 Subject: Fcc via -t test
8102 My body
8103 _EOT
8104 check 12 0 ./.ttout '1289478830 122'
8105 check 13 - ./.tall '4294967295 0'
8107 # This test assumes code of `^' and `digmsg' is shared: see t_digmsg()
8108 echo 'b 1' > ./.t' x 1'
8109 echo 'b 2' > ./.t' x 2'
8110 printf '#
8111 mail ./.tatt
8112 !^header insert subject subject
8113 !:set i="./.t x 1"
8114 !^header list
8115 !:echo =0
8116 !^attachment
8117 !:echo =1
8118 !^attachment insert "$i"
8119 !:echo =2
8120 !^attachment
8121 !:echo =3
8122 !^attachment list
8123 !:echo =4
8124 !^attachment insert '"'"'./.t x 2'"'"'
8125 !:echo =5
8126 !^attachment list
8127 !:echo =6
8128 !^attachment remove "$i"
8129 !:echo =7
8130 !^attachment list
8131 !:echo =8
8132 !^attachment insert $'"'"'\\$i'"'"'
8133 !:echo =10
8134 !^attachment list
8135 !:echo =11
8136 !^header list
8137 !:echo =12
8138 !^a a $i
8139 !:echo =13
8140 !^a attribute-set "$i" filenames " cannot wait for you "
8141 !:echo =14
8142 !^a a $i
8143 !:echo =15
8144 !^a attribute-set "$i" filename " cannot wait for you "
8145 !:echo =16
8146 !^a a $i
8147 !:echo =17
8148 !^a attribute-at 2
8149 !:echo =18
8150 !^a attribute-set-at 2 "filename" "private eyes"
8151 !:echo =19
8152 !^a attribute-at 2
8153 !:echo =20
8154 !^a attribute-set-at 2 content-description "private c-desc"
8155 !:echo =21
8156 !^a attribute-at 2
8157 !:echo =22
8158 !^a attribute-set-at 2 content-ID "priv invd c-id"
8159 !:echo =23
8160 !^a attribute-at 2
8161 !:echo =24
8162 !^a attribute-set-at 2 content-TyPE tExT/mARkLO
8163 !:echo =25
8164 !^a attribute-at 2
8165 !:echo =26
8166 !^a attribute-set-at 2 content-TyPE ""
8167 !:echo =27
8168 !^a attribute-at 2
8169 !:echo =28
8171 ' | ${MAILX} ${ARGS} -Sescape=! >./.tall 2>&1
8172 check 14 0 ./.tall '3491667030 1565'
8173 check 15 - ./.tatt '1685063733 636'
8175 t_epilog "${@}"
8178 t_digmsg() { # XXX rudimentary; <> compose_edits()?
8179 t_prolog "${@}"
8181 printf '#
8182 mail ./.tout\n!s This subject is\nThis body is
8183 !:echo --one
8184 !:digmsg create - -
8185 !:digmsg - header list
8186 !:digmsg - header show subject
8187 !:digmsg - header show to
8188 !:digmsg - header remove to
8189 !:digmsg - header list
8190 !:digmsg - header show to
8191 !:digmsg remove -
8192 !:echo --two
8193 !:digmsg create -
8194 !:digmsg - header list; readall x; echon "<$x>";
8195 !:digmsg - header show subject;readall x;echon "<$x>";;
8196 !:digmsg remove -
8197 !:echo --three
8198 !: # nothing here as is comment
8199 !^header insert fcc ./.tbox
8200 !:echo --four
8201 !:digmsg create - -
8202 !:digmsg - header list
8203 !:digmsg - header show fcc
8204 !:echo --five
8205 !^head remove fcc
8206 !:echo --six
8207 !:digmsg - header list
8208 !:digmsg - header show fcc
8209 !:digmsg - header insert fcc ./.tfcc
8210 !:echo --seven
8211 !:digmsg remove -
8212 !:echo bye
8214 echo --hello again
8215 File ./.tfcc
8216 echo --one
8217 digmsg create 1 -
8218 digmsg 1 header list
8219 digmsg 1 header show subject
8220 echo --two
8221 ! : > ./.tempty
8222 File ./.tempty
8223 echo --three
8224 digmsg 1 header list; echo $?/$^ERRNAME
8225 digmsg create -; echo $?/$^ERRNAME
8226 echo ==========
8227 ! %s ./.tfcc > ./.tcat
8228 ! %s "s/This subject is/There subject was/" < ./.tfcc >> ./.tcat
8229 File ./.tcat
8230 mail nowhere@exam.ple
8231 !:echo ===1
8232 !:digmsg create -; echo $?/$^ERRNAME;\\
8233 digmsg create 1; echo $?/$^ERRNAME;\\
8234 digmsg create 2; echo $?/$^ERRNAME
8235 !:echo ===2.1
8236 !:digmsg - h l;echo $?/$^ERRNAME;readall d;echo "$?/$^ERRNAME <$d>"
8237 !:echo =2.2
8238 !:digmsg 1 h l;echo $?/$^ERRNAME;readall d;echo "$?/$^ERRNAME <$d>"
8239 !:echo =2.3
8240 !^ h l
8241 !:echo =2.4
8242 !:digmsg 2 h l;echo $?/$^ERRNAME;readall d;echo "$?/$^ERRNAME <$d>"
8243 !:echo ===3.1
8244 !:digmsg - h s to;echo $?/$^ERRNAME;readall d;echo "$?/$^ERRNAME <$d>"
8245 !:echo =3.2
8246 !:digmsg 1 h s subject;echo $?/$^ERRNAME;readall d;echo "$?/$^ERRNAME <$d>"
8247 !:echo =3.3
8248 !^ h s to
8249 !:echo =3.4
8250 !:digmsg 2 h s subject;echo $?/$^ERRNAME;readall d;echo "$?/$^ERRNAME <$d>"
8251 !:echo ==4.1
8252 !:digmsg remove -; echo $?/$^ERRNAME;\\
8253 digmsg remove 1; echo $?/$^ERRNAME;\\
8254 digmsg remove 2; echo $?/$^ERRNAME;
8256 echo ======= new game new fun!
8257 mail one@to.invalid
8258 !s hossa
8259 !:set expandaddr=-name
8260 !:echo -oneo
8261 !^ header insert to two@to.invalid
8262 !:echo $?/$^ERRNAME
8263 !:echo --two
8264 !^ header insert cc no-name-allowed
8265 !:echo $?/$^ERRNAME
8266 !^ header insert cc one@cc.invalid
8267 !:echo $?/$^ERRNAME
8268 !:echo --three
8269 !:alias abcc one@bcc.invalid
8270 !^ header insert bcc abcc
8271 !:echo $?/$^ERRNAME
8272 !:set expandaddr=+addr
8273 !^ header insert bcc abcc
8274 !:echo $!/$?/$^ERRNAME
8276 echo --bye
8277 ' "${cat}" "${sed}" |
8278 ${MAILX} ${ARGS} -Smta=test://"$MBOX" -Sescape=! >./.tall 2>&1
8279 check 1 0 "$MBOX" '665881681 179'
8280 have_feat uistrings && i='4159482825 1372' || i='2254509488 1103'
8281 check 2 - ./.tall "${i}"
8282 check 3 - ./.tfcc '3993703854 127'
8283 check 4 - ./.tempty '4294967295 0'
8284 check 5 - ./.tcat '2157992522 256'
8286 t_epilog "${@}"
8289 t_on_main_loop_tick() {
8290 t_prolog "${@}"
8292 if have_feat cmd-vexpr; then :; else
8293 t_echoskip '[!CMD_VEXPR]'
8294 t_epilog "${@}"
8295 return
8298 printf '#
8299 echo hello; set i=1
8300 define bla {
8301 echo bla1
8302 echo bla2
8304 define omlt {
8305 echo in omlt: $i
8306 vput vexpr i + 1 $i
8308 echo one
8309 set on-main-loop-tick=omlt
8310 echo two
8311 echo three
8312 echo calling bla;call bla
8313 echo four
8314 echo --bye;xit' |
8315 ${MAILX} ${ARGS} -Smta=test://"$MBOX" -Sescape=! >./.tall 2>&1
8316 check 1 0 ./.tall '3697651500 130'
8318 t_epilog "${@}"
8321 t_on_program_exit() {
8322 t_prolog "${@}"
8324 ${MAILX} ${ARGS} \
8325 -X 'define x {' -X 'echo jay' -X '}' -X x -Son-program-exit=x \
8326 > ./.tall 2>&1
8327 check 1 0 ./.tall '2820891503 4'
8329 ${MAILX} ${ARGS} \
8330 -X 'define x {' -X 'echo jay' -X '}' -X q -Son-program-exit=x \
8331 > ./.tall 2>&1
8332 check 2 0 ./.tall '2820891503 4'
8334 </dev/null ${MAILX} ${ARGS} \
8335 -X 'define x {' -X 'echo jay' -X '}' -Son-program-exit=x \
8336 > ./.tall 2>&1
8337 check 3 0 ./.tall '2820891503 4'
8339 </dev/null ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
8340 -X 'define x {' -X 'echo jay' -X '}' -Son-program-exit=x \
8341 -s subject -. hey@you \
8342 > ./.tall 2>&1
8343 check 4 0 ./.tall '2820891503 4'
8344 check 5 - "$MBOX" '561900352 118'
8346 t_epilog "${@}"
8348 # }}}
8350 # Heavy use of/rely on state machine (behaviour) and basics {{{
8351 t_compose_hooks() { # {{{ TODO monster
8352 t_prolog "${@}"
8354 if have_feat uistrings &&
8355 have_feat cmd-csop && have_feat cmd-vexpr; then :; else
8356 t_echoskip '[!UISTRINGS/!CMD_CSOP/!CMD_VEXPR]'
8357 t_epilog "${@}"
8358 return
8361 (echo line one&&echo line two&&echo line three) > ./.treadctl
8362 (echo echo four&&echo echo five&&echo echo six) > ./.tattach
8364 # Supposed to extend t_compose_edits with ~^ stress tests!
8365 ${cat} <<'__EOT__' > ./.trc
8366 define bail {
8367 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
8369 define xerr {
8370 vput csop es substr "$1" 0 1
8371 if [ "$es" != 2 ]
8372 xcall bail "$2: $1"
8375 define read_mline_res {
8376 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
8377 echo $len/$es/$^ERRNAME: $hl
8378 if [ $es -ne $^ERR-NONE ]
8379 xcall bail read_mline_res
8380 elif [ $len -ne 0 ]
8381 \xcall read_mline_res
8384 define ins_addr {
8385 wysh set xh=$1
8386 echo "~^header list"; read hl; echo $hl;\
8387 call xerr "$hl" "in_addr ($xh) 0-1"
8389 echo "~^header insert $xh 'diet <$xh@exam.ple> spliced'";\
8390 read es; echo $es; call xerr "$es" "ins_addr $xh 1-1"
8391 echo "~^header insert $xh <${xh}2@exam.ple>";\
8392 read es; echo $es; call xerr "$es" "ins_addr $xh 1-2"
8393 echo "~^header insert $xh ${xh}3@exam.ple";\
8394 read es; echo $es; call xerr "$es" "ins_addr $xh 1-3"
8395 echo "~^header list $xh"; read hl; echo $hl;\
8396 call xerr "$hl" "ins_addr $xh 1-4"
8397 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 1-5"
8398 call read_mline_res
8400 if [ "$t_remove" == "" ]
8401 return
8404 echo "~^header remove $xh"; read es; call xerr $es "ins_addr $xh 2-1"
8405 echo "~^header remove $xh"; read es; vput csop es substr $es 0 3
8406 if [ $es != 501 ]
8407 xcall bail "ins_addr $xh 2-2"
8409 echo "~^header list $xh"; read es; vput csop es substr $es 0 3
8410 if [ $es != 501 ]
8411 xcall bail "ins_addr $xh 2-3"
8413 echo "~^header show $xh"; read es; vput csop es substr $es 0 3
8414 if [ $es != 501 ]
8415 xcall bail "ins_addr $xh 2-4"
8419 echo "~^header insert $xh 'diet <$xh@exam.ple> spliced'";\
8420 read es; echo $es; call xerr "$es" "ins_addr $xh 3-1"
8421 echo "~^header insert $xh <${xh}2@exam.ple>";\
8422 read es; echo $es; call xerr "$es" "ins_addr $xh 3-2"
8423 echo "~^header insert $xh ${xh}3@exam.ple";\
8424 read es; echo $es; call xerr "$es" "ins_addr $xh 3-3"
8425 echo "~^header list $xh"; read hl; echo $hl;\
8426 call xerr "$hl" "ins_addr $xh 3-4"
8427 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 3-5"
8428 call read_mline_res
8430 echo "~^header remove-at $xh 1"; read es;\
8431 call xerr $es "ins_addr $xh 3-6"
8432 echo "~^header remove-at $xh 1"; read es;\
8433 call xerr $es "ins_addr $xh 3-7"
8434 echo "~^header remove-at $xh 1"; read es;\
8435 call xerr $es "ins_addr $xh 3-8"
8436 echo "~^header remove-at $xh 1"; read es;\
8437 vput csop es substr $es 0 3
8438 if [ $es != 501 ]
8439 xcall bail "ins_addr $xh 3-9"
8441 echo "~^header remove-at $xh T"; read es;\
8442 vput csop es substr $es 0 3
8443 if [ $es != 505 ]
8444 xcall bail "ins_addr $xh 3-10"
8446 echo "~^header list $xh"; read es;\
8447 vput csop es substr $es 0 3
8448 if [ $es != 501 ]
8449 xcall bail "ins_addr $xh 3-11"
8451 echo "~^header show $xh"; read es;\
8452 vput csop es substr $es 0 3
8453 if [ $es != 501 ]
8454 xcall bail "ins_addr $xh 3-12"
8458 echo "~^header insert $xh 'diet <$xh@exam.ple> spliced'";\
8459 read es; echo $es; call xerr "$es" "ins_addr $xh 4-1"
8460 echo "~^header insert $xh <${xh}2@exam.ple>\ (comment)\ \\\"Quot(e)d\\\"";\
8461 read es; echo $es; call xerr "$es" "ins_addr $xh 4-2"
8462 echo "~^header insert $xh ${xh}3@exam.ple";\
8463 read es; echo $es; call xerr "$es" "ins_addr $xh 4-3"
8464 echo "~^header list $xh"; read hl; echo $hl;\
8465 call xerr "$hl" "header list $xh 3-4"
8466 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 4-5"
8467 call read_mline_res
8469 echo "~^header remove-at $xh 3"; read es;\
8470 call xerr $es "ins_addr $xh 4-6"
8471 echo "~^header remove-at $xh 2"; read es;\
8472 call xerr $es "ins_addr $xh 4-7"
8473 echo "~^header remove-at $xh 1"; read es;\
8474 call xerr $es "ins_addr $xh 4-8"
8475 echo "~^header remove-at $xh 1"; read es;\
8476 vput csop es substr $es 0 3
8477 if [ $es != 501 ]
8478 xcall bail "ins_addr $xh 4-9"
8480 echo "~^header remove-at $xh T"; read es;\
8481 vput csop es substr $es 0 3
8482 if [ $es != 505 ]
8483 xcall bail "ins_addr $xh 4-10"
8485 echo "~^header list $xh"; read es;\
8486 vput csop es substr $es 0 3
8487 if [ $es != 501 ]
8488 xcall bail "ins_addr $xh 4-11"
8490 echo "~^header show $xh"; read es;\
8491 vput csop es substr $es 0 3
8492 if [ $es != 501 ]
8493 xcall bail "ins_addr $xh 4-12"
8496 define ins_ref {
8497 wysh set xh=$1 mult=$2
8498 echo "~^header list"; read hl; echo $hl;\
8499 call xerr "$hl" "ins_ref ($xh) 0-1"
8501 echo "~^header insert $xh <$xh@exam.ple>";\
8502 read es; echo $es; call xerr "$es" "ins_ref $xh 1-1"
8503 if [ $mult -ne 0 ]
8504 echo "~^header insert $xh <${xh}2@exam.ple>";\
8505 read es; echo $es; call xerr "$es" "ins_ref $xh 1-2"
8506 echo "~^header insert $xh ${xh}3@exam.ple";\
8507 read es; echo $es; call xerr "$es" "ins_ref $xh 1-3"
8508 else
8509 echo "~^header insert $xh <${xh}2@exam.ple>"; read es;\
8510 vput csop es substr $es 0 3
8511 if [ $es != 506 ]
8512 xcall bail "ins_ref $xh 1-4"
8516 echo "~^header list $xh"; read hl; echo $hl;\
8517 call xerr "$hl" "ins_ref $xh 1-5"
8518 echo "~^header show $xh"; read es; call xerr $es "ins_ref $xh 1-6"
8519 call read_mline_res
8521 if [ "$t_remove" == "" ]
8522 return
8525 echo "~^header remove $xh"; read es;\
8526 call xerr $es "ins_ref $xh 2-1"
8527 echo "~^header remove $xh"; read es;\
8528 vput csop es substr $es 0 3
8529 if [ $es != 501 ]
8530 xcall bail "ins_ref $xh 2-2"
8532 echo "~^header list $xh"; read es;\
8533 vput csop es substr $es 0 3
8534 if [ $es != 501 ]
8535 xcall bail "$es ins_ref $xh 2-3"
8537 echo "~^header show $xh"; read es;\
8538 vput csop es substr $es 0 3
8539 if [ $es != 501 ]
8540 xcall bail "ins_ref $xh 2-4"
8544 echo "~^header insert $xh <$xh@exam.ple>";\
8545 read es; echo $es; call xerr "$es" "ins_ref $xh 3-1"
8546 if [ $mult -ne 0 ]
8547 echo "~^header insert $xh <${xh}2@exam.ple>";\
8548 read es; echo $es; call xerr "$es" "ins_ref $xh 3-2"
8549 echo "~^header insert $xh ${xh}3@exam.ple";\
8550 read es; echo $es; call xerr "$es" "ins_ref $xh 3-3"
8552 echo "~^header list $xh";\
8553 read hl; echo $hl; call xerr "$hl" "ins_ref $xh 3-4"
8554 echo "~^header show $xh";\
8555 read es; call xerr $es "ins_ref $xh 3-5"
8556 call read_mline_res
8558 echo "~^header remove-at $xh 1"; read es;\
8559 call xerr $es "ins_ref $xh 3-6"
8560 if [ $mult -ne 0 ] && [ $xh != subject ]
8561 echo "~^header remove-at $xh 1"; read es;\
8562 call xerr $es "ins_ref $xh 3-7"
8563 echo "~^header remove-at $xh 1"; read es;\
8564 call xerr $es "ins_ref $xh 3-8"
8566 echo "~^header remove-at $xh 1"; read es;\
8567 vput csop es substr $es 0 3
8568 if [ $es != 501 ]
8569 xcall bail "ins_ref $xh 3-9"
8571 echo "~^header remove-at $xh T"; read es;\
8572 vput csop es substr $es 0 3
8573 if [ $es != 505 ]
8574 xcall bail "ins_ref $xh 3-10"
8576 echo "~^header show $xh"; read es;\
8577 vput csop es substr $es 0 3
8578 if [ $es != 501 ]
8579 xcall bail "ins_ref $xh 3-11"
8583 echo "~^header insert $xh <$xh@exam.ple> ";\
8584 read es; echo $es; call xerr "$es" "ins_ref $xh 4-1"
8585 if [ $mult -ne 0 ]
8586 echo "~^header insert $xh <${xh}2@exam.ple> ";\
8587 read es; echo $es; call xerr "$es" "ins_ref $xh 4-2"
8588 echo "~^header insert $xh ${xh}3@exam.ple";\
8589 read es; echo $es; call xerr "$es" "ins_ref $xh 4-3"
8591 echo "~^header list $xh"; read hl; echo $hl;\
8592 call xerr "$hl" "ins_ref $xh 4-4"
8593 echo "~^header show $xh"; read es; call xerr $es "ins_ref $xh 4-5"
8594 call read_mline_res
8596 if [ $mult -ne 0 ] && [ $xh != subject ]
8597 echo "~^header remove-at $xh 3"; read es;\
8598 call xerr $es "ins_ref $xh 4-6"
8599 echo "~^header remove-at $xh 2"; read es;\
8600 call xerr $es "ins_ref $xh 4-7"
8602 echo "~^header remove-at $xh 1"; read es;\
8603 call xerr $es "ins_ref $xh 4-8"
8604 echo "~^header remove-at $xh 1"; read es;\
8605 vput csop es substr $es 0 3
8606 if [ $es != 501 ]
8607 xcall bail "ins_ref $xh 4-9"
8609 echo "~^header remove-at $xh T"; read es;\
8610 vput csop es substr $es 0 3
8611 if [ $es != 505 ]
8612 xcall bail "ins_ref $xh 4-10"
8614 echo "~^header show $xh"; read es;\
8615 vput csop es substr $es 0 3
8616 if [ $es != 501 ]
8617 xcall bail "ins_ref $xh 4-11"
8620 define t_header {
8621 echo t_header ENTER
8622 # In collect.c order
8623 call ins_addr from
8624 call ins_ref sender 0 # Not a "ref", but works
8625 call ins_addr To
8626 call ins_addr cC
8627 call ins_addr bCc
8628 call ins_addr reply-To
8629 call ins_addr mail-Followup-to
8630 call ins_ref messAge-id 0
8631 call ins_ref rEfErEncEs 1
8632 call ins_ref in-Reply-to 1
8633 call ins_ref subject 1 # Not a "ref", but works (with tweaks)
8634 call ins_addr freeForm1
8635 call ins_addr freeform2
8637 echo "~^header show MAILX-Command"; read es; call xerr $es "t_header 1000"
8638 call read_mline_res
8639 echo "~^header show MAILX-raw-TO"; read es; call xerr $es "t_header 1001"
8640 call read_mline_res
8642 echo t_header LEAVE
8644 define t_attach {
8645 echo t_attach ENTER
8647 echo "~^attachment";\
8648 read hl; echo $hl; vput csop es substr "$hl" 0 3
8649 if [ "$es" != 501 ]
8650 xcall bail "attach 0-1"
8653 echo "~^attach attribute ./.treadctl";\
8654 read hl; echo $hl; vput csop es substr "$hl" 0 3
8655 if [ "$es" != 501 ]
8656 xcall bail "attach 0-2"
8658 echo "~^attachment attribute-at 1";\
8659 read hl; echo $hl; vput csop es substr "$hl" 0 3
8660 if [ "$es" != 501 ]
8661 xcall bail "attach 0-3"
8664 echo "~^attachment insert ./.treadctl=ascii";\
8665 read hl; echo $hl; call xerr "$hl" "attach 1-1"
8666 echo "~^attachment list";\
8667 read es; echo $es;call xerr "$es" "attach 1-2"
8668 call read_mline_res
8669 echo "~^attachment attribute ./.treadctl";\
8670 read es; echo $es;call xerr "$es" "attach 1-3"
8671 call read_mline_res
8672 echo "~^attachment attribute .treadctl";\
8673 read es; echo $es;call xerr "$es" "attach 1-4"
8674 call read_mline_res
8675 echo "~^attachment attribute-at 1";\
8676 read es; echo $es;call xerr "$es" "attach 1-5"
8677 call read_mline_res
8679 echo "~^attachment attribute-set ./.treadctl filename rctl";\
8680 read es; echo $es;call xerr "$es" "attach 1-6"
8681 echo "~^attachment attribute-set .treadctl content-description Au";\
8682 read es; echo $es;call xerr "$es" "attach 1-7"
8683 echo "~^attachment attribute-set-at 1 content-id <10.du@ich>";\
8684 read es; echo $es;call xerr "$es" "attach 1-8"
8686 echo "~^attachment attribute ./.treadctl";\
8687 read es; echo $es;call xerr "$es" "attach 1-9"
8688 call read_mline_res
8689 echo "~^attachment attribute .treadctl";\
8690 read es; echo $es;call xerr "$es" "attach 1-10"
8691 call read_mline_res
8692 echo "~^attachment attribute rctl";\
8693 read es; echo $es;call xerr "$es" "attach 1-11"
8694 call read_mline_res
8695 echo "~^attachment attribute-at 1";\
8696 read es; echo $es;call xerr "$es" "attach 1-12"
8697 call read_mline_res
8700 echo "~^attachment insert ./.tattach=latin1";\
8701 read hl; echo $hl; call xerr "$hl" "attach 2-1"
8702 echo "~^attachment list";\
8703 read es; echo $es;call xerr "$es" "attach 2-2"
8704 call read_mline_res
8705 echo "~^attachment attribute ./.tattach";\
8706 read es; echo $es;call xerr "$es" "attach 2-3"
8707 call read_mline_res
8708 echo "~^attachment attribute .tattach";\
8709 read es; echo $es;call xerr "$es" "attach 2-4"
8710 call read_mline_res
8711 echo "~^attachment attribute-at 2";\
8712 read es; echo $es;call xerr "$es" "attach 2-5"
8713 call read_mline_res
8715 echo "~^attachment attribute-set ./.tattach filename tat";\
8716 read es; echo $es;call xerr "$es" "attach 2-6"
8717 echo \
8718 "~^attachment attribute-set .tattach content-description Au2";\
8719 read es; echo $es;call xerr "$es" "attach 2-7"
8720 echo "~^attachment attribute-set-at 2 content-id <20.du@wir>";\
8721 read es; echo $es;call xerr "$es" "attach 2-8"
8722 echo \
8723 "~^attachment attribute-set-at 2 content-type application/x-sh";\
8724 read es; echo $es;call xerr "$es" "attach 2-9"
8726 echo "~^attachment attribute ./.tattach";\
8727 read es; echo $es;call xerr "$es" "attach 2-10"
8728 call read_mline_res
8729 echo "~^attachment attribute .tattach";\
8730 read es; echo $es;call xerr "$es" "attach 2-11"
8731 call read_mline_res
8732 echo "~^attachment attribute tat";\
8733 read es; echo $es;call xerr "$es" "attach 2-12"
8734 call read_mline_res
8735 echo "~^attachment attribute-at 2";\
8736 read es; echo $es;call xerr "$es" "attach 2-13"
8737 call read_mline_res
8740 if [ "$t_remove" == "" ]
8741 return
8744 echo "~^attachment remove ./.treadctl"; read es;\
8745 call xerr $es "attach 3-1"
8746 echo "~^attachment remove ./.tattach"; read es;\
8747 call xerr $es "attach 3-2"
8748 echo "~^ attachment remove ./.treadctl"; read es;\
8749 vput csop es substr $es 0 3
8750 if [ $es != 501 ]
8751 xcall bail "attach 3-3"
8753 echo "~^ attachment remove ./.tattach"; read es;\
8754 vput csop es substr $es 0 3
8755 if [ $es != 501 ]
8756 xcall bail "attach 3-4"
8758 echo "~^attachment list"; read es;\
8759 vput csop es substr $es 0 3
8760 if [ $es != 501 ]
8761 xcall bail "attach 3-5"
8765 echo "~^attachment insert ./.tattach=latin1";\
8766 read hl; echo $hl; call xerr "$hl" "attach 4-1"
8767 echo "~^attachment insert ./.tattach=latin1";\
8768 read hl; echo $hl; call xerr "$hl" "attach 4-2"
8769 echo "~^attachment list";\
8770 read es; echo $es;call xerr "$es" "attach 4-3"
8771 call read_mline_res
8772 echo "~^ attachment remove .tattach"; read es;\
8773 vput csop es substr $es 0 3
8774 if [ $es != 506 ]
8775 xcall bail "attach 4-4 $es"
8777 echo "~^attachment remove-at T"; read es;\
8778 vput csop es substr $es 0 3
8779 if [ $es != 505 ]
8780 xcall bail "attach 4-5"
8782 echo "~^attachment remove ./.tattach"; read es;\
8783 call xerr $es "attach 4-6"
8784 echo "~^attachment remove ./.tattach"; read es;\
8785 call xerr $es "attach 4-7"
8786 echo "~^ attachment remove ./.tattach"; read es;\
8787 vput csop es substr $es 0 3
8788 if [ $es != 501 ]
8789 xcall bail "attach 4-8 $es"
8791 echo "~^attachment list"; read es;\
8792 vput csop es substr $es 0 3
8793 if [ $es != 501 ]
8794 xcall bail "attach 4-9"
8798 echo "~^attachment insert ./.tattach=latin1";\
8799 read hl; echo $hl; call xerr "$hl" "attach 5-1"
8800 echo "~^attachment insert ./.tattach=latin1";\
8801 read hl; echo $hl; call xerr "$hl" "attach 5-2"
8802 echo "~^attachment insert ./.tattach=latin1";\
8803 read hl; echo $hl; call xerr "$hl" "attach 5-3"
8804 echo "~^attachment list";\
8805 read es; echo $es;call xerr "$es" "attach 5-4"
8806 call read_mline_res
8808 echo "~^attachment remove-at 3"; read es;\
8809 call xerr $es "attach 5-5"
8810 echo "~^attachment remove-at 3"; read es;\
8811 vput csop es substr $es 0 3
8812 if [ $es != 501 ]
8813 xcall bail "attach 5-6"
8815 echo "~^attachment remove-at 2"; read es;\
8816 call xerr $es "attach 5-7"
8817 echo "~^attachment remove-at 2"; read es;\
8818 vput csop es substr $es 0 3
8819 if [ $es != 501 ]
8820 xcall bail "attach 5-8"
8822 echo "~^attachment remove-at 1"; read es;\
8823 call xerr $es "attach 5-9"
8824 echo "~^attachment remove-at 1"; read es;\
8825 vput csop es substr $es 0 3
8826 if [ $es != 501 ]
8827 xcall bail "attach 5-10"
8830 echo "~^attachment list"; read es;\
8831 vput csop es substr $es 0 3
8832 if [ $es != 501 ]
8833 xcall bail "attach 5-11"
8837 echo "~^attachment insert ./.tattach=latin1";\
8838 read hl; echo $hl; call xerr "$hl" "attach 6-1"
8839 echo "~^attachment insert ./.tattach=latin1";\
8840 read hl; echo $hl; call xerr "$hl" "attach 6-2"
8841 echo "~^attachment insert ./.tattach=latin1";\
8842 read hl; echo $hl; call xerr "$hl" "attach 6-3"
8843 echo "~^attachment list";\
8844 read es; echo $es;call xerr "$es" "attach 6-4"
8845 call read_mline_res
8847 echo "~^attachment remove-at 1"; read es;\
8848 call xerr $es "attach 6-5"
8849 echo "~^attachment remove-at 1"; read es;\
8850 call xerr $es "attach 6-6"
8851 echo "~^attachment remove-at 1"; read es;\
8852 call xerr $es "attach 6-7"
8853 echo "~^attachment remove-at 1"; read es;\
8854 vput csop es substr $es 0 3
8855 if [ $es != 501 ]
8856 xcall bail "attach 6-8"
8859 echo "~^attachment list"; read es;\
8860 vput csop es substr $es 0 3
8861 if [ $es != 501 ]
8862 xcall bail "attach 6-9"
8865 echo t_attach LEAVE
8867 define t_ocs {
8868 read ver
8869 echo t_ocs
8870 call t_header
8871 call t_attach
8873 define t_oce {
8874 echo on-compose-enter, mailx-command<$mailx-command>
8875 alternates alter1@exam.ple alter2@exam.ple
8876 alternates
8877 set autocc='alter1@exam.ple alter2@exam.ple'
8878 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
8879 echo mailx-subject<$mailx-subject>
8880 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
8881 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
8882 mailx-raw-bcc<$mailx-raw-bcc>
8883 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
8884 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
8885 digmsg create - -;echo $?/$!/$^ERRNAME;\
8886 digmsg - header list;\
8887 digmsg remove -;echo $?/$!/$^ERRNAME
8888 digmsg create -;echo $?/$!/$^ERRNAME;\
8889 digmsg - header list;readall x;echon $x;\
8890 digmsg remove -;echo $?/$!/$^ERRNAME
8892 define t_ocl {
8893 echo on-compose-leave, mailx-command<$mailx-command>
8894 vput alternates al
8895 eval alternates $al alter3@exam.ple alter4@exam.ple
8896 alternates
8897 set autobcc='alter3@exam.ple alter4@exam.ple'
8898 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
8899 echo mailx-subject<$mailx-subject>
8900 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
8901 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
8902 mailx-raw-bcc<$mailx-raw-bcc>
8903 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
8904 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
8905 digmsg create - -;echo $?/$!/$^ERRNAME;\
8906 digmsg - header list;\
8907 digmsg remove -;echo $?/$!/$^ERRNAME
8908 digmsg create -;echo $?/$!/$^ERRNAME;\
8909 digmsg - header list;readall x;echon $x;\
8910 digmsg remove -;echo $?/$!/$^ERRNAME
8912 define t_occ {
8913 echo on-compose-cleanup, mailx-command<$mailx-command>
8914 unalternates *
8915 alternates
8916 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
8917 echo mailx-subject<$mailx-subject>
8918 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
8919 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
8920 mailx-raw-bcc<$mailx-raw-bcc>
8921 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
8922 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
8923 # XXX error message variable digmsg create - -;echo $?/$!/$^ERRNAME;\
8924 digmsg - header list;\
8925 digmsg remove -;echo $?/$!/$^ERRNAME
8926 # ditto digmsg create -;echo $?/$!/$^ERRNAME;\
8927 digmsg - header list;readall x;echon $x;\
8928 digmsg remove -;echo $?/$!/$^ERRNAME
8930 wysh set on-compose-splice=t_ocs \
8931 on-compose-enter=t_oce on-compose-leave=t_ocl \
8932 on-compose-cleanup=t_occ
8933 __EOT__
8935 printf 'm this-goes@nowhere\nbody\n!.\n' |
8936 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
8937 -X'source ./.trc' -Smta=test://"$MBOX" \
8938 >./.tall 2>&1
8939 ${cat} ./.tall >> "${MBOX}"
8940 check 1 0 "${MBOX}" '1646284089 10565'
8942 ${rm} "${MBOX}"
8943 printf 'm this-goes@nowhere\nbody\n!.\n' |
8944 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
8945 -St_remove=1 -X'source ./.trc' -Smta=test://"$MBOX" \
8946 >./.tall 2>&1
8947 ${cat} ./.tall >> "${MBOX}"
8948 check 2 0 "${MBOX}" '700681006 12851'
8952 # Some state machine stress, shell compose hook, localopts for hook, etc.
8953 # readctl in child. ~r as HERE document
8954 ${rm} "${MBOX}"
8955 printf 'm ex@am.ple\nbody\n!.
8956 echon ${mailx-command}${mailx-subject}
8957 echon ${mailx-from}${mailx-sender}
8958 echon ${mailx-to}${mailx-cc}${mailx-bcc}
8959 echon ${mailx-raw-to}${mailx-raw-cc}${mailx-raw-bcc}
8960 echon ${mailx-orig-from}${mailx-orig-to}${mailx-orig-gcc}${mailx-orig-bcc}
8961 var t_oce t_ocs t_ocs_sh t_ocl t_occ autocc
8962 ' | ${MAILX} ${ARGS} -Snomemdebug -Sescape=! \
8963 -Smta=test://"$MBOX" \
8965 define bail {
8966 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
8968 define xerr {
8969 vput csop es substr "$1" 0 1
8970 if [ "$es" != 2 ]
8971 xcall bail "$2"
8974 define read_mline_res {
8975 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
8976 echo $len/$es/$^ERRNAME: $hl
8977 if [ $es -ne $^ERR-NONE ]
8978 xcall bail read_mline_res
8979 elif [ $len -ne 0 ]
8980 \xcall read_mline_res
8983 define _work {
8984 vput vexpr i + 1 "$2"
8985 if [ $i -lt 111 ]
8986 vput vexpr j % $i 10
8987 if [ $j -ne 0 ]
8988 set j=xcall
8989 else
8990 echon "$i.. "
8991 set j=call
8993 eval \\$j _work $1 $i
8994 return $?
8996 vput vexpr i + $i "$1"
8997 return $i
8999 define _read {
9000 wysh set line; read line;wysh set es=$? en=$^ERRNAME ;\
9001 echo read:$es/$en: $line
9002 if [ "${es}" -ne -1 ]
9003 xcall _read
9005 readctl remove $cwd/.treadctl; echo readctl remove:$?/$^ERRNAME
9007 define t_ocs {
9008 read ver
9009 echo t_ocs
9010 echo "~^header list"; read hl; echo $hl;\
9011 vput csop es substr "$hl" 0 1
9012 if [ "$es" != 2 ]
9013 xcall bail "header list"
9014 endif
9016 call _work 1; echo $?
9017 echo "~^header insert cc splicy\ diet\ <splice@exam.ple>\ spliced";\
9018 read es; echo $es; vput csop es substr "$es" 0 1
9019 if [ "$es" != 2 ]
9020 xcall bail "be diet"
9021 endif
9022 echo "~^header insert cc <splice2@exam.ple>";\
9023 read es; echo $es; vput csop es substr "$es" 0 1
9024 if [ "$es" != 2 ]
9025 xcall bail "be diet2"
9026 endif
9028 call _work 2; echo $?
9029 echo "~^header insert bcc juicy\ juice\ <juice@exam.ple>\ spliced";\
9030 read es; echo $es;vput csop es substr "$es" 0 1
9031 if [ "$es" != 2 ]
9032 xcall bail "be juicy"
9033 endif
9034 echo "~^header insert bcc juice2@exam.ple";\
9035 read es; echo $es;vput csop es substr "$es" 0 1
9036 if [ "$es" != 2 ]
9037 xcall bail "be juicy2"
9038 endif
9039 echo "~^header insert bcc juice3\ <juice3@exam.ple>";\
9040 read es; echo $es;vput csop es substr "$es" 0 1
9041 if [ "$es" != 2 ]
9042 xcall bail "be juicy3"
9043 endif
9044 echo "~^header insert bcc juice4@exam.ple";\
9045 read es; echo $es;vput csop es substr "$es" 0 1
9046 if [ "$es" != 2 ]
9047 xcall bail "be juicy4"
9048 endif
9050 echo "~^header remove-at bcc 3";\
9051 read es; echo $es;vput csop es substr "$es" 0 1
9052 if [ "$es" != 2 ]
9053 xcall bail "remove juicy5"
9054 endif
9055 echo "~^header remove-at bcc 2";\
9056 read es; echo $es;vput csop es substr "$es" 0 1
9057 if [ "$es" != 2 ]
9058 xcall bail "remove juicy6"
9059 endif
9060 echo "~^header remove-at bcc 3";\
9061 read es; echo $es;vput csop es substr "$es" 0 3
9062 if [ "$es" != 501 ]
9063 xcall bail "failed to remove-at"
9064 endif
9065 # Add duplicates which ought to be removed!
9066 echo "~^header insert bcc juice4@exam.ple";\
9067 read es; echo $es;vput csop es substr "$es" 0 1
9068 if [ "$es" != 2 ]
9069 xcall bail "be juicy4-1"
9070 endif
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-2"
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-3"
9080 endif
9081 echo "~:set t_ocs"
9084 call _work 3; echo $?
9085 echo "~r - '__EOT'"
9086 vput ! i echo just knock if you can hear me;\
9087 i=0;\
9088 while [ $i -lt 24 ]; do printf "%s " $i; i=`expr $i + 1`; done;\
9089 echo relax
9090 echon shell-cmd says $?/$^ERRNAME: $i
9091 echo "~x will not become interpreted, we are reading until __EOT"
9092 echo "__EOT"
9093 read r_status; echo "~~r status output: $r_status"
9094 echo "~:echo $? $! $^ERRNAME"
9095 read r_status
9096 echo "~~r status from parent: $r_status"
9099 call _work 4; echo $?
9100 vput cwd cwd;echo cwd:$?
9101 readctl create $cwd/.treadctl ;echo readctl:$?/$^ERRNAME;\
9102 call _read
9105 call _work 5; echo $?
9106 echo "~^header show MAILX-Command"; read es;\
9107 call xerr $es "t_header 1000"; call read_mline_res
9108 echo "~^header show MAILX-raw-TO"; read es;\
9109 call xerr $es "t_header 1001"; xcall read_mline_res
9111 echoerr IT IS WRONG IF YOU SEE THIS
9113 define t_oce {
9114 echo on-compose-enter, mailx-command<$mailx-command>
9115 set t_oce autobcc=oce@exam.ple
9116 alternates alter1@exam.ple alter2@exam.ple
9117 alternates
9118 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
9119 echo mailx-subject<$mailx-subject>
9120 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
9121 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
9122 mailx-raw-bcc<$mailx-raw-bcc>
9123 echo mailx-orig-from<$mailx-orig-from> \
9124 mailx-orig-to<$mailx-orig-to> \
9125 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
9127 define t_ocl {
9128 echo on-compose-leave, mailx-command<$mailx-command>
9129 set t_ocl autocc=ocl@exam.ple
9130 unalternates *
9131 alternates alter3@exam.ple alter4@exam.ple
9132 alternates
9133 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
9134 echo mailx-subject<$mailx-subject>
9135 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
9136 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
9137 mailx-raw-bcc<$mailx-raw-bcc>
9138 echo mailx-orig-from<$mailx-orig-from> \
9139 mailx-orig-to<$mailx-orig-to> \
9140 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
9142 define t_occ {
9143 echo on-compose-cleanup, mailx-command<$mailx-command>
9144 set t_occ autocc=occ@exam.ple
9145 unalternates *
9146 alternates
9147 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
9148 echo mailx-subject<$mailx-subject>
9149 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
9150 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
9151 mailx-raw-bcc<$mailx-raw-bcc>
9152 echo mailx-orig-from<$mailx-orig-from> \
9153 mailx-orig-to<$mailx-orig-to> \
9154 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
9156 wysh set on-compose-splice=t_ocs \
9157 on-compose-splice-shell="read ver;echo t_ocs-shell;\
9158 echo \"~t shell@exam.ple\"; echo \"~:set t_ocs_sh\"" \
9159 on-compose-enter=t_oce on-compose-leave=t_ocl \
9160 on-compose-cleanup=t_occ
9161 ' > ./.tnotes 2>&1
9162 check_ex0 3-estat
9163 ${cat} ./.tnotes >> "${MBOX}"
9164 check 3 - "${MBOX}" '3986011319 2437'
9166 # Reply, forward, resend, Resend
9168 ${rm} "${MBOX}"
9169 printf '#
9170 set from="f1@z"
9171 m t1@z
9174 set from="du <f2@z>" stealthmua=noagent
9175 m t2@z
9178 ' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" -Snomemdebug -Sescape=! \
9179 > ./.tnotes 2>&1
9180 check_ex0 4-intro-estat
9182 printf '
9183 echo start: $? $! $^ERRNAME
9184 File %s
9185 echo File: $? $! $^ERRNAME;echo;echo
9186 reply 1
9187 this is content of reply 1
9189 echo reply 1: $? $! $^ERRNAME;echo;echo
9190 Reply 1 2
9191 this is content of Reply 1 2
9193 echo Reply 1 2: $? $! $^ERRNAME;echo;echo
9194 forward 1 fwdex@am.ple
9195 this is content of forward 1
9197 echo forward 1: $? $! $^ERRNAME;echo;echo
9198 wysh set forward-inject-head=$'"'"'-- \\
9199 forward (%%a)(%%d)(%%f)(%%i)(%%n)(%%r) --\\n'"'"'
9200 wysh set forward-inject-tail=$'"'"'-- \\
9201 end of forward (%%i) --\\n'"'"'
9202 forward 2 fwdex@am.ple
9203 this is content of forward 2
9205 echo forward 2: $? $! $^ERRNAME;echo;echo
9206 set showname
9207 forward 2 fwdex2@am.ple
9208 this is content of forward 2, 2nd, with showname set
9210 echo forward 2, 2nd: $? $! $^ERRNAME;echo;echo
9211 resend 1 2 resendex@am.ple
9212 echo resend 1 2: $? $! $^ERRNAME;echo;echo
9213 Resend 1 2 Resendex@am.ple
9214 echo Resend 1 2: $? $! $^ERRNAME;echo;echo
9215 ' "${MBOX}" |
9216 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sfullnames \
9217 -Smta=test://"$MBOX" \
9219 define bail {
9220 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
9222 define xerr {
9223 vput csop es substr "$1" 0 1
9224 if [ "$es" != 2 ]
9225 xcall bail "$2"
9228 define read_mline_res {
9229 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
9230 echo mline_res:$len/$es/$^ERRNAME: $hl
9231 if [ $es -ne $^ERR-NONE ]
9232 xcall bail read_mline_res
9233 elif [ $len -ne 0 ]
9234 \xcall read_mline_res
9237 define work_hl {
9238 echo "~^header show $1"; read es;\
9239 call xerr $es "work_hl $1"; echo $1; call read_mline_res
9240 if [ $# -gt 1 ]
9241 shift
9242 xcall work_hl "$@"
9245 define t_ocs {
9246 read ver
9247 echo t_ocs version $ver
9248 echo "~^header list"; read hl; echo $hl;\
9249 echoerr the header list is $hl;\
9250 call xerr "$hl" "header list"
9251 eval vpospar set $hl
9252 shift
9253 xcall work_hl "$@"
9254 echoerr IT IS WRONG IF YOU SEE THIS
9256 define t_oce {
9257 echo on-XY-enter, mailx-command<$mailx-command>
9258 set t_oce autobcc=oce@exam.ple
9259 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
9260 echo mailx-subject<$mailx-subject>
9261 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
9262 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
9263 mailx-raw-bcc<$mailx-raw-bcc>
9264 echo mailx-orig-from<$mailx-orig-from> \
9265 mailx-orig-to<$mailx-orig-to> \
9266 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
9268 define t_ocl {
9269 echo on-XY-leave, mailx-command<$mailx-command>
9270 set t_ocl autocc=ocl@exam.ple
9271 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
9272 echo mailx-subject<$mailx-subject>
9273 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
9274 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
9275 mailx-raw-bcc<$mailx-raw-bcc>
9276 echo mailx-orig-from<$mailx-orig-from> \
9277 mailx-orig-to<$mailx-orig-to> \
9278 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
9280 define t_occ {
9281 echo on-XY-cleanup, mailx-command<$mailx-command>
9282 set t_occ autocc=occ@exam.ple
9283 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
9284 echo mailx-subject<$mailx-subject>
9285 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
9286 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
9287 mailx-raw-bcc<$mailx-raw-bcc>
9288 echo mailx-orig-from<$mailx-orig-from> \
9289 mailx-orig-to<$mailx-orig-to> \
9290 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
9292 wysh set on-compose-splice=t_ocs \
9293 on-compose-enter=t_oce on-compose-leave=t_ocl \
9294 on-compose-cleanup=t_occ \
9295 on-resend-enter=t_oce on-resend-cleanup=t_occ
9296 ' >> ./.tnotes 2>&1
9297 check_ex0 4-estat
9298 ${cat} ./.tnotes >> "${MBOX}"
9299 check 4 - "${MBOX}" '1850092468 11799'
9301 t_epilog "${@}"
9302 } # }}}
9304 t_mass_recipients() {
9305 t_prolog "${@}"
9307 if have_feat cmd-vexpr; then :; else
9308 t_echoskip '[!CMD_VEXPR]'
9309 t_epilog "${@}"
9310 return
9313 ${cat} <<'__EOT__' > ./.trc
9314 define bail {
9315 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
9317 define ins_addr {
9318 wysh set nr=$1 hn=$2
9319 echo "~$hn $hn$nr@$hn"; echo '~:echo $?'; read es
9320 if [ "$es" -ne 0 ]
9321 xcall bail "ins_addr $hn 1-$nr"
9323 vput vexpr nr + $nr 1
9324 if [ "$nr" -le "$maximum" ]
9325 xcall ins_addr $nr $hn
9328 define bld_alter {
9329 wysh set nr=$1 hn=$2
9330 alternates $hn$nr@$hn
9331 vput vexpr nr + $nr 2
9332 if [ "$nr" -le "$maximum" ]
9333 xcall bld_alter $nr $hn
9336 define t_ocs {
9337 read ver
9338 call ins_addr 1 t
9339 call ins_addr 1 c
9340 call ins_addr 1 b
9342 define t_ocl {
9343 if [ "$t_remove" != '' ]
9344 call bld_alter 1 t
9345 call bld_alter 2 c
9348 set on-compose-splice=t_ocs on-compose-leave=t_ocl
9349 __EOT__
9351 printf 'm this-goes@nowhere\nbody\n!.\n' |
9352 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
9353 -X'source ./.trc' -Smta=test://"$MBOX" -Smaximum=${LOOPS_MAX} \
9354 >./.tall 2>&1
9355 check_ex0 1-estat
9356 ${cat} ./.tall >> "${MBOX}"
9357 if [ ${LOOPS_MAX} -eq ${LOOPS_BIG} ]; then
9358 check 1-${LOOPS_BIG} - "${MBOX}" '3835365533 51534'
9359 elif [ ${LOOPS_MAX} -eq ${LOOPS_SMALL} ]; then
9360 check 1-${LOOPS_SMALL} - "${MBOX}" '3647549277 4686'
9363 ${rm} "${MBOX}"
9364 printf 'm this-goes@nowhere\nbody\n!.\n' |
9365 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
9366 -St_remove=1 -X'source ./.trc' -Smta=test://"$MBOX" \
9367 -Smaximum=${LOOPS_MAX} \
9368 >./.tall 2>&1
9369 check_ex0 2-estat
9370 ${cat} ./.tall >> "${MBOX}"
9371 if [ ${LOOPS_MAX} -eq ${LOOPS_BIG} ]; then
9372 check 2-${LOOPS_BIG} - "${MBOX}" '3768249992 34402'
9373 elif [ $LOOPS_MAX -eq ${LOOPS_SMALL} ]; then
9374 check 2-${LOOPS_SMALL} - "${MBOX}" '4042568441 3170'
9377 t_epilog "${@}"
9380 t_lreply_futh_rth_etc() {
9381 t_prolog "${@}"
9383 ${cat} <<-_EOT > ./.tmbox
9384 From neverneverland Sun Jul 23 13:46:25 2017
9385 Subject: Bugstop: five miles out 1
9386 Reply-To: mister originator2 <mr2@originator>, bugstop@five.miles.out
9387 From: mister originator <mr@originator>
9388 To: bugstop-commit@five.miles.out, laber@backe.eu
9389 Cc: is@a.list
9390 Mail-Followup-To: bugstop@five.miles.out, laber@backe.eu, is@a.list
9391 In-reply-to: <20170719111113.bkcMz%laber@backe.eu>
9392 Date: Wed, 19 Jul 2017 09:22:57 -0400
9393 Message-Id: <20170719132257.766AF781267@originator>
9394 Status: RO
9396 > |Sorry, I think I misunderstand something. I would think that
9398 That's appalling.
9400 From neverneverland Fri Jul 7 22:39:11 2017
9401 Subject: Bugstop: five miles out 2
9402 Reply-To: mister originator2<mr2@originator>,bugstop@five.miles.out,is@a.list
9403 Content-Transfer-Encoding: 7bit
9404 From: mister originator <mr@originator>
9405 To: bugstop-commit@five.miles.out
9406 Cc: is@a.list
9407 Message-ID: <149945963975.28888.6950788126957753723.reportbug@five.miles.out>
9408 Date: Fri, 07 Jul 2017 16:33:59 -0400
9409 Status: R
9411 capable of changing back.
9413 From neverneverland Fri Jul 7 22:42:00 2017
9414 Subject: Bugstop: five miles out 3
9415 Reply-To: mister originator2 <mr2@originator>, bugstop@five.miles.out
9416 Content-Transfer-Encoding: 7bit
9417 From: mister originator <mr@originator>
9418 To: bugstop-commit@five.miles.out
9419 Cc: is@a.list
9420 Message-ID: <149945963975.28888.6950788126957753746.reportbug@five.miles.out>
9421 Date: Fri, 07 Jul 2017 16:33:59 -0400
9422 List-Post: <mailto:bugstop@five.miles.out>
9423 Status: R
9425 are you ready, boots?
9427 From neverneverland Sat Aug 19 23:15:00 2017
9428 Subject: Bugstop: five miles out 4
9429 Reply-To: mister originator2 <mr2@originator>, bugstop@five.miles.out
9430 Content-Transfer-Encoding: 7bit
9431 From: mister originator <mr@originator>
9432 To: bugstop@five.miles.out
9433 Cc: is@a.list
9434 Message-ID: <149945963975.28888.6950788126qtewrqwer.reportbug@five.miles.out>
9435 Date: Fri, 07 Jul 2017 16:33:59 -0400
9436 List-Post: <mailto:bugstop@five.miles.out>
9437 Status: R
9439 are you ready, boots?
9440 _EOT
9444 ${cat} <<-'_EOT' | ${MAILX} ${ARGS} -Sescape=! -Smta=test://"$MBOX" \
9445 -Rf ./.tmbox >> "${MBOX}" 2>&1
9446 define r {
9447 wysh set m="This is text of \"reply ${1}."
9448 reply 1 2 3
9449 !I m
9452 !I m
9455 !I m
9458 echo -----After reply $1.1 - $1.3: $?/$^ERRNAME
9460 define R {
9461 wysh set m="This is text of \"Reply ${1}."
9462 eval Reply $2
9463 !I m
9464 !I 2
9467 echo -----After Reply $1.$2: $?/$^ERRNAME
9469 define _Lh {
9470 read protover
9471 echo '~I m'
9472 echo '~I n'
9473 echo '".'
9475 define _Ls {
9476 wysh set m="This is text of \"Lreply ${1}." on-compose-splice=_Lh n=$2
9477 eval Lreply $2
9479 define L {
9480 # We need two indirections for this test: one for the case that Lreply
9481 # fails because of missing recipients: we need to read EOF next, thus
9482 # place this in _Ls last; and second for the succeeding cases EOF is
9483 # not what these should read, so go over the backside and splice it in!
9484 # (A shame we do not have redirection++ as a Bourne/K/POSIX shell!)
9485 call _Ls "$@"
9486 echo -----After Lreply $1.$2: $?/$^ERRNAME
9488 define x {
9489 localopts call-fixate yes
9490 call r $1
9491 call R $1 1; call R $1 2; call R $1 3; call R $1 4
9492 call L $1 1; call L $1 2; call L $1 3
9494 define tweak {
9495 echo;echo '===== CHANGING === '"$*"' =====';echo
9496 eval "$@"
9499 set from=laber@backe.eu
9500 mlist is@a.list
9501 call x 1
9502 call tweak set reply-to-honour
9503 call x 2
9504 call tweak set followup-to
9505 call x 3
9506 call tweak set followup-to-honour
9507 call x 4
9508 call tweak mlist bugstop@five.miles.out
9509 call x 5
9510 call tweak mlsubscribe bugstop@five.miles.out
9511 call x 6
9512 call tweak set recipients-in-cc
9513 call x 7
9514 # While here, test that *fullnames* works (also here)
9515 call tweak set fullnames
9516 reply 1
9517 This message should have *fullnames* in the header.
9519 # Revert
9520 call tweak unmlsubscribe bugstop@five.miles.out';' \
9521 set followup-to-add-cc nofullnames
9522 call x 8
9523 call tweak mlsubscribe bugstop@five.miles.out
9524 call x 9
9525 _EOT
9527 check_ex0 1-estat
9528 if have_feat uistrings; then
9529 check 1 - "${MBOX}" '1519985418 39828'
9530 else
9531 t_echoskip '1:[!UISTRINGS]'
9536 ${cat} <<-_EOT > ./.tmbox
9537 From tom@i-i.example Thu Oct 26 03:15:55 2017
9538 Date: Wed, 25 Oct 2017 21:15:46 -0400
9539 From: tom <tom@i-i.example>
9540 To: Steffen Nurpmeso <steffen@sdaoden.eu>
9541 Cc: tom <tom@i-i.example>
9542 Subject: Re: xxxx yyyyyyyy configure does not really like a missing zzzzz
9543 Message-ID: <20171026011546.GA11643@i-i.example>
9544 Reply-To: tom@i-i.example
9545 References: <20171025214601.T2pNd%steffen@sdaoden.eu>
9546 In-Reply-To: <20171025214601.T2pNd%steffen@sdaoden.eu>
9547 Status: R
9549 The report's useful :-)
9550 _EOT
9552 # Let us test In-Reply-To: removal starts a new thread..
9553 # This needs adjustment of *stealthmua*
9554 argadd='-Sstealthmua=noagent -Shostname'
9556 ${rm} "${MBOX}"
9557 printf 'reply 1\nthread\n!.\n' |
9558 ${MAILX} ${ARGS} -Sescape=! -Smta=test://"$MBOX" -Sreply-to-honour \
9559 ${argadd} -Rf ./.tmbox > .tall 2>&1
9560 check 2 0 "${MBOX}" '841868335 433'
9561 check 3 - .tall '4294967295 0'
9563 printf 'reply 1\nnew <- thread!\n!||%s -e "%s"\n!.\n' \
9564 "${sed}" '/^In-Reply-To:/d' |
9565 ${MAILX} ${ARGS} -Sescape=! -Smta=test://"$MBOX" -Sreply-to-honour \
9566 ${argadd} -Rf "${MBOX}" > .tall 2>&1
9567 check 4 0 "${MBOX}" '3136957908 771'
9568 check 5 - .tall '4294967295 0'
9570 printf 'reply 2\nold <- new <- thread!\n!.\n' |
9571 ${MAILX} ${ARGS} -Sescape=! -Smta=test://"$MBOX" -Sreply-to-honour \
9572 ${argadd} -Rf "${MBOX}" > .tall 2>&1
9573 check 6 0 "${MBOX}" '3036449053 1231'
9574 check 7 - .tall '4294967295 0'
9576 printf 'reply 3\nnew <- old <- new <- thread!\n!|| %s -e "%s"\n!.\n' \
9577 "${sed}" '/^In-Reply-To:/d' |
9578 ${MAILX} ${ARGS} -Sescape=! -Smta=test://"$MBOX" -Sreply-to-honour \
9579 ${argadd} -Rf "${MBOX}" > .tall 2>&1
9580 check 8 0 "${MBOX}" '2069841383 1583'
9581 check 9 - .tall '4294967295 0'
9583 # And follow-up testing whether changing In-Reply-To: to - starts a new
9584 # thread with only the message being replied-to.
9586 printf 'reply 1\nthread with only one ref!\n!||%s -e "%s"\n!.\n' \
9587 "${sed}" 's/^In-Reply-To:.*$/In-Reply-To:-/' |
9588 ${MAILX} ${ARGS} -Sescape=! -Smta=test://"$MBOX" -Sreply-to-honour \
9589 ${argadd} -Rf "${MBOX}" > .tall 2>&1
9590 check 10 0 "${MBOX}" '3155846378 2047'
9591 check 11 - .tall '4294967295 0'
9593 t_epilog "${@}"
9596 t_pipe_handlers() {
9597 t_prolog "${@}"
9599 if have_feat cmd-vexpr; then :; else
9600 t_echoskip '[!CMD_VEXPR]'
9601 t_epilog "${@}"
9602 return
9605 # "Test for" [d6f316a] (Gavin Troy)
9606 printf "m ${MBOX}\n~s subject1\nEmail body\n~.\nfi ${MBOX}\np\nx\n" |
9607 ${MAILX} ${ARGS} ${ADDARG_UNI} -Spipe-text/plain="?* ${cat}" > "${BODY}"
9608 check 1 0 "${MBOX}" '3942990636 118'
9609 check 2 - "${BODY}" '3951695530 170'
9611 ${rm} "${MBOX}"
9612 printf "m %s\n~s subject2\n~@%s\nBody2\n~.\nFi %s\nmimeview\nx\n" \
9613 "${MBOX}" "${TOPDIR}snailmail.jpg" "${MBOX}" |
9614 ${MAILX} ${ARGS} ${ADDARG_UNI} \
9615 -S 'pipe-text/plain=?' \
9616 -S 'pipe-image/jpeg=?=&?'\
9617 'trap \"'"${rm}"' -f '\ '\\"${MAILX_FILENAME_TEMPORARY}\\"\" EXIT;'\
9618 'trap \"trap \\\"\\\" INT QUIT TERM; exit 1\" INT QUIT TERM;'\
9619 '{ echo C=$MAILX_CONTENT;'\
9620 'echo C-E=$MAILX_CONTENT_EVIDENCE;'\
9621 'echo E-B-U=$MAILX_EXTERNAL_BODY_URL;'\
9622 'echo F=$MAILX_FILENAME;'\
9623 'echo F-G=not testable MAILX_FILENAME_GENERATED;'\
9624 'echo F-T=not testable MAILX_FILENAME_TEMPORARY;'\
9625 ''"${cksum}"' < \"${MAILX_FILENAME_TEMPORARY}\" |'\
9626 ''"${sed}"' -e "s/[ ]\{1,\}/ /g"; } > ./.tax 2>&1;'"${mv}"' ./.tax ./.tay' \
9627 > "${BODY}" 2>&1
9628 check 3 0 "${MBOX}" '1933681911 13435'
9629 check 4 - "${BODY}" '2036666633 493'
9630 check 4-hdl - ./.tay '144517347 151' async
9632 # Keep $MBOX..
9633 if [ -z "${ln}" ]; then
9634 t_echoskip '5:[ln(1) not found]'
9635 else
9636 # Let us fill in tmpfile, test auto-deletion
9637 printf 'Fi %s\nmimeview\nvput vexpr v file-stat .t.one-link\n'\
9638 'eval wysh set $v;echo should be $st_nlink link\nx\n' "${MBOX}" |
9639 ${MAILX} ${ARGS} ${ADDARG_UNI} \
9640 -S 'pipe-text/plain=?' \
9641 -S 'pipe-image/jpeg=?=++?'\
9642 'echo C=$MAILX_CONTENT;'\
9643 'echo C-E=$MAILX_CONTENT_EVIDENCE;'\
9644 'echo E-B-U=$MAILX_EXTERNAL_BODY_URL;'\
9645 'echo F=$MAILX_FILENAME;'\
9646 'echo F-G=not testable MAILX_FILENAME_GENERATED;'\
9647 'echo F-T=not testable MAILX_FILENAME_TEMPORARY;'\
9648 "${ln}"' -f $MAILX_FILENAME_TEMPORARY .t.one-link;'\
9649 ''"${cksum}"' < \"${MAILX_FILENAME_TEMPORARY}\" |'\
9650 ''"${sed}"' -e "s/[ ]\{1,\}/ /g"' \
9651 > "${BODY}" 2>&1
9652 check 5 0 "${BODY}" '4260004050 661'
9654 # Fill in ourselfs, test auto-deletion
9655 printf 'Fi %s\nmimeview\nvput vexpr v file-stat .t.one-link\n'\
9656 'eval wysh set $v;echo should be $st_nlink link\nx\n' "${MBOX}" |
9657 ${MAILX} ${ARGS} ${ADDARG_UNI} \
9658 -S 'pipe-text/plain=?' \
9659 -S 'pipe-image/jpeg=?++?'\
9660 "${cat}"' > $MAILX_FILENAME_TEMPORARY;'\
9661 'echo C=$MAILX_CONTENT;'\
9662 'echo C-E=$MAILX_CONTENT_EVIDENCE;'\
9663 'echo E-B-U=$MAILX_EXTERNAL_BODY_URL;'\
9664 'echo F=$MAILX_FILENAME;'\
9665 'echo F-G=not testable MAILX_FILENAME_GENERATED;'\
9666 'echo F-T=not testable MAILX_FILENAME_TEMPORARY;'\
9667 ''"${cksum}"' < \"${MAILX_FILENAME_TEMPORARY}\" |'\
9668 ''"${sed}"' -e "s/[ ]\{1,\}/ /g"' \
9669 > "${BODY}" 2>&1
9670 check 6 0 "${BODY}" '4260004050 661'
9672 # And the same, via copiousoutput (fake)
9673 printf 'Fi %s\np\nvput vexpr v file-stat .t.one-link\n'\
9674 'eval wysh set $v;echo should be $st_nlink link\nx\n' "${MBOX}" |
9675 ${MAILX} ${ARGS} ${ADDARG_UNI} \
9676 -S 'pipe-text/plain=?' \
9677 -S 'pipe-image/jpeg=?*++?'\
9678 "${cat}"' > $MAILX_FILENAME_TEMPORARY;'\
9679 'echo C=$MAILX_CONTENT;'\
9680 'echo C-E=$MAILX_CONTENT_EVIDENCE;'\
9681 'echo E-B-U=$MAILX_EXTERNAL_BODY_URL;'\
9682 'echo F=$MAILX_FILENAME;'\
9683 'echo F-G=not testable MAILX_FILENAME_GENERATED;'\
9684 'echo F-T=not testable MAILX_FILENAME_TEMPORARY;'\
9685 "${ln}"' -f $MAILX_FILENAME_TEMPORARY .t.one-link;'\
9686 ''"${cksum}"' < \"${MAILX_FILENAME_TEMPORARY}\" |'\
9687 ''"${sed}"' -e "s/[ ]\{1,\}/ /g"' \
9688 > "${BODY}" 2>&1
9689 check 7 0 "${BODY}" '709946464 677'
9692 t_epilog "${@}"
9695 t_mailcap() {
9696 t_prolog "${@}"
9698 if have_feat mailcap; then :; else
9699 t_echoskip '[!MAILCAP]'
9700 t_epilog "${@}"
9701 return
9704 ${cat} <<-'_EOT' > ./.tmailcap
9705 text/html; lynx -dump %s; copiousoutput; nametemplate=%s.html
9706 application/pdf; /Applications/Preview.app/Contents/MacOS/Preview %s;\
9707 nametemplate=%s.pdf;\
9708 test = [ "${OSTYPE}" = darwin ]
9709 application/pdf;\
9710 infile=%s\;\
9711 trap "rm -f ${infile}" EXIT\;\
9712 trap "exit 75" INT QUIT TERM\;\
9713 mupdf "${infile}";\
9714 test = [ -n "${DISPLAY}" ];\
9715 nametemplate = %s.pdf; x-mailx-async
9716 application/pdf; pdftotext -layout %s -; nametemplate=%s.pdf; copiousoutput
9717 application/*; echo "This is \\"%t\\" but \
9718 is 50 \% Greek to me" \; < %s head -c 1024 | cat -vet; \
9719 description=" this is\;a \"wildcard\" match, no trailing quote! ;\
9720 copiousoutput; x-mailx-noquote
9724 bummer/hummer;;
9725 application/postscript; ps-to-terminal %s;\ needsterminal
9726 application/postscript; ps-to-terminal %s; \compose=idraw %s
9727 x-be2; the-cmd %s; \
9728 print=print-cmd %s ; \
9729 copiousoutput ; \
9730 compose=compose-cmd -d %s ; \
9731 textualnewlines; \
9732 composetyped = composetyped-cmd -dd %s ; \
9733 x-mailx-noquote ;\
9734 edit=edit-cmd -ddd %s; \
9735 description = a\;desc;\
9736 nametemplate=%s.be2;\
9737 test = this is "a" test ; \
9738 x-mailx-test-once ;\
9739 x11-bitmap = x11-bitmap.bpm;;;;;
9740 application/*; echo "is \"%t\" \
9741 50 \% Greek" \; cat %s; copiousoutput; \; description="catch-all buddy";
9742 audio/*; showaudio;compose=%n
9743 image/jpeg; showpicture -viewer xv %s
9744 image/*; showpicture %s
9745 message/partial; showpartial %s %{id} %{number} %{total}
9746 application/postscript ; lpr %s ; label="PS File";\
9747 compose="getx PS %s"
9748 application/atomicmail; atomicmail %s ; needsterminal
9749 application/andrew-inset; ezview %s ; copiousoutput;\
9750 edit=ez -d %s; compose="ez -d %s"; label="Andrew i/d"
9751 text/richtext; xy iso-8859-1 -e richtext -p %s; \
9752 test=test "`echo %{charset} | tr A-Z a-z`" = iso-8859-1; copiousoutput
9753 text/plain; xy iso-8859-1 %s;\
9754 test=test "`echo %{charset} | tr A-Z a-z`" = iso-8859-1; copiousoutput
9755 text/richtext; rich %s %{not-closed; copiousoutput
9756 default; cat %s; copiousoutput
9757 _EOT
9758 ${chmod} 0644 ./.tmailcap
9760 printf 'm;echo =1/$?;m c;echo =2/$?;
9761 mailca loa;echo =3/$?;mailc s;echo =4/$?' |
9762 MAILCAPS=./.tmailcap ${MAILX} -X'commandalias m mailcap' ${ARGS} \
9763 > ./.tall 2>./.terr
9764 check 1 0 ./.tall '2012114724 3064'
9765 have_feat uistrings && i='3903313993 2338' || i='4294967295 0'
9766 check 2 - ./.terr "${i}"
9770 echo 'From me with love' | ${MAILX} ${ARGS} -s sub1 "${MBOX}"
9771 check 3 0 "${MBOX}" '4224630386 228'
9773 # For reproducability, one pseudo check with cat(1) and mv(1)
9774 printf '#
9775 text/plain; echo p-1-1\\;< %%s cat\\;echo p-1-2;\\
9776 test=echo X >> ./.terrmc\\; [ -n "$XY" ];x-mailx-test-once
9777 text/plain; echo p-2-1\\;< %%s cat\\;echo p-2-2;\\
9778 test=echo Y >> ./.terrmc\\;[ -z "$XY" ]
9779 text/plain; { file=%%s\\; echo p-3-1 = ${file##*.}\\;\\
9780 </dev/null cat %%s\\;echo p-3-2\\; } > ./.tx\\; mv -f ./.tx ./.tasy;\\
9781 test=[ -n "$XY" ];nametemplate=%%s.txt;x-mailx-async
9782 text/plain; echo p-4-1\\;cat\\;echo p-4-2;copiousoutput
9783 ' > ./.tmailcap
9785 </dev/null MAILCAPS=./.tmailcap TMPDIR=`${pwd}` \
9786 ${MAILX} ${ARGS} -Snomailcap-disable \
9787 -Y '\mailcap' \
9788 -Rf "${MBOX}" > ./.tall 2>./.terr
9789 check 4.pre 0 ./.tall '1428075831 455'
9791 # Same with real programs
9792 printf '#
9793 text/plain; echo p-1-1\\;< %%s %s\\;echo p-1-2;\\
9794 test=echo X >> ./.terrmc\\; [ -n "$XY" ];x-mailx-test-once
9795 text/plain; echo p-2-1\\;< %%s %s\\;echo p-2-2;\\
9796 test=echo Y >> ./.terrmc\\;[ -z "$XY" ]
9797 text/plain; { file=%%s\\; echo p-3-1 = ${file##*.}\\;\\
9798 </dev/null %s %%s\\;echo p-3-2\\; } > ./.tx\\; %s -f ./.tx ./.tasy;\\
9799 test=[ -n "$XY" ];nametemplate=%%s.txt;x-mailx-async
9800 text/plain; echo p-4-1\\;%s\\;echo p-4-2;copiousoutput
9801 ' "${cat}" "${cat}" "${cat}" "${mv}" "${cat}" > ./.tmailcap
9803 </dev/null MAILCAPS=./.tmailcap TMPDIR=`${pwd}` \
9804 ${MAILX} ${ARGS} -Snomailcap-disable \
9805 -Y '#
9806 \echo =1
9807 \mimeview
9808 \echo =2
9809 \environ set XY=yes
9810 \mimeview
9811 \echo =3
9812 \type
9813 \echo =4
9815 -Rf "${MBOX}" > ./.tall 2>./.terr
9816 check 4 0 ./.tall '1912261831 831'
9817 check 5 - ./.terr '4294967295 0'
9818 check 6 - ./.terrmc '2376112102 6'
9819 check 7 - ./.tasy '3913344578 37' async
9821 # "Binary data"; ensure all possible temporary file / nametemplate
9822 # etc. paths are taken: avoid 2nd e7a60732c1906aefe4755fd61c5ffa81eeca0af0
9824 ${rm} -f "${MBOX}"
9825 printf 'du\x7fbo€o\bm' > ./.tatt.pdf
9826 printf 'du' | ${MAILX} ${ARGS} -a ./.tatt.pdf -s test "${MBOX}"
9827 check 8 0 "${MBOX}" '3444709420 644'
9829 printf '#
9830 # stdin
9831 application/pdf; echo p-1-1\\;%s\\;echo p-1-2; test=[ "$XY" = "" ]
9832 # tmpfile, no template
9833 application/pdf; echo p-2-1\\;< %%s %s\\;echo p-2-2; test = [ "$XY" = two ]
9834 # tmpfile, template
9835 application/pdf; echo p-3-1\\;< %%s %s\\;echo p-3-2; test=[ "$XY" = three ];\\
9836 nametemplate=%%s.txt
9837 # tmpfile, template, async
9838 application/pdf; { file=%%s \\; echo p-4-1 = ${file##*.}\\;\\
9839 </dev/null %s %%s\\;echo p-4-2\\; } > ./.tx\\; %s -f ./.tx ./.tasy;\\
9840 test=[ "$XY" = four ] ; nametemplate = %%s.txt ; x-mailx-async
9841 # copious,stdin
9842 application/pdf; echo p-5-1\\;%s\\;echo p-5-2; test=[ "$XY" = 1 ];\\
9843 copiousoutput
9844 # copious, tmpfile, no template
9845 application/pdf; echo p-6-1\\;< %%s %s\\;echo p-6-2; test = [ "$XY" = 2 ];\\
9846 copiousoutput
9847 # copious, tmpfile, template
9848 application/pdf; echo p-7-1\\;< %%s %s\\;echo p-7-2;test = [ "$XY" = 3 ];\\
9849 nametemplate=%%s.txt; copiousoutput
9850 ' "${cat}" "${cat}" "${cat}" "${cat}" "${mv}" "${cat}" "${cat}" "${cat}" \
9851 > ./.tmailcap
9853 </dev/null XY= MAILCAPS=./.tmailcap TMPDIR=`${pwd}` \
9854 ${MAILX} ${ARGS} -Snomailcap-disable \
9855 -Y '#
9856 \echo =1
9857 \mimeview
9858 \echo =2
9859 \environ set XY=two
9860 \mimeview
9861 \echo =3
9862 \environ set XY=three
9863 \mimeview
9864 \echo =4
9865 \environ set XY=four
9866 \mimeview
9867 \echo =5
9868 \environ set XY=1
9869 \type
9870 \echo =6
9871 \environ set XY=2
9872 \type
9873 \echo =7
9874 \environ set XY=3
9875 \type
9876 \echo =8
9878 -Rf "${MBOX}" > ./.tall 2>./.terr
9879 check 9 0 ./.tall '2388630345 3850'
9880 check 10 - ./.terr '4294967295 0'
9881 check 11 - ./.tasy '842146666 27' async
9883 # x-mailx-last-resort, x-mailx-ignore
9885 ${rm} -f "${MBOX}"
9886 printf 'in a pdf\n' > ./.tatt.pdf
9887 printf 'du\n' | ${MAILX} ${ARGS} -a ./.tatt.pdf -s test "${MBOX}"
9888 check 12 0 "${MBOX}" '3968874750 579'
9890 printf '#
9891 # stdin
9892 application/pdf;echo hidden;x-mailx-ignore
9893 application/pdf;echo hidden;copiousoutput;x-mailx-ignore
9894 application/pdf; echo pre\\;%s\\;echo post; x-mailx-last-resort
9895 ' "${cat}" > ./.tmailcap
9897 </dev/null XY= MAILCAPS=./.tmailcap TMPDIR=`${pwd}` \
9898 ${MAILX} ${ARGS} -Snomailcap-disable \
9899 -Y '#
9900 \echo =1
9901 \mimeview
9902 \echo =2
9903 \mimetype ?t application/pdf pdf
9904 \mimeview
9905 \echo =3
9906 \type
9907 \echo =4
9908 \unmimetype application/pdf
9909 \mimeview
9910 \echo =5
9912 -Rf "${MBOX}" > ./.tall 2>./.terr
9913 check 13 0 ./.tall '759843612 1961'
9914 check 14 - ./.terr '4294967295 0'
9916 t_epilog "${@}"
9918 # }}}
9920 # Unclassified rest {{{
9921 t_top() {
9922 t_prolog "${@}"
9924 t__gen_msg subject top1 to 1 from 1 cc 1 body 'body1-1
9925 body1-2
9927 body1-3
9928 body1-4
9931 body1-5
9932 ' > "${MBOX}"
9933 t__gen_msg subject top2 to 1 from 1 cc 1 body 'body2-1
9934 body2-2
9937 body2-3
9940 body2-4
9941 body2-5
9942 ' >> "${MBOX}"
9944 ${MAILX} ${ARGS} -Rf -Y '#
9945 \top 1
9946 \echo --- $?/$^ERRNAME, 1; \set toplines=10
9947 \top 1
9948 \echo --- $?/$^ERRNAME, 2; \set toplines=5
9949 \headerpick top retain subject # For top
9950 \headerpick type retain to subject # For Top
9951 \top 1
9952 \echo --- $?/$^ERRNAME, 3; \set topsqueeze
9953 \top 1 2
9954 \echo --- $?/$^ERRNAME, 4
9955 \Top 1
9956 \echo --- $?/$^ERRNAME, 5
9957 # ' "${MBOX}" > ./.tall 2>&1
9958 check 1 0 ./.tall '2556125754 705'
9960 t_epilog "${@}"
9963 t_s_mime() {
9964 t_prolog "${@}"
9966 if have_feat smime; then :; else
9967 t_echoskip '[!SMIME]'
9968 t_epilog "${@}"
9969 return
9972 ${cat} <<-_EOT > ./.t.conf
9973 [req]
9974 x509_extensions = extensions
9975 distinguished_name = req_distinguished_name
9976 attributes = req_attributes
9977 prompt = no
9978 output_password = Pacem_in_terris
9980 [extensions]
9981 basicConstraints = CA:FALSE
9982 # Needs a CA for that keyUsage = digitalSignature
9983 extendedKeyUsage = emailProtection
9985 [req_distinguished_name]
9986 C = GB
9987 ST = Over the
9988 L = rainbow
9989 O = S-nail
9990 OU = S-nail.smime
9991 CN = S-nail.test2
9992 emailAddress = test@localhost
9994 [req_attributes]
9995 challengePassword = hi ca it is me me me
9996 _EOT
9998 doit() {
9999 _z=${1}
10001 if [ "${_z}" = 0 ]; then
10002 _pass=
10003 _osslreq=-nodes
10004 _ossl=
10005 else
10006 _pass=Pacem_in_terris
10007 _osslreq=
10008 _ossl='-passin pass:'${_pass}
10011 ${rm} -f ./.VERIFY ./.ENCRYPT ./.DECRYPT
10013 openssl req ${_osslreq} ${_ossl} -x509 -days 3650 -config ./.t.conf \
10014 -newkey rsa:1024 -keyout ./.tkey.pem -out ./.tcert.pem >>${ERR} 2>&1
10015 check_ex0 ${_z}
10016 _z=`add ${_z} 1`
10018 ${cat} ./.tkey.pem ./.tcert.pem > ./.tpair.pem
10020 # Sign/verify
10021 echo bla | ${MAILX} ${ARGS} \
10022 -Ssmime-sign -Ssmime-sign-cert=./.tpair.pem -Sfrom=test@localhost \
10023 -Ssmime-sign-digest=sha1 \
10024 -S password-test@localhost.smime-cert-key=${_pass} \
10025 -s 'S/MIME test' ./.VERIFY >>${ERR} 2>&1
10026 check_ex0 ${_z}-estat
10027 ${awk} '
10028 BEGIN{ skip=0 }
10029 /^Content-Description: /{ skip = 2; print; next }
10030 /^$/{ if(skip) --skip }
10031 { if(!skip) print }
10033 < ./.VERIFY > "${MBOX}"
10034 check ${_z} - "${MBOX}" '335634014 644'
10035 _z=`add ${_z} 1`
10037 printf 'verify\nx\n' |
10038 ${MAILX} ${ARGS} -Ssmime-ca-file=./.tcert.pem -Serrexit \
10039 -R -f ./.VERIFY >>${ERR} 2>&1
10040 check_ex0 ${_z} # XXX pipe
10041 _z=`add ${_z} 1`
10043 openssl smime -verify -CAfile ./.tcert.pem -in ./.VERIFY >>${ERR} 2>&1
10044 check_ex0 ${_z}
10045 _z=`add ${_z} 1`
10047 # (signing +) encryption / decryption
10048 echo bla |
10049 ${MAILX} ${ARGS} \
10050 -Smta=test://./.ENCRYPT \
10051 -Ssmime-force-encryption -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
10052 -Ssmime-sign-digest=sha1 \
10053 -Ssmime-sign -Ssmime-sign-cert=./.tpair.pem -Sfrom=test@localhost \
10054 -S password-test@localhost.smime-cert-key=${_pass} \
10055 -s 'S/MIME test' recei@ver.com >>${ERR} 2>&1
10056 check_ex0 ${_z}-estat
10057 ${sed} -e '/^$/,$d' < ./.ENCRYPT > "${MBOX}"
10058 check ${_z} - "${MBOX}" '2359655411 336'
10059 _z=`add ${_z} 1`
10061 printf 'decrypt ./.DECRYPT\nfi ./.DECRYPT\nverify\nx\n' |
10062 ${MAILX} ${ARGS} \
10063 -Smta=test://./.ENCRYPT \
10064 -Ssmime-ca-file=./.tcert.pem \
10065 -Ssmime-sign-cert=./.tpair.pem \
10066 -Sfrom=test@localhost \
10067 -S password-test@localhost.smime-cert-key=${_pass} \
10068 -Serrexit -R -f ./.ENCRYPT >>${ERR} 2>&1
10069 check_ex0 ${_z}-estat
10070 ${awk} '
10071 BEGIN{ skip=0 }
10072 /^Content-Description: /{ skip = 2; print; next }
10073 /^$/{ if(skip) --skip }
10074 { if(!skip) print }
10076 < ./.DECRYPT > "${MBOX}"
10077 check ${_z} - "${MBOX}" '2602978204 940'
10078 _z=`add ${_z} 1`
10080 (openssl smime -decrypt ${_ossl} -inkey ./.tkey.pem -in ./.ENCRYPT |
10081 openssl smime -verify -CAfile ./.tcert.pem) >>${ERR} 2>&1
10082 check_ex0 ${_z} # XXX pipe..
10083 _z=`add ${_z} 1`
10085 ${rm} ./.ENCRYPT
10086 echo bla | ${MAILX} ${ARGS} \
10087 -Smta=test://./.ENCRYPT \
10088 -Ssmime-force-encryption -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
10089 -Sfrom=test@localhost \
10090 -S password-test@localhost.smime-cert-key=${_pass} \
10091 -s 'S/MIME test' recei@ver.com >>${ERR} 2>&1
10092 check_ex0 ${_z}-estat
10093 ${sed} -e '/^$/,$d' < ./.ENCRYPT > "${MBOX}"
10094 check ${_z} - "${MBOX}" '2359655411 336'
10095 _z=`add ${_z} 1`
10097 ${rm} ./.DECRYPT
10098 # Note: deduce from *sign-cert*, not from *from*!
10099 printf 'decrypt ./.DECRYPT\nx\n' | ${MAILX} ${ARGS} \
10100 -Smta=test://./.ENCRYPT \
10101 -Ssmime-sign-cert-recei@ver.com=./.tpair.pem \
10102 -S password-recei@ver.com.smime-cert-key=${_pass} \
10103 -Serrexit -R -f ./.ENCRYPT >>${ERR} 2>&1
10104 check ${_z} 0 ./.DECRYPT '2453471323 431'
10105 _z=`add ${_z} 1`
10107 openssl smime ${_ossl} -decrypt -inkey ./.tkey.pem -in ./.ENCRYPT \
10108 >>${ERR} 2>&1
10109 check_ex0 ${_z}
10111 unset _z _pass _osslreq _ossl
10114 doit 0
10115 doit 10
10117 t_epilog "${@}"
10119 # }}}
10121 # xxx Note: t_z() was the first test (series) written. Today many
10122 # xxx aspects are (better) covered by other tests above, some are not.
10123 # xxx At some future date and time, convert the last remains not covered
10124 # xxx elsewhere to a real t_* test and drop it
10125 t_z() {
10126 t_prolog "${@}"
10128 # Test for [260e19d] (Juergen Daubert)
10129 echo body | ${MAILX} ${ARGS} "${MBOX}"
10130 check 4 0 "${MBOX}" '2948857341 94'
10132 # "Test for" [c299c45] (Peter Hofmann) TODO shouldn't end up QP-encoded?
10133 ${rm} "${MBOX}"
10134 ${awk} 'BEGIN{
10135 for(i = 0; i < 10000; ++i)
10136 printf "\xC3\xBC"
10137 #printf "\xF0\x90\x87\x90"
10138 }' | ${MAILX} ${ARGS} ${ADDARG_UNI} -s TestSubject "${MBOX}"
10139 check 7 0 "${MBOX}" '1707496413 61812'
10141 t_epilog "${@}"
10144 # Test support {{{
10145 t__gen_msg() {
10146 t___gen_msg '' "${@}"
10149 t__gen_mimemsg() {
10150 t___gen_msg 1 "${@}"
10153 t___gen_msg() {
10154 ismime=${1}
10155 shift
10157 t___header() {
10158 printf '%s: ' ${1}
10159 case "${3}" in
10160 [0-9]*)
10161 ___hi=1
10162 while [ ${___hi} -le ${3} ]; do
10163 [ ${___hi} -gt 1 ] && printf ', '
10164 printf '%s%s <%s%s@exam.ple>' ${1} ${___hi} ${2} ${___hi}
10165 ___hi=`add ${___hi} 1`
10166 done
10169 printf '%s' "${3}"
10171 esac
10172 printf '\n'
10175 printf 'From reproducible_build Wed Oct 2 01:50:07 1996
10176 Date: Wed, 02 Oct 1996 01:50:07 +0000
10179 body=Body
10180 while [ ${#} -ge 2 ]; do
10181 case "${1}" in
10182 from) t___header From from "${2}";;
10183 to) t___header To to "${2}";;
10184 cc) t___header Cc cc "${2}";;
10185 bcc) t___header Bcc bcc "${2}";;
10186 subject) printf 'Subject: %s\n' "${2}";;
10187 body) body="${2}";;
10188 esac
10189 shift 2
10190 done
10192 if [ -z "${ismime}" ]; then
10193 printf '\n%s\n\n' "${body}"
10194 else
10195 printf 'MIME-Version: 1.0
10196 Message-ID: <20200204225307.FaKeD%%bo@oo>
10197 Content-Type: multipart/mixed; boundary="=BOUNDOUT="
10199 --=BOUNDOUT=
10200 Content-Type: multipart/alternative; boundary==BOUNDIN=
10202 --=BOUNDIN=
10203 Content-Type: text/plain; charset=utf-8
10204 Content-Transfer-Encoding: 8-bit
10208 --=BOUNDIN=
10209 Content-Type: text/html; charset=utf-8
10210 Content-Transfer-Encoding: 8-bit
10212 <HTML><BODY>%s<BR></BODY></HTML>
10214 --=BOUNDIN=--
10216 --=BOUNDOUT=
10217 Content-Type: text/troff
10219 Golden Brown
10221 --=BOUNDOUT=
10222 Content-Type: text/x-uuencode
10224 Aprendimos a quererte
10225 --=BOUNDOUT=--
10227 ' "${body}" "${body}"
10231 t__x1_msg() {
10232 ${cat} <<-_EOT
10233 From neverneverland Sun Jul 23 13:46:25 2017
10234 Subject: Bugstop: five miles out 1
10235 Reply-To: mister originator1 <mr1@originator>
10236 From: mister originator1 <mr1@originator>
10237 To: bugstop-commit@five.miles.out
10238 Cc: is1@a.list
10239 In-reply-to: <20170719111113.bkcMz%laber1@backe.eu>
10240 Date: Wed, 19 Jul 2017 09:22:57 -0400
10241 Message-Id: <20170719132257.766AF781267-1@originator>
10242 Mail-Followup-To: bugstop@five.miles.out, laber@backe.eu, is@a.list
10243 Status: RO
10245 That's appalling, I.
10247 _EOT
10250 t__x2_msg() {
10251 ${cat} <<-_EOT
10252 From neverneverland Sun Jul 23 13:47:25 2017
10253 Subject: Bugstop: five miles out 2
10254 Reply-To: mister originator2 <mr2@originator>
10255 From: mister originator2 <mr2@originator>
10256 To: bugstop-commit@five.miles.out
10257 Cc: is2@a.list
10258 In-reply-to: <20170719111113.bkcMz%laber2@backe.eu>
10259 Date: Wed, 19 Jul 2017 09:23:57 -0400
10260 Message-Id: <20170719132257.766AF781267-2@originator>
10261 Status: RO
10263 That's appalling, II.
10265 _EOT
10268 t__x3_msg() {
10269 ${cat} <<-_EOT
10270 From neverneverland Sun Jul 23 13:48:25 2017
10271 Subject: Bugstop: five miles out 3
10272 Reply-To: mister originator3 <mr3@originator>
10273 From: mister originator3 <mr3@originator>
10274 To: bugstop-commit@five.miles.out
10275 Cc: is3@a.list
10276 In-reply-to: <20170719111113.bkcMz%laber3@backe.eu>
10277 Date: Wed, 19 Jul 2017 09:24:57 -0400
10278 Message-Id: <20170719132257.766AF781267-3@originator>
10279 Status: RO
10281 That's appalling, III.
10283 _EOT
10286 t__put_subject() {
10287 # MIME encoding (QP) stress message subject
10288 printf 'Äbrä Kä?dä=brö Fü?di=bus? '\
10289 'adadaddsssssssddddddddddddddddddddd'\
10290 'ddddddddddddddddddddddddddddddddddd'\
10291 'ddddddddddddddddddddddddddddddddddd'\
10292 'dddddddddddddddddddd Hallelulja? Od'\
10293 'er?? eeeeeeeeeeeeeeeeeeeeeeeeeeeeee'\
10294 'eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'\
10295 'eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee f'\
10296 'fffffffffffffffffffffffffffffffffff'\
10297 'fffffffffffffffffffff ggggggggggggg'\
10298 'ggggggggggggggggggggggggggggggggggg'\
10299 'ggggggggggggggggggggggggggggggggggg'\
10300 'ggggggggggggggggggggggggggggggggggg'\
10301 'gggggggggggggggg'
10304 t__put_body() {
10305 # MIME encoding (QP) stress message body
10306 printf \
10307 'Ich bin eine DÖS-Datäi mit sehr langen Zeilen und auch '\
10308 'sonst bin ich ganz schön am Schleudern, da kannste denke '\
10309 "wasde willst, gelle, gelle, gelle, gelle, gelle.\r\n"\
10310 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst \r\n"\
10311 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1\r\n"\
10312 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12\r\n"\
10313 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123\r\n"\
10314 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1234\r\n"\
10315 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12345\r\n"\
10316 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123456\r\n"\
10317 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1234567\r\n"\
10318 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12345678\r\n"\
10319 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123456789\r\n"\
10320 "Unn ausserdem habe ich trailing SP/HT/SP/HT whitespace \r\n"\
10321 "Unn ausserdem habe ich trailing HT/SP/HT/SP whitespace \r\n"\
10322 "auf den zeilen vorher.\r\n"\
10323 "From am Zeilenbeginn und From der Mitte gibt es auch.\r\n"\
10324 ".\r\n"\
10325 "Die letzte Zeile war nur ein Punkt.\r\n"\
10326 "..\r\n"\
10327 "Das waren deren zwei.\r\n"\
10328 " \r\n"\
10329 "Die letzte Zeile war ein Leerschritt.\n"\
10330 "=VIER = EQUAL SIGNS=ON A LINE=\r\n"\
10331 "Prösterchen.\r\n"\
10332 ".\n"\
10333 "Die letzte Zeile war nur ein Punkt, mit Unix Zeilenende.\n"\
10334 "..\n"\
10335 "Das waren deren zwei. ditto.\n"\
10336 "Prösterchen.\n"\
10337 "Unn ausseerdem habe ich trailing SP/HT/SP/HT whitespace \n"\
10338 "Unn ausseerdem habe ich trailing HT/SP/HT/SP whitespace \n"\
10339 "auf den zeilen vorher.\n"\
10340 "ditto.\n"\
10341 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.\n"\
10342 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.1"\
10343 "\n"\
10344 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
10345 "\n"\
10346 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
10347 "3\n"\
10348 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
10349 "34\n"\
10350 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
10351 "345\n"\
10352 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
10353 "3456\n"\
10354 "QP am Zeilenende über soft-nl hinweg\n"\
10355 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
10356 "ö123\n"\
10357 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
10358 "1ö23\n"\
10359 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
10360 "12ö3\n"\
10361 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
10362 "123ö\n"\
10363 "=VIER = EQUAL SIGNS=ON A LINE=\n"\
10364 " \n"\
10365 "Die letzte Zeile war ein Leerschritt.\n"\
10368 # }}}
10370 # cc_all_configs() {{{
10371 # Test all configs TODO doesn't cover all *combinations*, stupid!
10372 cc_all_configs() {
10373 if [ ${MAXJOBS} -gt 1 ]; then
10374 MAXJOBS='-j '${MAXJOBS}
10375 else
10376 MAXJOBS=
10378 if [ -n "${NOCOLOUR}" ] || [ -n "${MAILX_CC_TEST_NO_COLOUR}" ]; then
10379 MAILX_CC_TEST_NO_COLOUR=1
10380 export MAILX_CC_TEST_NO_COLOUR
10383 < ${CONF} ${awk} '
10384 BEGIN{
10385 ALWAYS = "OPT_AUTOCC=1 OPT_AMALGAMATION=1"
10386 NOTME["OPT_AUTOCC_STACKPROT"] = 1
10387 NOTME["OPT_ALWAYS_UNICODE_LOCALE"] = 1
10388 NOTME["OPT_CROSS_BUILD"] = 1
10389 NOTME["OPT_AUTOCC"] = 1
10390 NOTME["OPT_AMALGAMATION"] = 1
10391 NOTME["OPT_DEBUG"] = 1
10392 NOTME["OPT_DEVEL"] = 1
10393 NOTME["OPT_ASAN_ADDRESS"] = 1
10394 NOTME["OPT_ASAN_MEMORY"] = 1
10395 NOTME["OPT_USAN"] = 1
10396 NOTME["OPT_NOMEMDBG"] = 1
10398 #OPTVALS
10399 OPTNO = 0
10401 MULCHOICE["OPT_ICONV"] = "VAL_ICONV"
10402 MULVALS["VAL_ICONV"] = 1
10403 MULCHOICE["OPT_IDNA"] = "VAL_IDNA"
10404 MULVALS["VAL_IDNA"] = 1
10406 #VALKEYS[0] = "VAL_RANDOM"
10407 VALVALS["VAL_RANDOM"] = 1
10408 VALNO = 0
10410 /^[ ]*OPT_/{
10411 sub(/^[ ]*/, "")
10412 # This bails for UnixWare 7.1.4 awk(1), but preceeding = with \
10413 # does not seem to be a compliant escape for =
10414 #sub(/=.*$/, "")
10415 $1 = substr($1, 1, index($1, "=") - 1)
10416 if(!NOTME[$1])
10417 OPTVALS[OPTNO++] = $1
10418 next
10420 /^[ ]*VAL_/{
10421 sub(/^[ ]*/, "")
10422 val = substr($0, index($0, "=") + 1)
10423 if(val ~ /^"/){
10424 val = substr(val, 2)
10425 val = substr(val, 1, length(val) - 1)
10427 $1 = substr($1, 1, index($1, "=") - 1)
10428 if(MULVALS[$1])
10429 MULVALS[$1] = val
10430 else if(VALVALS[$1]){
10431 VALKEYS[VALNO++] = $1
10432 VALVALS[$1] = val
10434 next
10436 function onepass(addons){
10437 a_onepass__worker(addons, "1", "0")
10438 a_onepass__worker(addons, "0", "1")
10440 function a_onepass__worker(addons, b0, b1){
10441 # Doing this completely sequentially and not doing make distclean in
10442 # between runs should effectively result in lesser compilations.
10443 # It is completely dumb nonetheless... TODO
10444 for(ono = 0; ono < OPTNO; ++ono){
10445 myconf = mula = ""
10446 for(i = 0; i < ono; ++i){
10447 myconf = myconf " " OPTVALS[i] "=" b0 " "
10448 if(b0 == "1"){
10449 j = MULCHOICE[OPTVALS[i]]
10450 if(j){
10451 if(i + 1 == ono)
10452 mula = j
10453 else
10454 myconf = myconf " " MULCHOICE[OPTVALS[i]] "=any "
10458 for(i = ono; i < OPTNO; ++i){
10459 myconf = myconf " " OPTVALS[i] "=" b1 " "
10460 if(b1 == "1"){
10461 j = MULCHOICE[OPTVALS[i]]
10462 if(j){
10463 if(i + 1 == OPTNO)
10464 mula = j;
10465 else
10466 myconf = myconf " " MULCHOICE[OPTVALS[i]] "=any "
10471 for(i in VALKEYS)
10472 myconf = VALKEYS[i] "=any " myconf
10474 myconf = myconf " " ALWAYS " " addons
10476 if(mula == "")
10477 print myconf
10478 else{
10479 i = split(MULVALS[mula], ia)
10480 j = "any"
10481 while(i >= 1){
10482 j = ia[i--] " " j
10483 print mula "=\"" j "\" " myconf
10488 END{
10489 # We cannot test NULL because of missing UI strings, which will end
10490 # up with different checksums
10491 print "CONFIG=NULLI OPT_AUTOCC=1"
10492 for(i in VALKEYS){
10493 j = split(VALVALS[VALKEYS[i]], ia)
10494 k = "any"
10495 while(j >= 1){
10496 k = ia[j--] " " k
10497 print VALKEYS[i] "=\"" k "\" CONFIG=NULLI OPT_AUTOCC=1"
10500 print "CONFIG=MINIMAL OPT_AUTOCC=1"
10501 print "CONFIG=NETSEND OPT_AUTOCC=1"
10502 print "CONFIG=MAXIMAL OPT_AUTOCC=1"
10503 for(i in VALKEYS){
10504 j = split(VALVALS[VALKEYS[i]], ia)
10505 k = "any"
10506 while(j >= 1){
10507 k = ia[j--] " " k
10508 print VALKEYS[i] "=\"" k "\" CONFIG=MAXIMAL OPT_AUTOCC=1"
10511 print "CONFIG=DEVEL OPT_AUTOCC=1"
10512 print "CONFIG=ODEVEL OPT_AUTOCC=1"
10514 print split_here
10516 onepass("OPT_DEBUG=1")
10517 onepass("")
10519 ' | while read c; do
10520 if [ "$c" = split_here ]; then
10521 printf 'Predefined configs done, now OPT_ combinations\n'
10522 printf 'Predefined configs done, now OPT_ combinations\n' >&2
10523 ${SHELL} -c "cd ../ && ${MAKE} distclean"
10524 continue
10526 [ -f mk-config.h ] && ${cp} mk-config.h .ccac.h
10527 printf "\n\n##########\n${MAKE} ${MAXJOBS} config $c\n"
10528 printf "\n\n##########\n${MAKE} ${MAXJOBS} config $c\n" >&2
10529 ${SHELL} -c "cd .. && ${MAKE} ${MAXJOBS} config ${c}"
10530 if [ -f .ccac.h ] && ${cmp} mk-config.h .ccac.h; then
10531 printf 'Skipping after config, nothing changed\n'
10532 printf 'Skipping after config, nothing changed\n' >&2
10533 continue
10535 ${SHELL} -c "cd ../ && ${MAKE} ${MAXJOBS} build test"
10536 done
10537 ${rm} -f .ccac.h
10538 cd .. && ${MAKE} distclean
10540 # }}}
10542 ssec=$SECONDS
10543 if [ -z "${CHECK}${RUN_TEST}" ]; then
10544 jobs_max
10545 cc_all_configs
10546 else
10547 if have_feat debug; then
10548 if have_feat devel; then
10549 JOBSYNC=1
10550 DEVELDIFF=y
10551 DUMPERR=y
10552 ARGS="${ARGS} -Smemdebug"
10553 JOBWAIT=`add $JOBWAIT $JOBWAIT`
10555 elif have_feat devel; then
10556 DEVELDIFF=y
10557 DUMPERR=y
10558 LOOPS_MAX=${LOOPS_BIG}
10560 color_init
10562 if [ -z "${RUN_TEST}" ] || [ ${#} -eq 0 ]; then
10563 jobs_max
10564 printf 'Will do up to %s tests in parallel, with a %s second timeout\n' \
10565 ${MAXJOBS} ${JOBWAIT}
10566 jobreaper_start
10567 t_all
10568 jobreaper_stop
10569 else
10570 MAXJOBS=1
10571 printf 'Tests have a %s second timeout\n' ${JOBWAIT}
10572 jobreaper_start
10573 while [ ${#} -gt 0 ]; do
10574 jspawn ${1}
10575 shift
10576 done
10577 jobreaper_stop
10581 esec=$SECONDS
10583 printf '%u tests: %s%u ok%s, %s%u failure(s)%s. %s%u test(s) skipped%s\n' \
10584 "${TESTS_PERFORMED}" "${COLOR_OK_ON}" "${TESTS_OK}" "${COLOR_OK_OFF}" \
10585 "${COLOR_ERR_ON}" "${TESTS_FAILED}" "${COLOR_ERR_OFF}" \
10586 "${COLOR_WARN_ON}" "${TESTS_SKIPPED}" "${COLOR_WARN_OFF}"
10587 if [ -n "${ssec}" ] && [ -n "${esec}" ]; then
10588 ( echo 'Elapsed seconds: '`$awk 'BEGIN{print '"${esec}"' - '"${ssec}"'}'` )
10591 exit ${ESTAT}
10592 # s-sh-mode