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