*quote-fold*: add optional third argument to improve break algo
[s-mailx.git] / cc-test.sh
blob1eb9e679cb12db5a3183e1d6552bc5e1db8f09ca
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='-:/ -# -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 t_X_opt_input_command_stack
286 t_X_errexit
287 t_S_freeze
288 t_input_inject_semicolon_seq
289 t_shcodec
290 t_wysh
291 t_commandalias
292 t_ifelse
293 t_localopts
294 t_local
295 t_macro_param_shift
296 t_addrcodec
297 t_vexpr
298 t_call_ret
299 t_xcall
300 t_vpospar
301 t_atxplode
302 t_read
304 t_mbox
305 t_maildir
306 t_record_a_resend
307 t_e_H_L_opts
309 t_alternates
310 t_alias
311 # FIXME t_mlist
312 t_filetype
314 t_message_injections
315 t_attachments
316 t_compose_hooks
317 t_C_opt_customhdr
318 t_quote_a_cmd_escapes
320 t_mass_recipients
321 t_mime_types_load_control
322 t_lreply_futh_rth_etc
324 t_mime_if_not_ascii
325 t_xxxheads_rfc2047
326 t_rfc2231
327 t_iconv_mbyte_base64
328 t_iconv_mainbody
329 t_binary_mainbody
330 t_q_t_etc_opts
332 t_s_mime
335 t_X_opt_input_command_stack() {
336 t_prolog X_opt_input_command_stack
338 ${cat} <<- '__EOT' > "${BODY}"
339 echo 1
340 define mac0 {
341 echo mac0-1 via1 $0
343 call mac0
344 echo 2
345 source '\
346 echo "define mac1 {";\
347 echo " echo mac1-1 via1 \$0";\
348 echo " call mac0";\
349 echo " echo mac1-2";\
350 echo " call mac2";\
351 echo " echo mac1-3";\
352 echo "}";\
353 echo "echo 1-1";\
354 echo "define mac2 {";\
355 echo " echo mac2-1 via1 \$0";\
356 echo " call mac0";\
357 echo " echo mac2-2";\
358 echo "}";\
359 echo "echo 1-2";\
360 echo "call mac1";\
361 echo "echo 1-3";\
362 echo "source \"\
363 echo echo 1-1-1 via1 \$0;\
364 echo call mac0;\
365 echo echo 1-1-2;\
366 | \"";\
367 echo "echo 1-4";\
369 echo 3
370 call mac2
371 echo 4
372 undefine *
373 __EOT
375 # The -X option supports multiline arguments, and those can internally use
376 # reverse solidus newline escaping. And all -X options are joined...
377 APO=\'
378 < "${BODY}" ${MAILX} ${ARGS} \
379 -X 'e\' \
380 -X ' c\' \
381 -X ' h\' \
382 -X ' o \' \
383 -X 1 \
385 define mac0 {
386 echo mac0-1 via2 $0
388 call mac0
389 echo 2
392 source '${APO}'\
393 echo "define mac1 {";\
394 echo " echo mac1-1 via2 \$0";\
395 echo " call mac0";\
396 echo " echo mac1-2";\
397 echo " call mac2";\
398 echo " echo mac1-3";\
399 echo "}";\
400 echo "echo 1-1";\
401 echo "define mac2 {";\
402 echo " echo mac2-1 via2 \$0";\
403 echo " call mac0";\
404 echo " echo mac2-2";\
405 echo "}";\
406 echo "echo 1-2";\
407 echo "call mac1";\
408 echo "echo 1-3";\
409 echo "source \"\
410 echo echo 1-1-1 via2 \$0;\
411 echo call mac0;\
412 echo echo 1-1-2;\
413 | \"";\
414 echo "echo 1-4";\
415 | '${APO}'
416 echo 3
419 call mac2
420 echo 4
421 undefine *
422 ' > "${MBOX}"
424 check 1 0 "${MBOX}" '1786542668 416'
426 t_epilog
429 t_X_errexit() {
430 t_prolog X_errexit
431 if have_feat uistrings; then :; else
432 echo 'x_errexit: unsupported, skipped'
433 return
436 ${cat} <<- '__EOT' > "${BODY}"
437 echo one
438 echos nono
439 echo two
440 __EOT
442 </dev/null ${MAILX} ${ARGS} -Snomemdebug \
443 -X'echo one' -X' echos nono ' -X'echo two' \
444 > "${MBOX}" 2>&1
445 check 1 0 "${MBOX}" '916157812 53'
447 </dev/null ${MAILX} ${ARGS} -X'source '"${BODY}" -Snomemdebug \
448 > "${MBOX}" 2>&1
449 check 2 0 "${MBOX}" '916157812 53'
451 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Snomemdebug \
452 > "${MBOX}" 2>&1
453 check 3 0 "${MBOX}" '916157812 53'
457 </dev/null ${MAILX} ${ARGS} -Serrexit -Snomemdebug \
458 -X'echo one' -X' echos nono ' -X'echo two' \
459 > "${MBOX}" 2>&1
460 check 4 1 "${MBOX}" '2118430867 49'
462 </dev/null ${MAILX} ${ARGS} -X'source '"${BODY}" -Serrexit -Snomemdebug \
463 > "${MBOX}" 2>&1
464 check 5 1 "${MBOX}" '2118430867 49'
466 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Serrexit -Snomemdebug \
467 > "${MBOX}" 2>&1
468 check 6 1 "${MBOX}" '12955965 172'
470 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Sposix -Snomemdebug \
471 > "${MBOX}" 2>&1
472 check 7 1 "${MBOX}" '12955965 172'
474 ## Repeat 4-7 with ignerr set
476 ${sed} -e 's/^echos /ignerr echos /' < "${BODY}" > "${MBOX}"
478 </dev/null ${MAILX} ${ARGS} -Serrexit -Snomemdebug \
479 -X'echo one' -X'ignerr echos nono ' -X'echo two' \
480 > "${BODY}" 2>&1
481 check 8 0 "${BODY}" '916157812 53'
483 </dev/null ${MAILX} ${ARGS} -X'source '"${MBOX}" -Serrexit -Snomemdebug \
484 > "${BODY}" 2>&1
485 check 9 0 "${BODY}" '916157812 53'
487 </dev/null MAILRC="${MBOX}" ${MAILX} ${ARGS} -:u -Serrexit -Snomemdebug \
488 > "${BODY}" 2>&1
489 check 10 0 "${BODY}" '916157812 53'
491 </dev/null MAILRC="${MBOX}" ${MAILX} ${ARGS} -:u -Sposix -Snomemdebug \
492 > "${BODY}" 2>&1
493 check 11 0 "${BODY}" '916157812 53'
495 t_epilog
498 t_S_freeze() {
499 t_prolog S_freeze
500 oterm=$TERM
501 unset TERM
503 # Test basic assumption
504 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} \
505 -X'echo asksub<$asksub> dietcurd<$dietcurd>' \
506 -Xx > "${MBOX}" 2>&1
507 check 1 0 "${MBOX}" '270686329 21'
510 ${cat} <<- '__EOT' > "${BODY}"
511 echo asksub<$asksub>
512 set asksub
513 echo asksub<$asksub>
514 __EOT
515 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
516 -Snoasksub -Sasksub -Snoasksub \
517 -X'echo asksub<$asksub>' -X'set asksub' -X'echo asksub<$asksub>' \
518 -Xx > "${MBOX}" 2>&1
519 check 2 0 "${MBOX}" '3182942628 37'
521 ${cat} <<- '__EOT' > "${BODY}"
522 echo asksub<$asksub>
523 unset asksub
524 echo asksub<$asksub>
525 __EOT
526 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
527 -Snoasksub -Sasksub \
528 -X'echo asksub<$asksub>' -X'unset asksub' -X'echo asksub<$asksub>' \
529 -Xx > "${MBOX}" 2>&1
530 check 3 0 "${MBOX}" '2006554293 39'
533 ${cat} <<- '__EOT' > "${BODY}"
534 echo dietcurd<$dietcurd>
535 set dietcurd=cherry
536 echo dietcurd<$dietcurd>
537 __EOT
538 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
539 -Sdietcurd=strawberry -Snodietcurd -Sdietcurd=vanilla \
540 -X'echo dietcurd<$dietcurd>' -X'unset dietcurd' \
541 -X'echo dietcurd<$dietcurd>' \
542 -Xx > "${MBOX}" 2>&1
543 check 4 0 "${MBOX}" '1985768109 65'
545 ${cat} <<- '__EOT' > "${BODY}"
546 echo dietcurd<$dietcurd>
547 unset dietcurd
548 echo dietcurd<$dietcurd>
549 __EOT
550 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
551 -Sdietcurd=strawberry -Snodietcurd \
552 -X'echo dietcurd<$dietcurd>' -X'set dietcurd=vanilla' \
553 -X'echo dietcurd<$dietcurd>' \
554 -Xx > "${MBOX}" 2>&1
555 check 5 0 "${MBOX}" '151574279 51'
557 # TODO once we have a detached one with env=1..
558 if [ -n "`</dev/null ${MAILX} ${ARGS} -X'!echo \$TERM' -Xx`" ]; then
559 echo 's_freeze-{6,7}: shell sets $TERM, skipped'
560 else
561 ${cat} <<- '__EOT' > "${BODY}"
562 !echo "shell says TERM<$TERM>"
563 echo TERM<$TERM>
564 !echo "shell says TERM<$TERM>"
565 set TERM=cherry
566 !echo "shell says TERM<$TERM>"
567 echo TERM<$TERM>
568 !echo "shell says TERM<$TERM>"
569 __EOT
570 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
571 -STERM=strawberry -SnoTERM -STERM=vanilla \
572 -X'echo mail<$TERM>' -X'unset TERM' \
573 -X'!echo "shell says TERM<$TERM>"' -X'echo TERM<$TERM>' \
574 -Xx > "${MBOX}" 2>&1
575 check 6 0 "${MBOX}" '1211476036 167'
577 ${cat} <<- '__EOT' > "${BODY}"
578 !echo "shell says TERM<$TERM>"
579 echo TERM<$TERM>
580 !echo "shell says TERM<$TERM>"
581 set TERM=cherry
582 !echo "shell says TERM<$TERM>"
583 echo TERM<$TERM>
584 !echo "shell says TERM<$TERM>"
585 __EOT
586 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
587 -STERM=strawberry -SnoTERM \
588 -X'echo TERM<$TERM>' -X'set TERM=vanilla' \
589 -X'!echo "shell says TERM<$TERM>"' -X'echo TERM<$TERM>' \
590 -Xx > "${MBOX}" 2>&1
591 check 7 0 "${MBOX}" '3365080441 132'
594 TERM=$oterm
595 t_epilog
598 t_input_inject_semicolon_seq() {
599 t_prolog input_inject_semicolon_seq
601 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
602 define mydeepmac {
603 echon '(mydeepmac)';
605 define mymac {
606 echon this_is_mymac;call mydeepmac;echon ';';
608 echon one';';call mymac;echon two";";call mymac;echo three$';';
609 define mymac {
610 echon this_is_mymac;call mydeepmac;echon ,TOO'!;';
612 echon one';';call mymac;echon two";";call mymac;echo three$';';
613 __EOT
615 check 1 0 "${MBOX}" '512117110 140'
617 t_epilog
620 t_shcodec() {
621 t_prolog shcodec
623 # XXX the first needs to be checked, it is quite dumb as such
624 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
625 shcodec e abcd
626 echo $?/$^ERRNAME
627 shcodec d abcd
628 echo $?/$^ERRNAME
629 shcodec e a'b'c'd'
630 echo $?/$^ERRNAME
631 shcodec d a'b'c'd'
632 echo $?/$^ERRNAME
633 shcodec e a"b"c"d"
634 echo $?/$^ERRNAME
635 shcodec d a"b"c"d"
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 'abcd'
642 echo $?/$^ERRNAME
643 shcodec d 'abcd'
644 echo $?/$^ERRNAME
645 shcodec e "abcd"
646 echo $?/$^ERRNAME
647 shcodec d "abcd"
648 echo $?/$^ERRNAME
649 shcodec e $'abcd'
650 echo $?/$^ERRNAME
651 shcodec d $'abcd'
652 echo $?/$^ERRNAME
653 # same but with vput
654 vput shcodec res e abcd
655 echo $?/$^ERRNAME $res
656 eval shcodec d $res
657 echo $?/$^ERRNAME
658 vput shcodec res d abcd
659 echo $?/$^ERRNAME $res
660 eval shcodec d $res
661 echo $?/$^ERRNAME
662 vput shcodec res e a'b'c'd'
663 echo $?/$^ERRNAME $res
664 eval shcodec d $res
665 echo $?/$^ERRNAME
666 vput shcodec res d a'b'c'd'
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 'abcd'
687 echo $?/$^ERRNAME $res
688 eval shcodec d $res
689 echo $?/$^ERRNAME
690 vput shcodec res d 'abcd'
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
711 vput shcodec res e a b\ c d
712 echo $?/$^ERRNAME $res
713 eval shcodec d $res
714 echo $?/$^ERRNAME
715 vput shcodec res d a b\ c d
716 echo $?/$^ERRNAME $res
717 vput shcodec res e ab cd
718 echo $?/$^ERRNAME $res
719 eval shcodec d $res
720 echo $?/$^ERRNAME
721 vput shcodec res d 'ab cd'
722 echo $?/$^ERRNAME $res
723 vput shcodec res e a 'b c' d
724 echo $?/$^ERRNAME $res
725 eval shcodec d $res
726 echo $?/$^ERRNAME
727 vput shcodec res d a 'b c' d
728 echo $?/$^ERRNAME $res
729 vput shcodec res e a "b c" d
730 echo $?/$^ERRNAME $res
731 eval shcodec d $res
732 echo $?/$^ERRNAME
733 vput shcodec res d a "b c" d
734 echo $?/$^ERRNAME $res
735 vput shcodec res e a $'b c' d
736 echo $?/$^ERRNAME $res
737 eval shcodec d $res
738 echo $?/$^ERRNAME
739 vput shcodec res d a $'b c' d
740 echo $?/$^ERRNAME $res
742 vput shcodec res e 'a$`"\'
743 echo $?/$^ERRNAME $res
744 eval shcodec d $res
745 echo $?/$^ERRNAME
746 vput shcodec res d 'a$`"\'
747 echo $?/$^ERRNAME $res
748 vput shcodec res e "a\$\`'\"\\"
749 echo $?/$^ERRNAME $res
750 eval shcodec d $res
751 echo $?/$^ERRNAME
752 vput shcodec res d "a\$\`'\"\\"
753 echo $?/$^ERRNAME $res
754 vput shcodec res e $'a\$`\'\"\\'
755 echo $?/$^ERRNAME $res
756 eval shcodec d $res
757 echo $?/$^ERRNAME
758 vput shcodec res d $'a\$`\'\"\\'
759 echo $?/$^ERRNAME $res
760 vput shcodec res e $'a\$`\'"\\'
761 echo $?/$^ERRNAME $res
762 eval shcodec d $res
763 echo $?/$^ERRNAME
764 vput shcodec res d $'a\$`\'"\\'
765 echo $?/$^ERRNAME $res
767 set diet=curd
768 vput shcodec res e a${diet}c
769 echo $?/$^ERRNAME $res
770 eval shcodec d $res
771 echo $?/$^ERRNAME
772 eval vput shcodec res e a${diet}c
773 echo $?/$^ERRNAME $res
774 eval shcodec d $res
775 echo $?/$^ERRNAME
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 __EOT
785 check 1 0 "${MBOX}" '3316745312 1241'
787 if [ -z "${UTF8_LOCALE}" ]; then
788 echo 'Skip shcodec-unicode, no UTF8_LOCALE TODO CANNOT'
789 else
790 ${cat} <<- '__EOT' | LC_ALL=${UTF8_LOCALE} \
791 ${MAILX} ${ARGS} > "${MBOX}" 2>>${ERR}
793 shcodec e täst
794 shcodec +e täst
795 shcodec d $'t\u00E4st'
796 shcodec e aՍc
797 shcodec +e aՍc
798 shcodec d $'a\u054Dc'
799 shcodec e a😃c
800 shcodec +e a😃c
801 shcodec d $'a\U0001F603c'
802 __EOT
803 check unicode 0 "${MBOX}" '4233409480 77'
806 t_epilog
809 t_wysh() {
810 t_prolog wysh
812 ${cat} <<- '__EOT' > "${BODY}"
814 echo abcd
815 echo a'b'c'd'
816 echo a"b"c"d"
817 echo a$'b'c$'d'
818 echo 'abcd'
819 echo "abcd"
820 echo $'abcd'
821 echo a\ b\ c\ d
822 echo a 'b c' d
823 echo a "b c" d
824 echo a $'b c' d
826 echo 'a$`"\'
827 echo "a\$\`'\"\\"
828 echo $'a\$`\'\"\\'
829 echo $'a\$`\'"\\'
830 # DIET=CURD TIED=
831 echo 'a${DIET}b${TIED}c\${DIET}d\${TIED}e' # COMMENT
832 echo "a${DIET}b${TIED}c\${DIET}d\${TIED}e"
833 echo $'a${DIET}b${TIED}c\${DIET}d\${TIED}e'
835 echo a$'\101\0101\x41\u0041\u41\U00000041\U41'c
836 echo a$'\u0041\u41\u0C1\U00000041\U41'c
837 echo a$'\377'c
838 echo a$'\0377'c
839 echo a$'\400'c
840 echo a$'\0400'c
841 echo a$'\U1100001'c
843 echo a$'b\0c'd
844 echo a$'b\00c'de
845 echo a$'b\000c'df
846 echo a$'b\0000c'dg
847 echo a$'b\x0c'dh
848 echo a$'b\x00c'di
849 echo a$'b\u0'dj
850 echo a$'b\u00'dk
851 echo a$'b\u000'dl
852 echo a$'b\u0000'dm
853 echo a$'b\U0'dn
854 echo a$'b\U00'do
855 echo a$'b\U000'dp
856 echo a$'b\U0000'dq
857 echo a$'b\U00000'dr
858 echo a$'b\U000000'ds
859 echo a$'b\U0000000'dt
860 echo a$'b\U00000000'du
862 echo a$'\cI'b
863 echo a$'\011'b
864 echo a$'\x9'b
865 echo a$'\u9'b
866 echo a$'\U9'b
867 echo a$'\c@'b c d
868 __EOT
870 if [ -z "${UTF8_LOCALE}" ]; then
871 echo 'Skip wysh-unicode, no UTF8_LOCALE'
872 else
873 < "${BODY}" DIET=CURD TIED= \
874 LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} > "${MBOX}" 2>>${ERR}
875 check unicode 0 "${MBOX}" '475805847 317'
878 < "${BODY}" DIET=CURD TIED= ${MAILX} ${ARGS} > "${MBOX}" 2>>${ERR}
879 check c 0 "${MBOX}" '1473887148 321'
881 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
882 wysh set mager='\hey\'
883 varshow mager
884 wysh set mager="\hey\\"
885 varshow mager
886 wysh set mager=$'\hey\\'
887 varshow mager
888 __EOT
889 check 3 0 "${MBOX}" '1289698238 69'
891 t_epilog
894 t_commandalias() {
895 t_prolog commandalias
897 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
898 commandalias echo echo hoho
899 echo stop.
900 commandalias X Xx
901 commandalias Xx XxX
902 commandalias XxX XxXx
903 commandalias XxXx XxXxX
904 commandalias XxXxX XxXxXx
905 commandalias XxXxXx echo huhu
906 commandalias XxXxXxX echo huhu
908 commandalias XxXxXx XxXxXxX
910 uncommandalias echo
911 commandalias XxXxXx echo huhu
913 __EOT
915 check 1 0 "${MBOX}" '1638809585 36'
917 t_epilog
920 t_ifelse() {
921 t_prolog ifelse
923 # Nestable conditions test
924 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
925 if 0
926 echo 1.err
927 else
928 echo 1.ok
929 endif
930 if 1
931 echo 2.ok
932 else
933 echo 2.err
934 endif
935 if $dietcurd
936 echo 3.err
937 else
938 echo 3.ok
939 endif
940 set dietcurd=yoho
941 if $dietcurd
942 echo 4.ok
943 else
944 echo 4.err
945 endif
946 if $dietcurd == 'yoho'
947 echo 5.ok
948 else
949 echo 5.err
950 endif
951 if $dietcurd @== 'Yoho'
952 echo 5-1.ok
953 else
954 echo 5-1.err
955 endif
956 if $dietcurd == 'Yoho'
957 echo 5-2.err
958 else
959 echo 5-2.ok
960 endif
961 if $dietcurd != 'yoho'
962 echo 6.err
963 else
964 echo 6.ok
965 endif
966 if $dietcurd @!= 'Yoho'
967 echo 6-1.err
968 else
969 echo 6-1.ok
970 endif
971 if $dietcurd != 'Yoho'
972 echo 6-2.ok
973 else
974 echo 6-2.err
975 endif
976 # Nesting
977 if faLse
978 echo 7.err1
979 if tRue
980 echo 7.err2
981 if yEs
982 echo 7.err3
983 else
984 echo 7.err4
985 endif
986 echo 7.err5
987 endif
988 echo 7.err6
989 else
990 echo 7.ok7
991 if YeS
992 echo 7.ok8
993 if No
994 echo 7.err9
995 else
996 echo 7.ok9
997 endif
998 echo 7.ok10
999 else
1000 echo 7.err11
1001 if yeS
1002 echo 7.err12
1003 else
1004 echo 7.err13
1005 endif
1006 endif
1007 echo 7.ok14
1008 endif
1009 if r
1010 echo 8.ok1
1011 if R
1012 echo 8.ok2
1013 else
1014 echo 8.err2
1015 endif
1016 echo 8.ok3
1017 else
1018 echo 8.err1
1019 endif
1020 if s
1021 echo 9.err1
1022 else
1023 echo 9.ok1
1024 if S
1025 echo 9.err2
1026 else
1027 echo 9.ok2
1028 endif
1029 echo 9.ok3
1030 endif
1031 # `elif'
1032 if $dietcurd == 'yohu'
1033 echo 10.err1
1034 elif $dietcurd == 'yoha'
1035 echo 10.err2
1036 elif $dietcurd == 'yohe'
1037 echo 10.err3
1038 elif $dietcurd == 'yoho'
1039 echo 10.ok1
1040 if $dietcurd == 'yohu'
1041 echo 10.err4
1042 elif $dietcurd == 'yoha'
1043 echo 10.err5
1044 elif $dietcurd == 'yohe'
1045 echo 10.err6
1046 elif $dietcurd == 'yoho'
1047 echo 10.ok2
1048 if $dietcurd == 'yohu'
1049 echo 10.err7
1050 elif $dietcurd == 'yoha'
1051 echo 10.err8
1052 elif $dietcurd == 'yohe'
1053 echo 10.err9
1054 elif $dietcurd == 'yoho'
1055 echo 10.ok3
1056 else
1057 echo 10.err10
1058 endif
1059 else
1060 echo 10.err11
1061 endif
1062 else
1063 echo 10.err12
1064 endif
1065 # integer
1066 set dietcurd=10
1067 if $dietcurd -lt 11
1068 echo 11.ok1
1069 if $dietcurd -gt 9
1070 echo 11.ok2
1071 else
1072 echo 11.err2
1073 endif
1074 if $dietcurd -eq 10
1075 echo 11.ok3
1076 else
1077 echo 11.err3
1078 endif
1079 if $dietcurd -ge 10
1080 echo 11.ok4
1081 else
1082 echo 11.err4
1083 endif
1084 if $dietcurd -le 10
1085 echo 11.ok5
1086 else
1087 echo 11.err5
1088 endif
1089 if $dietcurd -ge 11
1090 echo 11.err6
1091 else
1092 echo 11.ok6
1093 endif
1094 if $dietcurd -le 9
1095 echo 11.err7
1096 else
1097 echo 11.ok7
1098 endif
1099 else
1100 echo 11.err1
1101 endif
1102 set dietcurd=Abc
1103 if $dietcurd < aBd
1104 echo 12.ok1
1105 if $dietcurd @> abB
1106 echo 12.ok2
1107 else
1108 echo 12.err2
1109 endif
1110 if $dietcurd @== aBC
1111 echo 12.ok3
1112 else
1113 echo 12.err3
1114 endif
1115 if $dietcurd @>= AbC
1116 echo 12.ok4
1117 else
1118 echo 12.err4
1119 endif
1120 if $dietcurd @<= ABc
1121 echo 12.ok5
1122 else
1123 echo 12.err5
1124 endif
1125 if $dietcurd @>= abd
1126 echo 12.err6
1127 else
1128 echo 12.ok6
1129 endif
1130 if $dietcurd @<= abb
1131 echo 12.err7
1132 else
1133 echo 12.ok7
1134 endif
1135 else
1136 echo 12.err1
1137 endif
1138 if $dietcurd < aBc
1139 echo 12-1.ok
1140 else
1141 echo 12-1.err
1142 endif
1143 if $dietcurd @< aBc
1144 echo 12-2.err
1145 else
1146 echo 12-2.ok
1147 endif
1148 if $dietcurd > ABc
1149 echo 12-3.ok
1150 else
1151 echo 12-3.err
1152 endif
1153 if $dietcurd @> ABc
1154 echo 12-3.err
1155 else
1156 echo 12-3.ok
1157 endif
1158 if $dietcurd @i=% aB
1159 echo 13.ok
1160 else
1161 echo 13.err
1162 endif
1163 if $dietcurd =% aB
1164 echo 13-1.err
1165 else
1166 echo 13-1.ok
1167 endif
1168 if $dietcurd @=% bC
1169 echo 14.ok
1170 else
1171 echo 14.err
1172 endif
1173 if $dietcurd !% aB
1174 echo 15-1.ok
1175 else
1176 echo 15-1.err
1177 endif
1178 if $dietcurd @!% aB
1179 echo 15-2.err
1180 else
1181 echo 15-2.ok
1182 endif
1183 if $dietcurd !% bC
1184 echo 15-3.ok
1185 else
1186 echo 15-3.err
1187 endif
1188 if $dietcurd @!% bC
1189 echo 15-4.err
1190 else
1191 echo 15-4.ok
1192 endif
1193 if $dietcurd =% Cd
1194 echo 16.err
1195 else
1196 echo 16.ok
1197 endif
1198 if $dietcurd !% Cd
1199 echo 17.ok
1200 else
1201 echo 17.err
1202 endif
1203 set diet=abc curd=abc
1204 if $diet == $curd
1205 echo 18.ok
1206 else
1207 echo 18.err
1208 endif
1209 set diet=abc curd=abcd
1210 if $diet != $curd
1211 echo 19.ok
1212 else
1213 echo 19.err
1214 endif
1215 # 1. Shitty grouping capabilities as of today
1216 unset diet curd ndefined
1217 if [ [ false ] || [ false ] || [ true ] ] && [ [ false ] || [ true ] ] && \
1218 [ yes ]
1219 echo 20.ok
1220 else
1221 echo 20.err
1222 endif
1223 if [ [ [ [ 0 ] || [ 1 ] ] && [ [ 1 ] || [ 0 ] ] ] && [ 1 ] ] && [ yes ]
1224 echo 21.ok
1225 else
1226 echo 21.err
1227 endif
1228 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] ]
1229 echo 22.ok
1230 else
1231 echo 22.err
1232 endif
1233 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] ]
1234 echo 23.ok
1235 else
1236 echo 23.err
1237 endif
1238 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] && [ no ]
1239 echo 24.err
1240 else
1241 echo 24.ok
1242 endif
1243 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] \
1244 && [ no ] || [ yes ]
1245 echo 25.ok
1246 else
1247 echo 25.err
1248 endif
1249 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
1250 echo 26.ok
1251 else
1252 echo 26.err
1253 endif
1254 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 0 ] ]
1255 echo 27.err
1256 else
1257 echo 27.ok
1258 endif
1259 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 0 ] ] && [ 1 ] ] ] && [ 1 ] ]
1260 echo 28.err
1261 else
1262 echo 28.ok
1263 endif
1264 if [ [ [ [ [ [ [ 0 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
1265 echo 29.err
1266 else
1267 echo 29.ok
1268 endif
1269 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 0 ]
1270 echo 30.err
1271 else
1272 echo 30.ok
1273 endif
1274 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 1 ]
1275 echo 31.ok
1276 else
1277 echo 31.err
1278 endif
1279 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ]
1280 echo 32.err
1281 else
1282 echo 32.ok
1283 endif
1284 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 1 ]
1285 echo 33.ok
1286 else
1287 echo 33.err
1288 endif
1289 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 0 ]
1290 echo 34.err
1291 else
1292 echo 34.ok
1293 endif
1294 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 1 ]
1295 echo 35.ok
1296 else
1297 echo 35.err
1298 endif
1299 set diet=yo curd=ho
1300 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
1301 echo 36.err
1302 else
1303 echo 36.ok
1304 endif
1305 set ndefined
1306 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
1307 echo 37.ok
1308 else
1309 echo 37.err
1310 endif
1311 # 2. Shitty grouping capabilities as of today
1312 unset diet curd ndefined
1313 if [ false || false || true ] && [ false || true ] && yes
1314 echo 40.ok
1315 else
1316 echo 40.err
1317 endif
1318 if [ [ [ 0 || 1 ] && [ 1 || 0 ] ] && 1 ] && [ yes ]
1319 echo 41.ok
1320 else
1321 echo 41.err
1322 endif
1323 if [ 1 || 0 || 0 || 0 ]
1324 echo 42.ok
1325 else
1326 echo 42.err
1327 endif
1328 if [ 1 || 0 || 0 || 0 || [ 1 ] ]
1329 echo 43.ok
1330 else
1331 echo 43.err
1332 endif
1333 if [ 1 || 0 || 0 || 0 || [ 1 ] || 1 ] && no
1334 echo 44.err
1335 else
1336 echo 44.ok
1337 endif
1338 if [ 1 || 0 || 0 || 0 || 1 || [ 1 ] ] && no || [ yes ]
1339 echo 45.ok
1340 else
1341 echo 45.err
1342 endif
1343 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && 1 ] ] && [ 1 ] ]
1344 echo 46.ok
1345 else
1346 echo 46.err
1347 endif
1348 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && [ 1 ] ] ] && 0 ]
1349 echo 47.err
1350 else
1351 echo 47.ok
1352 endif
1353 if [ [ [ [ [ [ [ 1 ] ] && 1 ] && 0 ] && [ 1 ] ] ] && 1 ]
1354 echo 48.err
1355 else
1356 echo 48.ok
1357 endif
1358 if [ [ [ [ [ [ 0 ] && 1 ] && 1 ] && 1 ] ] && 1 ]
1359 echo 49.err
1360 else
1361 echo 49.ok
1362 endif
1363 if 1 || 0 || 0 || 0 && 0
1364 echo 50.err
1365 else
1366 echo 50.ok
1367 endif
1368 if 1 || 0 || 0 || 0 && 1
1369 echo 51.ok
1370 else
1371 echo 51.err
1372 endif
1373 if 0 || 0 || 0 || 1 && 0
1374 echo 52.err
1375 else
1376 echo 52.ok
1377 endif
1378 if 0 || 0 || 0 || 1 && 1
1379 echo 53.ok
1380 else
1381 echo 53.err
1382 endif
1383 if 0 || 0 || 0 || 1 && 0 || 1 && 0
1384 echo 54.err
1385 else
1386 echo 54.ok
1387 endif
1388 if 0 || 0 || 0 || 1 && 0 || 1 && 1
1389 echo 55.ok
1390 else
1391 echo 55.err
1392 endif
1393 set diet=yo curd=ho
1394 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
1395 echo 56.err
1396 else
1397 echo 56.ok
1398 endif
1399 if $diet == 'yo' && $curd == 'ho' && $ndefined
1400 echo 57.err
1401 else
1402 echo 57.ok
1403 endif
1404 set ndefined
1405 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
1406 echo 57.ok
1407 else
1408 echo 57.err
1409 endif
1410 if $diet == 'yo' && $curd == 'ho' && $ndefined
1411 echo 58.ok
1412 else
1413 echo 58.err
1414 endif
1415 if [ [ [ [ [ [ $diet == 'yo' && $curd == 'ho' && $ndefined ] ] ] ] ] ]
1416 echo 59.ok
1417 else
1418 echo 59.err
1419 endif
1420 # Some more en-braced variables
1421 set diet=yo curd=ho
1422 if ${diet} == ${curd}
1423 echo 70.err
1424 else
1425 echo 70.ok
1426 endif
1427 if ${diet} != ${curd}
1428 echo 71.ok
1429 else
1430 echo 71.err
1431 endif
1432 if $diet == ${curd}
1433 echo 72.err
1434 else
1435 echo 72.ok
1436 endif
1437 if ${diet} == $curd
1438 echo 73.err
1439 else
1440 echo 73.ok
1441 endif
1442 # Unary !
1443 if ! 0 && ! ! 1 && ! ! ! ! 2 && 3
1444 echo 80.ok
1445 else
1446 echo 80.err
1447 endif
1448 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ ! 2 ] ] ] && 3
1449 echo 81.ok
1450 else
1451 echo 81.err
1452 endif
1453 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1454 echo 82.ok
1455 else
1456 echo 82.err
1457 endif
1458 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
1459 echo 83.err
1460 else
1461 echo 83.ok
1462 endif
1463 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
1464 echo 84.err
1465 else
1466 echo 84.ok
1467 endif
1468 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1469 echo 85.err
1470 else
1471 echo 85.ok
1472 endif
1473 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1474 echo 86.err
1475 else
1476 echo 86.ok
1477 endif
1478 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] || 3
1479 echo 87.ok
1480 else
1481 echo 87.err
1482 endif
1483 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! ! [ 2 ] ] ] ] ]
1484 echo 88.ok
1485 else
1486 echo 88.err
1487 endif
1488 # Unary !, odd
1489 if ! 0 && ! ! 1 && ! ! ! 0 && 3
1490 echo 90.ok
1491 else
1492 echo 90.err
1493 endif
1494 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ 0 ] ] ] && 3
1495 echo 91.ok
1496 else
1497 echo 91.err
1498 endif
1499 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ [ 0 ] ] ] ] ] && 3
1500 echo 92.ok
1501 else
1502 echo 92.err
1503 endif
1504 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! ! [ ! [ ! 0 ] ] ] ] && ! 3
1505 echo 93.err
1506 else
1507 echo 93.ok
1508 endif
1509 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ ! [ ! [ ! [ ! 0 ] ] ] ] && 3
1510 echo 94.ok
1511 else
1512 echo 94.err
1513 endif
1514 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! ! [ ! [ ! [ ! [ 0 ] ] ] ] ] && 3
1515 echo 95.err
1516 else
1517 echo 95.ok
1518 endif
1519 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! ! 0 ] ] ] ] && 3
1520 echo 96.err
1521 else
1522 echo 96.ok
1523 endif
1524 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ ! 0 ] ] ] ] ] || 3
1525 echo 97.ok
1526 else
1527 echo 97.err
1528 endif
1529 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! [ 0 ] ] ] ] ]
1530 echo 98.ok
1531 else
1532 echo 98.err
1533 endif
1534 __EOT
1536 check normal 0 "${MBOX}" '1688759742 719'
1538 if have_feat regex; then
1539 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
1540 set dietcurd=yoho
1541 if $dietcurd =~ '^yo.*'
1542 echo 1.ok
1543 else
1544 echo 1.err
1545 endif
1546 if $dietcurd =~ '^Yo.*'
1547 echo 1-1.err
1548 else
1549 echo 1-1.ok
1550 endif
1551 if $dietcurd @=~ '^Yo.*'
1552 echo 1-2.ok
1553 else
1554 echo 1-2.err
1555 endif
1556 if $dietcurd =~ '^yOho.+'
1557 echo 2.err
1558 else
1559 echo 2.ok
1560 endif
1561 if $dietcurd @!~ '.*Ho$'
1562 echo 3.err
1563 else
1564 echo 3.ok
1565 endif
1566 if $dietcurd !~ '.+yohO$'
1567 echo 4.ok
1568 else
1569 echo 4.err
1570 endif
1571 if [ $dietcurd @i!~ '.+yoho$' ]
1572 echo 5.ok
1573 else
1574 echo 5.err
1575 endif
1576 if ! [ $dietcurd @i=~ '.+yoho$' ]
1577 echo 6.ok
1578 else
1579 echo 6.err
1580 endif
1581 if ! ! [ $dietcurd @i!~ '.+yoho$' ]
1582 echo 7.ok
1583 else
1584 echo 7.err
1585 endif
1586 if ! [ ! [ $dietcurd @i!~ '.+yoho$' ] ]
1587 echo 8.ok
1588 else
1589 echo 8.err
1590 endif
1591 if [ ! [ ! [ $dietcurd @i!~ '.+yoho$' ] ] ]
1592 echo 9.ok
1593 else
1594 echo 9.err
1595 endif
1596 if ! [ ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
1597 echo 10.err
1598 else
1599 echo 10.ok
1600 endif
1601 if ! ! ! $dietcurd !~ '.+yoho$'
1602 echo 11.err
1603 else
1604 echo 11.ok
1605 endif
1606 if ! ! ! $dietcurd =~ '.+yoho$'
1607 echo 12.ok
1608 else
1609 echo 12.err
1610 endif
1611 if ! [ ! ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
1612 echo 13.ok
1613 else
1614 echo 13.err
1615 endif
1616 set diet=abc curd='^abc$'
1617 if $diet =~ $curd
1618 echo 14.ok
1619 else
1620 echo 14.err
1621 endif
1622 set diet=abc curd='^abcd$'
1623 if $diet !~ $curd
1624 echo 15.ok
1625 else
1626 echo 15.err
1627 endif
1628 __EOT
1630 check regex 0 "${MBOX}" '1115671789 95'
1631 else
1632 printf 'if-regex: unsupported, skipped\n'
1635 t_epilog
1638 t_localopts() {
1639 t_prolog localopts
1641 # Nestable conditions test
1642 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
1643 define t2 {
1644 echo in: t2
1645 set t2=t2
1646 echo $t2
1648 define t1 {
1649 echo in: t1
1650 set gv1=gv1
1651 localopts on
1652 set lv1=lv1 lv2=lv2
1653 set lv3=lv3
1654 call t2
1655 localopts off
1656 set gv2=gv2
1657 echo $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2
1659 define t0 {
1660 echo in: t0
1661 call t1
1662 echo $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2
1663 echo "$gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2"
1665 account trouble {
1666 echo in: trouble
1667 call t0
1669 call t0
1670 unset gv1 gv2
1671 account trouble
1672 echo active trouble: $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t3
1673 account null
1674 echo active null: $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t3
1677 define ll2 {
1678 localopts $1
1679 set x=2
1680 echo ll2=$x
1682 define ll1 {
1683 wysh set y=$1; shift; eval localopts $y; localopts $1; shift
1684 set x=1
1685 echo ll1.1=$x
1686 call ll2 $1
1687 echo ll1.2=$x
1689 define ll0 {
1690 wysh set y=$1; shift; eval localopts $y; localopts $1; shift
1691 set x=0
1692 echo ll0.1=$x
1693 call ll1 $y "$@"
1694 echo ll0.2=$x
1696 define llx {
1697 echo ----- $1: $2 -> $3 -> $4
1698 echo ll-1.1=$x
1699 eval localopts $1
1700 call ll0 "$@"
1701 echo ll-1.2=$x
1702 unset x
1704 define lly {
1705 call llx 'call off' on on on
1706 call llx 'call off' off on on
1707 call llx 'call off' on off on
1708 call llx 'call off' on off off
1709 localopts call-fixate on
1710 call llx 'call-fixate on' on on on
1711 call llx 'call-fixate on' off on on
1712 call llx 'call-fixate on' on off on
1713 call llx 'call-fixate on' on off off
1714 unset x;localopts call on
1715 call llx 'call on' on on on
1716 call llx 'call on' off on on
1717 call llx 'call on' on off on
1718 call llx 'call on' on off off
1720 call lly
1721 __EOT
1723 check 1 0 "${MBOX}" '4016155249 1246'
1725 t_epilog
1728 t_local() {
1729 t_prolog local
1731 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
1732 define du2 {
1733 echo du2-1 du=$du
1734 local set du=$1
1735 echo du2-2 du=$du
1736 local unset du
1737 echo du2-3 du=$du
1739 define du {
1740 local set du=dudu
1741 echo du-1 du=$du
1742 call du2 du2du2
1743 echo du-2 du=$du
1744 local set nodu
1745 echo du-3 du=$du
1747 define ich {
1748 echo ich-1 du=$du
1749 call du
1750 echo ich-2 du=$du
1752 define wir {
1753 localopts $1
1754 set du=wirwir
1755 echo wir-1 du=$du
1756 call ich
1757 echo wir-2 du=$du
1759 echo ------- global-1 du=$du
1760 call ich
1761 echo ------- global-2 du=$du
1762 set du=global
1763 call ich
1764 echo ------- global-3 du=$du
1765 call wir on
1766 echo ------- global-4 du=$du
1767 call wir off
1768 echo ------- global-5 du=$du
1769 __EOT
1771 check 1 0 "${MBOX}" '2411598140 641'
1773 t_epilog
1776 t_macro_param_shift() {
1777 t_prolog macro_param_shift
1779 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>>${ERR}
1780 define t2 {
1781 echo in: t2
1782 echo t2.0 has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1783 localopts on
1784 wysh set ignerr=$1
1785 shift
1786 localopts off
1787 echo t2.1 has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1788 if [ $# > 1 ] || [ $ignerr == '' ]
1789 shift 2
1790 else
1791 ignerr shift 2
1792 endif
1793 echo t2.2:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1794 shift 0
1795 echo t2.3:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1796 if [ $# > 0 ]
1797 shift
1798 endif
1799 echo t2.4:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1801 define t1 {
1802 set errexit
1803 echo in: t1
1804 call t2 1 you get four args
1805 echo t1.1: $?';' ignerr ($ignerr) should not exist
1806 call t2 1 you get 'three args'
1807 echo t1.2: $?';' ignerr ($ignerr) should not exist
1808 call t2 1 you 'get two args'
1809 echo t1.3: $?';' ignerr ($ignerr) should not exist
1810 call t2 1 'you get one arg'
1811 echo t1.4: $?';' ignerr ($ignerr) should not exist
1812 ignerr call t2 '' 'you get one arg'
1813 echo t1.5: $?';' ignerr ($ignerr) should not exist
1815 call t1
1816 __EOT
1818 check 1 0 "${MBOX}" '1402489146 1682'
1820 t_epilog
1823 t_addrcodec() {
1824 t_prolog addrcodec
1826 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
1827 vput addrcodec res e 1 <doog@def>
1828 echo $?/$^ERRNAME $res
1829 eval vput addrcodec res d $res
1830 echo $?/$^ERRNAME $res
1831 vput addrcodec res e 2 . <doog@def>
1832 echo $?/$^ERRNAME $res
1833 eval vput addrcodec res d $res
1834 echo $?/$^ERRNAME $res
1835 vput addrcodec res e 3 Sauer Dr. <doog@def>
1836 echo $?/$^ERRNAME $res
1837 eval vput addrcodec res d $res
1838 echo $?/$^ERRNAME $res
1839 vput addrcodec res e 3.50 Sauer (Ma) Dr. <doog@def>
1840 echo $?/$^ERRNAME $res
1841 eval vput addrcodec res d $res
1842 echo $?/$^ERRNAME $res
1843 vput addrcodec res e 3.51 Sauer (Ma) "Dr." <doog@def>
1844 echo $?/$^ERRNAME $res
1845 eval vput addrcodec res d $res
1846 echo $?/$^ERRNAME $res
1848 vput addrcodec res +e 4 Sauer (Ma) Dr. <doog@def>
1849 echo $?/$^ERRNAME $res
1850 eval vput addrcodec res d $res
1851 echo $?/$^ERRNAME $res
1852 vput addrcodec res +e 5 Sauer (Ma) Braten Dr. <doog@def>
1853 echo $?/$^ERRNAME $res
1854 eval vput addrcodec res d $res
1855 echo $?/$^ERRNAME $res
1856 vput addrcodec res +e 6 Sauer (Ma) Braten Dr. (Heu) <doog@def>
1857 echo $?/$^ERRNAME $res
1858 eval vput addrcodec res d $res
1859 echo $?/$^ERRNAME $res
1860 vput addrcodec res +e 7 Sauer (Ma) Braten Dr. (Heu) <doog@def> (bu)
1861 echo $?/$^ERRNAME $res
1862 eval vput addrcodec res d $res
1863 echo $?/$^ERRNAME $res
1864 vput addrcodec res +e 8 \
1865 Dr. Sauer (Ma) Braten Dr. (Heu) <doog@def> (bu) Boom. Boom
1866 echo $?/$^ERRNAME $res
1867 eval vput addrcodec res d $res
1868 echo $?/$^ERRNAME $res
1869 vput addrcodec res +e 9 Dr.Sauer(Ma)Braten Dr. (Heu) <doog@def>
1870 echo $?/$^ERRNAME $res
1871 eval vput addrcodec res d $res
1872 echo $?/$^ERRNAME $res
1873 vput addrcodec res +e 10 (Ma)Braten Dr. (Heu) <doog@def>
1874 echo $?/$^ERRNAME $res
1875 eval vput addrcodec res d $res
1876 echo $?/$^ERRNAME $res
1877 vput addrcodec res +e 11 (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 12 Dr. Sauer (Ma) Braten Dr. (u) <doog@def>
1882 echo $?/$^ERRNAME $res
1883 eval vput addrcodec res d $res
1884 echo $?/$^ERRNAME $res
1885 vput addrcodec res +e 13(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 14 Hey, Du <doog@def> Wie() findet Dr. das? ()
1890 echo $?/$^ERRNAME $res
1891 eval vput addrcodec res d $res
1892 echo $?/$^ERRNAME $res
1893 vput addrcodec res +e 15 \
1894 Hey, Du <doog@def> Wie() findet "" Dr. "" das? ()
1895 echo $?/$^ERRNAME $res
1896 eval vput addrcodec res d $res
1897 echo $?/$^ERRNAME $res
1898 vput addrcodec res +e 16 \
1899 "Hey," "Du" <doog@def> "Wie()" findet "" Dr. "" das? ()
1900 echo $?/$^ERRNAME $res
1901 eval vput addrcodec res d $res
1902 echo $?/$^ERRNAME $res
1903 vput addrcodec res +e 17 \
1904 "Hey" Du <doog@def> "Wie() findet " " Dr. """ das? ()
1905 echo $?/$^ERRNAME $res
1906 eval vput addrcodec res d $res
1907 echo $?/$^ERRNAME $res
1908 vput addrcodec res +e 18 \
1909 <doog@def> "Hey" Du "Wie() findet " " Dr. """ das? ()
1910 echo $?/$^ERRNAME $res
1911 eval vput addrcodec res d $res
1912 echo $?/$^ERRNAME $res
1913 vput addrcodec res +e 19 Hey\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1914 echo $?/$^ERRNAME $res
1915 eval vput addrcodec res d $res
1916 echo $?/$^ERRNAME $res
1918 vput addrcodec res ++e 20 Hey\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1919 echo $?/$^ERRNAME $res
1920 vput addrcodec res ++e 21 Hey\,\"" <doog@def> "Wie()" findet \" Dr. \" das?
1921 echo $?/$^ERRNAME $res
1922 eval vput addrcodec res d $res
1923 echo $?/$^ERRNAME $res
1925 vput addrcodec res +++e 22 Hey\\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1926 echo $?/$^ERRNAME $res
1927 eval vput addrcodec res d $res
1928 echo $?/$^ERRNAME $res
1930 vput addrcodec res s \
1931 "23 Hey\\,\\\" \"Wie" () "\" findet \\\" Dr. \\\" das?" <doog@def>
1932 echo $?/$^ERRNAME $res
1934 # Fix for [f3852f88]
1935 vput addrcodec res ++e <from2@exam.ple> 100 (comment) "Quot(e)d"
1936 echo $?/$^ERRNAME $res
1937 eval vput addrcodec res d $res
1938 echo $?/$^ERRNAME $res
1939 vput addrcodec res e <from2@exam.ple> 100 (comment) "Quot(e)d"
1940 echo $?/$^ERRNAME $res
1941 eval vput addrcodec res d $res
1942 echo $?/$^ERRNAME $res
1943 __EOT
1945 check 1 0 "${MBOX}" '1047317989 2612'
1947 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
1948 mlist isa1@list
1949 mlsubscribe isa2@list
1951 vput addrcodec res skin Hey\\,\" <isa0@list> "Wie()" find \" Dr. \" das?
1952 echo $?/$^ERRNAME $res
1953 vput addrcodec res skinlist Hey\\,\" <isa0@list> "Wie()" find \" Dr. \" das?
1954 echo $?/$^ERRNAME $res
1955 vput addrcodec res skin Hey\\,\" <isa1@list> "Wie()" find \" Dr. \" das?
1956 echo $?/$^ERRNAME $res
1957 vput addrcodec res skinlist Hey\\,\" <isa1@list> "Wie()" find \" Dr. \" das?
1958 echo $?/$^ERRNAME $res
1959 vput addrcodec res skin Hey\\,\" <isa2@list> "Wie()" find \" Dr. \" das?
1960 echo $?/$^ERRNAME $res
1961 vput addrcodec res skinlist Hey\\,\" <isa2@list> "Wie()" find \" Dr. \" das?
1962 echo $?/$^ERRNAME $res
1963 __EOT
1965 check 2 0 "${MBOX}" '1391779299 104'
1967 if have_feat idna; then
1968 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} ${ADDARG_UNI} > "${MBOX}" 2>&1
1969 vput addrcodec res e (heu) <du@blödiän> "stroh" du
1970 echo $?/$^ERRNAME $res
1971 eval vput addrcodec res d $res
1972 echo $?/$^ERRNAME $res
1973 vput addrcodec res e <du@blödiän> du
1974 echo $?/$^ERRNAME $res
1975 eval vput addrcodec res d $res
1976 echo $?/$^ERRNAME $res
1977 vput addrcodec res e du <du@blödiän>
1978 echo $?/$^ERRNAME $res
1979 eval vput addrcodec res d $res
1980 echo $?/$^ERRNAME $res
1981 vput addrcodec res e <du@blödiän>
1982 echo $?/$^ERRNAME $res
1983 eval vput addrcodec res d $res
1984 echo $?/$^ERRNAME $res
1985 vput addrcodec res e du@blödiän
1986 echo $?/$^ERRNAME $res
1987 eval vput addrcodec res d $res
1988 echo $?/$^ERRNAME $res
1989 __EOT
1991 check idna 0 "${MBOX}" '498775983 326'
1992 else
1993 printf 'addrcodec-idna: unsupported, skipped\n'
1996 t_epilog
1999 t_vexpr() {
2000 t_prolog vexpr
2002 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>>${ERR}
2003 echo ' #0.0'
2004 vput vexpr res = 9223372036854775807
2005 echo $?/$^ERRNAME $res
2006 vput vexpr res = 9223372036854775808
2007 echo $?/$^ERRNAME $res
2008 vput vexpr res = u9223372036854775808
2009 echo $?/$^ERRNAME $res
2010 vput vexpr res @= 9223372036854775808
2011 echo $?/$^ERRNAME $res
2012 vput vexpr res = -9223372036854775808
2013 echo $?/$^ERRNAME $res
2014 vput vexpr res = -9223372036854775809
2015 echo $?/$^ERRNAME $res
2016 vput vexpr res @= -9223372036854775809
2017 echo $?/$^ERRNAME $res
2018 vput vexpr res = U9223372036854775809
2019 echo $?/$^ERRNAME $res
2020 echo ' #0.1'
2021 vput vexpr res = \
2022 0b0111111111111111111111111111111111111111111111111111111111111111
2023 echo $?/$^ERRNAME $res
2024 vput vexpr res = \
2025 S0b1000000000000000000000000000000000000000000000000000000000000000
2026 echo $?/$^ERRNAME $res
2027 vput vexpr res @= \
2028 S0b1000000000000000000000000000000000000000000000000000000000000000
2029 echo $?/$^ERRNAME $res
2030 vput vexpr res = \
2031 U0b1000000000000000000000000000000000000000000000000000000000000000
2032 echo $?/$^ERRNAME $res
2033 vput vexpr res = \
2034 0b1000000000000000000000000000000000000000000000000000000000000000
2035 echo $?/$^ERRNAME $res
2036 vput vexpr res @= \
2037 0b1000000000000000000000000000000000000000000000000000000000000000
2038 echo $?/$^ERRNAME $res
2039 vput vexpr res = \
2040 -0b1000000000000000000000000000000000000000000000000000000000000000
2041 echo $?/$^ERRNAME $res
2042 vput vexpr res = \
2043 S0b1000000000000000000000000000000000000000000000000000000000000001
2044 echo $?/$^ERRNAME $res
2045 vput vexpr res @= \
2046 S0b1000000000000000000000000000000000000000000000000000000000000001
2047 echo $?/$^ERRNAME $res
2048 vput vexpr res @= \
2049 -0b1000000000000000000000000000000000000000000000000000000000000001
2050 echo $?/$^ERRNAME $res
2051 vput vexpr res = \
2052 U0b1000000000000000000000000000000000000000000000000000000000000001
2053 echo $?/$^ERRNAME $res
2054 echo ' #0.2'
2055 vput vexpr res = 0777777777777777777777
2056 echo $?/$^ERRNAME $res
2057 vput vexpr res = S01000000000000000000000
2058 echo $?/$^ERRNAME $res
2059 vput vexpr res @= S01000000000000000000000
2060 echo $?/$^ERRNAME $res
2061 vput vexpr res = U01000000000000000000000
2062 echo $?/$^ERRNAME $res
2063 vput vexpr res = 01000000000000000000000
2064 echo $?/$^ERRNAME $res
2065 vput vexpr res @= 01000000000000000000000
2066 echo $?/$^ERRNAME $res
2067 vput vexpr res = -01000000000000000000000
2068 echo $?/$^ERRNAME $res
2069 vput vexpr res = S01000000000000000000001
2070 echo $?/$^ERRNAME $res
2071 vput vexpr res @= S01000000000000000000001
2072 echo $?/$^ERRNAME $res
2073 vput vexpr res @= -01000000000000000000001
2074 echo $?/$^ERRNAME $res
2075 vput vexpr res = U01000000000000000000001
2076 echo $?/$^ERRNAME $res
2077 echo ' #0.3'
2078 vput vexpr res = 0x7FFFFFFFFFFFFFFF
2079 echo $?/$^ERRNAME $res
2080 vput vexpr res = S0x8000000000000000
2081 echo $?/$^ERRNAME $res
2082 vput vexpr res @= S0x8000000000000000
2083 echo $?/$^ERRNAME $res
2084 vput vexpr res = U0x8000000000000000
2085 echo $?/$^ERRNAME $res
2086 vput vexpr res = 0x8000000000000000
2087 echo $?/$^ERRNAME $res
2088 vput vexpr res @= 0x8000000000000000
2089 echo $?/$^ERRNAME $res
2090 vput vexpr res = -0x8000000000000000
2091 echo $?/$^ERRNAME $res
2092 vput vexpr res = S0x8000000000000001
2093 echo $?/$^ERRNAME $res
2094 vput vexpr res @= S0x8000000000000001
2095 echo $?/$^ERRNAME $res
2096 vput vexpr res @= -0x8000000000000001
2097 echo $?/$^ERRNAME $res
2098 vput vexpr res = u0x8000000000000001
2099 echo $?/$^ERRNAME $res
2100 echo ' #1'
2101 vput vexpr res ~ 0
2102 echo $?/$^ERRNAME $res
2103 vput vexpr res ~ 1
2104 echo $?/$^ERRNAME $res
2105 vput vexpr res ~ -1
2106 echo $?/$^ERRNAME $res
2107 echo ' #2'
2108 vput vexpr res + 0 0
2109 echo $?/$^ERRNAME $res
2110 vput vexpr res + 0 1
2111 echo $?/$^ERRNAME $res
2112 vput vexpr res + 1 1
2113 echo $?/$^ERRNAME $res
2114 echo ' #3'
2115 vput vexpr res + 9223372036854775807 0
2116 echo $?/$^ERRNAME $res
2117 vput vexpr res + 9223372036854775807 1
2118 echo $?/$^ERRNAME $res
2119 vput vexpr res @+ 9223372036854775807 1
2120 echo $?/$^ERRNAME $res
2121 vput vexpr res + 0 9223372036854775807
2122 echo $?/$^ERRNAME $res
2123 vput vexpr res + 1 9223372036854775807
2124 echo $?/$^ERRNAME $res
2125 vput vexpr res @+ 1 9223372036854775807
2126 echo $?/$^ERRNAME $res
2127 echo ' #4'
2128 vput vexpr res + -9223372036854775808 0
2129 echo $?/$^ERRNAME $res
2130 vput vexpr res + -9223372036854775808 -1
2131 echo $?/$^ERRNAME $res
2132 vput vexpr res @+ -9223372036854775808 -1
2133 echo $?/$^ERRNAME $res
2134 vput vexpr res + 0 -9223372036854775808
2135 echo $?/$^ERRNAME $res
2136 vput vexpr res + -1 -9223372036854775808
2137 echo $?/$^ERRNAME $res
2138 vput vexpr res @+ -1 -9223372036854775808
2139 echo $?/$^ERRNAME $res
2140 echo ' #5'
2141 vput vexpr res - 0 0
2142 echo $?/$^ERRNAME $res
2143 vput vexpr res - 0 1
2144 echo $?/$^ERRNAME $res
2145 vput vexpr res - 1 1
2146 echo $?/$^ERRNAME $res
2147 echo ' #6'
2148 vput vexpr res - 9223372036854775807 0
2149 echo $?/$^ERRNAME $res
2150 vput vexpr res - 9223372036854775807 -1
2151 echo $?/$^ERRNAME $res
2152 vput vexpr res @- 9223372036854775807 -1
2153 echo $?/$^ERRNAME $res
2154 vput vexpr res - 0 9223372036854775807
2155 echo $?/$^ERRNAME $res
2156 vput vexpr res - -1 9223372036854775807
2157 echo $?/$^ERRNAME $res
2158 vput vexpr res - -2 9223372036854775807
2159 echo $?/$^ERRNAME $res
2160 vput vexpr res @- -2 9223372036854775807
2161 echo $?/$^ERRNAME $res
2162 echo ' #7'
2163 vput vexpr res - -9223372036854775808 +0
2164 echo $?/$^ERRNAME $res
2165 vput vexpr res - -9223372036854775808 +1
2166 echo $?/$^ERRNAME $res
2167 vput vexpr res @- -9223372036854775808 +1
2168 echo $?/$^ERRNAME $res
2169 vput vexpr res - 0 -9223372036854775808
2170 echo $?/$^ERRNAME $res
2171 vput vexpr res - +1 -9223372036854775808
2172 echo $?/$^ERRNAME $res
2173 vput vexpr res @- +1 -9223372036854775808
2174 echo $?/$^ERRNAME $res
2175 echo ' #8'
2176 vput vexpr res + -13 -2
2177 echo $?/$^ERRNAME $res
2178 vput vexpr res - 0 0
2179 echo $?/$^ERRNAME $res
2180 vput vexpr res - 0 1
2181 echo $?/$^ERRNAME $res
2182 vput vexpr res - 1 1
2183 echo $?/$^ERRNAME $res
2184 vput vexpr res - -13 -2
2185 echo $?/$^ERRNAME $res
2186 echo ' #9'
2187 vput vexpr res * 0 0
2188 echo $?/$^ERRNAME $res
2189 vput vexpr res * 0 1
2190 echo $?/$^ERRNAME $res
2191 vput vexpr res * 1 1
2192 echo $?/$^ERRNAME $res
2193 vput vexpr res * -13 -2
2194 echo $?/$^ERRNAME $res
2195 echo ' #10'
2196 vput vexpr res / 0 0
2197 echo $?/$^ERRNAME $res
2198 vput vexpr res / 0 1
2199 echo $?/$^ERRNAME $res
2200 vput vexpr res / 1 1
2201 echo $?/$^ERRNAME $res
2202 vput vexpr res / -13 -2
2203 echo $?/$^ERRNAME $res
2204 echo ' #11'
2205 vput vexpr res % 0 0
2206 echo $?/$^ERRNAME $res
2207 vput vexpr res % 0 1
2208 echo $?/$^ERRNAME $res
2209 vput vexpr res % 1 1
2210 echo $?/$^ERRNAME $res
2211 vput vexpr res % -13 -2
2212 echo $?/$^ERRNAME $res
2213 __EOT
2215 check numeric 0 "${MBOX}" '960821755 1962'
2217 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
2218 vput vexpr res find 'bananarama' 'nana'
2219 echo $?/$^ERRNAME :$res:
2220 vput vexpr res find 'bananarama' 'bana'
2221 echo $?/$^ERRNAME :$res:
2222 vput vexpr res find 'bananarama' 'Bana'
2223 echo $?/$^ERRNAME :$res:
2224 vput vexpr res find 'bananarama' 'rama'
2225 echo $?/$^ERRNAME :$res:
2226 echo ' #1'
2227 vput vexpr res ifind 'bananarama' 'nana'
2228 echo $?/$^ERRNAME :$res:
2229 vput vexpr res ifind 'bananarama' 'bana'
2230 echo $?/$^ERRNAME :$res:
2231 vput vexpr res ifind 'bananarama' 'Bana'
2232 echo $?/$^ERRNAME :$res:
2233 vput vexpr res ifind 'bananarama' 'rama'
2234 echo $?/$^ERRNAME :$res:
2235 echo ' #2'
2236 vput vexpr res substring 'bananarama' 1
2237 echo $?/$^ERRNAME :$res:
2238 vput vexpr res substring 'bananarama' 3
2239 echo $?/$^ERRNAME :$res:
2240 vput vexpr res substring 'bananarama' 5
2241 echo $?/$^ERRNAME :$res:
2242 vput vexpr res substring 'bananarama' 7
2243 echo $?/$^ERRNAME :$res:
2244 vput vexpr res substring 'bananarama' 9
2245 echo $?/$^ERRNAME :$res:
2246 vput vexpr res substring 'bananarama' 10
2247 echo $?/$^ERRNAME :$res:
2248 vput vexpr res substring 'bananarama' 1 3
2249 echo $?/$^ERRNAME :$res:
2250 vput vexpr res substring 'bananarama' 3 3
2251 echo $?/$^ERRNAME :$res:
2252 vput vexpr res substring 'bananarama' 5 3
2253 echo $?/$^ERRNAME :$res:
2254 vput vexpr res substring 'bananarama' 7 3
2255 echo $?/$^ERRNAME :$res:
2256 vput vexpr res substring 'bananarama' 9 3
2257 echo $?/$^ERRNAME :$res:
2258 vput vexpr res substring 'bananarama' 10 3
2259 echo $?/$^ERRNAME :$res:
2260 echo ' #3'
2261 vput vexpr res substring 'bananarama' -1
2262 echo $?/$^ERRNAME :$res:
2263 vput vexpr res substring 'bananarama' -3
2264 echo $?/$^ERRNAME :$res:
2265 vput vexpr res substring 'bananarama' -5
2266 echo $?/$^ERRNAME :$res:
2267 vput vexpr res substring 'bananarama' -7
2268 echo $?/$^ERRNAME :$res:
2269 vput vexpr res substring 'bananarama' -9
2270 echo $?/$^ERRNAME :$res:
2271 vput vexpr res substring 'bananarama' -10
2272 echo $?/$^ERRNAME :$res:
2273 vput vexpr res substring 'bananarama' 1 -3
2274 echo $?/$^ERRNAME :$res:
2275 vput vexpr res substring 'bananarama' 3 -3
2276 echo $?/$^ERRNAME :$res:
2277 vput vexpr res substring 'bananarama' 5 -3
2278 echo $?/$^ERRNAME :$res:
2279 vput vexpr res substring 'bananarama' 7 -3
2280 echo $?/$^ERRNAME :$res:
2281 vput vexpr res substring 'bananarama' 9 -3
2282 echo $?/$^ERRNAME :$res:
2283 vput vexpr res substring 'bananarama' 10 -3
2284 echo $?/$^ERRNAME :$res:
2285 echo ' #4'
2286 vput vexpr res trim 'Cocoon Cocoon'
2287 echo $?/$^ERRNAME :$res:
2288 vput vexpr res trim ' Cocoon Cocoon '
2289 echo $?/$^ERRNAME :$res:
2290 vput vexpr res trim-front 'Cocoon Cocoon'
2291 echo $?/$^ERRNAME :$res:
2292 vput vexpr res trim-front ' Cocoon Cocoon '
2293 echo $?/$^ERRNAME :$res:
2294 vput vexpr res trim-end 'Cocoon Cocoon'
2295 echo $?/$^ERRNAME :$res:
2296 vput vexpr res trim-end ' Cocoon Cocoon '
2297 echo $?/$^ERRNAME :$res:
2298 __EOT
2300 check string 0 "${MBOX}" '3182004322 601'
2302 if have_feat regex; then
2303 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
2304 vput vexpr res regex 'bananarama' 'nana'
2305 echo $?/$^ERRNAME :$res:
2306 vput vexpr res regex 'bananarama' 'bana'
2307 echo $?/$^ERRNAME :$res:
2308 vput vexpr res regex 'bananarama' 'Bana'
2309 echo $?/$^ERRNAME :$res:
2310 vput vexpr res regex 'bananarama' 'rama'
2311 echo $?/$^ERRNAME :$res:
2312 echo ' #1'
2313 vput vexpr res iregex 'bananarama' 'nana'
2314 echo $?/$^ERRNAME :$res:
2315 vput vexpr res iregex 'bananarama' 'bana'
2316 echo $?/$^ERRNAME :$res:
2317 vput vexpr res iregex 'bananarama' 'Bana'
2318 echo $?/$^ERRNAME :$res:
2319 vput vexpr res iregex 'bananarama' 'rama'
2320 echo $?/$^ERRNAME :$res:
2321 echo ' #2'
2322 vput vexpr res regex 'bananarama' '(.*)nana(.*)' '\${1}a\${0}u{\$2}'
2323 echo $?/$^ERRNAME :$res:
2324 vput vexpr res regex 'bananarama' '(.*)bana(.*)' '\${1}a\${0}u\$2'
2325 echo $?/$^ERRNAME :$res:
2326 vput vexpr res regex 'bananarama' 'Bana(.+)' '\$1\$0'
2327 echo $?/$^ERRNAME :$res:
2328 vput vexpr res regex 'bananarama' '(.+)rama' '\$1\$0'
2329 echo $?/$^ERRNAME :$res:
2330 echo ' #3'
2331 vput vexpr res iregex 'bananarama' '(.*)nana(.*)' '\${1}a\${0}u{\$2}'
2332 echo $?/$^ERRNAME :$res:
2333 vput vexpr res iregex 'bananarama' '(.*)bana(.*)' '\${1}a\${0}u\$2'
2334 echo $?/$^ERRNAME :$res:
2335 vput vexpr res iregex 'bananarama' 'Bana(.+)' '\$1\$0'
2336 echo $?/$^ERRNAME :$res:
2337 vput vexpr res iregex 'bananarama' '(.+)rama' '\$1\$0'
2338 echo $?/$^ERRNAME :$res:
2339 echo ' #4'
2340 __EOT
2342 check regex 0 "${MBOX}" '3270360157 311'
2343 else
2344 printf 'vexpr-regex: unsupported, skipped\n'
2347 t_epilog
2350 t_call_ret() {
2351 t_prolog call_ret
2353 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Snomemdebug > "${MBOX}" 2>&1
2354 define w1 {
2355 echon ">$1 "
2356 vput vexpr i + $1 1
2357 if [ $i -le 42 ]
2358 vput vexpr j '&' $i 7
2359 if [ $j -eq 7 ]
2360 echo .
2362 call w1 $i
2363 wysh set i=$? k=$!
2364 vput vexpr j '&' $i 7
2365 echon "<$1/$i/$k "
2366 if [ $j -eq 7 ]
2367 echo .
2369 else
2370 echo ! The end for $1
2372 return $1
2374 # Transport $?/$! up the call chain
2375 define w2 {
2376 echon ">$1 "
2377 vput vexpr i + $1 1
2378 if [ $1 -lt 42 ]
2379 call w2 $i
2380 wysh set i=$? j=$! k=$^ERRNAME
2381 echon "<$1/$i/$k "
2382 return $i $j
2383 else
2384 echo ! The end for $1
2385 return $i $^ERR-BUSY
2387 echoerr au
2389 # Up and down it goes
2390 define w3 {
2391 echon ">$1/$2 "
2392 vput vexpr i + $1 1
2393 if [ $1 -lt 42 ]
2394 call w3 $i $2
2395 wysh set i=$? j=$!
2396 vput vexpr k - $1 $2
2397 if [ $k -eq 21 ]
2398 vput vexpr i + $1 1
2399 vput vexpr j + $2 1
2400 echo "# <$i/$j> .. "
2401 call w3 $i $j
2402 wysh set i=$? j=$!
2404 eval echon "<\$1=\$i/\$^ERRNAME-$j "
2405 return $i $j
2406 else
2407 echo ! The end for $1=$i/$2
2408 if [ "$2" != "" ]
2409 return $i $^ERR-DOM
2410 else
2411 return $i $^ERR-BUSY
2414 echoerr au
2417 call w1 0; echo ?=$? !=$!; echo -----;
2418 call w2 0; echo ?=$? !=$^ERRNAME; echo -----;
2419 call w3 0 1; echo ?=$? !=$^ERRNAME; echo -----;
2420 __EOT
2422 check 1 0 "${MBOX}" '1572045517 5922'
2424 t_epilog
2427 t_xcall() {
2428 t_prolog xcall
2430 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Snomemdebug > "${MBOX}" 2>&1
2431 define work {
2432 echon "$1 "
2433 vput vexpr i + $1 1
2434 if [ $i -le 1111 ]
2435 vput vexpr j '&' $i 7
2436 if [ $j -eq 7 ]
2437 echo .
2439 \xcall work $i $2
2441 echo ! The end for $1/$2
2442 if [ "$2" != "" ]
2443 return $i $^ERR-BUSY
2446 define xwork {
2447 \xcall work 0 $2
2449 call work 0
2450 echo ?=$? !=$!
2451 call xwork
2452 echo ?=$? !=$!
2453 xcall xwork
2454 echo ?=$? !=$^ERRNAME
2456 call work 0 yes
2457 echo ?=$? !=$^ERRNAME
2458 call xwork 0 yes
2459 echo ?=$? !=$^ERRNAME
2460 __EOT
2462 check 1 0 "${MBOX}" '2401702082 23801'
2466 if have_feat uistrings; then
2467 ${cat} <<- '__EOT' > "${BODY}"
2468 define __w {
2469 echon "$1 "
2470 vput vexpr i + $1 1
2471 if [ $i -le 111 ]
2472 vput vexpr j '&' $i 7
2473 if [ $j -eq 7 ]
2474 echo .
2476 \xcall __w $i $2
2478 echo ! The end for $1
2479 if [ $2 -eq 0 ]
2480 nonexistingcommand
2481 echo would be err with errexit
2482 return
2484 echo calling exit
2485 exit
2487 define work {
2488 echo eins
2489 call __w 0 0
2490 echo zwei, ?=$? !=$!
2491 localopts yes; set errexit
2492 ignerr call __w 0 0
2493 echo drei, ?=$? !=$^ERRNAME
2494 call __w 0 $1
2495 echo vier, ?=$? !=$^ERRNAME, this is an error
2497 ignerr call work 0
2498 echo outer 1, ?=$? !=$^ERRNAME
2499 xxxign call work 0
2500 echo outer 2, ?=$? !=$^ERRNAME, could be error if xxxign non-empty
2501 call work 1
2502 echo outer 3, ?=$? !=$^ERRNAME
2503 echo this is definitely an error
2504 __EOT
2506 < "${BODY}" ${MAILX} ${ARGS} -X'commandalias xxxign ignerr' \
2507 -Snomemdebug > "${MBOX}" 2>&1
2508 check 2 0 "${MBOX}" '3900716531 4200'
2510 < "${BODY}" ${MAILX} ${ARGS} -X'commandalias xxxign " "' \
2511 -Snomemdebug > "${MBOX}" 2>&1
2512 check 3 1 "${MBOX}" '1006776201 2799'
2513 else
2514 echo 'xcall-2: unsupported, skipped'
2515 echo 'xcall-3: unsupported, skipped'
2518 t_epilog
2521 t_vpospar() {
2522 t_prolog vpospar
2524 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
2525 vpospar set hey, "'you ", world!
2526 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2527 vput vpospar x quote; echo x<$x>
2528 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2529 vput vpospar y quote;echo y<$y>
2530 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2531 eval vpospar set ${y};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2532 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2534 define infun2 {
2535 echo infun2:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2536 vput vpospar z quote;echo infun2:z<$z>
2539 define infun {
2540 echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2541 vput vpospar y quote;echo infun:y<$y>
2542 eval vpospar set ${x};echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2543 vpospar clear;echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2544 eval call infun2 $x
2545 echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2546 eval vpospar set ${y};echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2549 call infun This "in a" fun
2550 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2551 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2552 __EOT
2553 check 1 0 "${MBOX}" '155175639 866'
2556 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
2557 set ifs=\'
2558 echo ifs<$ifs> ifs-ws<$ifs-ws>
2559 vpospar set hey, "'you ", world!
2560 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2561 vput vpospar x quote; echo x<$x>
2562 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2563 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2565 set ifs=,
2566 echo ifs<$ifs> ifs-ws<$ifs-ws>
2567 vpospar set hey, "'you ", world!
2568 unset ifs;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2569 set ifs=,
2570 vput vpospar x quote; echo x<$x>
2571 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2572 eval vpospar set ${x};\
2573 unset ifs;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2575 wysh set ifs=$',\t'
2576 echo ifs<$ifs> ifs-ws<$ifs-ws>
2577 vpospar set hey, "'you ", world!
2578 unset ifs; echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2579 wysh set ifs=$',\t'
2580 vput vpospar x quote; echo x<$x>
2581 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2582 eval vpospar set ${x};\
2583 unset ifs;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2584 __EOT
2585 check ifs 0 "${MBOX}" '2015927702 706'
2587 t_epilog
2590 t_atxplode() {
2591 t_prolog atxplode
2592 TRAP_EXIT_ADDONS="./.t*"
2594 ${cat} > ./.t.sh <<- '___'; ${cat} > ./.t.rc <<- '___'
2595 x() { echo $#; }
2596 xxx() {
2597 printf " (1/$#: <$1>)"
2598 shift
2599 if [ $# -gt 0 ]; then
2600 xxx "$@"
2601 else
2602 echo
2605 yyy() {
2606 eval "$@ ' ball"
2608 set --
2609 x "$@"
2610 x "$@"''
2611 x " $@"
2612 x "$@ "
2613 printf yyy;yyy 'xxx' "b\$'\t'u ' "
2614 printf xxx;xxx arg ,b u.
2615 printf xxx;xxx arg , .
2616 printf xxx;xxx arg ,ball.
2618 define x {
2619 echo $#
2621 define xxx {
2622 echon " (1/$#: <$1>)"
2623 shift
2624 if [ $# -gt 0 ]
2625 \xcall xxx "$@"
2626 endif
2627 echo
2629 define yyy {
2630 eval "$@ ' ball"
2632 vpospar set
2633 call x "$@"
2634 call x "$@"''
2635 call x " $@"
2636 call x "$@ "
2637 echon yyy;call yyy '\call xxx' "b\$'\t'u ' "
2638 echon xxx;call xxx arg ,b u.
2639 echon xxx;call xxx arg , .
2640 echon xxx;call xxx arg ,ball.
2643 ${MAILX} ${ARGS} -X'source ./.t.rc' -Xx > "${MBOX}" 2>&1
2644 check 1 0 "${MBOX}" '41566293 164'
2646 #${SHELL} ./.t.sh > ./.tshout 2>&1
2647 #check disproof-1 0 ./.tshout '41566293 164'
2649 t_epilog
2652 t_read() {
2653 t_prolog read
2654 TRAP_EXIT_ADDONS="./.t*"
2656 ${cat} <<- '__EOT' > .tin
2657 hey1, "'you ", world!
2658 hey2, "'you ", bugs bunny!
2659 hey3, "'you ",
2660 hey4, "'you "
2661 __EOT
2663 ${cat} <<- '__EOT' |\
2664 ${MAILX} ${ARGS} -X'readctl create ./.tin' > "${MBOX}" 2>&1
2665 read a b c
2666 echo $?/$^ERRNAME / <$a><$b><$c>
2667 read a b c
2668 echo $?/$^ERRNAME / <$a><$b><$c>
2669 read a b c
2670 echo $?/$^ERRNAME / <$a><$b><$c>
2671 read a b c
2672 echo $?/$^ERRNAME / <$a><$b><$c>
2673 unset a b c;read a b c
2674 echo $?/$^ERRNAME / <$a><$b><$c>
2675 readctl remove ./.tin;echo readctl remove:$?/$^ERRNAME
2676 __EOT
2677 check 1 0 "${MBOX}" '1527910147 173'
2679 ${cat} <<- '__EOT' > .tin2
2680 hey2.0,:"'you ",:world!:mars.:
2681 hey2.1,:"'you ",:world!
2682 hey2.2,:"'you ",:bugs bunny!
2683 hey2.3,:"'you ",:
2684 hey2.4,:"'you ":
2686 __EOT
2688 ${cat} <<- '__EOT' |\
2689 6< .tin2 ${MAILX} ${ARGS} -X 'readctl create 6' > "${MBOX}" 2>&1
2690 set ifs=:
2691 read a b c
2692 echo $?/$^ERRNAME / <$a><$b><$c>
2693 read a b c
2694 echo $?/$^ERRNAME / <$a><$b><$c>
2695 read a b c
2696 echo $?/$^ERRNAME / <$a><$b><$c>
2697 read a b c
2698 echo $?/$^ERRNAME / <$a><$b><$c>
2699 read a b c
2700 echo $?/$^ERRNAME / <$a><$b><$c>
2701 read a b c
2702 echo $?/$^ERRNAME / <$a><$b><$c>
2703 unset a b c;read a b c
2704 echo $?/$^ERRNAME / <$a><$b><$c>
2705 read a b c
2706 echo $?/$^ERRNAME / <$a><$b><$c>
2707 readctl remove 6;echo readctl remove:$?/$^ERRNAME
2708 __EOT
2709 check ifs 0 "${MBOX}" '890153490 298'
2711 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
2712 readctl create .tin
2713 readall d; echo $?/$^ERRNAME / <$d>
2714 wysh set d;readall d;echo $?/$^ERRNAME / <$d>
2715 readctl create .tin2
2716 readall d; echo $?/$^ERRNAME / <$d>
2717 wysh set d;readall d;echo $?/$^ERRNAME / <$d>
2718 readctl remove .tin;echo $?/$^ERRNAME;\
2719 readctl remove .tin2;echo $?/$^ERRNAME
2720 echo '### now with empty lines'
2721 ! printf 'one line\n\ntwo line\n\n' > ./.temptynl
2722 readctl create .temptynl;echo $?/$^ERRNAME
2723 readall d; echo "$?/$^ERRNAME / <$d>"
2724 readctl remove .temptynl;echo $?/$^ERRNAME
2725 __EOT
2726 check readall 0 "${MBOX}" '4113506527 405'
2728 t_epilog
2731 t_mbox() {
2732 t_prolog mbox
2733 TRAP_EXIT_ADDONS="./.t*"
2737 while [ ${i} -lt 113 ]; do
2738 printf 'm file://%s\n~s Subject %s\nHello %s!\n~.\n' \
2739 "${MBOX}" "${i}" "${i}"
2740 i=`add ${i} 1`
2741 done
2742 ) | ${MAILX} ${ARGS} > .tall 2>&1
2743 check 1 0 "${MBOX}" '1872102723 13784'
2744 check 1-outerr - ./.tall '4294967295 0' # empty file
2746 printf 'File "%s"\ncopy * "%s"\nFile "%s"\nfrom*' "${MBOX}" .tmbox1 .tmbox1 |
2747 ${MAILX} ${ARGS} -Sshowlast > .tall 2>&1
2748 check 2 0 .tall '3498373999 9103'
2750 printf 'File "%s"\ncopy * "file://%s"\nFile "file://%s"\nfrom*' \
2751 "${MBOX}" .tmbox2 .tmbox2 | ${MAILX} ${ARGS} -Sshowlast > .tall 2>&1
2752 check 3 0 .tall '381610797 9110'
2754 # copy only the odd (but the first), move the even
2756 printf 'File "file://%s"\ncopy ' .tmbox2
2758 while [ ${i} -lt 113 ]; do
2759 printf '%s ' "${i}"
2760 i=`add ${i} 2`
2761 done
2762 printf 'file://%s\nFile "file://%s"\nfrom*' .tmbox3 .tmbox3
2763 ) | ${MAILX} ${ARGS} -Sshowlast > .tall 2>&1
2764 check 4 0 .tmbox3 '4145104131 6890'
2765 check 5 - .tall '361127721 4573'
2766 # ...
2768 printf 'file "file://%s"\nmove ' .tmbox2
2770 while [ ${i} -lt 113 ]; do
2771 printf '%s ' "${i}"
2772 i=`add ${i} 2`
2773 done
2774 printf 'file://%s\nFile "file://%s"\nfrom*\nFile "file://%s"\nfrom*' \
2775 .tmbox3 .tmbox3 .tmbox2
2776 ) | ${MAILX} ${ARGS} -Sshowlast > .tall 2>>${ERR}
2777 check 6 0 .tmbox3 '3249991493 13784'
2778 if have_feat uistrings; then
2779 ${sed} 2d < .tall > .tallx
2780 else
2781 ${cp} .tall .tallx
2783 check 7 - .tallx '1584413080 13645'
2785 # Invalid MBOXes (after [f4db93b3])
2786 echo > .tinvmbox
2787 printf 'copy 1 ./.tinvmbox' | ${MAILX} ${ARGS} -Rf "${MBOX}" > .tall 2>&1
2788 check 8 0 .tinvmbox '896415941 122'
2789 check 9 - ./.tall '3146754194 33'
2791 echo ' ' > .tinvmbox
2792 printf 'copy 1 ./.tinvmbox' | ${MAILX} ${ARGS} -Rf "${MBOX}" > .tall 2>&1
2793 check 10 0 .tinvmbox '4011310616 124'
2794 check 11 - ./.tall '3146754194 33'
2796 { echo; echo; } > .tinvmbox # (not invalid)
2797 printf 'copy 1 ./.tinvmbox' | ${MAILX} ${ARGS} -Rf "${MBOX}" > .tall 2>&1
2798 check 12 0 .tinvmbox '287409579 123'
2799 check 13 - ./.tall '3146754194 33'
2801 # *mbox-rfc4155*, plus
2802 ${cat} <<-_EOT > ./.tinv1
2805 From MAILER-DAEMON-1 Wed Oct 2 01:50:07 1996
2806 Date: Wed, 02 Oct 1996 01:50:07 +0000
2808 Subject: Bad bad message 1
2810 From me to you, blinde Kuh!
2812 From MAILER-DAEMON-2 Wed Oct 2 01:50:07 1996
2813 Date: Wed, 02 Oct 1996 01:50:07 +0000
2815 Subject: Bad bad message 2
2817 From me to you, blindes Kalb!
2818 _EOT
2819 ${cp} ./.tinv1 ./.tinv2
2821 printf \
2822 'define mboxfix {
2823 \\localopts yes; \\wysh set mbox-rfc4155;\\wysh File "${1}";\\
2824 \\eval copy * "${2}"
2826 call mboxfix ./.tinv1 ./.tok' | ${MAILX} ${ARGS} > .tall 2>&1
2827 check_ex0 14-estat
2828 ${cat} ./.tinv1 ./.tok >> .tall
2829 check 14 - ./.tall '739301109 616'
2831 printf \
2832 'wysh file ./.tinv1 # ^From not repaired, but missing trailing NL is
2833 wysh File ./.tok # Just move away to nowhere
2834 set mbox-rfc4155
2835 wysh file ./.tinv2 # Fully repaired
2836 File ./.tok' | ${MAILX} ${ARGS} >>${ERR} 2>&1
2837 check_ex0 15-estat
2838 check 15-1 - ./.tinv1 '3178048820 332'
2839 check 15-2 - ./.tinv2 '4151504442 314'
2841 t_epilog
2844 t_maildir() {
2845 t_prolog maildir
2846 if have_feat maildir; then :; else
2847 echo 'maildir: unsupported, skipped'
2848 return
2851 TRAP_EXIT_ADDONS="./.t*"
2855 while [ ${i} -lt 112 ]; do
2856 printf 'm file://%s\n~s Subject %s\nHello %s!\n~.\n' \
2857 "${MBOX}" "${i}" "${i}"
2858 i=`add ${i} 1`
2859 done
2860 ) | ${MAILX} ${ARGS}
2861 check 1 0 "${MBOX}" '1140119864 13780'
2863 printf 'File "%s"
2864 copy * "%s"
2865 File "%s"
2866 from*
2867 ' "${MBOX}" .tmdir1 .tmdir1 |
2868 ${MAILX} ${ARGS} -Snewfolders=maildir -Sshowlast > .tlst
2869 check 2 0 .tlst '1797938753 9103'
2871 printf 'File "%s"
2872 copy * "maildir://%s"
2873 File "maildir://%s"
2874 from*
2875 ' "${MBOX}" .tmdir2 .tmdir2 |
2876 ${MAILX} ${ARGS} -Sshowlast > .tlst
2877 check 3 0 .tlst '1155631089 9113'
2879 printf 'File "maildir://%s"
2880 copy * "file://%s"
2881 File "file://%s"
2882 from*
2883 ' .tmdir2 .tmbox1 .tmbox1 |
2884 ${MAILX} ${ARGS} -Sshowlast > .tlst
2885 check 4 0 .tmbox1 '2646131190 13220'
2886 check 5 - .tlst '3701297796 9110'
2888 # only the odd (even)
2890 printf 'File "maildir://%s"
2891 copy ' .tmdir2
2893 while [ ${i} -lt 112 ]; do
2894 j=`modulo ${i} 2`
2895 [ ${j} -eq 1 ] && printf '%s ' "${i}"
2896 i=`add ${i} 1`
2897 done
2898 printf ' file://%s
2899 File "file://%s"
2900 from*
2901 ' .tmbox2 .tmbox2
2902 ) | ${MAILX} ${ARGS} -Sshowlast > .tlst
2903 check 6 0 .tmbox2 '142890131 6610'
2904 check 7 - .tlst '960096773 4573'
2905 # ...
2907 printf 'file "maildir://%s"
2908 move ' .tmdir2
2910 while [ ${i} -lt 112 ]; do
2911 j=`modulo ${i} 2`
2912 [ ${j} -eq 0 ] && [ ${i} -ne 0 ] && printf '%s ' "${i}"
2913 i=`add ${i} 1`
2914 done
2915 printf ' file://%s
2916 File "file://%s"
2917 from*
2918 File "maildir://%s"
2919 from*
2920 ' .tmbox2 .tmbox2 .tmdir2
2921 ) | ${MAILX} ${ARGS} -Sshowlast > .tlst
2922 check 8 0 .tmbox2 '3806905791 13100'
2923 ${sed} 2d < .tlst > .tlstx
2924 check 9 - .tlstx '4216815295 13645'
2926 t_epilog
2929 t_record_a_resend() {
2930 t_prolog record_a_resend
2931 TRAP_EXIT_ADDONS="./.t.record ./.t.resent"
2933 printf '
2934 set record=%s
2935 m %s\n~s Subject 1.\nHello.\n~.
2936 set record-files add-file-recipients
2937 m %s\n~s Subject 2.\nHello.\n~.
2938 File %s
2939 resend 2 ./.t.resent
2940 Resend 1 ./.t.resent
2941 set record-resent
2942 resend 2 ./.t.resent
2943 Resend 1 ./.t.resent
2944 ' ./.t.record "${MBOX}" "${MBOX}" "${MBOX}" |
2945 ${MAILX} ${ARGS}
2947 check 1 0 "${MBOX}" '3057873538 256'
2948 check 2 - .t.record '391356429 460'
2949 check 3 - .t.resent '2685231691 648'
2951 t_epilog
2954 t_e_H_L_opts() {
2955 t_prolog e_H_L_opts
2956 TRAP_EXIT_ADDONS="./.tmta.sh ./.t.mbox"
2958 t_xmta 'Alchemilla Wed Apr 07 17:03:33 2017' ./.t.mbox
2960 touch ./.t.mbox
2961 ${MAILX} ${ARGS} -ef ./.t.mbox
2962 echo ${?} > "${MBOX}"
2964 printf 'm me@exam.ple\nLine 1.\nHello.\n~.\n' |
2965 ${MAILX} ${ARGS} -Smta=./.tmta.sh
2966 printf 'm you@exam.ple\nLine 1.\nBye.\n~.\n' |
2967 ${MAILX} ${ARGS} -Smta=./.tmta.sh
2969 ${MAILX} ${ARGS} -ef ./.t.mbox
2970 echo ${?} >> "${MBOX}"
2971 ${MAILX} ${ARGS} -efL @t@me ./.t.mbox
2972 echo ${?} >> "${MBOX}"
2973 ${MAILX} ${ARGS} -efL @t@you ./.t.mbox
2974 echo ${?} >> "${MBOX}"
2975 ${MAILX} ${ARGS} -efL '@>@Line 1' ./.t.mbox
2976 echo ${?} >> "${MBOX}"
2977 ${MAILX} ${ARGS} -efL '@>@Hello.' ./.t.mbox
2978 echo ${?} >> "${MBOX}"
2979 ${MAILX} ${ARGS} -efL '@>@Bye.' ./.t.mbox
2980 echo ${?} >> "${MBOX}"
2981 ${MAILX} ${ARGS} -efL '@>@Good bye.' ./.t.mbox
2982 echo ${?} >> "${MBOX}"
2984 ${MAILX} ${ARGS} -fH ./.t.mbox >> "${MBOX}"
2985 echo ${?} >> "${MBOX}"
2986 ${MAILX} ${ARGS} -fL @t@me ./.t.mbox >> "${MBOX}"
2987 echo ${?} >> "${MBOX}"
2988 ${MAILX} ${ARGS} -fL @t@you ./.t.mbox >> "${MBOX}"
2989 echo ${?} >> "${MBOX}"
2990 ${MAILX} ${ARGS} -fL '@>@Line 1' ./.t.mbox >> "${MBOX}"
2991 echo ${?} >> "${MBOX}"
2992 ${MAILX} ${ARGS} -fL '@>@Hello.' ./.t.mbox >> "${MBOX}"
2993 echo ${?} >> "${MBOX}"
2994 ${MAILX} ${ARGS} -fL '@>@Bye.' ./.t.mbox >> "${MBOX}"
2995 echo ${?} >> "${MBOX}"
2996 ${MAILX} ${ARGS} -fL '@>@Good bye.' ./.t.mbox >> "${MBOX}" 2>>${ERR}
2997 echo ${?} >> "${MBOX}"
2999 check 1 - "${MBOX}" '1708955574 678'
3001 t_epilog
3004 t_alternates() {
3005 t_prolog alternates
3006 TRAP_EXIT_ADDONS="./.t*"
3008 t_xmta 'Valeriana Sat Jul 08 15:54:03 2017'
3010 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Smta=./.tmta.sh > ./.tall 2>&1
3011 echo --0
3012 alternates
3013 echo $?/$^ERRNAME
3014 alternates a1@b1 a2@b2 a3@b3
3015 echo $?/$^ERRNAME
3016 alternates
3017 echo $?/$^ERRNAME
3018 vput alternates rv
3019 echo $?/$^ERRNAME <$rv>
3021 echo --1
3022 unalternates a2@b2
3023 vput alternates rv
3024 echo $?/$^ERRNAME <$rv>
3025 unalternates a3@b3
3026 vput alternates rv
3027 echo $?/$^ERRNAME <$rv>
3028 unalternates a1@b1
3029 vput alternates rv
3030 echo $?/$^ERRNAME <$rv>
3032 echo --2
3033 unalternates *
3034 alternates a1@b1 a2@b2 a3@b3
3035 unalternates a3@b3
3036 vput alternates rv
3037 echo $?/$^ERRNAME <$rv>
3038 unalternates a2@b2
3039 vput alternates rv
3040 echo $?/$^ERRNAME <$rv>
3041 unalternates a1@b1
3042 vput alternates rv
3043 echo $?/$^ERRNAME <$rv>
3045 echo --3
3046 alternates a1@b1 a2@b2 a3@b3
3047 unalternates a1@b1
3048 vput alternates rv
3049 echo $?/$^ERRNAME <$rv>
3050 unalternates a2@b2
3051 vput alternates rv
3052 echo $?/$^ERRNAME <$rv>
3053 unalternates a3@b3
3054 vput alternates rv
3055 echo $?/$^ERRNAME <$rv>
3057 echo --4
3058 unalternates *
3059 alternates a1@b1 a2@b2 a3@b3
3060 unalternates *
3061 vput alternates rv
3062 echo $?/$^ERRNAME <$rv>
3064 echo --5
3065 unalternates *
3066 alternates a1@b1 a1@c1 a1@d1 a2@b2 a3@b3 a3@c3 a3@d3
3067 m a1@b1 a1@c1 a1@d1
3068 ~s all alternates, only a1@b1 remains
3069 ~c a2@b2
3070 ~b a3@b3 a3@c3 a3@d3
3071 ~r - '_EOT'
3072 This body is!
3073 This also body is!!
3074 _EOT
3077 echo --6
3078 unalternates *
3079 alternates a1@b1 a1@c1 a2@b2 a3@b3
3080 m a1@b1 a1@c1 a1@d1
3081 ~s a1@b1 a1@d1, and a3@c3 a3@d3 remain
3082 ~c a2@b2
3083 ~b a3@b3 a3@c3 a3@d3
3084 ~r - '_EOT'
3085 This body2 is!
3086 _EOT
3089 echo --7
3090 alternates a1@b1 a2@b2 a3; set allnet
3091 m a1@b1 a1@c1 a1@d1
3092 ~s all alternates via allnet, only a1@b1 remains
3093 ~c a2@b2
3094 ~b a3@b3 a3@c3 a3@d3
3095 ~r - '_EOT'
3096 This body3 is!
3097 _EOT
3100 echo --10
3101 unalternates *
3102 alternates a1@b1
3103 echo $?/$^ERRNAME
3104 vput alternates rv
3105 echo $?/$^ERRNAME <$rv>
3106 alternates a2@b2
3107 echo $?/$^ERRNAME
3108 vput alternates rv
3109 echo $?/$^ERRNAME <$rv>
3110 alternates a3@b3
3111 echo $?/$^ERRNAME
3112 vput alternates rv
3113 echo $?/$^ERRNAME <$rv>
3114 alternates a4@b4
3115 echo $?/$^ERRNAME
3116 vput alternates rv
3117 echo $?/$^ERRNAME <$rv>
3119 unalternates *
3120 vput alternates rv
3121 echo $?/$^ERRNAME <$rv>
3123 echo --11
3124 set posix
3125 alternates a1@b1 a2@b2
3126 echo $?/$^ERRNAME
3127 vput alternates rv
3128 echo $?/$^ERRNAME <$rv>
3129 alternates a3@b3 a4@b4
3130 echo $?/$^ERRNAME
3131 vput alternates rv
3132 echo $?/$^ERRNAME <$rv>
3133 __EOT
3135 check 1 0 "${MBOX}" '142184864 515'
3136 if have_feat uistrings; then
3137 check 2 - .tall '1878598364 505'
3138 else
3139 echo 'alternates-2: unsupported, skipped'
3142 t_epilog
3145 t_alias() {
3146 t_prolog alias
3147 TRAP_EXIT_ADDONS="./.t*"
3149 t_xmta 'Hippocastanum Mon Jun 19 15:07:07 2017'
3151 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Smta=./.tmta.sh > ./.tall 2>&1
3152 alias a1 ex1@a1.ple
3153 alias a1 ex2@a1.ple "EX3 <ex3@a1.ple>"
3154 alias a1 ex4@a1.ple
3155 alias a2 ex1@a2.ple ex2@a2.ple ex3@a2.ple ex4@a2.ple
3156 alias a3 a4
3157 alias a4 a5 ex1@a4.ple
3158 alias a5 a6
3159 alias a6 a7 ex1@a6.ple
3160 alias a7 a8
3161 alias a8 ex1@a8.ple
3162 alias a1
3163 alias a2
3164 alias a3
3165 m a1
3166 ~c a2
3167 ~b a3
3168 ~r - '_EOT'
3169 This body is!
3170 This also body is!!
3171 _EOT
3172 __EOT
3173 check 1 0 "${MBOX}" '2496925843 272'
3174 check 2 - .tall '3548953204 152'
3176 # TODO t_alias: n_ALIAS_MAXEXP is compile-time constant,
3177 # TODO need to somehow provide its contents to the test, then test
3179 t_epilog
3182 t_filetype() {
3183 t_prolog filetype
3184 TRAP_EXIT_ADDONS="./.t*"
3186 t_xmta 'Alchemilla Wed Apr 25 15:12:13 2017'
3188 printf 'm m1@e.t\nL1\nHy1\n~.\nm m2@e.t\nL2\nHy2\n~@ %s\n~.\n' \
3189 "${SRCDIR}snailmail.jpg" | ${MAILX} ${ARGS} -Smta=./.tmta.sh
3190 check 1 0 "${MBOX}" '1594682963 13520'
3192 if (echo | gzip -c) >/dev/null 2>&1; then
3194 printf 'File "%s"\ncopy 1 ./.t.mbox.gz\ncopy 2 ./.t.mbox.gz' \
3195 "${MBOX}" | ${MAILX} ${ARGS} \
3196 -X'filetype gz gzip\ -dc gzip\ -c'
3197 printf 'File ./.t.mbox.gz\ncopy * ./.t.mbox\n' |
3198 ${MAILX} ${ARGS} -X'filetype gz gzip\ -dc gzip\ -c'
3199 } > ./.t.out 2>&1
3200 check 2 - "./.t.mbox" '1594682963 13520'
3201 check 3 - "./.t.out" '2392348396 102'
3202 else
3203 echo 'filetype-2: unsupported, skipped'
3204 echo 'filetype-3: unsupported, skipped'
3208 ${rm} ./.t.mbox*
3209 printf 'File "%s"\ncopy 1 ./.t.mbox.gz
3210 copy 2 ./.t.mbox.gz
3211 copy 1 ./.t.mbox.gz
3212 copy 2 ./.t.mbox.gz
3213 ' "${MBOX}" |
3214 ${MAILX} ${ARGS} \
3215 -X'filetype gz gzip\ -dc gzip\ -c' \
3216 -X'filetype mbox.gz "${sed} 1,3d|${cat}" \
3217 "echo eins;echo zwei;echo und mit ${sed} bist Du dabei;${cat}"'
3218 printf 'File ./.t.mbox.gz\ncopy * ./.t.mbox\n' |
3219 ${MAILX} ${ARGS} \
3220 -X'filetype gz gzip\ -dc gzip\ -c' \
3221 -X'filetype mbox.gz "${sed} 1,3d|${cat}" kill\ 0'
3222 } > ./.t.out 2>&1
3223 check 4 - "./.t.mbox" '2886541147 27060'
3224 check 5 - "./.t.out" '852335377 172'
3226 t_epilog
3229 t_message_injections() {
3230 t_prolog message_injections
3231 TRAP_EXIT_ADDONS="./.t*"
3233 t_xmta 'Echinacea Tue Jun 20 15:54:02 2017'
3235 echo mysig > ./.tmysig
3237 echo some-body | ${MAILX} ${ARGS} -Smta=./.tmta.sh \
3238 -Smessage-inject-head=head-inject \
3239 -Smessage-inject-tail=tail-inject \
3240 -Ssignature=./.tmysig \
3241 ex@am.ple > ./.tall 2>&1
3242 check 1 0 "${MBOX}" '2434746382 134'
3243 check 2 - .tall '4294967295 0' # empty file
3245 ${rm} "${MBOX}"
3246 ${cat} <<-_EOT > ./.template
3247 From: me
3248 To: ex1@am.ple
3249 Cc: ex2@am.ple
3250 Subject: This subject is
3252 Body, body, body me.
3253 _EOT
3254 < ./.template ${MAILX} ${ARGS} -t -Smta=./.tmta.sh \
3255 -Smessage-inject-head=head-inject \
3256 -Smessage-inject-tail=tail-inject \
3257 -Ssignature=./.tmysig \
3258 > ./.tall 2>&1
3259 check 3 0 "${MBOX}" '3114203412 198'
3260 check 4 - .tall '4294967295 0' # empty file
3262 t_epilog
3265 t_attachments() {
3266 t_prolog attachments
3267 TRAP_EXIT_ADDONS="./.t*"
3269 t_xmta 'Cannabis Sun Feb 18 02:02:46 2018'
3271 ${cat} <<-_EOT > ./.tx
3272 From steffen Sun Feb 18 02:48:40 2018
3273 Date: Sun, 18 Feb 2018 02:48:40 +0100
3275 Subject: m1
3276 User-Agent: s-nail v14.9.7
3279 From steffen Sun Feb 18 02:48:42 2018
3280 Date: Sun, 18 Feb 2018 02:48:42 +0100
3282 Subject: m2
3283 User-Agent: s-nail v14.9.7
3286 _EOT
3287 echo att1 > ./.t1
3288 printf 'att2-1\natt2-2\natt2-4\n' > ./'.t 2'
3289 printf 'att3-1\natt3-2\natt3-4\n' > ./.t3
3290 printf 'att4-1\natt4-2\natt4-4\n' > './.t 4'
3292 printf \
3293 '!@ ./.t3 "./.t 4" ""
3296 ./.t3
3297 "./.t 2"
3300 !.' \
3301 | ${MAILX} ${ARGS} -Sescape=! -Smta=./.tmta.sh \
3302 -a ./.t1 -a './.t 2' \
3303 -s attachment-test \
3304 ex@am.ple > ./.tall 2>&1
3305 check 1 0 "${MBOX}" '4107062253 634'
3306 if have_feat uistrings; then
3307 check 2 - .tall '1928331872 720'
3308 else
3309 echo 'attachments-2: unsupported, skipped'
3312 ${rm} "${MBOX}"
3313 printf \
3314 'mail ex@amp.ple
3315 !s This the subject is
3316 !@ ./.t3 "#2" "./.t 4" "#1" ""
3319 "./.t 4"
3320 "#2"
3324 mail ex@amp.ple
3325 !s Subject two
3326 !@ ./.t3 "#2" "./.t 4" "#1" ""
3332 mail ex@amp.ple
3333 !s Subject three
3334 !@ ./.t3 "" "#2" "" "./.t 4" "" "#1" ""
3337 ./.t3
3341 mail ex@amp.ple
3342 !s Subject Four
3343 !@ ./.t3 "" "#2" "" "./.t 4" "" "#1" ""
3346 "#1"
3350 mail ex@amp.ple
3351 !s Subject Five
3353 "#2"
3356 !.' \
3357 | ${MAILX} ${ARGS} -Sescape=! -Smta=./.tmta.sh -Rf ./.tx \
3358 > ./.tall 2>&1
3359 check 3 0 "${MBOX}" '798122412 2285'
3360 if have_feat uistrings; then
3361 check 4 - .tall '2526106274 1910'
3362 else
3363 echo 'attachments-4: unsupported, skipped'
3366 ${rm} "${MBOX}"
3367 printf \
3368 'mail ex@amp.ple
3369 !s Subject One
3370 !@ "#."
3371 Body one.
3374 from 2
3375 mail ex@amp.ple
3376 !s Subject Two
3378 "#."
3380 Body two.
3383 reply 1 2
3384 !@ "#."
3388 "#."
3391 !.' \
3392 | ${MAILX} ${ARGS} -Sescape=! -Smta=./.tmta.sh -Rf ./.tx \
3393 > ./.tall 2>&1
3394 check 5 0 "${MBOX}" '2165311808 2276'
3395 if have_feat uistrings; then
3396 check 6 - .tall '3662598562 509'
3397 else
3398 echo 'attachments-6: unsupported, skipped'
3401 t_epilog
3404 t_compose_hooks() { # TODO monster
3405 t_prolog compose_hooks
3406 if have_feat uistrings; then :; else
3407 echo 'compose_hooks: unsupported, skipped'
3408 return
3410 TRAP_EXIT_ADDONS="./.t*"
3412 t_xmta 'PrimulaVeris Wed Apr 10 22:59:00 2017'
3414 (echo line one&&echo line two&&echo line three) > ./.treadctl
3415 (echo echo four&&echo echo five&&echo echo six) > ./.tattach
3417 ${cat} <<'__EOT__' > ./.trc
3418 define bail {
3419 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
3421 define xerr {
3422 vput vexpr es substr "$1" 0 1
3423 if [ "$es" != 2 ]
3424 xcall bail "$2"
3427 define read_mline_res {
3428 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
3429 echo $len/$es/$^ERRNAME: $hl
3430 if [ $es -ne $^ERR-NONE ]
3431 xcall bail read_mline_res
3432 elif [ $len -ne 0 ]
3433 \xcall read_mline_res
3436 define ins_addr {
3437 wysh set xh=$1
3438 echo "~^header list"; read hl; echo $hl;\
3439 call xerr "$hl" "in_addr ($xh) 0-1"
3441 echo "~^header insert $xh diet <$xh@exam.ple> spliced";\
3442 read es; echo $es; call xerr "$es" "ins_addr $xh 1-1"
3443 echo "~^header insert $xh <${xh}2@exam.ple>";\
3444 read es; echo $es; call xerr "$es" "ins_addr $xh 1-2"
3445 echo "~^header insert $xh ${xh}3@exam.ple";\
3446 read es; echo $es; call xerr "$es" "ins_addr $xh 1-3"
3447 echo "~^header list $xh"; read hl; echo $hl;\
3448 call xerr "$hl" "ins_addr $xh 1-4"
3449 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 1-5"
3450 call read_mline_res
3452 if [ "$t_remove" == "" ]
3453 return
3456 echo "~^header remove $xh"; read es; call xerr $es "ins_addr $xh 2-1"
3457 echo "~^header remove $xh"; read es; vput vexpr es substr $es 0 3
3458 if [ $es != 501 ]
3459 xcall bail "ins_addr $xh 2-2"
3461 echo "~^header list $xh"; read es; vput vexpr es substr $es 0 3
3462 if [ $es != 501 ]
3463 xcall bail "ins_addr $xh 2-3"
3465 echo "~^header show $xh"; read es; vput vexpr es substr $es 0 3
3466 if [ $es != 501 ]
3467 xcall bail "ins_addr $xh 2-4"
3471 echo "~^header insert $xh diet <$xh@exam.ple> spliced";\
3472 read es; echo $es; call xerr "$es" "ins_addr $xh 3-1"
3473 echo "~^header insert $xh <${xh}2@exam.ple>";\
3474 read es; echo $es; call xerr "$es" "ins_addr $xh 3-2"
3475 echo "~^header insert $xh ${xh}3@exam.ple";\
3476 read es; echo $es; call xerr "$es" "ins_addr $xh 3-3"
3477 echo "~^header list $xh"; read hl; echo $hl;\
3478 call xerr "$hl" "ins_addr $xh 3-4"
3479 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 3-5"
3480 call read_mline_res
3482 echo "~^header remove-at $xh 1"; read es;\
3483 call xerr $es "ins_addr $xh 3-6"
3484 echo "~^header remove-at $xh 1"; read es;\
3485 call xerr $es "ins_addr $xh 3-7"
3486 echo "~^header remove-at $xh 1"; read es;\
3487 call xerr $es "ins_addr $xh 3-8"
3488 echo "~^header remove-at $xh 1"; read es;\
3489 vput vexpr es substr $es 0 3
3490 if [ $es != 501 ]
3491 xcall bail "ins_addr $xh 3-9"
3493 echo "~^header remove-at $xh T"; read es;\
3494 vput vexpr es substr $es 0 3
3495 if [ $es != 505 ]
3496 xcall bail "ins_addr $xh 3-10"
3498 echo "~^header list $xh"; read es;\
3499 vput vexpr es substr $es 0 3
3500 if [ $es != 501 ]
3501 xcall bail "ins_addr $xh 3-11"
3503 echo "~^header show $xh"; read es;\
3504 vput vexpr es substr $es 0 3
3505 if [ $es != 501 ]
3506 xcall bail "ins_addr $xh 3-12"
3510 echo "~^header insert $xh diet <$xh@exam.ple> spliced";\
3511 read es; echo $es; call xerr "$es" "ins_addr $xh 4-1"
3512 echo "~^header insert $xh <${xh}2@exam.ple> (comment) \"Quot(e)d\"";\
3513 read es; echo $es; call xerr "$es" "ins_addr $xh 4-2"
3514 echo "~^header insert $xh ${xh}3@exam.ple";\
3515 read es; echo $es; call xerr "$es" "ins_addr $xh 4-3"
3516 echo "~^header list $xh"; read hl; echo $hl;\
3517 call xerr "$hl" "header list $xh 3-4"
3518 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 4-5"
3519 call read_mline_res
3521 echo "~^header remove-at $xh 3"; read es;\
3522 call xerr $es "ins_addr $xh 4-6"
3523 echo "~^header remove-at $xh 2"; read es;\
3524 call xerr $es "ins_addr $xh 4-7"
3525 echo "~^header remove-at $xh 1"; read es;\
3526 call xerr $es "ins_addr $xh 4-8"
3527 echo "~^header remove-at $xh 1"; read es;\
3528 vput vexpr es substr $es 0 3
3529 if [ $es != 501 ]
3530 xcall bail "ins_addr $xh 4-9"
3532 echo "~^header remove-at $xh T"; read es;\
3533 vput vexpr es substr $es 0 3
3534 if [ $es != 505 ]
3535 xcall bail "ins_addr $xh 4-10"
3537 echo "~^header list $xh"; read es;\
3538 vput vexpr es substr $es 0 3
3539 if [ $es != 501 ]
3540 xcall bail "ins_addr $xh 4-11"
3542 echo "~^header show $xh"; read es;\
3543 vput vexpr es substr $es 0 3
3544 if [ $es != 501 ]
3545 xcall bail "ins_addr $xh 4-12"
3548 define ins_ref {
3549 wysh set xh=$1 mult=$2
3550 echo "~^header list"; read hl; echo $hl;\
3551 call xerr "$hl" "ins_ref ($xh) 0-1"
3553 echo "~^header insert $xh <$xh@exam.ple>";\
3554 read es; echo $es; call xerr "$es" "ins_ref $xh 1-1"
3555 if [ $mult -ne 0 ]
3556 echo "~^header insert $xh <${xh}2@exam.ple>";\
3557 read es; echo $es; call xerr "$es" "ins_ref $xh 1-2"
3558 echo "~^header insert $xh ${xh}3@exam.ple";\
3559 read es; echo $es; call xerr "$es" "ins_ref $xh 1-3"
3560 else
3561 echo "~^header insert $xh <${xh}2@exam.ple>"; read es;\
3562 vput vexpr es substr $es 0 3
3563 if [ $es != 506 ]
3564 xcall bail "ins_ref $xh 1-4"
3568 echo "~^header list $xh"; read hl; echo $hl;\
3569 call xerr "$hl" "ins_ref $xh 1-5"
3570 echo "~^header show $xh"; read es; call xerr $es "ins_ref $xh 1-6"
3571 call read_mline_res
3573 if [ "$t_remove" == "" ]
3574 return
3577 echo "~^header remove $xh"; read es;\
3578 call xerr $es "ins_ref $xh 2-1"
3579 echo "~^header remove $xh"; read es;\
3580 vput vexpr es substr $es 0 3
3581 if [ $es != 501 ]
3582 xcall bail "ins_ref $xh 2-2"
3584 echo "~^header list $xh"; read es;\
3585 vput vexpr es substr $es 0 3
3586 if [ $es != 501 ]
3587 xcall bail "$es ins_ref $xh 2-3"
3589 echo "~^header show $xh"; read es;\
3590 vput vexpr es substr $es 0 3
3591 if [ $es != 501 ]
3592 xcall bail "ins_ref $xh 2-4"
3596 echo "~^header insert $xh <$xh@exam.ple>";\
3597 read es; echo $es; call xerr "$es" "ins_ref $xh 3-1"
3598 if [ $mult -ne 0 ]
3599 echo "~^header insert $xh <${xh}2@exam.ple>";\
3600 read es; echo $es; call xerr "$es" "ins_ref $xh 3-2"
3601 echo "~^header insert $xh ${xh}3@exam.ple";\
3602 read es; echo $es; call xerr "$es" "ins_ref $xh 3-3"
3604 echo "~^header list $xh";\
3605 read hl; echo $hl; call xerr "$hl" "ins_ref $xh 3-4"
3606 echo "~^header show $xh";\
3607 read es; call xerr $es "ins_ref $xh 3-5"
3608 call read_mline_res
3610 echo "~^header remove-at $xh 1"; read es;\
3611 call xerr $es "ins_ref $xh 3-6"
3612 if [ $mult -ne 0 ] && [ $xh != subject ]
3613 echo "~^header remove-at $xh 1"; read es;\
3614 call xerr $es "ins_ref $xh 3-7"
3615 echo "~^header remove-at $xh 1"; read es;\
3616 call xerr $es "ins_ref $xh 3-8"
3618 echo "~^header remove-at $xh 1"; read es;\
3619 vput vexpr es substr $es 0 3
3620 if [ $es != 501 ]
3621 xcall bail "ins_ref $xh 3-9"
3623 echo "~^header remove-at $xh T"; read es;\
3624 vput vexpr es substr $es 0 3
3625 if [ $es != 505 ]
3626 xcall bail "ins_ref $xh 3-10"
3628 echo "~^header show $xh"; read es;\
3629 vput vexpr es substr $es 0 3
3630 if [ $es != 501 ]
3631 xcall bail "ins_ref $xh 3-11"
3635 echo "~^header insert $xh <$xh@exam.ple> ";\
3636 read es; echo $es; call xerr "$es" "ins_ref $xh 4-1"
3637 if [ $mult -ne 0 ]
3638 echo "~^header insert $xh <${xh}2@exam.ple> ";\
3639 read es; echo $es; call xerr "$es" "ins_ref $xh 4-2"
3640 echo "~^header insert $xh ${xh}3@exam.ple";\
3641 read es; echo $es; call xerr "$es" "ins_ref $xh 4-3"
3643 echo "~^header list $xh"; read hl; echo $hl;\
3644 call xerr "$hl" "ins_ref $xh 4-4"
3645 echo "~^header show $xh"; read es; call xerr $es "ins_ref $xh 4-5"
3646 call read_mline_res
3648 if [ $mult -ne 0 ] && [ $xh != subject ]
3649 echo "~^header remove-at $xh 3"; read es;\
3650 call xerr $es "ins_ref $xh 4-6"
3651 echo "~^header remove-at $xh 2"; read es;\
3652 call xerr $es "ins_ref $xh 4-7"
3654 echo "~^header remove-at $xh 1"; read es;\
3655 call xerr $es "ins_ref $xh 4-8"
3656 echo "~^header remove-at $xh 1"; read es;\
3657 vput vexpr es substr $es 0 3
3658 if [ $es != 501 ]
3659 xcall bail "ins_ref $xh 4-9"
3661 echo "~^header remove-at $xh T"; read es;\
3662 vput vexpr es substr $es 0 3
3663 if [ $es != 505 ]
3664 xcall bail "ins_ref $xh 4-10"
3666 echo "~^header show $xh"; read es;\
3667 vput vexpr es substr $es 0 3
3668 if [ $es != 501 ]
3669 xcall bail "ins_ref $xh 4-11"
3672 define t_header {
3673 echo t_header ENTER
3674 # In collect.c order
3675 call ins_addr from
3676 call ins_ref sender 0 # Not a "ref", but works
3677 call ins_addr To
3678 call ins_addr cC
3679 call ins_addr bCc
3680 call ins_addr reply-To
3681 call ins_addr mail-Followup-to
3682 call ins_ref messAge-id 0
3683 call ins_ref rEfErEncEs 1
3684 call ins_ref in-Reply-to 1
3685 call ins_ref subject 1 # Not a "ref", but works (with tweaks)
3686 call ins_addr freeForm1
3687 call ins_addr freeform2
3689 echo "~^header show MAILX-Command"; read es; call xerr $es "t_header 1000"
3690 call read_mline_res
3691 echo "~^header show MAILX-raw-TO"; read es; call xerr $es "t_header 1001"
3692 call read_mline_res
3694 echo t_header LEAVE
3696 define t_attach {
3697 echo t_attach ENTER
3699 echo "~^attachment";\
3700 read hl; echo $hl; vput vexpr es substr "$hl" 0 3
3701 if [ "$es" != 501 ]
3702 xcall bail "attach 0-1"
3705 echo "~^attach attribute ./.treadctl";\
3706 read hl; echo $hl; vput vexpr es substr "$hl" 0 3
3707 if [ "$es" != 501 ]
3708 xcall bail "attach 0-2"
3710 echo "~^attachment attribute-at 1";\
3711 read hl; echo $hl; vput vexpr es substr "$hl" 0 3
3712 if [ "$es" != 501 ]
3713 xcall bail "attach 0-3"
3716 echo "~^attachment insert ./.treadctl=ascii";\
3717 read hl; echo $hl; call xerr "$hl" "attach 1-1"
3718 echo "~^attachment list";\
3719 read es; echo $es;call xerr "$es" "attach 1-2"
3720 call read_mline_res
3721 echo "~^attachment attribute ./.treadctl";\
3722 read es; echo $es;call xerr "$es" "attach 1-3"
3723 call read_mline_res
3724 echo "~^attachment attribute .treadctl";\
3725 read es; echo $es;call xerr "$es" "attach 1-4"
3726 call read_mline_res
3727 echo "~^attachment attribute-at 1";\
3728 read es; echo $es;call xerr "$es" "attach 1-5"
3729 call read_mline_res
3731 echo "~^attachment attribute-set ./.treadctl filename rctl";\
3732 read es; echo $es;call xerr "$es" "attach 1-6"
3733 echo "~^attachment attribute-set .treadctl content-description Au";\
3734 read es; echo $es;call xerr "$es" "attach 1-7"
3735 echo "~^attachment attribute-set-at 1 content-id <10.du@ich>";\
3736 read es; echo $es;call xerr "$es" "attach 1-8"
3738 echo "~^attachment attribute ./.treadctl";\
3739 read es; echo $es;call xerr "$es" "attach 1-9"
3740 call read_mline_res
3741 echo "~^attachment attribute .treadctl";\
3742 read es; echo $es;call xerr "$es" "attach 1-10"
3743 call read_mline_res
3744 echo "~^attachment attribute rctl";\
3745 read es; echo $es;call xerr "$es" "attach 1-11"
3746 call read_mline_res
3747 echo "~^attachment attribute-at 1";\
3748 read es; echo $es;call xerr "$es" "attach 1-12"
3749 call read_mline_res
3752 echo "~^attachment insert ./.tattach=latin1";\
3753 read hl; echo $hl; call xerr "$hl" "attach 2-1"
3754 echo "~^attachment list";\
3755 read es; echo $es;call xerr "$es" "attach 2-2"
3756 call read_mline_res
3757 echo "~^attachment attribute ./.tattach";\
3758 read es; echo $es;call xerr "$es" "attach 2-3"
3759 call read_mline_res
3760 echo "~^attachment attribute .tattach";\
3761 read es; echo $es;call xerr "$es" "attach 2-4"
3762 call read_mline_res
3763 echo "~^attachment attribute-at 2";\
3764 read es; echo $es;call xerr "$es" "attach 2-5"
3765 call read_mline_res
3767 echo "~^attachment attribute-set ./.tattach filename tat";\
3768 read es; echo $es;call xerr "$es" "attach 2-6"
3769 echo \
3770 "~^attachment attribute-set .tattach content-description Au2";\
3771 read es; echo $es;call xerr "$es" "attach 2-7"
3772 echo "~^attachment attribute-set-at 2 content-id <20.du@wir>";\
3773 read es; echo $es;call xerr "$es" "attach 2-8"
3774 echo \
3775 "~^attachment attribute-set-at 2 content-type application/x-sh";\
3776 read es; echo $es;call xerr "$es" "attach 2-9"
3778 echo "~^attachment attribute ./.tattach";\
3779 read es; echo $es;call xerr "$es" "attach 2-10"
3780 call read_mline_res
3781 echo "~^attachment attribute .tattach";\
3782 read es; echo $es;call xerr "$es" "attach 2-11"
3783 call read_mline_res
3784 echo "~^attachment attribute tat";\
3785 read es; echo $es;call xerr "$es" "attach 2-12"
3786 call read_mline_res
3787 echo "~^attachment attribute-at 2";\
3788 read es; echo $es;call xerr "$es" "attach 2-13"
3789 call read_mline_res
3792 if [ "$t_remove" == "" ]
3793 return
3796 echo "~^attachment remove ./.treadctl"; read es;\
3797 call xerr $es "attach 3-1"
3798 echo "~^attachment remove ./.tattach"; read es;\
3799 call xerr $es "attach 3-2"
3800 echo "~^ attachment remove ./.treadctl"; read es;\
3801 vput vexpr es substr $es 0 3
3802 if [ $es != 501 ]
3803 xcall bail "attach 3-3"
3805 echo "~^ attachment remove ./.tattach"; read es;\
3806 vput vexpr es substr $es 0 3
3807 if [ $es != 501 ]
3808 xcall bail "attach 3-4"
3810 echo "~^attachment list"; read es;\
3811 vput vexpr es substr $es 0 3
3812 if [ $es != 501 ]
3813 xcall bail "attach 3-5"
3817 echo "~^attachment insert ./.tattach=latin1";\
3818 read hl; echo $hl; call xerr "$hl" "attach 4-1"
3819 echo "~^attachment insert ./.tattach=latin1";\
3820 read hl; echo $hl; call xerr "$hl" "attach 4-2"
3821 echo "~^attachment list";\
3822 read es; echo $es;call xerr "$es" "attach 4-3"
3823 call read_mline_res
3824 echo "~^ attachment remove .tattach"; read es;\
3825 vput vexpr es substr $es 0 3
3826 if [ $es != 506 ]
3827 xcall bail "attach 4-4 $es"
3829 echo "~^attachment remove-at T"; read es;\
3830 vput vexpr es substr $es 0 3
3831 if [ $es != 505 ]
3832 xcall bail "attach 4-5"
3834 echo "~^attachment remove ./.tattach"; read es;\
3835 call xerr $es "attach 4-6"
3836 echo "~^attachment remove ./.tattach"; read es;\
3837 call xerr $es "attach 4-7"
3838 echo "~^ attachment remove ./.tattach"; read es;\
3839 vput vexpr es substr $es 0 3
3840 if [ $es != 501 ]
3841 xcall bail "attach 4-8 $es"
3843 echo "~^attachment list"; read es;\
3844 vput vexpr es substr $es 0 3
3845 if [ $es != 501 ]
3846 xcall bail "attach 4-9"
3850 echo "~^attachment insert ./.tattach=latin1";\
3851 read hl; echo $hl; call xerr "$hl" "attach 5-1"
3852 echo "~^attachment insert ./.tattach=latin1";\
3853 read hl; echo $hl; call xerr "$hl" "attach 5-2"
3854 echo "~^attachment insert ./.tattach=latin1";\
3855 read hl; echo $hl; call xerr "$hl" "attach 5-3"
3856 echo "~^attachment list";\
3857 read es; echo $es;call xerr "$es" "attach 5-4"
3858 call read_mline_res
3860 echo "~^attachment remove-at 3"; read es;\
3861 call xerr $es "attach 5-5"
3862 echo "~^attachment remove-at 3"; read es;\
3863 vput vexpr es substr $es 0 3
3864 if [ $es != 501 ]
3865 xcall bail "attach 5-6"
3867 echo "~^attachment remove-at 2"; read es;\
3868 call xerr $es "attach 5-7"
3869 echo "~^attachment remove-at 2"; read es;\
3870 vput vexpr es substr $es 0 3
3871 if [ $es != 501 ]
3872 xcall bail "attach 5-8"
3874 echo "~^attachment remove-at 1"; read es;\
3875 call xerr $es "attach 5-9"
3876 echo "~^attachment remove-at 1"; read es;\
3877 vput vexpr es substr $es 0 3
3878 if [ $es != 501 ]
3879 xcall bail "attach 5-10"
3882 echo "~^attachment list"; read es;\
3883 vput vexpr es substr $es 0 3
3884 if [ $es != 501 ]
3885 xcall bail "attach 5-11"
3889 echo "~^attachment insert ./.tattach=latin1";\
3890 read hl; echo $hl; call xerr "$hl" "attach 6-1"
3891 echo "~^attachment insert ./.tattach=latin1";\
3892 read hl; echo $hl; call xerr "$hl" "attach 6-2"
3893 echo "~^attachment insert ./.tattach=latin1";\
3894 read hl; echo $hl; call xerr "$hl" "attach 6-3"
3895 echo "~^attachment list";\
3896 read es; echo $es;call xerr "$es" "attach 6-4"
3897 call read_mline_res
3899 echo "~^attachment remove-at 1"; read es;\
3900 call xerr $es "attach 6-5"
3901 echo "~^attachment remove-at 1"; read es;\
3902 call xerr $es "attach 6-6"
3903 echo "~^attachment remove-at 1"; read es;\
3904 call xerr $es "attach 6-7"
3905 echo "~^attachment remove-at 1"; read es;\
3906 vput vexpr es substr $es 0 3
3907 if [ $es != 501 ]
3908 xcall bail "attach 6-8"
3911 echo "~^attachment list"; read es;\
3912 vput vexpr es substr $es 0 3
3913 if [ $es != 501 ]
3914 xcall bail "attach 6-9"
3917 echo t_attach LEAVE
3919 define t_ocs {
3920 read ver
3921 echo t_ocs
3922 call t_header
3923 call t_attach
3925 define t_oce {
3926 echo on-compose-enter, mailx-command<$mailx-command>
3927 alternates alter1@exam.ple alter2@exam.ple
3928 alternates
3929 set autocc='alter1@exam.ple alter2@exam.ple'
3930 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3931 echo mailx-subject<$mailx-subject>
3932 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3933 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3934 mailx-raw-bcc<$mailx-raw-bcc>
3935 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
3936 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3938 define t_ocl {
3939 echo on-compose-leave, mailx-command<$mailx-command>
3940 vput alternates al
3941 eval alternates $al alter3@exam.ple alter4@exam.ple
3942 alternates
3943 set autobcc='alter3@exam.ple alter4@exam.ple'
3944 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3945 echo mailx-subject<$mailx-subject>
3946 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3947 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3948 mailx-raw-bcc<$mailx-raw-bcc>
3949 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
3950 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3952 define t_occ {
3953 echo on-compose-cleanup, mailx-command<$mailx-command>
3954 unalternates *
3955 alternates
3956 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3957 echo mailx-subject<$mailx-subject>
3958 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3959 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3960 mailx-raw-bcc<$mailx-raw-bcc>
3961 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
3962 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3964 wysh set on-compose-splice=t_ocs \
3965 on-compose-enter=t_oce on-compose-leave=t_ocl \
3966 on-compose-cleanup=t_occ
3967 __EOT__
3969 printf 'm this-goes@nowhere\nbody\n!.\n' |
3970 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
3971 -X'source ./.trc' -Smta=./.tmta.sh \
3972 >./.tall 2>&1
3973 ${cat} ./.tall >> "${MBOX}"
3974 check 1 0 "${MBOX}" '2481823179 10101'
3976 ${rm} "${MBOX}"
3977 printf 'm this-goes@nowhere\nbody\n!.\n' |
3978 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
3979 -St_remove=1 -X'source ./.trc' -Smta=./.tmta.sh \
3980 >./.tall 2>&1
3981 ${cat} ./.tall >> "${MBOX}"
3982 check 2 0 "${MBOX}" '3654000499 12535'
3986 # Some state machine stress, shell compose hook, localopts for hook, etc.
3987 # readctl in child. ~r as HERE document
3988 ${rm} "${MBOX}"
3989 printf 'm ex@am.ple\nbody\n!.
3990 echon ${mailx-command}${mailx-subject}
3991 echon ${mailx-from}${mailx-sender}
3992 echon ${mailx-to}${mailx-cc}${mailx-bcc}
3993 echon ${mailx-raw-to}${mailx-raw-cc}${mailx-raw-bcc}
3994 echon ${mailx-orig-from}${mailx-orig-to}${mailx-orig-gcc}${mailx-orig-bcc}
3995 var t_oce t_ocs t_ocs_sh t_ocl t_occ autocc
3996 ' | ${MAILX} ${ARGS} -Snomemdebug -Sescape=! \
3997 -Smta=./.tmta.sh \
3999 define bail {
4000 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
4002 define xerr {
4003 vput vexpr es substr "$1" 0 1
4004 if [ "$es" != 2 ]
4005 xcall bail "$2"
4008 define read_mline_res {
4009 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
4010 echo $len/$es/$^ERRNAME: $hl
4011 if [ $es -ne $^ERR-NONE ]
4012 xcall bail read_mline_res
4013 elif [ $len -ne 0 ]
4014 \xcall read_mline_res
4017 define _work {
4018 vput vexpr i + 1 "$2"
4019 if [ $i -lt 111 ]
4020 vput vexpr j % $i 10
4021 if [ $j -ne 0 ]
4022 set j=xcall
4023 else
4024 echon "$i.. "
4025 set j=call
4027 eval \\$j _work $1 $i
4028 return $?
4030 vput vexpr i + $i "$1"
4031 return $i
4033 define _read {
4034 wysh set line; read line;wysh set es=$? en=$^ERRNAME ;\
4035 echo read:$es/$en: $line
4036 if [ "${es}" -ne -1 ]
4037 xcall _read
4039 readctl remove $cwd/.treadctl; echo readctl remove:$?/$^ERRNAME
4041 define t_ocs {
4042 read ver
4043 echo t_ocs
4044 echo "~^header list"; read hl; echo $hl;\
4045 vput vexpr es substr "$hl" 0 1
4046 if [ "$es" != 2 ]
4047 xcall bail "header list"
4048 endif
4050 call _work 1; echo $?
4051 echo "~^header insert cc splicy diet <splice@exam.ple> spliced";\
4052 read es; echo $es; vput vexpr es substr "$es" 0 1
4053 if [ "$es" != 2 ]
4054 xcall bail "be diet"
4055 endif
4056 echo "~^header insert cc <splice2@exam.ple>";\
4057 read es; echo $es; vput vexpr es substr "$es" 0 1
4058 if [ "$es" != 2 ]
4059 xcall bail "be diet2"
4060 endif
4062 call _work 2; echo $?
4063 echo "~^header insert bcc juicy juice <juice@exam.ple> spliced";\
4064 read es; echo $es;vput vexpr es substr "$es" 0 1
4065 if [ "$es" != 2 ]
4066 xcall bail "be juicy"
4067 endif
4068 echo "~^header insert bcc juice2@exam.ple";\
4069 read es; echo $es;vput vexpr es substr "$es" 0 1
4070 if [ "$es" != 2 ]
4071 xcall bail "be juicy2"
4072 endif
4073 echo "~^header insert bcc juice3 <juice3@exam.ple>";\
4074 read es; echo $es;vput vexpr es substr "$es" 0 1
4075 if [ "$es" != 2 ]
4076 xcall bail "be juicy3"
4077 endif
4078 echo "~^header insert bcc juice4@exam.ple";\
4079 read es; echo $es;vput vexpr es substr "$es" 0 1
4080 if [ "$es" != 2 ]
4081 xcall bail "be juicy4"
4082 endif
4084 echo "~^header remove-at bcc 3";\
4085 read es; echo $es;vput vexpr es substr "$es" 0 1
4086 if [ "$es" != 2 ]
4087 xcall bail "remove juicy5"
4088 endif
4089 echo "~^header remove-at bcc 2";\
4090 read es; echo $es;vput vexpr es substr "$es" 0 1
4091 if [ "$es" != 2 ]
4092 xcall bail "remove juicy6"
4093 endif
4094 echo "~^header remove-at bcc 3";\
4095 read es; echo $es;vput vexpr es substr "$es" 0 3
4096 if [ "$es" != 501 ]
4097 xcall bail "failed to remove-at"
4098 endif
4099 # Add duplicates which ought to be removed!
4100 echo "~^header insert bcc juice4@exam.ple";\
4101 read es; echo $es;vput vexpr es substr "$es" 0 1
4102 if [ "$es" != 2 ]
4103 xcall bail "be juicy4-1"
4104 endif
4105 echo "~^header insert bcc juice4@exam.ple";\
4106 read es; echo $es;vput vexpr es substr "$es" 0 1
4107 if [ "$es" != 2 ]
4108 xcall bail "be juicy4-2"
4109 endif
4110 echo "~^header insert bcc juice4@exam.ple";\
4111 read es; echo $es;vput vexpr es substr "$es" 0 1
4112 if [ "$es" != 2 ]
4113 xcall bail "be juicy4-3"
4114 endif
4115 echo "~:set t_ocs"
4118 call _work 3; echo $?
4119 echo "~r - '__EOT'"
4120 vput ! i echo just knock if you can hear me;\
4121 i=0;\
4122 while [ $i -lt 24 ]; do printf "%s " $i; i=`expr $i + 1`; done;\
4123 echo relax
4124 echon shell-cmd says $?/$^ERRNAME: $i
4125 echo "~x will not become interpreted, we are reading until __EOT"
4126 echo "__EOT"
4127 read r_status; echo "~~r status output: $r_status"
4128 echo "~:echo $? $! $^ERRNAME"
4129 read r_status
4130 echo "~~r status from parent: $r_status"
4133 call _work 4; echo $?
4134 vput cwd cwd;echo cwd:$?
4135 readctl create $cwd/.treadctl ;echo readctl:$?/$^ERRNAME;\
4136 call _read
4139 call _work 5; echo $?
4140 echo "~^header show MAILX-Command"; read es;\
4141 call xerr $es "t_header 1000"; call read_mline_res
4142 echo "~^header show MAILX-raw-TO"; read es;\
4143 call xerr $es "t_header 1001"; xcall read_mline_res
4145 echoerr IT IS WRONG IF YOU SEE THIS
4147 define t_oce {
4148 echo on-compose-enter, mailx-command<$mailx-command>
4149 set t_oce autobcc=oce@exam.ple
4150 alternates alter1@exam.ple alter2@exam.ple
4151 alternates
4152 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
4153 echo mailx-subject<$mailx-subject>
4154 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
4155 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
4156 mailx-raw-bcc<$mailx-raw-bcc>
4157 echo mailx-orig-from<$mailx-orig-from> \
4158 mailx-orig-to<$mailx-orig-to> \
4159 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
4161 define t_ocl {
4162 echo on-compose-leave, mailx-command<$mailx-command>
4163 set t_ocl autocc=ocl@exam.ple
4164 unalternates *
4165 alternates alter3@exam.ple alter4@exam.ple
4166 alternates
4167 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
4168 echo mailx-subject<$mailx-subject>
4169 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
4170 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
4171 mailx-raw-bcc<$mailx-raw-bcc>
4172 echo mailx-orig-from<$mailx-orig-from> \
4173 mailx-orig-to<$mailx-orig-to> \
4174 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
4176 define t_occ {
4177 echo on-compose-cleanup, mailx-command<$mailx-command>
4178 set t_occ autocc=occ@exam.ple
4179 unalternates *
4180 alternates
4181 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
4182 echo mailx-subject<$mailx-subject>
4183 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
4184 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
4185 mailx-raw-bcc<$mailx-raw-bcc>
4186 echo mailx-orig-from<$mailx-orig-from> \
4187 mailx-orig-to<$mailx-orig-to> \
4188 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
4190 wysh set on-compose-splice=t_ocs \
4191 on-compose-splice-shell="read ver;echo t_ocs-shell;\
4192 echo \"~t shell@exam.ple\"; echo \"~:set t_ocs_sh\"" \
4193 on-compose-enter=t_oce on-compose-leave=t_ocl \
4194 on-compose-cleanup=t_occ
4195 ' > ./.tnotes 2>&1
4196 check_ex0 3-estat
4197 ${cat} ./.tnotes >> "${MBOX}"
4198 check 3 - "${MBOX}" '679526364 2431'
4200 # Reply, forward, resend, Resend
4202 ${rm} "${MBOX}"
4203 printf '#
4204 set from="f1@z
4205 m t1@z
4208 set from="du <f2@z>" stealthmua=noagent
4209 m t2@z
4212 ' | ${MAILX} ${ARGS} -Smta=./.tmta.sh -Snomemdebug -Sescape=!
4214 printf '
4215 echo start: $? $! $^ERRNAME
4216 File %s
4217 echo File: $? $! $^ERRNAME;echo;echo
4218 reply 1
4219 this is content of reply 1
4221 echo reply 1: $? $! $^ERRNAME;echo;echo
4222 Reply 1 2
4223 this is content of Reply 1 2
4225 echo Reply 1 2: $? $! $^ERRNAME;echo;echo
4226 forward 1 fwdex@am.ple
4227 this is content of forward 1
4229 echo forward 1: $? $! $^ERRNAME;echo;echo
4230 wysh set forward-inject-head=$'"'"'-- \\
4231 forward (%%a)(%%d)(%%f)(%%i)(%%n)(%%r) --\\n'"'"'
4232 wysh set forward-inject-tail=$'"'"'-- \\
4233 end of forward (%%i) --\\n'"'"'
4234 forward 2 fwdex@am.ple
4235 this is content of forward 2
4237 echo forward 2: $? $! $^ERRNAME;echo;echo
4238 set showname
4239 forward 2 fwdex2@am.ple
4240 this is content of forward 2, 2nd, with showname set
4242 echo forward 2, 2nd: $? $! $^ERRNAME;echo;echo
4243 resend 1 2 resendex@am.ple
4244 echo resend 1 2: $? $! $^ERRNAME;echo;echo
4245 Resend 1 2 Resendex@am.ple
4246 echo Resend 1 2: $? $! $^ERRNAME;echo;echo
4247 ' "${MBOX}" |
4248 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sfullnames \
4249 -Smta=./.tmta.sh \
4251 define bail {
4252 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
4254 define xerr {
4255 vput vexpr es substr "$1" 0 1
4256 if [ "$es" != 2 ]
4257 xcall bail "$2"
4260 define read_mline_res {
4261 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
4262 echo mline_res:$len/$es/$^ERRNAME: $hl
4263 if [ $es -ne $^ERR-NONE ]
4264 xcall bail read_mline_res
4265 elif [ $len -ne 0 ]
4266 \xcall read_mline_res
4269 define work_hl {
4270 echo "~^header show $1"; read es;\
4271 call xerr $es "work_hl $1"; echo $1; call read_mline_res
4272 if [ $# -gt 1 ]
4273 shift
4274 xcall work_hl "$@"
4277 define t_ocs {
4278 read ver
4279 echo t_ocs version $ver
4280 echo "~^header list"; read hl; echo $hl;\
4281 echoerr the header list is $hl;\
4282 call xerr "$hl" "header list"
4283 eval vpospar set $hl
4284 shift
4285 xcall work_hl "$@"
4286 echoerr IT IS WRONG IF YOU SEE THIS
4288 define t_oce {
4289 echo on-XY-enter, mailx-command<$mailx-command>
4290 set t_oce autobcc=oce@exam.ple
4291 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
4292 echo mailx-subject<$mailx-subject>
4293 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
4294 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
4295 mailx-raw-bcc<$mailx-raw-bcc>
4296 echo mailx-orig-from<$mailx-orig-from> \
4297 mailx-orig-to<$mailx-orig-to> \
4298 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
4300 define t_ocl {
4301 echo on-XY-leave, mailx-command<$mailx-command>
4302 set t_ocl autocc=ocl@exam.ple
4303 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
4304 echo mailx-subject<$mailx-subject>
4305 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
4306 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
4307 mailx-raw-bcc<$mailx-raw-bcc>
4308 echo mailx-orig-from<$mailx-orig-from> \
4309 mailx-orig-to<$mailx-orig-to> \
4310 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
4312 define t_occ {
4313 echo on-XY-cleanup, mailx-command<$mailx-command>
4314 set t_occ autocc=occ@exam.ple
4315 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
4316 echo mailx-subject<$mailx-subject>
4317 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
4318 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
4319 mailx-raw-bcc<$mailx-raw-bcc>
4320 echo mailx-orig-from<$mailx-orig-from> \
4321 mailx-orig-to<$mailx-orig-to> \
4322 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
4324 wysh set on-compose-splice=t_ocs \
4325 on-compose-enter=t_oce on-compose-leave=t_ocl \
4326 on-compose-cleanup=t_occ \
4327 on-resend-enter=t_oce on-resend-cleanup=t_occ
4328 ' > ./.tnotes 2>&1
4329 check_ex0 4-estat
4330 ${cat} ./.tnotes >> "${MBOX}"
4331 check 4 - "${MBOX}" '2151712038 11184'
4333 t_epilog
4336 t_C_opt_customhdr() {
4337 t_prolog C_opt_customhdr
4338 TRAP_EXIT_ADDONS="./.t*"
4340 t_xmta 'CimicifugaRacemosa Mon Dec 25 21:33:40 2017'
4342 echo bla |
4343 ${MAILX} ${ARGS} -Smta=./.tmta.sh \
4344 -C 'C-One : Custom One Body' \
4345 -C 'C-Two:CustomTwoBody' \
4346 -S customhdr='chdr1: chdr1 body, chdr2:chdr2 body' \
4347 this-goes@nowhere >./.tall 2>&1
4348 check_ex0 1-estat
4349 ${cat} ./.tall >> "${MBOX}"
4350 check 1 0 "${MBOX}" '2400078426 195'
4352 ${rm} "${MBOX}"
4353 printf 'm this-goes@nowhere\nbody\n!.
4354 unset customhdr
4355 m this-goes2@nowhere\nbody2\n!.
4356 set customhdr=%ccustom1 : custom1 body%c
4357 m this-goes2@nowhere\nbody2\n!.
4358 set customhdr=%ccustom1 : custom1\\, body , custom2: custom2 body%c
4359 m this-goes3@nowhere\nbody3\n!.
4360 ' "'" "'" "'" "'" |
4361 ${MAILX} ${ARGS} -Smta=./.tmta.sh -Sescape=! \
4362 -C 'C-One : Custom One Body' \
4363 -C 'C-Two:CustomTwoBody' \
4364 -S customhdr='chdr1: chdr1 body, chdr2:chdr2 body' \
4365 >./.tall 2>&1
4366 check_ex0 2-estat
4367 ${cat} ./.tall >> "${MBOX}"
4368 check 2 0 "${MBOX}" '3546878678 752'
4370 t_epilog
4373 t_quote_a_cmd_escapes() {
4374 t_prolog quote_a_cmd_escapes
4375 TRAP_EXIT_ADDONS="./.t*"
4377 t_xmta
4379 echo 'included file' > ./.ttxt
4381 ${cat} <<-_EOT > ./.tmbox
4382 From neverneverland Sun Jul 23 13:46:25 2017
4383 Subject: Bugstop: five miles out 1
4384 Reply-To: mister originator1 <mr1@originator>
4385 From: mister originator1 <mr1@originator>
4386 To: bugstop-commit@five.miles.out
4387 Cc: is1@a.list
4388 In-reply-to: <20170719111113.bkcMz%laber1@backe.eu>
4389 Date: Wed, 19 Jul 2017 09:22:57 -0400
4390 Message-Id: <20170719132257.766AF781267-1@originator>
4391 Status: RO
4393 That's appalling, I.
4395 From neverneverland Sun Jul 23 13:47:25 2017
4396 Subject: Bugstop: five miles out 2
4397 Reply-To: mister originator2 <mr2@originator>
4398 From: mister originator2 <mr2@originator>
4399 To: bugstop-commit@five.miles.out
4400 Cc: is2@a.list
4401 In-reply-to: <20170719111113.bkcMz%laber2@backe.eu>
4402 Date: Wed, 19 Jul 2017 09:23:57 -0400
4403 Message-Id: <20170719132257.766AF781267-2@originator>
4404 Status: RO
4406 That's appalling, II.
4408 From neverneverland Sun Jul 23 13:48:25 2017
4409 Subject: Bugstop: five miles out 3
4410 Reply-To: mister originator3 <mr3@originator>
4411 From: mister originator3 <mr3@originator>
4412 To: bugstop-commit@five.miles.out
4413 Cc: is3@a.list
4414 In-reply-to: <20170719111113.bkcMz%laber3@backe.eu>
4415 Date: Wed, 19 Jul 2017 09:24:57 -0400
4416 Message-Id: <20170719132257.766AF781267-3@originator>
4417 Status: RO
4419 That's appalling, III.
4421 _EOT
4423 printf '#
4424 set indentprefix=" |"
4425 set quote
4426 reply 2
4428 set quote=noheading
4429 reply 2
4431 headerpick type retain cc date from message-id reply-to subject to
4432 set quote=headers
4433 reply 2
4435 set quote=allheaders
4436 reply 2
4438 ' | ${MAILX} ${ARGS} -Smta=./.tmta.sh -Rf \
4439 -Sescape=! -Sindentprefix=' >' \
4440 ./.tmbox >./.tall 2>&1
4441 check_ex0 1-estat
4442 ${cat} ./.tall >> "${MBOX}"
4443 check 1 0 "${MBOX}" '2181726970 2023'
4445 # ~@ is tested with other attachment stuff, ~^ is in compose_hooks
4446 ${rm} "${MBOX}"
4447 printf '#
4448 set Sign=SignVar sign=signvar DEAD=./.ttxt
4449 headerpick type retain Subject
4450 reply 2
4451 !!1 Not escaped. And shell test last, right before !..
4452 !: echo 2 only echoed via colon
4453 !_ echo 3 only echoed via underscore
4454 !< ./.ttxt
4455 !<! echo 5 shell echo included
4456 !| echo 6 pipecmd-pre; cat; echo 6 pipecmd-post
4457 7 and 8 are ~A and ~a:
4460 !b 9 added ~b cc <ex1@am.ple>
4461 !c 10 added ~c c <ex2@am.ple>
4462 11 next ~d / $DEAD
4464 12: ~F
4466 13: ~F 1 3
4467 !F 1 3
4468 14: ~f (headerpick: subject)
4470 15: ~f 1
4471 !f 1
4472 16, 17: ~I Sign, ~i Sign
4473 !I Sign
4474 !i Sign
4475 18: ~M
4477 19: ~M 1
4478 !M 1
4479 20: ~m
4481 21: ~m 3
4482 !m 3
4483 28-32: ~Q; 28: ~Q
4485 29: ~Q 1 3
4486 !Q 1 3
4487 set quote
4488 !:set quote
4489 30: ~Q
4491 31: ~Q 1 3
4492 !Q 1 3
4493 set quote-inject-head quote-inject-tail indentprefix
4494 !:wysh set quote-inject-head=%%a quote-inject-tail=--%%r
4495 32: ~Q
4497 unset quote stuff
4498 !:unset quote quote-inject-head quote-inject-tail
4499 22: ~R ./.ttxt
4500 !R ./.ttxt
4501 23: ~r ./.ttxt
4502 !r ./.ttxt
4503 24: ~s this new subject
4504 !s 24 did new ~s ubject
4505 !t 25 added ~t o <ex3@am.ple>
4506 26: ~U
4508 27: ~U 1
4509 !U 1
4510 and i ~w rite this out to ./.tmsg
4511 !w ./.tmsg
4512 !:wysh set x=$escape;set escape=~
4513 ~!echo shell command output
4514 ~:wysh set escape=$x
4516 ' | ${MAILX} ${ARGS} -Smta=./.tmta.sh -Rf \
4517 -Sescape=! -Sindentprefix=' |' \
4518 ./.tmbox >./.tall 2>&1
4519 check_ex0 2-estat
4520 ${cat} ./.tall >> "${MBOX}"
4521 check 2 0 "${MBOX}" '2613898218 4090'
4522 check 3 - ./.tmsg '2771314896 3186'
4524 t_epilog
4527 t_mass_recipients() {
4528 t_prolog mass_recipients
4529 TRAP_EXIT_ADDONS="./.t*"
4531 t_xmta 'Eucalyptus Sat Jul 08 21:14:57 2017'
4533 ${cat} <<'__EOT__' > ./.trc
4534 define bail {
4535 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
4537 define ins_addr {
4538 wysh set nr=$1 hn=$2
4539 echo "~$hn $hn$nr@$hn"; echo '~:echo $?'; read es
4540 if [ "$es" -ne 0 ]
4541 xcall bail "ins_addr $hn 1-$nr"
4543 vput vexpr nr + $nr 1
4544 if [ "$nr" -le "$maximum" ]
4545 xcall ins_addr $nr $hn
4548 define bld_alter {
4549 wysh set nr=$1 hn=$2
4550 alternates $hn$nr@$hn
4551 vput vexpr nr + $nr 2
4552 if [ "$nr" -le "$maximum" ]
4553 xcall bld_alter $nr $hn
4556 define t_ocs {
4557 read ver
4558 call ins_addr 1 t
4559 call ins_addr 1 c
4560 call ins_addr 1 b
4562 define t_ocl {
4563 if [ "$t_remove" != '' ]
4564 call bld_alter 1 t
4565 call bld_alter 2 c
4568 set on-compose-splice=t_ocs on-compose-leave=t_ocl
4569 __EOT__
4571 printf 'm this-goes@nowhere\nbody\n!.\n' |
4572 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
4573 -X'source ./.trc' -Smta=./.tmta.sh -Smaximum=2001 \
4574 >./.tall 2>&1
4575 check_ex0 1-estat
4576 ${cat} ./.tall >> "${MBOX}"
4577 check 1 - "${MBOX}" '2912243346 51526'
4579 ${rm} "${MBOX}"
4580 printf 'm this-goes@nowhere\nbody\n!.\n' |
4581 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
4582 -St_remove=1 -X'source ./.trc' -Smta=./.tmta.sh -Smaximum=2001 \
4583 >./.tall 2>&1
4584 check_ex0 2-estat
4585 ${cat} ./.tall >> "${MBOX}"
4586 check 2 - "${MBOX}" '4097804632 34394'
4588 t_epilog
4591 t_mime_types_load_control() {
4592 t_prolog mime_types_load_control
4593 if have_feat uistrings; then :; else
4594 echo 'mime_types_load_control: unsupported, skipped'
4595 return
4597 TRAP_EXIT_ADDONS="./.t*"
4599 ${cat} <<-_EOT > ./.tmts1
4600 @ application/mathml+xml mathml
4601 _EOT
4602 ${cat} <<-_EOT > ./.tmts2
4603 @ x-conference/x-cooltalk ice
4604 @ aga-aga aga
4605 @ application/aga-aga aga
4606 _EOT
4608 ${cat} <<-_EOT > ./.tmts1.mathml
4609 <head>nonsense ML</head>
4610 _EOT
4611 ${cat} <<-_EOT > ./.tmts2.ice
4612 Icy, icy road.
4613 _EOT
4614 printf 'of which the c\x01rack is coming soon' > ./.tmtsx.doom
4615 printf 'of which the c\x01rack is coming soon' > ./.tmtsx.aga
4617 printf '
4618 m %s
4619 Schub-di-du
4620 ~@ ./.tmts1.mathml
4621 ~@ ./.tmts2.ice
4622 ~@ ./.tmtsx.doom
4623 ~@ ./.tmtsx.aga
4625 File %s
4626 from*
4627 type
4629 ' "${MBOX}" "${MBOX}" |
4630 ${MAILX} ${ARGS} \
4631 -Smimetypes-load-control=f=./.tmts1,f=./.tmts2 \
4632 > ./.tout 2>&1
4633 check_ex0 1-estat
4634 ${cat} "${MBOX}" >> ./.tout
4635 check 1 - ./.tout '1441260727 2449'
4637 echo type | ${MAILX} ${ARGS} -R \
4638 -Smimetypes-load-control=f=./.tmts1,f=./.tmts3 \
4639 -f "${MBOX}" >> ./.tout 2>&1
4640 check 2 0 ./.tout '1441391438 3646'
4642 t_epilog
4645 t_lreply_futh_rth_etc() { # TODO *fullnames*!
4646 t_prolog lreply_futh_rth_etc
4647 TRAP_EXIT_ADDONS="./.t*"
4649 t_xmta 'HumulusLupulus Thu Jul 27 14:41:20 2017'
4651 ${cat} <<-_EOT > ./.tmbox
4652 From neverneverland Sun Jul 23 13:46:25 2017
4653 Subject: Bugstop: five miles out 1
4654 Reply-To: mister originator2 <mr2@originator>, bugstop@five.miles.out
4655 From: mister originator <mr@originator>
4656 To: bugstop-commit@five.miles.out, laber@backe.eu
4657 Cc: is@a.list
4658 Mail-Followup-To: bugstop@five.miles.out, laber@backe.eu, is@a.list
4659 In-reply-to: <20170719111113.bkcMz%laber@backe.eu>
4660 Date: Wed, 19 Jul 2017 09:22:57 -0400
4661 Message-Id: <20170719132257.766AF781267@originator>
4662 Status: RO
4664 > |Sorry, I think I misunderstand something. I would think that
4666 That's appalling.
4668 From neverneverland Fri Jul 7 22:39:11 2017
4669 Subject: Bugstop: five miles out 2
4670 Reply-To: mister originator2<mr2@originator>,bugstop@five.miles.out,is@a.list
4671 Content-Transfer-Encoding: 7bit
4672 From: mister originator <mr@originator>
4673 To: bugstop-commit@five.miles.out
4674 Cc: is@a.list
4675 Message-ID: <149945963975.28888.6950788126957753723.reportbug@five.miles.out>
4676 Date: Fri, 07 Jul 2017 16:33:59 -0400
4677 Status: R
4679 capable of changing back.
4681 From neverneverland Fri Jul 7 22:42:00 2017
4682 Subject: Bugstop: five miles out 3
4683 Reply-To: mister originator2 <mr2@originator>, bugstop@five.miles.out
4684 Content-Transfer-Encoding: 7bit
4685 From: mister originator <mr@originator>
4686 To: bugstop-commit@five.miles.out
4687 Cc: is@a.list
4688 Message-ID: <149945963975.28888.6950788126957753746.reportbug@five.miles.out>
4689 Date: Fri, 07 Jul 2017 16:33:59 -0400
4690 List-Post: <mailto:bugstop@five.miles.out>
4691 Status: R
4693 are you ready, boots?
4695 From neverneverland Sat Aug 19 23:15:00 2017
4696 Subject: Bugstop: five miles out 4
4697 Reply-To: mister originator2 <mr2@originator>, bugstop@five.miles.out
4698 Content-Transfer-Encoding: 7bit
4699 From: mister originator <mr@originator>
4700 To: bugstop@five.miles.out
4701 Cc: is@a.list
4702 Message-ID: <149945963975.28888.6950788126qtewrqwer.reportbug@five.miles.out>
4703 Date: Fri, 07 Jul 2017 16:33:59 -0400
4704 List-Post: <mailto:bugstop@five.miles.out>
4705 Status: R
4707 are you ready, boots?
4708 _EOT
4712 ${cat} <<-'_EOT' | ${MAILX} ${ARGS} -Sescape=! -Smta=./.tmta.sh \
4713 -Rf ./.tmbox >> "${MBOX}" 2>&1
4714 define r {
4715 wysh set m="This is text of \"reply ${1}."
4716 reply 1 2 3
4717 !I m
4720 !I m
4723 !I m
4726 echo -----After reply $1.1 - $1.3: $?/$^ERRNAME
4728 define R {
4729 wysh set m="This is text of \"Reply ${1}."
4730 eval Reply $2
4731 !I m
4732 !I 2
4735 echo -----After Reply $1.$2: $?/$^ERRNAME
4737 define _Lh {
4738 read protover
4739 echo '~I m'
4740 echo '~I n'
4741 echo '".'
4743 define _Ls {
4744 wysh set m="This is text of \"Lreply ${1}." on-compose-splice=_Lh n=$2
4745 eval Lreply $2
4747 define L {
4748 # We need two indirections for this test: one for the case that Lreply
4749 # fails because of missing recipients: we need to read EOF next, thus
4750 # place this in _Ls last; and second for the succeeding cases EOF is
4751 # not what these should read, so go over the backside and splice it in!
4752 call _Ls "$@"
4753 echo -----After Lreply $1.$2: $?/$^ERRNAME
4755 define x {
4756 localopts call-fixate yes
4757 call r $1
4758 call R $1 1; call R $1 2; call R $1 3; call R $1 4
4759 call L $1 1; call L $1 2; call L $1 3
4761 define tweak {
4762 echo;echo '===== CHANGING === '"$*"' =====';echo
4763 eval "$@"
4766 set from=laber@backe.eu
4767 mlist is@a.list
4768 call x 1
4769 call tweak set reply-to-honour
4770 call x 2
4771 call tweak set followup-to
4772 call x 3
4773 call tweak set followup-to-honour
4774 call x 4
4775 call tweak mlist bugstop@five.miles.out
4776 call x 5
4777 call tweak mlsubscribe bugstop@five.miles.out
4778 call x 6
4779 call tweak set recipients-in-cc
4780 call x 7
4781 _EOT
4783 check_ex0 1-estat
4784 if have_feat uistrings; then
4785 check 1 - "${MBOX}" '2950056640 29373'
4786 else
4787 echo 'lreply_futh_rth_etc-1: content test unsupported, skipped'
4792 ${cat} <<-_EOT > ./.tmbox
4793 From tom@i-i.example Thu Oct 26 03:15:55 2017
4794 Date: Wed, 25 Oct 2017 21:15:46 -0400
4795 From: tom <tom@i-i.example>
4796 To: Steffen Nurpmeso <steffen@sdaoden.eu>
4797 Cc: tom <tom@i-i.example>
4798 Subject: Re: xxxx yyyyyyyy configure does not really like a missing zzzzz
4799 Message-ID: <20171026011546.GA11643@i-i.example>
4800 Reply-To: tom@i-i.example
4801 References: <20171025214601.T2pNd%steffen@sdaoden.eu>
4802 In-Reply-To: <20171025214601.T2pNd%steffen@sdaoden.eu>
4803 Status: R
4805 The report's useful :-)
4806 _EOT
4808 # Let us test In-Reply-To: removal starts a new thread..
4809 # This needs adjustment of *stealthmua*
4810 argadd='-Sstealthmua=noagent -Shostname'
4812 ${rm} "${MBOX}"
4813 printf 'reply 1\nthread\n!.\n' |
4814 ${MAILX} ${ARGS} -Sescape=! -Smta=./.tmta.sh -Sreply-to-honour \
4815 ${argadd} -Rf ./.tmbox > .tall 2>&1
4816 check 2 0 "${MBOX}" '3321764338 429'
4817 check 3 - .tall '4294967295 0'
4819 printf 'reply 1\nnew <- thread!\n!v\n!.\n' |
4820 ${MAILX} ${ARGS} -Sescape=! -Smta=./.tmta.sh -Sreply-to-honour \
4821 -Seditheaders -S VISUAL="${sed} -i'' -e '/^In-Reply-To:/d'" \
4822 ${argadd} -Rf "${MBOX}" > .tall 2>&1
4823 check 4 0 "${MBOX}" '1682552516 763'
4824 check 5 - .tall '4294967295 0'
4826 printf 'reply 2\nold <- new <- thread!\n!.\n' |
4827 ${MAILX} ${ARGS} -Sescape=! -Smta=./.tmta.sh -Sreply-to-honour \
4828 ${argadd} -Rf "${MBOX}" > .tall 2>&1
4829 check 6 0 "${MBOX}" '2900984135 1219'
4830 check 7 - .tall '4294967295 0'
4832 printf 'reply 3\nnew <- old <- new <- thread!\n!v\n!.\n' |
4833 ${MAILX} ${ARGS} -Sescape=! -Smta=./.tmta.sh -Sreply-to-honour \
4834 -Seditheaders -S VISUAL="${sed} -i'' -e '/^In-Reply-To:/d'" \
4835 ${argadd} -Rf "${MBOX}" > .tall 2>&1
4836 check 8 0 "${MBOX}" '794031200 1567'
4837 check 9 - .tall '4294967295 0'
4839 t_epilog
4842 t_mime_if_not_ascii() {
4843 t_prolog mime_if_not_ascii
4845 </dev/null ${MAILX} ${ARGS} -s Subject "${MBOX}" >> "${MBOX}" 2>&1
4846 check 1 0 "${MBOX}" '2287855519 110'
4848 </dev/null ${MAILX} ${ARGS} -Scharset-7bit=not-ascii -s Subject "${MBOX}" \
4849 >> "${MBOX}" 2>&1
4850 check 2 0 "${MBOX}" '70754682 282'
4852 t_epilog
4855 t_xxxheads_rfc2047() {
4856 t_prolog xxxheads_rfc2047
4857 TRAP_EXIT_ADDONS="./.t*"
4859 t_xmta 'GentianaLutea Mon Dec 04 17:15:29 2017'
4861 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
4862 -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̲' \
4863 "${MBOX}"
4864 check 1 0 "${MBOX}" '3370931614 375'
4866 # Single word (overlong line split -- bad standard! Requires injection of
4867 # artificial data!! But can be prevented by using RFC 2047 encoding)
4868 ${rm} "${MBOX}"
4869 i=`${awk} 'BEGIN{for(i=0; i<92; ++i) printf "0123456789_"}'`
4870 echo | ${MAILX} ${ARGS} -s "${i}" "${MBOX}"
4871 check 2 0 "${MBOX}" '489922370 1718'
4873 # Combination of encoded words, space and tabs of varying sort
4874 ${rm} "${MBOX}"
4875 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
4876 -s "1Abrä Kaspas1 2Abra Katä b_kaspas2 \
4877 3Abrä Kaspas3 4Abrä Kaspas4 5Abrä Kaspas5 \
4878 6Abra Kaspas6 7Abrä Kaspas7 8Abra Kaspas8 \
4879 9Abra Kaspastäb4-3 10Abra Kaspas1 _ 11Abra Katäb1 \
4880 12Abra Kadabrä1 After Tab after Täb this is NUTS" \
4881 "${MBOX}"
4882 check 3 0 "${MBOX}" '1676887734 591'
4884 # Overlong multibyte sequence that must be forcefully split
4885 # todo This works even before v15.0, but only by accident
4886 ${rm} "${MBOX}"
4887 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
4888 -s "✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
4889 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
4890 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄" \
4891 "${MBOX}"
4892 check 4 0 "${MBOX}" '3029301775 659'
4894 # Trailing WS
4895 ${rm} "${MBOX}"
4896 echo | ${MAILX} ${ARGS} \
4897 -s "1-1 B2 B3 B4 B5 B6 B\
4898 1-2 B2 B3 B4 B5 B6 B\
4899 1-3 B2 B3 B4 B5 B6 B\
4900 1-4 B2 B3 B4 B5 B6 B\
4901 1-5 B2 B3 B4 B5 B6 B\
4902 1-6 B2 B3 B4 B5 B6 " \
4903 "${MBOX}"
4904 check 5 0 "${MBOX}" '4126167195 297'
4906 # Leading and trailing WS
4907 ${rm} "${MBOX}"
4908 echo | ${MAILX} ${ARGS} \
4909 -s " 2-1 B2 B3 B4 B5 B6 B\
4910 1-2 B2 B3 B4 B5 B6 B\
4911 1-3 B2 B3 B4 B5 B6 B\
4912 1-4 B2 B3 B4 B5 B6 " \
4913 "${MBOX}"
4914 check 6 0 "${MBOX}" '3600624479 236'
4916 # RFC 2047 in an address field! (Missing test caused v14.9.6!)
4917 ${rm} "${MBOX}"
4918 echo "Dat Früchtchen riecht häußlich" |
4919 ${MAILX} ${ARGS} ${ADDARG_UNI} -Sfullnames -Smta=./.tmta.sh \
4920 -s Hühöttchen \
4921 'Schnödes "Früchtchen" <do@du> (Hä!)'
4922 check 7 0 "${MBOX}" '800505986 368'
4924 # RFC 2047 in an address field, and iconv involved
4925 if have_feat iconv; then
4926 ${rm} "${MBOX}"
4927 ${cat} > ./.trebox <<_EOT
4928 From zaza@exam.ple Fri Mar 2 21:31:56 2018
4929 Date: Fri, 2 Mar 2018 20:31:45 +0000
4930 From: z=?iso-8859-1?Q?=E1?=za <zaza@exam.ple>
4931 To: dude <dude@exam.ple>
4932 Subject: houston(...)
4933 Message-ID: <abra@1>
4934 MIME-Version: 1.0
4935 Content-Type: text/plain; charset=iso-8859-1
4936 Content-Disposition: inline
4937 Content-Transfer-Encoding: 8bit
4939 _EOT
4940 echo reply | ${MAILX} ${ARGS} ${ADDARG_UNI} \
4941 -Sfullnames -Sreply-in-same-charset \
4942 -Smta=./.tmta.sh -Rf ./.trebox
4943 check 8 0 "${MBOX}" '2914485741 280'
4944 else
4945 echo 'xxxheads_rfc2047-8: iconv unsupported, skipped'
4948 t_epilog
4951 t_rfc2231() {
4952 t_prolog rfc2231
4953 TRAP_EXIT_ADDONS="./.t*"
4956 mkdir ./.ttt || exit 1
4957 cd ./.ttt || exit 2
4958 : > "ma'ger.txt"
4959 : > "mä'ger.txt"
4960 : > 'diet\ is \curd.txt'
4961 : > 'diet "is" curd.txt'
4962 : > höde-tröge.txt
4963 : > 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
4964 : > höde__tröge__müde__dätte__hätte__vuelle__guelle__aese__aesse__sauerliche__kräuter__österliche__grüße__mäh.txt
4965 : > hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt
4966 : > ✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt
4968 echo bla | ${MAILX} ${ARGS} ${ADDARG_UNI} \
4969 -a "./.ttt/ma'ger.txt" -a "./.ttt/mä'ger.txt" \
4970 -a './.ttt/diet\ is \curd.txt' -a './.ttt/diet "is" curd.txt' \
4971 -a ./.ttt/höde-tröge.txt \
4972 -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 \
4973 -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 \
4974 -a ./.ttt/hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt \
4975 -a ./.ttt/✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt \
4976 "${MBOX}"
4977 check 1 0 "${MBOX}" '684985954 3092'
4979 # `resend' test, reusing $MBOX
4980 printf "Resend ./.t2\nx\n" | ${MAILX} ${ARGS} -Rf "${MBOX}"
4981 check 2 0 ./.t2 '684985954 3092'
4983 printf "resend ./.t3\nx\n" | ${MAILX} ${ARGS} -Rf "${MBOX}"
4984 check 3 0 ./.t3 '3130352658 3148'
4986 t_epilog
4989 t_iconv_mbyte_base64() { # TODO uses sed(1) and special *headline*!!
4990 t_prolog iconv_mbyte_base64
4991 TRAP_EXIT_ADDONS="./.t*"
4993 if [ -n "${UTF8_LOCALE}" ] && have_feat iconv; then
4994 if (</dev/null iconv -f ascii -t iso-2022-jp) >/dev/null 2>&1 ||
4995 (</dev/null iconv -f ascii -t euc-jp) >/dev/null 2>&1; then
4997 else
4998 echo 'iconv_mbyte_base64: unsupported, skipped'
4999 return
5001 else
5002 echo 'iconv_mbyte_base64: unsupported, skipped'
5003 return
5006 t_xmta 'DroseriaRotundifolia Thu Aug 03 17:26:25 2017'
5008 if (</dev/null iconv -f ascii -t iso-2022-jp) >/dev/null 2>&1; then
5009 ${cat} <<-'_EOT' | LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} \
5010 -Smta=./.tmta.sh \
5011 -Sescape=! -Smime-encoding=base64 2>./.terr
5012 set ttycharset=utf-8 sendcharsets=iso-2022-jp
5013 m t1@exam.ple
5014 !s Japanese from UTF-8 to ISO-2022-JP
5015 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
5017 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
5020 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
5022 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
5025 set ttycharset=iso-2022-jp charset-7bit=iso-2022-jp sendcharsets=utf-8
5026 m t2@exam.ple
5027 !s Japanese from ISO-2022-JP to UTF-8, eh, no, also ISO-2022-JP
5028 \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
5030 \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
5033 \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
5035 \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
5037 _EOT
5038 # May not presume iconv output as long as roundtrip possible [489a7122]
5039 check_ex0 1-estat
5040 ${awk} 'BEGIN{h=1}/^$/{++h;next}{if(h % 2 == 1)print}' \
5041 < "${MBOX}" > ./.tcksum
5042 check 1 - ./.tcksum '2694609714 520'
5043 check 2 - ./.terr '4294967295 0'
5045 printf 'eval f 1; eval write ./.twrite; eval type 1; eval type 2\n' |
5046 LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} \
5047 -S headline="%>%a%m %-18f %-16d %i%-s" \
5048 -Rf "${MBOX}" >./.tlog 2>&1
5049 check 3 0 ./.twrite '1259742080 686'
5050 #check 4 - ./.tlog '3214068822 2123'
5051 ${sed} -e '/^\[-- M/d' < ./.tlog > ./.txlog
5052 check 4 - ./.txlog '3659773472 2035'
5053 else
5054 echo 'iconv_mbyte_base64: ISO-2022-JP unsupported, skipping 1-4'
5057 if (</dev/null iconv -f ascii -t euc-jp) >/dev/null 2>&1; then
5058 rm -f "${MBOX}" ./.twrite
5059 ${cat} <<-'_EOT' | LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} \
5060 -Smta=./.tmta.sh \
5061 -Sescape=! -Smime-encoding=base64 2>./.terr
5062 set ttycharset=utf-8 sendcharsets=euc-jp
5063 m t1@exam.ple
5064 !s Japanese from UTF-8 to EUC-JP
5065 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
5067 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
5070 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
5072 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
5075 set ttycharset=EUC-JP sendcharsets=utf-8
5076 m t2@exam.ple
5077 !s Japanese from EUC-JP to UTF-8
5078 ¥·¥¸¥å¥¦¥«¥é²Ê¡Ê¥·¥¸¥å¥¦¥«¥é¤«¡¢³Ø̾ Paridae¡Ë¤Ï¡¢Ä»Îॹ¥º¥áÌܤβʤǤ¢¤ë¡£¥·¥¸¥å¥¦¥«¥é¡Ê»Í½½¿ý¡Ë¤ÈÁí¾Î¤µ¤ì¤ë¤¬¡¢¶¹µÁ¤Ë¤Ï¤³¤Î1¼ï¤ò¥·¥¸¥å¥¦¥«¥é¤È¸Æ¤Ö¡£
5080 ¥«¥ó¥à¥ê¥¬¥é¡Ê³Ø̾Parus cristatus¡Ë¤Ï¡¢¥¹¥º¥áÌÜ¥·¥¸¥å¥¦¥«¥é²Ê¤ËʬÎव¤ì¤ëÄ»Îà¤Î°ì¼ï¡£
5083 ¥«¥ó¥à¥ê¥¬¥é¡Ê³Ø̾Parus cristatus¡Ë¤Ï¡¢¥¹¥º¥áÌÜ¥·¥¸¥å¥¦¥«¥é²Ê¤ËʬÎव¤ì¤ëÄ»Îà¤Î°ì¼ï¡£
5085 ¥·¥¸¥å¥¦¥«¥é²Ê¡Ê¥·¥¸¥å¥¦¥«¥é¤«¡¢³Ø̾ Paridae¡Ë¤Ï¡¢Ä»Îॹ¥º¥áÌܤβʤǤ¢¤ë¡£¥·¥¸¥å¥¦¥«¥é¡Ê»Í½½¿ý¡Ë¤ÈÁí¾Î¤µ¤ì¤ë¤¬¡¢¶¹µÁ¤Ë¤Ï¤³¤Î1¼ï¤ò¥·¥¸¥å¥¦¥«¥é¤È¸Æ¤Ö¡£
5087 _EOT
5088 check_ex0 5-estat
5089 ${awk} 'BEGIN{h=1}/^$/{++h;next}{if(h % 2 == 1)print}' \
5090 < "${MBOX}" > ./.tcksum
5091 check 5 - ./.tcksum '2870183985 473'
5092 check 6 - ./.terr '4294967295 0'
5094 printf 'eval f 1; eval write ./.twrite; eval type 1; eval type 2\n' |
5095 LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} \
5096 -S headline="%>%a%m %-18f %-16d %i%-s" \
5097 -Rf "${MBOX}" >./.tlog 2>&1
5098 check 7 0 ./.twrite '1259742080 686'
5099 #check 8 - ./.tlog '2506063395 2075'
5100 ${sed} -e '/^\[-- M/d' < ./.tlog > ./.txlog
5101 check 8 - ./.txlog '2528199891 1988'
5102 else
5103 echo 'iconv_mbyte_base64: EUC-JP unsupported, skipping 5-8'
5106 t_epilog
5109 t_iconv_mainbody() {
5110 t_prolog iconv_mainbody
5111 TRAP_EXIT_ADDONS="./.t*"
5113 if [ -n "${UTF8_LOCALE}" ] && have_feat iconv; then
5115 else
5116 echo 'iconv_mainbody: unsupported, skipped'
5117 return
5120 t_xmta 'HamamelisVirginiana Fri Oct 20 16:23:21 2017'
5122 printf '–' | ${MAILX} ${ARGS} ${ADDARG_UNI} -Smta=./.tmta.sh \
5123 -S charset-7bit=us-ascii -S charset-8bit=utf-8 \
5124 -s '–' over-the@rain.bow 2>./.terr
5125 check 1 0 "${MBOX}" '3634015017 251'
5126 check 2 - ./.terr '4294967295 0'
5128 printf '–' | ${MAILX} ${ARGS} ${ADDARG_UNI} -Smta=./.tmta.sh \
5129 -S charset-7bit=us-ascii -S charset-8bit=us-ascii \
5130 -s '–' over-the@rain.bow 2>./.terr
5131 check_exn0 3
5132 check 3 - "${MBOX}" '3634015017 251'
5133 if have_feat uistrings; then
5134 if have_feat docstrings; then # xxx should not be like that
5135 check 4 - ./.terr '2579894983 148'
5136 else
5137 check 4 - ./.terr '271380835 121'
5139 else
5140 echo 'iconv_mainbody-4: unsupported, skipped'
5143 # The different iconv(3) implementations use different replacement sequence
5144 # types (character-wise, byte-wise, and the character(s) used differ)
5145 i="${MAILX_ICONV_MODE}"
5146 if [ -n "${i}" ]; then
5147 printf 'p\nx\n' | ${MAILX} ${ARGS} -Rf "${MBOX}" >./.tout 2>./.terr
5148 j=${?}
5149 check_ex0 5-1-estat ${j}
5150 check 5-1 - ./.terr '4294967295 0'
5151 if [ ${i} -eq 13 ]; then
5152 check 5-2 - ./.tout '189327996 283'
5153 elif [ ${i} -eq 12 ]; then
5154 check 5-3 - ./.tout '1959197095 283'
5155 elif [ ${i} -eq 3 ]; then
5156 check 5-4 - ./.tout '3196380198 279'
5157 else
5158 check 5-5 - ./.tout '3760313827 279'
5160 else
5161 echo 'iconv_mainbody-5: unsupported, skipped'
5164 t_epilog
5167 t_binary_mainbody() {
5168 t_prolog binary_mainbody
5169 TRAP_EXIT_ADDONS="./.t*"
5171 printf 'abra\0\nka\r\ndabra' |
5172 ${MAILX} ${ARGS} ${ADDARG_UNI} -s 'binary with carriage-return!' \
5173 "${MBOX}" 2>./.terr
5174 check 1 0 "${MBOX}" '2430168141 243'
5175 check 2 - ./.terr '4294967295 0'
5177 printf 'p\necho\necho writing now\nwrite ./.twrite\n' |
5178 ${MAILX} ${ARGS} -Rf \
5179 -Spipe-application/octet-stream="@* ${cat} > ./.tcat" \
5180 "${MBOX}" >./.tall 2>&1
5181 check 3 0 ./.tall '1151843761 324'
5182 check 4 - ./.tcat '3817108933 15'
5183 check 5 - ./.twrite '3817108933 15'
5185 t_epilog
5188 t_q_t_etc_opts() {
5189 t_prolog q_t_etc_opts
5190 TRAP_EXIT_ADDONS="./.t*"
5192 # Three tests for MIME encoding and (a bit) content classification.
5193 # At the same time testing -q FILE, < FILE and -t FILE
5194 t__put_body > ./.tin
5196 < ./.tin ${MAILX} ${ARGS} ${ADDARG_UNI} \
5197 -a ./.tin -s "`t__put_subject`" "${MBOX}"
5198 check 1 0 "${MBOX}" '3570973309 6646'
5200 ${rm} "${MBOX}"
5201 < /dev/null ${MAILX} ${ARGS} ${ADDARG_UNI} \
5202 -a ./.tin -s "`t__put_subject`" -q ./.tin "${MBOX}"
5203 check 2 0 "${MBOX}" '3570973309 6646'
5205 ${rm} "${MBOX}"
5206 ( echo "To: ${MBOX}" && echo "Subject: `t__put_subject`" && echo &&
5207 ${cat} ./.tin
5208 ) | ${MAILX} ${ARGS} ${ADDARG_UNI} -Snodot -a ./.tin -t
5209 check 3 0 "${MBOX}" '3570973309 6646'
5211 # Check comments in the header
5212 ${rm} "${MBOX}"
5213 ${cat} <<-_EOT | ${MAILX} ${ARGS} -Snodot -t "${MBOX}"
5214 # Ein Kommentar
5215 From: du@da
5216 # Noch ein Kommentar
5217 Subject: hey you
5218 # Nachgestelltes Kommentar
5220 BOOOM
5221 _EOT
5222 check 4 0 "${MBOX}" '3829967825 128'
5224 t_epilog
5227 t_s_mime() {
5228 have_feat smime || {
5229 echo 's_mime: unsupported, skipped'
5230 return
5233 t_prolog s_mime
5234 TRAP_EXIT_ADDONS="./.t.conf ./.tkey.pem ./.tcert.pem ./.tpair.pem"
5235 TRAP_EXIT_ADDONS="${TRAP_EXIT_ADDONS} ./.VERIFY ./.DECRYPT ./.ENCRYPT"
5236 TRAP_EXIT_ADDONS="${TRAP_EXIT_ADDONS} ./.tmta.sh"
5238 ${cat} <<-_EOT > ./.t.conf
5239 [ req ]
5240 default_bits = 1024
5241 default_keyfile = keyfile.pem
5242 distinguished_name = req_distinguished_name
5243 attributes = req_attributes
5244 prompt = no
5245 output_password =
5247 [ req_distinguished_name ]
5248 C = GB
5249 ST = Over the
5250 L = rainbow
5251 O = S-nail
5252 OU = S-nail.smime
5253 CN = S-nail.test
5254 emailAddress = test@localhost
5256 [ req_attributes ]
5257 challengePassword =
5258 _EOT
5259 openssl req -x509 -nodes -days 3650 -config ./.t.conf \
5260 -newkey rsa:1024 -keyout ./.tkey.pem -out ./.tcert.pem >>${ERR} 2>&1
5261 check_ex0 0
5262 ${cat} ./.tkey.pem ./.tcert.pem > ./.tpair.pem
5264 # Sign/verify
5265 echo bla | ${MAILX} ${ARGS} \
5266 -Ssmime-sign -Ssmime-sign-cert=./.tpair.pem -Sfrom=test@localhost \
5267 -s 'S/MIME test' ./.VERIFY
5268 check_ex0 1-estat
5269 ${awk} '
5270 BEGIN{ skip=0 }
5271 /^Content-Description: /{ skip = 2; print; next }
5272 /^$/{ if(skip) --skip }
5273 { if(!skip) print }
5275 < ./.VERIFY > "${MBOX}"
5276 check 1 - "${MBOX}" '2900817158 648'
5278 printf 'verify\nx\n' |
5279 ${MAILX} ${ARGS} -Ssmime-ca-file=./.tcert.pem -Serrexit \
5280 -R -f ./.VERIFY >>${ERR} 2>&1
5281 check_ex0 2
5283 openssl smime -verify -CAfile ./.tcert.pem -in ./.VERIFY >>${ERR} 2>&1
5284 check_ex0 3
5286 # (signing +) encryption / decryption
5287 t_xmta 'Euphrasia Thu Apr 27 17:56:23 2017' ./.ENCRYPT
5289 echo bla |
5290 ${MAILX} ${ARGS} \
5291 -Smta=./.tmta.sh \
5292 -Ssmime-force-encryption -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
5293 -Ssmime-sign -Ssmime-sign-cert=./.tpair.pem -Sfrom=test@localhost \
5294 -s 'S/MIME test' recei@ver.com
5295 check_ex0 4-estat
5296 ${sed} -e '/^$/,$d' < ./.ENCRYPT > "${MBOX}"
5297 check 4 - "${MBOX}" '1937410597 327'
5299 printf 'decrypt ./.DECRYPT\nfi ./.DECRYPT\nverify\nx\n' |
5300 ${MAILX} ${ARGS} \
5301 -Smta=./.tmta.sh \
5302 -Ssmime-ca-file=./.tcert.pem \
5303 -Ssmime-sign-cert=./.tpair.pem \
5304 -Serrexit -R -f ./.ENCRYPT >>${ERR} 2>&1
5305 check_ex0 5-estat
5306 ${awk} '
5307 BEGIN{ skip=0 }
5308 /^Content-Description: /{ skip = 2; print; next }
5309 /^$/{ if(skip) --skip }
5310 { if(!skip) print }
5312 < ./.DECRYPT > "${MBOX}"
5313 check 5 - "${MBOX}" '1720739247 931'
5315 (openssl smime -decrypt -inkey ./.tkey.pem -in ./.ENCRYPT |
5316 openssl smime -verify -CAfile ./.tcert.pem) >>${ERR} 2>&1
5317 check_ex0 6
5319 ${rm} ./.ENCRYPT
5320 echo bla | ${MAILX} ${ARGS} \
5321 -Smta=./.tmta.sh \
5322 -Ssmime-force-encryption -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
5323 -Sfrom=test@localhost \
5324 -s 'S/MIME test' recei@ver.com
5325 check_ex0 7-estat
5326 ${sed} -e '/^$/,$d' < ./.ENCRYPT > "${MBOX}"
5327 check 7 - "${MBOX}" '1937410597 327'
5329 ${rm} ./.DECRYPT
5330 printf 'decrypt ./.DECRYPT\nx\n' | ${MAILX} ${ARGS} \
5331 -Smta=./.tmta.sh \
5332 -Ssmime-sign-cert=./.tpair.pem \
5333 -Serrexit -R -f ./.ENCRYPT >>${ERR} 2>&1
5334 check 8 0 "./.DECRYPT" '2624716890 422'
5336 openssl smime -decrypt -inkey ./.tkey.pem \
5337 -in ./.ENCRYPT >>${ERR} 2>&1
5338 check_ex0 9
5340 t_epilog
5343 # xxx Note: t_z() was the first test (series) written. Today many
5344 # xxx aspects are (better) covered by other tests above, some are not.
5345 # xxx At some future date and time, convert the last remains not covered
5346 # xxx elsewhere to a real t_* test and drop it
5347 t_z() {
5348 t_prolog z
5350 # Test for [260e19d] (Juergen Daubert)
5351 echo body | ${MAILX} ${ARGS} "${MBOX}"
5352 check 4 0 "${MBOX}" '2917662811 98'
5354 # "Test for" [d6f316a] (Gavin Troy)
5355 ${rm} "${MBOX}"
5356 printf "m ${MBOX}\n~s subject1\nEmail body\n~.\nfi ${MBOX}\np\nx\n" |
5357 ${MAILX} ${ARGS} ${ADDARG_UNI} -Spipe-text/plain="@* ${cat}" > "${BODY}"
5358 check 6 0 "${MBOX}" '2099098650 122'
5359 check 6-1 - "${BODY}" '794542938 174'
5361 # "Test for" [c299c45] (Peter Hofmann) TODO shouldn't end up QP-encoded?
5362 ${rm} "${MBOX}"
5363 ${awk} 'BEGIN{
5364 for(i = 0; i < 10000; ++i)
5365 printf "\xC3\xBC"
5366 #printf "\xF0\x90\x87\x90"
5367 }' | ${MAILX} ${ARGS} ${ADDARG_UNI} -s TestSubject "${MBOX}"
5368 check 7 0 "${MBOX}" '534262374 61816'
5370 t_epilog
5373 t__put_subject() {
5374 # MIME encoding (QP) stress message subject
5375 printf 'Äbrä Kä?dä=brö Fü?di=bus? '\
5376 'adadaddsssssssddddddddddddddddddddd'\
5377 'ddddddddddddddddddddddddddddddddddd'\
5378 'ddddddddddddddddddddddddddddddddddd'\
5379 'dddddddddddddddddddd Hallelulja? Od'\
5380 'er?? eeeeeeeeeeeeeeeeeeeeeeeeeeeeee'\
5381 'eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'\
5382 'eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee f'\
5383 'fffffffffffffffffffffffffffffffffff'\
5384 'fffffffffffffffffffff ggggggggggggg'\
5385 'ggggggggggggggggggggggggggggggggggg'\
5386 'ggggggggggggggggggggggggggggggggggg'\
5387 'ggggggggggggggggggggggggggggggggggg'\
5388 'gggggggggggggggg'
5391 t__put_body() {
5392 # MIME encoding (QP) stress message body
5393 printf \
5394 'Ich bin eine DÖS-Datäi mit sehr langen Zeilen und auch '\
5395 'sonst bin ich ganz schön am Schleudern, da kannste denke '\
5396 "wasde willst, gelle, gelle, gelle, gelle, gelle.\r\n"\
5397 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst \r\n"\
5398 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1\r\n"\
5399 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12\r\n"\
5400 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123\r\n"\
5401 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1234\r\n"\
5402 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12345\r\n"\
5403 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123456\r\n"\
5404 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1234567\r\n"\
5405 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12345678\r\n"\
5406 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123456789\r\n"\
5407 "Unn ausserdem habe ich trailing SP/HT/SP/HT whitespace \r\n"\
5408 "Unn ausserdem habe ich trailing HT/SP/HT/SP whitespace \r\n"\
5409 "auf den zeilen vorher.\r\n"\
5410 "From am Zeilenbeginn und From der Mitte gibt es auch.\r\n"\
5411 ".\r\n"\
5412 "Die letzte Zeile war nur ein Punkt.\r\n"\
5413 "..\r\n"\
5414 "Das waren deren zwei.\r\n"\
5415 " \r\n"\
5416 "Die letzte Zeile war ein Leerschritt.\n"\
5417 "=VIER = EQUAL SIGNS=ON A LINE=\r\n"\
5418 "Prösterchen.\r\n"\
5419 ".\n"\
5420 "Die letzte Zeile war nur ein Punkt, mit Unix Zeilenende.\n"\
5421 "..\n"\
5422 "Das waren deren zwei. ditto.\n"\
5423 "Prösterchen.\n"\
5424 "Unn ausseerdem habe ich trailing SP/HT/SP/HT whitespace \n"\
5425 "Unn ausseerdem habe ich trailing HT/SP/HT/SP whitespace \n"\
5426 "auf den zeilen vorher.\n"\
5427 "ditto.\n"\
5428 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.\n"\
5429 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.1"\
5430 "\n"\
5431 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
5432 "\n"\
5433 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
5434 "3\n"\
5435 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
5436 "34\n"\
5437 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
5438 "345\n"\
5439 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
5440 "3456\n"\
5441 "QP am Zeilenende über soft-nl hinweg\n"\
5442 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
5443 "ö123\n"\
5444 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
5445 "1ö23\n"\
5446 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
5447 "12ö3\n"\
5448 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
5449 "123ö\n"\
5450 "=VIER = EQUAL SIGNS=ON A LINE=\n"\
5451 " \n"\
5452 "Die letzte Zeile war ein Leerschritt.\n"\
5456 # cc_all_configs()
5457 # Test all configs TODO doesn't cover all *combinations*, stupid!
5458 cc_all_configs() {
5459 < ${CONF} ${awk} '
5460 BEGIN{
5461 ALWAYS = "OPT_AUTOCC=1 OPT_AMALGAMATION=1"
5462 NOTME["OPT_ALWAYS_UNICODE_LOCALE"] = 1
5463 NOTME["OPT_CROSS_BUILD"] = 1
5464 NOTME["OPT_AUTOCC"] = 1
5465 NOTME["OPT_AMALGAMATION"] = 1
5466 NOTME["OPT_DEBUG"] = 1
5467 NOTME["OPT_DEVEL"] = 1
5468 NOTME["OPT_ASAN_ADDRESS"] = 1
5469 NOTME["OPT_ASAN_MEMORY"] = 1
5470 NOTME["OPT_FORCED_STACKPROT"] = 1
5471 NOTME["OPT_NOMEMDBG"] = 1
5472 NOTME["OPT_NYD2"] = 1
5474 #OPTVALS
5475 OPTNO = 0
5477 MULCHOICE["OPT_IDNA"] = "VAL_IDNA"
5478 MULVALS["VAL_IDNA"] = 1
5480 #VALKEYS[0] = "VAL_RANDOM"
5481 VALVALS["VAL_RANDOM"] = 1
5482 VALNO = 0
5484 /^[[:space:]]*OPT_/{
5485 sub(/^[[:space:]]*/, "")
5486 # This bails for UnixWare 7.1.4 awk(1), but preceeding = with \
5487 # does not seem to be a compliant escape for =
5488 #sub(/=.*$/, "")
5489 $1 = substr($1, 1, index($1, "=") - 1)
5490 if(!NOTME[$1])
5491 OPTVALS[OPTNO++] = $1
5492 next
5494 /^[[:space:]]*VAL_/{
5495 sub(/^[[:space:]]*/, "")
5496 val = substr($0, index($0, "=") + 1)
5497 if(val ~ /^\"/){
5498 val = substr(val, 2)
5499 val = substr(val, 1, length(val) - 1)
5501 $1 = substr($1, 1, index($1, "=") - 1)
5502 if(MULVALS[$1])
5503 MULVALS[$1] = val
5504 else if(VALVALS[$1]){
5505 VALKEYS[VALNO++] = $1
5506 VALVALS[$1] = val
5508 next
5510 function onepass(addons){
5511 a_onepass__worker(addons, "1", "0")
5512 a_onepass__worker(addons, "0", "1")
5514 function a_onepass__worker(addons, b0, b1){
5515 # Doing this completely sequentially and not doing make distclean in
5516 # between runs should effectively result in lesser compilations.
5517 # It is completely dumb nonetheless... TODO
5518 for(ono = 0; ono < OPTNO; ++ono){
5519 myconf = mula = ""
5520 for(i = 0; i < ono; ++i){
5521 myconf = myconf " " OPTVALS[i] "=" b0 " "
5522 if(b0 == "1"){
5523 j = MULCHOICE[OPTVALS[i]]
5524 if(j){
5525 if(i + 1 == ono)
5526 mula = j
5527 else
5528 myconf = myconf " " MULCHOICE[OPTVALS[i]] "=any "
5532 for(i = ono; i < OPTNO; ++i){
5533 myconf = myconf " " OPTVALS[i] "=" b1 " "
5534 if(b1 == "1"){
5535 j = MULCHOICE[OPTVALS[i]]
5536 if(j){
5537 if(i + 1 == OPTNO)
5538 mula = j;
5539 else
5540 myconf = myconf " " MULCHOICE[OPTVALS[i]] "=any "
5545 for(i in VALKEYS)
5546 myconf = VALKEYS[i] "=any " myconf
5548 myconf = myconf " " ALWAYS " " addons
5550 if(mula == "")
5551 print myconf
5552 else{
5553 i = split(MULVALS[mula], ia)
5554 j = "any"
5555 while(i >= 1){
5556 j = ia[i--] " " j
5557 print mula "=\"" j "\" " myconf
5562 END{
5563 # We cannot test NULL because of missing UI strings, which will end
5564 # up with different checksums
5565 print "CONFIG=NULLI OPT_AUTOCC=1"
5566 for(i in VALKEYS){
5567 j = split(VALVALS[VALKEYS[i]], ia)
5568 k = "any"
5569 while(j >= 1){
5570 k = ia[j--] " " k
5571 print VALKEYS[i] "=\"" k "\" CONFIG=NULLI OPT_AUTOCC=1"
5574 print "CONFIG=MINIMAL OPT_AUTOCC=1"
5575 print "CONFIG=NETSEND OPT_AUTOCC=1"
5576 print "CONFIG=MAXIMAL OPT_AUTOCC=1"
5577 for(i in VALKEYS){
5578 j = split(VALVALS[VALKEYS[i]], ia)
5579 k = "any"
5580 while(j >= 1){
5581 k = ia[j--] " " k
5582 print VALKEYS[i] "=\"" k "\" CONFIG=MAXIMAL OPT_AUTOCC=1"
5585 print "CONFIG=DEVEL OPT_AUTOCC=1"
5586 print "CONFIG=ODEVEL OPT_AUTOCC=1"
5588 onepass("OPT_DEBUG=1")
5589 onepass("")
5591 ' | while read c; do
5592 [ -f mk-config.h ] && ${cp} mk-config.h .ccac.h
5593 printf "\n\n##########\n$c\n"
5594 printf "\n\n##########\n$c\n" >&2
5595 ${SHELL} -c "cd .. && ${MAKE} ${c} config"
5596 if [ -f .ccac.h ] && ${cmp} mk-config.h .ccac.h; then
5597 printf 'Skipping after config, nothing changed\n'
5598 printf 'Skipping after config, nothing changed\n' >&2
5599 continue
5601 ${SHELL} -c "cd ../ && ${MAKE} build test"
5602 done
5603 ${rm} -f .ccac.h
5604 cd .. && ${MAKE} distclean
5607 [ -n "${ERR}" ] && echo > ${ERR}
5608 if [ -z "${CHECK_ONLY}${MAE_TEST}" ]; then
5609 cc_all_configs
5610 elif [ -z "${MAE_TEST}" ] || [ ${#} -eq 0 ]; then
5611 # if have_feat devel; then
5612 # ARGS="${ARGS} -Smemdebug"
5613 # export ARGS
5614 # fi
5615 t_all
5617 else
5618 while [ ${#} -gt 0 ]; do
5619 eval t_${1}
5620 shift
5621 done
5624 [ ${ESTAT} -eq 0 ] && echo Ok || echo >&2 'Errors occurred'
5626 exit ${ESTAT}
5627 # s-sh-mode