PRNG: VAL_RANDOM: add getentropy(3) support
[s-mailx.git] / mx-test.sh
blobff90031fdd1ea09867438f9f0a5622ce640681f7
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=`LC_ALL=C.utf8 "${RAWMAILX}" ${ARGS} -X '
285 \define cset_test {
286 \if "${ttycharset}" =%?case utf
287 \echo $LC_ALL
288 \xit 0
289 \end
290 \if "${#}" -gt 0
291 \wysh set LC_ALL=${1}
292 \shift
293 \eval xcall cset_test "${@}"
294 \end
295 \xit 1
297 \call cset_test C.UTF-8 POSIX.utf8 POSIX.UTF-8 \
298 en_EN.utf8 en_EN.UTF-8 en_US.utf8 en_US.UTF-8
300 [ $? -eq 0 ] && UTF8_LOCALE=$i
303 if [ -z "${UTF8_LOCALE}" ] && (locale yesexpr) >/dev/null 2>&1; then
304 echo 'Trying to detect UTF-8 locale via locale -a'
305 UTF8_LOCALE=`locale -a | { m=
306 while read n; do
307 if { echo ${n} |
308 ${grep} -i -e utf8 -e utf-8; } >/dev/null 2>&1; then
309 m=${n}
310 if { echo ${n} |
311 ${grep} -e POSIX -e en_EN -e en_US; } \
312 >/dev/null 2>&1; then
313 break
316 done
317 echo ${m}
322 if [ -n "${UTF8_LOCALE}" ]; then
323 echo 'Using Unicode locale '"${UTF8_LOCALE}"
324 else
325 echo 'No Unicode locale found, disabling Unicode tests'
328 if [ -z "${HONOURS_READONLY}" ]; then
329 trap "${rm} -f ./.tisrdonly" EXIT
330 trap "exit 1" HUP INT TERM
331 printf '' > ./.tisrdonly
332 ${chmod} 0444 ./.tisrdonly
333 if (printf 'no\n' > ./.tisrdonly) >/dev/null 2>&1 &&
334 test -s ./.tisrdonly; then
335 HONOURS_READONLY=
336 else
337 HONOURS_READONLY=yes
339 ${rm} -f ./.tisrdonly
340 trap '' EXIT HUP INT TERM
344 export UTF8_LOCALE HONOURS_READONLY
345 # }}}
347 TESTS_PERFORMED=0 TESTS_OK=0 TESTS_FAILED=0 TESTS_SKIPPED=0
348 JOBS=0 JOBLIST= JOBDESC= JOBREAPER= JOBSYNC=
350 COLOR_ERR_ON= COLOR_ERR_OFF=
351 COLOR_WARN_ON= COLOR_WARN_OFF=
352 COLOR_OK_ON= COLOR_OK_OFF=
353 ESTAT=0
354 TEST_NAME=
356 trap "
357 [ -z "${MAILX_CC_TEST_NO_CLEANUP}" ] &&
358 ${rm} -rf ./t.*.d ./t.*.io ./t.*.result
359 jobreaper_stop
360 " EXIT
361 trap "exit 1" HUP INT QUIT TERM
363 # JOBS {{{
364 if [ -n "${NOJOBS}" ]; then
365 jobs_max() { :; }
366 else
367 jobs_max() {
368 # The user desired variant
369 if ( echo "${MAKEFLAGS}" | ${grep} -- -j ) >/dev/null 2>&1; then
370 i=`echo "${MAKEFLAGS}" |
371 ${sed} -e 's/^.*-j[ ]*\([0-9]\{1,\}\).*$/\1/'`
372 if ( echo "${i}" | grep -q -e '^[0-9]\{1,\}$' ); then
373 printf 'Job number derived from MAKEFLAGS: %s\n' ${i}
374 MAXJOBS=${i}
375 [ "${MAXJOBS}" -eq 0 ] && MAXJOBS=1
376 return
380 # The actual hardware
381 printf 'all:\n' > t.mk.io
382 if ( ${MAKE} -j 10 -f t.mk.io ) >/dev/null 2>&1; then
383 if command -v nproc >/dev/null 2>&1; then
384 i=`nproc 2>/dev/null`
385 [ ${?} -eq 0 ] && MAXJOBS=${i}
386 else
387 i=`getconf _NPROCESSORS_ONLN 2>/dev/null`
388 j=${?}
389 if [ ${j} -ne 0 ]; then
390 i=`getconf NPROCESSORS_ONLN 2>/dev/null`
391 j=${?}
393 if [ ${j} -ne 0 ]; then
394 # SunOS 5.9 ++
395 if command -v kstat >/dev/null 2>&1; then
396 i=`PERL5OPT= kstat -p cpu | ${awk} '
397 BEGIN{no=0; FS=":"}
398 {if($2 > no) max = $2; next}
399 END{print ++max}
400 ' 2>/dev/null`
401 j=${?}
404 if [ ${j} -eq 0 ] && [ -n "${i}" ]; then
405 printf 'Job number derived from CPU number: %s\n' ${i}
406 MAXJOBS=${i}
409 [ "${MAXJOBS}" -eq 0 ] && MAXJOBS=1
414 jobreaper_start() {
415 ( sleep .1 ) >/dev/null 2>&1 && sleep_subsecond=1 || sleep_subsecond=
417 printf 'Starting job reaper (timeout of %s seconds)\n' ${JOBWAIT}
419 case "${JOBMON}" in
420 [yY]*)
421 # There were problems when using monitor mode with mksh
422 i=`env -i ${SHELL} -c 'echo $KSH_VERSION'`
423 if [ -n "${i}" ]; then
424 if [ "${i}" != "${i#*MIRBSD}" ]; then
425 JOBMON=
429 if [ -n "${JOBMON}" ]; then
430 ( set -m ) </dev/null >/dev/null 2>&1 || JOBMON=
431 else
432 printf >&2 '%s! $JOBMON: $SHELL %s incapable, disabled!%s\n' \
433 "${COLOR_ERR_ON}" "${SHELL}" "${COLOR_ERR_OFF}"
434 printf >&2 '%s! No process groups available, killed tests may '\
435 'leave process "zombies"!%s\n' \
436 "${COLOR_ERR_ON}" "${COLOR_ERR_OFF}"
440 JOBMON=
442 esac
445 trap 'i=1' USR1 # "reaper is up"
446 ( # .. which is actually a notify timer only
447 parent=${$}
448 sleeper= int=0 hot=0
449 trap '' EXIT HUP QUIT CHLD
450 trap 'exit 0' INT
451 trap '
452 [ -n "${sleeper}" ] && kill -TERM ${sleeper} >/dev/null 2>&1
453 int=1 hot=1
454 ' USR1
455 trap '
456 [ -n "${sleeper}" ] && kill -TERM ${sleeper} >/dev/null 2>&1
457 int=1 hot=0
458 ' USR2
459 trap '
460 [ -n "${sleeper}" ] && kill -TERM ${sleeper} >/dev/null 2>&1
461 echo "Stopping job reaper"
462 exit 0
463 ' TERM
465 # traps are setup, notify parent that we are up and running
466 kill -USR1 ${parent} >/dev/null 2>&1
468 while :; do
469 int=0
470 </dev/null ${cat} >/dev/null
471 sleep ${JOBWAIT} &
472 sleeper=${!}
473 wait ${sleeper}
474 sleeper=
475 [ "${int}${hot}" = 01 ] && kill -USR1 ${parent} >/dev/null 2>&1
476 done
477 ) </dev/null >/dev/null 2>&1 &
478 JOBREAPER=${!}
481 if [ ${?} -eq 0 ]; then
482 while :; do
483 if [ -n "${i}" ]; then
484 trap '' USR1
485 return
487 printf '..%s waiting for job reaper to come up\n' "${j}"
488 j=' still'
489 sleep 1 &
490 wait ${!}
491 done
494 JOBREAPER=
495 printf >&2 '%s! Cannot start the wild job reaper!%s\n' \
496 "${COLOR_ERR_ON}" "${COLOR_ERR_OFF}"
499 jobreaper_stop() {
500 [ -n "${JOBREAPER}" ] && kill -TERM ${JOBREAPER} >/dev/null 2>&1
501 JOBREAPER=
502 if [ ${JOBS} -gt 0 ]; then
503 echo 'Cleaning up running jobs'
504 jtimeout
505 wait ${JOBLIST}
506 JOBLIST=
510 jspawn() {
511 if [ -n "${CHECK}" ] && [ -n "${SKIPTEST}" ]; then
512 i="${@}"
513 j="${1}"
515 set -- ${SKIPTEST}
516 SKIPTEST=
517 while [ ${#} -gt 0 ]; do
518 if [ "${1}" != "${j}" ]; then
519 SKIPTEST="${SKIPTEST} ${1}"
520 elif [ -z "${k}" ]; then
522 t_echoskip ${1}
524 shift
525 done
526 [ -n "${k}" ] && return
527 set -- "${i}"
530 if [ ${MAXJOBS} -gt 1 ]; then
531 # We are spawning multiple jobs..
532 [ ${JOBS} -eq 0 ] && printf '...'
533 JOBS=`add ${JOBS} 1`
534 printf ' [%s=%s]' ${JOBS} "${1}"
535 else
536 JOBS=1
537 # Assume problems exist, do not let user keep hanging on terminal
538 if [ -n "${RUN_TEST}" ]; then
539 printf '... [%s]\n' "${1}"
543 [ -n "${JOBMON}" ] && set -m >/dev/null 2>&1
544 ( # Place the job in its own directory to ease file management
545 trap '' EXIT HUP INT QUIT TERM USR1 USR2
546 ${mkdir} t.${JOBS}.d && cd t.${JOBS}.d &&
547 eval t_${1} ${JOBS} ${1} &&
548 ${rm} -f ../t.${JOBS}.id
549 ) > t.${JOBS}.io </dev/null & # 2>&1 </dev/null &
550 i=${!}
551 [ -n "${JOBMON}" ] && set +m >/dev/null 2>&1
552 JOBLIST="${JOBLIST} ${i}"
553 printf '%s\n%s\n' ${i} ${1} > t.${JOBS}.id
555 # ..until we should sync or reach the maximum concurrent number
556 [ ${JOBS} -lt ${MAXJOBS} ] && return
558 jsync 1
561 jsync() {
562 if [ ${JOBS} -eq 0 ]; then
563 [ -n "${TEST_ANY}" ] && printf '\n'
564 TEST_ANY=
565 return
567 [ -z "${JOBSYNC}" ] && [ ${#} -eq 0 ] && return
569 [ ${MAXJOBS} -ne 1 ] && printf ' .. waiting\n'
571 if [ -n "${JOBREAPER}" ]; then
572 timeout= alldone=
574 trap 'timeout=1' USR1
575 kill -USR1 ${JOBREAPER} >/dev/null 2>&1
577 loops=0
578 while [ -z "${timeout}" ]; do
579 alldone=1
581 while [ ${i} -lt ${JOBS} ]; do
582 i=`add ${i} 1`
583 [ -f t.${i}.id ] || continue
584 alldone=
585 break
586 done
587 [ -n "${alldone}" ] && break
589 if [ -z "${sleep_subsecond}" ]; then
590 loops=`add ${loops} 1`
591 [ ${loops} -lt 111 ] && continue
592 sleep 1 &
593 else
594 sleep .1 &
596 wait ${!}
597 done
599 kill -USR2 ${JOBREAPER} >/dev/null 2>&1
600 trap '' USR1
602 [ -n "${timeout}" ] && jtimeout
605 # Now collect the zombies
606 wait ${JOBLIST}
607 JOBLIST=
609 # Update global counters
611 while [ ${i} -lt ${JOBS} ]; do
612 i=`add ${i} 1`
614 [ -s t.${i}.io ] && ${cat} t.${i}.io
615 if [ -n "${DUMPERR}" ] && [ -s ./t.${i}.d/${ERR} ]; then
616 printf '%s [Debug/Devel: nullified errors]\n' "${COLOR_ERR_ON}"
617 while read l; do
618 printf ' %s\n' "${l}"
619 done < t.${i}.d/${ERR}
620 printf '%s' "${COLOR_ERR_OFF}"
623 if [ -f t.${i}.id ]; then
624 { read pid; read desc; } < t.${i}.id
625 desc=${desc#${desc%%[! ]*}}
626 desc=${desc%${desc##*[! ]}}
627 [ -s t.${i}.io ] && printf >&2 '\n'
628 printf >&2 '%s!! Timeout: reaped job %s [%s]%s\n' \
629 "${COLOR_ERR_ON}" ${i} "${desc}" "${COLOR_ERR_OFF}"
630 TESTS_FAILED=`add ${TESTS_FAILED} 1`
631 elif [ -s t.${i}.result ]; then
632 read es tp to tf ts < t.${i}.result
633 TESTS_PERFORMED=`add ${TESTS_PERFORMED} ${tp}`
634 TESTS_OK=`add ${TESTS_OK} ${to}`
635 TESTS_FAILED=`add ${TESTS_FAILED} ${tf}`
636 TESTS_SKIPPED=`add ${TESTS_SKIPPED} ${ts}`
637 [ "${es}" != 0 ] && ESTAT=${es}
638 else
639 TESTS_FAILED=`add ${TESTS_FAILED} 1`
640 ESTAT=1
642 done
644 [ -z "${MAILX_CC_TEST_NO_CLEANUP}" ] &&
645 ${rm} -rf ./t.*.d ./t.*.id ./t.*.io t.*.result
647 JOBS=0
650 jtimeout() {
652 while [ ${i} -lt ${JOBS} ]; do
653 i=`add ${i} 1`
654 if [ -f t.${i}.id ] &&
655 read pid < t.${i}.id >/dev/null 2>&1 &&
656 kill -0 ${pid} >/dev/null 2>&1; then
657 j=${pid}
658 [ -n "${JOBMON}" ] && j=-${j}
659 kill -KILL ${j} >/dev/null 2>&1
660 else
661 ${rm} -f t.${i}.id
663 done
665 # }}}
667 # echoes, checks, etc. {{{
668 t_prolog() {
669 shift
671 ESTAT=0 TESTS_PERFORMED=0 TESTS_OK=0 TESTS_FAILED=0 TESTS_SKIPPED=0 \
672 TEST_NAME=${1} TEST_ANY=
674 printf '%s[%s]%s\n' "" "${TEST_NAME}" ""
677 t_epilog() {
678 [ -n "${TEST_ANY}" ] && printf '\n'
680 printf '%s %s %s %s %s\n' \
681 ${ESTAT} \
682 ${TESTS_PERFORMED} ${TESTS_OK} ${TESTS_FAILED} ${TESTS_SKIPPED} \
683 > ../t.${1}.result
686 t_echo() {
687 [ -n "${TEST_ANY}" ] && __i__=' ' || __i__=
688 printf "${__i__}"'%s' "${*}"
689 TEST_ANY=1
692 t_echook() {
693 [ -n "${TEST_ANY}" ] && __i__=' ' || __i__=
694 printf "${__i__}"'%s%s:ok%s' "${COLOR_OK_ON}" "${*}" "${COLOR_OK_OFF}"
695 TEST_ANY=1
698 t_echoerr() {
699 ESTAT=1
700 t_echo0err "${@}"
703 t_echo0err() {
704 [ -n "${TEST_ANY}" ] && __i__="\n" || __i__=
705 printf "${__i__}"'%sERROR: %s%s\n' \
706 "${COLOR_ERR_ON}" "${*}" "${COLOR_ERR_OFF}"
707 TEST_ANY=
710 t_echowarn() {
711 [ -n "${TEST_ANY}" ] && __i__=' ' || __i__=
712 printf "${__i__}"'%s%s%s' "${COLOR_WARN_ON}" "${*}" "${COLOR_WARN_OFF}"
713 TEST_ANY=1
716 t_echoskip() {
717 [ -n "${TEST_ANY}" ] && __i__=' ' || __i__=
718 printf "${__i__}"'%s%s[skip]%s' \
719 "${COLOR_WARN_ON}" "${*}" "${COLOR_WARN_OFF}"
720 TEST_ANY=1
721 TESTS_SKIPPED=`add ${TESTS_SKIPPED} 1`
724 check() {
725 restat=${?} tid=${1} eestat=${2} f=${3} s=${4} optmode=${5}
727 TESTS_PERFORMED=`add ${TESTS_PERFORMED} 1`
729 case "${optmode}" in
730 '') ;;
731 async)
732 [ "$eestat" = - ] || exit 200
733 while :; do
734 [ -f "${f}" ] && break
735 t_echowarn "[${tid}:async=wait]"
736 sleep 1 &
737 wait ${!}
738 done
740 *) exit 222;;
741 esac
743 check__bad= check__runx=
745 if [ "${eestat}" != - ] && [ "${restat}" != "${eestat}" ]; then
746 ESTAT=1
747 t_echoerr "${tid}: bad-status: ${restat} != ${eestat}"
748 check__bad=1
751 csum="`${cksum} < "${f}" | ${sed} -e 's/[ ]\{1,\}/ /g'`"
752 if [ "${csum}" = "${s}" ]; then
753 t_echook "${tid}"
754 check__runx=${DEVELDIFF}
755 else
756 ESTAT=1
757 t_echoerr "${tid}: checksum mismatch (got ${csum})"
758 check__bad=1 check__runx=1
761 if [ -z "${check__bad}" ]; then
762 TESTS_OK=`add ${TESTS_OK} 1`
763 else
764 TESTS_FAILED=`add ${TESTS_FAILED} 1`
767 if [ -n "${CHECK}${RUN_TEST}" ]; then
768 x="t.${TEST_NAME}-${tid}"
769 if [ -n "${RUN_TEST}" ] ||
770 [ -n "${check__runx}" -a -n "${GIT_REPO}" ]; then
771 ${cp} -f "${f}" ../"${x}"
774 if [ -n "${check__runx}" ] && [ -n "${GIT_REPO}" ] &&
775 command -v diff >/dev/null 2>&1; then
776 y=test-out
777 if (git rev-parse --verify $y) >/dev/null 2>&1; then :; else
778 y=refs/remotes/origin/test-out
779 (git rev-parse --verify $y) >/dev/null 2>&1 || y=
781 if [ -n "${y}" ]; then
782 if GIT_CONFIG=/dev/null git show "${y}":"${x}" > \
783 ../"${x}".old 2>/dev/null; then
784 diff -ru ../"${x}".old ../"${x}" > ../"${x}".diff
785 if [ ${?} -eq 0 ]; then
786 [ -z "${MAILX_CC_TEST_NO_CLEANUP}" ] &&
787 ${rm} -f ../"${x}" ../"${x}".old ../"${x}".diff
788 elif [ -n "${MAILX_CC_ALL_TESTS_DUMPERR}" ]; then
789 while read l; do
790 printf 'ERROR-DIFF %s\n' "${l}"
791 done < ../"${x}".diff
793 else
794 t_echo0err "${tid}: misses [test-out] template"
801 check_ex0() {
802 # $1=test name [$2=status]
803 __qm__=${?}
804 [ ${#} -gt 1 ] && __qm__=${2}
806 TESTS_PERFORMED=`add ${TESTS_PERFORMED} 1`
808 if [ ${__qm__} -ne 0 ]; then
809 ESTAT=1
810 t_echoerr "${1}: unexpected non-0 exit status: ${__qm__}"
811 TESTS_FAILED=`add ${TESTS_FAILED} 1`
812 else
813 t_echook "${1}"
814 TESTS_OK=`add ${TESTS_OK} 1`
818 check_exn0() {
819 # $1=test name [$2=status]
820 __qm__=${?}
821 [ ${#} -gt 1 ] && __qm__=${2}
822 [ ${#} -gt 2 ] && __expect__=${3} || __expect__=
824 TESTS_PERFORMED=`add ${TESTS_PERFORMED} 1`
826 if [ ${__qm__} -eq 0 ]; then
827 ESTAT=1
828 t_echoerr "${1}: unexpected 0 exit status: ${__qm__}"
829 TESTS_FAILED=`add ${TESTS_FAILED} 1`
830 elif [ -n "${__expect__}" ] && [ ${__expect__} -ne ${__qm__} ]; then
831 ESTAT=1
832 t_echoerr "${1}: unexpected exit status: ${__qm__} != ${__expected__}"
833 TESTS_FAILED=`add ${TESTS_FAILED} 1`
834 else
835 t_echook "${1}"
836 TESTS_OK=`add ${TESTS_OK} 1`
839 # }}}
841 color_init() {
842 [ -n "${NOCOLOUR}" ] && return
843 [ -n "${MAILX_CC_TEST_NO_COLOUR}" ] && return
844 # We do not want color for "make test > .LOG"!
845 if command -v stty >/dev/null 2>&1 && command -v tput >/dev/null 2>&1 &&
846 (<&1 >/dev/null stty -a) 2>/dev/null; then
847 { sgr0=`tput sgr0`; } 2>/dev/null
848 [ $? -eq 0 ] || return
849 { saf1=`tput setaf 1`; } 2>/dev/null
850 [ $? -eq 0 ] || return
851 { saf2=`tput setaf 2`; } 2>/dev/null
852 [ $? -eq 0 ] || return
853 { saf3=`tput setaf 3`; } 2>/dev/null
854 [ $? -eq 0 ] || return
855 { b=`tput bold`; } 2>/dev/null
856 [ $? -eq 0 ] || return
858 COLOR_ERR_ON=${saf1}${b} COLOR_ERR_OFF=${sgr0}
859 COLOR_WARN_ON=${saf3}${b} COLOR_WARN_OFF=${sgr0}
860 COLOR_OK_ON=${saf2} COLOR_OK_OFF=${sgr0}
861 unset saf1 saf2 saf3 b
865 if ( [ "$((1 + 1))" = 2 ] ) >/dev/null 2>&1; then
866 add() {
867 echo "$((${1} + ${2}))"
869 else
870 add() {
871 ${awk} 'BEGIN{print '${1}' + '${2}'}'
875 if ( [ "$((2 % 3))" = 2 ] ) >/dev/null 2>&1; then
876 modulo() {
877 echo "$((${1} % ${2}))"
879 else
880 modulo() {
881 ${awk} 'BEGIN{print '${1}' % '${2}'}'
885 have_feat() {
886 ( "${RAWMAILX}" ${ARGS} -X'echo $features' -Xx |
887 ${grep} +${1}, ) >/dev/null 2>&1
889 # }}}
891 # Absolute Basics {{{
892 t_X_Y_opt_input_go_stack() {
893 t_prolog "${@}"
895 ${cat} <<- '__EOT' > "${BODY}"
896 echo 1
897 define mac0 {
898 echo mac0-1 via1 $0
900 call mac0
901 echo 2
902 source '\
903 echo "define mac1 {";\
904 echo " echo mac1-1 via1 \$0";\
905 echo " call mac0";\
906 echo " echo mac1-2";\
907 echo " call mac2";\
908 echo " echo mac1-3";\
909 echo "}";\
910 echo "echo 1-1";\
911 echo "define mac2 {";\
912 echo " echo mac2-1 via1 \$0";\
913 echo " call mac0";\
914 echo " echo mac2-2";\
915 echo "}";\
916 echo "echo 1-2";\
917 echo "call mac1";\
918 echo "echo 1-3";\
919 echo "source \"\
920 echo echo 1-1-1 via1 \$0;\
921 echo call mac0;\
922 echo echo 1-1-2;\
923 | \"";\
924 echo "echo 1-4";\
926 echo 3
927 call mac2
928 echo 4
929 undefine *
930 __EOT
932 # The -X option supports multiline arguments, and those can internally use
933 # reverse solidus newline escaping. And all -X options are joined...
934 APO=\'
935 < "${BODY}" ${MAILX} ${ARGS} \
936 -X 'e\' \
937 -X ' c\' \
938 -X ' h\' \
939 -X ' o \' \
940 -X 1 \
942 define mac0 {
943 echo mac0-1 via2 $0
945 call mac0
946 echo 2
949 source '${APO}'\
950 echo "define mac1 {";\
951 echo " echo mac1-1 via2 \$0";\
952 echo " call mac0";\
953 echo " echo mac1-2";\
954 echo " call mac2";\
955 echo " echo mac1-3";\
956 echo "}";\
957 echo "echo 1-1";\
958 echo "define mac2 {";\
959 echo " echo mac2-1 via2 \$0";\
960 echo " call mac0";\
961 echo " echo mac2-2";\
962 echo "}";\
963 echo "echo 1-2";\
964 echo "call mac1";\
965 echo "echo 1-3";\
966 echo "source \"\
967 echo echo 1-1-1 via2 \$0;\
968 echo call mac0;\
969 echo echo 1-1-2;\
970 | \"";\
971 echo "echo 1-4";\
972 | '${APO}'
973 echo 3
976 call mac2
977 echo 4
978 undefine *
979 ' > "${MBOX}"
981 check 1 0 "${MBOX}" '1786542668 416'
983 # The -Y option supports multiline arguments, and those can internally use
984 # reverse solidus newline escaping.
985 APO=\'
986 < "${BODY}" ${MAILX} ${ARGS} \
987 -X 'echo FIRST_X' \
988 -X 'echo SECOND_X' \
989 -Y 'e\' \
990 -Y ' c\' \
991 -Y ' h\' \
992 -Y ' o \' \
993 -Y 1 \
995 define mac0 {
996 echo mac0-1 via2 $0
998 call mac0
999 echo 2
1002 source '${APO}'\
1003 echo "define mac1 {";\
1004 echo " echo mac1-1 via2 \$0";\
1005 echo " call mac0";\
1006 echo " echo mac1-2";\
1007 echo " call mac2";\
1008 echo " echo mac1-3";\
1009 echo "}";\
1010 echo "echo 1-1";\
1011 echo "define mac2 {";\
1012 echo " echo mac2-1 via2 \$0";\
1013 echo " call mac0";\
1014 echo " echo mac2-2";\
1015 echo "}";\
1016 echo "echo 1-2";\
1017 echo "call mac1";\
1018 echo "echo 1-3";\
1019 echo "source \"\
1020 echo echo 1-1-1 via2 \$0;\
1021 echo call mac0;\
1022 echo echo 1-1-2;\
1023 | \"";\
1024 echo "echo 1-4";\
1025 | '${APO}'
1026 echo 3
1029 call mac2
1030 echo 4
1031 undefine *
1033 -Y 'echo LAST_Y' > "${MBOX}"
1035 check 2 0 "${MBOX}" '1845176711 440'
1037 # Compose mode, too!
1038 </dev/null ${MAILX} ${ARGS} \
1039 -X 'echo X before compose mode' \
1040 -Y '~s Subject via -Y' \
1041 -Y 'Body via -Y' -. ./.tybox > "${MBOX}" 2>&1
1042 check 3 0 ./.tybox '264636255 125'
1043 check 4 - "${MBOX}" '467429373 22'
1045 ${cat} <<-_EOT | ${MAILX} ${ARGS} -t \
1046 -X 'echo X before compose mode' \
1047 -Y '~s Subject via -Y' \
1048 -Y 'Additional body via -Y' -. ./.tybox > "${MBOX}" 2>&1
1049 from: heya@exam.ple
1050 subject:diet not to be seen!
1052 this body via -t.
1053 _EOT
1054 check 5 0 ./.tybox '3313167452 299'
1055 check 6 - "${MBOX}" '467429373 22'
1058 printf 'this body via stdin pipe.\n' | ${MAILX} ${NOBATCH_ARGS} \
1059 -X 'echo X before compose mode' \
1060 -Y '~s Subject via -Y (not!)' \
1061 -Y 'Additional body via -Y, nobatch mode' -. ./.tybox > "${MBOX}" 2>&1
1062 check 7 0 ./.tybox '1561798488 476'
1063 check 8 - "${MBOX}" '467429373 22'
1065 printf 'this body via stdin pipe.\n' | ${MAILX} ${ARGS} \
1066 -X 'echo X before compose mode' \
1067 -Y '~s Subject via -Y' \
1068 -Y 'Additional body via -Y, batch mode' -. ./.tybox > "${MBOX}" 2>&1
1069 check 9 0 ./.tybox '3245082485 650'
1070 check 10 - "${MBOX}" '467429373 22'
1072 # Test for [8412796a] (n_cmd_arg_parse(): FIX token error -> crash, e.g.
1073 # "-RX 'bind;echo $?' -Xx".., 2018-08-02)
1074 ${MAILX} ${ARGS} -RX'call;echo $?' -Xx > ./.tall 2>&1
1075 ${MAILX} ${ARGS} -RX'call ;echo $?' -Xx >> ./.tall 2>&1
1076 ${MAILX} ${ARGS} -RX'call ;echo $?' -Xx >> ./.tall 2>&1
1077 ${MAILX} ${ARGS} -RX'call ;echo $?' -Xx >> ./.tall 2>&1
1078 check cmdline 0 ./.tall '1867586969 8'
1080 t_epilog "${@}"
1083 t_X_errexit() {
1084 t_prolog "${@}"
1086 if have_feat uistrings; then :; else
1087 t_echoskip '[!UISTRINGS]'
1088 t_epilog "${@}"
1089 return
1092 ${cat} <<- '__EOT' > "${BODY}"
1093 echo one
1094 echos nono
1095 echo two
1096 __EOT
1098 </dev/null ${MAILX} ${ARGS} -Snomemdebug \
1099 -X'echo one' -X' echos nono ' -X'echo two' \
1100 > "${MBOX}" 2>&1
1101 check 1 0 "${MBOX}" '2700500141 51'
1103 </dev/null ${MAILX} ${ARGS} -X'source '"${BODY}" -Snomemdebug \
1104 > "${MBOX}" 2>&1
1105 check 2 0 "${MBOX}" '2700500141 51'
1107 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Snomemdebug \
1108 > "${MBOX}" 2>&1
1109 check 3 0 "${MBOX}" '2700500141 51'
1113 </dev/null ${MAILX} ${ARGS} -Serrexit -Snomemdebug \
1114 -X'echo one' -X' echos nono ' -X'echo two' \
1115 > "${MBOX}" 2>&1
1116 check 4 1 "${MBOX}" '4096689457 47'
1118 </dev/null ${MAILX} ${ARGS} -X'source '"${BODY}" -Serrexit -Snomemdebug \
1119 > "${MBOX}" 2>&1
1120 check 5 1 "${MBOX}" '4096689457 47'
1122 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Serrexit -Snomemdebug \
1123 > "${MBOX}" 2>&1
1124 check 6 1 "${MBOX}" '1669262132 170'
1126 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Sposix -Snomemdebug \
1127 > "${MBOX}" 2>&1
1128 check 7 1 "${MBOX}" '1669262132 170'
1130 ## Repeat 4-7 with ignerr set
1132 ${sed} -e 's/^echos /ignerr echos /' < "${BODY}" > "${MBOX}"
1134 </dev/null ${MAILX} ${ARGS} -Serrexit -Snomemdebug \
1135 -X'echo one' -X'ignerr echos nono ' -X'echo two' \
1136 > "${BODY}" 2>&1
1137 check 8 0 "${BODY}" '2700500141 51'
1139 </dev/null ${MAILX} ${ARGS} -X'source '"${MBOX}" -Serrexit -Snomemdebug \
1140 > "${BODY}" 2>&1
1141 check 9 0 "${BODY}" '2700500141 51'
1143 </dev/null MAILRC="${MBOX}" ${MAILX} ${ARGS} -:u -Serrexit -Snomemdebug \
1144 > "${BODY}" 2>&1
1145 check 10 0 "${BODY}" '2700500141 51'
1147 </dev/null MAILRC="${MBOX}" ${MAILX} ${ARGS} -:u -Sposix -Snomemdebug \
1148 > "${BODY}" 2>&1
1149 check 11 0 "${BODY}" '2700500141 51'
1151 # Ensure "good-injection" in a deeper indirection does not cause trouble
1152 # This actually only works with MLE and HISTORY, and TODO needs a pseudo TTY
1153 # interaction so that we DO initialize our line editor...
1154 ${cat} <<- '__EOT' > "${BODY}"
1155 define oha {
1156 return 0
1158 define x {
1159 eval set $xarg
1160 echoes time
1161 return 0
1163 __EOT
1165 printf 'source %s\ncall x\necho au' "${BODY}" |
1166 ${MAILX} ${ARGS} -Snomemdebug -Sxarg=errexit > "${MBOX}" 2>&1
1167 check 12 1 "${MBOX}" '2908921993 44'
1169 printf 'source %s\nset on-history-addition=oha\ncall x\necho au' "${BODY}" |
1170 ${MAILX} ${ARGS} -Snomemdebug -Sxarg=errexit > "${MBOX}" 2>&1
1171 check 13 1 "${MBOX}" '2908921993 44'
1173 printf 'source %s\ncall x\necho au' "${BODY}" |
1174 ${MAILX} ${ARGS} -Snomemdebug -Sxarg=nowhere > "${MBOX}" 2>&1
1175 check 14 0 "${MBOX}" '2049365617 47'
1177 t_epilog "${@}"
1180 t_Y_errexit() {
1181 t_prolog "${@}"
1183 if have_feat uistrings; then :; else
1184 t_echoskip '[!UISTRINGS]'
1185 t_epilog "${@}"
1186 return
1189 ${cat} <<- '__EOT' > "${BODY}"
1190 echo one
1191 echos nono
1192 echo two
1193 __EOT
1195 </dev/null ${MAILX} ${ARGS} -Snomemdebug \
1196 -Y'echo one' -Y' echos nono ' -Y'echo two' \
1197 > "${MBOX}" 2>&1
1198 check 1 0 "${MBOX}" '2700500141 51'
1200 </dev/null ${MAILX} ${ARGS} -Y'source '"${BODY}" -Snomemdebug \
1201 > "${MBOX}" 2>&1
1202 check 2 0 "${MBOX}" '2700500141 51'
1206 </dev/null ${MAILX} ${ARGS} -Serrexit -Snomemdebug \
1207 -Y'echo one' -Y' echos nono ' -Y'echo two' \
1208 > "${MBOX}" 2>&1
1209 check 3 1 "${MBOX}" '4096689457 47'
1211 </dev/null ${MAILX} ${ARGS} -Y'source '"${BODY}" -Serrexit -Snomemdebug \
1212 > "${MBOX}" 2>&1
1213 check 4 1 "${MBOX}" '4096689457 47'
1215 ## Repeat 3-4 with ignerr set
1217 ${sed} -e 's/^echos /ignerr echos /' < "${BODY}" > "${MBOX}"
1219 </dev/null ${MAILX} ${ARGS} -Serrexit -Snomemdebug \
1220 -Y'echo one' -Y'ignerr echos nono ' -Y'echo two' \
1221 > "${BODY}" 2>&1
1222 check 5 0 "${BODY}" '2700500141 51'
1224 </dev/null ${MAILX} ${ARGS} -Y'source '"${MBOX}" -Serrexit -Snomemdebug \
1225 > "${BODY}" 2>&1
1226 check 6 0 "${BODY}" '2700500141 51'
1228 t_epilog "${@}"
1231 t_S_freeze() {
1232 t_prolog "${@}"
1233 oterm=$TERM
1234 unset TERM
1236 # Test basic assumption
1237 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} \
1238 -X'echo asksub<$asksub> dietcurd<$dietcurd>' \
1239 -Xx > "${MBOX}" 2>&1
1240 check 1 0 "${MBOX}" '270686329 21'
1243 ${cat} <<- '__EOT' > "${BODY}"
1244 echo asksub<$asksub>
1245 set asksub
1246 echo asksub<$asksub>
1247 __EOT
1248 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
1249 -Snoasksub -Sasksub -Snoasksub \
1250 -X'echo asksub<$asksub>' -X'set asksub' -X'echo asksub<$asksub>' \
1251 -Xx > "${MBOX}" 2>&1
1252 check 2 0 "${MBOX}" '3182942628 37'
1254 ${cat} <<- '__EOT' > "${BODY}"
1255 echo asksub<$asksub>
1256 unset asksub
1257 echo asksub<$asksub>
1258 __EOT
1259 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
1260 -Snoasksub -Sasksub \
1261 -X'echo asksub<$asksub>' -X'unset asksub' -X'echo asksub<$asksub>' \
1262 -Xx > "${MBOX}" 2>&1
1263 check 3 0 "${MBOX}" '2006554293 39'
1266 ${cat} <<- '__EOT' > "${BODY}"
1267 echo dietcurd<$dietcurd>
1268 set dietcurd=cherry
1269 echo dietcurd<$dietcurd>
1270 __EOT
1271 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
1272 -Sdietcurd=strawberry -Snodietcurd -Sdietcurd=vanilla \
1273 -X'echo dietcurd<$dietcurd>' -X'unset dietcurd' \
1274 -X'echo dietcurd<$dietcurd>' \
1275 -Xx > "${MBOX}" 2>&1
1276 check 4 0 "${MBOX}" '1985768109 65'
1278 ${cat} <<- '__EOT' > "${BODY}"
1279 echo dietcurd<$dietcurd>
1280 unset dietcurd
1281 echo dietcurd<$dietcurd>
1282 __EOT
1283 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
1284 -Sdietcurd=strawberry -Snodietcurd \
1285 -X'echo dietcurd<$dietcurd>' -X'set dietcurd=vanilla' \
1286 -X'echo dietcurd<$dietcurd>' \
1287 -Xx > "${MBOX}" 2>&1
1288 check 5 0 "${MBOX}" '151574279 51'
1290 # TODO once we have a detached one with env=1..
1291 if [ -n "`</dev/null ${MAILX} ${ARGS} -X'!echo \$TERM' -Xx`" ]; then
1292 t_echoskip 's_freeze-{6,7}:[shell sets $TERM]'
1293 else
1294 ${cat} <<- '__EOT' > "${BODY}"
1295 !echo "shell says TERM<$TERM>"
1296 echo TERM<$TERM>
1297 !echo "shell says TERM<$TERM>"
1298 set TERM=cherry
1299 !echo "shell says TERM<$TERM>"
1300 echo TERM<$TERM>
1301 !echo "shell says TERM<$TERM>"
1302 __EOT
1303 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
1304 -STERM=strawberry -SnoTERM -STERM=vanilla \
1305 -X'echo mail<$TERM>' -X'unset TERM' \
1306 -X'!echo "shell says TERM<$TERM>"' -X'echo TERM<$TERM>' \
1307 -Xx > "${MBOX}" 2>&1
1308 check 6 0 "${MBOX}" '1211476036 167'
1310 ${cat} <<- '__EOT' > "${BODY}"
1311 !echo "shell says TERM<$TERM>"
1312 echo TERM<$TERM>
1313 !echo "shell says TERM<$TERM>"
1314 set TERM=cherry
1315 !echo "shell says TERM<$TERM>"
1316 echo TERM<$TERM>
1317 !echo "shell says TERM<$TERM>"
1318 __EOT
1319 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
1320 -STERM=strawberry -SnoTERM \
1321 -X'echo TERM<$TERM>' -X'set TERM=vanilla' \
1322 -X'!echo "shell says TERM<$TERM>"' -X'echo TERM<$TERM>' \
1323 -Xx > "${MBOX}" 2>&1
1324 check 7 0 "${MBOX}" '3365080441 132'
1327 TERM=$oterm
1328 t_epilog "${@}"
1331 t_f_batch_order() {
1332 t_prolog "${@}"
1334 t__gen_msg subject f-batch-order > "${MBOX}"
1336 # This would exit 64 (EX_USAGE) from ? to [fbddb3b3] (FIX: -f: add
1337 # n_PO_f_FLAG to avoid that command line order matters)
1338 </dev/null ${MAILX} ${NOBATCH_ARGS} -R -f -# \
1339 -Y 'echo du;h;echo da;x' "${MBOX}" >./.tall 2>&1
1340 check 1 0 ./.tall '1690247457 86'
1342 # And this ever worked (hopefully)
1343 </dev/null ${MAILX} ${NOBATCH_ARGS} -R -# -f \
1344 -Y 'echo du;h;echo da;x' "${MBOX}" >./.tall 2>&1
1345 check 2 0 ./.tall '1690247457 86'
1347 t_epilog "${@}"
1350 t_input_inject_semicolon_seq() {
1351 t_prolog "${@}"
1353 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
1354 define mydeepmac {
1355 echon '(mydeepmac)';
1357 define mymac {
1358 echon this_is_mymac;call mydeepmac;echon ';';
1360 echon one';';call mymac;echon two";";call mymac;echo three$';';
1361 define mymac {
1362 echon this_is_mymac;call mydeepmac;echon ,TOO'!;';
1364 echon one';';call mymac;echon two";";call mymac;echo three$';';
1365 __EOT
1367 check 1 0 "${MBOX}" '512117110 140'
1369 t_epilog "${@}"
1372 t_wysh() {
1373 t_prolog "${@}"
1375 ${cat} <<- '__EOT' > "${BODY}"
1377 echo abcd
1378 echo a'b'c'd'
1379 echo a"b"c"d"
1380 echo a$'b'c$'d'
1381 echo 'abcd'
1382 echo "abcd"
1383 echo $'abcd'
1384 echo a\ b\ c\ d
1385 echo a 'b c' d
1386 echo a "b c" d
1387 echo a $'b c' d
1389 echo 'a$`"\'
1390 echo "a\$\`'\"\\"
1391 echo $'a\$`\'\"\\'
1392 echo $'a\$`\'"\\'
1393 # DIET=CURD TIED=
1394 echo 'a${DIET}b${TIED}c\${DIET}d\${TIED}e' # COMMENT
1395 echo "a${DIET}b${TIED}c\${DIET}d\${TIED}e"
1396 echo $'a${DIET}b${TIED}c\${DIET}d\${TIED}e'
1398 echo a$'\101\0101\x41\u0041\u41\U00000041\U41'c
1399 echo a$'\u0041\u41\u0C1\U00000041\U41'c
1400 echo a$'\377'c
1401 echo a$'\0377'c
1402 echo a$'\400'c
1403 echo a$'\0400'c
1404 echo a$'\U1100001'c
1406 echo a$'b\0c'd
1407 echo a$'b\00c'de
1408 echo a$'b\000c'df
1409 echo a$'b\0000c'dg
1410 echo a$'b\x0c'dh
1411 echo a$'b\x00c'di
1412 echo a$'b\u0'dj
1413 echo a$'b\u00'dk
1414 echo a$'b\u000'dl
1415 echo a$'b\u0000'dm
1416 echo a$'b\U0'dn
1417 echo a$'b\U00'do
1418 echo a$'b\U000'dp
1419 echo a$'b\U0000'dq
1420 echo a$'b\U00000'dr
1421 echo a$'b\U000000'ds
1422 echo a$'b\U0000000'dt
1423 echo a$'b\U00000000'du
1425 echo a$'\cI'b
1426 echo a$'\011'b
1427 echo a$'\x9'b
1428 echo a$'\u9'b
1429 echo a$'\U9'b
1430 echo a$'\c@'b c d
1431 __EOT
1433 if [ -z "${UTF8_LOCALE}" ]; then
1434 t_echoskip 'wysh-unicode:[no UTF-8 locale]'
1435 else
1436 < "${BODY}" DIET=CURD TIED= \
1437 LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} > "${MBOX}" 2>>${ERR}
1438 check unicode 0 "${MBOX}" '475805847 317'
1441 < "${BODY}" DIET=CURD TIED= ${MAILX} ${ARGS} > "${MBOX}" 2>>${ERR}
1442 check c 0 "${MBOX}" '1473887148 321'
1444 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
1445 wysh set mager='\hey\'
1446 varshow mager
1447 wysh set mager="\hey\\"
1448 varshow mager
1449 wysh set mager=$'\hey\\'
1450 varshow mager
1451 __EOT
1452 check 3 0 "${MBOX}" '1289698238 69'
1454 t_epilog "${@}"
1457 t_commandalias() {
1458 t_prolog "${@}"
1460 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
1461 commandalias echo echo hoho
1462 echo stop.
1463 commandalias X Xx
1464 commandalias Xx XxX
1465 commandalias XxX XxXx
1466 commandalias XxXx XxXxX
1467 commandalias XxXxX XxXxXx
1468 commandalias XxXxXx echo huhu
1469 commandalias XxXxXxX echo huhu
1471 commandalias XxXxXx XxXxXxX
1473 uncommandalias echo
1474 commandalias XxXxXx echo huhu
1476 __EOT
1478 check 1 0 "${MBOX}" '1638809585 36'
1480 t_epilog "${@}"
1483 t_posix_abbrev() {
1484 t_prolog "${@}"
1486 # In POSIX C181 standard order
1487 </dev/null ${MAILX} ${ARGS} \
1488 -Y 'echon alias/a\ ; ? a; echon group/g\ ; ?g' \
1489 -Y 'echon alternates/alt\ ; ? alt' \
1490 -Y 'echon chdir/ch\ ; ? ch' \
1491 -Y 'echon copy/c\ ; ? c; echon Copy/C\ ; ?C' \
1492 -Y 'echon delete/d\ ; ? d' \
1493 -Y 'echon discard/di\ ; ? di; echon ignore/ig\ ; ?ig' \
1494 -Y 'echon echo/ec\ ; ? ec' \
1495 -Y 'echon edit/e\ ; ? e' \
1496 -Y 'echon exit/ex\ ; ? ex; echon xit/x\ ; ?x' \
1497 -Y 'echon file/fi\ ; ? fi; echon folder/fold\ ; ? fold' \
1498 -Y 'echon followup/fo\ ; ? fo; echon Followup/F\ ; ?F' \
1499 -Y 'echon from/f\ ; ? f' \
1500 -Y 'echon headers/h\ ; ? h' \
1501 -Y 'echon help/hel\ ; ? hel' \
1502 -Y 'echon hold/ho\ ; ? ho; echon preserve/pre\ ; ? pre' \
1503 -Y 'echon if/i\ ; ? i; echon else/el\ ; ? el; echon endif/en\ ; ? en' \
1504 -Y 'echon list/l\ ; ? l' \
1505 -Y 'echon mail/m\ ; ? m' \
1506 -Y 'echon mbox/mb\ ; ? mb' \
1507 -Y 'echon next/n\ ; ? n' \
1508 -Y 'echon pipe/pi\ ; ? pi' \
1509 -Y 'echon Print/P\ ; ? P; echon Type/T\ ; ? T' \
1510 -Y 'echon print/p\ ; ? p; echon type/t\ ; ? t' \
1511 -Y 'echon quit/q\ ; ? q' \
1512 -Y 'echon Reply/R\ ; ? R' \
1513 -Y 'echon reply/r\ ; ? r' \
1514 -Y 'echon retain/ret\ ; ? ret' \
1515 -Y 'echon save/s\ ; ? s; echon Save/S\ ; ? S' \
1516 -Y 'echon set/se\ ; ? se' \
1517 -Y 'echon shell/sh\ ; ? sh' \
1518 -Y 'echon size/si\ ; ? si' \
1519 -Y 'echon source/so\ ; ? so' \
1520 -Y 'echon touch/tou\ ; ? tou' \
1521 -Y 'echon unalias/una\ ; ? una' \
1522 -Y 'echon undelete/u\ ; ? u' \
1523 -Y 'echon unset/uns\ ; ? uns' \
1524 -Y 'echon visual/v\ ; ? v' \
1525 -Y 'echon write/w\ ; ? w' \
1526 | ${sed} -e 's/:.*$//' > "${MBOX}"
1527 check 1 0 "${MBOX}" '1012680481 968'
1529 t_epilog "${@}"
1531 # }}}
1533 # Basics {{{
1534 t_shcodec() {
1535 t_prolog "${@}"
1537 # XXX the first needs to be checked, it is quite dumb as such
1538 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
1539 commandalias x echo '$?/$^ERRNAME'
1540 shcodec e abcd
1542 shcodec d abcd
1544 shcodec e a'b'c'd'
1546 shcodec d a'b'c'd'
1548 shcodec e a"b"c"d"
1550 shcodec d a"b"c"d"
1552 shcodec e a$'b'c$'d'
1554 shcodec d a$'b'c$'d'
1556 shcodec e 'abcd'
1558 shcodec d 'abcd'
1560 shcodec e "abcd"
1562 shcodec d "abcd"
1564 shcodec e $'abcd'
1566 shcodec d $'abcd'
1568 # same but with vput
1569 commandalias y echo '$?/$^ERRNAME $res'
1570 vput shcodec res e abcd
1572 eval shcodec d $res
1574 vput shcodec res d abcd
1576 eval shcodec d $res
1578 vput shcodec res e a'b'c'd'
1580 eval shcodec d $res
1582 vput shcodec res d a'b'c'd'
1584 eval shcodec d $res
1586 vput shcodec res e a"b"c"d"
1588 eval shcodec d $res
1590 vput shcodec res d a"b"c"d"
1592 eval shcodec d $res
1594 vput shcodec res e a$'b'c$'d'
1596 eval shcodec d $res
1598 vput shcodec res d a$'b'c$'d'
1600 eval shcodec d $res
1602 vput shcodec res e 'abcd'
1604 eval shcodec d $res
1606 vput shcodec res d 'abcd'
1608 eval shcodec d $res
1610 vput shcodec res e "abcd"
1612 eval shcodec d $res
1614 vput shcodec res d "abcd"
1616 eval shcodec d $res
1618 vput shcodec res e $'abcd'
1620 eval shcodec d $res
1622 vput shcodec res d $'abcd'
1624 eval shcodec d $res
1627 vput shcodec res e a b\ c d
1629 eval shcodec d $res
1631 vput shcodec res d a b\ c d
1633 vput shcodec res e ab cd
1635 eval shcodec d $res
1637 vput shcodec res d 'ab cd'
1639 vput shcodec res e a 'b c' d
1641 eval shcodec d $res
1643 vput shcodec res d a 'b c' d
1645 vput shcodec res e a "b c" d
1647 eval shcodec d $res
1649 vput shcodec res d a "b c" d
1651 vput shcodec res e a $'b c' d
1653 eval shcodec d $res
1655 vput shcodec res d a $'b c' d
1658 vput shcodec res e 'a$`"\'
1660 eval shcodec d $res
1662 vput shcodec res d 'a$`"\'
1664 vput shcodec res e "a\$\`'\"\\"
1666 eval shcodec d $res
1668 vput shcodec res d "a\$\`'\"\\"
1670 vput shcodec res e $'a\$`\'\"\\'
1672 eval shcodec d $res
1674 vput shcodec res d $'a\$`\'\"\\'
1676 vput shcodec res e $'a\$`\'"\\'
1678 eval shcodec d $res
1680 vput shcodec res d $'a\$`\'"\\'
1683 set diet=curd
1684 vput shcodec res e a${diet}c
1686 eval shcodec d $res
1688 eval vput shcodec res e a${diet}c
1690 eval shcodec d $res
1692 vput shcodec res e "a${diet}c"
1694 eval shcodec d $res
1696 eval vput shcodec res e "a${diet}c"
1698 eval shcodec d $res
1700 __EOT
1701 check 1 0 "${MBOX}" '3316745312 1241'
1703 if [ -z "${UTF8_LOCALE}" ]; then
1704 t_echoskip 'unicode:[no UTF-8 locale]'
1705 elif have_feat multibyte-charsets; then
1706 ${cat} <<- '__EOT' | LC_ALL=${UTF8_LOCALE} \
1707 ${MAILX} ${ARGS} > "${MBOX}" 2>>${ERR}
1709 shcodec e täst
1710 shcodec +e täst
1711 shcodec d $'t\u00E4st'
1712 shcodec e aՍc
1713 shcodec +e aՍc
1714 shcodec d $'a\u054Dc'
1715 shcodec e a𝕂c
1716 shcodec +e a𝕂c
1717 shcodec d $'a\U0001D542c'
1718 __EOT
1719 check unicode 0 "${MBOX}" '1175985867 77'
1720 else
1721 t_echoskip 'unicode:[!MULTIBYTE-CHARSETS]'
1724 t_epilog "${@}"
1727 t_ifelse() {
1728 t_prolog "${@}"
1730 # v15compat: old and new tests share the same result files!
1731 # v15compat: i.e., just throw away -old tests one day
1733 # Nestable conditions test
1734 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
1735 if 0
1736 echo 1.err
1737 else
1738 echo 1.ok
1739 endif
1740 if 1
1741 echo 2.ok
1742 else
1743 echo 2.err
1744 endif
1745 if $dietcurd
1746 echo 3.err
1747 else
1748 echo 3.ok
1749 endif
1750 set dietcurd=yoho
1751 if $dietcurd
1752 echo 4.ok
1753 else
1754 echo 4.err
1755 endif
1756 if $dietcurd == 'yoho'
1757 echo 5.ok
1758 else
1759 echo 5.err
1760 endif
1761 if $dietcurd ==? 'Yoho'
1762 echo 5-1.ok
1763 else
1764 echo 5-1.err
1765 endif
1766 if $dietcurd == 'Yoho'
1767 echo 5-2.err
1768 else
1769 echo 5-2.ok
1770 endif
1771 if $dietcurd != 'yoho'
1772 echo 6.err
1773 else
1774 echo 6.ok
1775 endif
1776 if $dietcurd !=?case 'Yoho'
1777 echo 6-1.err
1778 else
1779 echo 6-1.ok
1780 endif
1781 if $dietcurd != 'Yoho'
1782 echo 6-2.ok
1783 else
1784 echo 6-2.err
1785 endif
1786 # Nesting
1787 if faLse
1788 echo 7.err1
1789 if tRue
1790 echo 7.err2
1791 if yEs
1792 echo 7.err3
1793 else
1794 echo 7.err4
1795 endif
1796 echo 7.err5
1797 endif
1798 echo 7.err6
1799 else
1800 echo 7.ok7
1801 if YeS
1802 echo 7.ok8
1803 if No
1804 echo 7.err9
1805 else
1806 echo 7.ok9
1807 endif
1808 echo 7.ok10
1809 else
1810 echo 7.err11
1811 if yeS
1812 echo 7.err12
1813 else
1814 echo 7.err13
1815 endif
1816 endif
1817 echo 7.ok14
1818 endif
1819 if r
1820 echo 8.ok1
1821 if R
1822 echo 8.ok2
1823 else
1824 echo 8.err2
1825 endif
1826 echo 8.ok3
1827 else
1828 echo 8.err1
1829 endif
1830 if s
1831 echo 9.err1
1832 else
1833 echo 9.ok1
1834 if S
1835 echo 9.err2
1836 else
1837 echo 9.ok2
1838 endif
1839 echo 9.ok3
1840 endif
1841 # `elif'
1842 if $dietcurd == 'yohu'
1843 echo 10.err1
1844 elif $dietcurd == 'yoha'
1845 echo 10.err2
1846 elif $dietcurd == 'yohe'
1847 echo 10.err3
1848 elif $dietcurd == 'yoho'
1849 echo 10.ok1
1850 if $dietcurd == 'yohu'
1851 echo 10.err4
1852 elif $dietcurd == 'yoha'
1853 echo 10.err5
1854 elif $dietcurd == 'yohe'
1855 echo 10.err6
1856 elif $dietcurd == 'yoho'
1857 echo 10.ok2
1858 if $dietcurd == 'yohu'
1859 echo 10.err7
1860 elif $dietcurd == 'yoha'
1861 echo 10.err8
1862 elif $dietcurd == 'yohe'
1863 echo 10.err9
1864 elif $dietcurd == 'yoho'
1865 echo 10.ok3
1866 else
1867 echo 10.err10
1868 endif
1869 else
1870 echo 10.err11
1871 endif
1872 else
1873 echo 10.err12
1874 endif
1875 # integer
1876 set dietcurd=10
1877 if $dietcurd -lt 11
1878 echo 11.ok1
1879 if $dietcurd -gt 9
1880 echo 11.ok2
1881 else
1882 echo 11.err2
1883 endif
1884 if $dietcurd -eq 10
1885 echo 11.ok3
1886 else
1887 echo 11.err3
1888 endif
1889 if $dietcurd -ge 10
1890 echo 11.ok4
1891 else
1892 echo 11.err4
1893 endif
1894 if $dietcurd -le 10
1895 echo 11.ok5
1896 else
1897 echo 11.err5
1898 endif
1899 if $dietcurd -ge 11
1900 echo 11.err6
1901 else
1902 echo 11.ok6
1903 endif
1904 if $dietcurd -le 9
1905 echo 11.err7
1906 else
1907 echo 11.ok7
1908 endif
1909 else
1910 echo 11.err1
1911 endif
1912 set dietcurd=Abc
1913 if $dietcurd < aBd
1914 echo 12.ok1
1915 if $dietcurd >? abB
1916 echo 12.ok2
1917 else
1918 echo 12.err2
1919 endif
1920 if $dietcurd ==?case aBC
1921 echo 12.ok3
1922 else
1923 echo 12.err3
1924 endif
1925 if $dietcurd >=?ca AbC
1926 echo 12.ok4
1927 else
1928 echo 12.err4
1929 endif
1930 if $dietcurd <=? ABc
1931 echo 12.ok5
1932 else
1933 echo 12.err5
1934 endif
1935 if $dietcurd >=?case abd
1936 echo 12.err6
1937 else
1938 echo 12.ok6
1939 endif
1940 if $dietcurd <=? abb
1941 echo 12.err7
1942 else
1943 echo 12.ok7
1944 endif
1945 else
1946 echo 12.err1
1947 endif
1948 if $dietcurd < aBc
1949 echo 12-1.ok
1950 else
1951 echo 12-1.err
1952 endif
1953 if $dietcurd <? aBc
1954 echo 12-2.err
1955 else
1956 echo 12-2.ok
1957 endif
1958 if $dietcurd > ABc
1959 echo 12-3.ok
1960 else
1961 echo 12-3.err
1962 endif
1963 if $dietcurd >? ABc
1964 echo 12-3.err
1965 else
1966 echo 12-3.ok
1967 endif
1968 if $dietcurd =%?case aB
1969 echo 13.ok
1970 else
1971 echo 13.err
1972 endif
1973 if $dietcurd =% aB
1974 echo 13-1.err
1975 else
1976 echo 13-1.ok
1977 endif
1978 if $dietcurd =%? bC
1979 echo 14.ok
1980 else
1981 echo 14.err
1982 endif
1983 if $dietcurd !% aB
1984 echo 15-1.ok
1985 else
1986 echo 15-1.err
1987 endif
1988 if $dietcurd !%? aB
1989 echo 15-2.err
1990 else
1991 echo 15-2.ok
1992 endif
1993 if $dietcurd !% bC
1994 echo 15-3.ok
1995 else
1996 echo 15-3.err
1997 endif
1998 if $dietcurd !%? bC
1999 echo 15-4.err
2000 else
2001 echo 15-4.ok
2002 endif
2003 if $dietcurd =% Cd
2004 echo 16.err
2005 else
2006 echo 16.ok
2007 endif
2008 if $dietcurd !% Cd
2009 echo 17.ok
2010 else
2011 echo 17.err
2012 endif
2013 set diet=abc curd=abc
2014 if $diet == $curd
2015 echo 18.ok
2016 else
2017 echo 18.err
2018 endif
2019 set diet=abc curd=abcd
2020 if $diet != $curd
2021 echo 19.ok
2022 else
2023 echo 19.err
2024 endif
2025 # 1. Shitty grouping capabilities as of today
2026 unset diet curd ndefined
2027 if [ [ false ] || [ false ] || [ true ] ] && \
2028 [ [ false ] || [ true ] ] && \
2029 [ yes ]
2030 echo 20.ok
2031 else
2032 echo 20.err
2033 endif
2034 if [ [ [ [ 0 ] || [ 1 ] ] && [ [ 1 ] || [ 0 ] ] ] && [ 1 ] ] && [ yes ]
2035 echo 21.ok
2036 else
2037 echo 21.err
2038 endif
2039 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] ]
2040 echo 22.ok
2041 else
2042 echo 22.err
2043 endif
2044 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] ]
2045 echo 23.ok
2046 else
2047 echo 23.err
2048 endif
2049 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] && [ no ]
2050 echo 24.err
2051 else
2052 echo 24.ok
2053 endif
2054 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] \
2055 && [ no ] || [ yes ]
2056 echo 25.ok
2057 else
2058 echo 25.err
2059 endif
2060 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
2061 echo 26.ok
2062 else
2063 echo 26.err
2064 endif
2065 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 0 ] ]
2066 echo 27.err
2067 else
2068 echo 27.ok
2069 endif
2070 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 0 ] ] && [ 1 ] ] ] && [ 1 ] ]
2071 echo 28.err
2072 else
2073 echo 28.ok
2074 endif
2075 if [ [ [ [ [ [ [ 0 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
2076 echo 29.err
2077 else
2078 echo 29.ok
2079 endif
2080 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 0 ]
2081 echo 30.err
2082 else
2083 echo 30.ok
2084 endif
2085 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 1 ]
2086 echo 31.ok
2087 else
2088 echo 31.err
2089 endif
2090 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ]
2091 echo 32.err
2092 else
2093 echo 32.ok
2094 endif
2095 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 1 ]
2096 echo 33.ok
2097 else
2098 echo 33.err
2099 endif
2100 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 0 ]
2101 echo 34.err
2102 else
2103 echo 34.ok
2104 endif
2105 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 1 ]
2106 echo 35.ok
2107 else
2108 echo 35.err
2109 endif
2110 set diet=yo curd=ho
2111 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
2112 echo 36.err
2113 else
2114 echo 36.ok
2115 endif
2116 set ndefined
2117 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
2118 echo 37.ok
2119 else
2120 echo 37.err
2121 endif
2122 # 2. Shitty grouping capabilities as of today
2123 unset diet curd ndefined
2124 if [ false || false || true ] && [ false || true ] && yes
2125 echo 40.ok
2126 else
2127 echo 40.err
2128 endif
2129 if [ [ [ 0 || 1 ] && [ 1 || 0 ] ] && 1 ] && [ yes ]
2130 echo 41.ok
2131 else
2132 echo 41.err
2133 endif
2134 if [ 1 || 0 || 0 || 0 ]
2135 echo 42.ok
2136 else
2137 echo 42.err
2138 endif
2139 if [ 1 || 0 || 0 || 0 || [ 1 ] ]
2140 echo 43.ok
2141 else
2142 echo 43.err
2143 endif
2144 if [ 1 || 0 || 0 || 0 || [ 1 ] || 1 ] && no
2145 echo 44.err
2146 else
2147 echo 44.ok
2148 endif
2149 if [ 1 || 0 || 0 || 0 || 1 || [ 1 ] ] && no || [ yes ]
2150 echo 45.ok
2151 else
2152 echo 45.err
2153 endif
2154 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && 1 ] ] && [ 1 ] ]
2155 echo 46.ok
2156 else
2157 echo 46.err
2158 endif
2159 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && [ 1 ] ] ] && 0 ]
2160 echo 47.err
2161 else
2162 echo 47.ok
2163 endif
2164 if [ [ [ [ [ [ [ 1 ] ] && 1 ] && 0 ] && [ 1 ] ] ] && 1 ]
2165 echo 48.err
2166 else
2167 echo 48.ok
2168 endif
2169 if [ [ [ [ [ [ 0 ] && 1 ] && 1 ] && 1 ] ] && 1 ]
2170 echo 49.err
2171 else
2172 echo 49.ok
2173 endif
2174 if 1 || 0 || 0 || 0 && 0
2175 echo 50.err
2176 else
2177 echo 50.ok
2178 endif
2179 if 1 || 0 || 0 || 0 && 1
2180 echo 51.ok
2181 else
2182 echo 51.err
2183 endif
2184 if 0 || 0 || 0 || 1 && 0
2185 echo 52.err
2186 else
2187 echo 52.ok
2188 endif
2189 if 0 || 0 || 0 || 1 && 1
2190 echo 53.ok
2191 else
2192 echo 53.err
2193 endif
2194 if 0 || 0 || 0 || 1 && 0 || 1 && 0
2195 echo 54.err
2196 else
2197 echo 54.ok
2198 endif
2199 if 0 || 0 || 0 || 1 && 0 || 1 && 1
2200 echo 55.ok
2201 else
2202 echo 55.err
2203 endif
2204 set diet=yo curd=ho
2205 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
2206 echo 56.err
2207 else
2208 echo 56.ok
2209 endif
2210 if $diet == 'yo' && $curd == 'ho' && $ndefined
2211 echo 57.err
2212 else
2213 echo 57.ok
2214 endif
2215 set ndefined
2216 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
2217 echo 57.ok
2218 else
2219 echo 57.err
2220 endif
2221 if $diet == 'yo' && $curd == 'ho' && $ndefined
2222 echo 58.ok
2223 else
2224 echo 58.err
2225 endif
2226 if [ [ [ [ [ [ $diet == 'yo' && $curd == 'ho' && $ndefined ] ] ] ] ] ]
2227 echo 59.ok
2228 else
2229 echo 59.err
2230 endif
2231 # Some more en-braced variables
2232 set diet=yo curd=ho
2233 if ${diet} == ${curd}
2234 echo 70.err
2235 else
2236 echo 70.ok
2237 endif
2238 if ${diet} != ${curd}
2239 echo 71.ok
2240 else
2241 echo 71.err
2242 endif
2243 if $diet == ${curd}
2244 echo 72.err
2245 else
2246 echo 72.ok
2247 endif
2248 if ${diet} == $curd
2249 echo 73.err
2250 else
2251 echo 73.ok
2252 endif
2253 # Unary !
2254 if ! 0 && ! ! 1 && ! ! ! ! 2 && 3
2255 echo 80.ok
2256 else
2257 echo 80.err
2258 endif
2259 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ ! 2 ] ] ] && 3
2260 echo 81.ok
2261 else
2262 echo 81.err
2263 endif
2264 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
2265 echo 82.ok
2266 else
2267 echo 82.err
2268 endif
2269 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
2270 echo 83.err
2271 else
2272 echo 83.ok
2273 endif
2274 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
2275 echo 84.err
2276 else
2277 echo 84.ok
2278 endif
2279 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
2280 echo 85.err
2281 else
2282 echo 85.ok
2283 endif
2284 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
2285 echo 86.err
2286 else
2287 echo 86.ok
2288 endif
2289 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] || 3
2290 echo 87.ok
2291 else
2292 echo 87.err
2293 endif
2294 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! ! [ 2 ] ] ] ] ]
2295 echo 88.ok
2296 else
2297 echo 88.err
2298 endif
2299 # Unary !, odd
2300 if ! 0 && ! ! 1 && ! ! ! 0 && 3
2301 echo 90.ok
2302 else
2303 echo 90.err
2304 endif
2305 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ 0 ] ] ] && 3
2306 echo 91.ok
2307 else
2308 echo 91.err
2309 endif
2310 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ [ 0 ] ] ] ] ] && 3
2311 echo 92.ok
2312 else
2313 echo 92.err
2314 endif
2315 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! ! [ ! [ ! 0 ] ] ] ] && ! 3
2316 echo 93.err
2317 else
2318 echo 93.ok
2319 endif
2320 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ ! [ ! [ ! [ ! 0 ] ] ] ] && 3
2321 echo 94.ok
2322 else
2323 echo 94.err
2324 endif
2325 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! ! [ ! [ ! [ ! [ 0 ] ] ] ] ] && 3
2326 echo 95.err
2327 else
2328 echo 95.ok
2329 endif
2330 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! ! 0 ] ] ] ] && 3
2331 echo 96.err
2332 else
2333 echo 96.ok
2334 endif
2335 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ ! 0 ] ] ] ] ] || 3
2336 echo 97.ok
2337 else
2338 echo 97.err
2339 endif
2340 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! [ 0 ] ] ] ] ]
2341 echo 98.ok
2342 else
2343 echo 98.err
2344 endif
2345 __EOT
2347 check normal-old 0 "${MBOX}" '1688759742 719' # pre v15compat
2349 if have_feat regex; then
2350 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
2351 set dietcurd=yoho
2352 if $dietcurd =~ '^yo.*'
2353 echo 1.ok
2354 else
2355 echo 1.err
2356 endif
2357 if $dietcurd =~ '^Yo.*'
2358 echo 1-1.err
2359 else
2360 echo 1-1.ok
2361 endif
2362 if $dietcurd =~?case '^Yo.*'
2363 echo 1-2.ok
2364 else
2365 echo 1-2.err
2366 endif
2367 if $dietcurd =~ '^yOho.+'
2368 echo 2.err
2369 else
2370 echo 2.ok
2371 endif
2372 if $dietcurd !~? '.*Ho$'
2373 echo 3.err
2374 else
2375 echo 3.ok
2376 endif
2377 if $dietcurd !~ '.+yohO$'
2378 echo 4.ok
2379 else
2380 echo 4.err
2381 endif
2382 if [ $dietcurd !~?cas '.+yoho$' ]
2383 echo 5.ok
2384 else
2385 echo 5.err
2386 endif
2387 if ! [ $dietcurd =~?case '.+yoho$' ]
2388 echo 6.ok
2389 else
2390 echo 6.err
2391 endif
2392 if ! ! [ $dietcurd !~? '.+yoho$' ]
2393 echo 7.ok
2394 else
2395 echo 7.err
2396 endif
2397 if ! [ ! [ $dietcurd !~? '.+yoho$' ] ]
2398 echo 8.ok
2399 else
2400 echo 8.err
2401 endif
2402 if [ ! [ ! [ $dietcurd !~? '.+yoho$' ] ] ]
2403 echo 9.ok
2404 else
2405 echo 9.err
2406 endif
2407 if ! [ ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
2408 echo 10.err
2409 else
2410 echo 10.ok
2411 endif
2412 if ! ! ! $dietcurd !~ '.+yoho$'
2413 echo 11.err
2414 else
2415 echo 11.ok
2416 endif
2417 if ! ! ! $dietcurd =~ '.+yoho$'
2418 echo 12.ok
2419 else
2420 echo 12.err
2421 endif
2422 if ! [ ! ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
2423 echo 13.ok
2424 else
2425 echo 13.err
2426 endif
2427 set diet=abc curd='^abc$'
2428 if $diet =~ $curd
2429 echo 14.ok
2430 else
2431 echo 14.err
2432 endif
2433 set diet=abc curd='^abcd$'
2434 if $diet !~ $curd
2435 echo 15.ok
2436 else
2437 echo 15.err
2438 endif
2439 __EOT
2441 check regex-old 0 "${MBOX}" '1115671789 95' # pre v15compat
2442 else
2443 t_echoskip 'regex-old:[no regex option]'
2446 ## post v15compat
2448 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Sv15-compat=X > "${MBOX}"
2449 \if -N xyz; echo 1.err-1; \
2450 \elif ! -Z xyz;echo 1.err-2;\
2451 \elif -n "$xyz" ; echo 1.err-3 ; \
2452 \elif ! -z "$xyz" ; echo 1.err-4 ; \
2453 \else;echo 1.ok;\
2454 \end
2455 \set xyz
2456 \if ! -N xyz; echo 2.err-1; \
2457 \elif -Z xyz;echo 2.err-2;\
2458 \elif -n "$xyz" ; echo 2.err-3 ; \
2459 \elif ! -z "$xyz" ; echo 2.err-4 ; \
2460 \else;echo 2.ok;\
2461 \end
2462 \set xyz=notempty
2463 \if ! -N xyz; echo 3.err-1; \
2464 \elif -Z xyz;echo 3.err-2;\
2465 \elif ! -n "$xyz";echo 3.err-3;\
2466 \elif -z "$xyz";echo 3.err-4;\
2467 \else;echo 3.ok;\
2468 \end
2469 \if $xyz != notempty;echo 4.err-1;else;echo 4.ok;\end
2470 \if $xyz == notempty;echo 5.ok;else;echo 5.err-1;\end
2471 __EOT
2473 check NnZz_whiteout 0 "${MBOX}" '4280687462 25'
2475 # TODO t_ifelse: individual tests as for NnZz_whiteout
2476 # Nestable conditions test
2477 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Sv15-compat=x > "${MBOX}"
2478 if 0
2479 echo 1.err
2480 else
2481 echo 1.ok
2482 endif
2483 if 1
2484 echo 2.ok
2485 else
2486 echo 2.err
2487 endif
2488 if [ "$dietcurd" != "" ]
2489 echo 3.err
2490 else
2491 echo 3.ok
2492 endif
2493 set dietcurd=yoho
2494 if $'\$dietcurd' != ""
2495 echo 4.ok
2496 else
2497 echo 4.err
2498 endif
2499 if "$dietcurd" == 'yoho'
2500 echo 5.ok
2501 else
2502 echo 5.err
2503 endif
2504 if $'\$dietcurd' ==? 'Yoho'
2505 echo 5-1.ok
2506 else
2507 echo 5-1.err
2508 endif
2509 if $dietcurd == 'Yoho'
2510 echo 5-2.err
2511 else
2512 echo 5-2.ok
2513 endif
2514 if $dietcurd != 'yoho'
2515 echo 6.err
2516 else
2517 echo 6.ok
2518 endif
2519 if $dietcurd !=?case 'Yoho'
2520 echo 6-1.err
2521 else
2522 echo 6-1.ok
2523 endif
2524 if $dietcurd != 'Yoho'
2525 echo 6-2.ok
2526 else
2527 echo 6-2.err
2528 endif
2529 # Nesting
2530 if faLse
2531 echo 7.err1
2532 if tRue
2533 echo 7.err2
2534 if yEs
2535 echo 7.err3
2536 else
2537 echo 7.err4
2538 endif
2539 echo 7.err5
2540 endif
2541 echo 7.err6
2542 else
2543 echo 7.ok7
2544 if YeS
2545 echo 7.ok8
2546 if No
2547 echo 7.err9
2548 else
2549 echo 7.ok9
2550 endif
2551 echo 7.ok10
2552 else
2553 echo 7.err11
2554 if yeS
2555 echo 7.err12
2556 else
2557 echo 7.err13
2558 endif
2559 endif
2560 echo 7.ok14
2561 endif
2562 if r
2563 echo 8.ok1
2564 if R
2565 echo 8.ok2
2566 else
2567 echo 8.err2
2568 endif
2569 echo 8.ok3
2570 else
2571 echo 8.err1
2572 endif
2573 if s
2574 echo 9.err1
2575 else
2576 echo 9.ok1
2577 if S
2578 echo 9.err2
2579 else
2580 echo 9.ok2
2581 endif
2582 echo 9.ok3
2583 endif
2584 # `elif'
2585 if $dietcurd == 'yohu'
2586 echo 10.err1
2587 elif $dietcurd == 'yoha'
2588 echo 10.err2
2589 elif $dietcurd == 'yohe'
2590 echo 10.err3
2591 elif $dietcurd == 'yoho'
2592 echo 10.ok1
2593 if $dietcurd == 'yohu'
2594 echo 10.err4
2595 elif $dietcurd == 'yoha'
2596 echo 10.err5
2597 elif $dietcurd == 'yohe'
2598 echo 10.err6
2599 elif $dietcurd == 'yoho'
2600 echo 10.ok2
2601 if $dietcurd == 'yohu'
2602 echo 10.err7
2603 elif $dietcurd == 'yoha'
2604 echo 10.err8
2605 elif $dietcurd == 'yohe'
2606 echo 10.err9
2607 elif $dietcurd == 'yoho'
2608 echo 10.ok3
2609 else
2610 echo 10.err10
2611 endif
2612 else
2613 echo 10.err11
2614 endif
2615 else
2616 echo 10.err12
2617 endif
2618 # integer
2619 set dietcurd=10
2620 if $dietcurd -lt 11
2621 echo 11.ok1
2622 if $dietcurd -gt 9
2623 echo 11.ok2
2624 else
2625 echo 11.err2
2626 endif
2627 if $dietcurd -eq 10
2628 echo 11.ok3
2629 else
2630 echo 11.err3
2631 endif
2632 if $dietcurd -ge 10
2633 echo 11.ok4
2634 else
2635 echo 11.err4
2636 endif
2637 if $dietcurd -le 10
2638 echo 11.ok5
2639 else
2640 echo 11.err5
2641 endif
2642 if $dietcurd -ge 11
2643 echo 11.err6
2644 else
2645 echo 11.ok6
2646 endif
2647 if $dietcurd -ge?satu -0xFFFFFFFFFFFFFFFF1
2648 echo 11.err7
2649 else
2650 echo 11.ok7
2651 endif
2652 else
2653 echo 11.err1
2654 endif
2655 set dietcurd=Abc
2656 if $dietcurd < aBd
2657 echo 12.ok1
2658 if $dietcurd >? abB
2659 echo 12.ok2
2660 else
2661 echo 12.err2
2662 endif
2663 if $dietcurd ==?case aBC
2664 echo 12.ok3
2665 else
2666 echo 12.err3
2667 endif
2668 if $dietcurd >=?ca AbC
2669 echo 12.ok4
2670 else
2671 echo 12.err4
2672 endif
2673 if $dietcurd <=? ABc
2674 echo 12.ok5
2675 else
2676 echo 12.err5
2677 endif
2678 if $dietcurd >=?case abd
2679 echo 12.err6
2680 else
2681 echo 12.ok6
2682 endif
2683 if $dietcurd <=? abb
2684 echo 12.err7
2685 else
2686 echo 12.ok7
2687 endif
2688 else
2689 echo 12.err1
2690 endif
2691 if $dietcurd < aBc
2692 echo 12-1.ok
2693 else
2694 echo 12-1.err
2695 endif
2696 if $dietcurd <? aBc
2697 echo 12-2.err
2698 else
2699 echo 12-2.ok
2700 endif
2701 if $dietcurd > ABc
2702 echo 12-3.ok
2703 else
2704 echo 12-3.err
2705 endif
2706 if $dietcurd >? ABc
2707 echo 12-3.err
2708 else
2709 echo 12-3.ok
2710 endif
2711 if $dietcurd =%?case aB
2712 echo 13.ok
2713 else
2714 echo 13.err
2715 endif
2716 if $dietcurd =% aB
2717 echo 13-1.err
2718 else
2719 echo 13-1.ok
2720 endif
2721 if $dietcurd =%? bC
2722 echo 14.ok
2723 else
2724 echo 14.err
2725 endif
2726 if $dietcurd !% aB
2727 echo 15-1.ok
2728 else
2729 echo 15-1.err
2730 endif
2731 if $dietcurd !%? aB
2732 echo 15-2.err
2733 else
2734 echo 15-2.ok
2735 endif
2736 if $dietcurd !% bC
2737 echo 15-3.ok
2738 else
2739 echo 15-3.err
2740 endif
2741 if $dietcurd !%? bC
2742 echo 15-4.err
2743 else
2744 echo 15-4.ok
2745 endif
2746 if $dietcurd =% Cd
2747 echo 16.err
2748 else
2749 echo 16.ok
2750 endif
2751 if $dietcurd !% Cd
2752 echo 17.ok
2753 else
2754 echo 17.err
2755 endif
2756 set diet='ab c' curd='ab c'
2757 if "$diet" == "$curd"
2758 echo 18.ok
2759 else
2760 echo 18.err
2761 endif
2762 set diet='ab c' curd='ab cd'
2763 if "$diet" != "$curd"
2764 echo 19.ok
2765 else
2766 echo 19.err
2767 endif
2768 # 1. Shitty grouping capabilities as of today
2769 unset diet curd ndefined
2770 if [ [ false ] || [ false ] || [ true ] ] && \
2771 [ [ false ] || [ true ] ] && \
2772 [ yes ]
2773 echo 20.ok
2774 else
2775 echo 20.err
2776 endif
2777 if [ [ [ [ 0 ] || [ 1 ] ] && [ [ 1 ] || [ 0 ] ] ] && [ 1 ] ] && [ yes ]
2778 echo 21.ok
2779 else
2780 echo 21.err
2781 endif
2782 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] ]
2783 echo 22.ok
2784 else
2785 echo 22.err
2786 endif
2787 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] ]
2788 echo 23.ok
2789 else
2790 echo 23.err
2791 endif
2792 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] && [ no ]
2793 echo 24.err
2794 else
2795 echo 24.ok
2796 endif
2797 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] \
2798 && [ no ] || [ yes ]
2799 echo 25.ok
2800 else
2801 echo 25.err
2802 endif
2803 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
2804 echo 26.ok
2805 else
2806 echo 26.err
2807 endif
2808 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 0 ] ]
2809 echo 27.err
2810 else
2811 echo 27.ok
2812 endif
2813 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 0 ] ] && [ 1 ] ] ] && [ 1 ] ]
2814 echo 28.err
2815 else
2816 echo 28.ok
2817 endif
2818 if [ [ [ [ [ [ [ 0 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
2819 echo 29.err
2820 else
2821 echo 29.ok
2822 endif
2823 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 0 ]
2824 echo 30.err
2825 else
2826 echo 30.ok
2827 endif
2828 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 1 ]
2829 echo 31.ok
2830 else
2831 echo 31.err
2832 endif
2833 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ]
2834 echo 32.err
2835 else
2836 echo 32.ok
2837 endif
2838 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 1 ]
2839 echo 33.ok
2840 else
2841 echo 33.err
2842 endif
2843 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 0 ]
2844 echo 34.err
2845 else
2846 echo 34.ok
2847 endif
2848 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 1 ]
2849 echo 35.ok
2850 else
2851 echo 35.err
2852 endif
2853 set diet=yo curd=ho
2854 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && \
2855 [ -N ndefined || -n "$ndefined" || \
2856 ! -Z ndefined || ! -z "$ndefined" ]
2857 echo 36.err
2858 else
2859 echo 36.ok
2860 endif
2861 set ndefined
2862 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && \
2863 -N ndefined && ! -n "$ndefined" && \
2864 ! -Z ndefined && -z "$ndefined"
2865 echo 37.ok
2866 else
2867 echo 37.err
2868 endif
2869 # 2. Shitty grouping capabilities as of today
2870 unset diet curd ndefined
2871 if [ false || false || true ] && [ false || true ] && yes
2872 echo 40.ok
2873 else
2874 echo 40.err
2875 endif
2876 if [ [ [ 0 || 1 ] && [ 1 || 0 ] ] && 1 ] && [ yes ]
2877 echo 41.ok
2878 else
2879 echo 41.err
2880 endif
2881 if [ 1 || 0 || 0 || 0 ]
2882 echo 42.ok
2883 else
2884 echo 42.err
2885 endif
2886 if [ 1 || 0 || 0 || 0 || [ 1 ] ]
2887 echo 43.ok
2888 else
2889 echo 43.err
2890 endif
2891 if [ 1 || 0 || 0 || 0 || [ 1 ] || 1 ] && no
2892 echo 44.err
2893 else
2894 echo 44.ok
2895 endif
2896 if [ 1 || 0 || 0 || 0 || 1 || [ 1 ] ] && no || [ yes ]
2897 echo 45.ok
2898 else
2899 echo 45.err
2900 endif
2901 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && 1 ] ] && [ 1 ] ]
2902 echo 46.ok
2903 else
2904 echo 46.err
2905 endif
2906 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && [ 1 ] ] ] && 0 ]
2907 echo 47.err
2908 else
2909 echo 47.ok
2910 endif
2911 if [ [ [ [ [ [ [ 1 ] ] && 1 ] && 0 ] && [ 1 ] ] ] && 1 ]
2912 echo 48.err
2913 else
2914 echo 48.ok
2915 endif
2916 if [ [ [ [ [ [ 0 ] && 1 ] && 1 ] && 1 ] ] && 1 ]
2917 echo 49.err
2918 else
2919 echo 49.ok
2920 endif
2921 if 1 || 0 || 0 || 0 && 0
2922 echo 50.err
2923 else
2924 echo 50.ok
2925 endif
2926 if 1 || 0 || 0 || 0 && 1
2927 echo 51.ok
2928 else
2929 echo 51.err
2930 endif
2931 if 0 || 0 || 0 || 1 && 0
2932 echo 52.err
2933 else
2934 echo 52.ok
2935 endif
2936 if 0 || 0 || 0 || 1 && 1
2937 echo 53.ok
2938 else
2939 echo 53.err
2940 endif
2941 if 0 || 0 || 0 || 1 && 0 || 1 && 0
2942 echo 54.err
2943 else
2944 echo 54.ok
2945 endif
2946 if 0 || 0 || 0 || 1 && 0 || 1 && 1
2947 echo 55.ok
2948 else
2949 echo 55.err
2950 endif
2951 set diet=yo curd=ho
2952 if [ $diet == 'yo' && $curd == 'ho' ] && \
2953 [ -N ndefined || -n "$ndefined" || \
2954 ! -Z ndefined || ! -z "$ndefined" ]
2955 echo 56.err
2956 else
2957 echo 56.ok
2958 endif
2959 if [ $diet == 'yo' && $curd == 'ho' && \
2960 [ [ -N ndefined || -n "$ndefined" || \
2961 ! -Z ndefined || ! -z "$ndefined" ] ] ]
2962 echo 57.err
2963 else
2964 echo 57.ok
2965 endif
2966 set ndefined
2967 if [ $diet == 'yo' && $curd == 'ho' ] && \
2968 -N ndefined && ! -n "$ndefined" && \
2969 ! -Z ndefined && -z "$ndefined"
2970 echo 57.ok
2971 else
2972 echo 57.err
2973 endif
2974 if $diet == 'yo' && $curd == 'ho' && ! -Z ndefined
2975 echo 58.ok
2976 else
2977 echo 58.err
2978 endif
2979 if [ [ [ [ [ [ $diet == 'yo' && $curd == 'ho' && -N ndefined ] ] ] ] ] ]
2980 echo 59.ok
2981 else
2982 echo 59.err
2983 endif
2984 # Some more en-braced variables
2985 set diet=yo curd=ho
2986 if ${diet} == ${curd}
2987 echo 70.err
2988 else
2989 echo 70.ok
2990 endif
2991 if "${diet}" != "${curd}"
2992 echo 71.ok
2993 else
2994 echo 71.err
2995 endif
2996 if $diet == ${curd}
2997 echo 72.err
2998 else
2999 echo 72.ok
3000 endif
3001 if ${diet} == $curd
3002 echo 73.err
3003 else
3004 echo 73.ok
3005 endif
3006 # Unary !
3007 if ! 0 && ! ! 1 && ! ! ! ! 2 && 3
3008 echo 80.ok
3009 else
3010 echo 80.err
3011 endif
3012 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ ! 2 ] ] ] && 3
3013 echo 81.ok
3014 else
3015 echo 81.err
3016 endif
3017 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
3018 echo 82.ok
3019 else
3020 echo 82.err
3021 endif
3022 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
3023 echo 83.err
3024 else
3025 echo 83.ok
3026 endif
3027 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
3028 echo 84.err
3029 else
3030 echo 84.ok
3031 endif
3032 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
3033 echo 85.err
3034 else
3035 echo 85.ok
3036 endif
3037 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
3038 echo 86.err
3039 else
3040 echo 86.ok
3041 endif
3042 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] || 3
3043 echo 87.ok
3044 else
3045 echo 87.err
3046 endif
3047 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! ! [ 2 ] ] ] ] ]
3048 echo 88.ok
3049 else
3050 echo 88.err
3051 endif
3052 # Unary !, odd
3053 if ! 0 && ! ! 1 && ! ! ! 0 && 3
3054 echo 90.ok
3055 else
3056 echo 90.err
3057 endif
3058 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ 0 ] ] ] && 3
3059 echo 91.ok
3060 else
3061 echo 91.err
3062 endif
3063 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ [ 0 ] ] ] ] ] && 3
3064 echo 92.ok
3065 else
3066 echo 92.err
3067 endif
3068 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! ! [ ! [ ! 0 ] ] ] ] && ! 3
3069 echo 93.err
3070 else
3071 echo 93.ok
3072 endif
3073 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ ! [ ! [ ! [ ! 0 ] ] ] ] && 3
3074 echo 94.ok
3075 else
3076 echo 94.err
3077 endif
3078 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! ! [ ! [ ! [ ! [ 0 ] ] ] ] ] && 3
3079 echo 95.err
3080 else
3081 echo 95.ok
3082 endif
3083 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! ! 0 ] ] ] ] && 3
3084 echo 96.err
3085 else
3086 echo 96.ok
3087 endif
3088 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ ! 0 ] ] ] ] ] || 3
3089 echo 97.ok
3090 else
3091 echo 97.err
3092 endif
3093 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! [ 0 ] ] ] ] ]
3094 echo 98.ok
3095 else
3096 echo 98.err
3097 endif
3098 __EOT
3100 check normal 0 "${MBOX}" '1688759742 719'
3102 if have_feat regex; then
3103 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Sv15-compat=X > "${MBOX}"
3104 set dietcurd=yoho
3105 if $dietcurd =~ '^yo.*'
3106 echo 1.ok
3107 else
3108 echo 1.err
3109 endif
3110 if "$dietcurd" =~ '^Yo.*'
3111 echo 1-1.err
3112 else
3113 echo 1-1.ok
3114 endif
3115 if $dietcurd =~?case '^Yo.*'
3116 echo 1-2.ok
3117 else
3118 echo 1-2.err
3119 endif
3120 if $dietcurd =~ '^yOho.+'
3121 echo 2.err
3122 else
3123 echo 2.ok
3124 endif
3125 if $dietcurd !~? '.*Ho$'
3126 echo 3.err
3127 else
3128 echo 3.ok
3129 endif
3130 if $dietcurd !~ '.+yohO$'
3131 echo 4.ok
3132 else
3133 echo 4.err
3134 endif
3135 if [ $dietcurd !~?cas '.+yoho$' ]
3136 echo 5.ok
3137 else
3138 echo 5.err
3139 endif
3140 if ! [ "$dietcurd" =~?case '.+yoho$' ]
3141 echo 6.ok
3142 else
3143 echo 6.err
3144 endif
3145 if ! ! [ $'\$dietcurd' !~? '.+yoho$' ]
3146 echo 7.ok
3147 else
3148 echo 7.err
3149 endif
3150 if ! [ ! [ $dietcurd !~? '.+yoho$' ] ]
3151 echo 8.ok
3152 else
3153 echo 8.err
3154 endif
3155 if [ ! [ ! [ $dietcurd !~? '.+yoho$' ] ] ]
3156 echo 9.ok
3157 else
3158 echo 9.err
3159 endif
3160 if ! [ ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
3161 echo 10.err
3162 else
3163 echo 10.ok
3164 endif
3165 if ! ! ! $dietcurd !~ '.+yoho$'
3166 echo 11.err
3167 else
3168 echo 11.ok
3169 endif
3170 if ! ! ! $dietcurd =~ '.+yoho$'
3171 echo 12.ok
3172 else
3173 echo 12.err
3174 endif
3175 if ! [ ! ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
3176 echo 13.ok
3177 else
3178 echo 13.err
3179 endif
3180 set diet=abc curd='^abc$'
3181 if $diet =~ $curd
3182 echo 14.ok
3183 else
3184 echo 14.err
3185 endif
3186 set diet=abc curd='^abcd$'
3187 if "$diet" !~ $'\$curd'
3188 echo 15.ok
3189 else
3190 echo 15.err
3191 endif
3192 __EOT
3194 check regex 0 "${MBOX}" '1115671789 95'
3195 else
3196 t_echoskip 'regex:[!REGEX]'
3199 t_epilog "${@}"
3202 t_localopts() {
3203 t_prolog "${@}"
3205 # Nestable conditions test
3206 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
3207 define t2 {
3208 echo in: t2
3209 set t2=t2
3210 echo $t2
3212 define t1 {
3213 echo in: t1
3214 set gv1=gv1
3215 localopts on
3216 set lv1=lv1 lv2=lv2
3217 set lv3=lv3
3218 call t2
3219 localopts off
3220 set gv2=gv2
3221 echo $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2
3223 define t0 {
3224 echo in: t0
3225 call t1
3226 echo $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2
3227 echo "$gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2"
3229 account trouble {
3230 echo in: trouble
3231 call t0
3233 call t0
3234 unset gv1 gv2
3235 account trouble
3236 echo active trouble: $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t3
3237 account null
3238 echo active null: $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t3
3241 define ll2 {
3242 localopts $1
3243 set x=2
3244 echo ll2=$x
3246 define ll1 {
3247 wysh set y=$1; shift; eval localopts $y; localopts $1; shift
3248 set x=1
3249 echo ll1.1=$x
3250 call ll2 $1
3251 echo ll1.2=$x
3253 define ll0 {
3254 wysh set y=$1; shift; eval localopts $y; localopts $1; shift
3255 set x=0
3256 echo ll0.1=$x
3257 call ll1 $y "$@"
3258 echo ll0.2=$x
3260 define llx {
3261 echo ----- $1: $2 -> $3 -> $4
3262 echo ll-1.1=$x
3263 eval localopts $1
3264 call ll0 "$@"
3265 echo ll-1.2=$x
3266 unset x
3268 define lly {
3269 call llx 'call off' on on on
3270 call llx 'call off' off on on
3271 call llx 'call off' on off on
3272 call llx 'call off' on off off
3273 localopts call-fixate on
3274 call llx 'call-fixate on' on on on
3275 call llx 'call-fixate on' off on on
3276 call llx 'call-fixate on' on off on
3277 call llx 'call-fixate on' on off off
3278 unset x;localopts call on
3279 call llx 'call on' on on on
3280 call llx 'call on' off on on
3281 call llx 'call on' on off on
3282 call llx 'call on' on off off
3284 call lly
3285 __EOT
3287 check 1 0 "${MBOX}" '4016155249 1246'
3289 t_epilog "${@}"
3292 t_local() {
3293 t_prolog "${@}"
3295 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
3296 define du2 {
3297 echo du2-1 du=$du
3298 local set du=$1
3299 echo du2-2 du=$du
3300 local unset du
3301 echo du2-3 du=$du
3303 define du {
3304 local set du=dudu
3305 echo du-1 du=$du
3306 call du2 du2du2
3307 echo du-2 du=$du
3308 local set nodu
3309 echo du-3 du=$du
3311 define ich {
3312 echo ich-1 du=$du
3313 call du
3314 echo ich-2 du=$du
3316 define wir {
3317 localopts $1
3318 set du=wirwir
3319 echo wir-1 du=$du
3320 call ich
3321 echo wir-2 du=$du
3323 echo ------- global-1 du=$du
3324 call ich
3325 echo ------- global-2 du=$du
3326 set du=global
3327 call ich
3328 echo ------- global-3 du=$du
3329 call wir on
3330 echo ------- global-4 du=$du
3331 call wir off
3332 echo ------- global-5 du=$du
3333 __EOT
3334 check 1 0 "${MBOX}" '2411598140 641'
3337 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
3338 define z {
3339 echo z-1: x=$x y=$y z=$z crt=$crt
3340 local set z=1 y=2 crt=10
3341 echo z-2: x=$x y=$y z=$z crt=$crt
3343 define y {
3344 echo y-1: x=$x y=$y z=$z crt=$crt
3345 local set x=2 y=1 crt=5
3346 echo y-2: x=$x y=$y z=$z crt=$crt
3347 call z
3348 echo y-3: x=$x y=$y z=$z crt=$crt
3350 define x {
3351 echo x-1: x=$x y=$y z=$z crt=$crt
3352 local set x=1 crt=1
3353 echo x-2: x=$x y=$y z=$z crt=$crt
3354 call y
3355 echo x-3: x=$x y=$y z=$z crt=$crt
3357 set crt
3358 echo global-1: x=$x y=$y z=$z crt=$crt
3359 call x
3360 echo global-2: x=$x y=$y z=$z crt=$crt
3361 __EOT
3362 check 2 0 "${MBOX}" '2560788669 216'
3364 t_epilog "${@}"
3367 t_environ() {
3368 t_prolog "${@}"
3370 ${cat} <<- '__EOT' | EK1=EV1 EK2=EV2 ${MAILX} ${ARGS} > "${MBOX}" 2>&1
3371 echo "we: EK1<$EK1> EK2<$EK2> EK3<$EK3> EK4<$EK4> NEK5<$NEK5>"
3372 !echo "shell: EK1<$EK1> EK2<$EK2> EK3<$EK3> EK4<$EK4> NEK5<$NEK5>"
3373 varshow EK1 EK2 EK3 EK4 NEK5
3375 echo environ set EK3 EK4, set NEK5
3376 environ set EK3=EV3 EK4=EV4
3377 set NEK5=NEV5
3378 echo "we: EK1<$EK1> EK2<$EK2> EK3<$EK3> EK4<$EK4> NEK5<$NEK5>"
3379 !echo "shell: EK1<$EK1> EK2<$EK2> EK3<$EK3> EK4<$EK4> NEK5<$NEK5>"
3380 varshow EK1 EK2 EK3 EK4 NEK5
3382 echo removing NEK5 EK3
3383 unset NEK5
3384 environ unset EK3
3385 echo "we: EK1<$EK1> EK2<$EK2> EK3<$EK3> EK4<$EK4> NEK5<$NEK5>"
3386 !echo "shell: EK1<$EK1> EK2<$EK2> EK3<$EK3> EK4<$EK4> NEK5<$NEK5>"
3387 varshow EK1 EK2 EK3 EK4 NEK5
3389 echo changing EK1, EK4
3390 set EK1=EV1_CHANGED EK4=EV4_CHANGED
3391 echo "we: EK1<$EK1> EK2<$EK2> EK3<$EK3> EK4<$EK4> NEK5<$NEK5>"
3392 !echo "shell: EK1<$EK1> EK2<$EK2> EK3<$EK3> EK4<$EK4> NEK5<$NEK5>"
3393 varshow EK1 EK2 EK3 EK4 NEK5
3395 echo linking EK4, rechanging EK1, EK4
3396 environ link EK4
3397 set EK1=EV1 EK4=EV4
3398 echo "we: EK1<$EK1> EK2<$EK2> EK3<$EK3> EK4<$EK4> NEK5<$NEK5>"
3399 !echo "shell: EK1<$EK1> EK2<$EK2> EK3<$EK3> EK4<$EK4> NEK5<$NEK5>"
3400 varshow EK1 EK2 EK3 EK4 NEK5
3402 echo unset all
3403 unset EK1 EK2 EK4
3404 echo "we: EK1<$EK1> EK2<$EK2> EK3<$EK3> EK4<$EK4> NEK5<$NEK5>"
3405 !echo "shell: EK1<$EK1> EK2<$EK2> EK3<$EK3> EK4<$EK4> NEK5<$NEK5>"
3406 varshow EK1 EK2 EK3 EK4 NEK5
3407 __EOT
3409 check 1 0 "${MBOX}" '1685686686 1342'
3411 t_epilog "${@}"
3412 return
3415 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
3416 define l4 {
3417 echo '-------> L4 (environ unlink EK1, own localopts)'
3418 localopts yes
3419 environ unlink EK1
3420 set LK1=LK1_L4 EK1=EK1_L4
3421 echo "we: L4: LK1<$LK1> EK1<$EK1>"
3422 !echo "shell: L4: LK1<$LK1> EK1<$EK1>"
3423 varshow LK1 EK1
3424 echo '-------< L4'
3426 define l3 {
3427 echo '-------> L3'
3428 set LK1=LK1_L3 EK1=EK1_L3
3429 echo "we: L3-pre: LK1<$LK1> EK1<$EK1>"
3430 !echo "shell: L3-pre: LK1<$LK1> EK1<$EK1>"
3431 varshow LK1 EK1
3432 call l4
3433 echo "we: L3-post: LK1<$LK1> EK1<$EK1>"
3434 !echo "shell: L3-post: LK1<$LK1> EK1<$EK1>"
3435 varshow LK1 EK1
3436 echo '-------< L3'
3438 define l2 {
3439 echo '-------> L2'
3440 set LK1=LK1_L2 EK1=EK1_L2
3441 echo "we: L2-pre: LK1<$LK1> EK1<$EK1>"
3442 !echo "shell: L2-pre: LK1<$LK1> EK1<$EK1>"
3443 varshow LK1 EK1
3444 call l3
3445 echo "we: L2-post: LK1<$LK1> EK1<$EK1>"
3446 !echo "shell: L2-post: LK1<$LK1> EK1<$EK1>"
3447 varshow LK1 EK1
3448 echo '-------< L2'
3450 define l1 {
3451 echo '-------> L1 (environ link EK1; localopts call-fixate)'
3452 localopts call-fixate yes
3453 set LK1=LK1_L1 EK1=EK1_L1
3454 environ link EK1
3455 echo "we: L1-pre: LK1<$LK1> EK1<$EK1>"
3456 !echo "shell: L1-pre: LK1<$LK1> EK1<$EK1>"
3457 varshow LK1 EK1
3458 call l2
3459 echo "we: L1-post: LK1<$LK1> EK1<$EK1>"
3460 !echo "shell: L1-post: LK1<$LK1> EK1<$EK1>"
3461 varshow LK1 EK1
3462 echo '-------< L1'
3464 echo "we: outer-pre: LK1<$LK1> EK1<$EK1>"
3465 !echo "shell: outer-pre: LK1<$LK1> EK1<$EK1>"
3466 varshow LK1 EK1
3467 call l1
3468 echo "we: outer-post: LK1<$LK1> EK1<$EK1>"
3469 !echo "shell: outer-post: LK1<$LK1> EK1<$EK1>"
3470 varshow LK1 EK1
3471 __EOT
3473 check 2 0 "${MBOX}" '1903030743 1131'
3475 t_epilog "${@}"
3478 t_macro_param_shift() {
3479 t_prolog "${@}"
3481 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>>${ERR}
3482 define t2 {
3483 echo in: t2
3484 echo t2.0 has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
3485 localopts on
3486 wysh set ignerr=$1
3487 shift
3488 localopts off
3489 echo t2.1 has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
3490 if [ $# > 1 ] || [ $ignerr == '' ]
3491 shift 2
3492 else
3493 ignerr shift 2
3494 endif
3495 echo t2.2:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
3496 shift 0
3497 echo t2.3:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
3498 if [ $# > 0 ]
3499 shift
3500 endif
3501 echo t2.4:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
3503 define t1 {
3504 set errexit
3505 echo in: t1
3506 call t2 1 you get four args
3507 echo t1.1: $?';' ignerr ($ignerr) should not exist
3508 call t2 1 you get 'three args'
3509 echo t1.2: $?';' ignerr ($ignerr) should not exist
3510 call t2 1 you 'get two args'
3511 echo t1.3: $?';' ignerr ($ignerr) should not exist
3512 call t2 1 'you get one arg'
3513 echo t1.4: $?';' ignerr ($ignerr) should not exist
3514 ignerr call t2 '' 'you get one arg'
3515 echo t1.5: $?';' ignerr ($ignerr) should not exist
3517 call t1
3518 __EOT
3520 check 1 0 "${MBOX}" '1402489146 1682'
3522 t_epilog "${@}"
3525 t_addrcodec() {
3526 t_prolog "${@}"
3528 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
3529 commandalias x echo '$?/$^ERRNAME $res'
3530 vput addrcodec res e 1 <doog@def>
3532 eval vput addrcodec res d $res
3534 vput addrcodec res e 2 . <doog@def>
3536 eval vput addrcodec res d $res
3538 vput addrcodec res e 3 Sauer Dr. <doog@def>
3540 eval vput addrcodec res d $res
3542 vput addrcodec res e 3.50 Sauer (Ma) Dr. <doog@def>
3544 eval vput addrcodec res d $res
3546 vput addrcodec res e 3.51 Sauer (Ma) "Dr." <doog@def>
3548 eval vput addrcodec res d $res
3551 vput addrcodec res +e 4 Sauer (Ma) Dr. <doog@def>
3553 eval vput addrcodec res d $res
3555 vput addrcodec res +e 5 Sauer (Ma) Braten Dr. <doog@def>
3557 eval vput addrcodec res d $res
3559 vput addrcodec res +e 6 Sauer (Ma) Braten Dr. (Heu) <doog@def>
3561 eval vput addrcodec res d $res
3563 vput addrcodec res +e 7 Sauer (Ma) Braten Dr. (Heu) <doog@def> (bu)
3565 eval vput addrcodec res d $res
3567 vput addrcodec res +e 8 \
3568 Dr. Sauer (Ma) Braten Dr. (Heu) <doog@def> (bu) Boom. Boom
3570 eval vput addrcodec res d $res
3572 vput addrcodec res +e 9 Dr.Sauer(Ma)Braten Dr. (Heu) <doog@def>
3574 eval vput addrcodec res d $res
3576 vput addrcodec res +e 10 (Ma)Braten Dr. (Heu) <doog@def>
3578 eval vput addrcodec res d $res
3580 vput addrcodec res +e 11 (Ma)Braten Dr"." (Heu) <doog@def>
3582 eval vput addrcodec res d $res
3584 vput addrcodec res +e 12 Dr. Sauer (Ma) Braten Dr. (u) <doog@def>
3586 eval vput addrcodec res d $res
3588 vput addrcodec res +e 13(Ma)Braten Dr. (Heu) <doog@def>
3590 eval vput addrcodec res d $res
3592 vput addrcodec res +e 14 Hey, Du <doog@def> Wie() findet Dr. das? ()
3594 eval vput addrcodec res d $res
3596 vput addrcodec res +e 15 \
3597 Hey, Du <doog@def> Wie() findet "" Dr. "" das? ()
3599 eval vput addrcodec res d $res
3601 vput addrcodec res +e 16 \
3602 "Hey," "Du" <doog@def> "Wie()" findet "" Dr. "" das? ()
3604 eval vput addrcodec res d $res
3606 vput addrcodec res +e 17 \
3607 "Hey" Du <doog@def> "Wie() findet " " Dr. """ das? ()
3609 eval vput addrcodec res d $res
3611 vput addrcodec res +e 18 \
3612 <doog@def> "Hey" Du "Wie() findet " " Dr. """ das? ()
3614 eval vput addrcodec res d $res
3616 vput addrcodec res +e 19 Hey\,\" <doog@def> "Wie()" findet \" Dr. \" das?
3618 eval vput addrcodec res d $res
3621 vput addrcodec res ++e 20 Hey\,\" <doog@def> "Wie()" findet \" Dr. \" das?
3623 vput addrcodec res ++e 21 Hey\,\"" <doog@def> "Wie()" findet \" Dr. \" das?
3625 eval vput addrcodec res d $res
3628 vput addrcodec res \
3629 +++e 22 Hey\\,\" <doog@def> "Wie()" findet \" Dr. \" das?
3631 eval vput addrcodec res d $res
3634 vput addrcodec res s \
3635 "23 Hey\\,\\\" \"Wie" () "\" findet \\\" Dr. \\\" das?" <doog@def>
3638 # Fix for [f3852f88]
3639 vput addrcodec res ++e <from2@exam.ple> 100 (comment) "Quot(e)d"
3641 eval vput addrcodec res d $res
3643 vput addrcodec res e <from2@exam.ple> 100 (comment) "Quot(e)d"
3645 eval vput addrcodec res d $res
3647 __EOT
3649 check 1 0 "${MBOX}" '1047317989 2612'
3651 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
3652 commandalias x echo '$?/$^ERRNAME $res'
3653 mlist isa1@list
3654 mlsubscribe isa2@list
3656 vput addrcodec res skin Hey\\,\" <isa0@list> "Wie()" find \" Dr. \" das?
3658 vput addrcodec res skinlist Hey\\,\" <isa0@list> "Wie()" find \" Dr. \" das?
3660 vput addrcodec res skin Hey\\,\" <isa1@list> "Wie()" find \" Dr. \" das?
3662 vput addrcodec res skinlist Hey\\,\" <isa1@list> "Wie()" find \" Dr. \" das?
3664 vput addrcodec res skin Hey\\,\" <isa2@list> "Wie()" find \" Dr. \" das?
3666 vput addrcodec res skinlist Hey\\,\" <isa2@list> "Wie()" find \" Dr. \" das?
3668 __EOT
3670 check 2 0 "${MBOX}" '1391779299 104'
3672 if have_feat idna; then
3673 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} ${ADDARG_UNI} > "${MBOX}" 2>&1
3674 commandalias x echo '$?/$^ERRNAME $res'
3675 vput addrcodec res e (heu) <du@blödiän> "stroh" du
3677 eval vput addrcodec res d $res
3679 vput addrcodec res e <du@blödiän> du
3681 eval vput addrcodec res d $res
3683 vput addrcodec res e du <du@blödiän>
3685 eval vput addrcodec res d $res
3687 vput addrcodec res e <du@blödiän>
3689 eval vput addrcodec res d $res
3691 vput addrcodec res e du@blödiän
3693 eval vput addrcodec res d $res
3695 __EOT
3697 check idna 0 "${MBOX}" '498775983 326'
3698 else
3699 t_echoskip 'idna:[!IDNA]'
3702 t_epilog "${@}"
3705 t_csop() {
3706 t_prolog "${@}"
3708 if have_feat cmd-csop; then :; else
3709 t_echoskip '[!CMD_CSOP]'
3710 t_epilog "${@}"
3711 return
3714 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
3715 commandalias x echo '$?/$^ERRNAME :$res:'
3716 echo ' #-2'
3717 vput csop res find you y;x
3718 vput csop res find you o;x
3719 vput csop res find you u;x
3720 vput csop res find you yo;x
3721 vput csop res find you ou;x
3722 vput csop res find you you;x
3723 echo ' #-1'
3724 vput csop res find you Y;x
3725 vput csop res find? you Y;x
3726 vput csop res find?case you O;x
3727 vput csop res find? you U;x
3728 vput csop res find?ca you yO;x
3729 vput csop res find? you oU;x
3730 vput csop res find? you YoU;x
3731 echo ' #0'
3732 vput csop res find 'bananarama' 'nana';x
3733 vput csop res find 'bananarama' 'bana';x
3734 vput csop res find 'bananarama' 'Bana';x
3735 vput csop res find 'bananarama' 'rama';x
3736 echo ' #1'
3737 vput csop res find? 'bananarama' 'nana';x
3738 vput csop res find? 'bananarama' 'bana';x
3739 vput csop res find? 'bananarama' 'Bana';x
3740 vput csop res find? 'bananarama' 'rama';x
3741 echo ' #2'
3742 vput csop res substring 'bananarama' 1;x
3743 vput csop res substring 'bananarama' 3;x
3744 vput csop res substring 'bananarama' 5;x
3745 vput csop res substring 'bananarama' 7;x
3746 vput csop res substring 'bananarama' 9;x
3747 vput csop res substring 'bananarama' 10;x
3748 vput csop res substring 'bananarama' 1 3;x
3749 vput csop res substring 'bananarama' 3 3;x
3750 vput csop res substring 'bananarama' 5 3;x
3751 vput csop res substring 'bananarama' 7 3;x
3752 vput csop res substring 'bananarama' 9 3;x
3753 vput csop res substring 'bananarama' 10 3;x
3754 echo ' #3'
3755 vput csop res substring 'bananarama' -1;x
3756 vput csop res substring 'bananarama' -3;x
3757 vput csop res substring 'bananarama' -5;x
3758 vput csop res substring 'bananarama' -7;x
3759 vput csop res substring 'bananarama' -9;x
3760 vput csop res substring 'bananarama' -10;x
3761 vput csop res substring 'bananarama' 1 -3;x
3762 vput csop res substring 'bananarama' 3 -3;x
3763 vput csop res substring 'bananarama' 5 -3;x
3764 vput csop res substring 'bananarama' 7 -3;x
3765 vput csop res substring 'bananarama' 9 -3;x
3766 vput csop res substring 'bananarama' 10 -3;x
3767 echo ' #4'
3768 vput csop res trim 'Cocoon Cocoon';x
3769 vput csop res trim ' Cocoon Cocoon ';x
3770 vput csop res trim-front 'Cocoon Cocoon';x
3771 vput csop res trim-front ' Cocoon Cocoon ';x
3772 vput csop res trim-end 'Cocoon Cocoon';x
3773 vput csop res trim-end ' Cocoon Cocoon ';x
3774 __EOT
3776 check 1 0 "${MBOX}" '1892119538 755'
3778 t_epilog "${@}"
3781 t_vexpr() {
3782 t_prolog "${@}"
3784 if have_feat cmd-vexpr; then :; else
3785 t_echoskip '[!CMD_VEXPR]'
3786 t_epilog "${@}"
3787 return
3790 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>>${ERR}
3791 commandalias x echo '$?/$^ERRNAME $res'
3792 echo ' #0.0'
3793 vput vexpr res = 9223372036854775807;x
3794 vput vexpr res = 9223372036854775808;x
3795 vput vexpr res = u9223372036854775808;x
3796 vput vexpr res =? 9223372036854775808;x
3797 vput vexpr res = -9223372036854775808;x
3798 vput vexpr res = -9223372036854775809;x
3799 vput vexpr res =?saturated -9223372036854775809;x
3800 vput vexpr res = U9223372036854775809;x
3801 echo ' #0.1'
3802 vput vexpr res = \
3803 0b0111111111111111111111111111111111111111111111111111111111111111;x
3804 vput vexpr res = \
3805 S0b1000000000000000000000000000000000000000000000000000000000000000;x
3806 vput vexpr res =? \
3807 S0b1000000000000000000000000000000000000000000000000000000000000000;x
3808 vput vexpr res = \
3809 U0b1000000000000000000000000000000000000000000000000000000000000000;x
3810 vput vexpr res = \
3811 0b1000000000000000000000000000000000000000000000000000000000000000;x
3812 vput vexpr res =? \
3813 0b1000000000000000000000000000000000000000000000000000000000000000;x
3814 vput vexpr res = \
3815 -0b1000000000000000000000000000000000000000000000000000000000000000;x
3816 vput vexpr res = \
3817 S0b1000000000000000000000000000000000000000000000000000000000000001;x
3818 vput vexpr res =? \
3819 S0b1000000000000000000000000000000000000000000000000000000000000001;x
3820 vput vexpr res =? \
3821 -0b1000000000000000000000000000000000000000000000000000000000000001;x
3822 vput vexpr res = \
3823 U0b1000000000000000000000000000000000000000000000000000000000000001;x
3824 echo ' #0.2'
3825 vput vexpr res = 0777777777777777777777;x
3826 vput vexpr res = S01000000000000000000000;x
3827 vput vexpr res =? S01000000000000000000000;x
3828 vput vexpr res = U01000000000000000000000;x
3829 vput vexpr res = 01000000000000000000000;x
3830 vput vexpr res =?satur 01000000000000000000000;x
3831 vput vexpr res = -01000000000000000000000;x
3832 vput vexpr res = S01000000000000000000001;x
3833 vput vexpr res =?sat S01000000000000000000001;x
3834 vput vexpr res = -01000000000000000000001;x
3835 vput vexpr res = U01000000000000000000001;x
3836 echo ' #0.3'
3837 vput vexpr res = 0x7FFFFFFFFFFFFFFF;x
3838 vput vexpr res = S0x8000000000000000;x
3839 vput vexpr res =? S0x8000000000000000;x
3840 vput vexpr res = U0x8000000000000000;x
3841 vput vexpr res = 0x8000000000000000;x
3842 vput vexpr res =? 0x8000000000000000;x
3843 vput vexpr res = -0x8000000000000000;x
3844 vput vexpr res = S0x8000000000000001;x
3845 vput vexpr res =? S0x8000000000000001;x
3846 vput vexpr res = -0x8000000000000001;x
3847 vput vexpr res = u0x8000000000000001;x
3848 vput vexpr res = 9223372036854775809;x
3849 vput vexpr res =? 9223372036854775809;x
3850 vput vexpr res = u9223372036854775809;x
3851 echo ' #1'
3852 vput vexpr res ~ 0;x
3853 vput vexpr res ~ 1;x
3854 vput vexpr res ~ -1;x
3855 echo ' #1.1'
3856 vput vexpr res - 0;x
3857 vput vexpr res - 1;x
3858 vput vexpr res - -1;x
3859 vput vexpr res - -0xAFFE;x
3860 vput vexpr res - 0xAFFE;x
3861 vput vexpr res - u0x8000000000000001;x
3862 vput vexpr res - 0x8000000000000001;x
3863 vput vexpr res - 0x8000000000000001;x
3864 vput vexpr res - 9223372036854775809;x
3865 vput vexpr res -? 9223372036854775809;x
3866 echo ' #1.2'
3867 vput vexpr res + 0;x
3868 vput vexpr res + 1;x
3869 vput vexpr res + -1;x
3870 vput vexpr res + -0xAFFE;x
3871 vput vexpr res + 0xAFFE;x
3872 vput vexpr res + u0x8000000000000001;x
3873 vput vexpr res + 0x8000000000000001;x
3874 vput vexpr res + 9223372036854775809;x
3875 vput vexpr res +? 9223372036854775809;x
3876 echo ' #2'
3877 vput vexpr res + 0 0;x
3878 vput vexpr res + 0 1;x
3879 vput vexpr res + 1 1;x
3880 echo ' #3'
3881 vput vexpr res + 9223372036854775807 0;x
3882 vput vexpr res + 9223372036854775807 1;x
3883 vput vexpr res +? 9223372036854775807 1;x
3884 vput vexpr res + 0 9223372036854775807;x
3885 vput vexpr res + 1 9223372036854775807;x
3886 vput vexpr res +? 1 9223372036854775807;x
3887 echo ' #4'
3888 vput vexpr res + -9223372036854775808 0;x
3889 vput vexpr res + -9223372036854775808 -1;x
3890 vput vexpr res +? -9223372036854775808 -1;x
3891 vput vexpr res + 0 -9223372036854775808;x
3892 vput vexpr res + -1 -9223372036854775808;x
3893 vput vexpr res +? -1 -9223372036854775808;x
3894 echo ' #5'
3895 vput vexpr res - 0 0;x
3896 vput vexpr res - 0 1;x
3897 vput vexpr res - 1 1;x
3898 echo ' #6'
3899 vput vexpr res - 9223372036854775807 0;x
3900 vput vexpr res - 9223372036854775807 -1;x
3901 vput vexpr res -? 9223372036854775807 -1;x
3902 vput vexpr res - 0 9223372036854775807;x
3903 vput vexpr res - -1 9223372036854775807;x
3904 vput vexpr res - -2 9223372036854775807;x
3905 vput vexpr res -? -2 9223372036854775807;x
3906 echo ' #7'
3907 vput vexpr res - -9223372036854775808 +0;x
3908 vput vexpr res - -9223372036854775808 +1;x
3909 vput vexpr res -? -9223372036854775808 +1;x
3910 vput vexpr res - 0 -9223372036854775808;x
3911 vput vexpr res - +1 -9223372036854775808;x
3912 vput vexpr res -? +1 -9223372036854775808;x
3913 echo ' #8'
3914 vput vexpr res + -13 -2;x
3915 vput vexpr res - 0 0;x
3916 vput vexpr res - 0 1;x
3917 vput vexpr res - 1 1;x
3918 vput vexpr res - -13 -2;x
3919 echo ' #9'
3920 vput vexpr res * 0 0;x
3921 vput vexpr res * 0 1;x
3922 vput vexpr res * 1 1;x
3923 vput vexpr res * -13 -2;x
3924 echo ' #10'
3925 vput vexpr res / 0 0;x
3926 vput vexpr res / 0 1;x
3927 vput vexpr res / 1 1;x
3928 vput vexpr res / -13 -2;x
3929 echo ' #11'
3930 vput vexpr res % 0 0;x
3931 vput vexpr res % 0 1;x
3932 vput vexpr res % 1 1;x
3933 vput vexpr res % -13 -2;x
3934 echo ' #12'
3935 vput vexpr res pbase 10 u0x8000000000000001;x
3936 vput vexpr res pbase 16 0x8000000000000001;x
3937 vput vexpr res pbase 16 s0x8000000000000001;x
3938 vput vexpr res pbase 16 u0x8000000000000001;x
3939 vput vexpr res pbase 36 0x8000000000000001;x
3940 vput vexpr res pbase 36 u0x8000000000000001;x
3941 __EOT
3943 check numeric 0 "${MBOX}" '163128733 2519'
3945 if have_feat regex; then
3946 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
3947 commandalias x echo '$?/$^ERRNAME :$res:'
3948 echo ' #-2'
3949 vput vexpr res regex you y;x
3950 vput vexpr res regex you o;x
3951 vput vexpr res regex you u;x
3952 vput vexpr res regex you yo;x
3953 vput vexpr res regex you ou;x
3954 vput vexpr res regex you you;x
3955 echo ' #-1'
3956 vput vexpr res regex you Y;x
3957 vput vexpr res regex? you Y;x
3958 vput vexpr res regex? you O;x
3959 vput vexpr res regex? you U;x
3960 vput vexpr res regex? you yO;x
3961 vput vexpr res regex? you oU;x
3962 vput vexpr res regex? you YoU;x
3963 echo ' #0'
3964 vput vexpr res regex 'bananarama' 'nana';x
3965 vput vexpr res regex 'bananarama' 'bana';x
3966 vput vexpr res regex 'bananarama' 'Bana';x
3967 vput vexpr res regex 'bananarama' 'rama';x
3968 echo ' #1'
3969 vput vexpr res regex? 'bananarama' 'nana';x
3970 vput vexpr res regex? 'bananarama' 'bana';x
3971 vput vexpr res regex? 'bananarama' 'Bana';x
3972 vput vexpr res regex? 'bananarama' 'rama';x
3973 echo ' #2'
3974 vput vexpr res regex 'bananarama' '(.*)nana(.*)' '\${1}a\${0}u{\$2}';x
3975 vput vexpr res regex 'bananarama' '(.*)bana(.*)' '\${1}a\${0}u\$2';x
3976 vput vexpr res regex 'bananarama' 'Bana(.+)' '\$1\$0';x
3977 vput vexpr res regex 'bananarama' '(.+)rama' '\$1\$0';x
3978 echo ' #3'
3979 vput vexpr res regex? 'bananarama' '(.*)nana(.*)' '\${1}a\${0}u{\$2}';x
3980 vput vexpr res regex? 'bananarama' '(.*)bana(.*)' '\${1}a\${0}u\$2';x
3981 vput vexpr res regex? 'bananarama' 'Bana(.+)' '\$1\$0';x
3982 vput vexpr res regex? 'bananarama' '(.+)rama' '\$1\$0';x
3983 echo ' #4'
3984 vput vexpr res regex 'banana' '(club )?(.*)(nana)(.*)' \
3985 '\$1\${2}\$4\${3}rama';x
3986 vput vexpr res regex 'Banana' '(club )?(.*)(nana)(.*)' \
3987 '\$1\$2\${2}\$2\$4\${3}rama';x
3988 vput vexpr res regex 'Club banana' '(club )?(.*)(nana)(.*)' \
3989 '\$1\${2}\$4\${3}rama';x
3990 echo ' #5'
3991 __EOT
3993 check regex 0 "${MBOX}" '2831099111 542'
3994 else
3995 t_echoskip 'regex:[!REGEX]'
3998 t_epilog "${@}"
4001 t_call_ret() {
4002 t_prolog "${@}"
4004 if have_feat cmd-vexpr; then :; else
4005 t_echoskip '[!CMD_VEXPR]'
4006 t_epilog "${@}"
4007 return
4010 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Snomemdebug > "${MBOX}" 2>&1
4011 define w1 {
4012 echon ">$1 "
4013 vput vexpr i + $1 1
4014 if [ $i -le 42 ]
4015 vput vexpr j '&' $i 7
4016 if [ $j -eq 7 ]
4017 echo .
4019 call w1 $i
4020 wysh set i=$? k=$!
4021 vput vexpr j '&' $i 7
4022 echon "<$1/$i/$k "
4023 if [ $j -eq 7 ]
4024 echo .
4026 else
4027 echo ! The end for $1
4029 return $1
4031 # Transport $?/$! up the call chain
4032 define w2 {
4033 echon ">$1 "
4034 vput vexpr i + $1 1
4035 if [ $1 -lt 42 ]
4036 call w2 $i
4037 wysh set i=$? j=$! k=$^ERRNAME
4038 echon "<$1/$i/$k "
4039 return $i $j
4040 else
4041 echo ! The end for $1
4042 return $i $^ERR-BUSY
4044 echoerr au
4046 # Up and down it goes
4047 define w3 {
4048 echon ">$1/$2 "
4049 vput vexpr i + $1 1
4050 if [ $1 -lt 42 ]
4051 call w3 $i $2
4052 wysh set i=$? j=$!
4053 vput vexpr k - $1 $2
4054 if [ $k -eq 21 ]
4055 vput vexpr i + $1 1
4056 vput vexpr j + $2 1
4057 echo "# <$i/$j> .. "
4058 call w3 $i $j
4059 wysh set i=$? j=$!
4061 eval echon "<\$1=\$i/\$^ERRNAME-$j "
4062 return $i $j
4063 else
4064 echo ! The end for $1=$i/$2
4065 if [ "$2" != "" ]
4066 return $i $^ERR-DOM
4067 else
4068 return $i $^ERR-BUSY
4071 echoerr au
4074 call w1 0; echo ?=$? !=$!; echo -----;
4075 call w2 0; echo ?=$? !=$^ERRNAME; echo -----;
4076 call w3 0 1; echo ?=$? !=$^ERRNAME; echo -----;
4077 __EOT
4079 check 1 0 "${MBOX}" '1572045517 5922'
4081 t_epilog "${@}"
4084 t_xcall() {
4085 t_prolog "${@}"
4087 if have_feat cmd-vexpr; then :; else
4088 t_echoskip '[!CMD_VEXPR]'
4089 t_epilog "${@}"
4090 return
4093 ${cat} <<- '__EOT' | \
4094 ${MAILX} ${ARGS} -Snomemdebug \
4095 -Smax=${LOOPS_MAX} \
4096 > "${MBOX}" 2>&1
4097 define work {
4098 echon "$1 "
4099 vput vexpr i + $1 1
4100 if [ $i -le "$max" ]
4101 vput vexpr j '&' $i 7
4102 if [ $j -eq 7 ]
4103 echo .
4105 \xcall work $i $2
4107 echo ! The end for $1/$2
4108 if [ "$2" != "" ]
4109 return $i $^ERR-BUSY
4112 define xwork {
4113 \xcall work 0 $2
4115 call work 0
4116 echo ?=$? !=$!
4117 call xwork
4118 echo ?=$? !=$!
4119 xcall xwork
4120 echo ?=$? !=$^ERRNAME
4122 call work 0 yes
4123 echo ?=$? !=$^ERRNAME
4124 call xwork 0 yes
4125 echo ?=$? !=$^ERRNAME
4126 __EOT
4128 i=${?}
4129 if [ ${LOOPS_MAX} -eq ${LOOPS_BIG} ]; then
4130 check_ex0 1-${LOOPS_BIG} ${i}
4131 check 1-${LOOPS_BIG} - "${MBOX}" '1069764187 47161'
4132 else
4133 check_ex0 1-${LOOPS_SMALL} ${i}
4134 check 1-${LOOPS_SMALL} - "${MBOX}" '859201011 3894'
4139 if have_feat uistrings; then
4140 ${cat} <<- '__EOT' > "${BODY}"
4141 define __w {
4142 echon "$1 "
4143 vput vexpr i + $1 1
4144 if [ $i -le 111 ]
4145 vput vexpr j '&' $i 7
4146 if [ $j -eq 7 ]
4147 echo .
4149 \xcall __w $i $2
4151 echo ! The end for $1
4152 if [ $2 -eq 0 ]
4153 nonexistingcommand
4154 echo would be err with errexit
4155 return
4157 echo calling exit
4158 exit
4160 define work {
4161 echo eins
4162 call __w 0 0
4163 echo zwei, ?=$? !=$!
4164 localopts yes; set errexit
4165 ignerr call __w 0 0
4166 echo drei, ?=$? !=$^ERRNAME
4167 call __w 0 $1
4168 echo vier, ?=$? !=$^ERRNAME, this is an error
4170 ignerr call work 0
4171 echo outer 1, ?=$? !=$^ERRNAME
4172 xxxign call work 0
4173 echo outer 2, ?=$? !=$^ERRNAME, could be error if xxxign non-empty
4174 call work 1
4175 echo outer 3, ?=$? !=$^ERRNAME
4176 echo this is definitely an error
4177 __EOT
4179 < "${BODY}" ${MAILX} ${ARGS} -X'commandalias xxxign ignerr' \
4180 -Snomemdebug > "${MBOX}" 2>&1
4181 check 2 0 "${MBOX}" '4036613316 4184'
4183 < "${BODY}" ${MAILX} ${ARGS} -X'commandalias xxxign " "' \
4184 -Snomemdebug > "${MBOX}" 2>&1
4185 check 3 1 "${MBOX}" '3179757785 2787'
4186 else
4187 t_echoskip '2-3:[!UISTRINGS]'
4190 t_epilog "${@}"
4193 t_vpospar() {
4194 t_prolog "${@}"
4196 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
4197 vpospar set hey, "'you ", world!
4198 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4199 vput vpospar x quote; echo x<$x>
4200 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4201 vput vpospar y quote;echo y<$y>
4202 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4203 eval vpospar set ${y};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4204 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4206 define infun2 {
4207 echo infun2:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
4208 vput vpospar z quote;echo infun2:z<$z>
4211 define infun {
4212 echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
4213 vput vpospar y quote;echo infun:y<$y>
4214 eval vpospar set ${x};echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
4215 vpospar clear;echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
4216 eval call infun2 $x
4217 echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
4218 eval vpospar set ${y};echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
4221 call infun This "in a" fun
4222 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4223 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4224 __EOT
4225 check 1 0 "${MBOX}" '155175639 866'
4228 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
4229 set ifs=\'
4230 echo ifs<$ifs> ifs-ws<$ifs-ws>
4231 vpospar set hey, "'you ", world!
4232 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4233 vput vpospar x quote; echo x<$x>
4234 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4235 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4237 set ifs=,
4238 echo ifs<$ifs> ifs-ws<$ifs-ws>
4239 vpospar set hey, "'you ", world!
4240 unset ifs;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4241 set ifs=,
4242 vput vpospar x quote; echo x<$x>
4243 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4244 eval vpospar set ${x};\
4245 unset ifs;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4247 wysh set ifs=$',\t'
4248 echo ifs<$ifs> ifs-ws<$ifs-ws>
4249 vpospar set hey, "'you ", world!
4250 unset ifs; echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4251 wysh set ifs=$',\t'
4252 vput vpospar x quote; echo x<$x>
4253 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4254 eval vpospar set ${x};\
4255 unset ifs;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
4256 __EOT
4257 check ifs 0 "${MBOX}" '2015927702 706'
4259 t_epilog "${@}"
4262 t_atxplode() {
4263 t_prolog "${@}"
4265 ${cat} > ./.t.sh <<- '___'; ${cat} > ./.t.rc <<- '___'
4266 x() { echo $#; }
4267 xxx() {
4268 printf " (1/$#: <$1>)"
4269 shift
4270 if [ $# -gt 0 ]; then
4271 xxx "$@"
4272 else
4273 echo
4276 yyy() {
4277 eval "$@ ' ball"
4279 set --
4280 x "$@"
4281 x "$@"''
4282 x " $@"
4283 x "$@ "
4284 printf yyy;yyy 'xxx' "b\$'\t'u ' "
4285 printf xxx;xxx arg ,b u.
4286 printf xxx;xxx arg , .
4287 printf xxx;xxx arg ,ball.
4289 define x {
4290 echo $#
4292 define xxx {
4293 echon " (1/$#: <$1>)"
4294 shift
4295 if [ $# -gt 0 ]
4296 \xcall xxx "$@"
4297 endif
4298 echo
4300 define yyy {
4301 eval "$@ ' ball"
4303 vpospar set
4304 call x "$@"
4305 call x "$@"''
4306 call x " $@"
4307 call x "$@ "
4308 echon yyy;call yyy '\call xxx' "b\$'\t'u ' "
4309 echon xxx;call xxx arg ,b u.
4310 echon xxx;call xxx arg , .
4311 echon xxx;call xxx arg ,ball.
4314 ${MAILX} ${ARGS} -X'source ./.t.rc' -Xx > "${MBOX}" 2>&1
4315 check 1 0 "${MBOX}" '41566293 164'
4317 #${SHELL} ./.t.sh > ./.tshout 2>&1
4318 #check disproof-1 0 ./.tshout '41566293 164'
4320 t_epilog "${@}"
4323 t_read() {
4324 t_prolog "${@}"
4326 ${cat} <<- '__EOT' > .tin
4327 hey1, "'you ", world!
4328 hey2, "'you ", bugs bunny!
4329 hey3, "'you ",
4330 hey4, "'you "
4331 __EOT
4333 ${cat} <<- '__EOT' |\
4334 ${MAILX} ${ARGS} -X'readctl create ./.tin' > "${MBOX}" 2>&1
4335 commandalias x echo '$?/$^ERRNAME / <$a><$b><$c>'
4336 read a b c;x
4337 read a b c;x
4338 read a b c;x
4339 read a b c;x
4340 unset a b c;read a b c;x
4341 readctl remove ./.tin;echo readctl remove:$?/$^ERRNAME
4342 __EOT
4343 check 1 0 "${MBOX}" '1527910147 173'
4345 ${cat} <<- '__EOT' > .tin2
4346 hey2.0,:"'you ",:world!:mars.:
4347 hey2.1,:"'you ",:world!
4348 hey2.2,:"'you ",:bugs bunny!
4349 hey2.3,:"'you ",:
4350 hey2.4,:"'you ":
4352 __EOT
4354 ${cat} <<- '__EOT' |\
4355 6< .tin2 ${MAILX} ${ARGS} -X 'readctl create 6' > "${MBOX}" 2>&1
4356 commandalias x echo '$?/$^ERRNAME / <$a><$b><$c>'
4357 set ifs=:
4358 read a b c;x
4359 read a b c;x
4360 read a b c;x
4361 read a b c;x
4362 read a b c;x
4363 read a b c;x
4364 unset a b c;read a b c;x
4365 read a b c;x
4366 readctl remove 6;echo readctl remove:$?/$^ERRNAME
4367 __EOT
4368 check ifs 0 "${MBOX}" '890153490 298'
4370 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
4371 commandalias x echo '$?/$^ERRNAME / <$d>'
4372 readctl create .tin
4373 readall d;x
4374 wysh set d;readall d;x
4375 readctl create .tin2
4376 readall d;x
4377 wysh set d;readall d;x
4378 readctl remove .tin;echo $?/$^ERRNAME;\
4379 readctl remove .tin2;echo $?/$^ERRNAME
4380 echo '### now with empty lines'
4381 ! printf 'one line\n\ntwo line\n\n' > ./.temptynl
4382 readctl create .temptynl;echo $?/$^ERRNAME
4383 readall d;x
4384 readctl remove .temptynl;echo $?/$^ERRNAME
4385 __EOT
4386 check readall 0 "${MBOX}" '4113506527 405'
4388 t_epilog "${@}"
4391 t_readsh() { # TODO not enough
4392 t_prolog "${@}"
4394 ${cat} <<- '__EOT' > .tin
4395 from@exam.ple ' diet spliced <from@exam.ple> ' 'a'
4396 from@exam.ple ' diet spliced <from@exam.ple> ' 'a'
4397 from@exam.ple ' diet spliced <from@exam.ple> ''a'
4398 from@exam.ple' diet spliced <from@exam.ple> ''a'
4399 __EOT
4401 ${cat} <<- '__EOT' |\
4402 ${MAILX} ${ARGS} -X'readctl create ./.tin' > "${MBOX}" 2>&1
4403 commandalias x echo '$?/$^ERRNAME / <$a><$b><$c>'
4404 readsh a b c;x
4405 readsh a b c;x
4406 readsh a b c;x
4407 readsh a b c;x
4408 unset a b c;read a b c;x
4409 readctl remove ./.tin;echo readctl remove:$?/$^ERRNAME
4410 __EOT
4411 check 1 0 "${MBOX}" '2955084684 291'
4413 t_epilog "${@}"
4416 t_headerpick() {
4417 t_prolog "${@}"
4419 t__x1_msg > ./.tmbox
4422 </dev/null ${MAILX} ${ARGS} -Rf -Y '# Do not care much on error UISTRINGS
4423 \echo --- 1
4424 \headerpick
4425 \echo --- $?/$^ERRNAME, 2
4426 \type
4427 \echo --- $?/$^ERRNAME, 3
4428 \if "$features" !% +uistrings,
4429 \echoerr reproducible_build: Invalid field name cannot be ignored: ba:l
4430 \endif
4431 \headerpick type ignore \
4432 from_ mail-followup-to in-reply-to DATE MESSAGE-ID STATUS ba:l
4433 \echo --- $?/$^ERRNAME, 4
4434 \if "$features" !% +uistrings,
4435 \echo "#headerpick type retain currently covers no fields"
4436 \endif
4437 \headerpick
4438 \echo --- $?/$^ERRNAME, 5
4439 \type
4440 \echo --- $?/$^ERRNAME, 6
4441 \unheaderpick type ignore from_ DATE STATUS
4442 \echo --- $?/$^ERRNAME, 7
4443 \if "$features" !% +uistrings,
4444 \echo "#headerpick type retain currently covers no fields"
4445 \endif
4446 \headerpick
4447 \echo --- $?/$^ERRNAME, 8
4448 \type
4449 \echo --- $?/$^ERRNAME, 9
4450 \if "$features" =% +uistrings,
4451 \unheaderpick type ignore from_ ba:l
4452 \wysh set x=$? y=$^ERRNAME
4453 \else
4454 \echoerr reproducible_build: Field not ignored: from_
4455 \echoerr reproducible_build: Field not ignored: ba:l
4456 \set x=1 y=INVAL
4457 \endif
4458 \echo --- $x/$y, 10
4459 \unheaderpick type ignore *
4460 \echo --- $?/$^ERRNAME, 11
4461 \if "$features" !% +uistrings,
4462 \echo "#headerpick type retain currently covers no fields"
4463 \echo "#headerpick type ignore currently covers no fields"
4464 \endif
4465 \headerpick
4466 \echo --- $?/$^ERRNAME, 12
4467 \type
4468 \echo --- $?/$^ERRNAME, 13 ---
4469 # ' ./.tmbox >./.tall 2>&1
4470 check 1 0 ./.tall '2481904228 2273'
4473 if have_feat uistrings; then
4474 have_feat regex && i='3515512395 2378' || i='4201290332 2378'
4475 </dev/null ${MAILX} ${ARGS} -Y '#
4476 \headerpick type retain \
4477 bcc cc date from sender subject to \
4478 message-id mail-followup-to reply-to user-agent
4479 \echo --- $?/$^ERRNAME, 1
4480 \headerpick forward retain \
4481 cc date from message-id list-id sender subject to \
4482 mail-followup-to reply-to
4483 \echo --- $?/$^ERRNAME, 2
4484 \headerpick save ignore ^Original-.*$ ^X-.*$ ^DKIM.*$
4485 \echo --- $?/$^ERRNAME, 3
4486 \headerpick top retain To Cc
4487 \echo --- $?/$^ERRNAME, 4 ---
4488 \headerpick
4489 \echo --- $?/$^ERRNAME, 5
4490 \headerpick type
4491 \echo --- $?/$^ERRNAME, 6
4492 \headerpick forward
4493 \echo --- $?/$^ERRNAME, 7
4494 \headerpick save
4495 \echo --- $?/$^ERRNAME, 8
4496 \headerpick top
4497 \echo --- $?/$^ERRNAME, 9 ---
4498 \unheaderpick type retain message-id mail-followup-to reply-to user-agent
4499 \echo --- $?/$^ERRNAME, 10
4500 \unheaderpick save ignore ^X-.*$ ^DKIM.*$
4501 \echo --- $?/$^ERRNAME, 11
4502 \unheaderpick forward retain *
4503 \echo --- $?/$^ERRNAME, 12 ---
4504 \headerpick
4505 \echo --- $?/$^ERRNAME, 13
4506 \headerpick type
4507 \echo --- $?/$^ERRNAME, 14
4508 \headerpick save
4509 \echo --- $?/$^ERRNAME, 15 --
4510 \unheaderpick type retain *
4511 \echo --- $?/$^ERRNAME, 16
4512 \unheaderpick forward retain *
4513 \echo --- $?/$^ERRNAME, 17
4514 \unheaderpick save ignore *
4515 \echo --- $?/$^ERRNAME, 18
4516 \unheaderpick top retain *
4517 \echo --- $?/$^ERRNAME, 19 --
4518 \headerpick
4519 \echo --- $?/$^ERRNAME, 20
4520 # ' >./.tall 2>&1
4521 check 2 0 ./.tall "${i}"
4522 else
4523 t_echoskip '2:[!UISTRINGS]'
4526 t_epilog "${@}"
4528 # }}}
4530 # Send/RFC absolute basics {{{
4531 t_can_send_rfc() { # {{{
4532 t_prolog "${@}"
4534 </dev/null ${MAILX} ${ARGS} -Smta=test://"$MBOX" -s Sub.1 \
4535 receiver@number.1 \
4536 > ./.terr 2>&1
4537 check 1 0 "${MBOX}" '550126528 126'
4538 check 1-err - .terr '4294967295 0'
4540 </dev/null ${MAILX} ${ARGS} -Smta=test://"$MBOX" -s Sub.2 \
4541 -b bcc@no.1 -b bcc@no.2 -b bcc@no.3 \
4542 -c cc@no.1 -c cc@no.2 -c cc@no.3 \
4543 to@no.1 to@no.2 to@no.3 \
4544 > ./.terr 2>&1
4545 check 2 0 "${MBOX}" '3259888945 324'
4546 check 2-err - .terr '4294967295 0'
4548 </dev/null ${MAILX} ${ARGS} -Smta=test://"$MBOX" -s Sub.2no \
4549 -b bcc@no.1\ \ bcc@no.2 -b bcc@no.3 \
4550 -c cc@no.1,cc@no.2 -c cc@no.3 \
4551 to@no.1,to@no.2 to@no.3 \
4552 > ./.terr 2>&1
4553 check 2no 4 "${MBOX}" '3350946897 468'
4554 if have_feat uistrings; then
4555 check 2no-err - .terr '3397557940 190'
4556 else
4557 check 2no-err - .terr '4294967295 0'
4560 # XXX NOTE we cannot test "cc@no1 <cc@no.2>" because our stupid parser
4561 # XXX would not treat that as a list but look for "," as a separator
4562 </dev/null ${MAILX} ${ARGS} -Smta=test://"$MBOX" -Sfullnames -s Sub.3 \
4563 -T 'bcc?single: bcc@no.1, <bcc@no.2>' -T bcc:\ bcc@no.3 \
4564 -T cc?si\ \ :\ \ 'cc@no.1, <cc@no.2>' -T cc:\ cc@no.3 \
4565 -T to?:\ to@no.1,'<to@no.2>' -T to:\ to@no.3 \
4566 > ./.terr 2>&1
4567 check 3 0 "${MBOX}" '1453534480 678'
4568 check 3-err - .terr '4294967295 0'
4570 </dev/null ${MAILX} ${ARGS} -Smta=test://"$MBOX" -Sfullnames -s Sub.4 \
4571 -T 'bcc: bcc@no.1, <bcc@no.2>' -T bcc:\ bcc@no.3 \
4572 -T cc:\ 'cc@no.1, <cc@no.2>' -T cc\ \ :\ \ cc@no.3 \
4573 -T to\ :to@no.1,'<to@no.2>' -T to:\ to@no.3 \
4574 > ./.terr 2>&1
4575 check 4 0 "${MBOX}" '535767201 882'
4576 check 4-err - .terr '4294967295 0'
4578 # Two test with a file-based MTA
4579 "${cat}" <<-_EOT > .tmta.sh
4580 #!${SHELL} -
4581 (echo 'From reproducible_build Wed Oct 2 01:50:07 1996' &&
4582 "${cat}" && echo pardauz && echo) > "${MBOX}"
4583 _EOT
4584 ${chmod} 0755 .tmta.sh
4586 </dev/null ${MAILX} ${ARGS} -Smta=./.tmta.sh -s Sub.mta-1 \
4587 receiver@number.1 > ./.terr 2>&1
4588 check 5 0 "${MBOX}" '2384401657 138'
4589 check 5-err - .terr '4294967295 0'
4591 </dev/null ${MAILX} ${ARGS} -Smta=file://./.tmta.sh -s Sub.mta-2 \
4592 receiver@number.1 > ./.terr 2>&1
4593 check 6 0 "${MBOX}" '3006460737 138'
4594 check 6-err - .terr '4294967295 0'
4596 # Command
4597 </dev/null ${MAILX} ${ARGS} -Smta=test \
4598 -Y '#
4599 mail hey@exam.ple
4600 ~s Subject 1
4601 Body1
4603 echo $?/$^ERRNAME
4605 # ' > ./.tall 2>&1
4606 check 7 0 ./.tall '951018449 138'
4608 ## *record*, *outfolder*, with and without *mta-bcc-ok*
4609 ${mkdir} .tfolder
4610 xfolder=`${pwd}`/.tfolder
4612 "${cat}" <<-_EOT > .tmta.sh
4613 #!${SHELL} -
4614 (echo 'From reproducible_build Wed Oct 2 01:50:07 1996' &&
4615 "${cat}" && echo 'ARGS: '"\${@}" && echo) > "${MBOX}"
4616 _EOT
4617 ${chmod} 0755 .tmta.sh
4619 t_it() {
4620 </dev/null ${MAILX} ${ARGS} -Smta=./.tmta.sh -Sfolder="${xfolder}" \
4621 "${@}" \
4622 -s Sub.mta-1 \
4623 -b bcc@no.1 -b bcc@no.2 -b bcc@no.3 \
4624 -c cc@no.1 -c cc@no.2 -c cc@no.3 \
4625 to@no.1 to@no.2 to@no.3 \
4626 receiver@number.1 > ./.terr 2>&1
4627 return ${?}
4630 t_it -Snomta-bcc-ok
4631 check 8 0 "${MBOX}" '1365032629 292'
4632 check 8-1 - .terr '4294967295 0'
4634 t_it -Snomta-bcc-ok -Srecord=.trec9
4635 check 9 0 "${MBOX}" '1365032629 292'
4636 check 9-1 - .terr '4294967295 0'
4637 check 9-2 - ./.trec9 '160206230 221'
4639 t_it -Srecord=.trec10
4640 check 10 0 "${MBOX}" '3085765596 326'
4641 check 10-1 - .terr '4294967295 0'
4642 check 10-2 - ./.trec10 '160206230 221'
4644 t_it -Snomta-bcc-ok -Srecord=.trec11 -Soutfolder
4645 check 11 0 "${MBOX}" '1365032629 292'
4646 check 11-1 - .terr '4294967295 0'
4647 check 11-2 - ./.tfolder/.trec11 '160206230 221'
4648 # That is appends to an MBOX
4649 t_it -Srecord=.trec11 -Soutfolder
4650 check 12 0 "${MBOX}" '3085765596 326'
4651 check 12-1 - .terr '4294967295 0'
4652 check 12-2 - ./.tfolder/.trec11 '1618754846 442'
4654 ### More RFC cases
4656 ## From: and Sender:
4657 </dev/null ${MAILX} ${ARGS} -s ubject \
4658 -S from=a@b.org,b@b.org,c@c.org -S sender=a@b.org \
4659 to@exam.ple > "${MBOX}" 2>&1
4660 check 13 0 "${MBOX}" '143390417 169'
4662 # ..if From: is single mailbox and Sender: is same, no Sender:
4663 </dev/null ${MAILX} ${ARGS} -s ubject \
4664 -S from=a@b.org -S sender=a@b.org \
4665 to@exam.ple > "${MBOX}" 2>&1
4666 check 14 0 "${MBOX}" '1604962737 135'
4668 t_epilog "${@}"
4669 } # }}}
4671 t_reply() { # {{{
4672 # Alternates and ML related address massage etc. somewhere else
4673 t_prolog "${@}"
4674 XARGS=${ARGS} # TODO v15-compat
4675 ARGS="${ARGS} -Sv15-compat=y"
4677 t__gen_msg subject reply from 1 to 2 cc 2 > "${MBOX}"
4679 ## Base (does not test "recipient record")
4680 t_it() {
4681 </dev/null ${MAILX} ${ARGS} -Rf \
4682 -Y "${2}${1}"'
4685 echo 1:$?/$^ERRNAME
4686 set fullnames escape=!; '${1}'
4687 r2 fullnames
4689 echo 2:$?/$^ERRNAME
4690 set recipients-in-cc nofullnames; '${1}'
4691 r3 recipients-in-cc
4693 echo 3:$?/$^ERRNAME
4694 unset recipients-in-cc; '${1}'
4697 echo 4:$?/$^ERRNAME
4698 #' \
4699 "${MBOX}" > ./.tall 2>&1
4700 return ${?}
4703 t_it reply
4704 check 1 0 ./.tall '4164251531 851'
4705 t_it Reply
4706 check 2 0 ./.tall '3034955332 591'
4707 t_it reply 'set flipr;'
4708 check 3 0 ./.tall '3034955332 591'
4709 t_it Reply 'set flipr;'
4710 check 4 0 ./.tall '4164251531 851'
4712 ## Dig the errors
4713 t__gen_msg subject reply-no-addr > ./.tnoaddr
4715 # MBOX will deduce addressee from From_ line..
4716 </dev/null ${MAILX} ${ARGS} -R -Sescape=! \
4717 -Y '#
4718 File ./.tnoaddr; reply # Takes addressee from From_ line :(
4719 body1
4721 echo 1:$?/$^ERRNAME
4722 File '"${MBOX}"'; set ea=$expandaddr expandaddr=-all; reply
4723 body2
4725 echo 2:$?/$^ERRNAME; set expandaddr=$ea; reply 10 # BADMSG
4726 echo 3:$?/$^ERRNAME; reply # cannot test IO,NOTSUP,INVAL
4727 body3
4729 echo 4:$?/$^ERRNAME
4730 #' \
4731 > ./.tall 2>./.terr
4732 check 5 0 ./.tall '3088217220 382'
4733 if have_feat uistrings; then
4734 check 6 - ./.terr '2514745519 544'
4735 else
4736 t_echoskip '6:[!UISTRINGS]'
4739 # ..but Maildir will not
4740 if have_feat maildir; then
4741 ${mkdir} -p .tdir .tdir/tmp .tdir/cur .tdir/new
4742 ${sed} 1d < ./.tnoaddr > .tdir/new/sillyname
4744 </dev/null ${MAILX} ${ARGS} -R -Sescape=! \
4745 -Y '#
4746 File ./.tdir; reply
4747 body1
4749 echo 1:$?/$^ERRNAME
4750 File '"${MBOX}"'; set ea=$expandaddr expandaddr=-all; reply
4751 body2
4753 echo 2:$?/$^ERRNAME; set expandaddr=$ea; reply 10 # BADMSG
4754 echo 3:$?/$^ERRNAME;reply # cannot test IO,NOTSUP,INVAL
4755 body3
4757 echo 4:$?/$^ERRNAME
4758 #' \
4759 > ./.tall 2>./.terr
4760 check 7 0 ./.tall '3631170341 244'
4761 if have_feat uistrings; then
4762 check 8 - ./.terr '1074346767 629'
4763 else
4764 t_echoskip '8:[!UISTRINGS]'
4768 ## Ensure action on multiple messages
4769 t__gen_msg subject reply2 from from2@exam.ple body body2 >> "${MBOX}"
4771 t_it() {
4772 </dev/null ${MAILX} ${ARGS} -Rf -Sescape=! \
4773 -Y '#
4774 '${1}' 1 2
4775 repbody1
4777 repbody2
4779 echo 1:$?/$^ERRNAME; '${2}' 1 2
4780 Repbody1
4782 echo 2:$?/$^ERRNAME
4783 #' \
4784 "${MBOX}" > ./.tall 2>&1
4785 check ${3} 0 ./.tall '283309820 502'
4786 if [ ${#} -eq 4 ]; then
4787 echo * > ./.tlst
4788 check ${3}-1 - ./.tlst '1649520021 12'
4789 check ${3}-2 - ./from1 '1501109193 347'
4790 check ${3}-3 - ./from2 '2154231432 137'
4794 t_it reply Reply 9
4795 t_it respond Respond 10
4796 t_it followup Followup 11 yes
4797 ${rm} -f from1 from2
4799 ## *record*, *outfolder* (reuses $MBOX)
4800 ${mkdir} .tfolder
4802 t_it() {
4803 </dev/null ${MAILX} ${ARGS} -Rf -Sescape=! -Sfolder=`${pwd}`/.tfolder \
4804 -Y '#
4805 '${1}' 1 2
4806 repbody1
4808 repbody2
4810 echo 1:$?/$^ERRNAME; '${2}' 1 2
4811 Repbody3
4813 echo 2:$?/$^ERRNAME; set record=.trec'${4}'; '${1}' 1 2
4814 repbody4
4816 repbody5
4818 echo 3:$?/$^ERRNAME; '${2}' 1 2
4819 Repbody6
4821 echo 4:$?/$^ERRNAME; set outfolder norecord
4822 '${1}' 1 2
4823 repbody1
4825 repbody2
4827 echo 1:$?/$^ERRNAME; '${2}' 1 2
4828 Repbody3
4830 echo 2:$?/$^ERRNAME; set record=.trec'${4}'; '${1}' 1 2
4831 repbody4
4833 repbody5
4835 echo 3:$?/$^ERRNAME; '${2}' 1 2
4836 Repbody6
4838 echo 4:$?/$^ERRNAME
4839 #' \
4840 "${MBOX}" > ./.tall 2>&1
4841 check ${3} 0 ./.tall '3410330303 2008'
4842 if [ ${#} -ne 5 ]; then
4843 check ${4} - ./.trec${4} '3044885336 484'
4844 check ${4}-1 - ./.tfolder/.trec${4} '3044885336 484'
4845 else
4846 [ -f ./.trec${4} ]; check_exn0 ${4}
4847 echo * > ./.tlst
4848 check ${4}-1 - ./.tlst '1649520021 12'
4849 check ${4}-2 - ./from1 '2668975631 694'
4850 check ${4}-3 - ./from2 '225462887 274'
4851 [ -f ./.tfolder/.trec${4} ]; check_exn0 ${4}-4
4852 ( cd .tfolder && echo * > ./.tlst )
4853 check ${4}-5 - ./.tfolder/.tlst '1649520021 12'
4854 check ${4}-6 - ./.tfolder/from1 '2668975631 694'
4855 check ${4}-7 - ./.tfolder/from2 '225462887 274'
4859 t_it reply Reply 12 13
4860 t_it respond Respond 14 15
4861 t_it followup Followup 16 17 yes
4862 #${rm} -f from1 from2
4864 ## Quoting (if not cmd_escapes related)
4865 ${rm} -f "${MBOX}"
4866 t__x2_msg > ./.tmbox
4868 printf '#
4869 set indentprefix=" |" quote
4870 reply
4873 set quote=noheading quote-inject-head
4874 reply
4877 headerpick type retain cc date from message-id reply-to subject to
4878 set quote=headers
4879 reply
4882 set quote=allheaders
4883 reply
4886 set quote-inject-head=%% quote-inject-tail=%% quote=headers
4887 reply
4890 set quote \\
4891 quote-inject-head='"\$'"'\\
4892 (%%%%a=%%a %%%%d=%%d %%%%f=%%f %%%%i=%%i %%%%n=%%n %%%%r=%%r)\\
4893 \\n'"'"' \\
4894 quote-inject-tail='"\$'"'\\
4895 (%%%%a=%%a %%%%d=%%d %%%%f=%%f %%%%i=%%i %%%%n=%%n %%%%r=%%r)\\
4896 \\n'"'"'
4897 reply
4900 set showname datefield=%%y nodatefield-markout-older indentprefix=\\ :
4901 reply
4904 ' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" -Rf \
4905 -Sescape=! -Sindentprefix=' >' \
4906 ./.tmbox >./.tall 2>&1
4907 check_ex0 18-estat
4908 ${cat} ./.tall >> "${MBOX}"
4909 check 18 - "${MBOX}" '385267528 3926'
4911 # quote-as-attachment, fullnames
4912 </dev/null ${MAILX} ${ARGS} -Rf \
4913 -Sescape=! \
4914 -S quote-as-attachment \
4915 -Y reply -Y yb1 -Y !. \
4916 -Y 'unset quote-as-attachment' \
4917 -Y 'reply;yb2' -Y !. \
4918 -Y 'set quote-as-attachment fullnames' \
4919 -Y ';reply;yb3' -Y !. \
4920 ./.tmbox >./.tall 2>&1
4921 check 19 0 ./.tall '2774517283 2571'
4923 # Moreover, quoting of several parts with all*
4924 t__gen_mimemsg from 'ex1@am.ple' subject for-repl > ./.tmbox
4925 check 20 0 ./.tmbox '1874764424 668'
4927 </dev/null ${MAILX} ${ARGS} -Rf \
4928 -Sescape=! -Sindentprefix=' |' \
4929 -Y 'set quote=allheaders' \
4930 -Y reply -Y !. \
4931 -Y 'set quote=allbodies' \
4932 -Y reply -Y !. \
4933 -Y xit \
4934 ./.tmbox >./.tall 2>&1
4935 check 21 0 ./.tall '946925637 1105'
4937 ARGS=${XARGS} # TODO v15-compat
4938 t_epilog "${@}"
4939 } # }}}
4941 t_forward() { # {{{
4942 t_prolog "${@}"
4943 XARGS=${ARGS}
4944 ARGS="${ARGS} -Sv15-compat=y"
4946 t__gen_msg subject fwd1 body origb1 from 1 to 2 > "${MBOX}"
4947 t__gen_msg subject fwd2 body origb2 from 1 to 1 >> "${MBOX}"
4949 ## Base (does not test "recipient record")
4950 t_it() {
4951 </dev/null ${MAILX} ${ARGS} -Rf \
4952 -Y ${1}' . "du <ex1@am.ple>"
4955 echo 1:$?/$^ERRNAME; echoerr 1:done
4956 set fullnames escape=!
4957 '${1}' 1 "du <ex2@am.ple>"
4958 b2 fullnames
4960 echo 2:$?/$^ERRNAME; echoerr 2:done
4961 # Some errors
4962 set nofullnames ea=$expandaddr expandaddr=-all
4963 '${1}' ` "du <ex3@am.ple>"
4966 echo 3:$?/$^ERRNAME; echoerr 3:done
4967 set expandaddr=$ea
4968 '${1}' ` ex4-nono@am.ple ex4@am.ple # the first is a non-match msglist
4971 echo 4:$?/$^ERRNAME; echoerr 4:done
4972 '${1}' # TODO not yet possible b5 !.
4973 echo 5:$?/$^ERRNAME; echoerr 5:done
4974 set expandaddr=$ea
4975 '${1}' 1 2 ex6@am.ple
4976 b6-1
4978 b6-2
4980 echo 6:$?/$^ERRNAME; echoerr 6:done
4981 set forward-add-cc fullnames
4982 '${1}' . ex7@am.ple
4985 echo 7:$?/$^ERRNAME; echoerr 7:done
4986 set nofullnames
4987 '${1}' . ex8@am.ple
4990 echo 8:$?/$^ERRNAME; echoerr 8:done
4991 #' \
4992 "${MBOX}" > ./.tall 2>./.terr
4993 return ${?}
4996 t_it forward
4997 check 1 0 ./.tall '2356713156 2219'
4998 if have_feat uistrings && have_feat docstrings; then
4999 check 2 - ./.terr '3273108824 335'
5000 else
5001 t_echoskip '2:[!UISTRINGS]'
5004 t_it Forward
5005 check 3 0 ./.tall '2356713156 2219'
5006 if have_feat uistrings && have_feat docstrings; then
5007 check 4 - ./.terr '447176534 355'
5008 else
5009 t_echoskip '4:[!UISTRINGS]'
5011 ${rm} -f ex*
5013 ## *record*, *outfolder* (reuses $MBOX)
5014 ${mkdir} .tfolder
5016 t_it() {
5017 </dev/null ${MAILX} ${ARGS} -Rf -Sescape=! -Sfolder=`${pwd}`/.tfolder \
5018 -Y '#
5019 '${1}' 1 ex1@am.ple
5022 echo 1:$?/$^ERRNAME; set record=.trec'${2}'; '${1}' 1 ex2@am.ple
5025 echo 2:$?/$^ERRNAME; set outfolder norecord; '${1}' 2 ex1@am.ple
5028 echo 3:$?/$^ERRNAME; set record=.trec'${2}'; '${1}' 2 ex2@am.ple
5031 echo 4:$?/$^ERRNAME
5032 #' \
5033 "${MBOX}" > ./.tall 2>&1
5034 check ${2} 0 ./.tall '3180366037 1212'
5035 if [ ${#} -ne 4 ]; then
5036 check ${3}-1 - ./.trec${2} '1769129556 304'
5037 check ${3}-2 - ./.tfolder/.trec${2} '2335391111 284'
5038 else
5039 [ -f ./.trec${2} ]; check_exn0 ${3}
5040 echo * > ./.tlst
5041 check ${3}-1 - ./.tlst '2020171298 8'
5042 check ${3}-2 - ./ex1 '1512529673 304'
5043 check ${3}-3 - ./ex2 '1769129556 304'
5044 [ -f ./.tfolder/.trec${2} ]; check_exn0 ${3}-4
5045 ( cd .tfolder && echo * > ./.tlst )
5046 check ${3}-5 - ./.tfolder/.tlst '2020171298 8'
5047 check ${3}-6 - ./.tfolder/ex1 '2016773910 284'
5048 check ${3}-7 - ./.tfolder/ex2 '2335391111 284'
5052 t_it forward 5 6
5053 t_it Forward 7 8 yes
5054 #${rm} -f ex*
5056 ## Injections, headerpick selection
5057 ${rm} -f "${MBOX}"
5058 t__x2_msg > ./.tmbox
5060 printf '#
5061 set quote=noheading forward-inject-head
5062 forward 1 ex1@am.ple
5065 headerpick forward retain cc from subject to
5066 forward 1 ex1@am.ple
5069 unheaderpick forward retain *
5070 forward 1 ex1@am.ple
5073 headerpick forward ignore in-reply-to reply-to message-id status
5074 set forward-inject-head=%% forward-inject-tail=%%
5075 forward 1 ex1@am.ple
5078 set forward-inject-head='"\$'"'\\
5079 (%%%%a=%%a %%%%d=%%d %%%%f=%%f %%%%i=%%i %%%%n=%%n %%%%r=%%r)\\
5080 \\n'"'"' \\
5081 forward-inject-tail='"\$'"'\\
5082 (%%%%a=%%a %%%%d=%%d %%%%f=%%f %%%%i=%%i %%%%n=%%n %%%%r=%%r)\\
5083 \\n'"'"'
5084 forward 1 ex1@am.ple
5087 set showname datefield=%%y nodatefield-markout-older
5088 forward 1 ex1@am.ple
5091 ' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" -Rf \
5092 -Sescape=! \
5093 ./.tmbox >./.tall 2>&1
5094 check_ex0 9-estat
5095 ${cat} ./.tall >> "${MBOX}"
5096 check 9 - "${MBOX}" '2976943913 2916'
5098 # forward-as-attachment
5099 </dev/null ${MAILX} ${ARGS} -Rf \
5100 -Sescape=! \
5101 -S forward-inject-head=.head. \
5102 -S forward-inject-tail=.tail. \
5103 -S forward-as-attachment \
5104 -Y 'headerpick forward retain subject to from' \
5105 -Y 'forward ex1@am.ple' -Y b1 -Y !. \
5106 -Y 'unset forward-as-attachment' \
5107 -Y 'forward ex1@am.ple;b2' -Y !. \
5108 ./.tmbox >./.tall 2>&1
5109 check 10 0 ./.tall '799103633 1250'
5111 ARGS=${XARGS}
5112 t_epilog "${@}"
5113 } # }}}
5115 t_resend() { # {{{
5116 t_prolog "${@}"
5117 XARGS=${ARGS}
5118 ARGS="${ARGS} -Sv15-compat=y"
5120 t__gen_msg subject fwd1 body origb1 from 1 to 2 > "${MBOX}"
5121 t__gen_msg subject fwd2 body origb2 from 1 to 1 >> "${MBOX}"
5123 ## Base
5124 t_it() {
5125 </dev/null ${MAILX} ${ARGS} -Rf \
5126 -Y ${1}' . "du <ex1@am.ple>"
5127 echo 1:$?/$^ERRNAME; echoerr 1:done
5128 set fullnames escape=!
5129 '${1}' 1 "du , da <ex2@am.ple>"
5130 echo 2:$?/$^ERRNAME; echoerr 2:done
5131 # Some errors
5132 set nofullnames ea=$expandaddr expandaddr=-all
5133 '${1}' ` "du <ex3@am.ple>"
5134 echo 3:$?/$^ERRNAME; echoerr 3:done
5135 set expandaddr=$ea
5136 '${1}' ` ex4-nono@am.ple ex4@am.ple # the first is a non-match msglist
5137 echo 4:$?/$^ERRNAME; echoerr 4:done
5138 '${1}' # TODO not yet possible b5 !.
5139 echo 5:$?/$^ERRNAME; echoerr 5:done
5140 set expandaddr=$ea
5141 '${1}' 1 2 ex6@am.ple
5142 echo 6:$?/$^ERRNAME; echoerr 6:done
5143 #' \
5144 "${MBOX}" > ./.tall 2>./.terr
5145 return ${?}
5148 t_it resend
5149 check 1 0 ./.tall '1461006932 1305'
5150 if have_feat uistrings; then
5151 check 2 - ./.terr '138360532 210'
5152 else
5153 t_echoskip '2:[!UISTRINGS]'
5156 t_it Resend
5157 check 3 0 ./.tall '3674535444 958'
5158 if have_feat uistrings; then
5159 check 4 - ./.terr '138360532 210'
5160 else
5161 t_echoskip '4:[!UISTRINGS]'
5164 ## *record*, *outfolder* (reuses $MBOX)
5165 ${mkdir} .tfolder
5167 t_it() {
5168 </dev/null ${MAILX} ${ARGS} -Rf -Sescape=! -Sfolder=`${pwd}`/.tfolder \
5169 -Y '#
5170 set record=.trec'${2}'; '${1}' 1 ex1@am.ple
5171 echo 1:$?/$^ERRNAME; set record-resent; '${1}' 1 ex2@am.ple
5172 echo 2:$?/$^ERRNAME; set outfolder norecord-resent; '${1}' 2 ex1@am.ple
5173 echo 3:$?/$^ERRNAME; set record-resent; '${1}' 2 ex2@am.ple
5174 echo 4:$?/$^ERRNAME
5175 #' \
5176 "${MBOX}" > ./.tall 2>&1
5177 check_ex0 ${2}
5178 if [ ${#} -ne 3 ]; then
5179 check ${2} - ./.tall '1711347390 992'
5180 check ${3}-1 - ./.trec${2} '2840978700 249'
5181 check ${3}-2 - ./.tfolder/.trec${2} '3219997964 229'
5182 else
5183 check ${2} - ./.tall '1391418931 724'
5184 check ${3}-1 - ./.trec${2} '473817710 182'
5185 check ${3}-2 - ./.tfolder/.trec${2} '2174632404 162'
5189 t_it resend 5 6 yes
5190 t_it Resend 7 8
5192 ARGS=${XARGS}
5193 t_epilog "${@}"
5194 } # }}}
5195 # }}}
5197 # VFS {{{
5198 t_copy() { # {{{
5199 t_prolog "${@}"
5201 t__gen_msg subject Copy1 from 1 to 1 body 'Body1' > "${MBOX}"
5202 t__gen_msg subject Copy2 from 1 to 1 body 'Body2' >> "${MBOX}"
5203 check 1 - "${MBOX}" '137107341 324' # for flag test
5206 </dev/null ${MAILX} ${ARGS} -f \
5207 -Y '#
5208 headers
5209 copy 10 .tf1
5210 echo 0:$?/$^ERRNAME
5211 headers
5212 copy .tf1
5213 echo 1:$?/$^ERRNAME
5214 headers
5215 copy .tf1 # no auto-advance
5216 echo 2:$?/$^ERRNAME
5217 headers
5218 copy 2 .tf2
5219 echo 3:$?/$^ERRNAME
5220 headers
5221 copy 1 2 .tf3
5222 echo 4:$?/$^ERRNAME
5223 headers
5224 !'"${chmod}"' 0444 .tf3
5225 copy 1 2 .tf3
5226 echo 5:$?/$^ERRNAME
5227 #' \
5228 "${MBOX}" > ./.tallx 2>./.terr
5229 check_ex0 2
5231 if have_feat uistrings; then # TODO
5232 ${sed} -e '$bP' -e d -e :P < ./.tallx >> "${ERR}"
5233 ${sed} '$d' < ./.tallx > ./.tall
5234 else
5235 ${mv} ./.tallx ./.tall
5237 if [ -n "${HONOURS_READONLY}" ]; then
5238 n2_1=2-1 cs2_1='1913702840 1121'
5239 n2_4=2-4 cs2_4='3642131968 344'
5240 n2_5=2-5 cs2_5='2617612897 112'
5241 else
5242 n2_1=2-1-nrdonly cs2_1='1962556153 1146'
5243 n2_4=2-4-nrdonly cs2_4='3733058190 688'
5244 n2_5=2-5-nrdonly cs2_5='3989834342 80'
5246 check ${n2_1} - ./.tall "${cs2_1}"
5247 check 2-2 - ./.tf1 '686654461 334'
5248 check 2-3 - ./.tf2 '1931512953 162'
5249 check ${n2_4} - ./.tf3 "${cs2_4}"
5250 if have_feat uistrings; then
5251 check ${n2_5} - ./.terr "${cs2_5}"
5252 else
5253 t_echoskip '2-5:[!UISTRINGS]'
5257 check 3 - "${MBOX}" '1477662071 346'
5260 t_it() {
5261 t__gen_msg subject Copy1 from 1 to 1 body 'Body1' > "${MBOX}"
5262 t__gen_msg subject Copy2 from 1 to 1 body 'Body2' >> "${MBOX}"
5263 t__gen_msg subject Copy3 from ex@am.ple to 1 body 'Body3' >> "${MBOX}"
5264 check ${1} - "${MBOX}" '2667292819 473' # for flag test
5266 </dev/null ${MAILX} ${ARGS} -f \
5267 -Y "${3}"'
5268 '"${2}"'
5269 Copy
5270 echo 1:$?/$^ERRNAME
5271 '"${2}"'
5272 Copy
5273 echo 2:$?/$^ERRNAME
5274 '"${2}"'
5275 Copy 2
5276 echo 3:$?/$^ERRNAME
5277 '"${2}"'
5278 Copy 3
5279 echo 4:$?/$^ERRNAME
5280 '"${2}"'
5281 Copy *
5282 echo 5:$?/$^ERRNAME
5283 '"${2}"'
5284 #' \
5285 "${MBOX}" > ./.tallx 2>&1
5286 return ${?}
5289 t_it 5 headers '#'
5290 check_ex0 5-1
5291 if have_feat uistrings; then # TODO
5292 ${sed} -e '$bP' -e d -e :P < ./.tallx >> "${ERR}"
5293 ${sed} '$d' < ./.tallx > ./.tall
5294 else
5295 ${mv} ./.tallx ./.tall
5297 echo * > ./.tlst
5298 check 5-2 - ./.tlst '1058655452 9'
5299 check 5-3 - ./.tall '1543702808 1617'
5300 check 5-4 - ./from1 '1031912635 999'
5301 check 5-5 - ./ex '2400630246 149'
5302 ${rm} -f ./.tlst ./.tall ./from1 ./ex
5304 ${mkdir} .tfolder
5305 t_it 6 '#' 'set outfolder folder='"`${pwd}`"'/.tfolder'
5306 check_ex0 6-1
5307 if have_feat uistrings; then # TODO
5308 ${sed} -e '$bP' -e d -e :P < ./.tallx >> "${ERR}"
5309 ${sed} '$d' < ./.tallx > ./.tall
5310 else
5311 ${mv} ./.tallx ./.tall
5313 echo * .tfolder/* > ./.tlst
5314 check 6-2 - ./.tlst '1865898363 29'
5315 ${cat} ./.tall >> ${ERR} #check 6-3 - ./.tall # TODO due to folder echoes
5316 check 6-4 - .tfolder/from1 '1031912635 999'
5317 check 6-5 - .tfolder/ex '2400630246 149'
5320 t__x2_msg > ./.tmbox
5322 t_it() {
5323 printf '#
5324 '"${1}"'
5325 echo 1:$?/$^ERRNAME
5326 headerpick save retain cc date from subject to
5327 '"${1}"'
5328 echo 2:$?/$^ERRNAME
5329 unheaderpick save retain *
5330 '"${1}"'
5331 echo 3:$?/$^ERRNAME
5332 headerpick save ignore status in-reply-to
5333 '"${1}"'
5334 echo 4:$?/$^ERRNAME
5335 #' | ${MAILX} ${ARGS} -Rf ./.tmbox > ./.tall 2>&1
5336 return ${?}
5339 t_it 'copy ./.tout'
5340 check_ex0 7-estat
5341 check 7-1 - ./.tall '3805176908 152'
5342 check 7-2 - ./.tout '2447734879 1316'
5344 t_it Copy
5345 check_ex0 8-estat
5346 echo * > ./.tlst
5347 check 8-1 - ./.tall '1044700686 136'
5348 check 8-2 - ./mr2 '2447734879 1316'
5349 check 8-3 - ./.tlst '3190056903 4'
5351 t_epilog "${@}"
5352 } # }}}
5354 t_save() { # {{{
5355 t_prolog "${@}"
5357 t__gen_msg subject Save1 from 1 to 1 body 'Body1' > "${MBOX}"
5358 t__gen_msg subject Save2 from 1 to 1 body 'Body2' >> "${MBOX}"
5359 check 1 - "${MBOX}" '3634443864 324' # for flag test
5362 </dev/null ${MAILX} ${ARGS} -f \
5363 -Y '#
5364 headers
5365 save 10 .tf1
5366 echo 0:$?/$^ERRNAME
5367 headers
5368 save .tf1
5369 echo 1:$?/$^ERRNAME
5370 headers
5371 save .tf1 # no auto-advance
5372 echo 2:$?/$^ERRNAME
5373 headers
5374 save 2 .tf2
5375 echo 3:$?/$^ERRNAME
5376 headers
5377 save 1 2 .tf3
5378 echo 4:$?/$^ERRNAME
5379 headers
5380 !'"${chmod}"' 0444 .tf3
5381 save 1 2 .tf3
5382 echo 5:$?/$^ERRNAME
5383 #' \
5384 "${MBOX}" > ./.tallx 2>./.terr
5385 check_ex0 2
5387 if have_feat uistrings; then # TODO
5388 ${sed} -e '$bP' -e d -e :P < ./.tallx >> "${ERR}"
5389 ${sed} '$d' < ./.tallx > ./.tall
5390 else
5391 ${mv} ./.tallx ./.tall
5393 if [ -n "${HONOURS_READONLY}" ]; then
5394 n2_1=2-1 cs2_1='2335843514 1121'
5395 n2_4=2-4 cs2_4='970407001 344'
5396 n2_5=2-5 cs2_5='45116475 112'
5397 else
5398 n2_1=2-1-nrdonly cs2_1='1736244784 1146'
5399 n2_4=2-4-nrdonly cs2_4='3903872811 688'
5400 n2_5=2-5-nrdonly cs2_5='720724138 80'
5402 check ${n2_1} - ./.tall "${cs2_1}"
5403 check 2-2 - ./.tf1 '2435434321 334'
5404 check 2-3 - ./.tf2 '920652966 162'
5405 check ${n2_4} - ./.tf3 "${cs2_4}"
5406 if have_feat uistrings; then
5407 check ${n2_5} - ./.terr "${cs2_5}"
5408 else
5409 t_echoskip '2-5:[!UISTRINGS]'
5413 check 3 - "${MBOX}" '1219692400 346'
5416 t_it() {
5417 t__gen_msg subject Save1 from 1 to 1 body 'Body1' > "${MBOX}"
5418 t__gen_msg subject Save2 from 1 to 1 body 'Body2' >> "${MBOX}"
5419 t__gen_msg subject Save3 from ex@am.ple to 1 body 'Body3' >> "${MBOX}"
5420 check ${1} - "${MBOX}" '1391391227 473' # for flag test
5422 </dev/null ${MAILX} ${ARGS} -f \
5423 -Y "${3}"'
5424 '"${2}"'
5425 Save
5426 echo 1:$?/$^ERRNAME
5427 '"${2}"'
5428 Save
5429 echo 2:$?/$^ERRNAME
5430 '"${2}"'
5431 Save 2
5432 echo 3:$?/$^ERRNAME
5433 '"${2}"'
5434 Save 3
5435 echo 4:$?/$^ERRNAME
5436 '"${2}"'
5437 Save *
5438 echo 5:$?/$^ERRNAME
5439 '"${2}"'
5440 #' \
5441 "${MBOX}" > ./.tallx 2>&1
5442 return ${?}
5445 t_it 5 headers '#'
5446 check_ex0 5-1
5447 if have_feat uistrings; then # TODO
5448 ${sed} -e '$bP' -e d -e :P < ./.tallx >> "${ERR}"
5449 ${sed} '$d' < ./.tallx > ./.tall
5450 else
5451 ${mv} ./.tallx ./.tall
5453 echo * > ./.tlst
5454 check 5-2 - ./.tlst '1058655452 9'
5455 check 5-3 - ./.tall '3418590770 1617'
5456 check 5-4 - ./from1 '1462882526 999'
5457 check 5-5 - ./ex '2153575326 149'
5458 ${rm} -f ./.tlst ./.tall ./from1 ./ex
5460 ${mkdir} .tfolder
5461 t_it 6 '#' 'set outfolder folder='"`${pwd}`"'/.tfolder'
5462 check_ex0 6-1
5463 if have_feat uistrings; then # TODO
5464 ${sed} -e '$bP' -e d -e :P < ./.tallx >> "${ERR}"
5465 ${sed} '$d' < ./.tallx > ./.tall
5466 else
5467 ${mv} ./.tallx ./.tall
5469 echo * .tfolder/* > ./.tlst
5470 check 6-2 - ./.tlst '1865898363 29'
5471 ${cat} ./.tall >> ${ERR} #check 6-3 - ./.tall # TODO due to folder echoes
5472 check 6-4 - .tfolder/from1 '1462882526 999'
5473 check 6-5 - .tfolder/ex '2153575326 149'
5477 t_it() {
5478 t__x2_msg > ./.tmbox
5479 check ${1} - ./.tmbox '561523988 397'
5481 a='-Rf'
5482 [ ${#} -gt 2 ] && a='-S MBOX=./.tmboxx'
5483 [ ${#} -gt 3 ] && a="${a}"' -S inbox=./.tmbox'
5484 printf '#
5485 headers
5486 '"${2}"'
5487 echo 1:$?/$^ERRNAME
5488 headers
5489 headerpick save retain cc date from subject to
5490 '"${2}"'
5491 echo 2:$?/$^ERRNAME
5492 unheaderpick save retain *
5493 '"${2}"'
5494 echo 3:$?/$^ERRNAME
5495 headerpick save ignore status in-reply-to
5496 '"${2}"'
5497 echo 4:$?/$^ERRNAME
5498 #' | ${MAILX} ${ARGS} -f ${a} ./.tmbox > ./.tall 2>&1
5499 return ${?}
5502 t_it 7 'save ./.tout'
5503 check_ex0 7-estat
5504 check 7-1 - ./.tall '4190949581 312'
5505 check 7-2 - ./.tout '2447734879 1316'
5506 check 7-3 - ./.tmbox '561523988 397'
5508 t_it 8 Save
5509 check_ex0 8-estat
5510 echo * > ./.tlst
5511 check 8-1 - ./.tall '2109832180 296'
5512 check 8-2 - ./mr2 '2447734879 1316'
5513 check 8-3 - ./.tlst '3190056903 4'
5514 check 8-3 - ./.tmbox '561523988 397'
5516 # saves in $MBOX without argument
5517 t_it 9 save yes
5518 check_ex0 9-estat
5519 check 9-1 - ./.tall '652005824 320'
5520 check 9-2 - ./.tmboxx '2447734879 1316'
5521 check 9-3 - ./.tmbox '561523988 397'
5523 # and deletes if editing a primary mailbox
5524 ${rm} -f ./.tmboxx
5525 t_it 10 save yes yes
5526 check_ex0 10-estat
5527 check 10-1 - ./.tall '652005824 320'
5528 check 10-2 - ./.tmboxx '2447734879 1316'
5529 [ -f ./.tmbox ]; check_exn0 10-3
5531 t_epilog "${@}"
5532 } # }}}
5534 t_move() { # {{{
5535 t_prolog "${@}"
5537 t__gen_msg subject Move1 from 1 to 1 body 'Body1' > "${MBOX}"
5538 t__gen_msg subject Move2 from 1 to 1 body 'Body2' >> "${MBOX}"
5539 check 1 - "${MBOX}" '2967134193 324' # for flag test
5542 </dev/null ${MAILX} ${ARGS} -f \
5543 -Y '#
5544 headers
5545 move 10 .tf1
5546 echo 0:$?/$^ERRNAME
5547 headers
5548 move .tf1
5549 echo 1:$?/$^ERRNAME
5550 headers
5551 !touch .tf2; '"${chmod}"' 0444 .tf2
5552 move 2 .tf2
5553 echo 2:$?/$^ERRNAME
5554 !'"${chmod}"' 0644 .tf2
5555 move 2 .tf2
5556 echo 3:$?/$^ERRNAME
5557 headers
5558 #' \
5559 "${MBOX}" > ./.tallx 2>./.terr
5560 check_ex0 2
5562 if have_feat uistrings; then # TODO
5563 ${sed} -e '$bP' -e d -e :P < ./.tallx >> "${ERR}"
5564 ${sed} '$d' < ./.tallx > ./.tall
5565 else
5566 ${mv} ./.tallx ./.tall
5568 if [ -n "${HONOURS_READONLY}" ]; then
5569 n2_1=2-1 cs2_1='1641443074 491'
5570 n2_4=2-4 cs2_4='602144474 155'
5571 else
5572 n2_1=2-1-nrdonly cs2_1='3045412111 492'
5573 n2_4=2-4-nrdonly cs2_4='2197157669 201'
5575 check ${n2_1} - ./.tall "${cs2_1}"
5576 check 2-2 - ./.tf1 '1473857906 162'
5577 check 2-3 - ./.tf2 '331229810 162'
5578 if have_feat uistrings; then
5579 check ${n2_4} - ./.terr "${cs2_4}"
5580 else
5581 t_echoskip '2-4:[!UISTRINGS]'
5585 check 3 - "${MBOX}" '4294967295 0'
5588 t_it() {
5589 t__gen_msg subject Move1 from 1 to 1 body 'Body1' > "${MBOX}"
5590 t__gen_msg subject Move2 from 1 to 1 body 'Body2' >> "${MBOX}"
5591 t__gen_msg subject Move3 from ex@am.ple to 1 body 'Body3' >> "${MBOX}"
5592 check ${1} - "${MBOX}" '2826896131 473' # for flag test
5594 </dev/null ${MAILX} ${ARGS} -f \
5595 -Y "${3}"'
5596 '"${2}"'
5597 Move
5598 echo 1:$?/$^ERRNAME
5599 '"${2}"'
5600 Move 2
5601 echo 2:$?/$^ERRNAME
5602 '"${2}"'
5603 Move 3
5604 echo 3:$?/$^ERRNAME
5605 '"${2}"'
5606 undelete *
5607 echo 4:$?/$^ERRNAME
5608 '"${2}"'
5609 Move *
5610 echo 5:$?/$^ERRNAME
5611 '"${2}"'
5612 #' \
5613 "${MBOX}" > ./.tallx 2>./.terr
5614 return ${?}
5617 t_it 5 headers '#'
5618 check_ex0 5-1
5619 if have_feat uistrings; then # TODO
5620 ${sed} -e '$bP' -e d -e :P < ./.tallx >> "${ERR}"
5621 ${sed} '$d' < ./.tallx > ./.tall
5622 else
5623 ${mv} ./.tallx ./.tall
5625 echo * > ./.tlst
5626 check 5-2 - ./.tlst '1058655452 9'
5627 check 5-3 - ./.tall '419037676 870'
5628 if have_feat uistrings; then
5629 check 5-4 - ./.terr '1383646464 86'
5630 else
5631 t_echoskip '5-4:[!UISTRINGS]'
5633 check 5-5 - ./from1 '3719268580 827'
5634 check 5-6 - ./ex '4262925856 149'
5635 ${rm} -f ./.tlst ./.tall ./.terr ./from1 ./ex
5637 ${mkdir} .tfolder
5638 t_it 6 '#' 'set outfolder folder='"`${pwd}`"'/.tfolder'
5639 check_ex0 6-1
5640 if have_feat uistrings; then # TODO
5641 ${sed} -e '$bP' -e d -e :P < ./.tallx >> "${ERR}"
5642 ${sed} '$d' < ./.tallx > ./.tall
5643 else
5644 ${mv} ./.tallx ./.tall
5646 echo * .tfolder/* > ./.tlst
5647 check 6-2 - ./.tlst '1865898363 29'
5648 ${cat} ./.tall >> ${ERR} #check 6-3 - ./.tall # TODO due to folder echoes
5649 check 6-4 - .tfolder/from1 '3719268580 827'
5650 check 6-5 - .tfolder/ex '4262925856 149'
5653 t__x2_msg > ./.tmbox
5655 t_it() {
5656 printf '#
5657 '"${1}"'
5658 echo 1:$?/$^ERRNAME
5659 headerpick save retain cc date from subject to
5660 '"${1}"'
5661 echo 2:$?/$^ERRNAME
5662 unheaderpick save retain *
5663 '"${1}"'
5664 echo 3:$?/$^ERRNAME
5665 headerpick save ignore status in-reply-to
5666 '"${1}"'
5667 echo 4:$?/$^ERRNAME
5668 #' | ${MAILX} ${ARGS} -Rf ./.tmbox > ./.tall 2>&1
5669 return ${?}
5672 t_it 'move ./.tout'
5673 check_ex0 7-estat
5674 check 7-1 - ./.tall '3805176908 152'
5675 check 7-2 - ./.tout '2447734879 1316'
5677 t_it Move
5678 check_ex0 8-estat
5679 echo * > ./.tlst
5680 check 8-1 - ./.tall '1044700686 136'
5681 check 8-2 - ./mr2 '2447734879 1316'
5682 check 8-3 - ./.tlst '3190056903 4'
5684 t_epilog "${@}"
5685 } # }}}
5687 t_mbox() { # {{{
5688 t_prolog "${@}"
5692 while [ ${i} -lt 113 ]; do
5693 printf 'm file://%s\n~s Subject %s\nHello %s!\n~.\n' \
5694 "${MBOX}" "${i}" "${i}"
5695 i=`add ${i} 1`
5696 done
5697 ) | ${MAILX} ${ARGS} > .tall 2>&1
5698 check 1 0 "${MBOX}" '1785801373 13336'
5699 check 1-outerr - ./.tall '4294967295 0' # empty file
5701 printf 'File "%s"\ncopy * "%s"\nFile "%s"\nfrom*' "${MBOX}" .tmbox1 .tmbox1 |
5702 ${MAILX} ${ARGS} -Sshowlast > .tall 2>&1
5703 check 2 0 .tall '3467540956 8991'
5705 printf 'File "%s"\ncopy * "file://%s"\nFile "file://%s"\nfrom*' \
5706 "${MBOX}" .tmbox2 .tmbox2 | ${MAILX} ${ARGS} -Sshowlast > .tall 2>&1
5707 check 3 0 .tall '2410946529 8998'
5709 # copy only the odd (but the first), move the even
5711 printf 'File "file://%s"\ncopy ' .tmbox2
5713 while [ ${i} -lt 113 ]; do
5714 printf '%s ' "${i}"
5715 i=`add ${i} 2`
5716 done
5717 printf 'file://%s\nFile "file://%s"\nfrom*' .tmbox3 .tmbox3
5718 ) | ${MAILX} ${ARGS} -Sshowlast > .tall 2>&1
5719 check 4 0 .tmbox3 '2554734733 6666'
5720 check 5 - .tall '2062382804 4517'
5721 # ...
5723 printf 'file "file://%s"\nmove ' .tmbox2
5725 while [ ${i} -lt 113 ]; do
5726 printf '%s ' "${i}"
5727 i=`add ${i} 2`
5728 done
5729 printf 'file://%s\nFile "file://%s"\nfrom*\nFile "file://%s"\nfrom*' \
5730 .tmbox3 .tmbox3 .tmbox2
5731 ) | ${MAILX} ${ARGS} -Sshowlast > .tall 2>>${ERR}
5732 check 6 0 .tmbox3 '1429216753 13336'
5733 if have_feat uistrings; then
5734 ${sed} 2d < .tall > .tallx
5735 else
5736 ${cp} .tall .tallx
5738 check 7 - .tallx '169518319 13477'
5740 # Invalid MBOXes (after [f4db93b3])
5741 echo > .tinvmbox
5742 printf 'copy 1 ./.tinvmbox' | ${MAILX} ${ARGS} -Rf "${MBOX}" > .tall 2>&1
5743 check 8 0 .tinvmbox '2848412822 118'
5744 check 9 - ./.tall '461280182 33'
5746 echo ' ' > .tinvmbox
5747 printf 'copy 1 ./.tinvmbox' | ${MAILX} ${ARGS} -Rf "${MBOX}" > .tall 2>&1
5748 check 10 0 .tinvmbox '624770486 120'
5749 check 11 - ./.tall '461280182 33'
5751 { echo; echo; } > .tinvmbox # (not invalid)
5752 printf 'copy 1 ./.tinvmbox' | ${MAILX} ${ARGS} -Rf "${MBOX}" > .tall 2>&1
5753 check 12 0 .tinvmbox '1485640875 119'
5754 check 13 - ./.tall '461280182 33'
5756 # *mbox-rfc4155*, plus
5757 ${cat} <<-_EOT > ./.tinv1
5760 From MAILER-DAEMON-1 Wed Oct 2 01:50:07 1996
5761 Date: Wed, 02 Oct 1996 01:50:07 +0000
5763 Subject: Bad bad message 1
5765 From me to you, blinde Kuh!
5767 From MAILER-DAEMON-2 Wed Oct 2 01:50:07 1996
5768 Date: Wed, 02 Oct 1996 01:50:07 +0000
5770 Subject: Bad bad message 2
5772 From me to you, blindes Kalb!
5773 _EOT
5774 ${cp} ./.tinv1 ./.tinv2
5776 printf \
5777 'define mboxfix {
5778 \\localopts yes; \\wysh set mbox-rfc4155;\\wysh File "${1}";\\
5779 \\eval copy * "${2}"
5781 call mboxfix ./.tinv1 ./.tok' | ${MAILX} ${ARGS} > .tall 2>&1
5782 check_ex0 14-estat
5783 ${cat} ./.tinv1 ./.tok >> .tall
5784 check 14 - ./.tall '739301109 616'
5786 printf \
5787 'wysh file ./.tinv1 # ^From not repaired, but missing trailing NL is
5788 wysh File ./.tok # Just move away to nowhere
5789 set mbox-rfc4155
5790 wysh file ./.tinv2 # Fully repaired
5791 File ./.tok' | ${MAILX} ${ARGS} >>${ERR} 2>&1
5792 check_ex0 15-estat
5793 # Equal since [Auto-fix when MBOX had From_ errors on read (Dr. Werner
5794 # Fink).]
5795 check 15-1 - ./.tinv1 '4151504442 314'
5796 check 15-2 - ./.tinv2 '4151504442 314'
5798 # *mbox-fcc-and-pcc*
5799 ${cat} > ./.ttmpl <<-'_EOT'
5800 Fcc: ./.tfcc1
5801 Bcc: | cat >> ./.tpcc1
5802 Fcc: ./.tfcc2
5803 Subject: fcc and pcc, and *mbox-fcc-and-pcc*
5805 one line body
5806 _EOT
5808 < ./.ttmpl ${MAILX} ${ARGS} -t > "${MBOX}" 2>&1
5809 check 16 0 "${MBOX}" '4294967295 0'
5810 check 17 - ./.tfcc1 '2301294938 148'
5811 check 18 - ./.tfcc2 '2301294938 148'
5812 check 19 - ./.tpcc1 '2301294938 148'
5814 < ./.ttmpl ${MAILX} ${ARGS} -t -Snombox-fcc-and-pcc > "${MBOX}" 2>&1
5815 check 20 0 "${MBOX}" '4294967295 0'
5816 check 21 - ./.tfcc1 '3629108107 98'
5817 check 22 - ./.tfcc2 '3629108107 98'
5818 check 23 - ./.tpcc1 '2373220256 246'
5820 # More invalid: since in "copy * X" messages will be copied in `sort' order,
5821 # reordering may happen, and before ([f5db11fe] (a_cwrite_save1(): FIX:
5822 # ensure pre-v15 MBOX separation "in between" messages.., 2019-08-07) that
5823 # could still have created invalid MBOX files!
5824 ${cat} <<-_EOT > ./.tinv1
5827 From MAILER-DAEMON-4 Sun Oct 4 01:50:07 1998
5828 Date: Sun, 04 Oct 1998 01:50:07 +0000
5829 Subject: h4
5833 From MAILER-DAEMON-0 Fri Oct 28 21:02:21 2147483649
5834 Date: Nix, 01 Oct BAD 01:50:07 +0000
5835 Subject: hinvalid
5837 BINV
5839 From MAILER-DAEMON-3 Fri Oct 3 01:50:07 1997
5840 Date: Fri, 03 Oct 1997 01:50:07 +0000
5841 Subject: h3
5845 From MAILER-DAEMON-1 Sun Oct 1 01:50:07 1995
5846 Date: Sun, 01 Oct 1995 01:50:07 +0000
5847 Subject:h1
5852 From MAILER-DAEMON-2 Wed Oct 2 01:50:07 1996
5853 Date: Wed, 02 Oct 1996 01:50:07 +0000
5854 Subject: h2
5857 _EOT
5859 printf \
5860 'File ./.tinv1
5861 sort date
5862 remove ./.tinv2
5863 copy * ./.tinv2
5864 file ./.tinv1' | ${MAILX} ${ARGS} >>${ERR} 2>&1
5865 check 24 0 ./.tinv1 '104184185 560'
5866 check 25 - ./.tinv2 '853754737 510'
5868 t_epilog "${@}"
5869 } # }}}
5871 t_maildir() { # {{{
5872 t_prolog "${@}"
5874 if have_feat maildir; then :; else
5875 t_echoskip '[!MAILDIR]'
5876 t_epilog "${@}"
5877 return
5882 while [ ${i} -lt 112 ]; do
5883 printf 'm file://%s\n~s Subject %s\nHello %s!\n~.\n' \
5884 "${MBOX}" "${i}" "${i}"
5885 i=`add ${i} 1`
5886 done
5887 ) | ${MAILX} ${ARGS}
5888 check 1 0 "${MBOX}" '2366902811 13332'
5890 printf 'File "%s"
5891 copy * "%s"
5892 File "%s"
5893 from*
5894 ' "${MBOX}" .tmdir1 .tmdir1 |
5895 ${MAILX} ${ARGS} -Snewfolders=maildir -Sshowlast > .tlst
5896 check 2 0 .tlst '3442251309 8991'
5898 printf 'File "%s"
5899 copy * "maildir://%s"
5900 File "maildir://%s"
5901 from*
5902 ' "${MBOX}" .tmdir2 .tmdir2 |
5903 ${MAILX} ${ARGS} -Sshowlast > .tlst
5904 check 3 0 .tlst '3524806062 9001'
5906 printf 'File "maildir://%s"
5907 copy * "file://%s"
5908 File "file://%s"
5909 from*
5910 ' .tmdir2 .tmbox1 .tmbox1 |
5911 ${MAILX} ${ARGS} -Sshowlast > .tlst
5912 check 4 0 .tmbox1 '4096198846 12772'
5913 check 5 - .tlst '1262452287 8998'
5915 # only the odd (even)
5917 printf 'File "maildir://%s"
5918 copy ' .tmdir2
5920 while [ ${i} -lt 112 ]; do
5921 j=`modulo ${i} 2`
5922 [ ${j} -eq 1 ] && printf '%s ' "${i}"
5923 i=`add ${i} 1`
5924 done
5925 printf ' file://%s
5926 File "file://%s"
5927 from*
5928 ' .tmbox2 .tmbox2
5929 ) | ${MAILX} ${ARGS} -Sshowlast > .tlst
5930 check 6 0 .tmbox2 '4228337024 6386'
5931 check 7 - .tlst '2078821439 4517'
5932 # ...
5934 printf 'file "maildir://%s"
5935 move ' .tmdir2
5937 while [ ${i} -lt 112 ]; do
5938 j=`modulo ${i} 2`
5939 [ ${j} -eq 0 ] && [ ${i} -ne 0 ] && printf '%s ' "${i}"
5940 i=`add ${i} 1`
5941 done
5942 printf ' file://%s
5943 File "file://%s"
5944 from*
5945 File "maildir://%s"
5946 from*
5947 ' .tmbox2 .tmbox2 .tmdir2
5948 ) | ${MAILX} ${ARGS} -Sshowlast > .tlst
5949 check 8 0 .tmbox2 '978751761 12656'
5950 ${sed} 2d < .tlst > .tlstx
5951 check 9 - .tlstx '2172297531 13477'
5953 # More invalid: since in "copy * X" messages will be copied in `sort' order,
5954 # reordering may happen, and before ([f5db11fe] (a_cwrite_save1(): FIX:
5955 # ensure pre-v15 MBOX separation "in between" messages.., 2019-08-07) that
5956 # could still have created invalid MBOX files!
5957 ${cat} <<-_EOT > ./.tinv1
5960 From MAILER-DAEMON-4 Sun Oct 4 01:50:07 1998
5961 Date: Sun, 04 Oct 1998 01:50:07 +0000
5962 Subject: h4
5966 From MAILER-DAEMON-0 Fri Oct 28 21:02:21 2147483649
5967 Date: Nix, 01 Oct BAD 01:50:07 +0000
5968 Subject: hinvalid
5970 BINV
5972 From MAILER-DAEMON-3 Fri Oct 3 01:50:07 1997
5973 Date: Fri, 03 Oct 1997 01:50:07 +0000
5974 Subject: h3
5978 From MAILER-DAEMON-1 Sun Oct 1 01:50:07 1995
5979 Date: Sun, 01 Oct 1995 01:50:07 +0000
5980 Subject:h1
5985 From MAILER-DAEMON-2 Wed Oct 2 01:50:07 1996
5986 Date: Wed, 02 Oct 1996 01:50:07 +0000
5987 Subject: h2
5990 _EOT
5992 printf \
5993 'File ./.tinv1
5994 sort date
5995 copy * maildir://./.tmdir10
5996 !{ for f in ./.tmdir10/new/*; do echo ===; %s $f; done; } > ./.t11
5997 File ./.tmdir10
5998 sort date
5999 copy * ./.t10warp
6000 ' "${cat}" | ${MAILX} ${ARGS} >>${ERR} 2>&1
6001 # Note that substdate() fixes all but one From_ line to $SOURCE_DATE_EPOCH!
6002 check 10 0 ./.t10warp '3551111321 502'
6003 check 11 - ./.t11 '642719592 302'
6005 t_epilog "${@}"
6006 } # }}}
6007 # }}}
6009 # MIME and RFC basics {{{
6010 t_mime_if_not_ascii() {
6011 t_prolog "${@}"
6013 </dev/null ${MAILX} ${ARGS} -s Subject "${MBOX}" >> "${MBOX}" 2>&1
6014 check 1 0 "${MBOX}" '3647956381 106'
6016 </dev/null ${MAILX} ${ARGS} -Scharset-7bit=not-ascii -s Subject "${MBOX}" \
6017 >> "${MBOX}" 2>&1
6018 check 2 0 "${MBOX}" '3964303752 274'
6020 t_epilog "${@}"
6023 t_mime_encoding() {
6024 t_prolog "${@}"
6026 # 8B
6027 printf 'Hey, you.\nFrom me to you\nCiao\n' |
6028 ${MAILX} ${ARGS} -s Subject -Smime-encoding=8b "${MBOX}" \
6029 >> "${MBOX}" 2>&1
6030 check 1 0 "${MBOX}" '3835153597 136'
6031 printf 'Hey, you.\n\nFrom me to you\nCiao.\n' |
6032 ${MAILX} ${ARGS} -s Subject -Smime-encoding=8b "${MBOX}" \
6033 >> "${MBOX}" 2>&1
6034 check 2 0 "${MBOX}" '63875210 275'
6036 # QP
6037 printf 'Hey, you.\n From me to you\nCiao\n' |
6038 ${MAILX} ${ARGS} -s Subject -Smime-encoding=qp "${MBOX}" \
6039 >> "${MBOX}" 2>&1
6040 check 3 0 "${MBOX}" '465798521 412'
6041 printf 'Hey, you.\nFrom me to you\nCiao\n' |
6042 ${MAILX} ${ARGS} -s Subject -Smime-encoding=qp "${MBOX}" \
6043 >> "${MBOX}" 2>&1
6044 check 4 0 "${MBOX}" '2075263697 655'
6046 # B64
6047 printf 'Hey, you.\n From me to you\nCiao\n' |
6048 ${MAILX} ${ARGS} -s Subject -Smime-encoding=b64 "${MBOX}" \
6049 >> "${MBOX}" 2>&1
6050 check 5 0 "${MBOX}" '601672771 792'
6051 printf 'Hey, you.\nFrom me to you\nCiao\n' |
6052 ${MAILX} ${ARGS} -s Subject -Smime-encoding=b64 "${MBOX}" \
6053 >> "${MBOX}" 2>&1
6054 check 6 0 "${MBOX}" '3926760595 1034'
6056 t_epilog "${@}"
6059 t_xxxheads_rfc2047() {
6060 t_prolog "${@}"
6062 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
6063 -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̲' \
6064 "${MBOX}"
6065 check 1 0 "${MBOX}" '3422562347 371'
6067 # Single word (overlong line split -- bad standard! Requires injection of
6068 # artificial data!! But can be prevented by using RFC 2047 encoding)
6069 ${rm} "${MBOX}"
6070 i=`${awk} 'BEGIN{for(i=0; i<92; ++i) printf "0123456789_"}'`
6071 echo | ${MAILX} ${ARGS} -s "${i}" "${MBOX}"
6072 check 2 0 "${MBOX}" '3317256266 1714'
6074 # Combination of encoded words, space and tabs of varying sort
6075 ${rm} "${MBOX}"
6076 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
6077 -s "1Abrä Kaspas1 2Abra Katä b_kaspas2 \
6078 3Abrä Kaspas3 4Abrä Kaspas4 5Abrä Kaspas5 \
6079 6Abra Kaspas6 7Abrä Kaspas7 8Abra Kaspas8 \
6080 9Abra Kaspastäb4-3 10Abra Kaspas1 _ 11Abra Katäb1 \
6081 12Abra Kadabrä1 After Tab after Täb this is NUTS" \
6082 "${MBOX}"
6083 check 3 0 "${MBOX}" '786672837 587'
6085 # Overlong multibyte sequence that must be forcefully split
6086 # todo This works even before v15.0, but only by accident
6087 ${rm} "${MBOX}"
6088 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
6089 -s "✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
6090 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
6091 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄" \
6092 "${MBOX}"
6093 check 4 0 "${MBOX}" '2889557767 655'
6095 # Trailing WS
6096 ${rm} "${MBOX}"
6097 echo | ${MAILX} ${ARGS} \
6098 -s "1-1 B2 B3 B4 B5 B6 B\
6099 1-2 B2 B3 B4 B5 B6 B\
6100 1-3 B2 B3 B4 B5 B6 B\
6101 1-4 B2 B3 B4 B5 B6 B\
6102 1-5 B2 B3 B4 B5 B6 B\
6103 1-6 B2 B3 B4 B5 B6 " \
6104 "${MBOX}"
6105 check 5 0 "${MBOX}" '3135161683 293'
6107 # Leading and trailing WS
6108 ${rm} "${MBOX}"
6109 echo | ${MAILX} ${ARGS} \
6110 -s " 2-1 B2 B3 B4 B5 B6 B\
6111 1-2 B2 B3 B4 B5 B6 B\
6112 1-3 B2 B3 B4 B5 B6 B\
6113 1-4 B2 B3 B4 B5 B6 " \
6114 "${MBOX}"
6115 check 6 0 "${MBOX}" '3221845405 232'
6117 # RFC 2047 in an address field! (Missing test caused v14.9.6!)
6118 ${rm} "${MBOX}"
6119 echo "Dat Früchtchen riecht häußlich" |
6120 ${MAILX} ${ARGS} ${ADDARG_UNI} -Sfullnames -Smta=test://"$MBOX" \
6121 -s Hühöttchen \
6122 'Schnödes "Früchtchen" <do@du> (Hä!)'
6123 check 7 0 "${MBOX}" '3681801246 373'
6125 # RFC 2047 in an address field, and iconv involved
6126 if have_feat iconv; then
6127 ${rm} "${MBOX}"
6128 ${cat} > ./.trebox <<_EOT
6129 From zaza@exam.ple Fri Mar 2 21:31:56 2018
6130 Date: Fri, 2 Mar 2018 20:31:45 +0000
6131 From: z=?iso-8859-1?Q?=E1?=za <zaza@exam.ple>
6132 To: dude <dude@exam.ple>
6133 Subject: houston(...)
6134 Message-ID: <abra@1>
6135 MIME-Version: 1.0
6136 Content-Type: text/plain; charset=iso-8859-1
6137 Content-Disposition: inline
6138 Content-Transfer-Encoding: 8bit
6140 _EOT
6141 echo reply | ${MAILX} ${ARGS} ${ADDARG_UNI} \
6142 -Sfullnames -Sreply-in-same-charset \
6143 -Smta=test://"$MBOX" -Rf ./.trebox
6144 check 8 0 "${MBOX}" '3499372945 285'
6145 else
6146 t_echoskip '8:[!ICONV]'
6149 t_epilog "${@}"
6152 t_iconv_mbyte_base64() { # TODO uses sed(1) and special *headline*!!
6153 t_prolog "${@}"
6155 if [ -n "${UTF8_LOCALE}" ] && have_feat multibyte-charsets &&
6156 have_feat iconv; then
6157 if (</dev/null iconv -f ascii -t iso-2022-jp) >/dev/null 2>&1 ||
6158 (</dev/null iconv -f ascii -t euc-jp) >/dev/null 2>&1; then
6160 else
6161 t_echoskip '[ICONV/iconv(1):missing conversion(s)]'
6162 t_epilog "${@}"
6163 return
6165 else
6166 t_echoskip '[no UTF-8 locale or !MULTIBYTE-CHARSETS or !ICONV]'
6167 t_epilog "${@}"
6168 return
6171 if (</dev/null iconv -f ascii -t iso-2022-jp) >/dev/null 2>&1; then
6172 ${cat} <<-'_EOT' | LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} \
6173 -Smta=test://"$MBOX" \
6174 -Sescape=! -Smime-encoding=base64 2>./.terr
6175 set ttycharset=utf-8 sendcharsets=iso-2022-jp
6176 m t1@exam.ple
6177 !s Japanese from UTF-8 to ISO-2022-JP
6178 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
6180 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
6183 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
6185 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
6188 set ttycharset=iso-2022-jp charset-7bit=iso-2022-jp sendcharsets=utf-8
6189 m t2@exam.ple
6190 !s Japanese from ISO-2022-JP to UTF-8, eh, no, also ISO-2022-JP
6191 \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
6193 \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
6196 \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
6198 \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
6200 _EOT
6201 # May not presume iconv output as long as roundtrip possible [489a7122]
6202 check_ex0 1-estat
6203 ${awk} 'BEGIN{h=1}/^$/{++h;next}{if(h % 2 == 1)print}' \
6204 < "${MBOX}" > ./.tcksum
6205 check 1 - ./.tcksum '3314001564 516'
6206 check 2 - ./.terr '4294967295 0'
6208 printf 'eval f 1; eval write ./.twrite; eval type 1; eval type 2\n' |
6209 LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} \
6210 -S headline="%>%a%m %-18f %-16d %i%-s" \
6211 -Rf "${MBOX}" >./.tlog 2>&1
6212 check 3 0 ./.twrite '1259742080 686'
6213 #check 4 - ./.tlog '3214068822 2123'
6214 ${sed} -e '/^\[-- M/d' < ./.tlog > ./.txlog
6215 check 4 - ./.txlog '4083300132 2030'
6216 else
6217 t_echoskip '1-4:[ICONV/iconv(1):ISO-2022-JP unsupported]'
6220 if (</dev/null iconv -f ascii -t euc-jp) >/dev/null 2>&1; then
6221 ${rm} -f "${MBOX}" ./.twrite
6222 ${cat} <<-'_EOT' | LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} \
6223 -Smta=test://"$MBOX" \
6224 -Sescape=! -Smime-encoding=base64 2>./.terr
6225 set ttycharset=utf-8 sendcharsets=euc-jp
6226 m t1@exam.ple
6227 !s Japanese from UTF-8 to EUC-JP
6228 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
6230 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
6233 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
6235 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
6238 set ttycharset=EUC-JP sendcharsets=utf-8
6239 m t2@exam.ple
6240 !s Japanese from EUC-JP to UTF-8
6241 ¥·¥¸¥å¥¦¥«¥é²Ê¡Ê¥·¥¸¥å¥¦¥«¥é¤«¡¢³Ø̾ Paridae¡Ë¤Ï¡¢Ä»Îॹ¥º¥áÌܤβʤǤ¢¤ë¡£¥·¥¸¥å¥¦¥«¥é¡Ê»Í½½¿ý¡Ë¤ÈÁí¾Î¤µ¤ì¤ë¤¬¡¢¶¹µÁ¤Ë¤Ï¤³¤Î1¼ï¤ò¥·¥¸¥å¥¦¥«¥é¤È¸Æ¤Ö¡£
6243 ¥«¥ó¥à¥ê¥¬¥é¡Ê³Ø̾Parus cristatus¡Ë¤Ï¡¢¥¹¥º¥áÌÜ¥·¥¸¥å¥¦¥«¥é²Ê¤ËʬÎव¤ì¤ëÄ»Îà¤Î°ì¼ï¡£
6246 ¥«¥ó¥à¥ê¥¬¥é¡Ê³Ø̾Parus cristatus¡Ë¤Ï¡¢¥¹¥º¥áÌÜ¥·¥¸¥å¥¦¥«¥é²Ê¤ËʬÎव¤ì¤ëÄ»Îà¤Î°ì¼ï¡£
6248 ¥·¥¸¥å¥¦¥«¥é²Ê¡Ê¥·¥¸¥å¥¦¥«¥é¤«¡¢³Ø̾ Paridae¡Ë¤Ï¡¢Ä»Îॹ¥º¥áÌܤβʤǤ¢¤ë¡£¥·¥¸¥å¥¦¥«¥é¡Ê»Í½½¿ý¡Ë¤ÈÁí¾Î¤µ¤ì¤ë¤¬¡¢¶¹µÁ¤Ë¤Ï¤³¤Î1¼ï¤ò¥·¥¸¥å¥¦¥«¥é¤È¸Æ¤Ö¡£
6250 _EOT
6251 check_ex0 5-estat
6252 ${awk} 'BEGIN{h=1}/^$/{++h;next}{if(h % 2 == 1)print}' \
6253 < "${MBOX}" > ./.tcksum
6254 check 5 - ./.tcksum '1754179361 469'
6255 check 6 - ./.terr '4294967295 0'
6257 printf 'eval f 1; eval write ./.twrite; eval type 1; eval type 2\n' |
6258 LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} \
6259 -S headline="%>%a%m %-18f %-16d %i%-s" \
6260 -Rf "${MBOX}" >./.tlog 2>&1
6261 check 7 0 ./.twrite '1259742080 686'
6262 #check 8 - ./.tlog '2506063395 2075'
6263 ${sed} -e '/^\[-- M/d' < ./.tlog > ./.txlog
6264 check 8 - ./.txlog '3192017734 1983'
6265 else
6266 t_echoskip '5-8:[ICONV/iconv(1):EUC-JP unsupported]'
6269 t_epilog "${@}"
6272 t_iconv_mainbody() {
6273 t_prolog "${@}"
6275 if [ -n "${UTF8_LOCALE}" ] && have_feat iconv; then :; else
6276 t_echoskip '[no UTF-8 locale or !ICONV]'
6277 t_epilog "${@}"
6278 return
6281 printf '–' | ${MAILX} ${ARGS} ${ADDARG_UNI} -Smta=test://"$MBOX" \
6282 -S charset-7bit=us-ascii -S charset-8bit=utf-8 \
6283 -s '–' over-the@rain.bow 2>./.terr
6284 check 1 0 "${MBOX}" '3559538297 250'
6285 check 2 - ./.terr '4294967295 0'
6287 printf '–' | ${MAILX} ${ARGS} ${ADDARG_UNI} -Smta=test://"$MBOX" \
6288 -S charset-7bit=us-ascii -S charset-8bit=us-ascii \
6289 -s '–' over-the@rain.bow 2>./.terr
6290 check_exn0 3
6291 check 3 - "${MBOX}" '3559538297 250'
6292 if have_feat uistrings; then
6293 check 4 - ./.terr '271380835 121'
6294 else
6295 t_echoskip '4:[!UISTRINGS]'
6298 # The different iconv(3) implementations use different replacement sequence
6299 # types (character-wise, byte-wise, and the character(s) used differ)
6300 i="${MAILX_ICONV_MODE}"
6301 if [ -n "${i}" ]; then
6302 printf 'p\nx\n' | ${MAILX} ${ARGS} -Rf "${MBOX}" >./.tout 2>./.terr
6303 j=${?}
6304 check_ex0 5-1-estat ${j}
6305 check 5-1 - ./.terr '4294967295 0'
6306 if [ ${i} -eq 13 ]; then
6307 check 5-2 - ./.tout '189327996 283' # XXX old (before test MTA)
6308 elif [ ${i} -eq 12 ]; then
6309 check 5-3 - ./.tout '1959197095 283' # XXX old (before test MTA)
6310 elif [ ${i} -eq 3 ]; then
6311 check 5-4 - ./.tout '3544755786 278'
6312 else
6313 check 5-5 - ./.tout '2381160335 278'
6315 else
6316 t_echoskip '5:[test unsupported]'
6319 t_epilog "${@}"
6322 t_binary_mainbody() {
6323 t_prolog "${@}"
6325 printf 'abra\0\nka\r\ndabra' |
6326 ${MAILX} ${ARGS} ${ADDARG_UNI} -s 'binary with carriage-return!' \
6327 "${MBOX}" 2>./.terr
6328 check 1 0 "${MBOX}" '1629827 239'
6329 check 2 - ./.terr '4294967295 0'
6331 printf 'p\necho\necho writing now\nwrite ./.twrite\n' |
6332 ${MAILX} ${ARGS} -Rf \
6333 -Spipe-application/octet-stream="?* ${cat} > ./.tcat" \
6334 "${MBOX}" >./.tall 2>&1
6335 check 3 0 ./.tall '733582513 319'
6336 check 4 - ./.tcat '3817108933 15'
6337 check 5 - ./.twrite '3817108933 15'
6339 t_epilog "${@}"
6342 t_mime_force_sendout() {
6343 t_prolog "${@}"
6345 if have_feat iconv; then :; else
6346 t_echoskip '[!ICONV]'
6347 t_epilog "${@}"
6348 return
6351 printf '\150\303\274' > ./.tmba
6352 printf 'ha' > ./.tsba
6353 printf '' > "${MBOX}"
6355 printf '\150\303\244' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
6356 -s nogo \
6357 over-the@rain.bow 2>>${ERR}
6358 check 1 4 "${MBOX}" '4294967295 0'
6360 printf '\150\303\244' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
6361 -s go -Smime-force-sendout \
6362 over-the@rain.bow 2>>${ERR}
6363 check 2 0 "${MBOX}" '1866273282 219'
6365 printf ha | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
6366 -s nogo \
6367 -a ./.tmba over-the@rain.bow 2>>${ERR}
6368 check 3 4 "${MBOX}" '1866273282 219'
6370 printf ha | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
6371 -s go -Smime-force-sendout \
6372 -a ./.tmba over-the@rain.bow 2>>${ERR}
6373 check 4 0 "${MBOX}" '644433809 880'
6375 printf ha | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
6376 -s nogo \
6377 -a ./.tsba -a ./.tmba over-the@rain.bow 2>>${ERR}
6378 check 5 4 "${MBOX}" '644433809 880'
6380 printf ha | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
6381 -s go -Smime-force-sendout \
6382 -a ./.tsba -a ./.tmba over-the@rain.bow 2>>${ERR}
6383 check 6 0 "${MBOX}" '3172365123 1729'
6385 printf '\150\303\244' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
6386 -s nogo \
6387 -a ./.tsba -a ./.tmba over-the@rain.bow 2>>${ERR}
6388 check 7 4 "${MBOX}" '3172365123 1729'
6390 printf '\150\303\244' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
6391 -s go -Smime-force-sendout \
6392 -a ./.tsba -a ./.tmba over-the@rain.bow 2>>${ERR}
6393 check 8 0 "${MBOX}" '4002905306 2565'
6395 t_epilog "${@}"
6398 t_C_opt_customhdr() {
6399 t_prolog "${@}"
6401 echo bla |
6402 ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
6403 -C 'C-One : Custom One Body' \
6404 -C 'C-Two:CustomTwoBody' \
6405 -C 'C-Three: CustomThreeBody ' \
6406 -S customhdr='chdr1: chdr1 body, chdr2:chdr2 body, chdr3: chdr3 body ' \
6407 this-goes@nowhere >./.tall 2>&1
6408 check_ex0 1-estat
6409 ${cat} ./.tall >> "${MBOX}"
6410 check 1 0 "${MBOX}" '2535463301 238'
6412 ${rm} "${MBOX}"
6413 printf 'm this-goes@nowhere\nbody\n!.
6414 unset customhdr
6415 m this-goes2@nowhere\nbody2\n!.
6416 set customhdr=%ccustom1 : custom1 body%c
6417 m this-goes3@nowhere\nbody3\n!.
6418 set customhdr=%ccustom1 : custom1\\, body , \\
6419 custom2: custom2 body , custom-3 : custom3 body ,\\
6420 custom-4:custom4-body %c
6421 m this-goes4@nowhere\nbody4\n!.
6422 ' "'" "'" "'" "'" |
6423 ${MAILX} ${ARGS} -Smta=test://"$MBOX" -Sescape=! \
6424 -C 'C-One : Custom One Body' \
6425 -C 'C-Two:CustomTwoBody' \
6426 -C 'C-Three: CustomThreeBody ' \
6427 -C ' C-Four:CustomFourBody ' \
6428 -C 'C-Five:CustomFiveBody' \
6429 -S customhdr='ch1: b1 , ch2:b2, ch3:b3 ,ch4:b4, ch5: b5 ' \
6430 >./.tall 2>&1
6431 check_ex0 2-estat
6432 ${cat} ./.tall >> "${MBOX}"
6433 check 2 0 "${MBOX}" '544085062 1086'
6435 t_epilog "${@}"
6437 # }}}
6439 # Operational basics with trivial tests {{{
6440 t_alias() {
6441 t_prolog "${@}"
6443 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" > ./.tall 2>&1
6444 alias a1 ex1@a1.ple
6445 alias a1 ex2@a1.ple "EX3 <ex3@a1.ple>"
6446 alias a1 ex4@a1.ple
6447 alias a2 ex1@a2.ple ex2@a2.ple ex3@a2.ple ex4@a2.ple
6448 alias a3 a4
6449 alias a4 a5 ex1@a4.ple
6450 alias a5 a6
6451 alias a6 a7 ex1@a6.ple
6452 alias a7 a8
6453 alias a8 ex1@a8.ple
6454 alias a1
6455 alias a2
6456 alias a3
6457 m a1
6458 ~c a2
6459 ~b a3
6460 ~r - '_EOT'
6461 This body is!
6462 This also body is!!
6463 _EOT
6464 __EOT
6465 check 1 0 "${MBOX}" '139467786 277'
6466 check 2 - .tall '1598893942 133'
6468 if have_feat uistrings; then
6469 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
6470 commandalias x echo '$?/$^ERRNAME'
6471 echo 1
6472 alias a:bra! ha@m beb@ra ha@m '' zeb@ra ha@m; x
6473 alias a:bra!; x
6474 alias ha@m ham-expansion ha@m '';x
6475 alias ha@m;x
6476 alias beb@ra ceb@ra beb@ra1;x
6477 alias beb@ra;x
6478 alias ceb@ra ceb@ra1;x
6479 alias ceb@ra;x
6480 alias deb@ris '';x
6481 alias deb@ris;x
6482 echo 2
6483 alias - a:bra!;x
6484 alias - ha@m;x
6485 alias - beb@ra;x
6486 alias - ceb@ra;x
6487 alias - deb@ris;x
6488 echo 3
6489 unalias ha@m;x
6490 alias - a:bra!;x
6491 unalias beb@ra;x
6492 alias - a:bra!;x
6493 echo 4
6494 unalias*;x;alias;x
6495 echo 5
6496 \alias noexpa@and this@error1;x
6497 \alias ha@m '\noexp@and' expa@and \\noexp@and2;x
6498 \alias ha@m;x
6499 \alias - ha@m;x
6500 \alias noexpa@and2 this@error2;x
6501 \alias expa1@and this@error3;x
6502 \alias expa@and \\expa1@and;x
6503 \alias expa@and;x
6504 \alias - ha@m;x
6505 \alias - expa@and;x
6506 __EOT
6507 check 3 0 "${MBOX}" '1513155156 796'
6508 else
6509 t_echoskip '3:[!UISTRINGS]'
6512 # TODO t_alias: n_ALIAS_MAXEXP is compile-time constant,
6513 # TODO need to somehow provide its contents to the test, then test
6515 t_epilog "${@}"
6518 t_charsetalias() {
6519 t_prolog "${@}"
6521 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
6522 commandalias x echo '$?/$^ERRNAME'
6523 echo 1
6524 charsetalias latin1 latin15;x
6525 charsetalias latin1;x
6526 charsetalias - latin1;x
6527 echo 2
6528 charsetalias cp1252 latin1 latin15 utf8 utf8 utf16;x
6529 charsetalias cp1252;x
6530 charsetalias latin15;x
6531 charsetalias utf8;x
6532 echo 3
6533 charsetalias - cp1252;x
6534 charsetalias - latin15;x
6535 charsetalias - utf8;x
6536 echo 4
6537 charsetalias latin1;x
6538 charsetalias - latin1;x
6539 uncharsetalias latin15;x
6540 charsetalias latin1;x
6541 charsetalias - latin1;x
6542 __EOT
6543 check 1 0 "${MBOX}" '3551595280 433'
6545 t_epilog "${@}"
6548 t_shortcut() {
6549 t_prolog "${@}"
6551 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
6552 commandalias x echo '$?/$^ERRNAME'
6553 echo 1
6554 shortcut file1 expansion-of-file1;x
6555 shortcut file2 expansion-of-file2;x
6556 shortcut file3 expansion-of-file3;x
6557 shortcut file4 'expansion of file4' 'file 5' 'expansion of file5';x
6558 echo 2
6559 shortcut file1;x
6560 shortcut file2;x
6561 shortcut file3;x
6562 shortcut file4;x
6563 shortcut 'file 5';x
6564 echo 3
6565 shortcut;x
6566 __EOT
6567 check 1 0 "${MBOX}" '1970515669 430'
6569 t_epilog "${@}"
6572 t_netrc() {
6573 t_prolog "${@}"
6575 if have_feat netrc; then :; else
6576 t_echoskip '[!NETRC]'
6577 t_epilog "${@}"
6578 return
6581 printf '# comment
6582 machine x.local login a1 machine x.local login a2 password p2
6583 machine x.local login a3 password "p 3"
6584 machine
6585 pop.x.local
6586 login
6588 password
6589 p2-pop!
6590 machine *.x.local login a2 password p2-any!
6591 machine y.local login ausr password apass
6592 machine
6593 z.local password
6594 noupa
6595 # and unused default
6596 default login defacc password defpass
6597 ' > ./.tnetrc
6598 ${chmod} 0600 ./.tnetrc
6600 printf 'netrc;echo =$?;netrc c;echo =$?;netr loa;echo =$?;netr s;echo =$?' |
6601 NETRC=./.tnetrc ${MAILX} ${ARGS} > "${MBOX}" 2>&1
6602 check 1 0 "${MBOX}" '2911708535 542'
6604 have_feat uistrings && i='3076722625 893' || i='3808149439 645'
6605 printf '# Comment
6606 echo ==host
6607 netrc loo x.local
6608 netrc loo y.local
6609 netrc loo z.local
6610 echo ==(re)load cache
6611 netrc load;echo $?/$^ERRNAME
6612 echo ==usr@host
6613 netrc loo a1@x.local
6614 netrc loo a2@x.local
6615 netrc loo a3@x.local
6616 netrc loo a4@x.local
6617 echo ==clear cache
6618 netrc clear;echo $?/$^ERRNAME
6619 echo ==usr@x.host
6620 netrc loo a2@pop.x.local
6621 netrc loo a2@imap.x.local
6622 netrc loo a2@smtp.x.local
6623 echo ==usr@y.x.host
6624 netrc loo a2@nono.smtp.x.local
6625 echo ==[usr@]unknown-host
6626 netrc loo a.local
6627 netrc loo defacc@a.local
6628 netrc loo a1@a.local
6629 ' | NETRC=./.tnetrc ${MAILX} ${ARGS} > "${MBOX}" 2>&1
6630 check 2 0 "${MBOX}" "${i}"
6632 t_epilog "${@}"
6634 # }}}
6636 # Operational basics with easy tests {{{
6637 t_expandaddr() {
6638 # after: t_alias
6639 # MTA alias specific part in t_mta_aliases()
6640 # This only tests from command line, rest later on (iff any)
6641 t_prolog "${@}"
6643 if have_feat uistrings; then :; else
6644 t_echoskip '[!UISTRINGS]'
6645 t_epilog "${@}"
6646 return
6649 echo "${cat}" > ./.tcat
6650 ${chmod} 0755 ./.tcat
6653 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6654 -X'alias talias talias@exam.ple' \
6655 './.tfile' ' | ./.tcat > ./.tpipe' 'talias' 'taddr@exam.ple' \
6656 > ./.tall 2>&1
6657 check 1 4 "${MBOX}" '1216011460 138'
6658 check 2 - .tall '4169590008 162'
6661 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6662 -Sexpandaddr \
6663 -X'alias talias talias@exam.ple' \
6664 './.tfile' ' | ./.tcat >./.tpipe' 'talias' 'taddr@exam.ple' \
6665 > ./.tall 2>&1
6666 check 3 0 "${MBOX}" '847567042 276'
6667 check 4 - .tall '4294967295 0'
6668 check 5 - .tfile '1216011460 138'
6669 check 6 - .tpipe '1216011460 138'
6672 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6673 -Sexpandaddr=-all,+file,+pipe,+name,+addr \
6674 -X'alias talias talias@exam.ple' \
6675 './.tfile' ' | ./.tcat >./.tpipe' 'talias' 'taddr@exam.ple' \
6676 > ./.tall 2>&1
6677 check 7 0 "${MBOX}" '3682360102 414'
6678 check 8 - .tall '4294967295 0'
6679 check 9 - .tfile '847567042 276'
6680 check 10 - .tpipe '1216011460 138'
6683 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6684 -Sexpandaddr=-all,+file,-file,+pipe,+name,+addr \
6685 -X'alias talias talias@exam.ple' \
6686 './.tfile' ' | ./.tcat >./.tpipe' 'talias' 'taddr@exam.ple' \
6687 > ./.tall 2>&1
6688 check 11 4 "${MBOX}" '1010907786 552'
6689 check 12 - .tall '673208446 70'
6690 check 13 - .tfile '847567042 276'
6691 check 14 - .tpipe '1216011460 138'
6693 printf '' > ./.tpipe
6694 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6695 -Sexpandaddr=fail,-all,+file,-file,+pipe,+name,+addr \
6696 -X'alias talias talias@exam.ple' \
6697 './.tfile' ' | ./.tcat >./.tpipe' 'talias' 'taddr@exam.ple' \
6698 > ./.tall 2>&1
6699 check 15 4 "${MBOX}" '1010907786 552'
6700 check 16 - .tall '3280630252 179'
6701 check 17 - .tfile '847567042 276'
6702 check 18 - .tpipe '4294967295 0'
6705 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6706 -Sexpandaddr=-all,+file,+pipe,-pipe,+name,+addr \
6707 -X'alias talias talias@exam.ple' \
6708 './.tfile' ' | ./.tcat >./.tpipe' 'talias' 'taddr@exam.ple' \
6709 > ./.tall 2>&1
6710 check 19 4 "${MBOX}" '3359494254 690'
6711 check 20 - .tall '4052857227 91'
6712 check 21 - .tfile '3682360102 414'
6713 check 22 - .tpipe '4294967295 0'
6715 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6716 -Sexpandaddr=fail,-all,+file,+pipe,-pipe,+name,+addr \
6717 -X'alias talias talias@exam.ple' \
6718 './.tfile' ' | ./.tcat >./.tpipe' 'talias' 'taddr@exam.ple' \
6719 > ./.tall 2>&1
6720 check 23 4 "${MBOX}" '3359494254 690'
6721 check 24 - .tall '2168069102 200'
6722 check 25 - .tfile '3682360102 414'
6723 check 26 - .tpipe '4294967295 0'
6726 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6727 -Sexpandaddr=-all,+file,+pipe,+name,-name,+addr \
6728 -X'alias talias talias@exam.ple' \
6729 './.tfile' ' | ./.tcat >./.tpipe' 'talias' 'taddr@exam.ple' \
6730 > ./.tall 2>&1
6731 check 27 0 "${MBOX}" '3735108703 828'
6732 check 28 - .tall '4294967295 0'
6733 check 29 - .tfile '1010907786 552'
6734 check 30 - .tpipe '1216011460 138'
6736 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6737 -Sexpandaddr=-all,+file,+pipe,+name,-name,+addr \
6738 './.tfile' ' | ./.tcat >./.tpipe' 'talias' 'taddr@exam.ple' \
6739 > ./.tall 2>&1
6740 check 31 4 "${MBOX}" '4225234603 949'
6741 check 32 - .tall '3486613973 73'
6742 check 33 - .tfile '452731060 673'
6743 check 34 - .tpipe '1905076731 121'
6745 printf '' > ./.tpipe
6746 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6747 -Sexpandaddr=fail,-all,+file,+pipe,+name,-name,+addr \
6748 './.tfile' ' | ./.tcat >./.tpipe' 'talias' 'taddr@exam.ple' \
6749 > ./.tall 2>&1
6750 check 35 4 "${MBOX}" '4225234603 949'
6751 check 36 - .tall '3032065285 182'
6752 check 37 - .tfile '452731060 673'
6753 check 38 - .tpipe '4294967295 0'
6756 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6757 -Sexpandaddr=-all,+file,+pipe,+name,+addr,-addr \
6758 -X'alias talias talias@exam.ple' \
6759 './.tfile' ' | ./.tcat >./.tpipe' 'talias' 'taddr@exam.ple' \
6760 > ./.tall 2>&1
6761 check 39 4 "${MBOX}" '4225234603 949'
6762 check 40 - .tall '3863610168 169'
6763 check 41 - .tfile '1975297706 775'
6764 check 42 - .tpipe '130065764 102'
6766 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6767 -Sexpandaddr=-all,+file,+pipe,+name,+addr,-addr \
6768 -Sadd-file-recipients \
6769 -X'alias talias talias@exam.ple' \
6770 './.tfile' ' | ./.tcat >./.tpipe' 'talias' 'taddr@exam.ple' \
6771 > ./.tall 2>&1
6772 check 43 4 "${MBOX}" '4225234603 949'
6773 check 44 - .tall '3863610168 169'
6774 check 45 - .tfile '3291831864 911'
6775 check 46 - .tpipe '4072000848 136'
6777 printf '' > ./.tpipe
6778 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6779 -Sexpandaddr=fail,-all,+file,+pipe,+name,+addr,-addr \
6780 -Sadd-file-recipients \
6781 -X'alias talias talias@exam.ple' \
6782 './.tfile' ' | ./.tcat >./.tpipe' 'talias' 'taddr@exam.ple' \
6783 > ./.tall 2>&1
6784 check 47 4 "${MBOX}" '4225234603 949'
6785 check 48 - .tall '851041772 278'
6786 check 49 - .tfile '3291831864 911'
6787 check 50 - .tpipe '4294967295 0'
6790 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6791 -Sexpandaddr=-all,+addr \
6792 'taddr@exam.ple' 'this@@c.example' \
6793 > ./.tall 2>&1
6794 check 51 4 "${MBOX}" '473729143 1070'
6795 check 52 - .tall '2646392129 66'
6797 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6798 -Sexpandaddr=-all,failinvaddr \
6799 'taddr@exam.ple' 'this@@c.example' \
6800 > ./.tall 2>&1
6801 check 53 4 "${MBOX}" '473729143 1070'
6802 check 54 - .tall '887391555 175'
6805 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6806 -Sthis=taddr@exam.ple -Sexpandaddr \
6807 -c '\$this' -b '\$this' '\$this' \
6808 > ./.tall 2>&1
6809 check 55 4 "${MBOX}" '473729143 1070'
6810 check 56 - .tall '1144578880 139'
6812 </dev/null ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -ssub \
6813 -Sthis=taddr@exam.ple -Sexpandaddr=shquote \
6814 -c '\$this' -b '\$this' '\$this' \
6815 > ./.tall 2>&1
6816 check 57 0 "${MBOX}" '398243793 1191'
6817 check 58 - .tall '4294967295 0'
6820 printf '' > "${MBOX}"
6821 ${cat} <<-_EOT |\
6822 ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -t -ssub \
6823 -Sadd-file-recipients \
6824 -Sexpandaddr=-all,+fcc \
6825 > ./.tall 2>&1
6826 Fcc: .tfile1
6827 Fcc: .tfile2
6828 _EOT
6829 check 59 0 "${MBOX}" '4294967295 0'
6830 check 60 - .tall '4294967295 0'
6831 check 61 - .tfile1 '1067276522 124'
6832 check 62 - .tfile2 '1067276522 124'
6834 printf '' > "${MBOX}"
6835 ${cat} <<-_EOT |\
6836 ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -t -ssub \
6837 -Sadd-file-recipients \
6838 -Sexpandaddr=-all,+file \
6839 > ./.tall 2>&1
6840 Fcc: .tfile1
6841 Fcc: .tfile2
6842 _EOT
6843 check 63 0 "${MBOX}" '4294967295 0'
6844 check 64 - .tall '4294967295 0'
6845 check 65 - .tfile1 '2677253527 248'
6846 check 66 - .tfile2 '2677253527 248'
6848 printf '' > "${MBOX}"
6849 ${cat} <<-_EOT |\
6850 ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -t -ssub \
6851 -Sadd-file-recipients \
6852 -Sexpandaddr=-all,+file,-fcc \
6853 > ./.tall 2>&1
6854 Fcc: .tfile1
6855 Fcc: .tfile2
6856 _EOT
6857 check 67 0 "${MBOX}" '4294967295 0'
6858 check 68 - .tall '4294967295 0'
6859 check 69 - .tfile1 '3493511004 372'
6860 check 70 - .tfile2 '3493511004 372'
6862 printf '' > "${MBOX}"
6863 ${cat} <<-_EOT |\
6864 ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -t -ssub \
6865 -Sadd-file-recipients \
6866 -Sexpandaddr=-all,+fcc,-file \
6867 > ./.tall 2>&1
6868 Fcc: .tfile1
6869 Fcc: .tfile2
6870 _EOT
6871 check 71 4 "${MBOX}" '4294967295 0'
6872 check 72 - .tall '203687556 223'
6873 check 73 - .tfile1 '3493511004 372'
6874 check 74 - .tfile2 '3493511004 372'
6876 printf '' > "${MBOX}"
6877 ${cat} <<-_EOT |\
6878 ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -t -ssub \
6879 -Sadd-file-recipients \
6880 -Sexpandaddr=-all,fail,+addr \
6881 > ./.tall 2>&1
6882 Fcc: .tfile1
6883 Fcc: .tfile2
6884 To: never@exam.ple
6885 _EOT
6886 check 75 4 "${MBOX}" '4294967295 0'
6887 check 76 - .tall '4060426468 247'
6888 check 77 - .tfile1 '3493511004 372'
6889 check 78 - .tfile2 '3493511004 372'
6892 printf '' > "${MBOX}"
6893 ${cat} <<-_EOT |\
6894 ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -t -ssub \
6895 -Sexpandaddr=fail,domaincheck \
6896 > ./.tall 2>&1
6897 To: one@localhost
6898 _EOT
6899 check 79 0 "${MBOX}" '171635532 120'
6900 check 80 - .tall '4294967295 0'
6902 ${cat} <<-_EOT |\
6903 ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -t -ssub \
6904 -Sexpandaddr=domaincheck \
6905 > ./.tall 2>&1
6906 To: one@localhost , Hey two <two@exam.ple>, Trouble <three@tro.uble>
6907 _EOT
6908 check 81 4 "${MBOX}" '2659464839 240'
6909 check 82 - .tall '1119895397 158'
6911 ${cat} <<-_EOT |\
6912 ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -t -ssub \
6913 -Sexpandaddr=fail,domaincheck \
6914 > ./.tall 2>&1
6915 To: one@localhost , Hey two <two@exam.ple>, Trouble <three@tro.uble>
6916 _EOT
6917 check 83 4 "${MBOX}" '2659464839 240'
6918 check 84 - .tall '1577313789 267'
6920 ${cat} <<-_EOT |\
6921 ${MAILX} ${ARGS} -Snoexpandaddr -Smta=test://"$MBOX" -t -ssub \
6922 -Sexpandaddr=fail,domaincheck \
6923 -Sexpandaddr-domaincheck=exam.ple,tro.uble \
6924 > ./.tall 2>&1
6925 To: one@localhost , Hey two <two@exam.ple>, Trouble <three@tro.uble>
6926 _EOT
6927 check 85 0 "${MBOX}" '1670655701 410'
6928 check 86 - .tall '4294967295 0'
6930 t_epilog "${@}"
6933 t_mta_aliases() {
6934 # after: t_expandaddr
6935 t_prolog "${@}"
6937 if have_feat mta-aliases; then :; else
6938 t_echoskip '[!MTA_ALIASES]'
6939 t_epilog "${@}"
6940 return
6943 ${cat} > ./.tali <<- '__EOT'
6945 # Comment
6948 a1: ex1@a1.ple ,
6949 ex2@a1.ple, <ex3@a1.ple> ,
6950 ex4@a1.ple
6951 a2: ex1@a2.ple , ex2@a2.ple,a2_2
6952 a2_2:ex3@a2.ple,ex4@a2.ple
6953 a3: a4
6954 a4: a5,
6955 # Comment
6956 # More comment
6957 ex1@a4.ple
6958 # Comment
6959 a5: a6
6960 a6: a7 , ex1@a6.ple
6961 a7: a8,a9
6962 a8: ex1@a8.ple
6963 __EOT
6965 echo | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
6966 -Smta-aliases=./.tali \
6967 -b a3 -c a2 a1 > ./.tall 2>&1
6968 check 1 0 "${MBOX}" '1172368381 238'
6969 check 2 - .tall '4294967295 0'
6971 ## xxx The following are actually *expandaddr* tests!!
6973 # May not send plain names over SMTP!
6974 mtaali=
6975 if have_feat smtp; then
6976 echo | ${MAILX} ${ARGS} \
6977 -Smta=smtp://laber.backe -Ssmtp-auth=none \
6978 -Smta-aliases=./.tali \
6979 -b a3 -c a2 a1 > ./.tall 2>&1
6980 check_exn0 3
6981 check 4 - "${MBOX}" '1172368381 238'
6982 mtaali=1
6984 if [ -n "${mtaali}" ] && have_feat uistrings; then
6985 check 5 - .tall '771616226 179'
6986 else
6987 t_echoskip '5:[!SMTP/!UISTRINGS]'
6990 # xxx for false-positive SMTP test we would need some mocking
6991 echo | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
6992 -Sexpandaddr=fail,-name \
6993 -Smta-aliases=./.tali \
6994 -b a3 -c a2 a1 > ./.tall 2>&1
6995 check_exn0 6
6996 check 7 - "${MBOX}" '1172368381 238'
6997 if have_feat uistrings; then
6998 check 8 - .tall '2834389894 178'
6999 else
7000 t_echoskip '8:[!UISTRINGS]'
7003 echo | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
7004 -Sexpandaddr=-name \
7005 -Smta-aliases=./.tali \
7006 -b a3 -c a2 a1 > ./.tall 2>&1
7007 check 9 4 "${MBOX}" '2322273994 472'
7008 if have_feat uistrings; then
7009 check 10 - .tall '2136559508 69'
7010 else
7011 t_echoskip '10:[!UISTRINGS]'
7014 echo 'a9:nine@nine.nine' >> ./.tali
7016 echo | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
7017 -Sexpandaddr=fail,-name \
7018 -Smta-aliases=./.tali \
7019 -b a3 -c a2 a1 > ./.tall 2>&1
7020 check 11 0 "${MBOX}" '2422268299 722'
7021 check 12 - .tall '4294967295 0'
7023 printf '#
7024 set expandaddr=-name
7025 mail a1
7026 !c a2
7027 !:echo $?/$^ERRNAME
7028 !^header insert bcc a3
7029 !:echo $?/$^ERRNAME
7030 !:set expandaddr
7031 !t a1
7032 !c a2
7033 !:echo $?/$^ERRNAME
7034 !^header insert bcc a3
7035 !:echo $?/$^ERRNAME
7037 echo and, once again, check that cache is updated
7038 # Enclose one pipe in quotes: immense stress for our stupid address parser:(
7039 !echo "a10:./.tf1,|%s>./.tp1,\\"|%s > ./.tp2\\",./.tf2" >> ./.tali
7040 mtaaliases load
7041 mail a1
7042 !c a2
7043 !:echo $?/$^ERRNAME
7044 !^header insert bcc a3
7045 !:echo $?/$^ERRNAME
7047 echo trigger happiness
7048 mail a1
7049 !c a2
7050 !:echo $?/$^ERRNAME
7051 !^header insert bcc "a3 a10"
7052 !:echo $?/$^ERRNAME
7054 ' "${cat}" "${cat}" | ${MAILX} ${ARGS} -Smta=test://"$MBOX" -Sescape=! \
7055 -Smta-aliases=./.tali \
7056 > ./.tall 2>&1
7057 check 13 0 "${MBOX}" '550955032 1469'
7058 if have_feat uistrings; then
7059 check 14 - .tall '1795496020 473'
7060 else
7061 t_echoskip '14:[!UISTRINGS]'
7063 check 15 - .tf1 '3056269950 249'
7064 check 16 - .tp1 '3056269950 249'
7065 check 17 - .tp2 '3056269950 249'
7066 check 18 - .tf2 '3056269950 249'
7068 # TODO t_mta_aliases: n_ALIAS_MAXEXP is compile-time constant,
7069 # TODO need to somehow provide its contents to the test, then test
7071 t_epilog "${@}"
7074 t_filetype() {
7075 t_prolog "${@}"
7077 printf 'm m1@e.t\nL1\nHy1\n~.\nm m2@e.t\nL2\nHy2\n~@ %s\n~.\n' \
7078 "${TOPDIR}snailmail.jpg" | ${MAILX} ${ARGS} -Smta=test://"$MBOX"
7079 check 1 0 "${MBOX}" '1314354444 13536'
7081 if (echo | gzip -c) >/dev/null 2>&1; then
7083 printf 'File "%s"\ncopy 1 ./.t.mbox.gz\ncopy 2 ./.t.mbox.gz' \
7084 "${MBOX}" | ${MAILX} ${ARGS} \
7085 -X'filetype gz gzip\ -dc gzip\ -c'
7086 printf 'File ./.t.mbox.gz\ncopy * ./.t.mbox\n' |
7087 ${MAILX} ${ARGS} -X'filetype gz gzip\ -dc gzip\ -c'
7088 } > ./.t.out 2>&1
7089 check 2 - ./.t.mbox '1314354444 13536'
7090 check 3 - ./.t.out '635961640 103'
7091 else
7092 t_echoskip '2:[missing gzip(1)]'
7093 t_echoskip '3:[missing gzip(1)]'
7097 ${rm} ./.t.mbox*
7098 printf 'File "%s"\ncopy 1 ./.t.mbox.gz
7099 copy 2 ./.t.mbox.gz
7100 copy 1 ./.t.mbox.gz
7101 copy 2 ./.t.mbox.gz
7102 ' "${MBOX}" |
7103 ${MAILX} ${ARGS} \
7104 -X'filetype gz gzip\ -dc gzip\ -c' \
7105 -X'filetype mbox.gz "${sed} 1,3d|${cat}" \
7106 "echo eins;echo zwei;echo und mit ${sed} bist Du dabei;${cat}"'
7107 printf 'File ./.t.mbox.gz\ncopy * ./.t.mbox\n' |
7108 ${MAILX} ${ARGS} \
7109 -X'filetype gz gzip\ -dc gzip\ -c' \
7110 -X'filetype mbox.gz "${sed} 1,3d|${cat}" kill\ 0'
7111 } > ./.t.out 2>&1
7112 check 4 - ./.t.mbox '2687765142 27092'
7113 check 5 - ./.t.out '2230192693 173'
7115 t_epilog "${@}"
7118 t_e_H_L_opts() {
7119 t_prolog "${@}"
7121 touch ./.t.mbox
7122 ${MAILX} ${ARGS} -ef ./.t.mbox
7123 echo ${?} > "${MBOX}"
7125 printf 'm me@exam.ple\nLine 1.\nHello.\n~.\n' |
7126 ${MAILX} ${ARGS} -Smta=test://./.t.mbox
7127 printf 'm you@exam.ple\nLine 1.\nBye.\n~.\n' |
7128 ${MAILX} ${ARGS} -Smta=test://./.t.mbox
7130 ${MAILX} ${ARGS} -ef ./.t.mbox 2>> "${MBOX}"
7131 echo ${?} >> "${MBOX}"
7132 ${MAILX} ${ARGS} -efL @t@me ./.t.mbox 2>> "${MBOX}"
7133 echo ${?} >> "${MBOX}"
7134 ${MAILX} ${ARGS} -efL @t@you ./.t.mbox 2>> "${MBOX}"
7135 echo ${?} >> "${MBOX}"
7136 ${MAILX} ${ARGS} -efL '@>@Line 1' ./.t.mbox 2>> "${MBOX}"
7137 echo ${?} >> "${MBOX}"
7138 ${MAILX} ${ARGS} -efL '@>@Hello.' ./.t.mbox 2>> "${MBOX}"
7139 echo ${?} >> "${MBOX}"
7140 ${MAILX} ${ARGS} -efL '@>@Bye.' ./.t.mbox 2>> "${MBOX}"
7141 echo ${?} >> "${MBOX}"
7142 ${MAILX} ${ARGS} -efL '@>@Good bye.' ./.t.mbox 2>> "${MBOX}"
7143 echo ${?} >> "${MBOX}"
7145 ${MAILX} ${ARGS} -fH ./.t.mbox >> "${MBOX}" 2>&1
7146 echo ${?} >> "${MBOX}"
7147 ${MAILX} ${ARGS} -fL @t@me ./.t.mbox >> "${MBOX}" 2>&1
7148 echo ${?} >> "${MBOX}"
7149 ${MAILX} ${ARGS} -fL @t@you ./.t.mbox >> "${MBOX}" 2>&1
7150 echo ${?} >> "${MBOX}"
7151 ${MAILX} ${ARGS} -fL '@>@Line 1' ./.t.mbox >> "${MBOX}" 2>&1
7152 echo ${?} >> "${MBOX}"
7153 ${MAILX} ${ARGS} -fL '@>@Hello.' ./.t.mbox >> "${MBOX}" 2>&1
7154 echo ${?} >> "${MBOX}"
7155 ${MAILX} ${ARGS} -fL '@>@Bye.' ./.t.mbox >> "${MBOX}" 2>&1
7156 echo ${?} >> "${MBOX}"
7157 ${MAILX} ${ARGS} -fL '@>@Good bye.' ./.t.mbox >> "${MBOX}" 2>>${ERR}
7158 echo ${?} >> "${MBOX}"
7160 check 1 - "${MBOX}" '1369201287 670'
7164 printf 'm me1@exam.ple\n~s subject cab\nLine 1.\n~.\n' |
7165 ${MAILX} ${ARGS} -Smta=test://./.t.mbox \
7166 -r '' -X 'wysh set from=pony1@$LOGNAME'
7167 printf 'm me2@exam.ple\n~s subject bac\nLine 12.\n~.\n' |
7168 ${MAILX} ${ARGS} -Smta=test://./.t.mbox \
7169 -r '' -X 'wysh set from=pony2@$LOGNAME'
7170 printf 'm me3@exam.ple\n~s subject abc\nLine 123.\n~.\n' |
7171 ${MAILX} ${ARGS} -Smta=test://./.t.mbox \
7172 -r '' -X 'wysh set from=pony3@$LOGNAME'
7174 ${MAILX} ${ARGS} -S folder-hook=fh-test -X 'define fh-test {
7175 echo fh-test size; set autosort=size showname showto
7176 }' -fH ./.t.mbox > "${MBOX}" 2>&1
7177 check 2 0 "${MBOX}" '4286438644 413'
7179 ${MAILX} ${ARGS} -S folder-hook=fh-test -X 'define fh-test {
7180 echo fh-test subject; set autosort=subject showname showto
7181 }' -fH ./.t.mbox > "${MBOX}" 2>&1
7182 check 3 0 "${MBOX}" '3208053922 416'
7184 ${MAILX} ${ARGS} -S folder-hook=fh-test -X 'define fh-test {
7185 echo fh-test from; set autosort=from showto
7186 }' -fH ./.t.mbox > "${MBOX}" 2>&1
7187 check 4 0 "${MBOX}" '4209767839 413'
7189 ${MAILX} ${ARGS} -S folder-hook=fh-test -X 'define fh-test {
7190 echo fh-test to; set autosort=to showto
7191 }' -fH ./.t.mbox > "${MBOX}" 2>&1
7192 check 5 0 "${MBOX}" '2785342736 411'
7194 t_epilog "${@}"
7197 t_q_t_etc_opts() {
7198 # Simple, if we need more here, place in a later vim fold!
7199 t_prolog "${@}"
7201 # Three tests for MIME encoding and (a bit) content classification.
7202 # At the same time testing -q FILE, < FILE and -t FILE
7203 t__put_body > ./.tin
7205 < ./.tin ${MAILX} ${ARGS} ${ADDARG_UNI} \
7206 -a ./.tin -s "`t__put_subject`" "${MBOX}"
7207 check 1 0 "${MBOX}" '1088822685 6642'
7209 ${rm} "${MBOX}"
7210 < /dev/null ${MAILX} ${ARGS} ${ADDARG_UNI} \
7211 -a ./.tin -s "`t__put_subject`" -q ./.tin "${MBOX}"
7212 check 2 0 "${MBOX}" '1088822685 6642'
7214 ${rm} "${MBOX}"
7215 ( echo "To: ${MBOX}" && echo "Subject: `t__put_subject`" && echo &&
7216 ${cat} ./.tin
7217 ) | ${MAILX} ${ARGS} ${ADDARG_UNI} -Snodot -a ./.tin -t
7218 check 3 0 "${MBOX}" '1088822685 6642'
7220 # Check comments in the header
7221 ${rm} "${MBOX}"
7222 ${cat} <<-_EOT | ${MAILX} ${ARGS} -Snodot -t "${MBOX}"
7223 # Ein Kommentar
7224 From: du@da
7225 # Noch ein Kommentar
7226 Subject : hey you
7227 # Nachgestelltes Kommentar
7229 BOOOM
7230 _EOT
7231 check 4 0 "${MBOX}" '4161555890 124'
7233 # ?MODifier suffix
7234 printf '' > "${MBOX}"
7235 ( echo 'To?single : ./.tout1 .tout2 ' &&
7236 echo 'CC: ./.tcc1 ./.tcc2' &&
7237 echo 'BcC?sin : ./.tbcc1 .tbcc2 ' &&
7238 echo 'To? : ./.tout3 .tout4 ' &&
7239 echo &&
7240 echo body
7241 ) | ${MAILX} ${ARGS} ${ADDARG_UNI} -Snodot -t -Smta=test://"$MBOX"
7242 check 5 0 './.tout1 .tout2' '2948857341 94'
7243 check 6 - ./.tcc1 '2948857341 94'
7244 check 7 - ./.tcc2 '2948857341 94'
7245 check 8 - './.tbcc1 .tbcc2' '2948857341 94'
7246 check 9 - './.tout3 .tout4' '2948857341 94'
7247 check 10 - "${MBOX}" '4294967295 0'
7249 t_epilog "${@}"
7252 t_message_injections() {
7253 # Simple, if we need more here, place in a later vim fold!
7254 t_prolog "${@}"
7256 echo mysig > ./.tmysig
7258 echo some-body | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
7259 -Smessage-inject-head=head-inject \
7260 -Smessage-inject-tail="`${cat} ./.tmysig`"'\ntail-inject' \
7261 ex@am.ple > ./.tall 2>&1
7262 check 1 0 "${MBOX}" '701778583 143'
7263 check 2 - .tall '4294967295 0' # empty file
7265 ${rm} "${MBOX}"
7266 ${cat} <<-_EOT > ./.template
7267 From: me
7268 To: ex1@am.ple
7269 Cc: ex2@am.ple
7270 Subject: This subject is
7272 Body, body, body me.
7273 _EOT
7274 < ./.template ${MAILX} ${ARGS} -t -Smta=test://"$MBOX" \
7275 -Smessage-inject-head=head-inject \
7276 -Smessage-inject-tail="`${cat} ./.tmysig`\n"'tail-inject' \
7277 > ./.tall 2>&1
7278 check 3 0 "${MBOX}" '2189109479 207'
7279 check 4 - .tall '4294967295 0' # empty file
7281 t_epilog "${@}"
7284 t_attachments() {
7285 # TODO More should be in compose mode stuff aka digmsg
7286 t_prolog "${@}"
7288 ${cat} <<-_EOT > ./.tx
7289 From steffen Sun Feb 18 02:48:40 2018
7290 Date: Sun, 18 Feb 2018 02:48:40 +0100
7292 Subject: m1
7293 User-Agent: s-nail v14.9.7
7296 From steffen Sun Feb 18 02:48:42 2018
7297 Date: Sun, 18 Feb 2018 02:48:42 +0100
7299 Subject: m2
7300 User-Agent: s-nail v14.9.7
7303 _EOT
7304 echo att1 > ./.t1
7305 printf 'att2-1\natt2-2\natt2-4\n' > ./'.t 2'
7306 printf 'att3-1\natt3-2\natt3-4\n' > ./.t3
7307 printf 'att4-1\natt4-2\natt4-4\n' > './.t 4'
7309 printf \
7310 '!@ ./.t3 "./.t 4" ""
7313 ./.t3
7314 "./.t 2"
7317 !.' \
7318 | ${MAILX} ${ARGS} -Sescape=! -Smta=test://"$MBOX" \
7319 -a ./.t1 -a './.t 2' \
7320 -s attachment-test \
7321 ex@am.ple > ./.tall 2>&1
7322 check 1 0 "${MBOX}" '2484200149 644'
7323 if have_feat uistrings; then
7324 check 2 - .tall '1928331872 720'
7325 else
7326 t_echoskip '2:[!UISTRINGS]'
7329 ${rm} "${MBOX}"
7330 printf \
7331 'mail ex@amp.ple
7332 !s This the subject is
7333 !@ ./.t3 "#2" "./.t 4" "#1" ""
7336 "./.t 4"
7337 "#2"
7341 mail ex@amp.ple
7342 !s Subject two
7343 !@ ./.t3 "#2" "./.t 4" "#1" ""
7349 mail ex@amp.ple
7350 !s Subject three
7351 !@ ./.t3 "" "#2" "" "./.t 4" "" "#1" ""
7354 ./.t3
7358 mail ex@amp.ple
7359 !s Subject Four
7360 !@ ./.t3 "" "#2" "" "./.t 4" "" "#1" ""
7363 "#1"
7367 mail ex@amp.ple
7368 !s Subject Five
7370 "#2"
7373 !.' \
7374 | ${MAILX} ${ARGS} -Sescape=! -Smta=test://"$MBOX" -Rf ./.tx \
7375 > ./.tall 2>&1
7376 check 3 0 "${MBOX}" '3637385058 2335'
7377 if have_feat uistrings; then
7378 check 4 - .tall '2526106274 1910'
7379 else
7380 t_echoskip '4:[!UISTRINGS]'
7383 ${rm} "${MBOX}"
7384 printf \
7385 'mail ex@amp.ple
7386 !s Subject One
7387 !@ "#."
7388 Body one.
7391 from 2
7392 mail ex@amp.ple
7393 !s Subject Two
7395 "#."
7397 Body two.
7400 reply 1 2
7401 !@ "#."
7405 "#."
7408 !.' \
7409 | ${MAILX} ${ARGS} -Sescape=! -Smta=test://"$MBOX" -Rf ./.tx \
7410 > ./.tall 2>&1
7411 check 5 0 "${MBOX}" '1604688179 2316'
7412 if have_feat uistrings; then
7413 check 6 - .tall '1210753005 508'
7414 else
7415 t_echoskip '6:[!UISTRINGS]'
7420 # Content-ID:
7421 </dev/null ${MAILX} ${ARGS} -Smta=test \
7422 -Sstealthmua=noagent -Shostname \
7423 -a ./.t1 -a './.t 2' \
7424 -a ./.t3 -a './.t 4' \
7425 -s Y \
7426 ex@am.ple > ./.tall 2>&1
7427 check 7 0 .tall '1003537919 1262'
7429 # input charset
7430 </dev/null ${MAILX} ${ARGS} -Smta=test -Sttycharset=utf8 \
7431 -a ./.t1=ascii -a './.t 2'=LATin1 \
7432 -a ./.t3=UTF-8 -a './.t 4'=- \
7433 -s Y \
7434 ex@am.ple > ./.tall 2>&1
7435 check 8 0 .tall '361641281 921'
7437 # input+output charset, no iconv
7438 </dev/null ${MAILX} ${ARGS} -Smta=test \
7439 -a ./.t1=ascii#- -a './.t 2'=LATin1#- \
7440 -a ./.t3=UTF-8#- -a './.t 4'=utf8#- \
7441 -s Y \
7442 ex@am.ple > ./.tall 2>&1
7443 check 9 0 .tall '1357456844 933'
7445 if have_feat iconv; then
7446 printf 'ein \303\244ffchen und ein pferd\n' > .t10-f1
7447 if (< .t10-f1 iconv -f ascii -t utf8) >/dev/null 2>&1; then
7448 </dev/null ${MAILX} ${ARGS} --set mta=test \
7449 --set stealthmua=noagent --set hostname \
7450 --attach ./.t1=-#utf8 \
7451 --attach ./.t10-f1=utf8#latin1 \
7452 --subject Y \
7453 ex@am.ple > ./.tall 2>&1
7454 check 10 0 .tall '1257664842 877'
7455 else
7456 t_echoskip '10:[ICONV/iconv(1):missing conversion(1)]'
7458 else
7459 t_echoskip '10:[!ICONV]'
7462 t_epilog "${@}"
7465 t_rfc2231() {
7466 # (after attachments)
7467 t_prolog "${@}"
7470 mkdir ./.ttt || exit 1
7471 cd ./.ttt || exit 2
7472 : > "ma'ger.txt"
7473 : > "mä'ger.txt"
7474 : > 'diet\ is \curd.txt'
7475 : > 'diet "is" curd.txt'
7476 : > höde-tröge.txt
7477 : > 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
7478 : > höde__tröge__müde__dätte__hätte__vuelle__guelle__aese__aesse__sauerliche__kräuter__österliche__grüße__mäh.txt
7479 : > hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt
7480 : > ✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt
7482 echo bla | ${MAILX} ${ARGS} ${ADDARG_UNI} \
7483 -a "./.ttt/ma'ger.txt" -a "./.ttt/mä'ger.txt" \
7484 -a './.ttt/diet\ is \curd.txt' -a './.ttt/diet "is" curd.txt' \
7485 -a ./.ttt/höde-tröge.txt \
7486 -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 \
7487 -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 \
7488 -a ./.ttt/hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt \
7489 -a ./.ttt/✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt \
7490 "${MBOX}"
7491 check 1 0 "${MBOX}" '3720896054 3088'
7493 # `resend' test, reusing $MBOX
7494 printf "Resend ./.t2\nx\n" | ${MAILX} ${ARGS} -Rf "${MBOX}"
7495 check 2 0 ./.t2 '3720896054 3088'
7497 printf "resend ./.t3\nx\n" | ${MAILX} ${ARGS} -Rf "${MBOX}"
7498 check 3 0 ./.t3 '3979736592 3133'
7500 # And a primitive test for reading messages with invalid parameters
7501 ${cat} <<-_EOT > ./.tinv
7502 From a@b.invalid Wed May 15 12:43:00 2018
7503 MIME-Version: 1.0
7504 Content-Type: multipart/mixed; boundary="1"
7506 This is a multi-part message in MIME format.
7508 Content-Type: text/plain; charset=UTF-8
7509 Content-Transfer-Encoding: quoted-printable
7513 Content-Type: text/plain; name*17="na"; name*18="me-c-t"
7514 Content-Transfer-Encoding: 7bit
7515 Content-Disposition: inline
7518 --1--
7520 From a@b.invalid Wed May 15 12:43:00 2018
7521 MIME-Version: 1.0
7522 Content-Type: multipart/mixed; boundary="2"
7524 This is a multi-part message in MIME format.
7526 Content-Type: text/plain; charset=UTF-8
7527 Content-Transfer-Encoding: quoted-printable
7531 Content-Type: text/plain; name*17="na"; name*18="me-c-t"
7532 Content-Transfer-Encoding: 7bit
7533 Content-Disposition: inline;
7534 filename*0="na";
7535 filename*998999999999999999999999999999="me-c-d"
7538 --2--
7540 From a@b.invalid Wed May 15 12:43:00 2018
7541 MIME-Version: 1.0
7542 Content-Type: multipart/mixed; boundary="3"
7544 This is a multi-part message in MIME format.
7546 Content-Type: text/plain; charset=UTF-8
7547 Content-Transfer-Encoding: quoted-printable
7551 Content-Type: text/plain; name*17="na"; name*18="me-c-t"
7552 Content-Transfer-Encoding: 7bit
7553 Content-Disposition: inline;
7554 filename*0="na"; filename*998="me-c-d"
7557 --3--
7558 _EOT
7560 printf '\\#
7561 \\headerpick type ignore Content-Type Content-Disposition
7562 \\type 1 2 3
7563 \\xit
7564 ' | ${MAILX} ${ARGS} -Rf ./.tinv > ./.tall 2> ./.terr
7565 check 4 0 ./.tall '4094731083 905'
7566 if have_feat uistrings && have_feat iconv; then
7567 check 5 - ./.terr '3713266499 473'
7568 else
7569 t_echoskip '5:[!UISTRINGS or !ICONV]'
7572 t_epilog "${@}"
7575 t_mime_types_load_control() {
7576 t_prolog "${@}"
7578 if have_feat uistrings; then :; else
7579 t_echoskip '[!UISTRINGS]'
7580 t_epilog "${@}"
7581 return
7584 ${cat} <<-_EOT > ./.tmts1
7585 ? application/mathml+xml mathml
7586 _EOT
7587 ${cat} <<-_EOT > ./.tmts2
7588 ? x-conference/x-cooltalk ice
7589 ?t aga-aga aga
7590 ? application/aga-aga aga
7591 _EOT
7593 ${cat} <<-_EOT > ./.tmts1.mathml
7594 <head>nonsense ML</head>
7595 _EOT
7596 ${cat} <<-_EOT > ./.tmts2.ice
7597 Icy, icy road.
7598 _EOT
7599 printf 'of which the c\x01rack is coming soon' > ./.tmtsx.doom
7600 printf 'of which the c\x01rack is coming soon' > ./.tmtsx.aga
7602 printf '
7603 m %s
7604 Schub-di-du
7605 ~@ ./.tmts1.mathml
7606 ~@ ./.tmts2.ice
7607 ~@ ./.tmtsx.doom
7608 ~@ ./.tmtsx.aga
7610 File %s
7611 from*
7612 type
7614 ' "${MBOX}" "${MBOX}" |
7615 ${MAILX} ${ARGS} \
7616 -Smimetypes-load-control=f=./.tmts1,f=./.tmts2 \
7617 > ./.tout 2>&1
7618 check_ex0 1-estat
7619 ${cat} "${MBOX}" >> ./.tout
7620 check 1 - ./.tout '2128819500 2441'
7622 echo type | ${MAILX} ${ARGS} -R \
7623 -Smimetypes-load-control=f=./.tmts1,f=./.tmts3 \
7624 -f "${MBOX}" >> ./.tout 2>&1
7625 check 2 0 ./.tout '1125106528 3642'
7627 t_epilog "${@}"
7629 # }}}
7631 # Around state machine, after basics {{{
7632 t_alternates() {
7633 t_prolog "${@}"
7635 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" > ./.tall 2>&1
7636 commandalias x echo '$?/$^ERRNAME'
7637 commandalias y echo '$?/$^ERRNAME <$rv>'
7638 echo --0
7639 alternates;x
7640 alternates a1@b1 a2@b2 a3@b3;x
7641 alternates;x
7642 vput alternates rv;y
7644 echo --1
7645 unalternates a2@b2
7646 vput alternates rv;y
7647 unalternates a3@b3
7648 vput alternates rv;y
7649 unalternates a1@b1
7650 vput alternates rv;y
7652 echo --2
7653 unalternates *
7654 alternates a1@b1 a2@b2 a3@b3
7655 unalternates a3@b3
7656 vput alternates rv;y
7657 unalternates a2@b2
7658 vput alternates rv;y
7659 unalternates a1@b1
7660 vput alternates rv;y
7662 echo --3
7663 alternates a1@b1 a2@b2 a3@b3
7664 unalternates a1@b1
7665 vput alternates rv;y
7666 unalternates a2@b2
7667 vput alternates rv;y
7668 unalternates a3@b3
7669 vput alternates rv;y
7671 echo --4
7672 unalternates *
7673 alternates a1@b1 a2@b2 a3@b3
7674 unalternates *
7675 vput alternates rv;y
7677 echo --5
7678 unalternates *
7679 alternates a1@b1 a1@c1 a1@d1 a2@b2 a3@b3 a3@c3 a3@d3
7680 m a1@b1 a1@c1 a1@d1
7681 ~s all alternates, only a1@b1 remains
7682 ~c a2@b2
7683 ~b a3@b3 a3@c3 a3@d3
7684 ~r - '_EOT'
7685 This body is!
7686 This also body is!!
7687 _EOT
7690 echo --6
7691 unalternates *
7692 alternates a1@b1 a1@c1 a2@b2 a3@b3
7693 m a1@b1 a1@c1 a1@d1
7694 ~s a1@b1 a1@d1, and a3@c3 a3@d3 remain
7695 ~c a2@b2
7696 ~b a3@b3 a3@c3 a3@d3
7697 ~r - '_EOT'
7698 This body2 is!
7699 _EOT
7702 echo --7
7703 alternates a1@b1 a2@b2 a3; set allnet
7704 m a1@b1 a1@c1 a1@d1
7705 ~s all alternates via allnet, only a1@b1 remains
7706 ~c a2@b2
7707 ~b a3@b3 a3@c3 a3@d3
7708 ~r - '_EOT'
7709 This body3 is!
7710 _EOT
7713 echo --10
7714 unalternates *
7715 alternates a1@b1;x
7716 vput alternates rv;y
7717 alternates a2@b2;x
7718 vput alternates rv;y
7719 alternates a3@b3;x
7720 vput alternates rv;y
7721 alternates a4@b4;x
7722 vput alternates rv;y
7724 unalternates *
7725 vput alternates rv;y
7727 echo --11
7728 set posix
7729 alternates a1@b1 a2@b2;x
7730 vput alternates rv;y
7731 alternates a3@b3 a4@b4;x
7732 vput alternates rv;y
7733 __EOT
7735 check 1 0 "${MBOX}" '3901995195 542'
7736 if have_feat uistrings; then
7737 check 2 - .tall '1878598364 505'
7738 else
7739 t_echoskip '2:[!UISTRINGS]'
7742 # Automatic alternates, also from command line (freezing etc.)
7743 ${rm} "${MBOX}"
7744 ${cat} <<- __EOT > ./.tin
7745 From trouble-report@desy Wed Jun 6 20:19:28 2018
7746 Date: Wed, 06 Jun 2018 19:58:02 +0200
7747 From: a@b.org, b@b.org, c@c.org
7748 Sender: a@b.org
7749 To: b@b.org
7750 Cc: a@b.org, c@c.org
7751 Subject: test
7752 Message-ID: <20180606175802.dw-cn%a@b.org>
7754 sultry
7756 __EOT
7758 printf '#
7759 reply
7760 !^header remove to
7761 !^header remove cc
7762 !^header remove subject
7763 !^header insert to b@b.org
7764 !^header insert cc "a@b.org b@b.org c@c.org"
7765 my body
7767 ' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" -Sescape=! \
7768 -S from=a@b.org,b@b.org,c@c.org -S sender=a@b.org \
7769 -Rf ./.tin > ./.tall 2>&1
7770 check 3 0 "${MBOX}" '3184203976 265'
7771 check 4 - .tall '3604001424 44'
7773 # same, per command
7774 printf '#
7775 set from=a@b.org,b@b.org,c@c.org sender=a@b.org
7776 reply
7777 !^header remove to
7778 !^header remove cc
7779 !^header remove subject
7780 !^header insert to b@b.org
7781 !^header insert cc "a@b.org b@b.org c@c.org"
7782 my body
7784 ' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" -Sescape=! \
7785 -Rf ./.tin > ./.tall 2>&1
7786 check 5 0 "${MBOX}" '98184290 530'
7787 check 6 - .tall '3604001424 44'
7789 # And more, with/out -r (and that Sender: vanishs as necessary)
7790 # TODO -r should be the Sender:, which should automatically propagate to
7791 # TODO From: if possible and/or necessary. It should be possible to
7792 # TODO suppres -r stuff from From: and Sender:, but fallback to special -r
7793 # TODO arg as appropriate.
7794 # TODO For now we are a bit messy
7796 ${rm} "${MBOX}"
7797 </dev/null ${MAILX} ${ARGS} -Smta=test://"$MBOX" -s '-Sfrom + -r ++ test' \
7798 -c a@b.example -c b@b.example -c c@c.example \
7799 -S from=a@b.example,b@b.example,c@c.example \
7800 -S sender=a@b.example \
7801 -r a@b.example b@b.example ./.tout >./.tall 2>&1
7802 check 7 0 "${MBOX}" '4275947318 181'
7803 check 8 - .tout '4275947318 181'
7804 check 9 - .tall '4294967295 0'
7806 </dev/null ${MAILX} ${ARGS} -Smta=test://"$MBOX" -s '-Sfrom + -r ++ test' \
7807 -c a@b.example -c b@b.example -c c@c.example \
7808 -S from=a@b.example,b@b.example,c@c.example \
7809 -S sender=a2@b.example \
7810 -r a@b.example b@b.example ./.tout >./.tall 2>&1
7811 check 10 0 "${MBOX}" '1189494079 383'
7812 check 11 - .tout '1189494079 383'
7813 check 12 - .tall '4294967295 0'
7815 </dev/null ${MAILX} ${ARGS} -Smta=test://"$MBOX" -s '-Sfrom + -r ++ test' \
7816 -c a@b.example -c b@b.example -c c@c.example \
7817 -S from=a@b.example,b@b.example,c@c.example \
7818 -S sender=a@b.example \
7819 b@b.example >./.tall 2>&1
7820 check 13 0 "${MBOX}" '2253033142 610'
7821 check 14 - .tall '4294967295 0'
7823 t_epilog "${@}"
7826 t_cmd_escapes() {
7827 # quote and cmd escapes because this (since Mail times) is worked in the
7828 # big collect() monster of functions
7829 t_prolog "${@}"
7831 echo 'included file' > ./.ttxt
7832 { t__x1_msg && t__x2_msg && t__x3_msg &&
7833 t__gen_msg from 'ex4@am.ple' subject sub4 &&
7834 t__gen_msg from 'eximan <ex5@am.ple>' subject sub5 &&
7835 t__gen_mimemsg from 'ex6@am.ple' subject sub6; } > ./.tmbox
7836 check 1 - ./.tmbox '517368276 2182'
7838 # ~@ is tested with other attachment stuff, ~^ is in compose_edits + digmsg
7839 printf '#
7840 set Sign=SignVar sign=signvar DEAD=./.ttxt
7841 set forward-inject-head quote-inject-head
7842 headerpick type retain Subject
7843 headerpick forward retain Subject To
7844 reply 2
7845 !!1 Not escaped. And shell test last, right before !..
7846 !:echo 1
7847 !: echo 2 only echoed via colon
7848 !:echo 2:$?/$^ERRNAME
7849 !_ echo 3 only echoed via underscore
7850 !:echo 3:$?/$^ERRNAME
7851 !< ./.ttxt
7852 !:echo 4:$?/$^ERRNAME
7853 !<! echo 5 shell echo included
7854 !:echo 5:$?/$^ERRNAME
7855 !| echo 6 pipecmd-pre; cat; echo 6 pipecmd-post
7856 !:echo 6:$?/$^ERRNAME
7857 7 and 8 are ~A and ~a:
7859 !:echo 7:$?/$^ERRNAME
7861 !:echo 8:$?/$^ERRNAME
7862 !b 9 added ~b cc <ex1@am.ple>
7863 !:echo 9:$?/$^ERRNAME
7864 !c 10 added ~c c <ex2@am.ple>
7865 !:echo 10:$?/$^ERRNAME
7866 11 next ~d / $DEAD
7868 !:echo 11:$?/$^ERRNAME
7869 12: ~F
7871 !:echo 12:$?/$^ERRNAME
7872 13: ~F 1 3
7873 !F 1 3
7874 !:echo 13:$?/$^ERRNAME
7875 !F 1000
7876 !:echo 13-1:$?/$^ERRNAME; set posix
7877 14: ~f (headerpick: subject)
7879 !:echo 14:$?/$^ERRNAME; unset posix forward-inject-head quote-inject-head
7880 14.1: ~f (!posix: injections; headerpick: subject to)
7882 !:echo 14.1:$?/$^ERRNAME; set forward-add-cc
7883 14.2: ~f (!posix: headerpick: subject to; forward-add-cc adds mr3)
7884 !f 3
7885 !:echo 14.2:$?/$^ERRNAME; set fullnames
7886 14.3: ~f (!posix: headerpick: subject to; forward-add-cc adds mr1 fullname)
7887 !f 1
7888 !:echo 14.3:$?/$^ERRNAME; set nofullnames noforward-add-cc posix
7889 15: ~f 1
7890 !f 1
7891 !:echo 15:$?/$^ERRNAME
7892 15.5: nono: ~H, ~h
7894 !:echo 15.5-1:$?/$^ERRNAME
7896 !:echo 15.5-2:$?/$^ERRNAME
7897 16, 17: ~I Sign, ~i Sign
7898 !I Sign
7899 !:echo 16:$?/$^ERRNAME
7900 !i Sign
7901 !:echo 17:$?/$^ERRNAME
7902 18: ~M
7904 !:echo 18:$?/$^ERRNAME # XXX forward-add-cc: not expl. tested
7905 19: ~M 1
7906 !M 1
7907 !:echo 19:$?/$^ERRNAME
7908 20: ~m
7910 !:echo 20:$?/$^ERRNAME # XXX forward-add-cc: not expl. tested
7911 21: ~m 3
7912 !m 3
7913 !:echo 21:$?/$^ERRNAME
7914 !: # Initially ~Q was _exactly_ like
7915 28,29 nothing, 30-34: ~Q
7916 !:echo quote=<$quote>
7917 30: ~Q
7919 !:echo 30:$?/$^ERRNAME
7920 31: ~Q 1 3
7921 !Q 1 3
7922 !:echo 31:$?/$^ERRNAME
7923 set quote-inject-head quote-inject-tail indentprefix
7924 !:wysh set quote-inject-head=%%a quote-inject-tail=--%%r
7925 32: ~Q
7927 !:echo 32:$?/$^ERRNAME
7928 set noquote-inject-head noquote-inject-tail quote-add-cc
7929 !:set noquote-inject-head noquote-inject-tail quote-add-cc
7930 33: ~Q 4
7931 !Q 4
7932 !:echo 33:$?/$^ERRNAME
7933 set fullnames
7934 !:set fullnames
7935 34: ~Q 5
7936 !Q 5
7937 !:echo 34:$?/$^ERRNAME
7938 unset fullnames, quote stuff
7939 !:unset quote quote-add-cc fullnames
7940 22: ~R ./.ttxt
7941 !R ./.ttxt
7942 !:echo 22:$?/$^ERRNAME
7943 23: ~r ./.ttxt
7944 !r ./.ttxt
7945 !:echo 23:$?/$^ERRNAME
7946 24: ~s this new subject
7947 !s 24 did new ~s ubject
7948 !:echo 24:$?/$^ERRNAME
7949 !t 25 added ~t o <ex3@am.ple>
7950 !:echo 25:$?/$^ERRNAME
7951 26.1: ~U
7953 !:echo 26.1:$?/$^ERRNAME
7954 26.2: ~U 1
7955 !U 1
7956 !:echo 26.2:$?/$^ERRNAME # XXX forward-add-cc: not expl. tested
7957 27.1: ~u
7959 !:echo 27.1:$?/$^ERRNAME
7960 27.2: ~u 1
7961 !u 1
7962 !:echo 27.2:$?/$^ERRNAME # XXX forward-add-cc: not expl. tested
7963 and i ~w rite this out to ./.tmsg
7964 !w ./.tmsg
7965 !:echo i ~w:$?/$^ERRNAME
7966 !:wysh set x=$escape;set escape=~
7967 ~!echo shell command output
7968 ~:echo shell:$?/$^ERRNAME
7969 ~:wysh set escape=$x
7970 50:F
7971 !F 6
7972 !:echo 50 was F:$?/$^ERRNAME
7973 51:f
7974 !f 6
7975 !:echo 51 was f:$?/$^ERRNAME
7976 52:M
7977 !M 6
7978 !:echo 52 was M:$?/$^ERRNAME
7979 53:m
7980 !m 6
7981 !:echo 53 was m:$?/$^ERRNAME; set quote
7982 54:Q
7983 !Q 6
7984 !:echo 54 was Q:$?/$^ERRNAME
7985 55:U
7986 !U 6
7987 !:echo 55 was U:$?/$^ERRNAME
7988 56:u
7989 !u 6
7990 !:echo 56 was u:$?/$^ERRNAME
7992 ' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" -Rf \
7993 -Sescape=! -Sindentprefix=' |' \
7994 ./.tmbox >./.tall 2>./.terr
7995 check_ex0 2-estat
7996 ${cat} ./.tall >> "${MBOX}"
7997 check 2 - "${MBOX}" '3877629593 7699'
7999 if have_feat uistrings && have_feat iconv; then
8000 check 2-err - ./.terr '3575876476 49'
8001 else
8002 t_echoskip '2-err:[!UISTRINGS or !ICONV]'
8004 check 3 - ./.tmsg '3502750368 4445'
8006 # Simple return/error value after *expandaddr* failure test
8007 printf 'body
8008 !:echo --one
8009 !s This a new subject is
8010 !:set expandaddr=-name
8011 !t two@to.invalid
8012 !:echo $?/$^ERRNAME
8013 !:echo --two
8014 !c no-name-allowed
8015 !:echo $?/$^ERRNAME
8016 !c one@cc.invalid
8017 !:echo $?/$^ERRNAME
8018 !:echo --three
8019 !:alias abcc one@bcc.invalid
8020 !b abcc
8021 !:echo $?/$^ERRNAME
8022 !:set expandaddr=+addr
8023 !b abcc
8024 !:echo $!/$?/$^ERRNAME
8026 ' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
8027 -Sescape=! \
8028 -s testsub one@to.invalid >./.tall 2>&1
8029 check 4 0 "${MBOX}" '115245837 7900'
8030 if have_feat uistrings; then
8031 check 5 - ./.tall '2336041127 212'
8032 else
8033 check 5 - ./.tall '1818580177 59'
8036 # Modifiers and whitespace indulgence
8037 printf 'body
8038 !:remove '"${MBOX}"'
8039 ! :echo one
8040 ! <./.ttxts
8041 ! :echo two
8042 ! : set i=./.ttxts
8043 ! - $ < $i
8044 !:echo three
8045 ! : set \\
8046 errexit
8047 ! - $ < $i
8048 ! : echo four
8049 !$< ./.ttxts
8050 ! : echo five
8051 ' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
8052 -Sescape=! \
8053 -Spwd="`${pwd}`" \
8054 -s testsub one@to.invalid >./.tall 2>./.terr
8055 check 6 4 ./.tall '686767281 95'
8056 [ -f "${MBOX}" ]; check_exn0 7
8057 if have_feat uistrings; then
8058 check 8 - ./.terr '1304637795 199'
8059 else
8060 t_echoskip '8:[!UISTRINGS]'
8063 t_epilog "${@}"
8066 t_compose_edits() { # XXX very rudimentary
8067 # after: t_cmd_escapes
8068 t_prolog "${@}"
8070 # Something to use as "editor"
8071 ${cat} <<-_EOT > ./.ted.sh
8072 #!${SHELL}
8073 ${cat} <<-__EOT > \${1}
8074 Fcc: .tout1
8076 Fcc: .tout2
8077 Subject: Fcc test 1
8078 Fcc: .tout3
8080 A body
8081 __EOT
8082 exit 0
8083 _EOT
8084 ${chmod} 0755 .ted.sh
8086 # > All these are in-a-row!
8088 printf 'mail ./.tout\n~s This subject is\nThis body is\n~.' |
8089 ${MAILX} ${ARGS} -Seditheaders >./.tall 2>&1
8090 check 1 0 ./.tout '3993703854 127'
8091 check 2 - ./.tall '4294967295 0'
8093 ${mv} ./.tall ./.tout
8094 printf 'mail ./.tout\n~s This subject is\nThis body is\n~e\n~.' |
8095 ${MAILX} ${ARGS} -Seditheaders -SEDITOR=./.ted.sh >./.tall 2>&1
8096 check 3 0 ./.tout1 '285981670 116'
8097 check 4 - ./.tout2 '285981670 116'
8098 check 5 - ./.tout3 '285981670 116'
8099 check 6 - ./.tout '4294967295 0'
8100 check 7 - ./.tall '4294967295 0'
8101 ${rm} ./.tout1 ./.tout2 ./.tout3
8103 # Note t_compose_hooks adds ~^ stress tests
8104 ${mv} ./.tout ./.tout1
8105 ${mv} ./.tall ./.tout2
8106 printf '#
8107 mail ./.tout\n!s This subject is\nThis body is
8108 !^header
8109 !^header list
8110 !^header list fcc
8111 !^header show fcc
8112 !^header remove to
8113 !^header insert fcc ./.tout
8114 !^header insert fcc .tout1
8115 !^header insert fcc ./.tout2
8116 !^header list
8117 !^header show fcc
8118 !^header remove-at fcc 2
8119 !^header remove-at fcc 2
8120 !^header show fcc
8121 !^head remove fcc
8122 !^header show fcc
8123 !^header insert fcc ./.tout
8124 !^header show fcc
8125 !^header list
8127 ' | ${MAILX} ${ARGS} -Sescape=! >./.tall 2>&1
8128 check 8 0 ./.tout '3993703854 127'
8129 check 9 - ./.tout1 '4294967295 0'
8130 check 10 - ./.tout2 '4294967295 0'
8131 check 11 - ./.tall '1857504914 342'
8133 # < No longer in-a-row
8135 ${cat} <<-_EOT | ${MAILX} ${ARGS} -t >./.tall 2>&1
8136 Fcc: .ttout
8137 Subject: Fcc via -t test
8139 My body
8140 _EOT
8141 check 12 0 ./.ttout '1289478830 122'
8142 check 13 - ./.tall '4294967295 0'
8144 # This test assumes code of `^' and `digmsg' is shared: see t_digmsg()
8145 echo 'b 1' > ./.t' x 1'
8146 echo 'b 2' > ./.t' x 2'
8147 printf '#
8148 mail ./.tatt
8149 !^header insert subject subject
8150 !:set i="./.t x 1"
8151 !^header list
8152 !:echo =0
8153 !^attachment
8154 !:echo =1
8155 !^attachment insert "$i"
8156 !:echo =2
8157 !^attachment
8158 !:echo =3
8159 !^attachment list
8160 !:echo =4
8161 !^attachment insert '"'"'./.t x 2'"'"'
8162 !:echo =5
8163 !^attachment list
8164 !:echo =6
8165 !^attachment remove "$i"
8166 !:echo =7
8167 !^attachment list
8168 !:echo =8
8169 !^attachment insert $'"'"'\\$i'"'"'
8170 !:echo =10
8171 !^attachment list
8172 !:echo =11
8173 !^header list
8174 !:echo =12
8175 !^a a $i
8176 !:echo =13
8177 !^a attribute-set "$i" filenames " cannot wait for you "
8178 !:echo =14
8179 !^a a $i
8180 !:echo =15
8181 !^a attribute-set "$i" filename " cannot wait for you "
8182 !:echo =16
8183 !^a a $i
8184 !:echo =17
8185 !^a attribute-at 2
8186 !:echo =18
8187 !^a attribute-set-at 2 "filename" "private eyes"
8188 !:echo =19
8189 !^a attribute-at 2
8190 !:echo =20
8191 !^a attribute-set-at 2 content-description "private c-desc"
8192 !:echo =21
8193 !^a attribute-at 2
8194 !:echo =22
8195 !^a attribute-set-at 2 content-ID "priv invd c-id"
8196 !:echo =23
8197 !^a attribute-at 2
8198 !:echo =24
8199 !^a attribute-set-at 2 content-TyPE tExT/mARkLO
8200 !:echo =25
8201 !^a attribute-at 2
8202 !:echo =26
8203 !^a attribute-set-at 2 content-TyPE ""
8204 !:echo =27
8205 !^a attribute-at 2
8206 !:echo =28
8208 ' | ${MAILX} ${ARGS} -Sescape=! >./.tall 2>&1
8209 check 14 0 ./.tall '3491667030 1565'
8210 check 15 - ./.tatt '1685063733 636'
8212 t_epilog "${@}"
8215 t_digmsg() { # XXX rudimentary; <> compose_edits()?
8216 t_prolog "${@}"
8218 printf '#
8219 mail ./.tout\n!s This subject is\nThis body is
8220 !:echo --one
8221 !:digmsg create - -
8222 !:digmsg - header list
8223 !:digmsg - header show subject
8224 !:digmsg - header show to
8225 !:digmsg - header remove to
8226 !:digmsg - header list
8227 !:digmsg - header show to
8228 !:digmsg remove -
8229 !:echo --two
8230 !:digmsg create -
8231 !:digmsg - header list; readall x; echon "<$x>";
8232 !:digmsg - header show subject;readall x;echon "<$x>";;
8233 !:digmsg remove -
8234 !:echo --three
8235 !: # nothing here as is comment
8236 !^header insert fcc ./.tbox
8237 !:echo --four
8238 !:digmsg create - -
8239 !:digmsg - header list
8240 !:digmsg - header show fcc
8241 !:echo --five
8242 !^head remove fcc
8243 !:echo --six
8244 !:digmsg - header list
8245 !:digmsg - header show fcc
8246 !:digmsg - header insert fcc ./.tfcc
8247 !:echo --seven
8248 !:digmsg remove -
8249 !:echo bye
8251 echo --hello again
8252 File ./.tfcc
8253 echo --one
8254 digmsg create 1 -
8255 digmsg 1 header list
8256 digmsg 1 header show subject
8257 echo --two
8258 ! : > ./.tempty
8259 File ./.tempty
8260 echo --three
8261 digmsg 1 header list; echo $?/$^ERRNAME
8262 digmsg create -; echo $?/$^ERRNAME
8263 echo ==========
8264 ! %s ./.tfcc > ./.tcat
8265 ! %s "s/This subject is/There subject was/" < ./.tfcc >> ./.tcat
8266 File ./.tcat
8267 mail nowhere@exam.ple
8268 !:echo ===1
8269 !:digmsg create -; echo $?/$^ERRNAME;\\
8270 digmsg create 1; echo $?/$^ERRNAME;\\
8271 digmsg create 2; echo $?/$^ERRNAME
8272 !:echo ===2.1
8273 !:digmsg - h l;echo $?/$^ERRNAME;readall d;echo "$?/$^ERRNAME <$d>"
8274 !:echo =2.2
8275 !:digmsg 1 h l;echo $?/$^ERRNAME;readall d;echo "$?/$^ERRNAME <$d>"
8276 !:echo =2.3
8277 !^ h l
8278 !:echo =2.4
8279 !:digmsg 2 h l;echo $?/$^ERRNAME;readall d;echo "$?/$^ERRNAME <$d>"
8280 !:echo ===3.1
8281 !:digmsg - h s to;echo $?/$^ERRNAME;readall d;echo "$?/$^ERRNAME <$d>"
8282 !:echo =3.2
8283 !:digmsg 1 h s subject;echo $?/$^ERRNAME;readall d;echo "$?/$^ERRNAME <$d>"
8284 !:echo =3.3
8285 !^ h s to
8286 !:echo =3.4
8287 !:digmsg 2 h s subject;echo $?/$^ERRNAME;readall d;echo "$?/$^ERRNAME <$d>"
8288 !:echo ==4.1
8289 !:digmsg remove -; echo $?/$^ERRNAME;\\
8290 digmsg remove 1; echo $?/$^ERRNAME;\\
8291 digmsg remove 2; echo $?/$^ERRNAME;
8293 echo ======= new game new fun!
8294 mail one@to.invalid
8295 !s hossa
8296 !:set expandaddr=-name
8297 !:echo -oneo
8298 !^ header insert to two@to.invalid
8299 !:echo $?/$^ERRNAME
8300 !:echo --two
8301 !^ header insert cc no-name-allowed
8302 !:echo $?/$^ERRNAME
8303 !^ header insert cc one@cc.invalid
8304 !:echo $?/$^ERRNAME
8305 !:echo --three
8306 !:alias abcc one@bcc.invalid
8307 !^ header insert bcc abcc
8308 !:echo $?/$^ERRNAME
8309 !:set expandaddr=+addr
8310 !^ header insert bcc abcc
8311 !:echo $!/$?/$^ERRNAME
8313 echo --bye
8314 ' "${cat}" "${sed}" |
8315 ${MAILX} ${ARGS} -Smta=test://"$MBOX" -Sescape=! >./.tall 2>&1
8316 check 1 0 "$MBOX" '665881681 179'
8317 have_feat uistrings && i='4159482825 1372' || i='2254509488 1103'
8318 check 2 - ./.tall "${i}"
8319 check 3 - ./.tfcc '3993703854 127'
8320 check 4 - ./.tempty '4294967295 0'
8321 check 5 - ./.tcat '2157992522 256'
8323 t_epilog "${@}"
8326 t_on_main_loop_tick() {
8327 t_prolog "${@}"
8329 if have_feat cmd-vexpr; then :; else
8330 t_echoskip '[!CMD_VEXPR]'
8331 t_epilog "${@}"
8332 return
8335 printf '#
8336 echo hello; set i=1
8337 define bla {
8338 echo bla1
8339 echo bla2
8341 define omlt {
8342 echo in omlt: $i
8343 vput vexpr i + 1 $i
8345 echo one
8346 set on-main-loop-tick=omlt
8347 echo two
8348 echo three
8349 echo calling bla;call bla
8350 echo four
8351 echo --bye;xit' |
8352 ${MAILX} ${ARGS} -Smta=test://"$MBOX" -Sescape=! >./.tall 2>&1
8353 check 1 0 ./.tall '3697651500 130'
8355 t_epilog "${@}"
8358 t_on_program_exit() {
8359 t_prolog "${@}"
8361 ${MAILX} ${ARGS} \
8362 -X 'define x {' -X 'echo jay' -X '}' -X x -Son-program-exit=x \
8363 > ./.tall 2>&1
8364 check 1 0 ./.tall '2820891503 4'
8366 ${MAILX} ${ARGS} \
8367 -X 'define x {' -X 'echo jay' -X '}' -X q -Son-program-exit=x \
8368 > ./.tall 2>&1
8369 check 2 0 ./.tall '2820891503 4'
8371 </dev/null ${MAILX} ${ARGS} \
8372 -X 'define x {' -X 'echo jay' -X '}' -Son-program-exit=x \
8373 > ./.tall 2>&1
8374 check 3 0 ./.tall '2820891503 4'
8376 </dev/null ${MAILX} ${ARGS} -Smta=test://"$MBOX" \
8377 -X 'define x {' -X 'echo jay' -X '}' -Son-program-exit=x \
8378 -s subject -. hey@you \
8379 > ./.tall 2>&1
8380 check 4 0 ./.tall '2820891503 4'
8381 check 5 - "$MBOX" '561900352 118'
8383 t_epilog "${@}"
8385 # }}}
8387 # Heavy use of/rely on state machine (behaviour) and basics {{{
8388 t_compose_hooks() { # {{{ TODO monster
8389 t_prolog "${@}"
8391 if have_feat uistrings &&
8392 have_feat cmd-csop && have_feat cmd-vexpr; then :; else
8393 t_echoskip '[!UISTRINGS/!CMD_CSOP/!CMD_VEXPR]'
8394 t_epilog "${@}"
8395 return
8398 (echo line one&&echo line two&&echo line three) > ./.treadctl
8399 (echo echo four&&echo echo five&&echo echo six) > ./.tattach
8401 # Supposed to extend t_compose_edits with ~^ stress tests!
8402 ${cat} <<'__EOT__' > ./.trc
8403 define bail {
8404 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
8406 define xerr {
8407 vput csop es substr "$1" 0 1
8408 if [ "$es" != 2 ]
8409 xcall bail "$2: $1"
8412 define read_mline_res {
8413 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
8414 echo $len/$es/$^ERRNAME: $hl
8415 if [ $es -ne $^ERR-NONE ]
8416 xcall bail read_mline_res
8417 elif [ $len -ne 0 ]
8418 \xcall read_mline_res
8421 define ins_addr {
8422 wysh set xh=$1
8423 echo "~^header list"; read hl; echo $hl;\
8424 call xerr "$hl" "in_addr ($xh) 0-1"
8426 echo "~^header insert $xh 'diet <$xh@exam.ple> spliced'";\
8427 read es; echo $es; call xerr "$es" "ins_addr $xh 1-1"
8428 echo "~^header insert $xh <${xh}2@exam.ple>";\
8429 read es; echo $es; call xerr "$es" "ins_addr $xh 1-2"
8430 echo "~^header insert $xh ${xh}3@exam.ple";\
8431 read es; echo $es; call xerr "$es" "ins_addr $xh 1-3"
8432 echo "~^header list $xh"; read hl; echo $hl;\
8433 call xerr "$hl" "ins_addr $xh 1-4"
8434 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 1-5"
8435 call read_mline_res
8437 if [ "$t_remove" == "" ]
8438 return
8441 echo "~^header remove $xh"; read es; call xerr $es "ins_addr $xh 2-1"
8442 echo "~^header remove $xh"; read es; vput csop es substr $es 0 3
8443 if [ $es != 501 ]
8444 xcall bail "ins_addr $xh 2-2"
8446 echo "~^header list $xh"; read es; vput csop es substr $es 0 3
8447 if [ $es != 501 ]
8448 xcall bail "ins_addr $xh 2-3"
8450 echo "~^header show $xh"; read es; vput csop es substr $es 0 3
8451 if [ $es != 501 ]
8452 xcall bail "ins_addr $xh 2-4"
8456 echo "~^header insert $xh 'diet <$xh@exam.ple> spliced'";\
8457 read es; echo $es; call xerr "$es" "ins_addr $xh 3-1"
8458 echo "~^header insert $xh <${xh}2@exam.ple>";\
8459 read es; echo $es; call xerr "$es" "ins_addr $xh 3-2"
8460 echo "~^header insert $xh ${xh}3@exam.ple";\
8461 read es; echo $es; call xerr "$es" "ins_addr $xh 3-3"
8462 echo "~^header list $xh"; read hl; echo $hl;\
8463 call xerr "$hl" "ins_addr $xh 3-4"
8464 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 3-5"
8465 call read_mline_res
8467 echo "~^header remove-at $xh 1"; read es;\
8468 call xerr $es "ins_addr $xh 3-6"
8469 echo "~^header remove-at $xh 1"; read es;\
8470 call xerr $es "ins_addr $xh 3-7"
8471 echo "~^header remove-at $xh 1"; read es;\
8472 call xerr $es "ins_addr $xh 3-8"
8473 echo "~^header remove-at $xh 1"; read es;\
8474 vput csop es substr $es 0 3
8475 if [ $es != 501 ]
8476 xcall bail "ins_addr $xh 3-9"
8478 echo "~^header remove-at $xh T"; read es;\
8479 vput csop es substr $es 0 3
8480 if [ $es != 505 ]
8481 xcall bail "ins_addr $xh 3-10"
8483 echo "~^header list $xh"; read es;\
8484 vput csop es substr $es 0 3
8485 if [ $es != 501 ]
8486 xcall bail "ins_addr $xh 3-11"
8488 echo "~^header show $xh"; read es;\
8489 vput csop es substr $es 0 3
8490 if [ $es != 501 ]
8491 xcall bail "ins_addr $xh 3-12"
8495 echo "~^header insert $xh 'diet <$xh@exam.ple> spliced'";\
8496 read es; echo $es; call xerr "$es" "ins_addr $xh 4-1"
8497 echo "~^header insert $xh <${xh}2@exam.ple>\ (comment)\ \\\"Quot(e)d\\\"";\
8498 read es; echo $es; call xerr "$es" "ins_addr $xh 4-2"
8499 echo "~^header insert $xh ${xh}3@exam.ple";\
8500 read es; echo $es; call xerr "$es" "ins_addr $xh 4-3"
8501 echo "~^header list $xh"; read hl; echo $hl;\
8502 call xerr "$hl" "header list $xh 3-4"
8503 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 4-5"
8504 call read_mline_res
8506 echo "~^header remove-at $xh 3"; read es;\
8507 call xerr $es "ins_addr $xh 4-6"
8508 echo "~^header remove-at $xh 2"; read es;\
8509 call xerr $es "ins_addr $xh 4-7"
8510 echo "~^header remove-at $xh 1"; read es;\
8511 call xerr $es "ins_addr $xh 4-8"
8512 echo "~^header remove-at $xh 1"; read es;\
8513 vput csop es substr $es 0 3
8514 if [ $es != 501 ]
8515 xcall bail "ins_addr $xh 4-9"
8517 echo "~^header remove-at $xh T"; read es;\
8518 vput csop es substr $es 0 3
8519 if [ $es != 505 ]
8520 xcall bail "ins_addr $xh 4-10"
8522 echo "~^header list $xh"; read es;\
8523 vput csop es substr $es 0 3
8524 if [ $es != 501 ]
8525 xcall bail "ins_addr $xh 4-11"
8527 echo "~^header show $xh"; read es;\
8528 vput csop es substr $es 0 3
8529 if [ $es != 501 ]
8530 xcall bail "ins_addr $xh 4-12"
8533 define ins_ref {
8534 wysh set xh=$1 mult=$2
8535 echo "~^header list"; read hl; echo $hl;\
8536 call xerr "$hl" "ins_ref ($xh) 0-1"
8538 echo "~^header insert $xh <$xh@exam.ple>";\
8539 read es; echo $es; call xerr "$es" "ins_ref $xh 1-1"
8540 if [ $mult -ne 0 ]
8541 echo "~^header insert $xh <${xh}2@exam.ple>";\
8542 read es; echo $es; call xerr "$es" "ins_ref $xh 1-2"
8543 echo "~^header insert $xh ${xh}3@exam.ple";\
8544 read es; echo $es; call xerr "$es" "ins_ref $xh 1-3"
8545 else
8546 echo "~^header insert $xh <${xh}2@exam.ple>"; read es;\
8547 vput csop es substr $es 0 3
8548 if [ $es != 506 ]
8549 xcall bail "ins_ref $xh 1-4"
8553 echo "~^header list $xh"; read hl; echo $hl;\
8554 call xerr "$hl" "ins_ref $xh 1-5"
8555 echo "~^header show $xh"; read es; call xerr $es "ins_ref $xh 1-6"
8556 call read_mline_res
8558 if [ "$t_remove" == "" ]
8559 return
8562 echo "~^header remove $xh"; read es;\
8563 call xerr $es "ins_ref $xh 2-1"
8564 echo "~^header remove $xh"; read es;\
8565 vput csop es substr $es 0 3
8566 if [ $es != 501 ]
8567 xcall bail "ins_ref $xh 2-2"
8569 echo "~^header list $xh"; read es;\
8570 vput csop es substr $es 0 3
8571 if [ $es != 501 ]
8572 xcall bail "$es ins_ref $xh 2-3"
8574 echo "~^header show $xh"; read es;\
8575 vput csop es substr $es 0 3
8576 if [ $es != 501 ]
8577 xcall bail "ins_ref $xh 2-4"
8581 echo "~^header insert $xh <$xh@exam.ple>";\
8582 read es; echo $es; call xerr "$es" "ins_ref $xh 3-1"
8583 if [ $mult -ne 0 ]
8584 echo "~^header insert $xh <${xh}2@exam.ple>";\
8585 read es; echo $es; call xerr "$es" "ins_ref $xh 3-2"
8586 echo "~^header insert $xh ${xh}3@exam.ple";\
8587 read es; echo $es; call xerr "$es" "ins_ref $xh 3-3"
8589 echo "~^header list $xh";\
8590 read hl; echo $hl; call xerr "$hl" "ins_ref $xh 3-4"
8591 echo "~^header show $xh";\
8592 read es; call xerr $es "ins_ref $xh 3-5"
8593 call read_mline_res
8595 echo "~^header remove-at $xh 1"; read es;\
8596 call xerr $es "ins_ref $xh 3-6"
8597 if [ $mult -ne 0 ] && [ $xh != subject ]
8598 echo "~^header remove-at $xh 1"; read es;\
8599 call xerr $es "ins_ref $xh 3-7"
8600 echo "~^header remove-at $xh 1"; read es;\
8601 call xerr $es "ins_ref $xh 3-8"
8603 echo "~^header remove-at $xh 1"; read es;\
8604 vput csop es substr $es 0 3
8605 if [ $es != 501 ]
8606 xcall bail "ins_ref $xh 3-9"
8608 echo "~^header remove-at $xh T"; read es;\
8609 vput csop es substr $es 0 3
8610 if [ $es != 505 ]
8611 xcall bail "ins_ref $xh 3-10"
8613 echo "~^header show $xh"; read es;\
8614 vput csop es substr $es 0 3
8615 if [ $es != 501 ]
8616 xcall bail "ins_ref $xh 3-11"
8620 echo "~^header insert $xh <$xh@exam.ple> ";\
8621 read es; echo $es; call xerr "$es" "ins_ref $xh 4-1"
8622 if [ $mult -ne 0 ]
8623 echo "~^header insert $xh <${xh}2@exam.ple> ";\
8624 read es; echo $es; call xerr "$es" "ins_ref $xh 4-2"
8625 echo "~^header insert $xh ${xh}3@exam.ple";\
8626 read es; echo $es; call xerr "$es" "ins_ref $xh 4-3"
8628 echo "~^header list $xh"; read hl; echo $hl;\
8629 call xerr "$hl" "ins_ref $xh 4-4"
8630 echo "~^header show $xh"; read es; call xerr $es "ins_ref $xh 4-5"
8631 call read_mline_res
8633 if [ $mult -ne 0 ] && [ $xh != subject ]
8634 echo "~^header remove-at $xh 3"; read es;\
8635 call xerr $es "ins_ref $xh 4-6"
8636 echo "~^header remove-at $xh 2"; read es;\
8637 call xerr $es "ins_ref $xh 4-7"
8639 echo "~^header remove-at $xh 1"; read es;\
8640 call xerr $es "ins_ref $xh 4-8"
8641 echo "~^header remove-at $xh 1"; read es;\
8642 vput csop es substr $es 0 3
8643 if [ $es != 501 ]
8644 xcall bail "ins_ref $xh 4-9"
8646 echo "~^header remove-at $xh T"; read es;\
8647 vput csop es substr $es 0 3
8648 if [ $es != 505 ]
8649 xcall bail "ins_ref $xh 4-10"
8651 echo "~^header show $xh"; read es;\
8652 vput csop es substr $es 0 3
8653 if [ $es != 501 ]
8654 xcall bail "ins_ref $xh 4-11"
8657 define t_header {
8658 echo t_header ENTER
8659 # In collect.c order
8660 call ins_addr from
8661 call ins_ref sender 0 # Not a "ref", but works
8662 call ins_addr To
8663 call ins_addr cC
8664 call ins_addr bCc
8665 call ins_addr reply-To
8666 call ins_addr mail-Followup-to
8667 call ins_ref messAge-id 0
8668 call ins_ref rEfErEncEs 1
8669 call ins_ref in-Reply-to 1
8670 call ins_ref subject 1 # Not a "ref", but works (with tweaks)
8671 call ins_addr freeForm1
8672 call ins_addr freeform2
8674 echo "~^header show MAILX-Command"; read es; call xerr $es "t_header 1000"
8675 call read_mline_res
8676 echo "~^header show MAILX-raw-TO"; read es; call xerr $es "t_header 1001"
8677 call read_mline_res
8679 echo t_header LEAVE
8681 define t_attach {
8682 echo t_attach ENTER
8684 echo "~^attachment";\
8685 read hl; echo $hl; vput csop es substr "$hl" 0 3
8686 if [ "$es" != 501 ]
8687 xcall bail "attach 0-1"
8690 echo "~^attach attribute ./.treadctl";\
8691 read hl; echo $hl; vput csop es substr "$hl" 0 3
8692 if [ "$es" != 501 ]
8693 xcall bail "attach 0-2"
8695 echo "~^attachment attribute-at 1";\
8696 read hl; echo $hl; vput csop es substr "$hl" 0 3
8697 if [ "$es" != 501 ]
8698 xcall bail "attach 0-3"
8701 echo "~^attachment insert ./.treadctl=ascii";\
8702 read hl; echo $hl; call xerr "$hl" "attach 1-1"
8703 echo "~^attachment list";\
8704 read es; echo $es;call xerr "$es" "attach 1-2"
8705 call read_mline_res
8706 echo "~^attachment attribute ./.treadctl";\
8707 read es; echo $es;call xerr "$es" "attach 1-3"
8708 call read_mline_res
8709 echo "~^attachment attribute .treadctl";\
8710 read es; echo $es;call xerr "$es" "attach 1-4"
8711 call read_mline_res
8712 echo "~^attachment attribute-at 1";\
8713 read es; echo $es;call xerr "$es" "attach 1-5"
8714 call read_mline_res
8716 echo "~^attachment attribute-set ./.treadctl filename rctl";\
8717 read es; echo $es;call xerr "$es" "attach 1-6"
8718 echo "~^attachment attribute-set .treadctl content-description Au";\
8719 read es; echo $es;call xerr "$es" "attach 1-7"
8720 echo "~^attachment attribute-set-at 1 content-id <10.du@ich>";\
8721 read es; echo $es;call xerr "$es" "attach 1-8"
8723 echo "~^attachment attribute ./.treadctl";\
8724 read es; echo $es;call xerr "$es" "attach 1-9"
8725 call read_mline_res
8726 echo "~^attachment attribute .treadctl";\
8727 read es; echo $es;call xerr "$es" "attach 1-10"
8728 call read_mline_res
8729 echo "~^attachment attribute rctl";\
8730 read es; echo $es;call xerr "$es" "attach 1-11"
8731 call read_mline_res
8732 echo "~^attachment attribute-at 1";\
8733 read es; echo $es;call xerr "$es" "attach 1-12"
8734 call read_mline_res
8737 echo "~^attachment insert ./.tattach=latin1";\
8738 read hl; echo $hl; call xerr "$hl" "attach 2-1"
8739 echo "~^attachment list";\
8740 read es; echo $es;call xerr "$es" "attach 2-2"
8741 call read_mline_res
8742 echo "~^attachment attribute ./.tattach";\
8743 read es; echo $es;call xerr "$es" "attach 2-3"
8744 call read_mline_res
8745 echo "~^attachment attribute .tattach";\
8746 read es; echo $es;call xerr "$es" "attach 2-4"
8747 call read_mline_res
8748 echo "~^attachment attribute-at 2";\
8749 read es; echo $es;call xerr "$es" "attach 2-5"
8750 call read_mline_res
8752 echo "~^attachment attribute-set ./.tattach filename tat";\
8753 read es; echo $es;call xerr "$es" "attach 2-6"
8754 echo \
8755 "~^attachment attribute-set .tattach content-description Au2";\
8756 read es; echo $es;call xerr "$es" "attach 2-7"
8757 echo "~^attachment attribute-set-at 2 content-id <20.du@wir>";\
8758 read es; echo $es;call xerr "$es" "attach 2-8"
8759 echo \
8760 "~^attachment attribute-set-at 2 content-type application/x-sh";\
8761 read es; echo $es;call xerr "$es" "attach 2-9"
8763 echo "~^attachment attribute ./.tattach";\
8764 read es; echo $es;call xerr "$es" "attach 2-10"
8765 call read_mline_res
8766 echo "~^attachment attribute .tattach";\
8767 read es; echo $es;call xerr "$es" "attach 2-11"
8768 call read_mline_res
8769 echo "~^attachment attribute tat";\
8770 read es; echo $es;call xerr "$es" "attach 2-12"
8771 call read_mline_res
8772 echo "~^attachment attribute-at 2";\
8773 read es; echo $es;call xerr "$es" "attach 2-13"
8774 call read_mline_res
8777 if [ "$t_remove" == "" ]
8778 return
8781 echo "~^attachment remove ./.treadctl"; read es;\
8782 call xerr $es "attach 3-1"
8783 echo "~^attachment remove ./.tattach"; read es;\
8784 call xerr $es "attach 3-2"
8785 echo "~^ attachment remove ./.treadctl"; read es;\
8786 vput csop es substr $es 0 3
8787 if [ $es != 501 ]
8788 xcall bail "attach 3-3"
8790 echo "~^ attachment remove ./.tattach"; read es;\
8791 vput csop es substr $es 0 3
8792 if [ $es != 501 ]
8793 xcall bail "attach 3-4"
8795 echo "~^attachment list"; read es;\
8796 vput csop es substr $es 0 3
8797 if [ $es != 501 ]
8798 xcall bail "attach 3-5"
8802 echo "~^attachment insert ./.tattach=latin1";\
8803 read hl; echo $hl; call xerr "$hl" "attach 4-1"
8804 echo "~^attachment insert ./.tattach=latin1";\
8805 read hl; echo $hl; call xerr "$hl" "attach 4-2"
8806 echo "~^attachment list";\
8807 read es; echo $es;call xerr "$es" "attach 4-3"
8808 call read_mline_res
8809 echo "~^ attachment remove .tattach"; read es;\
8810 vput csop es substr $es 0 3
8811 if [ $es != 506 ]
8812 xcall bail "attach 4-4 $es"
8814 echo "~^attachment remove-at T"; read es;\
8815 vput csop es substr $es 0 3
8816 if [ $es != 505 ]
8817 xcall bail "attach 4-5"
8819 echo "~^attachment remove ./.tattach"; read es;\
8820 call xerr $es "attach 4-6"
8821 echo "~^attachment remove ./.tattach"; read es;\
8822 call xerr $es "attach 4-7"
8823 echo "~^ attachment remove ./.tattach"; read es;\
8824 vput csop es substr $es 0 3
8825 if [ $es != 501 ]
8826 xcall bail "attach 4-8 $es"
8828 echo "~^attachment list"; read es;\
8829 vput csop es substr $es 0 3
8830 if [ $es != 501 ]
8831 xcall bail "attach 4-9"
8835 echo "~^attachment insert ./.tattach=latin1";\
8836 read hl; echo $hl; call xerr "$hl" "attach 5-1"
8837 echo "~^attachment insert ./.tattach=latin1";\
8838 read hl; echo $hl; call xerr "$hl" "attach 5-2"
8839 echo "~^attachment insert ./.tattach=latin1";\
8840 read hl; echo $hl; call xerr "$hl" "attach 5-3"
8841 echo "~^attachment list";\
8842 read es; echo $es;call xerr "$es" "attach 5-4"
8843 call read_mline_res
8845 echo "~^attachment remove-at 3"; read es;\
8846 call xerr $es "attach 5-5"
8847 echo "~^attachment remove-at 3"; read es;\
8848 vput csop es substr $es 0 3
8849 if [ $es != 501 ]
8850 xcall bail "attach 5-6"
8852 echo "~^attachment remove-at 2"; read es;\
8853 call xerr $es "attach 5-7"
8854 echo "~^attachment remove-at 2"; read es;\
8855 vput csop es substr $es 0 3
8856 if [ $es != 501 ]
8857 xcall bail "attach 5-8"
8859 echo "~^attachment remove-at 1"; read es;\
8860 call xerr $es "attach 5-9"
8861 echo "~^attachment remove-at 1"; read es;\
8862 vput csop es substr $es 0 3
8863 if [ $es != 501 ]
8864 xcall bail "attach 5-10"
8867 echo "~^attachment list"; read es;\
8868 vput csop es substr $es 0 3
8869 if [ $es != 501 ]
8870 xcall bail "attach 5-11"
8874 echo "~^attachment insert ./.tattach=latin1";\
8875 read hl; echo $hl; call xerr "$hl" "attach 6-1"
8876 echo "~^attachment insert ./.tattach=latin1";\
8877 read hl; echo $hl; call xerr "$hl" "attach 6-2"
8878 echo "~^attachment insert ./.tattach=latin1";\
8879 read hl; echo $hl; call xerr "$hl" "attach 6-3"
8880 echo "~^attachment list";\
8881 read es; echo $es;call xerr "$es" "attach 6-4"
8882 call read_mline_res
8884 echo "~^attachment remove-at 1"; read es;\
8885 call xerr $es "attach 6-5"
8886 echo "~^attachment remove-at 1"; read es;\
8887 call xerr $es "attach 6-6"
8888 echo "~^attachment remove-at 1"; read es;\
8889 call xerr $es "attach 6-7"
8890 echo "~^attachment remove-at 1"; read es;\
8891 vput csop es substr $es 0 3
8892 if [ $es != 501 ]
8893 xcall bail "attach 6-8"
8896 echo "~^attachment list"; read es;\
8897 vput csop es substr $es 0 3
8898 if [ $es != 501 ]
8899 xcall bail "attach 6-9"
8902 echo t_attach LEAVE
8904 define t_ocs {
8905 read ver
8906 echo t_ocs
8907 call t_header
8908 call t_attach
8910 define t_oce {
8911 echo on-compose-enter, mailx-command<$mailx-command>
8912 alternates alter1@exam.ple alter2@exam.ple
8913 alternates
8914 set autocc='alter1@exam.ple alter2@exam.ple'
8915 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
8916 echo mailx-subject<$mailx-subject>
8917 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
8918 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
8919 mailx-raw-bcc<$mailx-raw-bcc>
8920 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
8921 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
8922 digmsg create - -;echo $?/$!/$^ERRNAME;\
8923 digmsg - header list;\
8924 digmsg remove -;echo $?/$!/$^ERRNAME
8925 digmsg create -;echo $?/$!/$^ERRNAME;\
8926 digmsg - header list;readall x;echon $x;\
8927 digmsg remove -;echo $?/$!/$^ERRNAME
8929 define t_ocl {
8930 echo on-compose-leave, mailx-command<$mailx-command>
8931 vput alternates al
8932 eval alternates $al alter3@exam.ple alter4@exam.ple
8933 alternates
8934 set autobcc='alter3@exam.ple alter4@exam.ple'
8935 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
8936 echo mailx-subject<$mailx-subject>
8937 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
8938 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
8939 mailx-raw-bcc<$mailx-raw-bcc>
8940 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
8941 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
8942 digmsg create - -;echo $?/$!/$^ERRNAME;\
8943 digmsg - header list;\
8944 digmsg remove -;echo $?/$!/$^ERRNAME
8945 digmsg create -;echo $?/$!/$^ERRNAME;\
8946 digmsg - header list;readall x;echon $x;\
8947 digmsg remove -;echo $?/$!/$^ERRNAME
8949 define t_occ {
8950 echo on-compose-cleanup, mailx-command<$mailx-command>
8951 unalternates *
8952 alternates
8953 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
8954 echo mailx-subject<$mailx-subject>
8955 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
8956 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
8957 mailx-raw-bcc<$mailx-raw-bcc>
8958 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
8959 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
8960 # XXX error message variable digmsg create - -;echo $?/$!/$^ERRNAME;\
8961 digmsg - header list;\
8962 digmsg remove -;echo $?/$!/$^ERRNAME
8963 # ditto digmsg create -;echo $?/$!/$^ERRNAME;\
8964 digmsg - header list;readall x;echon $x;\
8965 digmsg remove -;echo $?/$!/$^ERRNAME
8967 wysh set on-compose-splice=t_ocs \
8968 on-compose-enter=t_oce on-compose-leave=t_ocl \
8969 on-compose-cleanup=t_occ
8970 __EOT__
8972 printf 'm this-goes@nowhere\nbody\n!.\n' |
8973 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
8974 -X'source ./.trc' -Smta=test://"$MBOX" \
8975 >./.tall 2>&1
8976 ${cat} ./.tall >> "${MBOX}"
8977 check 1 0 "${MBOX}" '1646284089 10565'
8979 ${rm} "${MBOX}"
8980 printf 'm this-goes@nowhere\nbody\n!.\n' |
8981 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
8982 -St_remove=1 -X'source ./.trc' -Smta=test://"$MBOX" \
8983 >./.tall 2>&1
8984 ${cat} ./.tall >> "${MBOX}"
8985 check 2 0 "${MBOX}" '700681006 12851'
8989 # Some state machine stress, shell compose hook, localopts for hook, etc.
8990 # readctl in child. ~r as HERE document
8991 ${rm} "${MBOX}"
8992 printf 'm ex@am.ple\nbody\n!.
8993 echon ${mailx-command}${mailx-subject}
8994 echon ${mailx-from}${mailx-sender}
8995 echon ${mailx-to}${mailx-cc}${mailx-bcc}
8996 echon ${mailx-raw-to}${mailx-raw-cc}${mailx-raw-bcc}
8997 echon ${mailx-orig-from}${mailx-orig-to}${mailx-orig-gcc}${mailx-orig-bcc}
8998 var t_oce t_ocs t_ocs_sh t_ocl t_occ autocc
8999 ' | ${MAILX} ${ARGS} -Snomemdebug -Sescape=! \
9000 -Smta=test://"$MBOX" \
9002 define bail {
9003 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
9005 define xerr {
9006 vput csop es substr "$1" 0 1
9007 if [ "$es" != 2 ]
9008 xcall bail "$2"
9011 define read_mline_res {
9012 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
9013 echo $len/$es/$^ERRNAME: $hl
9014 if [ $es -ne $^ERR-NONE ]
9015 xcall bail read_mline_res
9016 elif [ $len -ne 0 ]
9017 \xcall read_mline_res
9020 define _work {
9021 vput vexpr i + 1 "$2"
9022 if [ $i -lt 111 ]
9023 vput vexpr j % $i 10
9024 if [ $j -ne 0 ]
9025 set j=xcall
9026 else
9027 echon "$i.. "
9028 set j=call
9030 eval \\$j _work $1 $i
9031 return $?
9033 vput vexpr i + $i "$1"
9034 return $i
9036 define _read {
9037 wysh set line; read line;wysh set es=$? en=$^ERRNAME ;\
9038 echo read:$es/$en: $line
9039 if [ "${es}" -ne -1 ]
9040 xcall _read
9042 readctl remove $cwd/.treadctl; echo readctl remove:$?/$^ERRNAME
9044 define t_ocs {
9045 read ver
9046 echo t_ocs
9047 echo "~^header list"; read hl; echo $hl;\
9048 vput csop es substr "$hl" 0 1
9049 if [ "$es" != 2 ]
9050 xcall bail "header list"
9051 endif
9053 call _work 1; echo $?
9054 echo "~^header insert cc splicy\ diet\ <splice@exam.ple>\ spliced";\
9055 read es; echo $es; vput csop es substr "$es" 0 1
9056 if [ "$es" != 2 ]
9057 xcall bail "be diet"
9058 endif
9059 echo "~^header insert cc <splice2@exam.ple>";\
9060 read es; echo $es; vput csop es substr "$es" 0 1
9061 if [ "$es" != 2 ]
9062 xcall bail "be diet2"
9063 endif
9065 call _work 2; echo $?
9066 echo "~^header insert bcc juicy\ juice\ <juice@exam.ple>\ spliced";\
9067 read es; echo $es;vput csop es substr "$es" 0 1
9068 if [ "$es" != 2 ]
9069 xcall bail "be juicy"
9070 endif
9071 echo "~^header insert bcc juice2@exam.ple";\
9072 read es; echo $es;vput csop es substr "$es" 0 1
9073 if [ "$es" != 2 ]
9074 xcall bail "be juicy2"
9075 endif
9076 echo "~^header insert bcc juice3\ <juice3@exam.ple>";\
9077 read es; echo $es;vput csop es substr "$es" 0 1
9078 if [ "$es" != 2 ]
9079 xcall bail "be juicy3"
9080 endif
9081 echo "~^header insert bcc juice4@exam.ple";\
9082 read es; echo $es;vput csop es substr "$es" 0 1
9083 if [ "$es" != 2 ]
9084 xcall bail "be juicy4"
9085 endif
9087 echo "~^header remove-at bcc 3";\
9088 read es; echo $es;vput csop es substr "$es" 0 1
9089 if [ "$es" != 2 ]
9090 xcall bail "remove juicy5"
9091 endif
9092 echo "~^header remove-at bcc 2";\
9093 read es; echo $es;vput csop es substr "$es" 0 1
9094 if [ "$es" != 2 ]
9095 xcall bail "remove juicy6"
9096 endif
9097 echo "~^header remove-at bcc 3";\
9098 read es; echo $es;vput csop es substr "$es" 0 3
9099 if [ "$es" != 501 ]
9100 xcall bail "failed to remove-at"
9101 endif
9102 # Add duplicates which ought to be removed!
9103 echo "~^header insert bcc juice4@exam.ple";\
9104 read es; echo $es;vput csop es substr "$es" 0 1
9105 if [ "$es" != 2 ]
9106 xcall bail "be juicy4-1"
9107 endif
9108 echo "~^header insert bcc juice4@exam.ple";\
9109 read es; echo $es;vput csop es substr "$es" 0 1
9110 if [ "$es" != 2 ]
9111 xcall bail "be juicy4-2"
9112 endif
9113 echo "~^header insert bcc juice4@exam.ple";\
9114 read es; echo $es;vput csop es substr "$es" 0 1
9115 if [ "$es" != 2 ]
9116 xcall bail "be juicy4-3"
9117 endif
9118 echo "~:set t_ocs"
9121 call _work 3; echo $?
9122 echo "~r - '__EOT'"
9123 vput ! i echo just knock if you can hear me;\
9124 i=0;\
9125 while [ $i -lt 24 ]; do printf "%s " $i; i=`expr $i + 1`; done;\
9126 echo relax
9127 echon shell-cmd says $?/$^ERRNAME: $i
9128 echo "~x will not become interpreted, we are reading until __EOT"
9129 echo "__EOT"
9130 read r_status; echo "~~r status output: $r_status"
9131 echo "~:echo $? $! $^ERRNAME"
9132 read r_status
9133 echo "~~r status from parent: $r_status"
9136 call _work 4; echo $?
9137 vput cwd cwd;echo cwd:$?
9138 readctl create $cwd/.treadctl ;echo readctl:$?/$^ERRNAME;\
9139 call _read
9142 call _work 5; echo $?
9143 echo "~^header show MAILX-Command"; read es;\
9144 call xerr $es "t_header 1000"; call read_mline_res
9145 echo "~^header show MAILX-raw-TO"; read es;\
9146 call xerr $es "t_header 1001"; xcall read_mline_res
9148 echoerr IT IS WRONG IF YOU SEE THIS
9150 define t_oce {
9151 echo on-compose-enter, mailx-command<$mailx-command>
9152 set t_oce autobcc=oce@exam.ple
9153 alternates alter1@exam.ple alter2@exam.ple
9154 alternates
9155 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
9156 echo mailx-subject<$mailx-subject>
9157 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
9158 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
9159 mailx-raw-bcc<$mailx-raw-bcc>
9160 echo mailx-orig-from<$mailx-orig-from> \
9161 mailx-orig-to<$mailx-orig-to> \
9162 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
9164 define t_ocl {
9165 echo on-compose-leave, mailx-command<$mailx-command>
9166 set t_ocl autocc=ocl@exam.ple
9167 unalternates *
9168 alternates alter3@exam.ple alter4@exam.ple
9169 alternates
9170 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
9171 echo mailx-subject<$mailx-subject>
9172 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
9173 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
9174 mailx-raw-bcc<$mailx-raw-bcc>
9175 echo mailx-orig-from<$mailx-orig-from> \
9176 mailx-orig-to<$mailx-orig-to> \
9177 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
9179 define t_occ {
9180 echo on-compose-cleanup, mailx-command<$mailx-command>
9181 set t_occ autocc=occ@exam.ple
9182 unalternates *
9183 alternates
9184 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
9185 echo mailx-subject<$mailx-subject>
9186 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
9187 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
9188 mailx-raw-bcc<$mailx-raw-bcc>
9189 echo mailx-orig-from<$mailx-orig-from> \
9190 mailx-orig-to<$mailx-orig-to> \
9191 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
9193 wysh set on-compose-splice=t_ocs \
9194 on-compose-splice-shell="read ver;echo t_ocs-shell;\
9195 echo \"~t shell@exam.ple\"; echo \"~:set t_ocs_sh\"" \
9196 on-compose-enter=t_oce on-compose-leave=t_ocl \
9197 on-compose-cleanup=t_occ
9198 ' > ./.tnotes 2>&1
9199 check_ex0 3-estat
9200 ${cat} ./.tnotes >> "${MBOX}"
9201 check 3 - "${MBOX}" '3986011319 2437'
9203 # Reply, forward, resend, Resend
9205 ${rm} "${MBOX}"
9206 printf '#
9207 set from="f1@z"
9208 m t1@z
9211 set from="du <f2@z>" stealthmua=noagent
9212 m t2@z
9215 ' | ${MAILX} ${ARGS} -Smta=test://"$MBOX" -Snomemdebug -Sescape=! \
9216 > ./.tnotes 2>&1
9217 check_ex0 4-intro-estat
9219 printf '
9220 echo start: $? $! $^ERRNAME
9221 File %s
9222 echo File: $? $! $^ERRNAME;echo;echo
9223 reply 1
9224 this is content of reply 1
9226 echo reply 1: $? $! $^ERRNAME;echo;echo
9227 Reply 1 2
9228 this is content of Reply 1 2
9230 echo Reply 1 2: $? $! $^ERRNAME;echo;echo
9231 forward 1 fwdex@am.ple
9232 this is content of forward 1
9234 echo forward 1: $? $! $^ERRNAME;echo;echo
9235 wysh set forward-inject-head=$'"'"'-- \\
9236 forward (%%a)(%%d)(%%f)(%%i)(%%n)(%%r) --\\n'"'"'
9237 wysh set forward-inject-tail=$'"'"'-- \\
9238 end of forward (%%i) --\\n'"'"'
9239 forward 2 fwdex@am.ple
9240 this is content of forward 2
9242 echo forward 2: $? $! $^ERRNAME;echo;echo
9243 set showname
9244 forward 2 fwdex2@am.ple
9245 this is content of forward 2, 2nd, with showname set
9247 echo forward 2, 2nd: $? $! $^ERRNAME;echo;echo
9248 resend 1 2 resendex@am.ple
9249 echo resend 1 2: $? $! $^ERRNAME;echo;echo
9250 Resend 1 2 Resendex@am.ple
9251 echo Resend 1 2: $? $! $^ERRNAME;echo;echo
9252 ' "${MBOX}" |
9253 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sfullnames \
9254 -Smta=test://"$MBOX" \
9256 define bail {
9257 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
9259 define xerr {
9260 vput csop es substr "$1" 0 1
9261 if [ "$es" != 2 ]
9262 xcall bail "$2"
9265 define read_mline_res {
9266 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
9267 echo mline_res:$len/$es/$^ERRNAME: $hl
9268 if [ $es -ne $^ERR-NONE ]
9269 xcall bail read_mline_res
9270 elif [ $len -ne 0 ]
9271 \xcall read_mline_res
9274 define work_hl {
9275 echo "~^header show $1"; read es;\
9276 call xerr $es "work_hl $1"; echo $1; call read_mline_res
9277 if [ $# -gt 1 ]
9278 shift
9279 xcall work_hl "$@"
9282 define t_ocs {
9283 read ver
9284 echo t_ocs version $ver
9285 echo "~^header list"; read hl; echo $hl;\
9286 echoerr the header list is $hl;\
9287 call xerr "$hl" "header list"
9288 eval vpospar set $hl
9289 shift
9290 xcall work_hl "$@"
9291 echoerr IT IS WRONG IF YOU SEE THIS
9293 define t_oce {
9294 echo on-XY-enter, mailx-command<$mailx-command>
9295 set t_oce autobcc=oce@exam.ple
9296 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
9297 echo mailx-subject<$mailx-subject>
9298 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
9299 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
9300 mailx-raw-bcc<$mailx-raw-bcc>
9301 echo mailx-orig-from<$mailx-orig-from> \
9302 mailx-orig-to<$mailx-orig-to> \
9303 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
9305 define t_ocl {
9306 echo on-XY-leave, mailx-command<$mailx-command>
9307 set t_ocl autocc=ocl@exam.ple
9308 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
9309 echo mailx-subject<$mailx-subject>
9310 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
9311 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
9312 mailx-raw-bcc<$mailx-raw-bcc>
9313 echo mailx-orig-from<$mailx-orig-from> \
9314 mailx-orig-to<$mailx-orig-to> \
9315 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
9317 define t_occ {
9318 echo on-XY-cleanup, mailx-command<$mailx-command>
9319 set t_occ autocc=occ@exam.ple
9320 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
9321 echo mailx-subject<$mailx-subject>
9322 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
9323 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
9324 mailx-raw-bcc<$mailx-raw-bcc>
9325 echo mailx-orig-from<$mailx-orig-from> \
9326 mailx-orig-to<$mailx-orig-to> \
9327 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
9329 wysh set on-compose-splice=t_ocs \
9330 on-compose-enter=t_oce on-compose-leave=t_ocl \
9331 on-compose-cleanup=t_occ \
9332 on-resend-enter=t_oce on-resend-cleanup=t_occ
9333 ' >> ./.tnotes 2>&1
9334 check_ex0 4-estat
9335 ${cat} ./.tnotes >> "${MBOX}"
9336 check 4 - "${MBOX}" '1850092468 11799'
9338 t_epilog "${@}"
9339 } # }}}
9341 t_mass_recipients() {
9342 t_prolog "${@}"
9344 if have_feat cmd-vexpr; then :; else
9345 t_echoskip '[!CMD_VEXPR]'
9346 t_epilog "${@}"
9347 return
9350 ${cat} <<'__EOT__' > ./.trc
9351 define bail {
9352 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
9354 define ins_addr {
9355 wysh set nr=$1 hn=$2
9356 echo "~$hn $hn$nr@$hn"; echo '~:echo $?'; read es
9357 if [ "$es" -ne 0 ]
9358 xcall bail "ins_addr $hn 1-$nr"
9360 vput vexpr nr + $nr 1
9361 if [ "$nr" -le "$maximum" ]
9362 xcall ins_addr $nr $hn
9365 define bld_alter {
9366 wysh set nr=$1 hn=$2
9367 alternates $hn$nr@$hn
9368 vput vexpr nr + $nr 2
9369 if [ "$nr" -le "$maximum" ]
9370 xcall bld_alter $nr $hn
9373 define t_ocs {
9374 read ver
9375 call ins_addr 1 t
9376 call ins_addr 1 c
9377 call ins_addr 1 b
9379 define t_ocl {
9380 if [ "$t_remove" != '' ]
9381 call bld_alter 1 t
9382 call bld_alter 2 c
9385 set on-compose-splice=t_ocs on-compose-leave=t_ocl
9386 __EOT__
9388 printf 'm this-goes@nowhere\nbody\n!.\n' |
9389 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
9390 -X'source ./.trc' -Smta=test://"$MBOX" -Smaximum=${LOOPS_MAX} \
9391 >./.tall 2>&1
9392 check_ex0 1-estat
9393 ${cat} ./.tall >> "${MBOX}"
9394 if [ ${LOOPS_MAX} -eq ${LOOPS_BIG} ]; then
9395 check 1-${LOOPS_BIG} - "${MBOX}" '3835365533 51534'
9396 elif [ ${LOOPS_MAX} -eq ${LOOPS_SMALL} ]; then
9397 check 1-${LOOPS_SMALL} - "${MBOX}" '3647549277 4686'
9400 ${rm} "${MBOX}"
9401 printf 'm this-goes@nowhere\nbody\n!.\n' |
9402 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
9403 -St_remove=1 -X'source ./.trc' -Smta=test://"$MBOX" \
9404 -Smaximum=${LOOPS_MAX} \
9405 >./.tall 2>&1
9406 check_ex0 2-estat
9407 ${cat} ./.tall >> "${MBOX}"
9408 if [ ${LOOPS_MAX} -eq ${LOOPS_BIG} ]; then
9409 check 2-${LOOPS_BIG} - "${MBOX}" '3768249992 34402'
9410 elif [ $LOOPS_MAX -eq ${LOOPS_SMALL} ]; then
9411 check 2-${LOOPS_SMALL} - "${MBOX}" '4042568441 3170'
9414 t_epilog "${@}"
9417 t_lreply_futh_rth_etc() {
9418 t_prolog "${@}"
9420 ${cat} <<-_EOT > ./.tmbox
9421 From neverneverland Sun Jul 23 13:46:25 2017
9422 Subject: Bugstop: five miles out 1
9423 Reply-To: mister originator2 <mr2@originator>, bugstop@five.miles.out
9424 From: mister originator <mr@originator>
9425 To: bugstop-commit@five.miles.out, laber@backe.eu
9426 Cc: is@a.list
9427 Mail-Followup-To: bugstop@five.miles.out, laber@backe.eu, is@a.list
9428 In-reply-to: <20170719111113.bkcMz%laber@backe.eu>
9429 Date: Wed, 19 Jul 2017 09:22:57 -0400
9430 Message-Id: <20170719132257.766AF781267@originator>
9431 Status: RO
9433 > |Sorry, I think I misunderstand something. I would think that
9435 That's appalling.
9437 From neverneverland Fri Jul 7 22:39:11 2017
9438 Subject: Bugstop: five miles out 2
9439 Reply-To: mister originator2<mr2@originator>,bugstop@five.miles.out,is@a.list
9440 Content-Transfer-Encoding: 7bit
9441 From: mister originator <mr@originator>
9442 To: bugstop-commit@five.miles.out
9443 Cc: is@a.list
9444 Message-ID: <149945963975.28888.6950788126957753723.reportbug@five.miles.out>
9445 Date: Fri, 07 Jul 2017 16:33:59 -0400
9446 Status: R
9448 capable of changing back.
9450 From neverneverland Fri Jul 7 22:42:00 2017
9451 Subject: Bugstop: five miles out 3
9452 Reply-To: mister originator2 <mr2@originator>, bugstop@five.miles.out
9453 Content-Transfer-Encoding: 7bit
9454 From: mister originator <mr@originator>
9455 To: bugstop-commit@five.miles.out
9456 Cc: is@a.list
9457 Message-ID: <149945963975.28888.6950788126957753746.reportbug@five.miles.out>
9458 Date: Fri, 07 Jul 2017 16:33:59 -0400
9459 List-Post: <mailto:bugstop@five.miles.out>
9460 Status: R
9462 are you ready, boots?
9464 From neverneverland Sat Aug 19 23:15:00 2017
9465 Subject: Bugstop: five miles out 4
9466 Reply-To: mister originator2 <mr2@originator>, bugstop@five.miles.out
9467 Content-Transfer-Encoding: 7bit
9468 From: mister originator <mr@originator>
9469 To: bugstop@five.miles.out
9470 Cc: is@a.list
9471 Message-ID: <149945963975.28888.6950788126qtewrqwer.reportbug@five.miles.out>
9472 Date: Fri, 07 Jul 2017 16:33:59 -0400
9473 List-Post: <mailto:bugstop@five.miles.out>
9474 Status: R
9476 are you ready, boots?
9477 _EOT
9481 ${cat} <<-'_EOT' | ${MAILX} ${ARGS} -Sescape=! -Smta=test://"$MBOX" \
9482 -Rf ./.tmbox >> "${MBOX}" 2>&1
9483 define r {
9484 wysh set m="This is text of \"reply ${1}."
9485 reply 1 2 3
9486 !I m
9489 !I m
9492 !I m
9495 echo -----After reply $1.1 - $1.3: $?/$^ERRNAME
9497 define R {
9498 wysh set m="This is text of \"Reply ${1}."
9499 eval Reply $2
9500 !I m
9501 !I 2
9504 echo -----After Reply $1.$2: $?/$^ERRNAME
9506 define _Lh {
9507 read protover
9508 echo '~I m'
9509 echo '~I n'
9510 echo '".'
9512 define _Ls {
9513 wysh set m="This is text of \"Lreply ${1}." on-compose-splice=_Lh n=$2
9514 eval Lreply $2
9516 define L {
9517 # We need two indirections for this test: one for the case that Lreply
9518 # fails because of missing recipients: we need to read EOF next, thus
9519 # place this in _Ls last; and second for the succeeding cases EOF is
9520 # not what these should read, so go over the backside and splice it in!
9521 # (A shame we do not have redirection++ as a Bourne/K/POSIX shell!)
9522 call _Ls "$@"
9523 echo -----After Lreply $1.$2: $?/$^ERRNAME
9525 define x {
9526 localopts call-fixate yes
9527 call r $1
9528 call R $1 1; call R $1 2; call R $1 3; call R $1 4
9529 call L $1 1; call L $1 2; call L $1 3
9531 define tweak {
9532 echo;echo '===== CHANGING === '"$*"' =====';echo
9533 eval "$@"
9536 set from=laber@backe.eu
9537 mlist is@a.list
9538 call x 1
9539 call tweak set reply-to-honour
9540 call x 2
9541 call tweak set followup-to
9542 call x 3
9543 call tweak set followup-to-honour
9544 call x 4
9545 call tweak mlist bugstop@five.miles.out
9546 call x 5
9547 call tweak mlsubscribe bugstop@five.miles.out
9548 call x 6
9549 call tweak set recipients-in-cc
9550 call x 7
9551 # While here, test that *fullnames* works (also here)
9552 call tweak set fullnames
9553 reply 1
9554 This message should have *fullnames* in the header.
9556 # Revert
9557 call tweak unmlsubscribe bugstop@five.miles.out';' \
9558 set followup-to-add-cc nofullnames
9559 call x 8
9560 call tweak mlsubscribe bugstop@five.miles.out
9561 call x 9
9562 _EOT
9564 check_ex0 1-estat
9565 if have_feat uistrings; then
9566 check 1 - "${MBOX}" '1519985418 39828'
9567 else
9568 t_echoskip '1:[!UISTRINGS]'
9573 ${cat} <<-_EOT > ./.tmbox
9574 From tom@i-i.example Thu Oct 26 03:15:55 2017
9575 Date: Wed, 25 Oct 2017 21:15:46 -0400
9576 From: tom <tom@i-i.example>
9577 To: Steffen Nurpmeso <steffen@sdaoden.eu>
9578 Cc: tom <tom@i-i.example>
9579 Subject: Re: xxxx yyyyyyyy configure does not really like a missing zzzzz
9580 Message-ID: <20171026011546.GA11643@i-i.example>
9581 Reply-To: tom@i-i.example
9582 References: <20171025214601.T2pNd%steffen@sdaoden.eu>
9583 In-Reply-To: <20171025214601.T2pNd%steffen@sdaoden.eu>
9584 Status: R
9586 The report's useful :-)
9587 _EOT
9589 # Let us test In-Reply-To: removal starts a new thread..
9590 # This needs adjustment of *stealthmua*
9591 argadd='-Sstealthmua=noagent -Shostname'
9593 ${rm} "${MBOX}"
9594 printf 'reply 1\nthread\n!.\n' |
9595 ${MAILX} ${ARGS} -Sescape=! -Smta=test://"$MBOX" -Sreply-to-honour \
9596 ${argadd} -Rf ./.tmbox > .tall 2>&1
9597 check 2 0 "${MBOX}" '841868335 433'
9598 check 3 - .tall '4294967295 0'
9600 printf 'reply 1\nnew <- thread!\n!||%s -e "%s"\n!.\n' \
9601 "${sed}" '/^In-Reply-To:/d' |
9602 ${MAILX} ${ARGS} -Sescape=! -Smta=test://"$MBOX" -Sreply-to-honour \
9603 ${argadd} -Rf "${MBOX}" > .tall 2>&1
9604 check 4 0 "${MBOX}" '3136957908 771'
9605 check 5 - .tall '4294967295 0'
9607 printf 'reply 2\nold <- new <- thread!\n!.\n' |
9608 ${MAILX} ${ARGS} -Sescape=! -Smta=test://"$MBOX" -Sreply-to-honour \
9609 ${argadd} -Rf "${MBOX}" > .tall 2>&1
9610 check 6 0 "${MBOX}" '3036449053 1231'
9611 check 7 - .tall '4294967295 0'
9613 printf 'reply 3\nnew <- old <- new <- thread!\n!|| %s -e "%s"\n!.\n' \
9614 "${sed}" '/^In-Reply-To:/d' |
9615 ${MAILX} ${ARGS} -Sescape=! -Smta=test://"$MBOX" -Sreply-to-honour \
9616 ${argadd} -Rf "${MBOX}" > .tall 2>&1
9617 check 8 0 "${MBOX}" '2069841383 1583'
9618 check 9 - .tall '4294967295 0'
9620 # And follow-up testing whether changing In-Reply-To: to - starts a new
9621 # thread with only the message being replied-to.
9623 printf 'reply 1\nthread with only one ref!\n!||%s -e "%s"\n!.\n' \
9624 "${sed}" 's/^In-Reply-To:.*$/In-Reply-To:-/' |
9625 ${MAILX} ${ARGS} -Sescape=! -Smta=test://"$MBOX" -Sreply-to-honour \
9626 ${argadd} -Rf "${MBOX}" > .tall 2>&1
9627 check 10 0 "${MBOX}" '3155846378 2047'
9628 check 11 - .tall '4294967295 0'
9630 t_epilog "${@}"
9633 t_pipe_handlers() {
9634 t_prolog "${@}"
9636 if have_feat cmd-vexpr; then :; else
9637 t_echoskip '[!CMD_VEXPR]'
9638 t_epilog "${@}"
9639 return
9642 # "Test for" [d6f316a] (Gavin Troy)
9643 printf "m ${MBOX}\n~s subject1\nEmail body\n~.\nfi ${MBOX}\np\nx\n" |
9644 ${MAILX} ${ARGS} ${ADDARG_UNI} -Spipe-text/plain="?* ${cat}" > "${BODY}"
9645 check 1 0 "${MBOX}" '3942990636 118'
9646 check 2 - "${BODY}" '3951695530 170'
9648 ${rm} "${MBOX}"
9649 printf "m %s\n~s subject2\n~@%s\nBody2\n~.\nFi %s\nmimeview\nx\n" \
9650 "${MBOX}" "${TOPDIR}snailmail.jpg" "${MBOX}" |
9651 ${MAILX} ${ARGS} ${ADDARG_UNI} \
9652 -S 'pipe-text/plain=?' \
9653 -S 'pipe-image/jpeg=?=&?'\
9654 'trap \"'"${rm}"' -f '\ '\\"${MAILX_FILENAME_TEMPORARY}\\"\" EXIT;'\
9655 'trap \"trap \\\"\\\" INT QUIT TERM; exit 1\" INT QUIT TERM;'\
9656 '{ echo C=$MAILX_CONTENT;'\
9657 'echo C-E=$MAILX_CONTENT_EVIDENCE;'\
9658 'echo E-B-U=$MAILX_EXTERNAL_BODY_URL;'\
9659 'echo F=$MAILX_FILENAME;'\
9660 'echo F-G=not testable MAILX_FILENAME_GENERATED;'\
9661 'echo F-T=not testable MAILX_FILENAME_TEMPORARY;'\
9662 ''"${cksum}"' < \"${MAILX_FILENAME_TEMPORARY}\" |'\
9663 ''"${sed}"' -e "s/[ ]\{1,\}/ /g"; } > ./.tax 2>&1;'"${mv}"' ./.tax ./.tay' \
9664 > "${BODY}" 2>&1
9665 check 3 0 "${MBOX}" '1933681911 13435'
9666 check 4 - "${BODY}" '2036666633 493'
9667 check 4-hdl - ./.tay '144517347 151' async
9669 # Keep $MBOX..
9670 if [ -z "${ln}" ]; then
9671 t_echoskip '5:[ln(1) not found]'
9672 else
9673 # Let us fill in tmpfile, test auto-deletion
9674 printf 'Fi %s\nmimeview\nvput vexpr v file-stat .t.one-link\n'\
9675 'eval wysh set $v;echo should be $st_nlink link\nx\n' "${MBOX}" |
9676 ${MAILX} ${ARGS} ${ADDARG_UNI} \
9677 -S 'pipe-text/plain=?' \
9678 -S 'pipe-image/jpeg=?=++?'\
9679 'echo C=$MAILX_CONTENT;'\
9680 'echo C-E=$MAILX_CONTENT_EVIDENCE;'\
9681 'echo E-B-U=$MAILX_EXTERNAL_BODY_URL;'\
9682 'echo F=$MAILX_FILENAME;'\
9683 'echo F-G=not testable MAILX_FILENAME_GENERATED;'\
9684 'echo F-T=not testable MAILX_FILENAME_TEMPORARY;'\
9685 "${ln}"' -f $MAILX_FILENAME_TEMPORARY .t.one-link;'\
9686 ''"${cksum}"' < \"${MAILX_FILENAME_TEMPORARY}\" |'\
9687 ''"${sed}"' -e "s/[ ]\{1,\}/ /g"' \
9688 > "${BODY}" 2>&1
9689 check 5 0 "${BODY}" '4260004050 661'
9691 # Fill in ourselfs, test auto-deletion
9692 printf 'Fi %s\nmimeview\nvput vexpr v file-stat .t.one-link\n'\
9693 'eval wysh set $v;echo should be $st_nlink link\nx\n' "${MBOX}" |
9694 ${MAILX} ${ARGS} ${ADDARG_UNI} \
9695 -S 'pipe-text/plain=?' \
9696 -S 'pipe-image/jpeg=?++?'\
9697 "${cat}"' > $MAILX_FILENAME_TEMPORARY;'\
9698 'echo C=$MAILX_CONTENT;'\
9699 'echo C-E=$MAILX_CONTENT_EVIDENCE;'\
9700 'echo E-B-U=$MAILX_EXTERNAL_BODY_URL;'\
9701 'echo F=$MAILX_FILENAME;'\
9702 'echo F-G=not testable MAILX_FILENAME_GENERATED;'\
9703 'echo F-T=not testable MAILX_FILENAME_TEMPORARY;'\
9704 ''"${cksum}"' < \"${MAILX_FILENAME_TEMPORARY}\" |'\
9705 ''"${sed}"' -e "s/[ ]\{1,\}/ /g"' \
9706 > "${BODY}" 2>&1
9707 check 6 0 "${BODY}" '4260004050 661'
9709 # And the same, via copiousoutput (fake)
9710 printf 'Fi %s\np\nvput vexpr v file-stat .t.one-link\n'\
9711 'eval wysh set $v;echo should be $st_nlink link\nx\n' "${MBOX}" |
9712 ${MAILX} ${ARGS} ${ADDARG_UNI} \
9713 -S 'pipe-text/plain=?' \
9714 -S 'pipe-image/jpeg=?*++?'\
9715 "${cat}"' > $MAILX_FILENAME_TEMPORARY;'\
9716 'echo C=$MAILX_CONTENT;'\
9717 'echo C-E=$MAILX_CONTENT_EVIDENCE;'\
9718 'echo E-B-U=$MAILX_EXTERNAL_BODY_URL;'\
9719 'echo F=$MAILX_FILENAME;'\
9720 'echo F-G=not testable MAILX_FILENAME_GENERATED;'\
9721 'echo F-T=not testable MAILX_FILENAME_TEMPORARY;'\
9722 "${ln}"' -f $MAILX_FILENAME_TEMPORARY .t.one-link;'\
9723 ''"${cksum}"' < \"${MAILX_FILENAME_TEMPORARY}\" |'\
9724 ''"${sed}"' -e "s/[ ]\{1,\}/ /g"' \
9725 > "${BODY}" 2>&1
9726 check 7 0 "${BODY}" '709946464 677'
9729 t_epilog "${@}"
9732 t_mailcap() {
9733 t_prolog "${@}"
9735 if have_feat mailcap; then :; else
9736 t_echoskip '[!MAILCAP]'
9737 t_epilog "${@}"
9738 return
9741 ${cat} <<-'_EOT' > ./.tmailcap
9742 text/html; lynx -dump %s; copiousoutput; nametemplate=%s.html
9743 application/pdf; /Applications/Preview.app/Contents/MacOS/Preview %s;\
9744 nametemplate=%s.pdf;\
9745 test = [ "${OSTYPE}" = darwin ]
9746 application/pdf;\
9747 infile=%s\;\
9748 trap "rm -f ${infile}" EXIT\;\
9749 trap "exit 75" INT QUIT TERM\;\
9750 mupdf "${infile}";\
9751 test = [ -n "${DISPLAY}" ];\
9752 nametemplate = %s.pdf; x-mailx-async
9753 application/pdf; pdftotext -layout %s -; nametemplate=%s.pdf; copiousoutput
9754 application/*; echo "This is \\"%t\\" but \
9755 is 50 \% Greek to me" \; < %s head -c 1024 | cat -vet; \
9756 description=" this is\;a \"wildcard\" match, no trailing quote! ;\
9757 copiousoutput; x-mailx-noquote
9761 bummer/hummer;;
9762 application/postscript; ps-to-terminal %s;\ needsterminal
9763 application/postscript; ps-to-terminal %s; \compose=idraw %s
9764 x-be2; the-cmd %s; \
9765 print=print-cmd %s ; \
9766 copiousoutput ; \
9767 compose=compose-cmd -d %s ; \
9768 textualnewlines; \
9769 composetyped = composetyped-cmd -dd %s ; \
9770 x-mailx-noquote ;\
9771 edit=edit-cmd -ddd %s; \
9772 description = a\;desc;\
9773 nametemplate=%s.be2;\
9774 test = this is "a" test ; \
9775 x-mailx-test-once ;\
9776 x11-bitmap = x11-bitmap.bpm;;;;;
9777 application/*; echo "is \"%t\" \
9778 50 \% Greek" \; cat %s; copiousoutput; \; description="catch-all buddy";
9779 audio/*; showaudio;compose=%n
9780 image/jpeg; showpicture -viewer xv %s
9781 image/*; showpicture %s
9782 message/partial; showpartial %s %{id} %{number} %{total}
9783 application/postscript ; lpr %s ; label="PS File";\
9784 compose="getx PS %s"
9785 application/atomicmail; atomicmail %s ; needsterminal
9786 application/andrew-inset; ezview %s ; copiousoutput;\
9787 edit=ez -d %s; compose="ez -d %s"; label="Andrew i/d"
9788 text/richtext; xy iso-8859-1 -e richtext -p %s; \
9789 test=test "`echo %{charset} | tr A-Z a-z`" = iso-8859-1; copiousoutput
9790 text/plain; xy iso-8859-1 %s;\
9791 test=test "`echo %{charset} | tr A-Z a-z`" = iso-8859-1; copiousoutput
9792 text/richtext; rich %s %{not-closed; copiousoutput
9793 default; cat %s; copiousoutput
9794 _EOT
9795 ${chmod} 0644 ./.tmailcap
9797 printf 'm;echo =1/$?;m c;echo =2/$?;
9798 mailca loa;echo =3/$?;mailc s;echo =4/$?' |
9799 MAILCAPS=./.tmailcap ${MAILX} -X'commandalias m mailcap' ${ARGS} \
9800 > ./.tall 2>./.terr
9801 check 1 0 ./.tall '2012114724 3064'
9802 have_feat uistrings && i='3903313993 2338' || i='4294967295 0'
9803 check 2 - ./.terr "${i}"
9807 echo 'From me with love' | ${MAILX} ${ARGS} -s sub1 "${MBOX}"
9808 check 3 0 "${MBOX}" '4224630386 228'
9810 # For reproducability, one pseudo check with cat(1) and mv(1)
9811 printf '#
9812 text/plain; echo p-1-1\\;< %%s cat\\;echo p-1-2;\\
9813 test=echo X >> ./.terrmc\\; [ -n "$XY" ];x-mailx-test-once
9814 text/plain; echo p-2-1\\;< %%s cat\\;echo p-2-2;\\
9815 test=echo Y >> ./.terrmc\\;[ -z "$XY" ]
9816 text/plain; { file=%%s\\; echo p-3-1 = ${file##*.}\\;\\
9817 </dev/null cat %%s\\;echo p-3-2\\; } > ./.tx\\; mv -f ./.tx ./.tasy;\\
9818 test=[ -n "$XY" ];nametemplate=%%s.txt;x-mailx-async
9819 text/plain; echo p-4-1\\;cat\\;echo p-4-2;copiousoutput
9820 ' > ./.tmailcap
9822 </dev/null MAILCAPS=./.tmailcap TMPDIR=`${pwd}` \
9823 ${MAILX} ${ARGS} -Snomailcap-disable \
9824 -Y '\mailcap' \
9825 -Rf "${MBOX}" > ./.tall 2>./.terr
9826 check 4.pre 0 ./.tall '1428075831 455'
9828 # Same with real programs
9829 printf '#
9830 text/plain; echo p-1-1\\;< %%s %s\\;echo p-1-2;\\
9831 test=echo X >> ./.terrmc\\; [ -n "$XY" ];x-mailx-test-once
9832 text/plain; echo p-2-1\\;< %%s %s\\;echo p-2-2;\\
9833 test=echo Y >> ./.terrmc\\;[ -z "$XY" ]
9834 text/plain; { file=%%s\\; echo p-3-1 = ${file##*.}\\;\\
9835 </dev/null %s %%s\\;echo p-3-2\\; } > ./.tx\\; %s -f ./.tx ./.tasy;\\
9836 test=[ -n "$XY" ];nametemplate=%%s.txt;x-mailx-async
9837 text/plain; echo p-4-1\\;%s\\;echo p-4-2;copiousoutput
9838 ' "${cat}" "${cat}" "${cat}" "${mv}" "${cat}" > ./.tmailcap
9840 </dev/null MAILCAPS=./.tmailcap TMPDIR=`${pwd}` \
9841 ${MAILX} ${ARGS} -Snomailcap-disable \
9842 -Y '#
9843 \echo =1
9844 \mimeview
9845 \echo =2
9846 \environ set XY=yes
9847 \mimeview
9848 \echo =3
9849 \type
9850 \echo =4
9852 -Rf "${MBOX}" > ./.tall 2>./.terr
9853 check 4 0 ./.tall '1912261831 831'
9854 check 5 - ./.terr '4294967295 0'
9855 check 6 - ./.terrmc '2376112102 6'
9856 check 7 - ./.tasy '3913344578 37' async
9858 # "Binary data"; ensure all possible temporary file / nametemplate
9859 # etc. paths are taken: avoid 2nd e7a60732c1906aefe4755fd61c5ffa81eeca0af0
9861 ${rm} -f "${MBOX}"
9862 printf 'du\x7fbo€o\bm' > ./.tatt.pdf
9863 printf 'du' | ${MAILX} ${ARGS} -a ./.tatt.pdf -s test "${MBOX}"
9864 check 8 0 "${MBOX}" '3444709420 644'
9866 printf '#
9867 # stdin
9868 application/pdf; echo p-1-1\\;%s\\;echo p-1-2; test=[ "$XY" = "" ]
9869 # tmpfile, no template
9870 application/pdf; echo p-2-1\\;< %%s %s\\;echo p-2-2; test = [ "$XY" = two ]
9871 # tmpfile, template
9872 application/pdf; echo p-3-1\\;< %%s %s\\;echo p-3-2; test=[ "$XY" = three ];\\
9873 nametemplate=%%s.txt
9874 # tmpfile, template, async
9875 application/pdf; { file=%%s \\; echo p-4-1 = ${file##*.}\\;\\
9876 </dev/null %s %%s\\;echo p-4-2\\; } > ./.tx\\; %s -f ./.tx ./.tasy;\\
9877 test=[ "$XY" = four ] ; nametemplate = %%s.txt ; x-mailx-async
9878 # copious,stdin
9879 application/pdf; echo p-5-1\\;%s\\;echo p-5-2; test=[ "$XY" = 1 ];\\
9880 copiousoutput
9881 # copious, tmpfile, no template
9882 application/pdf; echo p-6-1\\;< %%s %s\\;echo p-6-2; test = [ "$XY" = 2 ];\\
9883 copiousoutput
9884 # copious, tmpfile, template
9885 application/pdf; echo p-7-1\\;< %%s %s\\;echo p-7-2;test = [ "$XY" = 3 ];\\
9886 nametemplate=%%s.txt; copiousoutput
9887 ' "${cat}" "${cat}" "${cat}" "${cat}" "${mv}" "${cat}" "${cat}" "${cat}" \
9888 > ./.tmailcap
9890 </dev/null XY= MAILCAPS=./.tmailcap TMPDIR=`${pwd}` \
9891 ${MAILX} ${ARGS} -Snomailcap-disable \
9892 -Y '#
9893 \echo =1
9894 \mimeview
9895 \echo =2
9896 \environ set XY=two
9897 \mimeview
9898 \echo =3
9899 \environ set XY=three
9900 \mimeview
9901 \echo =4
9902 \environ set XY=four
9903 \mimeview
9904 \echo =5
9905 \environ set XY=1
9906 \type
9907 \echo =6
9908 \environ set XY=2
9909 \type
9910 \echo =7
9911 \environ set XY=3
9912 \type
9913 \echo =8
9915 -Rf "${MBOX}" > ./.tall 2>./.terr
9916 check 9 0 ./.tall '2388630345 3850'
9917 check 10 - ./.terr '4294967295 0'
9918 check 11 - ./.tasy '842146666 27' async
9920 # x-mailx-last-resort, x-mailx-ignore
9922 ${rm} -f "${MBOX}"
9923 printf 'in a pdf\n' > ./.tatt.pdf
9924 printf 'du\n' | ${MAILX} ${ARGS} -a ./.tatt.pdf -s test "${MBOX}"
9925 check 12 0 "${MBOX}" '3968874750 579'
9927 printf '#
9928 # stdin
9929 application/pdf;echo hidden;x-mailx-ignore
9930 application/pdf;echo hidden;copiousoutput;x-mailx-ignore
9931 application/pdf; echo pre\\;%s\\;echo post; x-mailx-last-resort
9932 ' "${cat}" > ./.tmailcap
9934 </dev/null XY= MAILCAPS=./.tmailcap TMPDIR=`${pwd}` \
9935 ${MAILX} ${ARGS} -Snomailcap-disable \
9936 -Y '#
9937 \echo =1
9938 \mimeview
9939 \echo =2
9940 \mimetype ?t application/pdf pdf
9941 \mimeview
9942 \echo =3
9943 \type
9944 \echo =4
9945 \unmimetype application/pdf
9946 \mimeview
9947 \echo =5
9949 -Rf "${MBOX}" > ./.tall 2>./.terr
9950 check 13 0 ./.tall '759843612 1961'
9951 check 14 - ./.terr '4294967295 0'
9953 t_epilog "${@}"
9955 # }}}
9957 # Unclassified rest {{{
9958 t_top() {
9959 t_prolog "${@}"
9961 t__gen_msg subject top1 to 1 from 1 cc 1 body 'body1-1
9962 body1-2
9964 body1-3
9965 body1-4
9968 body1-5
9969 ' > "${MBOX}"
9970 t__gen_msg subject top2 to 1 from 1 cc 1 body 'body2-1
9971 body2-2
9974 body2-3
9977 body2-4
9978 body2-5
9979 ' >> "${MBOX}"
9981 ${MAILX} ${ARGS} -Rf -Y '#
9982 \top 1
9983 \echo --- $?/$^ERRNAME, 1; \set toplines=10
9984 \top 1
9985 \echo --- $?/$^ERRNAME, 2; \set toplines=5
9986 \headerpick top retain subject # For top
9987 \headerpick type retain to subject # For Top
9988 \top 1
9989 \echo --- $?/$^ERRNAME, 3; \set topsqueeze
9990 \top 1 2
9991 \echo --- $?/$^ERRNAME, 4
9992 \Top 1
9993 \echo --- $?/$^ERRNAME, 5
9994 # ' "${MBOX}" > ./.tall 2>&1
9995 check 1 0 ./.tall '2556125754 705'
9997 t_epilog "${@}"
10000 t_s_mime() {
10001 t_prolog "${@}"
10003 if have_feat smime; then :; else
10004 t_echoskip '[!SMIME]'
10005 t_epilog "${@}"
10006 return
10009 ${cat} <<-_EOT > ./.t.conf
10010 [req]
10011 x509_extensions = extensions
10012 distinguished_name = req_distinguished_name
10013 attributes = req_attributes
10014 prompt = no
10015 output_password = Pacem_in_terris
10017 [extensions]
10018 basicConstraints = CA:FALSE
10019 # Needs a CA for that keyUsage = digitalSignature
10020 extendedKeyUsage = emailProtection
10022 [req_distinguished_name]
10023 C = GB
10024 ST = Over the
10025 L = rainbow
10026 O = S-nail
10027 OU = S-nail.smime
10028 CN = S-nail.test2
10029 emailAddress = test@localhost
10031 [req_attributes]
10032 challengePassword = hi ca it is me me me
10033 _EOT
10035 doit() {
10036 _z=${1}
10038 if [ "${_z}" = 0 ]; then
10039 _pass=
10040 _osslreq=-nodes
10041 _ossl=
10042 else
10043 _pass=Pacem_in_terris
10044 _osslreq=
10045 _ossl='-passin pass:'${_pass}
10048 ${rm} -f ./.VERIFY ./.ENCRYPT ./.DECRYPT
10050 openssl req ${_osslreq} ${_ossl} -x509 -days 3650 -config ./.t.conf \
10051 -newkey rsa:1024 -keyout ./.tkey.pem -out ./.tcert.pem >>${ERR} 2>&1
10052 check_ex0 ${_z}
10053 _z=`add ${_z} 1`
10055 ${cat} ./.tkey.pem ./.tcert.pem > ./.tpair.pem
10057 # Sign/verify
10058 echo bla | ${MAILX} ${ARGS} \
10059 -Ssmime-sign -Ssmime-sign-cert=./.tpair.pem -Sfrom=test@localhost \
10060 -Ssmime-sign-digest=sha1 \
10061 -S password-test@localhost.smime-cert-key=${_pass} \
10062 -s 'S/MIME test' ./.VERIFY >>${ERR} 2>&1
10063 check_ex0 ${_z}-estat
10064 ${awk} '
10065 BEGIN{ skip=0 }
10066 /^Content-Description: /{ skip = 2; print; next }
10067 /^$/{ if(skip) --skip }
10068 { if(!skip) print }
10070 < ./.VERIFY > "${MBOX}"
10071 check ${_z} - "${MBOX}" '335634014 644'
10072 _z=`add ${_z} 1`
10074 printf 'verify\nx\n' |
10075 ${MAILX} ${ARGS} -Ssmime-ca-file=./.tcert.pem -Serrexit \
10076 -R -f ./.VERIFY >>${ERR} 2>&1
10077 check_ex0 ${_z} # XXX pipe
10078 _z=`add ${_z} 1`
10080 openssl smime -verify -CAfile ./.tcert.pem -in ./.VERIFY >>${ERR} 2>&1
10081 check_ex0 ${_z}
10082 _z=`add ${_z} 1`
10084 # (signing +) encryption / decryption
10085 echo bla |
10086 ${MAILX} ${ARGS} \
10087 -Smta=test://./.ENCRYPT \
10088 -Ssmime-force-encryption -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
10089 -Ssmime-sign-digest=sha1 \
10090 -Ssmime-sign -Ssmime-sign-cert=./.tpair.pem -Sfrom=test@localhost \
10091 -S password-test@localhost.smime-cert-key=${_pass} \
10092 -s 'S/MIME test' recei@ver.com >>${ERR} 2>&1
10093 check_ex0 ${_z}-estat
10094 ${sed} -e '/^$/,$d' < ./.ENCRYPT > "${MBOX}"
10095 check ${_z} - "${MBOX}" '2359655411 336'
10096 _z=`add ${_z} 1`
10098 printf 'decrypt ./.DECRYPT\nfi ./.DECRYPT\nverify\nx\n' |
10099 ${MAILX} ${ARGS} \
10100 -Smta=test://./.ENCRYPT \
10101 -Ssmime-ca-file=./.tcert.pem \
10102 -Ssmime-sign-cert=./.tpair.pem \
10103 -Sfrom=test@localhost \
10104 -S password-test@localhost.smime-cert-key=${_pass} \
10105 -Serrexit -R -f ./.ENCRYPT >>${ERR} 2>&1
10106 check_ex0 ${_z}-estat
10107 ${awk} '
10108 BEGIN{ skip=0 }
10109 /^Content-Description: /{ skip = 2; print; next }
10110 /^$/{ if(skip) --skip }
10111 { if(!skip) print }
10113 < ./.DECRYPT > "${MBOX}"
10114 check ${_z} - "${MBOX}" '2602978204 940'
10115 _z=`add ${_z} 1`
10117 (openssl smime -decrypt ${_ossl} -inkey ./.tkey.pem -in ./.ENCRYPT |
10118 openssl smime -verify -CAfile ./.tcert.pem) >>${ERR} 2>&1
10119 check_ex0 ${_z} # XXX pipe..
10120 _z=`add ${_z} 1`
10122 ${rm} ./.ENCRYPT
10123 echo bla | ${MAILX} ${ARGS} \
10124 -Smta=test://./.ENCRYPT \
10125 -Ssmime-force-encryption -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
10126 -Sfrom=test@localhost \
10127 -S password-test@localhost.smime-cert-key=${_pass} \
10128 -s 'S/MIME test' recei@ver.com >>${ERR} 2>&1
10129 check_ex0 ${_z}-estat
10130 ${sed} -e '/^$/,$d' < ./.ENCRYPT > "${MBOX}"
10131 check ${_z} - "${MBOX}" '2359655411 336'
10132 _z=`add ${_z} 1`
10134 ${rm} ./.DECRYPT
10135 # Note: deduce from *sign-cert*, not from *from*!
10136 printf 'decrypt ./.DECRYPT\nx\n' | ${MAILX} ${ARGS} \
10137 -Smta=test://./.ENCRYPT \
10138 -Ssmime-sign-cert-recei@ver.com=./.tpair.pem \
10139 -S password-recei@ver.com.smime-cert-key=${_pass} \
10140 -Serrexit -R -f ./.ENCRYPT >>${ERR} 2>&1
10141 check ${_z} 0 ./.DECRYPT '2453471323 431'
10142 _z=`add ${_z} 1`
10144 openssl smime ${_ossl} -decrypt -inkey ./.tkey.pem -in ./.ENCRYPT \
10145 >>${ERR} 2>&1
10146 check_ex0 ${_z}
10148 unset _z _pass _osslreq _ossl
10151 doit 0
10152 doit 10
10154 t_epilog "${@}"
10156 # }}}
10158 # xxx Note: t_z() was the first test (series) written. Today many
10159 # xxx aspects are (better) covered by other tests above, some are not.
10160 # xxx At some future date and time, convert the last remains not covered
10161 # xxx elsewhere to a real t_* test and drop it
10162 t_z() {
10163 t_prolog "${@}"
10165 # Test for [260e19d] (Juergen Daubert)
10166 echo body | ${MAILX} ${ARGS} "${MBOX}"
10167 check 4 0 "${MBOX}" '2948857341 94'
10169 # "Test for" [c299c45] (Peter Hofmann) TODO shouldn't end up QP-encoded?
10170 ${rm} "${MBOX}"
10171 ${awk} 'BEGIN{
10172 for(i = 0; i < 10000; ++i)
10173 printf "\xC3\xBC"
10174 #printf "\xF0\x90\x87\x90"
10175 }' | ${MAILX} ${ARGS} ${ADDARG_UNI} -s TestSubject "${MBOX}"
10176 check 7 0 "${MBOX}" '1707496413 61812'
10178 t_epilog "${@}"
10181 # Test support {{{
10182 t__gen_msg() {
10183 t___gen_msg '' "${@}"
10186 t__gen_mimemsg() {
10187 t___gen_msg 1 "${@}"
10190 t___gen_msg() {
10191 ismime=${1}
10192 shift
10194 t___header() {
10195 printf '%s: ' ${1}
10196 case "${3}" in
10197 [0-9]*)
10198 ___hi=1
10199 while [ ${___hi} -le ${3} ]; do
10200 [ ${___hi} -gt 1 ] && printf ', '
10201 printf '%s%s <%s%s@exam.ple>' ${1} ${___hi} ${2} ${___hi}
10202 ___hi=`add ${___hi} 1`
10203 done
10206 printf '%s' "${3}"
10208 esac
10209 printf '\n'
10212 printf 'From reproducible_build Wed Oct 2 01:50:07 1996
10213 Date: Wed, 02 Oct 1996 01:50:07 +0000
10216 body=Body
10217 while [ ${#} -ge 2 ]; do
10218 case "${1}" in
10219 from) t___header From from "${2}";;
10220 to) t___header To to "${2}";;
10221 cc) t___header Cc cc "${2}";;
10222 bcc) t___header Bcc bcc "${2}";;
10223 subject) printf 'Subject: %s\n' "${2}";;
10224 body) body="${2}";;
10225 esac
10226 shift 2
10227 done
10229 if [ -z "${ismime}" ]; then
10230 printf '\n%s\n\n' "${body}"
10231 else
10232 printf 'MIME-Version: 1.0
10233 Message-ID: <20200204225307.FaKeD%%bo@oo>
10234 Content-Type: multipart/mixed; boundary="=BOUNDOUT="
10236 --=BOUNDOUT=
10237 Content-Type: multipart/alternative; boundary==BOUNDIN=
10239 --=BOUNDIN=
10240 Content-Type: text/plain; charset=utf-8
10241 Content-Transfer-Encoding: 8-bit
10245 --=BOUNDIN=
10246 Content-Type: text/html; charset=utf-8
10247 Content-Transfer-Encoding: 8-bit
10249 <HTML><BODY>%s<BR></BODY></HTML>
10251 --=BOUNDIN=--
10253 --=BOUNDOUT=
10254 Content-Type: text/troff
10256 Golden Brown
10258 --=BOUNDOUT=
10259 Content-Type: text/x-uuencode
10261 Aprendimos a quererte
10262 --=BOUNDOUT=--
10264 ' "${body}" "${body}"
10268 t__x1_msg() {
10269 ${cat} <<-_EOT
10270 From neverneverland Sun Jul 23 13:46:25 2017
10271 Subject: Bugstop: five miles out 1
10272 Reply-To: mister originator1 <mr1@originator>
10273 From: mister originator1 <mr1@originator>
10274 To: bugstop-commit@five.miles.out
10275 Cc: is1@a.list
10276 In-reply-to: <20170719111113.bkcMz%laber1@backe.eu>
10277 Date: Wed, 19 Jul 2017 09:22:57 -0400
10278 Message-Id: <20170719132257.766AF781267-1@originator>
10279 Mail-Followup-To: bugstop@five.miles.out, laber@backe.eu, is@a.list
10280 Status: RO
10282 That's appalling, I.
10284 _EOT
10287 t__x2_msg() {
10288 ${cat} <<-_EOT
10289 From neverneverland Sun Jul 23 13:47:25 2017
10290 Subject: Bugstop: five miles out 2
10291 Reply-To: mister originator2 <mr2@originator>
10292 From: mister originator2 <mr2@originator>
10293 To: bugstop-commit@five.miles.out
10294 Cc: is2@a.list
10295 In-reply-to: <20170719111113.bkcMz%laber2@backe.eu>
10296 Date: Wed, 19 Jul 2017 09:23:57 -0400
10297 Message-Id: <20170719132257.766AF781267-2@originator>
10298 Status: RO
10300 That's appalling, II.
10302 _EOT
10305 t__x3_msg() {
10306 ${cat} <<-_EOT
10307 From neverneverland Sun Jul 23 13:48:25 2017
10308 Subject: Bugstop: five miles out 3
10309 Reply-To: mister originator3 <mr3@originator>
10310 From: mister originator3 <mr3@originator>
10311 To: bugstop-commit@five.miles.out
10312 Cc: is3@a.list
10313 In-reply-to: <20170719111113.bkcMz%laber3@backe.eu>
10314 Date: Wed, 19 Jul 2017 09:24:57 -0400
10315 Message-Id: <20170719132257.766AF781267-3@originator>
10316 Status: RO
10318 That's appalling, III.
10320 _EOT
10323 t__put_subject() {
10324 # MIME encoding (QP) stress message subject
10325 printf 'Äbrä Kä?dä=brö Fü?di=bus? '\
10326 'adadaddsssssssddddddddddddddddddddd'\
10327 'ddddddddddddddddddddddddddddddddddd'\
10328 'ddddddddddddddddddddddddddddddddddd'\
10329 'dddddddddddddddddddd Hallelulja? Od'\
10330 'er?? eeeeeeeeeeeeeeeeeeeeeeeeeeeeee'\
10331 'eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'\
10332 'eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee f'\
10333 'fffffffffffffffffffffffffffffffffff'\
10334 'fffffffffffffffffffff ggggggggggggg'\
10335 'ggggggggggggggggggggggggggggggggggg'\
10336 'ggggggggggggggggggggggggggggggggggg'\
10337 'ggggggggggggggggggggggggggggggggggg'\
10338 'gggggggggggggggg'
10341 t__put_body() {
10342 # MIME encoding (QP) stress message body
10343 printf \
10344 'Ich bin eine DÖS-Datäi mit sehr langen Zeilen und auch '\
10345 'sonst bin ich ganz schön am Schleudern, da kannste denke '\
10346 "wasde willst, gelle, gelle, gelle, gelle, gelle.\r\n"\
10347 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst \r\n"\
10348 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1\r\n"\
10349 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12\r\n"\
10350 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123\r\n"\
10351 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1234\r\n"\
10352 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12345\r\n"\
10353 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123456\r\n"\
10354 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1234567\r\n"\
10355 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12345678\r\n"\
10356 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123456789\r\n"\
10357 "Unn ausserdem habe ich trailing SP/HT/SP/HT whitespace \r\n"\
10358 "Unn ausserdem habe ich trailing HT/SP/HT/SP whitespace \r\n"\
10359 "auf den zeilen vorher.\r\n"\
10360 "From am Zeilenbeginn und From der Mitte gibt es auch.\r\n"\
10361 ".\r\n"\
10362 "Die letzte Zeile war nur ein Punkt.\r\n"\
10363 "..\r\n"\
10364 "Das waren deren zwei.\r\n"\
10365 " \r\n"\
10366 "Die letzte Zeile war ein Leerschritt.\n"\
10367 "=VIER = EQUAL SIGNS=ON A LINE=\r\n"\
10368 "Prösterchen.\r\n"\
10369 ".\n"\
10370 "Die letzte Zeile war nur ein Punkt, mit Unix Zeilenende.\n"\
10371 "..\n"\
10372 "Das waren deren zwei. ditto.\n"\
10373 "Prösterchen.\n"\
10374 "Unn ausseerdem habe ich trailing SP/HT/SP/HT whitespace \n"\
10375 "Unn ausseerdem habe ich trailing HT/SP/HT/SP whitespace \n"\
10376 "auf den zeilen vorher.\n"\
10377 "ditto.\n"\
10378 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.\n"\
10379 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.1"\
10380 "\n"\
10381 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
10382 "\n"\
10383 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
10384 "3\n"\
10385 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
10386 "34\n"\
10387 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
10388 "345\n"\
10389 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
10390 "3456\n"\
10391 "QP am Zeilenende über soft-nl hinweg\n"\
10392 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
10393 "ö123\n"\
10394 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
10395 "1ö23\n"\
10396 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
10397 "12ö3\n"\
10398 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
10399 "123ö\n"\
10400 "=VIER = EQUAL SIGNS=ON A LINE=\n"\
10401 " \n"\
10402 "Die letzte Zeile war ein Leerschritt.\n"\
10405 # }}}
10407 # cc_all_configs() {{{
10408 # Test all configs TODO doesn't cover all *combinations*, stupid!
10409 cc_all_configs() {
10410 if [ ${MAXJOBS} -gt 1 ]; then
10411 MAXJOBS='-j '${MAXJOBS}
10412 else
10413 MAXJOBS=
10415 if [ -n "${NOCOLOUR}" ] || [ -n "${MAILX_CC_TEST_NO_COLOUR}" ]; then
10416 MAILX_CC_TEST_NO_COLOUR=1
10417 export MAILX_CC_TEST_NO_COLOUR
10420 < ${CONF} ${awk} '
10421 BEGIN{
10422 ALWAYS = "OPT_AUTOCC=1 OPT_AMALGAMATION=1"
10423 NOTME["OPT_AUTOCC_STACKPROT"] = 1
10424 NOTME["OPT_ALWAYS_UNICODE_LOCALE"] = 1
10425 NOTME["OPT_CROSS_BUILD"] = 1
10426 NOTME["OPT_AUTOCC"] = 1
10427 NOTME["OPT_AMALGAMATION"] = 1
10428 NOTME["OPT_DEBUG"] = 1
10429 NOTME["OPT_DEVEL"] = 1
10430 NOTME["OPT_ASAN_ADDRESS"] = 1
10431 NOTME["OPT_ASAN_MEMORY"] = 1
10432 NOTME["OPT_NOMEMDBG"] = 1
10434 #OPTVALS
10435 OPTNO = 0
10437 MULCHOICE["OPT_IDNA"] = "VAL_IDNA"
10438 MULVALS["VAL_IDNA"] = 1
10440 #VALKEYS[0] = "VAL_RANDOM"
10441 VALVALS["VAL_RANDOM"] = 1
10442 VALNO = 0
10444 /^[ ]*OPT_/{
10445 sub(/^[ ]*/, "")
10446 # This bails for UnixWare 7.1.4 awk(1), but preceeding = with \
10447 # does not seem to be a compliant escape for =
10448 #sub(/=.*$/, "")
10449 $1 = substr($1, 1, index($1, "=") - 1)
10450 if(!NOTME[$1])
10451 OPTVALS[OPTNO++] = $1
10452 next
10454 /^[ ]*VAL_/{
10455 sub(/^[ ]*/, "")
10456 val = substr($0, index($0, "=") + 1)
10457 if(val ~ /^"/){
10458 val = substr(val, 2)
10459 val = substr(val, 1, length(val) - 1)
10461 $1 = substr($1, 1, index($1, "=") - 1)
10462 if(MULVALS[$1])
10463 MULVALS[$1] = val
10464 else if(VALVALS[$1]){
10465 VALKEYS[VALNO++] = $1
10466 VALVALS[$1] = val
10468 next
10470 function onepass(addons){
10471 a_onepass__worker(addons, "1", "0")
10472 a_onepass__worker(addons, "0", "1")
10474 function a_onepass__worker(addons, b0, b1){
10475 # Doing this completely sequentially and not doing make distclean in
10476 # between runs should effectively result in lesser compilations.
10477 # It is completely dumb nonetheless... TODO
10478 for(ono = 0; ono < OPTNO; ++ono){
10479 myconf = mula = ""
10480 for(i = 0; i < ono; ++i){
10481 myconf = myconf " " OPTVALS[i] "=" b0 " "
10482 if(b0 == "1"){
10483 j = MULCHOICE[OPTVALS[i]]
10484 if(j){
10485 if(i + 1 == ono)
10486 mula = j
10487 else
10488 myconf = myconf " " MULCHOICE[OPTVALS[i]] "=any "
10492 for(i = ono; i < OPTNO; ++i){
10493 myconf = myconf " " OPTVALS[i] "=" b1 " "
10494 if(b1 == "1"){
10495 j = MULCHOICE[OPTVALS[i]]
10496 if(j){
10497 if(i + 1 == OPTNO)
10498 mula = j;
10499 else
10500 myconf = myconf " " MULCHOICE[OPTVALS[i]] "=any "
10505 for(i in VALKEYS)
10506 myconf = VALKEYS[i] "=any " myconf
10508 myconf = myconf " " ALWAYS " " addons
10510 if(mula == "")
10511 print myconf
10512 else{
10513 i = split(MULVALS[mula], ia)
10514 j = "any"
10515 while(i >= 1){
10516 j = ia[i--] " " j
10517 print mula "=\"" j "\" " myconf
10522 END{
10523 # We cannot test NULL because of missing UI strings, which will end
10524 # up with different checksums
10525 print "CONFIG=NULLI OPT_AUTOCC=1"
10526 for(i in VALKEYS){
10527 j = split(VALVALS[VALKEYS[i]], ia)
10528 k = "any"
10529 while(j >= 1){
10530 k = ia[j--] " " k
10531 print VALKEYS[i] "=\"" k "\" CONFIG=NULLI OPT_AUTOCC=1"
10534 print "CONFIG=MINIMAL OPT_AUTOCC=1"
10535 print "CONFIG=NETSEND OPT_AUTOCC=1"
10536 print "CONFIG=MAXIMAL OPT_AUTOCC=1"
10537 for(i in VALKEYS){
10538 j = split(VALVALS[VALKEYS[i]], ia)
10539 k = "any"
10540 while(j >= 1){
10541 k = ia[j--] " " k
10542 print VALKEYS[i] "=\"" k "\" CONFIG=MAXIMAL OPT_AUTOCC=1"
10545 print "CONFIG=DEVEL OPT_AUTOCC=1"
10546 print "CONFIG=ODEVEL OPT_AUTOCC=1"
10548 print split_here
10550 onepass("OPT_DEBUG=1")
10551 onepass("")
10553 ' | while read c; do
10554 if [ "$c" = split_here ]; then
10555 printf 'Predefined configs done, now OPT_ combinations\n'
10556 printf 'Predefined configs done, now OPT_ combinations\n' >&2
10557 ${SHELL} -c "cd ../ && ${MAKE} distclean"
10558 continue
10560 [ -f mk-config.h ] && ${cp} mk-config.h .ccac.h
10561 printf "\n\n##########\n${MAKE} ${MAXJOBS} config $c\n"
10562 printf "\n\n##########\n${MAKE} ${MAXJOBS} config $c\n" >&2
10563 ${SHELL} -c "cd .. && ${MAKE} ${MAXJOBS} config ${c}"
10564 if [ -f .ccac.h ] && ${cmp} mk-config.h .ccac.h; then
10565 printf 'Skipping after config, nothing changed\n'
10566 printf 'Skipping after config, nothing changed\n' >&2
10567 continue
10569 ${SHELL} -c "cd ../ && ${MAKE} ${MAXJOBS} build test"
10570 done
10571 ${rm} -f .ccac.h
10572 cd .. && ${MAKE} distclean
10574 # }}}
10576 ssec=$SECONDS
10577 if [ -z "${CHECK}${RUN_TEST}" ]; then
10578 jobs_max
10579 cc_all_configs
10580 else
10581 if have_feat debug; then
10582 if have_feat devel; then
10583 JOBSYNC=1
10584 DEVELDIFF=y
10585 DUMPERR=y
10586 ARGS="${ARGS} -Smemdebug"
10587 JOBWAIT=`add $JOBWAIT $JOBWAIT`
10589 elif have_feat devel; then
10590 DEVELDIFF=y
10591 DUMPERR=y
10592 LOOPS_MAX=${LOOPS_BIG}
10594 color_init
10596 if [ -z "${RUN_TEST}" ] || [ ${#} -eq 0 ]; then
10597 jobs_max
10598 printf 'Will do up to %s tests in parallel, with a %s second timeout\n' \
10599 ${MAXJOBS} ${JOBWAIT}
10600 jobreaper_start
10601 t_all
10602 jobreaper_stop
10603 else
10604 MAXJOBS=1
10605 jobreaper_start
10606 while [ ${#} -gt 0 ]; do
10607 jspawn ${1}
10608 shift
10609 done
10610 jobreaper_stop
10614 esec=$SECONDS
10616 printf '%u tests: %s%u ok%s, %s%u failure(s)%s. %s%u test(s) skipped%s\n' \
10617 "${TESTS_PERFORMED}" "${COLOR_OK_ON}" "${TESTS_OK}" "${COLOR_OK_OFF}" \
10618 "${COLOR_ERR_ON}" "${TESTS_FAILED}" "${COLOR_ERR_OFF}" \
10619 "${COLOR_WARN_ON}" "${TESTS_SKIPPED}" "${COLOR_WARN_OFF}"
10620 if [ -n "${ssec}" ] && [ -n "${esec}" ]; then
10621 ( echo 'Elapsed seconds: '`$awk 'BEGIN{print '"${esec}"' - '"${ssec}"'}'` )
10624 exit ${ESTAT}
10625 # s-sh-mode