a_go_evaluate(): fix un/signed comparison
[s-mailx.git] / cc-test.sh
blob59f258dfa5dacdfda7b3e5e91c5f922c65819cea
1 #!/bin/sh -
2 #@ Synopsis: ./cc-test.sh --check-only [s-mailx-binary]
3 #@ ./cc-test.sh --mae-test s-mailx-binary [:TESTNAME:]
4 #@ [./cc-test.sh # Note: performs hundreds of compilations!]
5 #@ The latter generates output files.
6 #@ TODO _All_ the tests should happen in a temporary subdir.
7 # Public Domain
9 # Instead of figuring out the environment in here, require a configured build
10 # system and include that! Our makefile and configure ensure that this test
11 # does not run in the configured, but the user environment nonetheless!
13 if [ -f ./mk-config.ev ]; then
15 elif [ -f snailmail.jpg ] && [ -f .obj/mk-config.ev ]; then
16 cd .obj
17 i=../
18 else
19 echo >&2 'S-nail/S-mailx is not configured.'
20 echo >&2 'This test script requires the shell environment that only the'
21 echo >&2 'configuration script can figure out, even if it will be used to'
22 echo >&2 'test a different binary than the one that would be produced!'
23 echo >&2 '(The necessary information will be in .obj/mk-config.ev.)'
24 echo >&2 'Hit RETURN to run "make config CONFIG=null'
25 read l
26 make config CONFIG=null
28 . ./mk-config.ev
29 if [ -z "${MAILX__CC_TEST_RUNNING}" ]; then
30 MAILX__CC_TEST_RUNNING=1
31 export MAILX__CC_TEST_RUNNING
32 exec "${SHELL}" "${i}${0}" "${@}"
35 # We need *stealthmua* regardless of $SOURCE_DATE_EPOCH, the program name as
36 # such is a compile-time variable
37 ARGS='-Sv15-compat -:/ -# -Sdotlock-disable -Sexpandaddr=restrict'
38 ARGS="${ARGS}"' -Smime-encoding=quoted-printable -Snosave -Sstealthmua'
39 ADDARG_UNI=-Sttycharset=UTF-8
40 CONF=../make.rc
41 BODY=./.cc-body.txt
42 MBOX=./.cc-test.mbox
43 ERR=./.cc-test.err # Covers only some which cannot be checksummed; not quoted!
44 MAIL=/dev/null
45 #UTF8_LOCALE= autodetected unless set
47 # Note valgrind has problems with FDs in forked childs, which causes some tests
48 # to fail (the FD is rewound and thus will be dumped twice)
49 MEMTESTER=
50 #MEMTESTER='valgrind --leak-check=full --log-file=.vl-%p '
52 ## -- (>8 -- 8<) -- ##
54 msg() {
55 fmt=${1}
56 shift
57 printf >&2 -- "${fmt}\\n" "${@}"
60 ## -- >8 -- 8< -- ##
62 export ARGS ADDARG_UNI CONF BODY MBOX MAIL MAKE awk cat cksum rm sed grep
64 LC_ALL=C LANG=C
65 TZ=UTC
66 # Wed Oct 2 01:50:07 UTC 1996
67 SOURCE_DATE_EPOCH=844221007
69 export LC_ALL LANG TZ SOURCE_DATE_EPOCH
70 unset POSIXLY_CORRECT LOGNAME USER
72 usage() {
73 ${cat} >&2 <<_EOT
74 Synopsis: cc-test.sh --check-only s-mailx-binary
75 Synopsis: cc-test.sh --mae-test s-mailx-binary [:TEST:]
76 Synopsis: cc-test.sh
78 --check-only EXE run the test series, exit success or error;
79 if run in a git(1) checkout then failed tests
80 create test output data files
81 --mae-test EXE [:TEST:] run all or only the given TESTs, and create
82 test output data files; if run in a git(1)
83 checkout with the [test-out] branch available,
84 it will also create file differences
86 Without arguments as many different configurations as possible
87 will be compiled and tested.
88 _EOT
89 exit 1
92 CHECK_ONLY= MAE_TEST= GIT_REPO= MAILX=
93 if [ "${1}" = --check-only ]; then
94 [ ${#} -eq 2 ] || usage
95 CHECK_ONLY=1 MAILX=${2}
96 [ -x "${MAILX}" ] || usage
97 echo 'Mode: --check-only, binary: '"${MAILX}"
98 [ -d ../.git ] && [ -z "${MAILX__CC_TEST_NO_DATA_FILES}" ] && GIT_REPO=1
99 elif [ "${1}" = --mae-test ]; then
100 [ ${#} -ge 2 ] || usage
101 MAE_TEST=1 MAILX=${2}
102 [ -x "${MAILX}" ] || usage
103 shift 2
104 echo 'Mode: --mae-test, binary: '"${MAILX}"
105 [ -d ../.git ] && GIT_REPO=1
106 else
107 [ ${#} -eq 0 ] || usage
108 echo 'Mode: full compile test, this will take a long time...'
109 MAILX__CC_TEST_NO_DATA_FILES=1
110 export MAILX__CC_TEST_NO_DATA_FILES
113 RAWMAILX=${MAILX}
114 MAILX="${MEMTESTER}${MAILX}"
115 export RAWMAILX MAILX
117 if [ -n "${CHECK_ONLY}${MAE_TEST}" ]; then
118 if [ -z "${UTF8_LOCALE}" ]; then
119 # Try ourselfs via nl_langinfo(CODESET) first (requires a new version)
120 if command -v "${RAWMAILX}" >/dev/null 2>&1 &&
121 ("${RAWMAILX}" -:/ -Xxit) >/dev/null 2>&1; then
122 echo 'Trying to detect UTF-8 locale via '"${RAWMAILX}"
123 i=`LC_ALL=C.utf8 "${RAWMAILX}" ${ARGS} -X '
124 \define cset_test {
125 \if [ "${ttycharset}" @i=% utf ]
126 \echo $LC_ALL
127 \xit 0
128 \end
129 \if [ "${#}" -gt 0 ]
130 \wysh set LC_ALL=${1}
131 \shift
132 \eval xcall cset_test "${@}"
133 \end
134 \xit 1
136 \call cset_test C.UTF-8 POSIX.utf8 POSIX.UTF-8 \
137 en_EN.utf8 en_EN.UTF-8 en_US.utf8 en_US.UTF-8
139 [ $? -eq 0 ] && UTF8_LOCALE=$i
142 if [ -z "${UTF8_LOCALE}" ] && (locale yesexpr) >/dev/null 2>&1; then
143 echo 'Trying to detect UTF-8 locale via locale -a'
144 UTF8_LOCALE=`locale -a | { m=
145 while read n; do
146 if { echo ${n} |
147 ${grep} -i -e utf8 -e utf-8; } >/dev/null 2>&1; then
148 m=${n}
149 if { echo ${n} |
150 ${grep} -e POSIX -e en_EN -e en_US; } \
151 >/dev/null 2>&1; then
152 break
155 done
156 echo ${m}
161 if [ -n "${UTF8_LOCALE}" ]; then
162 echo 'Using Unicode locale '"${UTF8_LOCALE}"
163 else
164 echo 'No Unicode locale found, disabling Unicode tests'
168 ESTAT=0
170 TRAP_EXIT_ADDONS=
171 TEST_NAME=
172 trap "${rm} -rf \"${BODY}\" \"${MBOX}\" \"${ERR}\" \${TRAP_EXIT_ADDONS}" EXIT
173 trap "exit 1" HUP INT TERM
175 have_feat() {
176 ( "${RAWMAILX}" ${ARGS} -X'echo $features' -Xx |
177 ${grep} +${1} ) >/dev/null 2>&1
180 t_prolog() {
181 ${rm} -rf "${BODY}" "${MBOX}" ${TRAP_EXIT_ADDONS}
182 TRAP_EXIT_ADDONS=
183 if [ ${#} -gt 0 ]; then
184 TEST_NAME=${1}
185 printf '[%s]\n' "${1}"
188 t_epilog() {
189 t_prolog
192 t_xmta() {
193 [ ${#} -ge 1 ] && __from=${1} ||
194 __from='Silybum Marianum Tue Apr 17 15:55:01 2018'
195 [ ${#} -eq 2 ] && __to=${2} || __to="${MBOX}"
196 ${cat} <<-_EOT > .tmta.sh
197 #!${SHELL} -
198 ( echo 'From '"${__from}" && ${cat} && echo ) >> "${__to}"
199 _EOT
200 chmod 0755 .tmta.sh
203 check() {
204 restat=${?} tid=${1} eestat=${2} f=${3} s=${4}
205 [ "${eestat}" != - ] && [ "${restat}" != "${eestat}" ] &&
206 err "${TESTNAME}-${tid}" 'unexpected status: '"${restat} != ${eestat}"
207 csum="`${cksum} < ${f}`"
208 if [ "${csum}" = "${s}" ]; then
209 maex=
210 printf '%s-%s: ok\n' "${TEST_NAME}" "${tid}"
211 else
212 maex=yes
213 ESTAT=1
214 printf '%s-%s: error: checksum mismatch (got %s)\n' \
215 "${TEST_NAME}" "${tid}" "${csum}"
218 if [ -n "${CHECK_ONLY}${MAE_TEST}" ]; then
219 x="t.${TEST_NAME}-${tid}"
220 if [ -n "${MAE_TEST}" ] || [ -n "${maex}" -a -n "${GIT_REPO}" ]; then
221 ${cp} -f "${f}" ./"${x}"
224 if [ -n "${maex}" ] && [ -n "${GIT_REPO}" ] &&
225 command -v diff >/dev/null 2>&1 &&
226 (git rev-parse --verify test-out) >/dev/null 2>&1 &&
227 git show test-out:"${x}" > ./"${x}".old 2>/dev/null; then
228 diff -ru ./"${x}".old ./"${x}" > "${x}".diff
233 err() {
234 ESTAT=1
235 printf '%s: error: %s\n' ${1} "${2}"
238 check_ex0() {
239 # $1=test name [$2=status]
240 __qm__=${?}
241 [ ${#} -gt 1 ] && __qm__=${2}
242 if [ ${__qm__} -ne 0 ]; then
243 err "${TEST_NAME}-${1}" 'unexpected non-0 exit status'
244 return 0
245 else
246 printf '%s-%s: ok\n' "${TEST_NAME}" "${1}"
247 return 1
251 check_exn0() {
252 # $1=test name [$2=status]
253 __qm__=${?}
254 [ ${#} -gt 1 ] && __qm__=${2}
255 if [ ${__qm__} -eq 0 ]; then
256 err "${TEST_NAME}-${1}" 'unexpected 0 exit status'
257 return 1
258 else
259 printf '%s-%s: ok\n' "${TEST_NAME}" "${1}"
260 return 0
264 if ( [ "$((1 + 1))" = 2 ] ) >/dev/null 2>&1; then
265 add() {
266 echo "$((${1} + ${2}))"
268 else
269 add() {
270 echo `${awk} 'BEGIN{print '${1}' + '${2}'}'`
274 if ( [ "$((2 % 3))" = 2 ] ) >/dev/null 2>&1; then
275 modulo() {
276 echo "$((${1} % ${2}))"
278 else
279 modulo() {
280 echo `${awk} 'BEGIN{print '${1}' % '${2}'}'`
284 t_all() {
285 # Basics
286 t_X_opt_input_command_stack
287 t_X_errexit
288 t_S_freeze
289 t_input_inject_semicolon_seq
290 t_shcodec
291 t_wysh
292 t_commandalias
293 t_ifelse
294 t_localopts
295 t_local
296 t_macro_param_shift
297 t_addrcodec
298 t_vexpr
299 t_call_ret
300 t_xcall
301 t_vpospar
302 t_atxplode
303 t_read
305 # VFS
306 t_mbox
307 t_maildir
309 # MIME and RFC basics
310 t_mime_if_not_ascii
311 t_xxxheads_rfc2047
312 t_iconv_mbyte_base64
313 t_iconv_mainbody
314 t_binary_mainbody
315 t_C_opt_customhdr
317 # Operational basics with easy tests
318 t_alias
319 t_filetype
320 t_record_a_resend
321 t_e_H_L_opts
322 t_q_t_etc_opts
323 t_message_injections
324 t_attachments
325 t_rfc2231 # (after attachments)
326 t_mime_types_load_control
328 # Around state machine, after basics
329 t_alternates
330 t_quote_a_cmd_escapes
331 t_compose_edits
333 # Heavy use of/rely on state machine (behaviour) and basics
334 t_compose_hooks
335 t_mass_recipients
336 t_lreply_futh_rth_etc
338 # Rest
339 t_s_mime
342 # Basics {{{
343 t_X_opt_input_command_stack() {
344 t_prolog X_opt_input_command_stack
346 ${cat} <<- '__EOT' > "${BODY}"
347 echo 1
348 define mac0 {
349 echo mac0-1 via1 $0
351 call mac0
352 echo 2
353 source '\
354 echo "define mac1 {";\
355 echo " echo mac1-1 via1 \$0";\
356 echo " call mac0";\
357 echo " echo mac1-2";\
358 echo " call mac2";\
359 echo " echo mac1-3";\
360 echo "}";\
361 echo "echo 1-1";\
362 echo "define mac2 {";\
363 echo " echo mac2-1 via1 \$0";\
364 echo " call mac0";\
365 echo " echo mac2-2";\
366 echo "}";\
367 echo "echo 1-2";\
368 echo "call mac1";\
369 echo "echo 1-3";\
370 echo "source \"\
371 echo echo 1-1-1 via1 \$0;\
372 echo call mac0;\
373 echo echo 1-1-2;\
374 | \"";\
375 echo "echo 1-4";\
377 echo 3
378 call mac2
379 echo 4
380 undefine *
381 __EOT
383 # The -X option supports multiline arguments, and those can internally use
384 # reverse solidus newline escaping. And all -X options are joined...
385 APO=\'
386 < "${BODY}" ${MAILX} ${ARGS} \
387 -X 'e\' \
388 -X ' c\' \
389 -X ' h\' \
390 -X ' o \' \
391 -X 1 \
393 define mac0 {
394 echo mac0-1 via2 $0
396 call mac0
397 echo 2
400 source '${APO}'\
401 echo "define mac1 {";\
402 echo " echo mac1-1 via2 \$0";\
403 echo " call mac0";\
404 echo " echo mac1-2";\
405 echo " call mac2";\
406 echo " echo mac1-3";\
407 echo "}";\
408 echo "echo 1-1";\
409 echo "define mac2 {";\
410 echo " echo mac2-1 via2 \$0";\
411 echo " call mac0";\
412 echo " echo mac2-2";\
413 echo "}";\
414 echo "echo 1-2";\
415 echo "call mac1";\
416 echo "echo 1-3";\
417 echo "source \"\
418 echo echo 1-1-1 via2 \$0;\
419 echo call mac0;\
420 echo echo 1-1-2;\
421 | \"";\
422 echo "echo 1-4";\
423 | '${APO}'
424 echo 3
427 call mac2
428 echo 4
429 undefine *
430 ' > "${MBOX}"
432 check 1 0 "${MBOX}" '1786542668 416'
434 t_epilog
437 t_X_errexit() {
438 t_prolog X_errexit
439 if have_feat uistrings; then :; else
440 echo 'x_errexit: unsupported, skipped'
441 return
444 ${cat} <<- '__EOT' > "${BODY}"
445 echo one
446 echos nono
447 echo two
448 __EOT
450 </dev/null ${MAILX} ${ARGS} -Snomemdebug \
451 -X'echo one' -X' echos nono ' -X'echo two' \
452 > "${MBOX}" 2>&1
453 check 1 0 "${MBOX}" '916157812 53'
455 </dev/null ${MAILX} ${ARGS} -X'source '"${BODY}" -Snomemdebug \
456 > "${MBOX}" 2>&1
457 check 2 0 "${MBOX}" '916157812 53'
459 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Snomemdebug \
460 > "${MBOX}" 2>&1
461 check 3 0 "${MBOX}" '916157812 53'
465 </dev/null ${MAILX} ${ARGS} -Serrexit -Snomemdebug \
466 -X'echo one' -X' echos nono ' -X'echo two' \
467 > "${MBOX}" 2>&1
468 check 4 1 "${MBOX}" '2118430867 49'
470 </dev/null ${MAILX} ${ARGS} -X'source '"${BODY}" -Serrexit -Snomemdebug \
471 > "${MBOX}" 2>&1
472 check 5 1 "${MBOX}" '2118430867 49'
474 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Serrexit -Snomemdebug \
475 > "${MBOX}" 2>&1
476 check 6 1 "${MBOX}" '12955965 172'
478 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Sposix -Snomemdebug \
479 > "${MBOX}" 2>&1
480 check 7 1 "${MBOX}" '12955965 172'
482 ## Repeat 4-7 with ignerr set
484 ${sed} -e 's/^echos /ignerr echos /' < "${BODY}" > "${MBOX}"
486 </dev/null ${MAILX} ${ARGS} -Serrexit -Snomemdebug \
487 -X'echo one' -X'ignerr echos nono ' -X'echo two' \
488 > "${BODY}" 2>&1
489 check 8 0 "${BODY}" '916157812 53'
491 </dev/null ${MAILX} ${ARGS} -X'source '"${MBOX}" -Serrexit -Snomemdebug \
492 > "${BODY}" 2>&1
493 check 9 0 "${BODY}" '916157812 53'
495 </dev/null MAILRC="${MBOX}" ${MAILX} ${ARGS} -:u -Serrexit -Snomemdebug \
496 > "${BODY}" 2>&1
497 check 10 0 "${BODY}" '916157812 53'
499 </dev/null MAILRC="${MBOX}" ${MAILX} ${ARGS} -:u -Sposix -Snomemdebug \
500 > "${BODY}" 2>&1
501 check 11 0 "${BODY}" '916157812 53'
503 t_epilog
506 t_S_freeze() {
507 t_prolog S_freeze
508 oterm=$TERM
509 unset TERM
511 # Test basic assumption
512 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} \
513 -X'echo asksub<$asksub> dietcurd<$dietcurd>' \
514 -Xx > "${MBOX}" 2>&1
515 check 1 0 "${MBOX}" '270686329 21'
518 ${cat} <<- '__EOT' > "${BODY}"
519 echo asksub<$asksub>
520 set asksub
521 echo asksub<$asksub>
522 __EOT
523 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
524 -Snoasksub -Sasksub -Snoasksub \
525 -X'echo asksub<$asksub>' -X'set asksub' -X'echo asksub<$asksub>' \
526 -Xx > "${MBOX}" 2>&1
527 check 2 0 "${MBOX}" '3182942628 37'
529 ${cat} <<- '__EOT' > "${BODY}"
530 echo asksub<$asksub>
531 unset asksub
532 echo asksub<$asksub>
533 __EOT
534 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
535 -Snoasksub -Sasksub \
536 -X'echo asksub<$asksub>' -X'unset asksub' -X'echo asksub<$asksub>' \
537 -Xx > "${MBOX}" 2>&1
538 check 3 0 "${MBOX}" '2006554293 39'
541 ${cat} <<- '__EOT' > "${BODY}"
542 echo dietcurd<$dietcurd>
543 set dietcurd=cherry
544 echo dietcurd<$dietcurd>
545 __EOT
546 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
547 -Sdietcurd=strawberry -Snodietcurd -Sdietcurd=vanilla \
548 -X'echo dietcurd<$dietcurd>' -X'unset dietcurd' \
549 -X'echo dietcurd<$dietcurd>' \
550 -Xx > "${MBOX}" 2>&1
551 check 4 0 "${MBOX}" '1985768109 65'
553 ${cat} <<- '__EOT' > "${BODY}"
554 echo dietcurd<$dietcurd>
555 unset dietcurd
556 echo dietcurd<$dietcurd>
557 __EOT
558 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
559 -Sdietcurd=strawberry -Snodietcurd \
560 -X'echo dietcurd<$dietcurd>' -X'set dietcurd=vanilla' \
561 -X'echo dietcurd<$dietcurd>' \
562 -Xx > "${MBOX}" 2>&1
563 check 5 0 "${MBOX}" '151574279 51'
565 # TODO once we have a detached one with env=1..
566 if [ -n "`</dev/null ${MAILX} ${ARGS} -X'!echo \$TERM' -Xx`" ]; then
567 echo 's_freeze-{6,7}: shell sets $TERM, skipped'
568 else
569 ${cat} <<- '__EOT' > "${BODY}"
570 !echo "shell says TERM<$TERM>"
571 echo TERM<$TERM>
572 !echo "shell says TERM<$TERM>"
573 set TERM=cherry
574 !echo "shell says TERM<$TERM>"
575 echo TERM<$TERM>
576 !echo "shell says TERM<$TERM>"
577 __EOT
578 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
579 -STERM=strawberry -SnoTERM -STERM=vanilla \
580 -X'echo mail<$TERM>' -X'unset TERM' \
581 -X'!echo "shell says TERM<$TERM>"' -X'echo TERM<$TERM>' \
582 -Xx > "${MBOX}" 2>&1
583 check 6 0 "${MBOX}" '1211476036 167'
585 ${cat} <<- '__EOT' > "${BODY}"
586 !echo "shell says TERM<$TERM>"
587 echo TERM<$TERM>
588 !echo "shell says TERM<$TERM>"
589 set TERM=cherry
590 !echo "shell says TERM<$TERM>"
591 echo TERM<$TERM>
592 !echo "shell says TERM<$TERM>"
593 __EOT
594 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
595 -STERM=strawberry -SnoTERM \
596 -X'echo TERM<$TERM>' -X'set TERM=vanilla' \
597 -X'!echo "shell says TERM<$TERM>"' -X'echo TERM<$TERM>' \
598 -Xx > "${MBOX}" 2>&1
599 check 7 0 "${MBOX}" '3365080441 132'
602 TERM=$oterm
603 t_epilog
606 t_input_inject_semicolon_seq() {
607 t_prolog input_inject_semicolon_seq
609 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
610 define mydeepmac {
611 echon '(mydeepmac)';
613 define mymac {
614 echon this_is_mymac;call mydeepmac;echon ';';
616 echon one';';call mymac;echon two";";call mymac;echo three$';';
617 define mymac {
618 echon this_is_mymac;call mydeepmac;echon ,TOO'!;';
620 echon one';';call mymac;echon two";";call mymac;echo three$';';
621 __EOT
623 check 1 0 "${MBOX}" '512117110 140'
625 t_epilog
628 t_shcodec() {
629 t_prolog shcodec
631 # XXX the first needs to be checked, it is quite dumb as such
632 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
633 shcodec e abcd
634 echo $?/$^ERRNAME
635 shcodec d abcd
636 echo $?/$^ERRNAME
637 shcodec e a'b'c'd'
638 echo $?/$^ERRNAME
639 shcodec d a'b'c'd'
640 echo $?/$^ERRNAME
641 shcodec e a"b"c"d"
642 echo $?/$^ERRNAME
643 shcodec d a"b"c"d"
644 echo $?/$^ERRNAME
645 shcodec e a$'b'c$'d'
646 echo $?/$^ERRNAME
647 shcodec d a$'b'c$'d'
648 echo $?/$^ERRNAME
649 shcodec e 'abcd'
650 echo $?/$^ERRNAME
651 shcodec d 'abcd'
652 echo $?/$^ERRNAME
653 shcodec e "abcd"
654 echo $?/$^ERRNAME
655 shcodec d "abcd"
656 echo $?/$^ERRNAME
657 shcodec e $'abcd'
658 echo $?/$^ERRNAME
659 shcodec d $'abcd'
660 echo $?/$^ERRNAME
661 # same but with vput
662 vput shcodec res e abcd
663 echo $?/$^ERRNAME $res
664 eval shcodec d $res
665 echo $?/$^ERRNAME
666 vput shcodec res d abcd
667 echo $?/$^ERRNAME $res
668 eval shcodec d $res
669 echo $?/$^ERRNAME
670 vput shcodec res e a'b'c'd'
671 echo $?/$^ERRNAME $res
672 eval shcodec d $res
673 echo $?/$^ERRNAME
674 vput shcodec res d a'b'c'd'
675 echo $?/$^ERRNAME $res
676 eval shcodec d $res
677 echo $?/$^ERRNAME
678 vput shcodec res e a"b"c"d"
679 echo $?/$^ERRNAME $res
680 eval shcodec d $res
681 echo $?/$^ERRNAME
682 vput shcodec res d a"b"c"d"
683 echo $?/$^ERRNAME $res
684 eval shcodec d $res
685 echo $?/$^ERRNAME
686 vput shcodec res e a$'b'c$'d'
687 echo $?/$^ERRNAME $res
688 eval shcodec d $res
689 echo $?/$^ERRNAME
690 vput shcodec res d a$'b'c$'d'
691 echo $?/$^ERRNAME $res
692 eval shcodec d $res
693 echo $?/$^ERRNAME
694 vput shcodec res e 'abcd'
695 echo $?/$^ERRNAME $res
696 eval shcodec d $res
697 echo $?/$^ERRNAME
698 vput shcodec res d 'abcd'
699 echo $?/$^ERRNAME $res
700 eval shcodec d $res
701 echo $?/$^ERRNAME
702 vput shcodec res e "abcd"
703 echo $?/$^ERRNAME $res
704 eval shcodec d $res
705 echo $?/$^ERRNAME
706 vput shcodec res d "abcd"
707 echo $?/$^ERRNAME $res
708 eval shcodec d $res
709 echo $?/$^ERRNAME
710 vput shcodec res e $'abcd'
711 echo $?/$^ERRNAME $res
712 eval shcodec d $res
713 echo $?/$^ERRNAME
714 vput shcodec res d $'abcd'
715 echo $?/$^ERRNAME $res
716 eval shcodec d $res
717 echo $?/$^ERRNAME
719 vput shcodec res e a b\ c d
720 echo $?/$^ERRNAME $res
721 eval shcodec d $res
722 echo $?/$^ERRNAME
723 vput shcodec res d a b\ c d
724 echo $?/$^ERRNAME $res
725 vput shcodec res e ab cd
726 echo $?/$^ERRNAME $res
727 eval shcodec d $res
728 echo $?/$^ERRNAME
729 vput shcodec res d 'ab cd'
730 echo $?/$^ERRNAME $res
731 vput shcodec res e a 'b c' d
732 echo $?/$^ERRNAME $res
733 eval shcodec d $res
734 echo $?/$^ERRNAME
735 vput shcodec res d a 'b c' d
736 echo $?/$^ERRNAME $res
737 vput shcodec res e a "b c" d
738 echo $?/$^ERRNAME $res
739 eval shcodec d $res
740 echo $?/$^ERRNAME
741 vput shcodec res d a "b c" d
742 echo $?/$^ERRNAME $res
743 vput shcodec res e a $'b c' d
744 echo $?/$^ERRNAME $res
745 eval shcodec d $res
746 echo $?/$^ERRNAME
747 vput shcodec res d a $'b c' d
748 echo $?/$^ERRNAME $res
750 vput shcodec res e 'a$`"\'
751 echo $?/$^ERRNAME $res
752 eval shcodec d $res
753 echo $?/$^ERRNAME
754 vput shcodec res d 'a$`"\'
755 echo $?/$^ERRNAME $res
756 vput shcodec res e "a\$\`'\"\\"
757 echo $?/$^ERRNAME $res
758 eval shcodec d $res
759 echo $?/$^ERRNAME
760 vput shcodec res d "a\$\`'\"\\"
761 echo $?/$^ERRNAME $res
762 vput shcodec res e $'a\$`\'\"\\'
763 echo $?/$^ERRNAME $res
764 eval shcodec d $res
765 echo $?/$^ERRNAME
766 vput shcodec res d $'a\$`\'\"\\'
767 echo $?/$^ERRNAME $res
768 vput shcodec res e $'a\$`\'"\\'
769 echo $?/$^ERRNAME $res
770 eval shcodec d $res
771 echo $?/$^ERRNAME
772 vput shcodec res d $'a\$`\'"\\'
773 echo $?/$^ERRNAME $res
775 set diet=curd
776 vput shcodec res e a${diet}c
777 echo $?/$^ERRNAME $res
778 eval shcodec d $res
779 echo $?/$^ERRNAME
780 eval vput shcodec res e a${diet}c
781 echo $?/$^ERRNAME $res
782 eval shcodec d $res
783 echo $?/$^ERRNAME
784 vput shcodec res e "a${diet}c"
785 echo $?/$^ERRNAME $res
786 eval shcodec d $res
787 echo $?/$^ERRNAME
788 eval vput shcodec res e "a${diet}c"
789 echo $?/$^ERRNAME $res
790 eval shcodec d $res
791 echo $?/$^ERRNAME
792 __EOT
793 check 1 0 "${MBOX}" '3316745312 1241'
795 if [ -z "${UTF8_LOCALE}" ]; then
796 echo 'Skip shcodec-unicode, no UTF8_LOCALE TODO CANNOT'
797 else
798 ${cat} <<- '__EOT' | LC_ALL=${UTF8_LOCALE} \
799 ${MAILX} ${ARGS} > "${MBOX}" 2>>${ERR}
801 shcodec e täst
802 shcodec +e täst
803 shcodec d $'t\u00E4st'
804 shcodec e aՍc
805 shcodec +e aՍc
806 shcodec d $'a\u054Dc'
807 shcodec e a😃c
808 shcodec +e a😃c
809 shcodec d $'a\U0001F603c'
810 __EOT
811 check unicode 0 "${MBOX}" '4233409480 77'
814 t_epilog
817 t_wysh() {
818 t_prolog wysh
820 ${cat} <<- '__EOT' > "${BODY}"
822 echo abcd
823 echo a'b'c'd'
824 echo a"b"c"d"
825 echo a$'b'c$'d'
826 echo 'abcd'
827 echo "abcd"
828 echo $'abcd'
829 echo a\ b\ c\ d
830 echo a 'b c' d
831 echo a "b c" d
832 echo a $'b c' d
834 echo 'a$`"\'
835 echo "a\$\`'\"\\"
836 echo $'a\$`\'\"\\'
837 echo $'a\$`\'"\\'
838 # DIET=CURD TIED=
839 echo 'a${DIET}b${TIED}c\${DIET}d\${TIED}e' # COMMENT
840 echo "a${DIET}b${TIED}c\${DIET}d\${TIED}e"
841 echo $'a${DIET}b${TIED}c\${DIET}d\${TIED}e'
843 echo a$'\101\0101\x41\u0041\u41\U00000041\U41'c
844 echo a$'\u0041\u41\u0C1\U00000041\U41'c
845 echo a$'\377'c
846 echo a$'\0377'c
847 echo a$'\400'c
848 echo a$'\0400'c
849 echo a$'\U1100001'c
851 echo a$'b\0c'd
852 echo a$'b\00c'de
853 echo a$'b\000c'df
854 echo a$'b\0000c'dg
855 echo a$'b\x0c'dh
856 echo a$'b\x00c'di
857 echo a$'b\u0'dj
858 echo a$'b\u00'dk
859 echo a$'b\u000'dl
860 echo a$'b\u0000'dm
861 echo a$'b\U0'dn
862 echo a$'b\U00'do
863 echo a$'b\U000'dp
864 echo a$'b\U0000'dq
865 echo a$'b\U00000'dr
866 echo a$'b\U000000'ds
867 echo a$'b\U0000000'dt
868 echo a$'b\U00000000'du
870 echo a$'\cI'b
871 echo a$'\011'b
872 echo a$'\x9'b
873 echo a$'\u9'b
874 echo a$'\U9'b
875 echo a$'\c@'b c d
876 __EOT
878 if [ -z "${UTF8_LOCALE}" ]; then
879 echo 'Skip wysh-unicode, no UTF8_LOCALE'
880 else
881 < "${BODY}" DIET=CURD TIED= \
882 LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} > "${MBOX}" 2>>${ERR}
883 check unicode 0 "${MBOX}" '475805847 317'
886 < "${BODY}" DIET=CURD TIED= ${MAILX} ${ARGS} > "${MBOX}" 2>>${ERR}
887 check c 0 "${MBOX}" '1473887148 321'
889 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
890 wysh set mager='\hey\'
891 varshow mager
892 wysh set mager="\hey\\"
893 varshow mager
894 wysh set mager=$'\hey\\'
895 varshow mager
896 __EOT
897 check 3 0 "${MBOX}" '1289698238 69'
899 t_epilog
902 t_commandalias() {
903 t_prolog commandalias
905 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
906 commandalias echo echo hoho
907 echo stop.
908 commandalias X Xx
909 commandalias Xx XxX
910 commandalias XxX XxXx
911 commandalias XxXx XxXxX
912 commandalias XxXxX XxXxXx
913 commandalias XxXxXx echo huhu
914 commandalias XxXxXxX echo huhu
916 commandalias XxXxXx XxXxXxX
918 uncommandalias echo
919 commandalias XxXxXx echo huhu
921 __EOT
923 check 1 0 "${MBOX}" '1638809585 36'
925 t_epilog
928 t_ifelse() {
929 t_prolog ifelse
931 # Nestable conditions test
932 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
933 if 0
934 echo 1.err
935 else
936 echo 1.ok
937 endif
938 if 1
939 echo 2.ok
940 else
941 echo 2.err
942 endif
943 if $dietcurd
944 echo 3.err
945 else
946 echo 3.ok
947 endif
948 set dietcurd=yoho
949 if $dietcurd
950 echo 4.ok
951 else
952 echo 4.err
953 endif
954 if $dietcurd == 'yoho'
955 echo 5.ok
956 else
957 echo 5.err
958 endif
959 if $dietcurd @== 'Yoho'
960 echo 5-1.ok
961 else
962 echo 5-1.err
963 endif
964 if $dietcurd == 'Yoho'
965 echo 5-2.err
966 else
967 echo 5-2.ok
968 endif
969 if $dietcurd != 'yoho'
970 echo 6.err
971 else
972 echo 6.ok
973 endif
974 if $dietcurd @!= 'Yoho'
975 echo 6-1.err
976 else
977 echo 6-1.ok
978 endif
979 if $dietcurd != 'Yoho'
980 echo 6-2.ok
981 else
982 echo 6-2.err
983 endif
984 # Nesting
985 if faLse
986 echo 7.err1
987 if tRue
988 echo 7.err2
989 if yEs
990 echo 7.err3
991 else
992 echo 7.err4
993 endif
994 echo 7.err5
995 endif
996 echo 7.err6
997 else
998 echo 7.ok7
999 if YeS
1000 echo 7.ok8
1001 if No
1002 echo 7.err9
1003 else
1004 echo 7.ok9
1005 endif
1006 echo 7.ok10
1007 else
1008 echo 7.err11
1009 if yeS
1010 echo 7.err12
1011 else
1012 echo 7.err13
1013 endif
1014 endif
1015 echo 7.ok14
1016 endif
1017 if r
1018 echo 8.ok1
1019 if R
1020 echo 8.ok2
1021 else
1022 echo 8.err2
1023 endif
1024 echo 8.ok3
1025 else
1026 echo 8.err1
1027 endif
1028 if s
1029 echo 9.err1
1030 else
1031 echo 9.ok1
1032 if S
1033 echo 9.err2
1034 else
1035 echo 9.ok2
1036 endif
1037 echo 9.ok3
1038 endif
1039 # `elif'
1040 if $dietcurd == 'yohu'
1041 echo 10.err1
1042 elif $dietcurd == 'yoha'
1043 echo 10.err2
1044 elif $dietcurd == 'yohe'
1045 echo 10.err3
1046 elif $dietcurd == 'yoho'
1047 echo 10.ok1
1048 if $dietcurd == 'yohu'
1049 echo 10.err4
1050 elif $dietcurd == 'yoha'
1051 echo 10.err5
1052 elif $dietcurd == 'yohe'
1053 echo 10.err6
1054 elif $dietcurd == 'yoho'
1055 echo 10.ok2
1056 if $dietcurd == 'yohu'
1057 echo 10.err7
1058 elif $dietcurd == 'yoha'
1059 echo 10.err8
1060 elif $dietcurd == 'yohe'
1061 echo 10.err9
1062 elif $dietcurd == 'yoho'
1063 echo 10.ok3
1064 else
1065 echo 10.err10
1066 endif
1067 else
1068 echo 10.err11
1069 endif
1070 else
1071 echo 10.err12
1072 endif
1073 # integer
1074 set dietcurd=10
1075 if $dietcurd -lt 11
1076 echo 11.ok1
1077 if $dietcurd -gt 9
1078 echo 11.ok2
1079 else
1080 echo 11.err2
1081 endif
1082 if $dietcurd -eq 10
1083 echo 11.ok3
1084 else
1085 echo 11.err3
1086 endif
1087 if $dietcurd -ge 10
1088 echo 11.ok4
1089 else
1090 echo 11.err4
1091 endif
1092 if $dietcurd -le 10
1093 echo 11.ok5
1094 else
1095 echo 11.err5
1096 endif
1097 if $dietcurd -ge 11
1098 echo 11.err6
1099 else
1100 echo 11.ok6
1101 endif
1102 if $dietcurd -le 9
1103 echo 11.err7
1104 else
1105 echo 11.ok7
1106 endif
1107 else
1108 echo 11.err1
1109 endif
1110 set dietcurd=Abc
1111 if $dietcurd < aBd
1112 echo 12.ok1
1113 if $dietcurd @> abB
1114 echo 12.ok2
1115 else
1116 echo 12.err2
1117 endif
1118 if $dietcurd @== aBC
1119 echo 12.ok3
1120 else
1121 echo 12.err3
1122 endif
1123 if $dietcurd @>= AbC
1124 echo 12.ok4
1125 else
1126 echo 12.err4
1127 endif
1128 if $dietcurd @<= ABc
1129 echo 12.ok5
1130 else
1131 echo 12.err5
1132 endif
1133 if $dietcurd @>= abd
1134 echo 12.err6
1135 else
1136 echo 12.ok6
1137 endif
1138 if $dietcurd @<= abb
1139 echo 12.err7
1140 else
1141 echo 12.ok7
1142 endif
1143 else
1144 echo 12.err1
1145 endif
1146 if $dietcurd < aBc
1147 echo 12-1.ok
1148 else
1149 echo 12-1.err
1150 endif
1151 if $dietcurd @< aBc
1152 echo 12-2.err
1153 else
1154 echo 12-2.ok
1155 endif
1156 if $dietcurd > ABc
1157 echo 12-3.ok
1158 else
1159 echo 12-3.err
1160 endif
1161 if $dietcurd @> ABc
1162 echo 12-3.err
1163 else
1164 echo 12-3.ok
1165 endif
1166 if $dietcurd @i=% aB
1167 echo 13.ok
1168 else
1169 echo 13.err
1170 endif
1171 if $dietcurd =% aB
1172 echo 13-1.err
1173 else
1174 echo 13-1.ok
1175 endif
1176 if $dietcurd @=% bC
1177 echo 14.ok
1178 else
1179 echo 14.err
1180 endif
1181 if $dietcurd !% aB
1182 echo 15-1.ok
1183 else
1184 echo 15-1.err
1185 endif
1186 if $dietcurd @!% aB
1187 echo 15-2.err
1188 else
1189 echo 15-2.ok
1190 endif
1191 if $dietcurd !% bC
1192 echo 15-3.ok
1193 else
1194 echo 15-3.err
1195 endif
1196 if $dietcurd @!% bC
1197 echo 15-4.err
1198 else
1199 echo 15-4.ok
1200 endif
1201 if $dietcurd =% Cd
1202 echo 16.err
1203 else
1204 echo 16.ok
1205 endif
1206 if $dietcurd !% Cd
1207 echo 17.ok
1208 else
1209 echo 17.err
1210 endif
1211 set diet=abc curd=abc
1212 if $diet == $curd
1213 echo 18.ok
1214 else
1215 echo 18.err
1216 endif
1217 set diet=abc curd=abcd
1218 if $diet != $curd
1219 echo 19.ok
1220 else
1221 echo 19.err
1222 endif
1223 # 1. Shitty grouping capabilities as of today
1224 unset diet curd ndefined
1225 if [ [ false ] || [ false ] || [ true ] ] && [ [ false ] || [ true ] ] && \
1226 [ yes ]
1227 echo 20.ok
1228 else
1229 echo 20.err
1230 endif
1231 if [ [ [ [ 0 ] || [ 1 ] ] && [ [ 1 ] || [ 0 ] ] ] && [ 1 ] ] && [ yes ]
1232 echo 21.ok
1233 else
1234 echo 21.err
1235 endif
1236 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] ]
1237 echo 22.ok
1238 else
1239 echo 22.err
1240 endif
1241 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] ]
1242 echo 23.ok
1243 else
1244 echo 23.err
1245 endif
1246 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] && [ no ]
1247 echo 24.err
1248 else
1249 echo 24.ok
1250 endif
1251 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] \
1252 && [ no ] || [ yes ]
1253 echo 25.ok
1254 else
1255 echo 25.err
1256 endif
1257 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
1258 echo 26.ok
1259 else
1260 echo 26.err
1261 endif
1262 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 0 ] ]
1263 echo 27.err
1264 else
1265 echo 27.ok
1266 endif
1267 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 0 ] ] && [ 1 ] ] ] && [ 1 ] ]
1268 echo 28.err
1269 else
1270 echo 28.ok
1271 endif
1272 if [ [ [ [ [ [ [ 0 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
1273 echo 29.err
1274 else
1275 echo 29.ok
1276 endif
1277 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 0 ]
1278 echo 30.err
1279 else
1280 echo 30.ok
1281 endif
1282 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 1 ]
1283 echo 31.ok
1284 else
1285 echo 31.err
1286 endif
1287 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ]
1288 echo 32.err
1289 else
1290 echo 32.ok
1291 endif
1292 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 1 ]
1293 echo 33.ok
1294 else
1295 echo 33.err
1296 endif
1297 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 0 ]
1298 echo 34.err
1299 else
1300 echo 34.ok
1301 endif
1302 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 1 ]
1303 echo 35.ok
1304 else
1305 echo 35.err
1306 endif
1307 set diet=yo curd=ho
1308 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
1309 echo 36.err
1310 else
1311 echo 36.ok
1312 endif
1313 set ndefined
1314 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
1315 echo 37.ok
1316 else
1317 echo 37.err
1318 endif
1319 # 2. Shitty grouping capabilities as of today
1320 unset diet curd ndefined
1321 if [ false || false || true ] && [ false || true ] && yes
1322 echo 40.ok
1323 else
1324 echo 40.err
1325 endif
1326 if [ [ [ 0 || 1 ] && [ 1 || 0 ] ] && 1 ] && [ yes ]
1327 echo 41.ok
1328 else
1329 echo 41.err
1330 endif
1331 if [ 1 || 0 || 0 || 0 ]
1332 echo 42.ok
1333 else
1334 echo 42.err
1335 endif
1336 if [ 1 || 0 || 0 || 0 || [ 1 ] ]
1337 echo 43.ok
1338 else
1339 echo 43.err
1340 endif
1341 if [ 1 || 0 || 0 || 0 || [ 1 ] || 1 ] && no
1342 echo 44.err
1343 else
1344 echo 44.ok
1345 endif
1346 if [ 1 || 0 || 0 || 0 || 1 || [ 1 ] ] && no || [ yes ]
1347 echo 45.ok
1348 else
1349 echo 45.err
1350 endif
1351 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && 1 ] ] && [ 1 ] ]
1352 echo 46.ok
1353 else
1354 echo 46.err
1355 endif
1356 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && [ 1 ] ] ] && 0 ]
1357 echo 47.err
1358 else
1359 echo 47.ok
1360 endif
1361 if [ [ [ [ [ [ [ 1 ] ] && 1 ] && 0 ] && [ 1 ] ] ] && 1 ]
1362 echo 48.err
1363 else
1364 echo 48.ok
1365 endif
1366 if [ [ [ [ [ [ 0 ] && 1 ] && 1 ] && 1 ] ] && 1 ]
1367 echo 49.err
1368 else
1369 echo 49.ok
1370 endif
1371 if 1 || 0 || 0 || 0 && 0
1372 echo 50.err
1373 else
1374 echo 50.ok
1375 endif
1376 if 1 || 0 || 0 || 0 && 1
1377 echo 51.ok
1378 else
1379 echo 51.err
1380 endif
1381 if 0 || 0 || 0 || 1 && 0
1382 echo 52.err
1383 else
1384 echo 52.ok
1385 endif
1386 if 0 || 0 || 0 || 1 && 1
1387 echo 53.ok
1388 else
1389 echo 53.err
1390 endif
1391 if 0 || 0 || 0 || 1 && 0 || 1 && 0
1392 echo 54.err
1393 else
1394 echo 54.ok
1395 endif
1396 if 0 || 0 || 0 || 1 && 0 || 1 && 1
1397 echo 55.ok
1398 else
1399 echo 55.err
1400 endif
1401 set diet=yo curd=ho
1402 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
1403 echo 56.err
1404 else
1405 echo 56.ok
1406 endif
1407 if $diet == 'yo' && $curd == 'ho' && $ndefined
1408 echo 57.err
1409 else
1410 echo 57.ok
1411 endif
1412 set ndefined
1413 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
1414 echo 57.ok
1415 else
1416 echo 57.err
1417 endif
1418 if $diet == 'yo' && $curd == 'ho' && $ndefined
1419 echo 58.ok
1420 else
1421 echo 58.err
1422 endif
1423 if [ [ [ [ [ [ $diet == 'yo' && $curd == 'ho' && $ndefined ] ] ] ] ] ]
1424 echo 59.ok
1425 else
1426 echo 59.err
1427 endif
1428 # Some more en-braced variables
1429 set diet=yo curd=ho
1430 if ${diet} == ${curd}
1431 echo 70.err
1432 else
1433 echo 70.ok
1434 endif
1435 if ${diet} != ${curd}
1436 echo 71.ok
1437 else
1438 echo 71.err
1439 endif
1440 if $diet == ${curd}
1441 echo 72.err
1442 else
1443 echo 72.ok
1444 endif
1445 if ${diet} == $curd
1446 echo 73.err
1447 else
1448 echo 73.ok
1449 endif
1450 # Unary !
1451 if ! 0 && ! ! 1 && ! ! ! ! 2 && 3
1452 echo 80.ok
1453 else
1454 echo 80.err
1455 endif
1456 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ ! 2 ] ] ] && 3
1457 echo 81.ok
1458 else
1459 echo 81.err
1460 endif
1461 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1462 echo 82.ok
1463 else
1464 echo 82.err
1465 endif
1466 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
1467 echo 83.err
1468 else
1469 echo 83.ok
1470 endif
1471 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
1472 echo 84.err
1473 else
1474 echo 84.ok
1475 endif
1476 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1477 echo 85.err
1478 else
1479 echo 85.ok
1480 endif
1481 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1482 echo 86.err
1483 else
1484 echo 86.ok
1485 endif
1486 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] || 3
1487 echo 87.ok
1488 else
1489 echo 87.err
1490 endif
1491 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! ! [ 2 ] ] ] ] ]
1492 echo 88.ok
1493 else
1494 echo 88.err
1495 endif
1496 # Unary !, odd
1497 if ! 0 && ! ! 1 && ! ! ! 0 && 3
1498 echo 90.ok
1499 else
1500 echo 90.err
1501 endif
1502 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ 0 ] ] ] && 3
1503 echo 91.ok
1504 else
1505 echo 91.err
1506 endif
1507 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ [ 0 ] ] ] ] ] && 3
1508 echo 92.ok
1509 else
1510 echo 92.err
1511 endif
1512 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! ! [ ! [ ! 0 ] ] ] ] && ! 3
1513 echo 93.err
1514 else
1515 echo 93.ok
1516 endif
1517 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ ! [ ! [ ! [ ! 0 ] ] ] ] && 3
1518 echo 94.ok
1519 else
1520 echo 94.err
1521 endif
1522 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! ! [ ! [ ! [ ! [ 0 ] ] ] ] ] && 3
1523 echo 95.err
1524 else
1525 echo 95.ok
1526 endif
1527 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! ! 0 ] ] ] ] && 3
1528 echo 96.err
1529 else
1530 echo 96.ok
1531 endif
1532 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ ! 0 ] ] ] ] ] || 3
1533 echo 97.ok
1534 else
1535 echo 97.err
1536 endif
1537 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! [ 0 ] ] ] ] ]
1538 echo 98.ok
1539 else
1540 echo 98.err
1541 endif
1542 __EOT
1544 check normal 0 "${MBOX}" '1688759742 719'
1546 if have_feat regex; then
1547 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
1548 set dietcurd=yoho
1549 if $dietcurd =~ '^yo.*'
1550 echo 1.ok
1551 else
1552 echo 1.err
1553 endif
1554 if $dietcurd =~ '^Yo.*'
1555 echo 1-1.err
1556 else
1557 echo 1-1.ok
1558 endif
1559 if $dietcurd @=~ '^Yo.*'
1560 echo 1-2.ok
1561 else
1562 echo 1-2.err
1563 endif
1564 if $dietcurd =~ '^yOho.+'
1565 echo 2.err
1566 else
1567 echo 2.ok
1568 endif
1569 if $dietcurd @!~ '.*Ho$'
1570 echo 3.err
1571 else
1572 echo 3.ok
1573 endif
1574 if $dietcurd !~ '.+yohO$'
1575 echo 4.ok
1576 else
1577 echo 4.err
1578 endif
1579 if [ $dietcurd @i!~ '.+yoho$' ]
1580 echo 5.ok
1581 else
1582 echo 5.err
1583 endif
1584 if ! [ $dietcurd @i=~ '.+yoho$' ]
1585 echo 6.ok
1586 else
1587 echo 6.err
1588 endif
1589 if ! ! [ $dietcurd @i!~ '.+yoho$' ]
1590 echo 7.ok
1591 else
1592 echo 7.err
1593 endif
1594 if ! [ ! [ $dietcurd @i!~ '.+yoho$' ] ]
1595 echo 8.ok
1596 else
1597 echo 8.err
1598 endif
1599 if [ ! [ ! [ $dietcurd @i!~ '.+yoho$' ] ] ]
1600 echo 9.ok
1601 else
1602 echo 9.err
1603 endif
1604 if ! [ ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
1605 echo 10.err
1606 else
1607 echo 10.ok
1608 endif
1609 if ! ! ! $dietcurd !~ '.+yoho$'
1610 echo 11.err
1611 else
1612 echo 11.ok
1613 endif
1614 if ! ! ! $dietcurd =~ '.+yoho$'
1615 echo 12.ok
1616 else
1617 echo 12.err
1618 endif
1619 if ! [ ! ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
1620 echo 13.ok
1621 else
1622 echo 13.err
1623 endif
1624 set diet=abc curd='^abc$'
1625 if $diet =~ $curd
1626 echo 14.ok
1627 else
1628 echo 14.err
1629 endif
1630 set diet=abc curd='^abcd$'
1631 if $diet !~ $curd
1632 echo 15.ok
1633 else
1634 echo 15.err
1635 endif
1636 __EOT
1638 check regex 0 "${MBOX}" '1115671789 95'
1639 else
1640 printf 'if-regex: unsupported, skipped\n'
1643 t_epilog
1646 t_localopts() {
1647 t_prolog localopts
1649 # Nestable conditions test
1650 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
1651 define t2 {
1652 echo in: t2
1653 set t2=t2
1654 echo $t2
1656 define t1 {
1657 echo in: t1
1658 set gv1=gv1
1659 localopts on
1660 set lv1=lv1 lv2=lv2
1661 set lv3=lv3
1662 call t2
1663 localopts off
1664 set gv2=gv2
1665 echo $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2
1667 define t0 {
1668 echo in: t0
1669 call t1
1670 echo $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2
1671 echo "$gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2"
1673 account trouble {
1674 echo in: trouble
1675 call t0
1677 call t0
1678 unset gv1 gv2
1679 account trouble
1680 echo active trouble: $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t3
1681 account null
1682 echo active null: $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t3
1685 define ll2 {
1686 localopts $1
1687 set x=2
1688 echo ll2=$x
1690 define ll1 {
1691 wysh set y=$1; shift; eval localopts $y; localopts $1; shift
1692 set x=1
1693 echo ll1.1=$x
1694 call ll2 $1
1695 echo ll1.2=$x
1697 define ll0 {
1698 wysh set y=$1; shift; eval localopts $y; localopts $1; shift
1699 set x=0
1700 echo ll0.1=$x
1701 call ll1 $y "$@"
1702 echo ll0.2=$x
1704 define llx {
1705 echo ----- $1: $2 -> $3 -> $4
1706 echo ll-1.1=$x
1707 eval localopts $1
1708 call ll0 "$@"
1709 echo ll-1.2=$x
1710 unset x
1712 define lly {
1713 call llx 'call off' on on on
1714 call llx 'call off' off on on
1715 call llx 'call off' on off on
1716 call llx 'call off' on off off
1717 localopts call-fixate on
1718 call llx 'call-fixate on' on on on
1719 call llx 'call-fixate on' off on on
1720 call llx 'call-fixate on' on off on
1721 call llx 'call-fixate on' on off off
1722 unset x;localopts call on
1723 call llx 'call on' on on on
1724 call llx 'call on' off on on
1725 call llx 'call on' on off on
1726 call llx 'call on' on off off
1728 call lly
1729 __EOT
1731 check 1 0 "${MBOX}" '4016155249 1246'
1733 t_epilog
1736 t_local() {
1737 t_prolog local
1739 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
1740 define du2 {
1741 echo du2-1 du=$du
1742 local set du=$1
1743 echo du2-2 du=$du
1744 local unset du
1745 echo du2-3 du=$du
1747 define du {
1748 local set du=dudu
1749 echo du-1 du=$du
1750 call du2 du2du2
1751 echo du-2 du=$du
1752 local set nodu
1753 echo du-3 du=$du
1755 define ich {
1756 echo ich-1 du=$du
1757 call du
1758 echo ich-2 du=$du
1760 define wir {
1761 localopts $1
1762 set du=wirwir
1763 echo wir-1 du=$du
1764 call ich
1765 echo wir-2 du=$du
1767 echo ------- global-1 du=$du
1768 call ich
1769 echo ------- global-2 du=$du
1770 set du=global
1771 call ich
1772 echo ------- global-3 du=$du
1773 call wir on
1774 echo ------- global-4 du=$du
1775 call wir off
1776 echo ------- global-5 du=$du
1777 __EOT
1779 check 1 0 "${MBOX}" '2411598140 641'
1781 t_epilog
1784 t_macro_param_shift() {
1785 t_prolog macro_param_shift
1787 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>>${ERR}
1788 define t2 {
1789 echo in: t2
1790 echo t2.0 has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1791 localopts on
1792 wysh set ignerr=$1
1793 shift
1794 localopts off
1795 echo t2.1 has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1796 if [ $# > 1 ] || [ $ignerr == '' ]
1797 shift 2
1798 else
1799 ignerr shift 2
1800 endif
1801 echo t2.2:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1802 shift 0
1803 echo t2.3:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1804 if [ $# > 0 ]
1805 shift
1806 endif
1807 echo t2.4:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1809 define t1 {
1810 set errexit
1811 echo in: t1
1812 call t2 1 you get four args
1813 echo t1.1: $?';' ignerr ($ignerr) should not exist
1814 call t2 1 you get 'three args'
1815 echo t1.2: $?';' ignerr ($ignerr) should not exist
1816 call t2 1 you 'get two args'
1817 echo t1.3: $?';' ignerr ($ignerr) should not exist
1818 call t2 1 'you get one arg'
1819 echo t1.4: $?';' ignerr ($ignerr) should not exist
1820 ignerr call t2 '' 'you get one arg'
1821 echo t1.5: $?';' ignerr ($ignerr) should not exist
1823 call t1
1824 __EOT
1826 check 1 0 "${MBOX}" '1402489146 1682'
1828 t_epilog
1831 t_addrcodec() {
1832 t_prolog addrcodec
1834 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
1835 vput addrcodec res e 1 <doog@def>
1836 echo $?/$^ERRNAME $res
1837 eval vput addrcodec res d $res
1838 echo $?/$^ERRNAME $res
1839 vput addrcodec res e 2 . <doog@def>
1840 echo $?/$^ERRNAME $res
1841 eval vput addrcodec res d $res
1842 echo $?/$^ERRNAME $res
1843 vput addrcodec res e 3 Sauer Dr. <doog@def>
1844 echo $?/$^ERRNAME $res
1845 eval vput addrcodec res d $res
1846 echo $?/$^ERRNAME $res
1847 vput addrcodec res e 3.50 Sauer (Ma) Dr. <doog@def>
1848 echo $?/$^ERRNAME $res
1849 eval vput addrcodec res d $res
1850 echo $?/$^ERRNAME $res
1851 vput addrcodec res e 3.51 Sauer (Ma) "Dr." <doog@def>
1852 echo $?/$^ERRNAME $res
1853 eval vput addrcodec res d $res
1854 echo $?/$^ERRNAME $res
1856 vput addrcodec res +e 4 Sauer (Ma) Dr. <doog@def>
1857 echo $?/$^ERRNAME $res
1858 eval vput addrcodec res d $res
1859 echo $?/$^ERRNAME $res
1860 vput addrcodec res +e 5 Sauer (Ma) Braten Dr. <doog@def>
1861 echo $?/$^ERRNAME $res
1862 eval vput addrcodec res d $res
1863 echo $?/$^ERRNAME $res
1864 vput addrcodec res +e 6 Sauer (Ma) Braten Dr. (Heu) <doog@def>
1865 echo $?/$^ERRNAME $res
1866 eval vput addrcodec res d $res
1867 echo $?/$^ERRNAME $res
1868 vput addrcodec res +e 7 Sauer (Ma) Braten Dr. (Heu) <doog@def> (bu)
1869 echo $?/$^ERRNAME $res
1870 eval vput addrcodec res d $res
1871 echo $?/$^ERRNAME $res
1872 vput addrcodec res +e 8 \
1873 Dr. Sauer (Ma) Braten Dr. (Heu) <doog@def> (bu) Boom. Boom
1874 echo $?/$^ERRNAME $res
1875 eval vput addrcodec res d $res
1876 echo $?/$^ERRNAME $res
1877 vput addrcodec res +e 9 Dr.Sauer(Ma)Braten Dr. (Heu) <doog@def>
1878 echo $?/$^ERRNAME $res
1879 eval vput addrcodec res d $res
1880 echo $?/$^ERRNAME $res
1881 vput addrcodec res +e 10 (Ma)Braten Dr. (Heu) <doog@def>
1882 echo $?/$^ERRNAME $res
1883 eval vput addrcodec res d $res
1884 echo $?/$^ERRNAME $res
1885 vput addrcodec res +e 11 (Ma)Braten Dr"." (Heu) <doog@def>
1886 echo $?/$^ERRNAME $res
1887 eval vput addrcodec res d $res
1888 echo $?/$^ERRNAME $res
1889 vput addrcodec res +e 12 Dr. Sauer (Ma) Braten Dr. (u) <doog@def>
1890 echo $?/$^ERRNAME $res
1891 eval vput addrcodec res d $res
1892 echo $?/$^ERRNAME $res
1893 vput addrcodec res +e 13(Ma)Braten Dr. (Heu) <doog@def>
1894 echo $?/$^ERRNAME $res
1895 eval vput addrcodec res d $res
1896 echo $?/$^ERRNAME $res
1897 vput addrcodec res +e 14 Hey, Du <doog@def> Wie() findet Dr. das? ()
1898 echo $?/$^ERRNAME $res
1899 eval vput addrcodec res d $res
1900 echo $?/$^ERRNAME $res
1901 vput addrcodec res +e 15 \
1902 Hey, Du <doog@def> Wie() findet "" Dr. "" das? ()
1903 echo $?/$^ERRNAME $res
1904 eval vput addrcodec res d $res
1905 echo $?/$^ERRNAME $res
1906 vput addrcodec res +e 16 \
1907 "Hey," "Du" <doog@def> "Wie()" findet "" Dr. "" das? ()
1908 echo $?/$^ERRNAME $res
1909 eval vput addrcodec res d $res
1910 echo $?/$^ERRNAME $res
1911 vput addrcodec res +e 17 \
1912 "Hey" Du <doog@def> "Wie() findet " " Dr. """ das? ()
1913 echo $?/$^ERRNAME $res
1914 eval vput addrcodec res d $res
1915 echo $?/$^ERRNAME $res
1916 vput addrcodec res +e 18 \
1917 <doog@def> "Hey" Du "Wie() findet " " Dr. """ das? ()
1918 echo $?/$^ERRNAME $res
1919 eval vput addrcodec res d $res
1920 echo $?/$^ERRNAME $res
1921 vput addrcodec res +e 19 Hey\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1922 echo $?/$^ERRNAME $res
1923 eval vput addrcodec res d $res
1924 echo $?/$^ERRNAME $res
1926 vput addrcodec res ++e 20 Hey\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1927 echo $?/$^ERRNAME $res
1928 vput addrcodec res ++e 21 Hey\,\"" <doog@def> "Wie()" findet \" Dr. \" das?
1929 echo $?/$^ERRNAME $res
1930 eval vput addrcodec res d $res
1931 echo $?/$^ERRNAME $res
1933 vput addrcodec res +++e 22 Hey\\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1934 echo $?/$^ERRNAME $res
1935 eval vput addrcodec res d $res
1936 echo $?/$^ERRNAME $res
1938 vput addrcodec res s \
1939 "23 Hey\\,\\\" \"Wie" () "\" findet \\\" Dr. \\\" das?" <doog@def>
1940 echo $?/$^ERRNAME $res
1942 # Fix for [f3852f88]
1943 vput addrcodec res ++e <from2@exam.ple> 100 (comment) "Quot(e)d"
1944 echo $?/$^ERRNAME $res
1945 eval vput addrcodec res d $res
1946 echo $?/$^ERRNAME $res
1947 vput addrcodec res e <from2@exam.ple> 100 (comment) "Quot(e)d"
1948 echo $?/$^ERRNAME $res
1949 eval vput addrcodec res d $res
1950 echo $?/$^ERRNAME $res
1951 __EOT
1953 check 1 0 "${MBOX}" '1047317989 2612'
1955 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
1956 mlist isa1@list
1957 mlsubscribe isa2@list
1959 vput addrcodec res skin Hey\\,\" <isa0@list> "Wie()" find \" Dr. \" das?
1960 echo $?/$^ERRNAME $res
1961 vput addrcodec res skinlist Hey\\,\" <isa0@list> "Wie()" find \" Dr. \" das?
1962 echo $?/$^ERRNAME $res
1963 vput addrcodec res skin Hey\\,\" <isa1@list> "Wie()" find \" Dr. \" das?
1964 echo $?/$^ERRNAME $res
1965 vput addrcodec res skinlist Hey\\,\" <isa1@list> "Wie()" find \" Dr. \" das?
1966 echo $?/$^ERRNAME $res
1967 vput addrcodec res skin Hey\\,\" <isa2@list> "Wie()" find \" Dr. \" das?
1968 echo $?/$^ERRNAME $res
1969 vput addrcodec res skinlist Hey\\,\" <isa2@list> "Wie()" find \" Dr. \" das?
1970 echo $?/$^ERRNAME $res
1971 __EOT
1973 check 2 0 "${MBOX}" '1391779299 104'
1975 if have_feat idna; then
1976 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} ${ADDARG_UNI} > "${MBOX}" 2>&1
1977 vput addrcodec res e (heu) <du@blödiän> "stroh" du
1978 echo $?/$^ERRNAME $res
1979 eval vput addrcodec res d $res
1980 echo $?/$^ERRNAME $res
1981 vput addrcodec res e <du@blödiän> du
1982 echo $?/$^ERRNAME $res
1983 eval vput addrcodec res d $res
1984 echo $?/$^ERRNAME $res
1985 vput addrcodec res e du <du@blödiän>
1986 echo $?/$^ERRNAME $res
1987 eval vput addrcodec res d $res
1988 echo $?/$^ERRNAME $res
1989 vput addrcodec res e <du@blödiän>
1990 echo $?/$^ERRNAME $res
1991 eval vput addrcodec res d $res
1992 echo $?/$^ERRNAME $res
1993 vput addrcodec res e du@blödiän
1994 echo $?/$^ERRNAME $res
1995 eval vput addrcodec res d $res
1996 echo $?/$^ERRNAME $res
1997 __EOT
1999 check idna 0 "${MBOX}" '498775983 326'
2000 else
2001 printf 'addrcodec-idna: unsupported, skipped\n'
2004 t_epilog
2007 t_vexpr() {
2008 t_prolog vexpr
2010 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>>${ERR}
2011 echo ' #0.0'
2012 vput vexpr res = 9223372036854775807
2013 echo $?/$^ERRNAME $res
2014 vput vexpr res = 9223372036854775808
2015 echo $?/$^ERRNAME $res
2016 vput vexpr res = u9223372036854775808
2017 echo $?/$^ERRNAME $res
2018 vput vexpr res @= 9223372036854775808
2019 echo $?/$^ERRNAME $res
2020 vput vexpr res = -9223372036854775808
2021 echo $?/$^ERRNAME $res
2022 vput vexpr res = -9223372036854775809
2023 echo $?/$^ERRNAME $res
2024 vput vexpr res @= -9223372036854775809
2025 echo $?/$^ERRNAME $res
2026 vput vexpr res = U9223372036854775809
2027 echo $?/$^ERRNAME $res
2028 echo ' #0.1'
2029 vput vexpr res = \
2030 0b0111111111111111111111111111111111111111111111111111111111111111
2031 echo $?/$^ERRNAME $res
2032 vput vexpr res = \
2033 S0b1000000000000000000000000000000000000000000000000000000000000000
2034 echo $?/$^ERRNAME $res
2035 vput vexpr res @= \
2036 S0b1000000000000000000000000000000000000000000000000000000000000000
2037 echo $?/$^ERRNAME $res
2038 vput vexpr res = \
2039 U0b1000000000000000000000000000000000000000000000000000000000000000
2040 echo $?/$^ERRNAME $res
2041 vput vexpr res = \
2042 0b1000000000000000000000000000000000000000000000000000000000000000
2043 echo $?/$^ERRNAME $res
2044 vput vexpr res @= \
2045 0b1000000000000000000000000000000000000000000000000000000000000000
2046 echo $?/$^ERRNAME $res
2047 vput vexpr res = \
2048 -0b1000000000000000000000000000000000000000000000000000000000000000
2049 echo $?/$^ERRNAME $res
2050 vput vexpr res = \
2051 S0b1000000000000000000000000000000000000000000000000000000000000001
2052 echo $?/$^ERRNAME $res
2053 vput vexpr res @= \
2054 S0b1000000000000000000000000000000000000000000000000000000000000001
2055 echo $?/$^ERRNAME $res
2056 vput vexpr res @= \
2057 -0b1000000000000000000000000000000000000000000000000000000000000001
2058 echo $?/$^ERRNAME $res
2059 vput vexpr res = \
2060 U0b1000000000000000000000000000000000000000000000000000000000000001
2061 echo $?/$^ERRNAME $res
2062 echo ' #0.2'
2063 vput vexpr res = 0777777777777777777777
2064 echo $?/$^ERRNAME $res
2065 vput vexpr res = S01000000000000000000000
2066 echo $?/$^ERRNAME $res
2067 vput vexpr res @= S01000000000000000000000
2068 echo $?/$^ERRNAME $res
2069 vput vexpr res = U01000000000000000000000
2070 echo $?/$^ERRNAME $res
2071 vput vexpr res = 01000000000000000000000
2072 echo $?/$^ERRNAME $res
2073 vput vexpr res @= 01000000000000000000000
2074 echo $?/$^ERRNAME $res
2075 vput vexpr res = -01000000000000000000000
2076 echo $?/$^ERRNAME $res
2077 vput vexpr res = S01000000000000000000001
2078 echo $?/$^ERRNAME $res
2079 vput vexpr res @= S01000000000000000000001
2080 echo $?/$^ERRNAME $res
2081 vput vexpr res @= -01000000000000000000001
2082 echo $?/$^ERRNAME $res
2083 vput vexpr res = U01000000000000000000001
2084 echo $?/$^ERRNAME $res
2085 echo ' #0.3'
2086 vput vexpr res = 0x7FFFFFFFFFFFFFFF
2087 echo $?/$^ERRNAME $res
2088 vput vexpr res = S0x8000000000000000
2089 echo $?/$^ERRNAME $res
2090 vput vexpr res @= S0x8000000000000000
2091 echo $?/$^ERRNAME $res
2092 vput vexpr res = U0x8000000000000000
2093 echo $?/$^ERRNAME $res
2094 vput vexpr res = 0x8000000000000000
2095 echo $?/$^ERRNAME $res
2096 vput vexpr res @= 0x8000000000000000
2097 echo $?/$^ERRNAME $res
2098 vput vexpr res = -0x8000000000000000
2099 echo $?/$^ERRNAME $res
2100 vput vexpr res = S0x8000000000000001
2101 echo $?/$^ERRNAME $res
2102 vput vexpr res @= S0x8000000000000001
2103 echo $?/$^ERRNAME $res
2104 vput vexpr res @= -0x8000000000000001
2105 echo $?/$^ERRNAME $res
2106 vput vexpr res = u0x8000000000000001
2107 echo $?/$^ERRNAME $res
2108 echo ' #1'
2109 vput vexpr res ~ 0
2110 echo $?/$^ERRNAME $res
2111 vput vexpr res ~ 1
2112 echo $?/$^ERRNAME $res
2113 vput vexpr res ~ -1
2114 echo $?/$^ERRNAME $res
2115 echo ' #2'
2116 vput vexpr res + 0 0
2117 echo $?/$^ERRNAME $res
2118 vput vexpr res + 0 1
2119 echo $?/$^ERRNAME $res
2120 vput vexpr res + 1 1
2121 echo $?/$^ERRNAME $res
2122 echo ' #3'
2123 vput vexpr res + 9223372036854775807 0
2124 echo $?/$^ERRNAME $res
2125 vput vexpr res + 9223372036854775807 1
2126 echo $?/$^ERRNAME $res
2127 vput vexpr res @+ 9223372036854775807 1
2128 echo $?/$^ERRNAME $res
2129 vput vexpr res + 0 9223372036854775807
2130 echo $?/$^ERRNAME $res
2131 vput vexpr res + 1 9223372036854775807
2132 echo $?/$^ERRNAME $res
2133 vput vexpr res @+ 1 9223372036854775807
2134 echo $?/$^ERRNAME $res
2135 echo ' #4'
2136 vput vexpr res + -9223372036854775808 0
2137 echo $?/$^ERRNAME $res
2138 vput vexpr res + -9223372036854775808 -1
2139 echo $?/$^ERRNAME $res
2140 vput vexpr res @+ -9223372036854775808 -1
2141 echo $?/$^ERRNAME $res
2142 vput vexpr res + 0 -9223372036854775808
2143 echo $?/$^ERRNAME $res
2144 vput vexpr res + -1 -9223372036854775808
2145 echo $?/$^ERRNAME $res
2146 vput vexpr res @+ -1 -9223372036854775808
2147 echo $?/$^ERRNAME $res
2148 echo ' #5'
2149 vput vexpr res - 0 0
2150 echo $?/$^ERRNAME $res
2151 vput vexpr res - 0 1
2152 echo $?/$^ERRNAME $res
2153 vput vexpr res - 1 1
2154 echo $?/$^ERRNAME $res
2155 echo ' #6'
2156 vput vexpr res - 9223372036854775807 0
2157 echo $?/$^ERRNAME $res
2158 vput vexpr res - 9223372036854775807 -1
2159 echo $?/$^ERRNAME $res
2160 vput vexpr res @- 9223372036854775807 -1
2161 echo $?/$^ERRNAME $res
2162 vput vexpr res - 0 9223372036854775807
2163 echo $?/$^ERRNAME $res
2164 vput vexpr res - -1 9223372036854775807
2165 echo $?/$^ERRNAME $res
2166 vput vexpr res - -2 9223372036854775807
2167 echo $?/$^ERRNAME $res
2168 vput vexpr res @- -2 9223372036854775807
2169 echo $?/$^ERRNAME $res
2170 echo ' #7'
2171 vput vexpr res - -9223372036854775808 +0
2172 echo $?/$^ERRNAME $res
2173 vput vexpr res - -9223372036854775808 +1
2174 echo $?/$^ERRNAME $res
2175 vput vexpr res @- -9223372036854775808 +1
2176 echo $?/$^ERRNAME $res
2177 vput vexpr res - 0 -9223372036854775808
2178 echo $?/$^ERRNAME $res
2179 vput vexpr res - +1 -9223372036854775808
2180 echo $?/$^ERRNAME $res
2181 vput vexpr res @- +1 -9223372036854775808
2182 echo $?/$^ERRNAME $res
2183 echo ' #8'
2184 vput vexpr res + -13 -2
2185 echo $?/$^ERRNAME $res
2186 vput vexpr res - 0 0
2187 echo $?/$^ERRNAME $res
2188 vput vexpr res - 0 1
2189 echo $?/$^ERRNAME $res
2190 vput vexpr res - 1 1
2191 echo $?/$^ERRNAME $res
2192 vput vexpr res - -13 -2
2193 echo $?/$^ERRNAME $res
2194 echo ' #9'
2195 vput vexpr res * 0 0
2196 echo $?/$^ERRNAME $res
2197 vput vexpr res * 0 1
2198 echo $?/$^ERRNAME $res
2199 vput vexpr res * 1 1
2200 echo $?/$^ERRNAME $res
2201 vput vexpr res * -13 -2
2202 echo $?/$^ERRNAME $res
2203 echo ' #10'
2204 vput vexpr res / 0 0
2205 echo $?/$^ERRNAME $res
2206 vput vexpr res / 0 1
2207 echo $?/$^ERRNAME $res
2208 vput vexpr res / 1 1
2209 echo $?/$^ERRNAME $res
2210 vput vexpr res / -13 -2
2211 echo $?/$^ERRNAME $res
2212 echo ' #11'
2213 vput vexpr res % 0 0
2214 echo $?/$^ERRNAME $res
2215 vput vexpr res % 0 1
2216 echo $?/$^ERRNAME $res
2217 vput vexpr res % 1 1
2218 echo $?/$^ERRNAME $res
2219 vput vexpr res % -13 -2
2220 echo $?/$^ERRNAME $res
2221 __EOT
2223 check numeric 0 "${MBOX}" '960821755 1962'
2225 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
2226 vput vexpr res find 'bananarama' 'nana'
2227 echo $?/$^ERRNAME :$res:
2228 vput vexpr res find 'bananarama' 'bana'
2229 echo $?/$^ERRNAME :$res:
2230 vput vexpr res find 'bananarama' 'Bana'
2231 echo $?/$^ERRNAME :$res:
2232 vput vexpr res find 'bananarama' 'rama'
2233 echo $?/$^ERRNAME :$res:
2234 echo ' #1'
2235 vput vexpr res ifind 'bananarama' 'nana'
2236 echo $?/$^ERRNAME :$res:
2237 vput vexpr res ifind 'bananarama' 'bana'
2238 echo $?/$^ERRNAME :$res:
2239 vput vexpr res ifind 'bananarama' 'Bana'
2240 echo $?/$^ERRNAME :$res:
2241 vput vexpr res ifind 'bananarama' 'rama'
2242 echo $?/$^ERRNAME :$res:
2243 echo ' #2'
2244 vput vexpr res substring 'bananarama' 1
2245 echo $?/$^ERRNAME :$res:
2246 vput vexpr res substring 'bananarama' 3
2247 echo $?/$^ERRNAME :$res:
2248 vput vexpr res substring 'bananarama' 5
2249 echo $?/$^ERRNAME :$res:
2250 vput vexpr res substring 'bananarama' 7
2251 echo $?/$^ERRNAME :$res:
2252 vput vexpr res substring 'bananarama' 9
2253 echo $?/$^ERRNAME :$res:
2254 vput vexpr res substring 'bananarama' 10
2255 echo $?/$^ERRNAME :$res:
2256 vput vexpr res substring 'bananarama' 1 3
2257 echo $?/$^ERRNAME :$res:
2258 vput vexpr res substring 'bananarama' 3 3
2259 echo $?/$^ERRNAME :$res:
2260 vput vexpr res substring 'bananarama' 5 3
2261 echo $?/$^ERRNAME :$res:
2262 vput vexpr res substring 'bananarama' 7 3
2263 echo $?/$^ERRNAME :$res:
2264 vput vexpr res substring 'bananarama' 9 3
2265 echo $?/$^ERRNAME :$res:
2266 vput vexpr res substring 'bananarama' 10 3
2267 echo $?/$^ERRNAME :$res:
2268 echo ' #3'
2269 vput vexpr res substring 'bananarama' -1
2270 echo $?/$^ERRNAME :$res:
2271 vput vexpr res substring 'bananarama' -3
2272 echo $?/$^ERRNAME :$res:
2273 vput vexpr res substring 'bananarama' -5
2274 echo $?/$^ERRNAME :$res:
2275 vput vexpr res substring 'bananarama' -7
2276 echo $?/$^ERRNAME :$res:
2277 vput vexpr res substring 'bananarama' -9
2278 echo $?/$^ERRNAME :$res:
2279 vput vexpr res substring 'bananarama' -10
2280 echo $?/$^ERRNAME :$res:
2281 vput vexpr res substring 'bananarama' 1 -3
2282 echo $?/$^ERRNAME :$res:
2283 vput vexpr res substring 'bananarama' 3 -3
2284 echo $?/$^ERRNAME :$res:
2285 vput vexpr res substring 'bananarama' 5 -3
2286 echo $?/$^ERRNAME :$res:
2287 vput vexpr res substring 'bananarama' 7 -3
2288 echo $?/$^ERRNAME :$res:
2289 vput vexpr res substring 'bananarama' 9 -3
2290 echo $?/$^ERRNAME :$res:
2291 vput vexpr res substring 'bananarama' 10 -3
2292 echo $?/$^ERRNAME :$res:
2293 echo ' #4'
2294 vput vexpr res trim 'Cocoon Cocoon'
2295 echo $?/$^ERRNAME :$res:
2296 vput vexpr res trim ' Cocoon Cocoon '
2297 echo $?/$^ERRNAME :$res:
2298 vput vexpr res trim-front 'Cocoon Cocoon'
2299 echo $?/$^ERRNAME :$res:
2300 vput vexpr res trim-front ' Cocoon Cocoon '
2301 echo $?/$^ERRNAME :$res:
2302 vput vexpr res trim-end 'Cocoon Cocoon'
2303 echo $?/$^ERRNAME :$res:
2304 vput vexpr res trim-end ' Cocoon Cocoon '
2305 echo $?/$^ERRNAME :$res:
2306 __EOT
2308 check string 0 "${MBOX}" '3182004322 601'
2310 if have_feat regex; then
2311 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
2312 vput vexpr res regex 'bananarama' 'nana'
2313 echo $?/$^ERRNAME :$res:
2314 vput vexpr res regex 'bananarama' 'bana'
2315 echo $?/$^ERRNAME :$res:
2316 vput vexpr res regex 'bananarama' 'Bana'
2317 echo $?/$^ERRNAME :$res:
2318 vput vexpr res regex 'bananarama' 'rama'
2319 echo $?/$^ERRNAME :$res:
2320 echo ' #1'
2321 vput vexpr res iregex 'bananarama' 'nana'
2322 echo $?/$^ERRNAME :$res:
2323 vput vexpr res iregex 'bananarama' 'bana'
2324 echo $?/$^ERRNAME :$res:
2325 vput vexpr res iregex 'bananarama' 'Bana'
2326 echo $?/$^ERRNAME :$res:
2327 vput vexpr res iregex 'bananarama' 'rama'
2328 echo $?/$^ERRNAME :$res:
2329 echo ' #2'
2330 vput vexpr res regex 'bananarama' '(.*)nana(.*)' '\${1}a\${0}u{\$2}'
2331 echo $?/$^ERRNAME :$res:
2332 vput vexpr res regex 'bananarama' '(.*)bana(.*)' '\${1}a\${0}u\$2'
2333 echo $?/$^ERRNAME :$res:
2334 vput vexpr res regex 'bananarama' 'Bana(.+)' '\$1\$0'
2335 echo $?/$^ERRNAME :$res:
2336 vput vexpr res regex 'bananarama' '(.+)rama' '\$1\$0'
2337 echo $?/$^ERRNAME :$res:
2338 echo ' #3'
2339 vput vexpr res iregex 'bananarama' '(.*)nana(.*)' '\${1}a\${0}u{\$2}'
2340 echo $?/$^ERRNAME :$res:
2341 vput vexpr res iregex 'bananarama' '(.*)bana(.*)' '\${1}a\${0}u\$2'
2342 echo $?/$^ERRNAME :$res:
2343 vput vexpr res iregex 'bananarama' 'Bana(.+)' '\$1\$0'
2344 echo $?/$^ERRNAME :$res:
2345 vput vexpr res iregex 'bananarama' '(.+)rama' '\$1\$0'
2346 echo $?/$^ERRNAME :$res:
2347 echo ' #4'
2348 __EOT
2350 check regex 0 "${MBOX}" '3270360157 311'
2351 else
2352 printf 'vexpr-regex: unsupported, skipped\n'
2355 t_epilog
2358 t_call_ret() {
2359 t_prolog call_ret
2361 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Snomemdebug > "${MBOX}" 2>&1
2362 define w1 {
2363 echon ">$1 "
2364 vput vexpr i + $1 1
2365 if [ $i -le 42 ]
2366 vput vexpr j '&' $i 7
2367 if [ $j -eq 7 ]
2368 echo .
2370 call w1 $i
2371 wysh set i=$? k=$!
2372 vput vexpr j '&' $i 7
2373 echon "<$1/$i/$k "
2374 if [ $j -eq 7 ]
2375 echo .
2377 else
2378 echo ! The end for $1
2380 return $1
2382 # Transport $?/$! up the call chain
2383 define w2 {
2384 echon ">$1 "
2385 vput vexpr i + $1 1
2386 if [ $1 -lt 42 ]
2387 call w2 $i
2388 wysh set i=$? j=$! k=$^ERRNAME
2389 echon "<$1/$i/$k "
2390 return $i $j
2391 else
2392 echo ! The end for $1
2393 return $i $^ERR-BUSY
2395 echoerr au
2397 # Up and down it goes
2398 define w3 {
2399 echon ">$1/$2 "
2400 vput vexpr i + $1 1
2401 if [ $1 -lt 42 ]
2402 call w3 $i $2
2403 wysh set i=$? j=$!
2404 vput vexpr k - $1 $2
2405 if [ $k -eq 21 ]
2406 vput vexpr i + $1 1
2407 vput vexpr j + $2 1
2408 echo "# <$i/$j> .. "
2409 call w3 $i $j
2410 wysh set i=$? j=$!
2412 eval echon "<\$1=\$i/\$^ERRNAME-$j "
2413 return $i $j
2414 else
2415 echo ! The end for $1=$i/$2
2416 if [ "$2" != "" ]
2417 return $i $^ERR-DOM
2418 else
2419 return $i $^ERR-BUSY
2422 echoerr au
2425 call w1 0; echo ?=$? !=$!; echo -----;
2426 call w2 0; echo ?=$? !=$^ERRNAME; echo -----;
2427 call w3 0 1; echo ?=$? !=$^ERRNAME; echo -----;
2428 __EOT
2430 check 1 0 "${MBOX}" '1572045517 5922'
2432 t_epilog
2435 t_xcall() {
2436 t_prolog xcall
2438 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Snomemdebug > "${MBOX}" 2>&1
2439 define work {
2440 echon "$1 "
2441 vput vexpr i + $1 1
2442 if [ $i -le 1111 ]
2443 vput vexpr j '&' $i 7
2444 if [ $j -eq 7 ]
2445 echo .
2447 \xcall work $i $2
2449 echo ! The end for $1/$2
2450 if [ "$2" != "" ]
2451 return $i $^ERR-BUSY
2454 define xwork {
2455 \xcall work 0 $2
2457 call work 0
2458 echo ?=$? !=$!
2459 call xwork
2460 echo ?=$? !=$!
2461 xcall xwork
2462 echo ?=$? !=$^ERRNAME
2464 call work 0 yes
2465 echo ?=$? !=$^ERRNAME
2466 call xwork 0 yes
2467 echo ?=$? !=$^ERRNAME
2468 __EOT
2470 check 1 0 "${MBOX}" '2401702082 23801'
2474 if have_feat uistrings; then
2475 ${cat} <<- '__EOT' > "${BODY}"
2476 define __w {
2477 echon "$1 "
2478 vput vexpr i + $1 1
2479 if [ $i -le 111 ]
2480 vput vexpr j '&' $i 7
2481 if [ $j -eq 7 ]
2482 echo .
2484 \xcall __w $i $2
2486 echo ! The end for $1
2487 if [ $2 -eq 0 ]
2488 nonexistingcommand
2489 echo would be err with errexit
2490 return
2492 echo calling exit
2493 exit
2495 define work {
2496 echo eins
2497 call __w 0 0
2498 echo zwei, ?=$? !=$!
2499 localopts yes; set errexit
2500 ignerr call __w 0 0
2501 echo drei, ?=$? !=$^ERRNAME
2502 call __w 0 $1
2503 echo vier, ?=$? !=$^ERRNAME, this is an error
2505 ignerr call work 0
2506 echo outer 1, ?=$? !=$^ERRNAME
2507 xxxign call work 0
2508 echo outer 2, ?=$? !=$^ERRNAME, could be error if xxxign non-empty
2509 call work 1
2510 echo outer 3, ?=$? !=$^ERRNAME
2511 echo this is definitely an error
2512 __EOT
2514 < "${BODY}" ${MAILX} ${ARGS} -X'commandalias xxxign ignerr' \
2515 -Snomemdebug > "${MBOX}" 2>&1
2516 check 2 0 "${MBOX}" '3900716531 4200'
2518 < "${BODY}" ${MAILX} ${ARGS} -X'commandalias xxxign " "' \
2519 -Snomemdebug > "${MBOX}" 2>&1
2520 check 3 1 "${MBOX}" '1006776201 2799'
2521 else
2522 echo 'xcall-2: unsupported, skipped'
2523 echo 'xcall-3: unsupported, skipped'
2526 t_epilog
2529 t_vpospar() {
2530 t_prolog vpospar
2532 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
2533 vpospar set hey, "'you ", world!
2534 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2535 vput vpospar x quote; echo x<$x>
2536 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2537 vput vpospar y quote;echo y<$y>
2538 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2539 eval vpospar set ${y};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2540 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2542 define infun2 {
2543 echo infun2:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2544 vput vpospar z quote;echo infun2:z<$z>
2547 define infun {
2548 echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2549 vput vpospar y quote;echo infun:y<$y>
2550 eval vpospar set ${x};echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2551 vpospar clear;echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2552 eval call infun2 $x
2553 echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2554 eval vpospar set ${y};echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2557 call infun This "in a" fun
2558 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2559 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2560 __EOT
2561 check 1 0 "${MBOX}" '155175639 866'
2564 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
2565 set ifs=\'
2566 echo ifs<$ifs> ifs-ws<$ifs-ws>
2567 vpospar set hey, "'you ", world!
2568 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2569 vput vpospar x quote; echo x<$x>
2570 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2571 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2573 set ifs=,
2574 echo ifs<$ifs> ifs-ws<$ifs-ws>
2575 vpospar set hey, "'you ", world!
2576 unset ifs;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2577 set ifs=,
2578 vput vpospar x quote; echo x<$x>
2579 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2580 eval vpospar set ${x};\
2581 unset ifs;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2583 wysh set ifs=$',\t'
2584 echo ifs<$ifs> ifs-ws<$ifs-ws>
2585 vpospar set hey, "'you ", world!
2586 unset ifs; echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2587 wysh set ifs=$',\t'
2588 vput vpospar x quote; echo x<$x>
2589 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2590 eval vpospar set ${x};\
2591 unset ifs;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2592 __EOT
2593 check ifs 0 "${MBOX}" '2015927702 706'
2595 t_epilog
2598 t_atxplode() {
2599 t_prolog atxplode
2600 TRAP_EXIT_ADDONS="./.t*"
2602 ${cat} > ./.t.sh <<- '___'; ${cat} > ./.t.rc <<- '___'
2603 x() { echo $#; }
2604 xxx() {
2605 printf " (1/$#: <$1>)"
2606 shift
2607 if [ $# -gt 0 ]; then
2608 xxx "$@"
2609 else
2610 echo
2613 yyy() {
2614 eval "$@ ' ball"
2616 set --
2617 x "$@"
2618 x "$@"''
2619 x " $@"
2620 x "$@ "
2621 printf yyy;yyy 'xxx' "b\$'\t'u ' "
2622 printf xxx;xxx arg ,b u.
2623 printf xxx;xxx arg , .
2624 printf xxx;xxx arg ,ball.
2626 define x {
2627 echo $#
2629 define xxx {
2630 echon " (1/$#: <$1>)"
2631 shift
2632 if [ $# -gt 0 ]
2633 \xcall xxx "$@"
2634 endif
2635 echo
2637 define yyy {
2638 eval "$@ ' ball"
2640 vpospar set
2641 call x "$@"
2642 call x "$@"''
2643 call x " $@"
2644 call x "$@ "
2645 echon yyy;call yyy '\call xxx' "b\$'\t'u ' "
2646 echon xxx;call xxx arg ,b u.
2647 echon xxx;call xxx arg , .
2648 echon xxx;call xxx arg ,ball.
2651 ${MAILX} ${ARGS} -X'source ./.t.rc' -Xx > "${MBOX}" 2>&1
2652 check 1 0 "${MBOX}" '41566293 164'
2654 #${SHELL} ./.t.sh > ./.tshout 2>&1
2655 #check disproof-1 0 ./.tshout '41566293 164'
2657 t_epilog
2660 t_read() {
2661 t_prolog read
2662 TRAP_EXIT_ADDONS="./.t*"
2664 ${cat} <<- '__EOT' > .tin
2665 hey1, "'you ", world!
2666 hey2, "'you ", bugs bunny!
2667 hey3, "'you ",
2668 hey4, "'you "
2669 __EOT
2671 ${cat} <<- '__EOT' |\
2672 ${MAILX} ${ARGS} -X'readctl create ./.tin' > "${MBOX}" 2>&1
2673 read a b c
2674 echo $?/$^ERRNAME / <$a><$b><$c>
2675 read a b c
2676 echo $?/$^ERRNAME / <$a><$b><$c>
2677 read a b c
2678 echo $?/$^ERRNAME / <$a><$b><$c>
2679 read a b c
2680 echo $?/$^ERRNAME / <$a><$b><$c>
2681 unset a b c;read a b c
2682 echo $?/$^ERRNAME / <$a><$b><$c>
2683 readctl remove ./.tin;echo readctl remove:$?/$^ERRNAME
2684 __EOT
2685 check 1 0 "${MBOX}" '1527910147 173'
2687 ${cat} <<- '__EOT' > .tin2
2688 hey2.0,:"'you ",:world!:mars.:
2689 hey2.1,:"'you ",:world!
2690 hey2.2,:"'you ",:bugs bunny!
2691 hey2.3,:"'you ",:
2692 hey2.4,:"'you ":
2694 __EOT
2696 ${cat} <<- '__EOT' |\
2697 6< .tin2 ${MAILX} ${ARGS} -X 'readctl create 6' > "${MBOX}" 2>&1
2698 set ifs=:
2699 read a b c
2700 echo $?/$^ERRNAME / <$a><$b><$c>
2701 read a b c
2702 echo $?/$^ERRNAME / <$a><$b><$c>
2703 read a b c
2704 echo $?/$^ERRNAME / <$a><$b><$c>
2705 read a b c
2706 echo $?/$^ERRNAME / <$a><$b><$c>
2707 read a b c
2708 echo $?/$^ERRNAME / <$a><$b><$c>
2709 read a b c
2710 echo $?/$^ERRNAME / <$a><$b><$c>
2711 unset a b c;read a b c
2712 echo $?/$^ERRNAME / <$a><$b><$c>
2713 read a b c
2714 echo $?/$^ERRNAME / <$a><$b><$c>
2715 readctl remove 6;echo readctl remove:$?/$^ERRNAME
2716 __EOT
2717 check ifs 0 "${MBOX}" '890153490 298'
2719 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
2720 readctl create .tin
2721 readall d; echo $?/$^ERRNAME / <$d>
2722 wysh set d;readall d;echo $?/$^ERRNAME / <$d>
2723 readctl create .tin2
2724 readall d; echo $?/$^ERRNAME / <$d>
2725 wysh set d;readall d;echo $?/$^ERRNAME / <$d>
2726 readctl remove .tin;echo $?/$^ERRNAME;\
2727 readctl remove .tin2;echo $?/$^ERRNAME
2728 echo '### now with empty lines'
2729 ! printf 'one line\n\ntwo line\n\n' > ./.temptynl
2730 readctl create .temptynl;echo $?/$^ERRNAME
2731 readall d; echo "$?/$^ERRNAME / <$d>"
2732 readctl remove .temptynl;echo $?/$^ERRNAME
2733 __EOT
2734 check readall 0 "${MBOX}" '4113506527 405'
2736 t_epilog
2738 # }}}
2740 # VFS {{{
2741 t_mbox() {
2742 t_prolog mbox
2743 TRAP_EXIT_ADDONS="./.t*"
2747 while [ ${i} -lt 113 ]; do
2748 printf 'm file://%s\n~s Subject %s\nHello %s!\n~.\n' \
2749 "${MBOX}" "${i}" "${i}"
2750 i=`add ${i} 1`
2751 done
2752 ) | ${MAILX} ${ARGS} > .tall 2>&1
2753 check 1 0 "${MBOX}" '1785801373 13336'
2754 check 1-outerr - ./.tall '4294967295 0' # empty file
2756 printf 'File "%s"\ncopy * "%s"\nFile "%s"\nfrom*' "${MBOX}" .tmbox1 .tmbox1 |
2757 ${MAILX} ${ARGS} -Sshowlast > .tall 2>&1
2758 check 2 0 .tall '3075634057 9103'
2760 printf 'File "%s"\ncopy * "file://%s"\nFile "file://%s"\nfrom*' \
2761 "${MBOX}" .tmbox2 .tmbox2 | ${MAILX} ${ARGS} -Sshowlast > .tall 2>&1
2762 check 3 0 .tall '1902668747 9110'
2764 # copy only the odd (but the first), move the even
2766 printf 'File "file://%s"\ncopy ' .tmbox2
2768 while [ ${i} -lt 113 ]; do
2769 printf '%s ' "${i}"
2770 i=`add ${i} 2`
2771 done
2772 printf 'file://%s\nFile "file://%s"\nfrom*' .tmbox3 .tmbox3
2773 ) | ${MAILX} ${ARGS} -Sshowlast > .tall 2>&1
2774 check 4 0 .tmbox3 '2554734733 6666'
2775 check 5 - .tall '3168324241 4573'
2776 # ...
2778 printf 'file "file://%s"\nmove ' .tmbox2
2780 while [ ${i} -lt 113 ]; do
2781 printf '%s ' "${i}"
2782 i=`add ${i} 2`
2783 done
2784 printf 'file://%s\nFile "file://%s"\nfrom*\nFile "file://%s"\nfrom*' \
2785 .tmbox3 .tmbox3 .tmbox2
2786 ) | ${MAILX} ${ARGS} -Sshowlast > .tall 2>>${ERR}
2787 check 6 0 .tmbox3 '1429216753 13336'
2788 if have_feat uistrings; then
2789 ${sed} 2d < .tall > .tallx
2790 else
2791 ${cp} .tall .tallx
2793 check 7 - .tallx '3604509039 13645'
2795 # Invalid MBOXes (after [f4db93b3])
2796 echo > .tinvmbox
2797 printf 'copy 1 ./.tinvmbox' | ${MAILX} ${ARGS} -Rf "${MBOX}" > .tall 2>&1
2798 check 8 0 .tinvmbox '2848412822 118'
2799 check 9 - ./.tall '461280182 33'
2801 echo ' ' > .tinvmbox
2802 printf 'copy 1 ./.tinvmbox' | ${MAILX} ${ARGS} -Rf "${MBOX}" > .tall 2>&1
2803 check 10 0 .tinvmbox '624770486 120'
2804 check 11 - ./.tall '461280182 33'
2806 { echo; echo; } > .tinvmbox # (not invalid)
2807 printf 'copy 1 ./.tinvmbox' | ${MAILX} ${ARGS} -Rf "${MBOX}" > .tall 2>&1
2808 check 12 0 .tinvmbox '1485640875 119'
2809 check 13 - ./.tall '461280182 33'
2811 # *mbox-rfc4155*, plus
2812 ${cat} <<-_EOT > ./.tinv1
2815 From MAILER-DAEMON-1 Wed Oct 2 01:50:07 1996
2816 Date: Wed, 02 Oct 1996 01:50:07 +0000
2818 Subject: Bad bad message 1
2820 From me to you, blinde Kuh!
2822 From MAILER-DAEMON-2 Wed Oct 2 01:50:07 1996
2823 Date: Wed, 02 Oct 1996 01:50:07 +0000
2825 Subject: Bad bad message 2
2827 From me to you, blindes Kalb!
2828 _EOT
2829 ${cp} ./.tinv1 ./.tinv2
2831 printf \
2832 'define mboxfix {
2833 \\localopts yes; \\wysh set mbox-rfc4155;\\wysh File "${1}";\\
2834 \\eval copy * "${2}"
2836 call mboxfix ./.tinv1 ./.tok' | ${MAILX} ${ARGS} > .tall 2>&1
2837 check_ex0 14-estat
2838 ${cat} ./.tinv1 ./.tok >> .tall
2839 check 14 - ./.tall '739301109 616'
2841 printf \
2842 'wysh file ./.tinv1 # ^From not repaired, but missing trailing NL is
2843 wysh File ./.tok # Just move away to nowhere
2844 set mbox-rfc4155
2845 wysh file ./.tinv2 # Fully repaired
2846 File ./.tok' | ${MAILX} ${ARGS} >>${ERR} 2>&1
2847 check_ex0 15-estat
2848 check 15-1 - ./.tinv1 '3178048820 332'
2849 check 15-2 - ./.tinv2 '4151504442 314'
2851 t_epilog
2854 t_maildir() {
2855 t_prolog maildir
2856 if have_feat maildir; then :; else
2857 echo 'maildir: unsupported, skipped'
2858 return
2861 TRAP_EXIT_ADDONS="./.t*"
2865 while [ ${i} -lt 112 ]; do
2866 printf 'm file://%s\n~s Subject %s\nHello %s!\n~.\n' \
2867 "${MBOX}" "${i}" "${i}"
2868 i=`add ${i} 1`
2869 done
2870 ) | ${MAILX} ${ARGS}
2871 check 1 0 "${MBOX}" '2366902811 13332'
2873 printf 'File "%s"
2874 copy * "%s"
2875 File "%s"
2876 from*
2877 ' "${MBOX}" .tmdir1 .tmdir1 |
2878 ${MAILX} ${ARGS} -Snewfolders=maildir -Sshowlast > .tlst
2879 check 2 0 .tlst '1713783045 9103'
2881 printf 'File "%s"
2882 copy * "maildir://%s"
2883 File "maildir://%s"
2884 from*
2885 ' "${MBOX}" .tmdir2 .tmdir2 |
2886 ${MAILX} ${ARGS} -Sshowlast > .tlst
2887 check 3 0 .tlst '1240307893 9113'
2889 printf 'File "maildir://%s"
2890 copy * "file://%s"
2891 File "file://%s"
2892 from*
2893 ' .tmdir2 .tmbox1 .tmbox1 |
2894 ${MAILX} ${ARGS} -Sshowlast > .tlst
2895 check 4 0 .tmbox1 '4096198846 12772'
2896 check 5 - .tlst '817337448 9110'
2898 # only the odd (even)
2900 printf 'File "maildir://%s"
2901 copy ' .tmdir2
2903 while [ ${i} -lt 112 ]; do
2904 j=`modulo ${i} 2`
2905 [ ${j} -eq 1 ] && printf '%s ' "${i}"
2906 i=`add ${i} 1`
2907 done
2908 printf ' file://%s
2909 File "file://%s"
2910 from*
2911 ' .tmbox2 .tmbox2
2912 ) | ${MAILX} ${ARGS} -Sshowlast > .tlst
2913 check 6 0 .tmbox2 '4228337024 6386'
2914 check 7 - .tlst '884389294 4573'
2915 # ...
2917 printf 'file "maildir://%s"
2918 move ' .tmdir2
2920 while [ ${i} -lt 112 ]; do
2921 j=`modulo ${i} 2`
2922 [ ${j} -eq 0 ] && [ ${i} -ne 0 ] && printf '%s ' "${i}"
2923 i=`add ${i} 1`
2924 done
2925 printf ' file://%s
2926 File "file://%s"
2927 from*
2928 File "maildir://%s"
2929 from*
2930 ' .tmbox2 .tmbox2 .tmdir2
2931 ) | ${MAILX} ${ARGS} -Sshowlast > .tlst
2932 check 8 0 .tmbox2 '978751761 12656'
2933 ${sed} 2d < .tlst > .tlstx
2934 check 9 - .tlstx '2391942957 13645'
2936 t_epilog
2938 # }}}
2940 # MIME and RFC basics {{{
2941 t_mime_if_not_ascii() {
2942 t_prolog mime_if_not_ascii
2944 </dev/null ${MAILX} ${ARGS} -s Subject "${MBOX}" >> "${MBOX}" 2>&1
2945 check 1 0 "${MBOX}" '3647956381 106'
2947 </dev/null ${MAILX} ${ARGS} -Scharset-7bit=not-ascii -s Subject "${MBOX}" \
2948 >> "${MBOX}" 2>&1
2949 check 2 0 "${MBOX}" '3964303752 274'
2951 t_epilog
2954 t_xxxheads_rfc2047() {
2955 t_prolog xxxheads_rfc2047
2956 TRAP_EXIT_ADDONS="./.t*"
2958 t_xmta 'GentianaLutea Mon Dec 04 17:15:29 2017'
2960 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
2961 -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̲' \
2962 "${MBOX}"
2963 check 1 0 "${MBOX}" '3422562347 371'
2965 # Single word (overlong line split -- bad standard! Requires injection of
2966 # artificial data!! But can be prevented by using RFC 2047 encoding)
2967 ${rm} "${MBOX}"
2968 i=`${awk} 'BEGIN{for(i=0; i<92; ++i) printf "0123456789_"}'`
2969 echo | ${MAILX} ${ARGS} -s "${i}" "${MBOX}"
2970 check 2 0 "${MBOX}" '3317256266 1714'
2972 # Combination of encoded words, space and tabs of varying sort
2973 ${rm} "${MBOX}"
2974 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
2975 -s "1Abrä Kaspas1 2Abra Katä b_kaspas2 \
2976 3Abrä Kaspas3 4Abrä Kaspas4 5Abrä Kaspas5 \
2977 6Abra Kaspas6 7Abrä Kaspas7 8Abra Kaspas8 \
2978 9Abra Kaspastäb4-3 10Abra Kaspas1 _ 11Abra Katäb1 \
2979 12Abra Kadabrä1 After Tab after Täb this is NUTS" \
2980 "${MBOX}"
2981 check 3 0 "${MBOX}" '786672837 587'
2983 # Overlong multibyte sequence that must be forcefully split
2984 # todo This works even before v15.0, but only by accident
2985 ${rm} "${MBOX}"
2986 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
2987 -s "✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
2988 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
2989 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄" \
2990 "${MBOX}"
2991 check 4 0 "${MBOX}" '2889557767 655'
2993 # Trailing WS
2994 ${rm} "${MBOX}"
2995 echo | ${MAILX} ${ARGS} \
2996 -s "1-1 B2 B3 B4 B5 B6 B\
2997 1-2 B2 B3 B4 B5 B6 B\
2998 1-3 B2 B3 B4 B5 B6 B\
2999 1-4 B2 B3 B4 B5 B6 B\
3000 1-5 B2 B3 B4 B5 B6 B\
3001 1-6 B2 B3 B4 B5 B6 " \
3002 "${MBOX}"
3003 check 5 0 "${MBOX}" '3135161683 293'
3005 # Leading and trailing WS
3006 ${rm} "${MBOX}"
3007 echo | ${MAILX} ${ARGS} \
3008 -s " 2-1 B2 B3 B4 B5 B6 B\
3009 1-2 B2 B3 B4 B5 B6 B\
3010 1-3 B2 B3 B4 B5 B6 B\
3011 1-4 B2 B3 B4 B5 B6 " \
3012 "${MBOX}"
3013 check 6 0 "${MBOX}" '3221845405 232'
3015 # RFC 2047 in an address field! (Missing test caused v14.9.6!)
3016 ${rm} "${MBOX}"
3017 echo "Dat Früchtchen riecht häußlich" |
3018 ${MAILX} ${ARGS} ${ADDARG_UNI} -Sfullnames -Smta=./.tmta.sh \
3019 -s Hühöttchen \
3020 'Schnödes "Früchtchen" <do@du> (Hä!)'
3021 check 7 0 "${MBOX}" '800505986 368'
3023 # RFC 2047 in an address field, and iconv involved
3024 if have_feat iconv; then
3025 ${rm} "${MBOX}"
3026 ${cat} > ./.trebox <<_EOT
3027 From zaza@exam.ple Fri Mar 2 21:31:56 2018
3028 Date: Fri, 2 Mar 2018 20:31:45 +0000
3029 From: z=?iso-8859-1?Q?=E1?=za <zaza@exam.ple>
3030 To: dude <dude@exam.ple>
3031 Subject: houston(...)
3032 Message-ID: <abra@1>
3033 MIME-Version: 1.0
3034 Content-Type: text/plain; charset=iso-8859-1
3035 Content-Disposition: inline
3036 Content-Transfer-Encoding: 8bit
3038 _EOT
3039 echo reply | ${MAILX} ${ARGS} ${ADDARG_UNI} \
3040 -Sfullnames -Sreply-in-same-charset \
3041 -Smta=./.tmta.sh -Rf ./.trebox
3042 check 8 0 "${MBOX}" '2914485741 280'
3043 else
3044 echo 'xxxheads_rfc2047-8: iconv unsupported, skipped'
3047 t_epilog
3050 t_iconv_mbyte_base64() { # TODO uses sed(1) and special *headline*!!
3051 t_prolog iconv_mbyte_base64
3052 TRAP_EXIT_ADDONS="./.t*"
3054 if [ -n "${UTF8_LOCALE}" ] && have_feat iconv; then
3055 if (</dev/null iconv -f ascii -t iso-2022-jp) >/dev/null 2>&1 ||
3056 (</dev/null iconv -f ascii -t euc-jp) >/dev/null 2>&1; then
3058 else
3059 echo 'iconv_mbyte_base64: unsupported, skipped'
3060 return
3062 else
3063 echo 'iconv_mbyte_base64: unsupported, skipped'
3064 return
3067 t_xmta 'DroseriaRotundifolia Thu Aug 03 17:26:25 2017'
3069 if (</dev/null iconv -f ascii -t iso-2022-jp) >/dev/null 2>&1; then
3070 ${cat} <<-'_EOT' | LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} \
3071 -Smta=./.tmta.sh \
3072 -Sescape=! -Smime-encoding=base64 2>./.terr
3073 set ttycharset=utf-8 sendcharsets=iso-2022-jp
3074 m t1@exam.ple
3075 !s Japanese from UTF-8 to ISO-2022-JP
3076 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
3078 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
3081 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
3083 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
3086 set ttycharset=iso-2022-jp charset-7bit=iso-2022-jp sendcharsets=utf-8
3087 m t2@exam.ple
3088 !s Japanese from ISO-2022-JP to UTF-8, eh, no, also ISO-2022-JP
3089 \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
3091 \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
3094 \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
3096 \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
3098 _EOT
3099 # May not presume iconv output as long as roundtrip possible [489a7122]
3100 check_ex0 1-estat
3101 ${awk} 'BEGIN{h=1}/^$/{++h;next}{if(h % 2 == 1)print}' \
3102 < "${MBOX}" > ./.tcksum
3103 check 1 - ./.tcksum '2694609714 520'
3104 check 2 - ./.terr '4294967295 0'
3106 printf 'eval f 1; eval write ./.twrite; eval type 1; eval type 2\n' |
3107 LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} \
3108 -S headline="%>%a%m %-18f %-16d %i%-s" \
3109 -Rf "${MBOX}" >./.tlog 2>&1
3110 check 3 0 ./.twrite '1259742080 686'
3111 #check 4 - ./.tlog '3214068822 2123'
3112 ${sed} -e '/^\[-- M/d' < ./.tlog > ./.txlog
3113 check 4 - ./.txlog '3659773472 2035'
3114 else
3115 echo 'iconv_mbyte_base64: ISO-2022-JP unsupported, skipping 1-4'
3118 if (</dev/null iconv -f ascii -t euc-jp) >/dev/null 2>&1; then
3119 rm -f "${MBOX}" ./.twrite
3120 ${cat} <<-'_EOT' | LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} \
3121 -Smta=./.tmta.sh \
3122 -Sescape=! -Smime-encoding=base64 2>./.terr
3123 set ttycharset=utf-8 sendcharsets=euc-jp
3124 m t1@exam.ple
3125 !s Japanese from UTF-8 to EUC-JP
3126 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
3128 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
3131 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
3133 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
3136 set ttycharset=EUC-JP sendcharsets=utf-8
3137 m t2@exam.ple
3138 !s Japanese from EUC-JP to UTF-8
3139 ¥·¥¸¥å¥¦¥«¥é²Ê¡Ê¥·¥¸¥å¥¦¥«¥é¤«¡¢³Ø̾ Paridae¡Ë¤Ï¡¢Ä»Îॹ¥º¥áÌܤβʤǤ¢¤ë¡£¥·¥¸¥å¥¦¥«¥é¡Ê»Í½½¿ý¡Ë¤ÈÁí¾Î¤µ¤ì¤ë¤¬¡¢¶¹µÁ¤Ë¤Ï¤³¤Î1¼ï¤ò¥·¥¸¥å¥¦¥«¥é¤È¸Æ¤Ö¡£
3141 ¥«¥ó¥à¥ê¥¬¥é¡Ê³Ø̾Parus cristatus¡Ë¤Ï¡¢¥¹¥º¥áÌÜ¥·¥¸¥å¥¦¥«¥é²Ê¤ËʬÎव¤ì¤ëÄ»Îà¤Î°ì¼ï¡£
3144 ¥«¥ó¥à¥ê¥¬¥é¡Ê³Ø̾Parus cristatus¡Ë¤Ï¡¢¥¹¥º¥áÌÜ¥·¥¸¥å¥¦¥«¥é²Ê¤ËʬÎव¤ì¤ëÄ»Îà¤Î°ì¼ï¡£
3146 ¥·¥¸¥å¥¦¥«¥é²Ê¡Ê¥·¥¸¥å¥¦¥«¥é¤«¡¢³Ø̾ Paridae¡Ë¤Ï¡¢Ä»Îॹ¥º¥áÌܤβʤǤ¢¤ë¡£¥·¥¸¥å¥¦¥«¥é¡Ê»Í½½¿ý¡Ë¤ÈÁí¾Î¤µ¤ì¤ë¤¬¡¢¶¹µÁ¤Ë¤Ï¤³¤Î1¼ï¤ò¥·¥¸¥å¥¦¥«¥é¤È¸Æ¤Ö¡£
3148 _EOT
3149 check_ex0 5-estat
3150 ${awk} 'BEGIN{h=1}/^$/{++h;next}{if(h % 2 == 1)print}' \
3151 < "${MBOX}" > ./.tcksum
3152 check 5 - ./.tcksum '2870183985 473'
3153 check 6 - ./.terr '4294967295 0'
3155 printf 'eval f 1; eval write ./.twrite; eval type 1; eval type 2\n' |
3156 LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} \
3157 -S headline="%>%a%m %-18f %-16d %i%-s" \
3158 -Rf "${MBOX}" >./.tlog 2>&1
3159 check 7 0 ./.twrite '1259742080 686'
3160 #check 8 - ./.tlog '2506063395 2075'
3161 ${sed} -e '/^\[-- M/d' < ./.tlog > ./.txlog
3162 check 8 - ./.txlog '2528199891 1988'
3163 else
3164 echo 'iconv_mbyte_base64: EUC-JP unsupported, skipping 5-8'
3167 t_epilog
3170 t_iconv_mainbody() {
3171 t_prolog iconv_mainbody
3172 TRAP_EXIT_ADDONS="./.t*"
3174 if [ -n "${UTF8_LOCALE}" ] && have_feat iconv; then
3176 else
3177 echo 'iconv_mainbody: unsupported, skipped'
3178 return
3181 t_xmta 'HamamelisVirginiana Fri Oct 20 16:23:21 2017'
3183 printf '–' | ${MAILX} ${ARGS} ${ADDARG_UNI} -Smta=./.tmta.sh \
3184 -S charset-7bit=us-ascii -S charset-8bit=utf-8 \
3185 -s '–' over-the@rain.bow 2>./.terr
3186 check 1 0 "${MBOX}" '3634015017 251'
3187 check 2 - ./.terr '4294967295 0'
3189 printf '–' | ${MAILX} ${ARGS} ${ADDARG_UNI} -Smta=./.tmta.sh \
3190 -S charset-7bit=us-ascii -S charset-8bit=us-ascii \
3191 -s '–' over-the@rain.bow 2>./.terr
3192 check_exn0 3
3193 check 3 - "${MBOX}" '3634015017 251'
3194 if have_feat uistrings; then
3195 if have_feat docstrings; then # xxx should not be like that
3196 check 4 - ./.terr '2579894983 148'
3197 else
3198 check 4 - ./.terr '271380835 121'
3200 else
3201 echo 'iconv_mainbody-4: unsupported, skipped'
3204 # The different iconv(3) implementations use different replacement sequence
3205 # types (character-wise, byte-wise, and the character(s) used differ)
3206 i="${MAILX_ICONV_MODE}"
3207 if [ -n "${i}" ]; then
3208 printf 'p\nx\n' | ${MAILX} ${ARGS} -Rf "${MBOX}" >./.tout 2>./.terr
3209 j=${?}
3210 check_ex0 5-1-estat ${j}
3211 check 5-1 - ./.terr '4294967295 0'
3212 if [ ${i} -eq 13 ]; then
3213 check 5-2 - ./.tout '189327996 283'
3214 elif [ ${i} -eq 12 ]; then
3215 check 5-3 - ./.tout '1959197095 283'
3216 elif [ ${i} -eq 3 ]; then
3217 check 5-4 - ./.tout '3196380198 279'
3218 else
3219 check 5-5 - ./.tout '3760313827 279'
3221 else
3222 echo 'iconv_mainbody-5: unsupported, skipped'
3225 t_epilog
3228 t_binary_mainbody() {
3229 t_prolog binary_mainbody
3230 TRAP_EXIT_ADDONS="./.t*"
3232 printf 'abra\0\nka\r\ndabra' |
3233 ${MAILX} ${ARGS} ${ADDARG_UNI} -s 'binary with carriage-return!' \
3234 "${MBOX}" 2>./.terr
3235 check 1 0 "${MBOX}" '1629827 239'
3236 check 2 - ./.terr '4294967295 0'
3238 printf 'p\necho\necho writing now\nwrite ./.twrite\n' |
3239 ${MAILX} ${ARGS} -Rf \
3240 -Spipe-application/octet-stream="@* ${cat} > ./.tcat" \
3241 "${MBOX}" >./.tall 2>&1
3242 check 3 0 ./.tall '733582513 319'
3243 check 4 - ./.tcat '3817108933 15'
3244 check 5 - ./.twrite '3817108933 15'
3246 t_epilog
3249 t_C_opt_customhdr() {
3250 t_prolog C_opt_customhdr
3251 TRAP_EXIT_ADDONS="./.t*"
3253 t_xmta 'CimicifugaRacemosa Mon Dec 25 21:33:40 2017'
3255 echo bla |
3256 ${MAILX} ${ARGS} -Smta=./.tmta.sh \
3257 -C 'C-One : Custom One Body' \
3258 -C 'C-Two:CustomTwoBody' \
3259 -S customhdr='chdr1: chdr1 body, chdr2:chdr2 body' \
3260 this-goes@nowhere >./.tall 2>&1
3261 check_ex0 1-estat
3262 ${cat} ./.tall >> "${MBOX}"
3263 check 1 0 "${MBOX}" '2400078426 195'
3265 ${rm} "${MBOX}"
3266 printf 'm this-goes@nowhere\nbody\n!.
3267 unset customhdr
3268 m this-goes2@nowhere\nbody2\n!.
3269 set customhdr=%ccustom1 : custom1 body%c
3270 m this-goes2@nowhere\nbody2\n!.
3271 set customhdr=%ccustom1 : custom1\\, body , custom2: custom2 body%c
3272 m this-goes3@nowhere\nbody3\n!.
3273 ' "'" "'" "'" "'" |
3274 ${MAILX} ${ARGS} -Smta=./.tmta.sh -Sescape=! \
3275 -C 'C-One : Custom One Body' \
3276 -C 'C-Two:CustomTwoBody' \
3277 -S customhdr='chdr1: chdr1 body, chdr2:chdr2 body' \
3278 >./.tall 2>&1
3279 check_ex0 2-estat
3280 ${cat} ./.tall >> "${MBOX}"
3281 check 2 0 "${MBOX}" '3546878678 752'
3283 t_epilog
3285 # }}}
3287 # Operational basics with easy tests {{{
3288 t_alias() {
3289 t_prolog alias
3290 TRAP_EXIT_ADDONS="./.t*"
3292 t_xmta 'Hippocastanum Mon Jun 19 15:07:07 2017'
3294 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Smta=./.tmta.sh > ./.tall 2>&1
3295 alias a1 ex1@a1.ple
3296 alias a1 ex2@a1.ple "EX3 <ex3@a1.ple>"
3297 alias a1 ex4@a1.ple
3298 alias a2 ex1@a2.ple ex2@a2.ple ex3@a2.ple ex4@a2.ple
3299 alias a3 a4
3300 alias a4 a5 ex1@a4.ple
3301 alias a5 a6
3302 alias a6 a7 ex1@a6.ple
3303 alias a7 a8
3304 alias a8 ex1@a8.ple
3305 alias a1
3306 alias a2
3307 alias a3
3308 m a1
3309 ~c a2
3310 ~b a3
3311 ~r - '_EOT'
3312 This body is!
3313 This also body is!!
3314 _EOT
3315 __EOT
3316 check 1 0 "${MBOX}" '2496925843 272'
3317 check 2 - .tall '3548953204 152'
3319 # TODO t_alias: n_ALIAS_MAXEXP is compile-time constant,
3320 # TODO need to somehow provide its contents to the test, then test
3322 t_epilog
3325 t_filetype() {
3326 t_prolog filetype
3327 TRAP_EXIT_ADDONS="./.t*"
3329 t_xmta 'Alchemilla Wed Apr 25 15:12:13 2017'
3331 printf 'm m1@e.t\nL1\nHy1\n~.\nm m2@e.t\nL2\nHy2\n~@ %s\n~.\n' \
3332 "${SRCDIR}snailmail.jpg" | ${MAILX} ${ARGS} -Smta=./.tmta.sh
3333 check 1 0 "${MBOX}" '1594682963 13520'
3335 if (echo | gzip -c) >/dev/null 2>&1; then
3337 printf 'File "%s"\ncopy 1 ./.t.mbox.gz\ncopy 2 ./.t.mbox.gz' \
3338 "${MBOX}" | ${MAILX} ${ARGS} \
3339 -X'filetype gz gzip\ -dc gzip\ -c'
3340 printf 'File ./.t.mbox.gz\ncopy * ./.t.mbox\n' |
3341 ${MAILX} ${ARGS} -X'filetype gz gzip\ -dc gzip\ -c'
3342 } > ./.t.out 2>&1
3343 check 2 - "./.t.mbox" '1594682963 13520'
3344 check 3 - "./.t.out" '2392348396 102'
3345 else
3346 echo 'filetype-2: unsupported, skipped'
3347 echo 'filetype-3: unsupported, skipped'
3351 ${rm} ./.t.mbox*
3352 printf 'File "%s"\ncopy 1 ./.t.mbox.gz
3353 copy 2 ./.t.mbox.gz
3354 copy 1 ./.t.mbox.gz
3355 copy 2 ./.t.mbox.gz
3356 ' "${MBOX}" |
3357 ${MAILX} ${ARGS} \
3358 -X'filetype gz gzip\ -dc gzip\ -c' \
3359 -X'filetype mbox.gz "${sed} 1,3d|${cat}" \
3360 "echo eins;echo zwei;echo und mit ${sed} bist Du dabei;${cat}"'
3361 printf 'File ./.t.mbox.gz\ncopy * ./.t.mbox\n' |
3362 ${MAILX} ${ARGS} \
3363 -X'filetype gz gzip\ -dc gzip\ -c' \
3364 -X'filetype mbox.gz "${sed} 1,3d|${cat}" kill\ 0'
3365 } > ./.t.out 2>&1
3366 check 4 - "./.t.mbox" '2886541147 27060'
3367 check 5 - "./.t.out" '852335377 172'
3369 t_epilog
3372 t_record_a_resend() {
3373 t_prolog record_a_resend
3374 TRAP_EXIT_ADDONS="./.t.record ./.t.resent"
3376 printf '
3377 set record=%s
3378 m %s\n~s Subject 1.\nHello.\n~.
3379 set record-files add-file-recipients
3380 m %s\n~s Subject 2.\nHello.\n~.
3381 File %s
3382 resend 2 ./.t.resent
3383 Resend 1 ./.t.resent
3384 set record-resent
3385 resend 2 ./.t.resent
3386 Resend 1 ./.t.resent
3387 ' ./.t.record "${MBOX}" "${MBOX}" "${MBOX}" |
3388 ${MAILX} ${ARGS}
3390 check 1 0 "${MBOX}" '2632690399 252'
3391 check 2 - .t.record '3337485450 456'
3392 check 3 - .t.resent '1560890069 640'
3394 t_epilog
3397 t_e_H_L_opts() {
3398 t_prolog e_H_L_opts
3399 TRAP_EXIT_ADDONS="./.tmta.sh ./.t.mbox"
3401 t_xmta 'Alchemilla Wed Apr 07 17:03:33 2017' ./.t.mbox
3403 touch ./.t.mbox
3404 ${MAILX} ${ARGS} -ef ./.t.mbox
3405 echo ${?} > "${MBOX}"
3407 printf 'm me@exam.ple\nLine 1.\nHello.\n~.\n' |
3408 ${MAILX} ${ARGS} -Smta=./.tmta.sh
3409 printf 'm you@exam.ple\nLine 1.\nBye.\n~.\n' |
3410 ${MAILX} ${ARGS} -Smta=./.tmta.sh
3412 ${MAILX} ${ARGS} -ef ./.t.mbox 2>> "${MBOX}"
3413 echo ${?} >> "${MBOX}"
3414 ${MAILX} ${ARGS} -efL @t@me ./.t.mbox 2>> "${MBOX}"
3415 echo ${?} >> "${MBOX}"
3416 ${MAILX} ${ARGS} -efL @t@you ./.t.mbox 2>> "${MBOX}"
3417 echo ${?} >> "${MBOX}"
3418 ${MAILX} ${ARGS} -efL '@>@Line 1' ./.t.mbox 2>> "${MBOX}"
3419 echo ${?} >> "${MBOX}"
3420 ${MAILX} ${ARGS} -efL '@>@Hello.' ./.t.mbox 2>> "${MBOX}"
3421 echo ${?} >> "${MBOX}"
3422 ${MAILX} ${ARGS} -efL '@>@Bye.' ./.t.mbox 2>> "${MBOX}"
3423 echo ${?} >> "${MBOX}"
3424 ${MAILX} ${ARGS} -efL '@>@Good bye.' ./.t.mbox 2>> "${MBOX}"
3425 echo ${?} >> "${MBOX}"
3427 ${MAILX} ${ARGS} -fH ./.t.mbox >> "${MBOX}" 2>&1
3428 echo ${?} >> "${MBOX}"
3429 ${MAILX} ${ARGS} -fL @t@me ./.t.mbox >> "${MBOX}" 2>&1
3430 echo ${?} >> "${MBOX}"
3431 ${MAILX} ${ARGS} -fL @t@you ./.t.mbox >> "${MBOX}" 2>&1
3432 echo ${?} >> "${MBOX}"
3433 ${MAILX} ${ARGS} -fL '@>@Line 1' ./.t.mbox >> "${MBOX}" 2>&1
3434 echo ${?} >> "${MBOX}"
3435 ${MAILX} ${ARGS} -fL '@>@Hello.' ./.t.mbox >> "${MBOX}" 2>&1
3436 echo ${?} >> "${MBOX}"
3437 ${MAILX} ${ARGS} -fL '@>@Bye.' ./.t.mbox >> "${MBOX}" 2>&1
3438 echo ${?} >> "${MBOX}"
3439 ${MAILX} ${ARGS} -fL '@>@Good bye.' ./.t.mbox >> "${MBOX}" 2>>${ERR}
3440 echo ${?} >> "${MBOX}"
3442 check 1 - "${MBOX}" '1708955574 678'
3446 printf 'm me1@exam.ple\n~s subject cab\nLine 1.\n~.\n' |
3447 ${MAILX} ${ARGS} -Smta=./.tmta.sh \
3448 -r '' -X 'wysh set from=pony1@$LOGNAME'
3449 printf 'm me2@exam.ple\n~s subject bac\nLine 12.\n~.\n' |
3450 ${MAILX} ${ARGS} -Smta=./.tmta.sh \
3451 -r '' -X 'wysh set from=pony2@$LOGNAME'
3452 printf 'm me3@exam.ple\n~s subject abc\nLine 123.\n~.\n' |
3453 ${MAILX} ${ARGS} -Smta=./.tmta.sh \
3454 -r '' -X 'wysh set from=pony3@$LOGNAME'
3456 ${MAILX} ${ARGS} -S folder-hook=fh-test -X 'define fh-test {
3457 echo fh-test size; set autosort=size showname showto
3458 }' -fH ./.t.mbox > "${MBOX}" 2>&1
3459 check 2-1 0 "${MBOX}" '512787278 418'
3461 ${MAILX} ${ARGS} -S folder-hook=fh-test -X 'define fh-test {
3462 echo fh-test subject; set autosort=subject showname showto
3463 }' -fH ./.t.mbox > "${MBOX}" 2>&1
3464 check 2-2 0 "${MBOX}" '3606067531 421'
3466 ${MAILX} ${ARGS} -S folder-hook=fh-test -X 'define fh-test {
3467 echo fh-test from; set autosort=from showto
3468 }' -fH ./.t.mbox > "${MBOX}" 2>&1
3469 check 2-3 0 "${MBOX}" '2506148572 418'
3471 ${MAILX} ${ARGS} -S folder-hook=fh-test -X 'define fh-test {
3472 echo fh-test to; set autosort=to showto
3473 }' -fH ./.t.mbox > "${MBOX}" 2>&1
3474 check 2-4 0 "${MBOX}" '1221542854 416'
3476 t_epilog
3479 t_q_t_etc_opts() {
3480 # Simple, if we need more here, place in a later vim fold!
3481 t_prolog q_t_etc_opts
3482 TRAP_EXIT_ADDONS="./.t*"
3484 # Three tests for MIME encoding and (a bit) content classification.
3485 # At the same time testing -q FILE, < FILE and -t FILE
3486 t__put_body > ./.tin
3488 < ./.tin ${MAILX} ${ARGS} ${ADDARG_UNI} \
3489 -a ./.tin -s "`t__put_subject`" "${MBOX}"
3490 check 1 0 "${MBOX}" '1088822685 6642'
3492 ${rm} "${MBOX}"
3493 < /dev/null ${MAILX} ${ARGS} ${ADDARG_UNI} \
3494 -a ./.tin -s "`t__put_subject`" -q ./.tin "${MBOX}"
3495 check 2 0 "${MBOX}" '1088822685 6642'
3497 ${rm} "${MBOX}"
3498 ( echo "To: ${MBOX}" && echo "Subject: `t__put_subject`" && echo &&
3499 ${cat} ./.tin
3500 ) | ${MAILX} ${ARGS} ${ADDARG_UNI} -Snodot -a ./.tin -t
3501 check 3 0 "${MBOX}" '1088822685 6642'
3503 # Check comments in the header
3504 ${rm} "${MBOX}"
3505 ${cat} <<-_EOT | ${MAILX} ${ARGS} -Snodot -t "${MBOX}"
3506 # Ein Kommentar
3507 From: du@da
3508 # Noch ein Kommentar
3509 Subject: hey you
3510 # Nachgestelltes Kommentar
3512 BOOOM
3513 _EOT
3514 check 4 0 "${MBOX}" '4161555890 124'
3516 t_epilog
3519 t_message_injections() {
3520 # Simple, if we need more here, place in a later vim fold!
3521 t_prolog message_injections
3522 TRAP_EXIT_ADDONS="./.t*"
3524 t_xmta 'Echinacea Tue Jun 20 15:54:02 2017'
3526 echo mysig > ./.tmysig
3528 echo some-body | ${MAILX} ${ARGS} -Smta=./.tmta.sh \
3529 -Smessage-inject-head=head-inject \
3530 -Smessage-inject-tail=tail-inject \
3531 -Ssignature=./.tmysig \
3532 ex@am.ple > ./.tall 2>&1
3533 check 1 0 "${MBOX}" '2434746382 134'
3534 check 2 - .tall '4294967295 0' # empty file
3536 ${rm} "${MBOX}"
3537 ${cat} <<-_EOT > ./.template
3538 From: me
3539 To: ex1@am.ple
3540 Cc: ex2@am.ple
3541 Subject: This subject is
3543 Body, body, body me.
3544 _EOT
3545 < ./.template ${MAILX} ${ARGS} -t -Smta=./.tmta.sh \
3546 -Smessage-inject-head=head-inject \
3547 -Smessage-inject-tail=tail-inject \
3548 -Ssignature=./.tmysig \
3549 > ./.tall 2>&1
3550 check 3 0 "${MBOX}" '3114203412 198'
3551 check 4 - .tall '4294967295 0' # empty file
3553 t_epilog
3556 t_attachments() {
3557 # Relatively Simple, if we need more here, place in a later vim fold!
3558 t_prolog attachments
3559 TRAP_EXIT_ADDONS="./.t*"
3561 t_xmta 'Cannabis Sun Feb 18 02:02:46 2018'
3563 ${cat} <<-_EOT > ./.tx
3564 From steffen Sun Feb 18 02:48:40 2018
3565 Date: Sun, 18 Feb 2018 02:48:40 +0100
3567 Subject: m1
3568 User-Agent: s-nail v14.9.7
3571 From steffen Sun Feb 18 02:48:42 2018
3572 Date: Sun, 18 Feb 2018 02:48:42 +0100
3574 Subject: m2
3575 User-Agent: s-nail v14.9.7
3578 _EOT
3579 echo att1 > ./.t1
3580 printf 'att2-1\natt2-2\natt2-4\n' > ./'.t 2'
3581 printf 'att3-1\natt3-2\natt3-4\n' > ./.t3
3582 printf 'att4-1\natt4-2\natt4-4\n' > './.t 4'
3584 printf \
3585 '!@ ./.t3 "./.t 4" ""
3588 ./.t3
3589 "./.t 2"
3592 !.' \
3593 | ${MAILX} ${ARGS} -Sescape=! -Smta=./.tmta.sh \
3594 -a ./.t1 -a './.t 2' \
3595 -s attachment-test \
3596 ex@am.ple > ./.tall 2>&1
3597 check 1 0 "${MBOX}" '4107062253 634'
3598 if have_feat uistrings; then
3599 check 2 - .tall '1928331872 720'
3600 else
3601 echo 'attachments-2: unsupported, skipped'
3604 ${rm} "${MBOX}"
3605 printf \
3606 'mail ex@amp.ple
3607 !s This the subject is
3608 !@ ./.t3 "#2" "./.t 4" "#1" ""
3611 "./.t 4"
3612 "#2"
3616 mail ex@amp.ple
3617 !s Subject two
3618 !@ ./.t3 "#2" "./.t 4" "#1" ""
3624 mail ex@amp.ple
3625 !s Subject three
3626 !@ ./.t3 "" "#2" "" "./.t 4" "" "#1" ""
3629 ./.t3
3633 mail ex@amp.ple
3634 !s Subject Four
3635 !@ ./.t3 "" "#2" "" "./.t 4" "" "#1" ""
3638 "#1"
3642 mail ex@amp.ple
3643 !s Subject Five
3645 "#2"
3648 !.' \
3649 | ${MAILX} ${ARGS} -Sescape=! -Smta=./.tmta.sh -Rf ./.tx \
3650 > ./.tall 2>&1
3651 check 3 0 "${MBOX}" '798122412 2285'
3652 if have_feat uistrings; then
3653 check 4 - .tall '2526106274 1910'
3654 else
3655 echo 'attachments-4: unsupported, skipped'
3658 ${rm} "${MBOX}"
3659 printf \
3660 'mail ex@amp.ple
3661 !s Subject One
3662 !@ "#."
3663 Body one.
3666 from 2
3667 mail ex@amp.ple
3668 !s Subject Two
3670 "#."
3672 Body two.
3675 reply 1 2
3676 !@ "#."
3680 "#."
3683 !.' \
3684 | ${MAILX} ${ARGS} -Sescape=! -Smta=./.tmta.sh -Rf ./.tx \
3685 > ./.tall 2>&1
3686 check 5 0 "${MBOX}" '2165311808 2276'
3687 if have_feat uistrings; then
3688 check 6 - .tall '3662598562 509'
3689 else
3690 echo 'attachments-6: unsupported, skipped'
3693 t_epilog
3696 t_rfc2231() {
3697 # (after attachments)
3698 t_prolog rfc2231
3699 TRAP_EXIT_ADDONS="./.t*"
3702 mkdir ./.ttt || exit 1
3703 cd ./.ttt || exit 2
3704 : > "ma'ger.txt"
3705 : > "'ger.txt"
3706 : > 'diet\ is \curd.txt'
3707 : > 'diet "is" curd.txt'
3708 : > höde-tröge.txt
3709 : > 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
3710 : > höde__tröge__müde__dätte__hätte__vuelle__guelle__aese__aesse__sauerliche__kräuter__österliche__grüße__mäh.txt
3711 : > hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt
3712 : > ✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt
3714 echo bla | ${MAILX} ${ARGS} ${ADDARG_UNI} \
3715 -a "./.ttt/ma'ger.txt" -a "./.ttt/'ger.txt" \
3716 -a './.ttt/diet\ is \curd.txt' -a './.ttt/diet "is" curd.txt' \
3717 -a ./.ttt/höde-tröge.txt \
3718 -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 \
3719 -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 \
3720 -a ./.ttt/hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt \
3721 -a ./.ttt/✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt \
3722 "${MBOX}"
3723 check 1 0 "${MBOX}" '3720896054 3088'
3725 # `resend' test, reusing $MBOX
3726 printf "Resend ./.t2\nx\n" | ${MAILX} ${ARGS} -Rf "${MBOX}"
3727 check 2 0 ./.t2 '3720896054 3088'
3729 printf "resend ./.t3\nx\n" | ${MAILX} ${ARGS} -Rf "${MBOX}"
3730 check 3 0 ./.t3 '3979736592 3133'
3732 t_epilog
3735 t_mime_types_load_control() {
3736 t_prolog mime_types_load_control
3737 if have_feat uistrings; then :; else
3738 echo 'mime_types_load_control: unsupported, skipped'
3739 return
3741 TRAP_EXIT_ADDONS="./.t*"
3743 ${cat} <<-_EOT > ./.tmts1
3744 @ application/mathml+xml mathml
3745 _EOT
3746 ${cat} <<-_EOT > ./.tmts2
3747 @ x-conference/x-cooltalk ice
3748 @ aga-aga aga
3749 @ application/aga-aga aga
3750 _EOT
3752 ${cat} <<-_EOT > ./.tmts1.mathml
3753 <head>nonsense ML</head>
3754 _EOT
3755 ${cat} <<-_EOT > ./.tmts2.ice
3756 Icy, icy road.
3757 _EOT
3758 printf 'of which the c\x01rack is coming soon' > ./.tmtsx.doom
3759 printf 'of which the c\x01rack is coming soon' > ./.tmtsx.aga
3761 printf '
3762 m %s
3763 Schub-di-du
3764 ~@ ./.tmts1.mathml
3765 ~@ ./.tmts2.ice
3766 ~@ ./.tmtsx.doom
3767 ~@ ./.tmtsx.aga
3769 File %s
3770 from*
3771 type
3773 ' "${MBOX}" "${MBOX}" |
3774 ${MAILX} ${ARGS} \
3775 -Smimetypes-load-control=f=./.tmts1,f=./.tmts2 \
3776 > ./.tout 2>&1
3777 check_ex0 1-estat
3778 ${cat} "${MBOX}" >> ./.tout
3779 check 1 - ./.tout '2716124839 2441'
3781 echo type | ${MAILX} ${ARGS} -R \
3782 -Smimetypes-load-control=f=./.tmts1,f=./.tmts3 \
3783 -f "${MBOX}" >> ./.tout 2>&1
3784 check 2 0 ./.tout '2093030907 3634'
3786 t_epilog
3788 # }}}
3790 # Around state machine, after basics {{{
3791 t_alternates() {
3792 t_prolog alternates
3793 TRAP_EXIT_ADDONS="./.t*"
3795 t_xmta 'Valeriana Sat Jul 08 15:54:03 2017'
3797 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Smta=./.tmta.sh > ./.tall 2>&1
3798 echo --0
3799 alternates
3800 echo $?/$^ERRNAME
3801 alternates a1@b1 a2@b2 a3@b3
3802 echo $?/$^ERRNAME
3803 alternates
3804 echo $?/$^ERRNAME
3805 vput alternates rv
3806 echo $?/$^ERRNAME <$rv>
3808 echo --1
3809 unalternates a2@b2
3810 vput alternates rv
3811 echo $?/$^ERRNAME <$rv>
3812 unalternates a3@b3
3813 vput alternates rv
3814 echo $?/$^ERRNAME <$rv>
3815 unalternates a1@b1
3816 vput alternates rv
3817 echo $?/$^ERRNAME <$rv>
3819 echo --2
3820 unalternates *
3821 alternates a1@b1 a2@b2 a3@b3
3822 unalternates a3@b3
3823 vput alternates rv
3824 echo $?/$^ERRNAME <$rv>
3825 unalternates a2@b2
3826 vput alternates rv
3827 echo $?/$^ERRNAME <$rv>
3828 unalternates a1@b1
3829 vput alternates rv
3830 echo $?/$^ERRNAME <$rv>
3832 echo --3
3833 alternates a1@b1 a2@b2 a3@b3
3834 unalternates a1@b1
3835 vput alternates rv
3836 echo $?/$^ERRNAME <$rv>
3837 unalternates a2@b2
3838 vput alternates rv
3839 echo $?/$^ERRNAME <$rv>
3840 unalternates a3@b3
3841 vput alternates rv
3842 echo $?/$^ERRNAME <$rv>
3844 echo --4
3845 unalternates *
3846 alternates a1@b1 a2@b2 a3@b3
3847 unalternates *
3848 vput alternates rv
3849 echo $?/$^ERRNAME <$rv>
3851 echo --5
3852 unalternates *
3853 alternates a1@b1 a1@c1 a1@d1 a2@b2 a3@b3 a3@c3 a3@d3
3854 m a1@b1 a1@c1 a1@d1
3855 ~s all alternates, only a1@b1 remains
3856 ~c a2@b2
3857 ~b a3@b3 a3@c3 a3@d3
3858 ~r - '_EOT'
3859 This body is!
3860 This also body is!!
3861 _EOT
3864 echo --6
3865 unalternates *
3866 alternates a1@b1 a1@c1 a2@b2 a3@b3
3867 m a1@b1 a1@c1 a1@d1
3868 ~s a1@b1 a1@d1, and a3@c3 a3@d3 remain
3869 ~c a2@b2
3870 ~b a3@b3 a3@c3 a3@d3
3871 ~r - '_EOT'
3872 This body2 is!
3873 _EOT
3876 echo --7
3877 alternates a1@b1 a2@b2 a3; set allnet
3878 m a1@b1 a1@c1 a1@d1
3879 ~s all alternates via allnet, only a1@b1 remains
3880 ~c a2@b2
3881 ~b a3@b3 a3@c3 a3@d3
3882 ~r - '_EOT'
3883 This body3 is!
3884 _EOT
3887 echo --10
3888 unalternates *
3889 alternates a1@b1
3890 echo $?/$^ERRNAME
3891 vput alternates rv
3892 echo $?/$^ERRNAME <$rv>
3893 alternates a2@b2
3894 echo $?/$^ERRNAME
3895 vput alternates rv
3896 echo $?/$^ERRNAME <$rv>
3897 alternates a3@b3
3898 echo $?/$^ERRNAME
3899 vput alternates rv
3900 echo $?/$^ERRNAME <$rv>
3901 alternates a4@b4
3902 echo $?/$^ERRNAME
3903 vput alternates rv
3904 echo $?/$^ERRNAME <$rv>
3906 unalternates *
3907 vput alternates rv
3908 echo $?/$^ERRNAME <$rv>
3910 echo --11
3911 set posix
3912 alternates a1@b1 a2@b2
3913 echo $?/$^ERRNAME
3914 vput alternates rv
3915 echo $?/$^ERRNAME <$rv>
3916 alternates a3@b3 a4@b4
3917 echo $?/$^ERRNAME
3918 vput alternates rv
3919 echo $?/$^ERRNAME <$rv>
3920 __EOT
3922 check 1 0 "${MBOX}" '142184864 515'
3923 if have_feat uistrings; then
3924 check 2 - .tall '1878598364 505'
3925 else
3926 echo 'alternates-2: unsupported, skipped'
3929 # Automatic alternates, also from command line (freezing etc.)
3930 ${rm} "${MBOX}"
3931 ${cat} <<- __EOT > ./.tin
3932 From trouble-report@desy Wed Jun 6 20:19:28 2018
3933 Date: Wed, 06 Jun 2018 19:58:02 +0200
3934 From: a@b.org, b@b.org, c@c.org
3935 Sender: a@b.org
3936 To: b@b.org
3937 Cc: a@b.org, c@c.org
3938 Subject: test
3939 Message-ID: <20180606175802.dw-cn%a@b.org>
3941 sultry
3943 __EOT
3945 printf '#
3946 reply
3948 b@b.org
3949 a@b.org b@b.org c@c.org
3952 my body
3954 ' | ${MAILX} ${ARGS} -Smta=./.tmta.sh -Sescape=! \
3955 -S from=a@b.org,b@b.org,c@c.org -S sender=a@b.org \
3956 -Rf ./.tin > ./.tall 2>&1
3957 check 3 0 "${MBOX}" '287250471 256'
3958 check 4 - .tall '4294967295 0'
3960 # same, per command
3961 printf '#
3962 set from=a@b.org,b@b.org,c@c.org sender=a@b.org
3963 reply
3965 b@b.org
3966 a@b.org b@b.org c@c.org
3969 my body
3971 ' | ${MAILX} ${ARGS} -Smta=./.tmta.sh -Sescape=! \
3972 -Rf ./.tin > ./.tall 2>&1
3973 check 5 0 "${MBOX}" '2618762028 512'
3974 check 6 - .tall '4294967295 0'
3976 # And more, with/out -r
3977 # TODO -r should be the Sender:, which should automatically propagate to
3978 # TODO From: if possible and/or necessary. It should be possible to
3979 # TODO suppres -r stuff from From: and Sender:, but fallback to special -r
3980 # TODO arg as appropriate.
3981 # TODO For now we are a bit messy
3983 ${rm} "${MBOX}"
3984 </dev/null ${MAILX} ${ARGS} -Smta=./.tmta.sh -s '-Sfrom + -r ++ test' \
3985 -c a@b.example,b@b.example,c@c.example \
3986 -S from=a@b.example,b@b.example,c@c.example \
3987 -S sender=a@b.example \
3988 -r a@b.example b@b.example ./.tout >./.tall 2>&1
3989 check 7 0 "${MBOX}" '3510981487 192'
3990 check 8 - .tout '2052716617 201'
3991 check 9 - .tall '4294967295 0'
3993 </dev/null ${MAILX} ${ARGS} -Smta=./.tmta.sh -s '-Sfrom + -r ++ test' \
3994 -c a@b.example,b@b.example,c@c.example \
3995 -S from=a@b.example,b@b.example,c@c.example \
3996 -r a@b.example b@b.example ./.tout >./.tall 2>&1
3997 check 10 0 "${MBOX}" '2282326606 364'
3998 check 11 - .tout '3213404599 382'
3999 check 12 - .tall '4294967295 0'
4001 </dev/null ${MAILX} ${ARGS} -Smta=./.tmta.sh -s '-Sfrom + -r ++ test' \
4002 -c a@b.example,b@b.example,c@c.example \
4003 -S from=a@b.example,b@b.example,c@c.example \
4004 -S sender=a@b.example \
4005 b@b.example >./.tall 2>&1
4006 check 13 0 "${MBOX}" '1460017970 582'
4007 check 14 - .tall '4294967295 0'
4009 t_epilog
4012 t_quote_a_cmd_escapes() {
4013 t_prolog quote_a_cmd_escapes
4014 TRAP_EXIT_ADDONS="./.t*"
4016 t_xmta
4018 echo 'included file' > ./.ttxt
4020 ${cat} <<-_EOT > ./.tmbox
4021 From neverneverland Sun Jul 23 13:46:25 2017
4022 Subject: Bugstop: five miles out 1
4023 Reply-To: mister originator1 <mr1@originator>
4024 From: mister originator1 <mr1@originator>
4025 To: bugstop-commit@five.miles.out
4026 Cc: is1@a.list
4027 In-reply-to: <20170719111113.bkcMz%laber1@backe.eu>
4028 Date: Wed, 19 Jul 2017 09:22:57 -0400
4029 Message-Id: <20170719132257.766AF781267-1@originator>
4030 Status: RO
4032 That's appalling, I.
4034 From neverneverland Sun Jul 23 13:47:25 2017
4035 Subject: Bugstop: five miles out 2
4036 Reply-To: mister originator2 <mr2@originator>
4037 From: mister originator2 <mr2@originator>
4038 To: bugstop-commit@five.miles.out
4039 Cc: is2@a.list
4040 In-reply-to: <20170719111113.bkcMz%laber2@backe.eu>
4041 Date: Wed, 19 Jul 2017 09:23:57 -0400
4042 Message-Id: <20170719132257.766AF781267-2@originator>
4043 Status: RO
4045 That's appalling, II.
4047 From neverneverland Sun Jul 23 13:48:25 2017
4048 Subject: Bugstop: five miles out 3
4049 Reply-To: mister originator3 <mr3@originator>
4050 From: mister originator3 <mr3@originator>
4051 To: bugstop-commit@five.miles.out
4052 Cc: is3@a.list
4053 In-reply-to: <20170719111113.bkcMz%laber3@backe.eu>
4054 Date: Wed, 19 Jul 2017 09:24:57 -0400
4055 Message-Id: <20170719132257.766AF781267-3@originator>
4056 Status: RO
4058 That's appalling, III.
4060 _EOT
4062 printf '#
4063 set indentprefix=" |"
4064 set quote
4065 reply 2
4067 set quote=noheading
4068 reply 2
4070 headerpick type retain cc date from message-id reply-to subject to
4071 set quote=headers
4072 reply 2
4074 set quote=allheaders
4075 reply 2
4077 ' | ${MAILX} ${ARGS} -Smta=./.tmta.sh -Rf \
4078 -Sescape=! -Sindentprefix=' >' \
4079 ./.tmbox >./.tall 2>&1
4080 check_ex0 1-estat
4081 ${cat} ./.tall >> "${MBOX}"
4082 check 1 0 "${MBOX}" '2181726970 2023'
4084 # ~@ is tested with other attachment stuff, ~^ is in compose_hooks
4085 ${rm} "${MBOX}"
4086 printf '#
4087 set Sign=SignVar sign=signvar DEAD=./.ttxt
4088 headerpick type retain Subject
4089 reply 2
4090 !!1 Not escaped. And shell test last, right before !..
4091 !: echo 2 only echoed via colon
4092 !_ echo 3 only echoed via underscore
4093 !< ./.ttxt
4094 !<! echo 5 shell echo included
4095 !| echo 6 pipecmd-pre; cat; echo 6 pipecmd-post
4096 7 and 8 are ~A and ~a:
4099 !b 9 added ~b cc <ex1@am.ple>
4100 !c 10 added ~c c <ex2@am.ple>
4101 11 next ~d / $DEAD
4103 12: ~F
4105 13: ~F 1 3
4106 !F 1 3
4107 14: ~f (headerpick: subject)
4109 15: ~f 1
4110 !f 1
4111 16, 17: ~I Sign, ~i Sign
4112 !I Sign
4113 !i Sign
4114 18: ~M
4116 19: ~M 1
4117 !M 1
4118 20: ~m
4120 21: ~m 3
4121 !m 3
4122 28-32: ~Q; 28: ~Q
4124 29: ~Q 1 3
4125 !Q 1 3
4126 set quote
4127 !:set quote
4128 30: ~Q
4130 31: ~Q 1 3
4131 !Q 1 3
4132 set quote-inject-head quote-inject-tail indentprefix
4133 !:wysh set quote-inject-head=%%a quote-inject-tail=--%%r
4134 32: ~Q
4136 unset quote stuff
4137 !:unset quote quote-inject-head quote-inject-tail
4138 22: ~R ./.ttxt
4139 !R ./.ttxt
4140 23: ~r ./.ttxt
4141 !r ./.ttxt
4142 24: ~s this new subject
4143 !s 24 did new ~s ubject
4144 !t 25 added ~t o <ex3@am.ple>
4145 26: ~U
4147 27: ~U 1
4148 !U 1
4149 and i ~w rite this out to ./.tmsg
4150 !w ./.tmsg
4151 !:wysh set x=$escape;set escape=~
4152 ~!echo shell command output
4153 ~:wysh set escape=$x
4155 ' | ${MAILX} ${ARGS} -Smta=./.tmta.sh -Rf \
4156 -Sescape=! -Sindentprefix=' |' \
4157 ./.tmbox >./.tall 2>&1
4158 check_ex0 2-estat
4159 ${cat} ./.tall >> "${MBOX}"
4160 check 2 - "${MBOX}" '2613898218 4090'
4161 check 3 - ./.tmsg '2771314896 3186'
4163 t_epilog
4166 t_compose_edits() { # XXX very rudimentary
4167 t_prolog compose_edits
4168 TRAP_EXIT_ADDONS="./.t*"
4170 ${cat} <<-_EOT > ./.ted.sh
4171 #!${SHELL}
4172 ${cat} <<-__EOT > \${1}
4173 Fcc: .tout1
4175 Fcc: .tout2
4176 Subject: Fcc test 1
4177 Fcc: .tout3
4179 A body
4180 __EOT
4181 exit 0
4182 _EOT
4183 chmod 0755 .ted.sh
4185 # > All these are in-a-row!
4187 printf 'mail ./.tout\n~s This subject is\nThis body is\n~.' |
4188 ${MAILX} ${ARGS} -Seditheaders >./.tall 2>&1
4189 check 1 0 ./.tout '3993703854 127'
4190 check 2 - ./.tall '4294967295 0'
4192 ${mv} ./.tall ./.tout
4193 printf 'mail ./.tout\n~s This subject is\nThis body is\n~e\n~.' |
4194 ${MAILX} ${ARGS} -Seditheaders -SEDITOR=./.ted.sh >./.tall 2>&1
4195 check 3 0 ./.tout1 '285981670 116'
4196 check 4 - ./.tout2 '285981670 116'
4197 check 5 - ./.tout3 '285981670 116'
4198 check 6 - ./.tout '4294967295 0'
4199 check 7 - ./.tall '4294967295 0'
4200 ${rm} ./.tout1 ./.tout2 ./.tout3
4202 # t_compose_hooks will test ~^ at edge
4203 ${mv} ./.tout ./.tout1
4204 ${mv} ./.tall ./.tout2
4205 printf '#
4206 mail ./.tout\n!s This subject is\nThis body is
4207 !^header list
4208 !^header list fcc
4209 !^header show fcc
4210 !^header remove to
4211 !^header insert fcc ./.tout
4212 !^header insert fcc .tout1
4213 !^header insert fcc ./.tout2
4214 !^header list
4215 !^header show fcc
4216 !^header remove-at fcc 2
4217 !^header remove-at fcc 2
4218 !^header show fcc
4219 !^head remove fcc
4220 !^header show fcc
4221 !^header insert fcc ./.tout
4222 !^header show fcc
4223 !^header list
4225 ' | ${MAILX} ${ARGS} -Sescape=! >./.tall 2>&1
4226 check 8 0 ./.tout '3993703854 127'
4227 check 9 - ./.tout1 '4294967295 0'
4228 check 10 - ./.tout2 '4294967295 0'
4229 check 11 - ./.tall '4280910245 300'
4231 # < No longer in-a-row
4233 ${cat} <<-_EOT | ${MAILX} ${ARGS} -t >./.tall 2>&1
4234 Fcc: .ttout
4235 Subject: Fcc via -t test
4237 My body
4238 _EOT
4239 check 12 0 ./.ttout '1289478830 122'
4240 check 13 - ./.tall '4294967295 0'
4242 t_epilog
4244 # }}}
4246 # Heavy use of/rely on state machine (behaviour) and basics {{{
4247 t_compose_hooks() { # {{{ TODO monster
4248 t_prolog compose_hooks
4249 if have_feat uistrings; then :; else
4250 echo 'compose_hooks: unsupported, skipped'
4251 return
4253 TRAP_EXIT_ADDONS="./.t*"
4255 t_xmta 'PrimulaVeris Wed Apr 10 22:59:00 2017'
4257 (echo line one&&echo line two&&echo line three) > ./.treadctl
4258 (echo echo four&&echo echo five&&echo echo six) > ./.tattach
4260 ${cat} <<'__EOT__' > ./.trc
4261 define bail {
4262 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
4264 define xerr {
4265 vput vexpr es substr "$1" 0 1
4266 if [ "$es" != 2 ]
4267 xcall bail "$2"
4270 define read_mline_res {
4271 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
4272 echo $len/$es/$^ERRNAME: $hl
4273 if [ $es -ne $^ERR-NONE ]
4274 xcall bail read_mline_res
4275 elif [ $len -ne 0 ]
4276 \xcall read_mline_res
4279 define ins_addr {
4280 wysh set xh=$1
4281 echo "~^header list"; read hl; echo $hl;\
4282 call xerr "$hl" "in_addr ($xh) 0-1"
4284 echo "~^header insert $xh diet <$xh@exam.ple> spliced";\
4285 read es; echo $es; call xerr "$es" "ins_addr $xh 1-1"
4286 echo "~^header insert $xh <${xh}2@exam.ple>";\
4287 read es; echo $es; call xerr "$es" "ins_addr $xh 1-2"
4288 echo "~^header insert $xh ${xh}3@exam.ple";\
4289 read es; echo $es; call xerr "$es" "ins_addr $xh 1-3"
4290 echo "~^header list $xh"; read hl; echo $hl;\
4291 call xerr "$hl" "ins_addr $xh 1-4"
4292 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 1-5"
4293 call read_mline_res
4295 if [ "$t_remove" == "" ]
4296 return
4299 echo "~^header remove $xh"; read es; call xerr $es "ins_addr $xh 2-1"
4300 echo "~^header remove $xh"; read es; vput vexpr es substr $es 0 3
4301 if [ $es != 501 ]
4302 xcall bail "ins_addr $xh 2-2"
4304 echo "~^header list $xh"; read es; vput vexpr es substr $es 0 3
4305 if [ $es != 501 ]
4306 xcall bail "ins_addr $xh 2-3"
4308 echo "~^header show $xh"; read es; vput vexpr es substr $es 0 3
4309 if [ $es != 501 ]
4310 xcall bail "ins_addr $xh 2-4"
4314 echo "~^header insert $xh diet <$xh@exam.ple> spliced";\
4315 read es; echo $es; call xerr "$es" "ins_addr $xh 3-1"
4316 echo "~^header insert $xh <${xh}2@exam.ple>";\
4317 read es; echo $es; call xerr "$es" "ins_addr $xh 3-2"
4318 echo "~^header insert $xh ${xh}3@exam.ple";\
4319 read es; echo $es; call xerr "$es" "ins_addr $xh 3-3"
4320 echo "~^header list $xh"; read hl; echo $hl;\
4321 call xerr "$hl" "ins_addr $xh 3-4"
4322 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 3-5"
4323 call read_mline_res
4325 echo "~^header remove-at $xh 1"; read es;\
4326 call xerr $es "ins_addr $xh 3-6"
4327 echo "~^header remove-at $xh 1"; read es;\
4328 call xerr $es "ins_addr $xh 3-7"
4329 echo "~^header remove-at $xh 1"; read es;\
4330 call xerr $es "ins_addr $xh 3-8"
4331 echo "~^header remove-at $xh 1"; read es;\
4332 vput vexpr es substr $es 0 3
4333 if [ $es != 501 ]
4334 xcall bail "ins_addr $xh 3-9"
4336 echo "~^header remove-at $xh T"; read es;\
4337 vput vexpr es substr $es 0 3
4338 if [ $es != 505 ]
4339 xcall bail "ins_addr $xh 3-10"
4341 echo "~^header list $xh"; read es;\
4342 vput vexpr es substr $es 0 3
4343 if [ $es != 501 ]
4344 xcall bail "ins_addr $xh 3-11"
4346 echo "~^header show $xh"; read es;\
4347 vput vexpr es substr $es 0 3
4348 if [ $es != 501 ]
4349 xcall bail "ins_addr $xh 3-12"
4353 echo "~^header insert $xh diet <$xh@exam.ple> spliced";\
4354 read es; echo $es; call xerr "$es" "ins_addr $xh 4-1"
4355 echo "~^header insert $xh <${xh}2@exam.ple> (comment) \"Quot(e)d\"";\
4356 read es; echo $es; call xerr "$es" "ins_addr $xh 4-2"
4357 echo "~^header insert $xh ${xh}3@exam.ple";\
4358 read es; echo $es; call xerr "$es" "ins_addr $xh 4-3"
4359 echo "~^header list $xh"; read hl; echo $hl;\
4360 call xerr "$hl" "header list $xh 3-4"
4361 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 4-5"
4362 call read_mline_res
4364 echo "~^header remove-at $xh 3"; read es;\
4365 call xerr $es "ins_addr $xh 4-6"
4366 echo "~^header remove-at $xh 2"; read es;\
4367 call xerr $es "ins_addr $xh 4-7"
4368 echo "~^header remove-at $xh 1"; read es;\
4369 call xerr $es "ins_addr $xh 4-8"
4370 echo "~^header remove-at $xh 1"; read es;\
4371 vput vexpr es substr $es 0 3
4372 if [ $es != 501 ]
4373 xcall bail "ins_addr $xh 4-9"
4375 echo "~^header remove-at $xh T"; read es;\
4376 vput vexpr es substr $es 0 3
4377 if [ $es != 505 ]
4378 xcall bail "ins_addr $xh 4-10"
4380 echo "~^header list $xh"; read es;\
4381 vput vexpr es substr $es 0 3
4382 if [ $es != 501 ]
4383 xcall bail "ins_addr $xh 4-11"
4385 echo "~^header show $xh"; read es;\
4386 vput vexpr es substr $es 0 3
4387 if [ $es != 501 ]
4388 xcall bail "ins_addr $xh 4-12"
4391 define ins_ref {
4392 wysh set xh=$1 mult=$2
4393 echo "~^header list"; read hl; echo $hl;\
4394 call xerr "$hl" "ins_ref ($xh) 0-1"
4396 echo "~^header insert $xh <$xh@exam.ple>";\
4397 read es; echo $es; call xerr "$es" "ins_ref $xh 1-1"
4398 if [ $mult -ne 0 ]
4399 echo "~^header insert $xh <${xh}2@exam.ple>";\
4400 read es; echo $es; call xerr "$es" "ins_ref $xh 1-2"
4401 echo "~^header insert $xh ${xh}3@exam.ple";\
4402 read es; echo $es; call xerr "$es" "ins_ref $xh 1-3"
4403 else
4404 echo "~^header insert $xh <${xh}2@exam.ple>"; read es;\
4405 vput vexpr es substr $es 0 3
4406 if [ $es != 506 ]
4407 xcall bail "ins_ref $xh 1-4"
4411 echo "~^header list $xh"; read hl; echo $hl;\
4412 call xerr "$hl" "ins_ref $xh 1-5"
4413 echo "~^header show $xh"; read es; call xerr $es "ins_ref $xh 1-6"
4414 call read_mline_res
4416 if [ "$t_remove" == "" ]
4417 return
4420 echo "~^header remove $xh"; read es;\
4421 call xerr $es "ins_ref $xh 2-1"
4422 echo "~^header remove $xh"; read es;\
4423 vput vexpr es substr $es 0 3
4424 if [ $es != 501 ]
4425 xcall bail "ins_ref $xh 2-2"
4427 echo "~^header list $xh"; read es;\
4428 vput vexpr es substr $es 0 3
4429 if [ $es != 501 ]
4430 xcall bail "$es ins_ref $xh 2-3"
4432 echo "~^header show $xh"; read es;\
4433 vput vexpr es substr $es 0 3
4434 if [ $es != 501 ]
4435 xcall bail "ins_ref $xh 2-4"
4439 echo "~^header insert $xh <$xh@exam.ple>";\
4440 read es; echo $es; call xerr "$es" "ins_ref $xh 3-1"
4441 if [ $mult -ne 0 ]
4442 echo "~^header insert $xh <${xh}2@exam.ple>";\
4443 read es; echo $es; call xerr "$es" "ins_ref $xh 3-2"
4444 echo "~^header insert $xh ${xh}3@exam.ple";\
4445 read es; echo $es; call xerr "$es" "ins_ref $xh 3-3"
4447 echo "~^header list $xh";\
4448 read hl; echo $hl; call xerr "$hl" "ins_ref $xh 3-4"
4449 echo "~^header show $xh";\
4450 read es; call xerr $es "ins_ref $xh 3-5"
4451 call read_mline_res
4453 echo "~^header remove-at $xh 1"; read es;\
4454 call xerr $es "ins_ref $xh 3-6"
4455 if [ $mult -ne 0 ] && [ $xh != subject ]
4456 echo "~^header remove-at $xh 1"; read es;\
4457 call xerr $es "ins_ref $xh 3-7"
4458 echo "~^header remove-at $xh 1"; read es;\
4459 call xerr $es "ins_ref $xh 3-8"
4461 echo "~^header remove-at $xh 1"; read es;\
4462 vput vexpr es substr $es 0 3
4463 if [ $es != 501 ]
4464 xcall bail "ins_ref $xh 3-9"
4466 echo "~^header remove-at $xh T"; read es;\
4467 vput vexpr es substr $es 0 3
4468 if [ $es != 505 ]
4469 xcall bail "ins_ref $xh 3-10"
4471 echo "~^header show $xh"; read es;\
4472 vput vexpr es substr $es 0 3
4473 if [ $es != 501 ]
4474 xcall bail "ins_ref $xh 3-11"
4478 echo "~^header insert $xh <$xh@exam.ple> ";\
4479 read es; echo $es; call xerr "$es" "ins_ref $xh 4-1"
4480 if [ $mult -ne 0 ]
4481 echo "~^header insert $xh <${xh}2@exam.ple> ";\
4482 read es; echo $es; call xerr "$es" "ins_ref $xh 4-2"
4483 echo "~^header insert $xh ${xh}3@exam.ple";\
4484 read es; echo $es; call xerr "$es" "ins_ref $xh 4-3"
4486 echo "~^header list $xh"; read hl; echo $hl;\
4487 call xerr "$hl" "ins_ref $xh 4-4"
4488 echo "~^header show $xh"; read es; call xerr $es "ins_ref $xh 4-5"
4489 call read_mline_res
4491 if [ $mult -ne 0 ] && [ $xh != subject ]
4492 echo "~^header remove-at $xh 3"; read es;\
4493 call xerr $es "ins_ref $xh 4-6"
4494 echo "~^header remove-at $xh 2"; read es;\
4495 call xerr $es "ins_ref $xh 4-7"
4497 echo "~^header remove-at $xh 1"; read es;\
4498 call xerr $es "ins_ref $xh 4-8"
4499 echo "~^header remove-at $xh 1"; read es;\
4500 vput vexpr es substr $es 0 3
4501 if [ $es != 501 ]
4502 xcall bail "ins_ref $xh 4-9"
4504 echo "~^header remove-at $xh T"; read es;\
4505 vput vexpr es substr $es 0 3
4506 if [ $es != 505 ]
4507 xcall bail "ins_ref $xh 4-10"
4509 echo "~^header show $xh"; read es;\
4510 vput vexpr es substr $es 0 3
4511 if [ $es != 501 ]
4512 xcall bail "ins_ref $xh 4-11"
4515 define t_header {
4516 echo t_header ENTER
4517 # In collect.c order
4518 call ins_addr from
4519 call ins_ref sender 0 # Not a "ref", but works
4520 call ins_addr To
4521 call ins_addr cC
4522 call ins_addr bCc
4523 call ins_addr reply-To
4524 call ins_addr mail-Followup-to
4525 call ins_ref messAge-id 0
4526 call ins_ref rEfErEncEs 1
4527 call ins_ref in-Reply-to 1
4528 call ins_ref subject 1 # Not a "ref", but works (with tweaks)
4529 call ins_addr freeForm1
4530 call ins_addr freeform2
4532 echo "~^header show MAILX-Command"; read es; call xerr $es "t_header 1000"
4533 call read_mline_res
4534 echo "~^header show MAILX-raw-TO"; read es; call xerr $es "t_header 1001"
4535 call read_mline_res
4537 echo t_header LEAVE
4539 define t_attach {
4540 echo t_attach ENTER
4542 echo "~^attachment";\
4543 read hl; echo $hl; vput vexpr es substr "$hl" 0 3
4544 if [ "$es" != 501 ]
4545 xcall bail "attach 0-1"
4548 echo "~^attach attribute ./.treadctl";\
4549 read hl; echo $hl; vput vexpr es substr "$hl" 0 3
4550 if [ "$es" != 501 ]
4551 xcall bail "attach 0-2"
4553 echo "~^attachment attribute-at 1";\
4554 read hl; echo $hl; vput vexpr es substr "$hl" 0 3
4555 if [ "$es" != 501 ]
4556 xcall bail "attach 0-3"
4559 echo "~^attachment insert ./.treadctl=ascii";\
4560 read hl; echo $hl; call xerr "$hl" "attach 1-1"
4561 echo "~^attachment list";\
4562 read es; echo $es;call xerr "$es" "attach 1-2"
4563 call read_mline_res
4564 echo "~^attachment attribute ./.treadctl";\
4565 read es; echo $es;call xerr "$es" "attach 1-3"
4566 call read_mline_res
4567 echo "~^attachment attribute .treadctl";\
4568 read es; echo $es;call xerr "$es" "attach 1-4"
4569 call read_mline_res
4570 echo "~^attachment attribute-at 1";\
4571 read es; echo $es;call xerr "$es" "attach 1-5"
4572 call read_mline_res
4574 echo "~^attachment attribute-set ./.treadctl filename rctl";\
4575 read es; echo $es;call xerr "$es" "attach 1-6"
4576 echo "~^attachment attribute-set .treadctl content-description Au";\
4577 read es; echo $es;call xerr "$es" "attach 1-7"
4578 echo "~^attachment attribute-set-at 1 content-id <10.du@ich>";\
4579 read es; echo $es;call xerr "$es" "attach 1-8"
4581 echo "~^attachment attribute ./.treadctl";\
4582 read es; echo $es;call xerr "$es" "attach 1-9"
4583 call read_mline_res
4584 echo "~^attachment attribute .treadctl";\
4585 read es; echo $es;call xerr "$es" "attach 1-10"
4586 call read_mline_res
4587 echo "~^attachment attribute rctl";\
4588 read es; echo $es;call xerr "$es" "attach 1-11"
4589 call read_mline_res
4590 echo "~^attachment attribute-at 1";\
4591 read es; echo $es;call xerr "$es" "attach 1-12"
4592 call read_mline_res
4595 echo "~^attachment insert ./.tattach=latin1";\
4596 read hl; echo $hl; call xerr "$hl" "attach 2-1"
4597 echo "~^attachment list";\
4598 read es; echo $es;call xerr "$es" "attach 2-2"
4599 call read_mline_res
4600 echo "~^attachment attribute ./.tattach";\
4601 read es; echo $es;call xerr "$es" "attach 2-3"
4602 call read_mline_res
4603 echo "~^attachment attribute .tattach";\
4604 read es; echo $es;call xerr "$es" "attach 2-4"
4605 call read_mline_res
4606 echo "~^attachment attribute-at 2";\
4607 read es; echo $es;call xerr "$es" "attach 2-5"
4608 call read_mline_res
4610 echo "~^attachment attribute-set ./.tattach filename tat";\
4611 read es; echo $es;call xerr "$es" "attach 2-6"
4612 echo \
4613 "~^attachment attribute-set .tattach content-description Au2";\
4614 read es; echo $es;call xerr "$es" "attach 2-7"
4615 echo "~^attachment attribute-set-at 2 content-id <20.du@wir>";\
4616 read es; echo $es;call xerr "$es" "attach 2-8"
4617 echo \
4618 "~^attachment attribute-set-at 2 content-type application/x-sh";\
4619 read es; echo $es;call xerr "$es" "attach 2-9"
4621 echo "~^attachment attribute ./.tattach";\
4622 read es; echo $es;call xerr "$es" "attach 2-10"
4623 call read_mline_res
4624 echo "~^attachment attribute .tattach";\
4625 read es; echo $es;call xerr "$es" "attach 2-11"
4626 call read_mline_res
4627 echo "~^attachment attribute tat";\
4628 read es; echo $es;call xerr "$es" "attach 2-12"
4629 call read_mline_res
4630 echo "~^attachment attribute-at 2";\
4631 read es; echo $es;call xerr "$es" "attach 2-13"
4632 call read_mline_res
4635 if [ "$t_remove" == "" ]
4636 return
4639 echo "~^attachment remove ./.treadctl"; read es;\
4640 call xerr $es "attach 3-1"
4641 echo "~^attachment remove ./.tattach"; read es;\
4642 call xerr $es "attach 3-2"
4643 echo "~^ attachment remove ./.treadctl"; read es;\
4644 vput vexpr es substr $es 0 3
4645 if [ $es != 501 ]
4646 xcall bail "attach 3-3"
4648 echo "~^ attachment remove ./.tattach"; read es;\
4649 vput vexpr es substr $es 0 3
4650 if [ $es != 501 ]
4651 xcall bail "attach 3-4"
4653 echo "~^attachment list"; read es;\
4654 vput vexpr es substr $es 0 3
4655 if [ $es != 501 ]
4656 xcall bail "attach 3-5"
4660 echo "~^attachment insert ./.tattach=latin1";\
4661 read hl; echo $hl; call xerr "$hl" "attach 4-1"
4662 echo "~^attachment insert ./.tattach=latin1";\
4663 read hl; echo $hl; call xerr "$hl" "attach 4-2"
4664 echo "~^attachment list";\
4665 read es; echo $es;call xerr "$es" "attach 4-3"
4666 call read_mline_res
4667 echo "~^ attachment remove .tattach"; read es;\
4668 vput vexpr es substr $es 0 3
4669 if [ $es != 506 ]
4670 xcall bail "attach 4-4 $es"
4672 echo "~^attachment remove-at T"; read es;\
4673 vput vexpr es substr $es 0 3
4674 if [ $es != 505 ]
4675 xcall bail "attach 4-5"
4677 echo "~^attachment remove ./.tattach"; read es;\
4678 call xerr $es "attach 4-6"
4679 echo "~^attachment remove ./.tattach"; read es;\
4680 call xerr $es "attach 4-7"
4681 echo "~^ attachment remove ./.tattach"; read es;\
4682 vput vexpr es substr $es 0 3
4683 if [ $es != 501 ]
4684 xcall bail "attach 4-8 $es"
4686 echo "~^attachment list"; read es;\
4687 vput vexpr es substr $es 0 3
4688 if [ $es != 501 ]
4689 xcall bail "attach 4-9"
4693 echo "~^attachment insert ./.tattach=latin1";\
4694 read hl; echo $hl; call xerr "$hl" "attach 5-1"
4695 echo "~^attachment insert ./.tattach=latin1";\
4696 read hl; echo $hl; call xerr "$hl" "attach 5-2"
4697 echo "~^attachment insert ./.tattach=latin1";\
4698 read hl; echo $hl; call xerr "$hl" "attach 5-3"
4699 echo "~^attachment list";\
4700 read es; echo $es;call xerr "$es" "attach 5-4"
4701 call read_mline_res
4703 echo "~^attachment remove-at 3"; read es;\
4704 call xerr $es "attach 5-5"
4705 echo "~^attachment remove-at 3"; read es;\
4706 vput vexpr es substr $es 0 3
4707 if [ $es != 501 ]
4708 xcall bail "attach 5-6"
4710 echo "~^attachment remove-at 2"; read es;\
4711 call xerr $es "attach 5-7"
4712 echo "~^attachment remove-at 2"; read es;\
4713 vput vexpr es substr $es 0 3
4714 if [ $es != 501 ]
4715 xcall bail "attach 5-8"
4717 echo "~^attachment remove-at 1"; read es;\
4718 call xerr $es "attach 5-9"
4719 echo "~^attachment remove-at 1"; read es;\
4720 vput vexpr es substr $es 0 3
4721 if [ $es != 501 ]
4722 xcall bail "attach 5-10"
4725 echo "~^attachment list"; read es;\
4726 vput vexpr es substr $es 0 3
4727 if [ $es != 501 ]
4728 xcall bail "attach 5-11"
4732 echo "~^attachment insert ./.tattach=latin1";\
4733 read hl; echo $hl; call xerr "$hl" "attach 6-1"
4734 echo "~^attachment insert ./.tattach=latin1";\
4735 read hl; echo $hl; call xerr "$hl" "attach 6-2"
4736 echo "~^attachment insert ./.tattach=latin1";\
4737 read hl; echo $hl; call xerr "$hl" "attach 6-3"
4738 echo "~^attachment list";\
4739 read es; echo $es;call xerr "$es" "attach 6-4"
4740 call read_mline_res
4742 echo "~^attachment remove-at 1"; read es;\
4743 call xerr $es "attach 6-5"
4744 echo "~^attachment remove-at 1"; read es;\
4745 call xerr $es "attach 6-6"
4746 echo "~^attachment remove-at 1"; read es;\
4747 call xerr $es "attach 6-7"
4748 echo "~^attachment remove-at 1"; read es;\
4749 vput vexpr es substr $es 0 3
4750 if [ $es != 501 ]
4751 xcall bail "attach 6-8"
4754 echo "~^attachment list"; read es;\
4755 vput vexpr es substr $es 0 3
4756 if [ $es != 501 ]
4757 xcall bail "attach 6-9"
4760 echo t_attach LEAVE
4762 define t_ocs {
4763 read ver
4764 echo t_ocs
4765 call t_header
4766 call t_attach
4768 define t_oce {
4769 echo on-compose-enter, mailx-command<$mailx-command>
4770 alternates alter1@exam.ple alter2@exam.ple
4771 alternates
4772 set autocc='alter1@exam.ple alter2@exam.ple'
4773 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
4774 echo mailx-subject<$mailx-subject>
4775 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
4776 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
4777 mailx-raw-bcc<$mailx-raw-bcc>
4778 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
4779 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
4781 define t_ocl {
4782 echo on-compose-leave, mailx-command<$mailx-command>
4783 vput alternates al
4784 eval alternates $al alter3@exam.ple alter4@exam.ple
4785 alternates
4786 set autobcc='alter3@exam.ple alter4@exam.ple'
4787 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
4788 echo mailx-subject<$mailx-subject>
4789 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
4790 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
4791 mailx-raw-bcc<$mailx-raw-bcc>
4792 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
4793 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
4795 define t_occ {
4796 echo on-compose-cleanup, mailx-command<$mailx-command>
4797 unalternates *
4798 alternates
4799 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
4800 echo mailx-subject<$mailx-subject>
4801 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
4802 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
4803 mailx-raw-bcc<$mailx-raw-bcc>
4804 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
4805 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
4807 wysh set on-compose-splice=t_ocs \
4808 on-compose-enter=t_oce on-compose-leave=t_ocl \
4809 on-compose-cleanup=t_occ
4810 __EOT__
4812 printf 'm this-goes@nowhere\nbody\n!.\n' |
4813 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
4814 -X'source ./.trc' -Smta=./.tmta.sh \
4815 >./.tall 2>&1
4816 ${cat} ./.tall >> "${MBOX}"
4817 check 1 0 "${MBOX}" '2481823179 10101'
4819 ${rm} "${MBOX}"
4820 printf 'm this-goes@nowhere\nbody\n!.\n' |
4821 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
4822 -St_remove=1 -X'source ./.trc' -Smta=./.tmta.sh \
4823 >./.tall 2>&1
4824 ${cat} ./.tall >> "${MBOX}"
4825 check 2 0 "${MBOX}" '3654000499 12535'
4829 # Some state machine stress, shell compose hook, localopts for hook, etc.
4830 # readctl in child. ~r as HERE document
4831 ${rm} "${MBOX}"
4832 printf 'm ex@am.ple\nbody\n!.
4833 echon ${mailx-command}${mailx-subject}
4834 echon ${mailx-from}${mailx-sender}
4835 echon ${mailx-to}${mailx-cc}${mailx-bcc}
4836 echon ${mailx-raw-to}${mailx-raw-cc}${mailx-raw-bcc}
4837 echon ${mailx-orig-from}${mailx-orig-to}${mailx-orig-gcc}${mailx-orig-bcc}
4838 var t_oce t_ocs t_ocs_sh t_ocl t_occ autocc
4839 ' | ${MAILX} ${ARGS} -Snomemdebug -Sescape=! \
4840 -Smta=./.tmta.sh \
4842 define bail {
4843 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
4845 define xerr {
4846 vput vexpr es substr "$1" 0 1
4847 if [ "$es" != 2 ]
4848 xcall bail "$2"
4851 define read_mline_res {
4852 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
4853 echo $len/$es/$^ERRNAME: $hl
4854 if [ $es -ne $^ERR-NONE ]
4855 xcall bail read_mline_res
4856 elif [ $len -ne 0 ]
4857 \xcall read_mline_res
4860 define _work {
4861 vput vexpr i + 1 "$2"
4862 if [ $i -lt 111 ]
4863 vput vexpr j % $i 10
4864 if [ $j -ne 0 ]
4865 set j=xcall
4866 else
4867 echon "$i.. "
4868 set j=call
4870 eval \\$j _work $1 $i
4871 return $?
4873 vput vexpr i + $i "$1"
4874 return $i
4876 define _read {
4877 wysh set line; read line;wysh set es=$? en=$^ERRNAME ;\
4878 echo read:$es/$en: $line
4879 if [ "${es}" -ne -1 ]
4880 xcall _read
4882 readctl remove $cwd/.treadctl; echo readctl remove:$?/$^ERRNAME
4884 define t_ocs {
4885 read ver
4886 echo t_ocs
4887 echo "~^header list"; read hl; echo $hl;\
4888 vput vexpr es substr "$hl" 0 1
4889 if [ "$es" != 2 ]
4890 xcall bail "header list"
4891 endif
4893 call _work 1; echo $?
4894 echo "~^header insert cc splicy diet <splice@exam.ple> spliced";\
4895 read es; echo $es; vput vexpr es substr "$es" 0 1
4896 if [ "$es" != 2 ]
4897 xcall bail "be diet"
4898 endif
4899 echo "~^header insert cc <splice2@exam.ple>";\
4900 read es; echo $es; vput vexpr es substr "$es" 0 1
4901 if [ "$es" != 2 ]
4902 xcall bail "be diet2"
4903 endif
4905 call _work 2; echo $?
4906 echo "~^header insert bcc juicy juice <juice@exam.ple> spliced";\
4907 read es; echo $es;vput vexpr es substr "$es" 0 1
4908 if [ "$es" != 2 ]
4909 xcall bail "be juicy"
4910 endif
4911 echo "~^header insert bcc juice2@exam.ple";\
4912 read es; echo $es;vput vexpr es substr "$es" 0 1
4913 if [ "$es" != 2 ]
4914 xcall bail "be juicy2"
4915 endif
4916 echo "~^header insert bcc juice3 <juice3@exam.ple>";\
4917 read es; echo $es;vput vexpr es substr "$es" 0 1
4918 if [ "$es" != 2 ]
4919 xcall bail "be juicy3"
4920 endif
4921 echo "~^header insert bcc juice4@exam.ple";\
4922 read es; echo $es;vput vexpr es substr "$es" 0 1
4923 if [ "$es" != 2 ]
4924 xcall bail "be juicy4"
4925 endif
4927 echo "~^header remove-at bcc 3";\
4928 read es; echo $es;vput vexpr es substr "$es" 0 1
4929 if [ "$es" != 2 ]
4930 xcall bail "remove juicy5"
4931 endif
4932 echo "~^header remove-at bcc 2";\
4933 read es; echo $es;vput vexpr es substr "$es" 0 1
4934 if [ "$es" != 2 ]
4935 xcall bail "remove juicy6"
4936 endif
4937 echo "~^header remove-at bcc 3";\
4938 read es; echo $es;vput vexpr es substr "$es" 0 3
4939 if [ "$es" != 501 ]
4940 xcall bail "failed to remove-at"
4941 endif
4942 # Add duplicates which ought to be removed!
4943 echo "~^header insert bcc juice4@exam.ple";\
4944 read es; echo $es;vput vexpr es substr "$es" 0 1
4945 if [ "$es" != 2 ]
4946 xcall bail "be juicy4-1"
4947 endif
4948 echo "~^header insert bcc juice4@exam.ple";\
4949 read es; echo $es;vput vexpr es substr "$es" 0 1
4950 if [ "$es" != 2 ]
4951 xcall bail "be juicy4-2"
4952 endif
4953 echo "~^header insert bcc juice4@exam.ple";\
4954 read es; echo $es;vput vexpr es substr "$es" 0 1
4955 if [ "$es" != 2 ]
4956 xcall bail "be juicy4-3"
4957 endif
4958 echo "~:set t_ocs"
4961 call _work 3; echo $?
4962 echo "~r - '__EOT'"
4963 vput ! i echo just knock if you can hear me;\
4964 i=0;\
4965 while [ $i -lt 24 ]; do printf "%s " $i; i=`expr $i + 1`; done;\
4966 echo relax
4967 echon shell-cmd says $?/$^ERRNAME: $i
4968 echo "~x will not become interpreted, we are reading until __EOT"
4969 echo "__EOT"
4970 read r_status; echo "~~r status output: $r_status"
4971 echo "~:echo $? $! $^ERRNAME"
4972 read r_status
4973 echo "~~r status from parent: $r_status"
4976 call _work 4; echo $?
4977 vput cwd cwd;echo cwd:$?
4978 readctl create $cwd/.treadctl ;echo readctl:$?/$^ERRNAME;\
4979 call _read
4982 call _work 5; echo $?
4983 echo "~^header show MAILX-Command"; read es;\
4984 call xerr $es "t_header 1000"; call read_mline_res
4985 echo "~^header show MAILX-raw-TO"; read es;\
4986 call xerr $es "t_header 1001"; xcall read_mline_res
4988 echoerr IT IS WRONG IF YOU SEE THIS
4990 define t_oce {
4991 echo on-compose-enter, mailx-command<$mailx-command>
4992 set t_oce autobcc=oce@exam.ple
4993 alternates alter1@exam.ple alter2@exam.ple
4994 alternates
4995 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
4996 echo mailx-subject<$mailx-subject>
4997 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
4998 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
4999 mailx-raw-bcc<$mailx-raw-bcc>
5000 echo mailx-orig-from<$mailx-orig-from> \
5001 mailx-orig-to<$mailx-orig-to> \
5002 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
5004 define t_ocl {
5005 echo on-compose-leave, mailx-command<$mailx-command>
5006 set t_ocl autocc=ocl@exam.ple
5007 unalternates *
5008 alternates alter3@exam.ple alter4@exam.ple
5009 alternates
5010 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
5011 echo mailx-subject<$mailx-subject>
5012 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
5013 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
5014 mailx-raw-bcc<$mailx-raw-bcc>
5015 echo mailx-orig-from<$mailx-orig-from> \
5016 mailx-orig-to<$mailx-orig-to> \
5017 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
5019 define t_occ {
5020 echo on-compose-cleanup, mailx-command<$mailx-command>
5021 set t_occ autocc=occ@exam.ple
5022 unalternates *
5023 alternates
5024 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
5025 echo mailx-subject<$mailx-subject>
5026 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
5027 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
5028 mailx-raw-bcc<$mailx-raw-bcc>
5029 echo mailx-orig-from<$mailx-orig-from> \
5030 mailx-orig-to<$mailx-orig-to> \
5031 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
5033 wysh set on-compose-splice=t_ocs \
5034 on-compose-splice-shell="read ver;echo t_ocs-shell;\
5035 echo \"~t shell@exam.ple\"; echo \"~:set t_ocs_sh\"" \
5036 on-compose-enter=t_oce on-compose-leave=t_ocl \
5037 on-compose-cleanup=t_occ
5038 ' > ./.tnotes 2>&1
5039 check_ex0 3-estat
5040 ${cat} ./.tnotes >> "${MBOX}"
5041 check 3 - "${MBOX}" '679526364 2431'
5043 # Reply, forward, resend, Resend
5045 ${rm} "${MBOX}"
5046 printf '#
5047 set from="f1@z
5048 m t1@z
5051 set from="du <f2@z>" stealthmua=noagent
5052 m t2@z
5055 ' | ${MAILX} ${ARGS} -Smta=./.tmta.sh -Snomemdebug -Sescape=!
5057 printf '
5058 echo start: $? $! $^ERRNAME
5059 File %s
5060 echo File: $? $! $^ERRNAME;echo;echo
5061 reply 1
5062 this is content of reply 1
5064 echo reply 1: $? $! $^ERRNAME;echo;echo
5065 Reply 1 2
5066 this is content of Reply 1 2
5068 echo Reply 1 2: $? $! $^ERRNAME;echo;echo
5069 forward 1 fwdex@am.ple
5070 this is content of forward 1
5072 echo forward 1: $? $! $^ERRNAME;echo;echo
5073 wysh set forward-inject-head=$'"'"'-- \\
5074 forward (%%a)(%%d)(%%f)(%%i)(%%n)(%%r) --\\n'"'"'
5075 wysh set forward-inject-tail=$'"'"'-- \\
5076 end of forward (%%i) --\\n'"'"'
5077 forward 2 fwdex@am.ple
5078 this is content of forward 2
5080 echo forward 2: $? $! $^ERRNAME;echo;echo
5081 set showname
5082 forward 2 fwdex2@am.ple
5083 this is content of forward 2, 2nd, with showname set
5085 echo forward 2, 2nd: $? $! $^ERRNAME;echo;echo
5086 resend 1 2 resendex@am.ple
5087 echo resend 1 2: $? $! $^ERRNAME;echo;echo
5088 Resend 1 2 Resendex@am.ple
5089 echo Resend 1 2: $? $! $^ERRNAME;echo;echo
5090 ' "${MBOX}" |
5091 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sfullnames \
5092 -Smta=./.tmta.sh \
5094 define bail {
5095 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
5097 define xerr {
5098 vput vexpr es substr "$1" 0 1
5099 if [ "$es" != 2 ]
5100 xcall bail "$2"
5103 define read_mline_res {
5104 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
5105 echo mline_res:$len/$es/$^ERRNAME: $hl
5106 if [ $es -ne $^ERR-NONE ]
5107 xcall bail read_mline_res
5108 elif [ $len -ne 0 ]
5109 \xcall read_mline_res
5112 define work_hl {
5113 echo "~^header show $1"; read es;\
5114 call xerr $es "work_hl $1"; echo $1; call read_mline_res
5115 if [ $# -gt 1 ]
5116 shift
5117 xcall work_hl "$@"
5120 define t_ocs {
5121 read ver
5122 echo t_ocs version $ver
5123 echo "~^header list"; read hl; echo $hl;\
5124 echoerr the header list is $hl;\
5125 call xerr "$hl" "header list"
5126 eval vpospar set $hl
5127 shift
5128 xcall work_hl "$@"
5129 echoerr IT IS WRONG IF YOU SEE THIS
5131 define t_oce {
5132 echo on-XY-enter, mailx-command<$mailx-command>
5133 set t_oce autobcc=oce@exam.ple
5134 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
5135 echo mailx-subject<$mailx-subject>
5136 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
5137 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
5138 mailx-raw-bcc<$mailx-raw-bcc>
5139 echo mailx-orig-from<$mailx-orig-from> \
5140 mailx-orig-to<$mailx-orig-to> \
5141 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
5143 define t_ocl {
5144 echo on-XY-leave, mailx-command<$mailx-command>
5145 set t_ocl autocc=ocl@exam.ple
5146 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
5147 echo mailx-subject<$mailx-subject>
5148 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
5149 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
5150 mailx-raw-bcc<$mailx-raw-bcc>
5151 echo mailx-orig-from<$mailx-orig-from> \
5152 mailx-orig-to<$mailx-orig-to> \
5153 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
5155 define t_occ {
5156 echo on-XY-cleanup, mailx-command<$mailx-command>
5157 set t_occ autocc=occ@exam.ple
5158 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
5159 echo mailx-subject<$mailx-subject>
5160 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
5161 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
5162 mailx-raw-bcc<$mailx-raw-bcc>
5163 echo mailx-orig-from<$mailx-orig-from> \
5164 mailx-orig-to<$mailx-orig-to> \
5165 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
5167 wysh set on-compose-splice=t_ocs \
5168 on-compose-enter=t_oce on-compose-leave=t_ocl \
5169 on-compose-cleanup=t_occ \
5170 on-resend-enter=t_oce on-resend-cleanup=t_occ
5171 ' > ./.tnotes 2>&1
5172 check_ex0 4-estat
5173 ${cat} ./.tnotes >> "${MBOX}"
5174 check 4 - "${MBOX}" '2151712038 11184'
5176 t_epilog
5177 } # }}}
5179 t_mass_recipients() {
5180 t_prolog mass_recipients
5181 TRAP_EXIT_ADDONS="./.t*"
5183 t_xmta 'Eucalyptus Sat Jul 08 21:14:57 2017'
5185 ${cat} <<'__EOT__' > ./.trc
5186 define bail {
5187 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
5189 define ins_addr {
5190 wysh set nr=$1 hn=$2
5191 echo "~$hn $hn$nr@$hn"; echo '~:echo $?'; read es
5192 if [ "$es" -ne 0 ]
5193 xcall bail "ins_addr $hn 1-$nr"
5195 vput vexpr nr + $nr 1
5196 if [ "$nr" -le "$maximum" ]
5197 xcall ins_addr $nr $hn
5200 define bld_alter {
5201 wysh set nr=$1 hn=$2
5202 alternates $hn$nr@$hn
5203 vput vexpr nr + $nr 2
5204 if [ "$nr" -le "$maximum" ]
5205 xcall bld_alter $nr $hn
5208 define t_ocs {
5209 read ver
5210 call ins_addr 1 t
5211 call ins_addr 1 c
5212 call ins_addr 1 b
5214 define t_ocl {
5215 if [ "$t_remove" != '' ]
5216 call bld_alter 1 t
5217 call bld_alter 2 c
5220 set on-compose-splice=t_ocs on-compose-leave=t_ocl
5221 __EOT__
5223 printf 'm this-goes@nowhere\nbody\n!.\n' |
5224 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
5225 -X'source ./.trc' -Smta=./.tmta.sh -Smaximum=2001 \
5226 >./.tall 2>&1
5227 check_ex0 1-estat
5228 ${cat} ./.tall >> "${MBOX}"
5229 check 1 - "${MBOX}" '2912243346 51526'
5231 ${rm} "${MBOX}"
5232 printf 'm this-goes@nowhere\nbody\n!.\n' |
5233 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
5234 -St_remove=1 -X'source ./.trc' -Smta=./.tmta.sh -Smaximum=2001 \
5235 >./.tall 2>&1
5236 check_ex0 2-estat
5237 ${cat} ./.tall >> "${MBOX}"
5238 check 2 - "${MBOX}" '4097804632 34394'
5240 t_epilog
5243 t_lreply_futh_rth_etc() {
5244 t_prolog lreply_futh_rth_etc
5245 TRAP_EXIT_ADDONS="./.t*"
5247 t_xmta 'HumulusLupulus Thu Jul 27 14:41:20 2017'
5249 ${cat} <<-_EOT > ./.tmbox
5250 From neverneverland Sun Jul 23 13:46:25 2017
5251 Subject: Bugstop: five miles out 1
5252 Reply-To: mister originator2 <mr2@originator>, bugstop@five.miles.out
5253 From: mister originator <mr@originator>
5254 To: bugstop-commit@five.miles.out, laber@backe.eu
5255 Cc: is@a.list
5256 Mail-Followup-To: bugstop@five.miles.out, laber@backe.eu, is@a.list
5257 In-reply-to: <20170719111113.bkcMz%laber@backe.eu>
5258 Date: Wed, 19 Jul 2017 09:22:57 -0400
5259 Message-Id: <20170719132257.766AF781267@originator>
5260 Status: RO
5262 > |Sorry, I think I misunderstand something. I would think that
5264 That's appalling.
5266 From neverneverland Fri Jul 7 22:39:11 2017
5267 Subject: Bugstop: five miles out 2
5268 Reply-To: mister originator2<mr2@originator>,bugstop@five.miles.out,is@a.list
5269 Content-Transfer-Encoding: 7bit
5270 From: mister originator <mr@originator>
5271 To: bugstop-commit@five.miles.out
5272 Cc: is@a.list
5273 Message-ID: <149945963975.28888.6950788126957753723.reportbug@five.miles.out>
5274 Date: Fri, 07 Jul 2017 16:33:59 -0400
5275 Status: R
5277 capable of changing back.
5279 From neverneverland Fri Jul 7 22:42:00 2017
5280 Subject: Bugstop: five miles out 3
5281 Reply-To: mister originator2 <mr2@originator>, bugstop@five.miles.out
5282 Content-Transfer-Encoding: 7bit
5283 From: mister originator <mr@originator>
5284 To: bugstop-commit@five.miles.out
5285 Cc: is@a.list
5286 Message-ID: <149945963975.28888.6950788126957753746.reportbug@five.miles.out>
5287 Date: Fri, 07 Jul 2017 16:33:59 -0400
5288 List-Post: <mailto:bugstop@five.miles.out>
5289 Status: R
5291 are you ready, boots?
5293 From neverneverland Sat Aug 19 23:15:00 2017
5294 Subject: Bugstop: five miles out 4
5295 Reply-To: mister originator2 <mr2@originator>, bugstop@five.miles.out
5296 Content-Transfer-Encoding: 7bit
5297 From: mister originator <mr@originator>
5298 To: bugstop@five.miles.out
5299 Cc: is@a.list
5300 Message-ID: <149945963975.28888.6950788126qtewrqwer.reportbug@five.miles.out>
5301 Date: Fri, 07 Jul 2017 16:33:59 -0400
5302 List-Post: <mailto:bugstop@five.miles.out>
5303 Status: R
5305 are you ready, boots?
5306 _EOT
5310 ${cat} <<-'_EOT' | ${MAILX} ${ARGS} -Sescape=! -Smta=./.tmta.sh \
5311 -Rf ./.tmbox >> "${MBOX}" 2>&1
5312 define r {
5313 wysh set m="This is text of \"reply ${1}."
5314 reply 1 2 3
5315 !I m
5318 !I m
5321 !I m
5324 echo -----After reply $1.1 - $1.3: $?/$^ERRNAME
5326 define R {
5327 wysh set m="This is text of \"Reply ${1}."
5328 eval Reply $2
5329 !I m
5330 !I 2
5333 echo -----After Reply $1.$2: $?/$^ERRNAME
5335 define _Lh {
5336 read protover
5337 echo '~I m'
5338 echo '~I n'
5339 echo '".'
5341 define _Ls {
5342 wysh set m="This is text of \"Lreply ${1}." on-compose-splice=_Lh n=$2
5343 eval Lreply $2
5345 define L {
5346 # We need two indirections for this test: one for the case that Lreply
5347 # fails because of missing recipients: we need to read EOF next, thus
5348 # place this in _Ls last; and second for the succeeding cases EOF is
5349 # not what these should read, so go over the backside and splice it in!
5350 call _Ls "$@"
5351 echo -----After Lreply $1.$2: $?/$^ERRNAME
5353 define x {
5354 localopts call-fixate yes
5355 call r $1
5356 call R $1 1; call R $1 2; call R $1 3; call R $1 4
5357 call L $1 1; call L $1 2; call L $1 3
5359 define tweak {
5360 echo;echo '===== CHANGING === '"$*"' =====';echo
5361 eval "$@"
5364 set from=laber@backe.eu
5365 mlist is@a.list
5366 call x 1
5367 call tweak set reply-to-honour
5368 call x 2
5369 call tweak set followup-to
5370 call x 3
5371 call tweak set followup-to-honour
5372 call x 4
5373 call tweak mlist bugstop@five.miles.out
5374 call x 5
5375 call tweak mlsubscribe bugstop@five.miles.out
5376 call x 6
5377 call tweak set recipients-in-cc
5378 call x 7
5379 # While here, test that *fullnames* works (also here)
5380 set fullnames
5381 reply 1
5382 This message should have *fullnames* in the header.
5384 _EOT
5386 check_ex0 1-estat
5387 if have_feat uistrings; then
5388 check 1 - "${MBOX}" '1530821219 29859'
5389 else
5390 echo 'lreply_futh_rth_etc-1: content test unsupported, skipped'
5395 ${cat} <<-_EOT > ./.tmbox
5396 From tom@i-i.example Thu Oct 26 03:15:55 2017
5397 Date: Wed, 25 Oct 2017 21:15:46 -0400
5398 From: tom <tom@i-i.example>
5399 To: Steffen Nurpmeso <steffen@sdaoden.eu>
5400 Cc: tom <tom@i-i.example>
5401 Subject: Re: xxxx yyyyyyyy configure does not really like a missing zzzzz
5402 Message-ID: <20171026011546.GA11643@i-i.example>
5403 Reply-To: tom@i-i.example
5404 References: <20171025214601.T2pNd%steffen@sdaoden.eu>
5405 In-Reply-To: <20171025214601.T2pNd%steffen@sdaoden.eu>
5406 Status: R
5408 The report's useful :-)
5409 _EOT
5411 # Let us test In-Reply-To: removal starts a new thread..
5412 # This needs adjustment of *stealthmua*
5413 argadd='-Sstealthmua=noagent -Shostname'
5415 ${rm} "${MBOX}"
5416 printf 'reply 1\nthread\n!.\n' |
5417 ${MAILX} ${ARGS} -Sescape=! -Smta=./.tmta.sh -Sreply-to-honour \
5418 ${argadd} -Rf ./.tmbox > .tall 2>&1
5419 check 2 0 "${MBOX}" '3321764338 429'
5420 check 3 - .tall '4294967295 0'
5422 printf 'reply 1\nnew <- thread!\n!||%s -e "%s"\n!.\n' \
5423 "${sed}" '/^In-Reply-To:/d' |
5424 ${MAILX} ${ARGS} -Sescape=! -Smta=./.tmta.sh -Sreply-to-honour \
5425 ${argadd} -Rf "${MBOX}" > .tall 2>&1
5426 check 4 0 "${MBOX}" '1682552516 763'
5427 check 5 - .tall '4294967295 0'
5429 printf 'reply 2\nold <- new <- thread!\n!.\n' |
5430 ${MAILX} ${ARGS} -Sescape=! -Smta=./.tmta.sh -Sreply-to-honour \
5431 ${argadd} -Rf "${MBOX}" > .tall 2>&1
5432 check 6 0 "${MBOX}" '2900984135 1219'
5433 check 7 - .tall '4294967295 0'
5435 printf 'reply 3\nnew <- old <- new <- thread!\n!|| %s -e "%s"\n!.\n' \
5436 "${sed}" '/^In-Reply-To:/d' |
5437 ${MAILX} ${ARGS} -Sescape=! -Smta=./.tmta.sh -Sreply-to-honour \
5438 ${argadd} -Rf "${MBOX}" > .tall 2>&1
5439 check 8 0 "${MBOX}" '794031200 1567'
5440 check 9 - .tall '4294967295 0'
5442 t_epilog
5444 # }}}
5446 # Rest {{{
5447 t_s_mime() {
5448 have_feat smime || {
5449 echo 's_mime: unsupported, skipped'
5450 return
5453 t_prolog s_mime
5454 TRAP_EXIT_ADDONS="./.t.conf ./.tkey.pem ./.tcert.pem ./.tpair.pem"
5455 TRAP_EXIT_ADDONS="${TRAP_EXIT_ADDONS} ./.VERIFY ./.DECRYPT ./.ENCRYPT"
5456 TRAP_EXIT_ADDONS="${TRAP_EXIT_ADDONS} ./.tmta.sh"
5458 ${cat} <<-_EOT > ./.t.conf
5459 [ req ]
5460 default_bits = 1024
5461 default_keyfile = keyfile.pem
5462 distinguished_name = req_distinguished_name
5463 attributes = req_attributes
5464 prompt = no
5465 output_password =
5467 [ req_distinguished_name ]
5468 C = GB
5469 ST = Over the
5470 L = rainbow
5471 O = S-nail
5472 OU = S-nail.smime
5473 CN = S-nail.test
5474 emailAddress = test@localhost
5476 [ req_attributes ]
5477 challengePassword =
5478 _EOT
5479 openssl req -x509 -nodes -days 3650 -config ./.t.conf \
5480 -newkey rsa:1024 -keyout ./.tkey.pem -out ./.tcert.pem >>${ERR} 2>&1
5481 check_ex0 0
5482 ${cat} ./.tkey.pem ./.tcert.pem > ./.tpair.pem
5484 # Sign/verify
5485 echo bla | ${MAILX} ${ARGS} \
5486 -Ssmime-sign -Ssmime-sign-cert=./.tpair.pem -Sfrom=test@localhost \
5487 -Ssmime-sign-digest=sha1 \
5488 -s 'S/MIME test' ./.VERIFY
5489 check_ex0 1-estat
5490 ${awk} '
5491 BEGIN{ skip=0 }
5492 /^Content-Description: /{ skip = 2; print; next }
5493 /^$/{ if(skip) --skip }
5494 { if(!skip) print }
5496 < ./.VERIFY > "${MBOX}"
5497 check 1 - "${MBOX}" '335634014 644'
5499 printf 'verify\nx\n' |
5500 ${MAILX} ${ARGS} -Ssmime-ca-file=./.tcert.pem -Serrexit \
5501 -R -f ./.VERIFY >>${ERR} 2>&1
5502 check_ex0 2
5504 openssl smime -verify -CAfile ./.tcert.pem -in ./.VERIFY >>${ERR} 2>&1
5505 check_ex0 3
5507 # (signing +) encryption / decryption
5508 t_xmta 'Euphrasia Thu Apr 27 17:56:23 2017' ./.ENCRYPT
5510 echo bla |
5511 ${MAILX} ${ARGS} \
5512 -Smta=./.tmta.sh \
5513 -Ssmime-force-encryption -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
5514 -Ssmime-sign-digest=sha1 \
5515 -Ssmime-sign -Ssmime-sign-cert=./.tpair.pem -Sfrom=test@localhost \
5516 -s 'S/MIME test' recei@ver.com
5517 check_ex0 4-estat
5518 ${sed} -e '/^$/,$d' < ./.ENCRYPT > "${MBOX}"
5519 check 4 - "${MBOX}" '1937410597 327'
5521 printf 'decrypt ./.DECRYPT\nfi ./.DECRYPT\nverify\nx\n' |
5522 ${MAILX} ${ARGS} \
5523 -Smta=./.tmta.sh \
5524 -Ssmime-ca-file=./.tcert.pem \
5525 -Ssmime-sign-cert=./.tpair.pem \
5526 -Serrexit -R -f ./.ENCRYPT >>${ERR} 2>&1
5527 check_ex0 5-estat
5528 ${awk} '
5529 BEGIN{ skip=0 }
5530 /^Content-Description: /{ skip = 2; print; next }
5531 /^$/{ if(skip) --skip }
5532 { if(!skip) print }
5534 < ./.DECRYPT > "${MBOX}"
5535 check 5 - "${MBOX}" '1019076159 931'
5537 (openssl smime -decrypt -inkey ./.tkey.pem -in ./.ENCRYPT |
5538 openssl smime -verify -CAfile ./.tcert.pem) >>${ERR} 2>&1
5539 check_ex0 6
5541 ${rm} ./.ENCRYPT
5542 echo bla | ${MAILX} ${ARGS} \
5543 -Smta=./.tmta.sh \
5544 -Ssmime-force-encryption -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
5545 -Sfrom=test@localhost \
5546 -s 'S/MIME test' recei@ver.com
5547 check_ex0 7-estat
5548 ${sed} -e '/^$/,$d' < ./.ENCRYPT > "${MBOX}"
5549 check 7 - "${MBOX}" '1937410597 327'
5551 ${rm} ./.DECRYPT
5552 printf 'decrypt ./.DECRYPT\nx\n' | ${MAILX} ${ARGS} \
5553 -Smta=./.tmta.sh \
5554 -Ssmime-sign-cert=./.tpair.pem \
5555 -Serrexit -R -f ./.ENCRYPT >>${ERR} 2>&1
5556 check 8 0 "./.DECRYPT" '2624716890 422'
5558 openssl smime -decrypt -inkey ./.tkey.pem \
5559 -in ./.ENCRYPT >>${ERR} 2>&1
5560 check_ex0 9
5562 t_epilog
5564 # }}}
5566 # xxx Note: t_z() was the first test (series) written. Today many
5567 # xxx aspects are (better) covered by other tests above, some are not.
5568 # xxx At some future date and time, convert the last remains not covered
5569 # xxx elsewhere to a real t_* test and drop it
5570 t_z() {
5571 t_prolog z
5573 # Test for [260e19d] (Juergen Daubert)
5574 echo body | ${MAILX} ${ARGS} "${MBOX}"
5575 check 4 0 "${MBOX}" '2948857341 94'
5577 # "Test for" [d6f316a] (Gavin Troy)
5578 ${rm} "${MBOX}"
5579 printf "m ${MBOX}\n~s subject1\nEmail body\n~.\nfi ${MBOX}\np\nx\n" |
5580 ${MAILX} ${ARGS} ${ADDARG_UNI} -Spipe-text/plain="@* ${cat}" > "${BODY}"
5581 check 6 0 "${MBOX}" '3942990636 118'
5582 check 6-1 - "${BODY}" '3951695530 170'
5584 # "Test for" [c299c45] (Peter Hofmann) TODO shouldn't end up QP-encoded?
5585 ${rm} "${MBOX}"
5586 ${awk} 'BEGIN{
5587 for(i = 0; i < 10000; ++i)
5588 printf "\xC3\xBC"
5589 #printf "\xF0\x90\x87\x90"
5590 }' | ${MAILX} ${ARGS} ${ADDARG_UNI} -s TestSubject "${MBOX}"
5591 check 7 0 "${MBOX}" '1707496413 61812'
5593 t_epilog
5596 t__put_subject() {
5597 # MIME encoding (QP) stress message subject
5598 printf 'Äbrä Kä?dä=brö Fü?di=bus? '\
5599 'adadaddsssssssddddddddddddddddddddd'\
5600 'ddddddddddddddddddddddddddddddddddd'\
5601 'ddddddddddddddddddddddddddddddddddd'\
5602 'dddddddddddddddddddd Hallelulja? Od'\
5603 'er?? eeeeeeeeeeeeeeeeeeeeeeeeeeeeee'\
5604 'eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'\
5605 'eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee f'\
5606 'fffffffffffffffffffffffffffffffffff'\
5607 'fffffffffffffffffffff ggggggggggggg'\
5608 'ggggggggggggggggggggggggggggggggggg'\
5609 'ggggggggggggggggggggggggggggggggggg'\
5610 'ggggggggggggggggggggggggggggggggggg'\
5611 'gggggggggggggggg'
5614 t__put_body() {
5615 # MIME encoding (QP) stress message body
5616 printf \
5617 'Ich bin eine DÖS-Datäi mit sehr langen Zeilen und auch '\
5618 'sonst bin ich ganz schön am Schleudern, da kannste denke '\
5619 "wasde willst, gelle, gelle, gelle, gelle, gelle.\r\n"\
5620 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst \r\n"\
5621 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1\r\n"\
5622 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12\r\n"\
5623 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123\r\n"\
5624 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1234\r\n"\
5625 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12345\r\n"\
5626 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123456\r\n"\
5627 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1234567\r\n"\
5628 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12345678\r\n"\
5629 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123456789\r\n"\
5630 "Unn ausserdem habe ich trailing SP/HT/SP/HT whitespace \r\n"\
5631 "Unn ausserdem habe ich trailing HT/SP/HT/SP whitespace \r\n"\
5632 "auf den zeilen vorher.\r\n"\
5633 "From am Zeilenbeginn und From der Mitte gibt es auch.\r\n"\
5634 ".\r\n"\
5635 "Die letzte Zeile war nur ein Punkt.\r\n"\
5636 "..\r\n"\
5637 "Das waren deren zwei.\r\n"\
5638 " \r\n"\
5639 "Die letzte Zeile war ein Leerschritt.\n"\
5640 "=VIER = EQUAL SIGNS=ON A LINE=\r\n"\
5641 "Prösterchen.\r\n"\
5642 ".\n"\
5643 "Die letzte Zeile war nur ein Punkt, mit Unix Zeilenende.\n"\
5644 "..\n"\
5645 "Das waren deren zwei. ditto.\n"\
5646 "Prösterchen.\n"\
5647 "Unn ausseerdem habe ich trailing SP/HT/SP/HT whitespace \n"\
5648 "Unn ausseerdem habe ich trailing HT/SP/HT/SP whitespace \n"\
5649 "auf den zeilen vorher.\n"\
5650 "ditto.\n"\
5651 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.\n"\
5652 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.1"\
5653 "\n"\
5654 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
5655 "\n"\
5656 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
5657 "3\n"\
5658 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
5659 "34\n"\
5660 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
5661 "345\n"\
5662 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
5663 "3456\n"\
5664 "QP am Zeilenende über soft-nl hinweg\n"\
5665 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
5666 "ö123\n"\
5667 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
5668 "1ö23\n"\
5669 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
5670 "12ö3\n"\
5671 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
5672 "123ö\n"\
5673 "=VIER = EQUAL SIGNS=ON A LINE=\n"\
5674 " \n"\
5675 "Die letzte Zeile war ein Leerschritt.\n"\
5679 # cc_all_configs()
5680 # Test all configs TODO doesn't cover all *combinations*, stupid!
5681 cc_all_configs() {
5682 < ${CONF} ${awk} '
5683 BEGIN{
5684 ALWAYS = "OPT_AUTOCC=1 OPT_AMALGAMATION=1"
5685 NOTME["OPT_ALWAYS_UNICODE_LOCALE"] = 1
5686 NOTME["OPT_CROSS_BUILD"] = 1
5687 NOTME["OPT_AUTOCC"] = 1
5688 NOTME["OPT_AMALGAMATION"] = 1
5689 NOTME["OPT_DEBUG"] = 1
5690 NOTME["OPT_DEVEL"] = 1
5691 NOTME["OPT_ASAN_ADDRESS"] = 1
5692 NOTME["OPT_ASAN_MEMORY"] = 1
5693 NOTME["OPT_FORCED_STACKPROT"] = 1
5694 NOTME["OPT_NOMEMDBG"] = 1
5695 NOTME["OPT_NYD2"] = 1
5697 #OPTVALS
5698 OPTNO = 0
5700 MULCHOICE["OPT_IDNA"] = "VAL_IDNA"
5701 MULVALS["VAL_IDNA"] = 1
5703 #VALKEYS[0] = "VAL_RANDOM"
5704 VALVALS["VAL_RANDOM"] = 1
5705 VALNO = 0
5707 /^[[:space:]]*OPT_/{
5708 sub(/^[[:space:]]*/, "")
5709 # This bails for UnixWare 7.1.4 awk(1), but preceeding = with \
5710 # does not seem to be a compliant escape for =
5711 #sub(/=.*$/, "")
5712 $1 = substr($1, 1, index($1, "=") - 1)
5713 if(!NOTME[$1])
5714 OPTVALS[OPTNO++] = $1
5715 next
5717 /^[[:space:]]*VAL_/{
5718 sub(/^[[:space:]]*/, "")
5719 val = substr($0, index($0, "=") + 1)
5720 if(val ~ /^\"/){
5721 val = substr(val, 2)
5722 val = substr(val, 1, length(val) - 1)
5724 $1 = substr($1, 1, index($1, "=") - 1)
5725 if(MULVALS[$1])
5726 MULVALS[$1] = val
5727 else if(VALVALS[$1]){
5728 VALKEYS[VALNO++] = $1
5729 VALVALS[$1] = val
5731 next
5733 function onepass(addons){
5734 a_onepass__worker(addons, "1", "0")
5735 a_onepass__worker(addons, "0", "1")
5737 function a_onepass__worker(addons, b0, b1){
5738 # Doing this completely sequentially and not doing make distclean in
5739 # between runs should effectively result in lesser compilations.
5740 # It is completely dumb nonetheless... TODO
5741 for(ono = 0; ono < OPTNO; ++ono){
5742 myconf = mula = ""
5743 for(i = 0; i < ono; ++i){
5744 myconf = myconf " " OPTVALS[i] "=" b0 " "
5745 if(b0 == "1"){
5746 j = MULCHOICE[OPTVALS[i]]
5747 if(j){
5748 if(i + 1 == ono)
5749 mula = j
5750 else
5751 myconf = myconf " " MULCHOICE[OPTVALS[i]] "=any "
5755 for(i = ono; i < OPTNO; ++i){
5756 myconf = myconf " " OPTVALS[i] "=" b1 " "
5757 if(b1 == "1"){
5758 j = MULCHOICE[OPTVALS[i]]
5759 if(j){
5760 if(i + 1 == OPTNO)
5761 mula = j;
5762 else
5763 myconf = myconf " " MULCHOICE[OPTVALS[i]] "=any "
5768 for(i in VALKEYS)
5769 myconf = VALKEYS[i] "=any " myconf
5771 myconf = myconf " " ALWAYS " " addons
5773 if(mula == "")
5774 print myconf
5775 else{
5776 i = split(MULVALS[mula], ia)
5777 j = "any"
5778 while(i >= 1){
5779 j = ia[i--] " " j
5780 print mula "=\"" j "\" " myconf
5785 END{
5786 # We cannot test NULL because of missing UI strings, which will end
5787 # up with different checksums
5788 print "CONFIG=NULLI OPT_AUTOCC=1"
5789 for(i in VALKEYS){
5790 j = split(VALVALS[VALKEYS[i]], ia)
5791 k = "any"
5792 while(j >= 1){
5793 k = ia[j--] " " k
5794 print VALKEYS[i] "=\"" k "\" CONFIG=NULLI OPT_AUTOCC=1"
5797 print "CONFIG=MINIMAL OPT_AUTOCC=1"
5798 print "CONFIG=NETSEND OPT_AUTOCC=1"
5799 print "CONFIG=MAXIMAL OPT_AUTOCC=1"
5800 for(i in VALKEYS){
5801 j = split(VALVALS[VALKEYS[i]], ia)
5802 k = "any"
5803 while(j >= 1){
5804 k = ia[j--] " " k
5805 print VALKEYS[i] "=\"" k "\" CONFIG=MAXIMAL OPT_AUTOCC=1"
5808 print "CONFIG=DEVEL OPT_AUTOCC=1"
5809 print "CONFIG=ODEVEL OPT_AUTOCC=1"
5811 onepass("OPT_DEBUG=1")
5812 onepass("")
5814 ' | while read c; do
5815 [ -f mk-config.h ] && ${cp} mk-config.h .ccac.h
5816 printf "\n\n##########\n$c\n"
5817 printf "\n\n##########\n$c\n" >&2
5818 ${SHELL} -c "cd .. && ${MAKE} ${c} config"
5819 if [ -f .ccac.h ] && ${cmp} mk-config.h .ccac.h; then
5820 printf 'Skipping after config, nothing changed\n'
5821 printf 'Skipping after config, nothing changed\n' >&2
5822 continue
5824 ${SHELL} -c "cd ../ && ${MAKE} build test"
5825 done
5826 ${rm} -f .ccac.h
5827 cd .. && ${MAKE} distclean
5830 [ -n "${ERR}" ] && echo > ${ERR}
5831 if [ -z "${CHECK_ONLY}${MAE_TEST}" ]; then
5832 cc_all_configs
5833 elif [ -z "${MAE_TEST}" ] || [ ${#} -eq 0 ]; then
5834 # if have_feat devel; then
5835 # ARGS="${ARGS} -Smemdebug"
5836 # export ARGS
5837 # fi
5838 t_all
5840 else
5841 while [ ${#} -gt 0 ]; do
5842 eval t_${1}
5843 shift
5844 done
5847 [ ${ESTAT} -eq 0 ] && echo Ok || echo >&2 'Errors occurred'
5849 exit ${ESTAT}
5850 # s-sh-mode