cache_setptr(): IMAP cache double free introduced with fix for CID 1376978!!
[s-mailx.git] / cc-test.sh
blobd234b1f8e37a77ba588efd29dfd28af4a56a1975
1 #!/bin/sh -
2 #@ Synopsis: ./cc-test.sh [--check-only s-mailx-binary]
3 #@ ./cc-test.sh --mae-test s-mailx-binary [:TESTNAME:]
4 #@ The latter generates output files.
5 #@ TODO All ex0_test should say TESTNUMBER-estat instead of having own numbers
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!
12 if [ -f ./mk-config.ev ]; then
13 . ./mk-config.ev
14 if [ -z "${MAILX__CC_TEST_RUNNING}" ]; then
15 MAILX__CC_TEST_RUNNING=1
16 export MAILX__CC_TEST_RUNNING
17 exec "${SHELL}" "${0}" "${@}"
19 else
20 echo >&2 'S-nail/S-mailx is not configured.'
21 echo >&2 'This test script requires the shell environment that only the'
22 echo >&2 'configuration script can figure out, even if it will be used to'
23 echo >&2 'test a different binary than the one that would be produced!'
24 exit 41
27 # We need *stealthmua* regardless of $SOURCE_DATE_EPOCH, the program name as
28 # such is a compile-time variable
29 ARGS='-:/ -# -Sdotlock-ignore-error -Sexpandaddr=restrict'
30 ARGS="${ARGS}"' -Smime-encoding=quoted-printable -Snosave -Sstealthmua'
31 ADDARG_UNI=-Sttycharset=UTF-8
32 CONF=./make.rc
33 BODY=./.cc-body.txt
34 MBOX=./.cc-test.mbox
35 MAIL=/dev/null
36 #UTF8_LOCALE= autodetected unless set
38 # Note valgrind has problems with FDs in forked childs, which causes some tests
39 # to fail (the FD is rewound and thus will be dumped twice)
40 MEMTESTER=
41 #MEMTESTER='valgrind --leak-check=full --log-file=.vl-%p '
43 ## -- (>8 -- 8<) -- ##
45 ( set -o noglob ) >/dev/null 2>&1 && noglob_shell=1 || unset noglob_shell
47 msg() {
48 fmt=${1}
49 shift
50 printf >&2 -- "${fmt}\\n" "${@}"
53 ## -- >8 -- 8< -- ##
55 export ARGS ADDARG_UNI CONF BODY MBOX MAIL MAKE awk cat cksum rm sed grep
57 LC_ALL=C LANG=C
58 TZ=UTC
59 # Wed Oct 2 01:50:07 UTC 1996
60 SOURCE_DATE_EPOCH=844221007
62 export LC_ALL LANG TZ SOURCE_DATE_EPOCH
63 unset POSIXLY_CORRECT LOGNAME USER
65 usage() {
66 echo >&2 "Synopsis: ./cc-test.sh [--check-only s-mailx-binary]"
67 echo >&2 "Synopsis: ./cc-test.sh --mae-test s-mailx-binary [:TESTNAME:]"
68 exit 1
71 CHECK_ONLY= MAE_TEST= MAILX=
72 if [ "${1}" = --check-only ]; then
73 CHECK_ONLY=1
74 MAILX=${2}
75 [ -x "${MAILX}" ] || usage
76 shift 2
77 elif [ "${1}" = --mae-test ]; then
78 MAE_TEST=1
79 MAILX=${2}
80 [ -x "${MAILX}" ] || usage
81 shift 2
83 RAWMAILX=${MAILX}
84 MAILX="${MEMTESTER}${MAILX}"
85 export RAWMAILX MAILX
87 if [ -n "${CHECK_ONLY}${MAE_TEST}" ] && [ -z "${UTF8_LOCALE}" ]; then
88 # Try ourselfs for nl_langinfo(CODESET) output first (requires a new version)
89 i=`LC_ALL=C.utf8 "${RAWMAILX}" ${ARGS} -X '
90 \define cset_test {
91 \if [ "${ttycharset}" @i=% utf ]
92 \echo $LC_ALL
93 \xit 0
94 \end
95 \if [ "${#}" -gt 0 ]
96 \wysh set LC_ALL=${1}
97 \shift
98 \eval xcall cset_test "${@}"
99 \end
100 \xit 1
102 \call cset_test C.UTF-8 POSIX.utf8 POSIX.UTF-8 en_EN.utf8 en_EN.UTF-8 \
103 en_US.utf8 en_US.UTF-8
105 [ $? -eq 0 ] && UTF8_LOCALE=$i
107 if [ -z "${UTF8_LOCALE}" ] && (locale yesexpr) >/dev/null 2>&1; then
108 UTF8_LOCALE=`locale -a | { m=
109 while read n; do
110 if { echo ${n} | ${grep} -i 'utf-\{0,1\}8'; } >/dev/null 2>&1; then
111 m=${n}
112 if { echo ${n} | ${grep} -e POSIX -e en_EN -e en_US; }; then
113 exit 0
116 m=${n}
117 done
118 echo ${m}
123 ESTAT=0
125 TRAP_EXIT_ADDONS=
126 trap "${rm} -rf \"${BODY}\" \"${MBOX}\" \${TRAP_EXIT_ADDONS}" EXIT
127 trap "exit 1" HUP INT TERM
129 # cc_all_configs()
130 # Test all configs TODO doesn't cover all *combinations*, stupid!
131 cc_all_configs() {
132 < ${CONF} ${awk} '
133 BEGIN {
134 NOTME["OPT_AUTOCC"] = 1
135 NOTME["OPT_DEBUG"] = 1
136 NOTME["OPT_DEVEL"] = 1
137 NOTME["OPT_ASAN_ADDRESS"] = 1
138 NOTME["OPT_ASAN_MEMORY"] = 1
139 NOTME["OPT_FORCED_STACKPROT"] = 1
140 NOTME["OPT_NOMEMDBG"] = 1
141 NOTME["OPT_NYD2"] = 1
142 i = 0
144 /^[[:space:]]*OPT_/ {
145 sub(/^[[:space:]]*/, "")
146 # This bails for UnixWare 7.1.4 awk(1), but preceeding = with \
147 # does not seem to be a compliant escape for =
148 #sub(/=.*$/, "")
149 $1 = substr($1, 1, index($1, "=") - 1)
150 if (NOTME[$1])
151 next
152 data[i++] = $1
154 END {
155 # Doing this completely sequentially and not doing make distclean in
156 # between runs should effectively result in lesser compilations.
157 # It is completely dumb nonetheless... TODO
158 for (j = 1; j < i; ++j) {
159 for (k = 1; k < j; ++k)
160 printf data[k] "=1 "
161 for (k = j; k < i; ++k)
162 printf data[k] "=0 "
163 printf "OPT_AUTOCC=1\n"
165 for (j = 1; j < i; ++j) {
166 for (k = 1; k < j; ++k)
167 printf data[k] "=0 "
168 for (k = j; k < i; ++k)
169 printf data[k] "=1 "
170 printf "OPT_AUTOCC=1\n"
172 # With debug
173 for (j = 1; j < i; ++j) {
174 for (k = 1; k < j; ++k)
175 printf data[k] "=1 "
176 for (k = j; k < i; ++k)
177 printf data[k] "=0 "
178 printf "OPT_AUTOCC=1\n"
179 printf "OPT_DEBUG=1\n"
181 for (j = 1; j < i; ++j) {
182 for (k = 1; k < j; ++k)
183 printf data[k] "=0 "
184 for (k = j; k < i; ++k)
185 printf data[k] "=1 "
186 printf "OPT_AUTOCC=1\n"
187 printf "OPT_DEBUG=1\n"
190 printf "CONFIG=NULL OPT_AUTOCC=0\n"
191 printf "CONFIG=NULL OPT_AUTOCC=1\n"
192 printf "CONFIG=NULLI OPT_AUTOCC=0\n"
193 printf "CONFIG=NULLI OPT_AUTOCC=1\n"
194 printf "CONFIG=MINIMAL OPT_AUTOCC=0\n"
195 printf "CONFIG=MINIMAL OPT_AUTOCC=1\n"
196 printf "CONFIG=NETSEND OPT_AUTOCC=0\n"
197 printf "CONFIG=NETSEND OPT_AUTOCC=1\n"
198 printf "CONFIG=MAXIMAL OPT_AUTOCC=0\n"
199 printf "CONFIG=MAXIMAL OPT_AUTOCC=1\n"
200 printf "CONFIG=DEVEL OPT_AUTOCC=0\n"
201 printf "CONFIG=DEVEL OPT_AUTOCC=1\n"
202 printf "CONFIG=ODEVEL OPT_AUTOCC=0\n"
203 printf "CONFIG=ODEVEL OPT_AUTOCC=1\n"
205 ' | while read c; do
206 printf "\n\n##########\n$c\n"
207 printf "\n\n##########\n$c\n" >&2
208 sh -c "${MAKE} ${c} all test"
209 done
210 ${MAKE} distclean
213 have_feat() {
214 ( "${RAWMAILX}" ${ARGS} -X'echo $features' -Xx |
215 ${grep} +${1} ) >/dev/null 2>&1
218 t_prolog() {
219 ${rm} -rf "${BODY}" "${MBOX}" ${TRAP_EXIT_ADDONS}
220 TRAP_EXIT_ADDONS=
221 [ ${#} -gt 0 ] && printf '[%s]\n' "${1}"
223 t_epilog() {
224 t_prolog
227 check() {
228 restat=${?} tid=${1} eestat=${2} f=${3} s=${4}
229 [ "${eestat}" != - ] && [ "${restat}" != "${eestat}" ] &&
230 err "${tid}" 'unexpected exit status: '"${restat} != ${eestat}"
231 csum="`${cksum} < ${f}`"
232 if [ "${csum}" = "${s}" ]; then
233 printf '%s: ok\n' "${tid}"
234 else
235 ESTAT=1
236 printf '%s: error: checksum mismatch (got %s)\n' "${tid}" "${csum}"
238 if [ -n "${MAE_TEST}" ]; then
239 x=`echo ${tid} | ${tr} "/:=" "__-"`
240 ${cp} -f "${f}" ./mae-test-"${x}"
244 err() {
245 ESTAT=1
246 printf '%s: error: %s\n' ${1} "${2}"
249 ex0_test() {
250 # $1=test name [$2=status]
251 __qm__=${?}
252 [ ${#} -gt 1 ] && __qm__=${2}
253 if [ ${__qm__} -ne 0 ]; then
254 err $1 'unexpected non-0 exit status'
255 else
256 printf '%s: ok\n' "${1}"
260 exn0_test() {
261 # $1=test name [$2=status]
262 __qm__=${?}
263 [ ${#} -gt 1 ] && __qm__=${2}
264 if [ ${__qm__} -eq 0 ]; then
265 err $1 'unexpected 0 exit status'
266 else
267 printf '%s: ok\n' "${1}"
271 if ( [ "$((1 + 1))" = 2 ] ) >/dev/null 2>&1; then
272 add() {
273 echo "$((${1} + ${2}))"
275 else
276 add() {
277 echo `${awk} 'BEGIN{print '${1}' + '${2}'}'`
281 if ( [ "$((2 % 3))" = 2 ] ) >/dev/null 2>&1; then
282 modulo() {
283 echo "$((${1} % ${2}))"
285 else
286 modulo() {
287 echo `${awk} 'BEGIN{print '${1}' % '${2}'}'`
291 # t_behave()
292 # Basic (easily testable) behaviour tests
293 t_behave() {
294 t_behave_X_opt_input_command_stack
295 t_behave_X_errexit
296 t_behave_S_freeze
297 t_behave_wysh
298 t_behave_input_inject_semicolon_seq
299 t_behave_commandalias
300 t_behave_ifelse
301 t_behave_localopts
302 t_behave_local
303 t_behave_macro_param_shift
304 t_behave_addrcodec
305 t_behave_vexpr
306 t_behave_call_ret
307 t_behave_xcall
308 t_behave_vpospar
309 t_behave_atxplode
310 t_behave_read
312 t_behave_mbox
313 t_behave_maildir
314 t_behave_record_a_resend
315 t_behave_e_H_L_opts
317 t_behave_alternates
318 t_behave_alias
319 # FIXME t_behave_mlist
320 t_behave_filetype
322 t_behave_message_injections
323 t_behave_attachments
324 t_behave_compose_hooks
325 t_behave_C_opt_customhdr
327 t_behave_mass_recipients
328 t_behave_mime_types_load_control
329 t_behave_lreply_futh_rth_etc
331 t_behave_xxxheads_rfc2047
332 t_behave_rfc2231
333 t_behave_iconv_mbyte_base64
334 t_behave_iconv_mainbody
335 t_behave_binary_mainbody
336 t_behave_q_t_etc_opts
338 t_behave_s_mime
341 t_behave_X_opt_input_command_stack() {
342 t_prolog t_behave_X_opt_input_command_stack
344 ${cat} <<- '__EOT' > "${BODY}"
345 echo 1
346 define mac0 {
347 echo mac0-1 via1 $0
349 call mac0
350 echo 2
351 source '\
352 echo "define mac1 {";\
353 echo " echo mac1-1 via1 \$0";\
354 echo " call mac0";\
355 echo " echo mac1-2";\
356 echo " call mac2";\
357 echo " echo mac1-3";\
358 echo "}";\
359 echo "echo 1-1";\
360 echo "define mac2 {";\
361 echo " echo mac2-1 via1 \$0";\
362 echo " call mac0";\
363 echo " echo mac2-2";\
364 echo "}";\
365 echo "echo 1-2";\
366 echo "call mac1";\
367 echo "echo 1-3";\
368 echo "source \"\
369 echo echo 1-1-1 via1 \$0;\
370 echo call mac0;\
371 echo echo 1-1-2;\
372 | \"";\
373 echo "echo 1-4";\
375 echo 3
376 call mac2
377 echo 4
378 undefine *
379 __EOT
381 # The -X option supports multiline arguments, and those can internally use
382 # reverse solidus newline escaping. And all -X options are joined...
383 APO=\'
384 < "${BODY}" ${MAILX} ${ARGS} \
385 -X 'e\' \
386 -X ' c\' \
387 -X ' h\' \
388 -X ' o \' \
389 -X 1 \
391 define mac0 {
392 echo mac0-1 via2 $0
394 call mac0
395 echo 2
398 source '${APO}'\
399 echo "define mac1 {";\
400 echo " echo mac1-1 via2 \$0";\
401 echo " call mac0";\
402 echo " echo mac1-2";\
403 echo " call mac2";\
404 echo " echo mac1-3";\
405 echo "}";\
406 echo "echo 1-1";\
407 echo "define mac2 {";\
408 echo " echo mac2-1 via2 \$0";\
409 echo " call mac0";\
410 echo " echo mac2-2";\
411 echo "}";\
412 echo "echo 1-2";\
413 echo "call mac1";\
414 echo "echo 1-3";\
415 echo "source \"\
416 echo echo 1-1-1 via2 \$0;\
417 echo call mac0;\
418 echo echo 1-1-2;\
419 | \"";\
420 echo "echo 1-4";\
421 | '${APO}'
422 echo 3
425 call mac2
426 echo 4
427 undefine *
428 ' > "${MBOX}"
430 check behave:x_opt_input_command_stack 0 "${MBOX}" '1786542668 416'
432 t_epilog
435 t_behave_X_errexit() {
436 t_prolog t_behave_X_errexit
438 ${cat} <<- '__EOT' > "${BODY}"
439 echo one
440 echos nono
441 echo two
442 __EOT
444 </dev/null ${MAILX} ${ARGS} -Snomemdebug \
445 -X'echo one' -X' echos nono ' -X'echo two' \
446 > "${MBOX}" 2>&1
447 check behave:x_errexit-1 0 "${MBOX}" '916157812 53'
449 </dev/null ${MAILX} ${ARGS} -X'source '"${BODY}" -Snomemdebug \
450 > "${MBOX}" 2>&1
451 check behave:x_errexit-2 0 "${MBOX}" '916157812 53'
453 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Snomemdebug \
454 > "${MBOX}" 2>&1
455 check behave:x_errexit-3 0 "${MBOX}" '916157812 53'
459 </dev/null ${MAILX} ${ARGS} -Serrexit -Snomemdebug \
460 -X'echo one' -X' echos nono ' -X'echo two' \
461 > "${MBOX}" 2>&1
462 check behave:x_errexit-4 1 "${MBOX}" '2118430867 49'
464 </dev/null ${MAILX} ${ARGS} -X'source '"${BODY}" -Serrexit -Snomemdebug \
465 > "${MBOX}" 2>&1
466 check behave:x_errexit-5 1 "${MBOX}" '2118430867 49'
468 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Serrexit -Snomemdebug \
469 > "${MBOX}" 2>&1
470 check behave:x_errexit-6 1 "${MBOX}" '12955965 172'
472 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Sposix -Snomemdebug \
473 > "${MBOX}" 2>&1
474 check behave:x_errexit-7 1 "${MBOX}" '12955965 172'
476 ## Repeat 4-7 with ignerr set
478 ${sed} -e 's/^echos /ignerr echos /' < "${BODY}" > "${MBOX}"
480 </dev/null ${MAILX} ${ARGS} -Serrexit -Snomemdebug \
481 -X'echo one' -X'ignerr echos nono ' -X'echo two' \
482 > "${BODY}" 2>&1
483 check behave:x_errexit-8 0 "${BODY}" '916157812 53'
485 </dev/null ${MAILX} ${ARGS} -X'source '"${MBOX}" -Serrexit -Snomemdebug \
486 > "${BODY}" 2>&1
487 check behave:x_errexit-9 0 "${BODY}" '916157812 53'
489 </dev/null MAILRC="${MBOX}" ${MAILX} ${ARGS} -:u -Serrexit -Snomemdebug \
490 > "${BODY}" 2>&1
491 check behave:x_errexit-10 0 "${BODY}" '916157812 53'
493 </dev/null MAILRC="${MBOX}" ${MAILX} ${ARGS} -:u -Sposix -Snomemdebug \
494 > "${BODY}" 2>&1
495 check behave:x_errexit-11 0 "${BODY}" '916157812 53'
497 t_epilog
500 t_behave_S_freeze() {
501 t_prolog t_behave_S_freeze
502 oterm=$TERM
503 unset TERM
505 # Test basic assumption
506 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} \
507 -X'echo asksub<$asksub> dietcurd<$dietcurd>' \
508 -Xx > "${MBOX}" 2>&1
509 check behave:s_freeze-1 0 "${MBOX}" '270686329 21'
512 ${cat} <<- '__EOT' > "${BODY}"
513 echo asksub<$asksub>
514 set asksub
515 echo asksub<$asksub>
516 __EOT
517 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
518 -Snoasksub -Sasksub -Snoasksub \
519 -X'echo asksub<$asksub>' -X'set asksub' -X'echo asksub<$asksub>' \
520 -Xx > "${MBOX}" 2>&1
521 check behave:s_freeze-2 0 "${MBOX}" '3182942628 37'
523 ${cat} <<- '__EOT' > "${BODY}"
524 echo asksub<$asksub>
525 unset asksub
526 echo asksub<$asksub>
527 __EOT
528 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
529 -Snoasksub -Sasksub \
530 -X'echo asksub<$asksub>' -X'unset asksub' -X'echo asksub<$asksub>' \
531 -Xx > "${MBOX}" 2>&1
532 check behave:s_freeze-3 0 "${MBOX}" '2006554293 39'
535 ${cat} <<- '__EOT' > "${BODY}"
536 echo dietcurd<$dietcurd>
537 set dietcurd=cherry
538 echo dietcurd<$dietcurd>
539 __EOT
540 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
541 -Sdietcurd=strawberry -Snodietcurd -Sdietcurd=vanilla \
542 -X'echo dietcurd<$dietcurd>' -X'unset dietcurd' \
543 -X'echo dietcurd<$dietcurd>' \
544 -Xx > "${MBOX}" 2>&1
545 check behave:s_freeze-4 0 "${MBOX}" '1985768109 65'
547 ${cat} <<- '__EOT' > "${BODY}"
548 echo dietcurd<$dietcurd>
549 unset dietcurd
550 echo dietcurd<$dietcurd>
551 __EOT
552 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
553 -Sdietcurd=strawberry -Snodietcurd \
554 -X'echo dietcurd<$dietcurd>' -X'set dietcurd=vanilla' \
555 -X'echo dietcurd<$dietcurd>' \
556 -Xx > "${MBOX}" 2>&1
557 check behave:s_freeze-5 0 "${MBOX}" '151574279 51'
559 # TODO once we have a detached one with env=1..
560 if [ -n "`</dev/null ${MAILX} ${ARGS} -X'!echo \$TERM' -Xx`" ]; then
561 echo 'behave:s_freeze-{6,7}: shell sets $TERM, skipped'
562 else
563 ${cat} <<- '__EOT' > "${BODY}"
564 !echo "shell says TERM<$TERM>"
565 echo TERM<$TERM>
566 !echo "shell says TERM<$TERM>"
567 set TERM=cherry
568 !echo "shell says TERM<$TERM>"
569 echo TERM<$TERM>
570 !echo "shell says TERM<$TERM>"
571 __EOT
572 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
573 -STERM=strawberry -SnoTERM -STERM=vanilla \
574 -X'echo mail<$TERM>' -X'unset TERM' \
575 -X'!echo "shell says TERM<$TERM>"' -X'echo TERM<$TERM>' \
576 -Xx > "${MBOX}" 2>&1
577 check behave:s_freeze-6 0 "${MBOX}" '1211476036 167'
579 ${cat} <<- '__EOT' > "${BODY}"
580 !echo "shell says TERM<$TERM>"
581 echo TERM<$TERM>
582 !echo "shell says TERM<$TERM>"
583 set TERM=cherry
584 !echo "shell says TERM<$TERM>"
585 echo TERM<$TERM>
586 !echo "shell says TERM<$TERM>"
587 __EOT
588 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
589 -STERM=strawberry -SnoTERM \
590 -X'echo TERM<$TERM>' -X'set TERM=vanilla' \
591 -X'!echo "shell says TERM<$TERM>"' -X'echo TERM<$TERM>' \
592 -Xx > "${MBOX}" 2>&1
593 check behave:s_freeze-7 0 "${MBOX}" '3365080441 132'
596 TERM=$oterm
597 t_epilog
600 t_behave_wysh() {
601 t_prolog t_behave_wysh
603 ${cat} <<- '__EOT' > "${BODY}"
605 echo abcd
606 echo a'b'c'd'
607 echo a"b"c"d"
608 echo a$'b'c$'d'
609 echo 'abcd'
610 echo "abcd"
611 echo $'abcd'
612 echo a\ b\ c\ d
613 echo a 'b c' d
614 echo a "b c" d
615 echo a $'b c' d
617 echo 'a$`"\'
618 echo "a\$\`'\"\\"
619 echo $'a\$`\'\"\\'
620 echo $'a\$`\'"\\'
621 # DIET=CURD TIED=
622 echo 'a${DIET}b${TIED}c\${DIET}d\${TIED}e' # COMMENT
623 echo "a${DIET}b${TIED}c\${DIET}d\${TIED}e"
624 echo $'a${DIET}b${TIED}c\${DIET}d\${TIED}e'
626 echo a$'\101\0101\x41\u0041\u41\U00000041\U41'c
627 echo a$'\u0041\u41\u0C1\U00000041\U41'c
628 echo a$'\377'c
629 echo a$'\0377'c
630 echo a$'\400'c
631 echo a$'\0400'c
632 echo a$'\U1100001'c
634 echo a$'b\0c'd
635 echo a$'b\00c'de
636 echo a$'b\000c'df
637 echo a$'b\0000c'dg
638 echo a$'b\x0c'dh
639 echo a$'b\x00c'di
640 echo a$'b\u0'dj
641 echo a$'b\u00'dk
642 echo a$'b\u000'dl
643 echo a$'b\u0000'dm
644 echo a$'b\U0'dn
645 echo a$'b\U00'do
646 echo a$'b\U000'dp
647 echo a$'b\U0000'dq
648 echo a$'b\U00000'dr
649 echo a$'b\U000000'ds
650 echo a$'b\U0000000'dt
651 echo a$'b\U00000000'du
653 echo a$'\cI'b
654 echo a$'\011'b
655 echo a$'\x9'b
656 echo a$'\u9'b
657 echo a$'\U9'b
658 echo a$'\c@'b c d
659 __EOT
661 if [ -z "${UTF8_LOCALE}" ]; then
662 echo 'Skip behave:wysh_unicode, no UTF8_LOCALE'
663 else
664 < "${BODY}" DIET=CURD TIED= \
665 LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} 2>/dev/null > "${MBOX}"
666 check behave:wysh_unicode 0 "${MBOX}" '475805847 317'
669 < "${BODY}" DIET=CURD TIED= ${MAILX} ${ARGS} > "${MBOX}" 2>/dev/null
670 check behave:wysh_c 0 "${MBOX}" '1473887148 321'
672 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
673 wysh set mager='\hey\'
674 varshow mager
675 wysh set mager="\hey\\"
676 varshow mager
677 wysh set mager=$'\hey\\'
678 varshow mager
679 __EOT
680 check behave:wysh-3 0 "${MBOX}" '1289698238 69'
682 t_epilog
685 t_behave_input_inject_semicolon_seq() {
686 t_prolog t_behave_input_inject_semicolon_seq
688 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
689 define mydeepmac {
690 echon '(mydeepmac)';
692 define mymac {
693 echon this_is_mymac;call mydeepmac;echon ';';
695 echon one';';call mymac;echon two";";call mymac;echo three$';';
696 define mymac {
697 echon this_is_mymac;call mydeepmac;echon ,TOO'!;';
699 echon one';';call mymac;echon two";";call mymac;echo three$';';
700 __EOT
702 check behave:input_inject_semicolon_seq 0 "${MBOX}" '512117110 140'
704 t_epilog
707 t_behave_commandalias() {
708 t_prolog t_behave_commandalias
710 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
711 commandalias echo echo hoho
712 echo stop.
713 commandalias X Xx
714 commandalias Xx XxX
715 commandalias XxX XxXx
716 commandalias XxXx XxXxX
717 commandalias XxXxX XxXxXx
718 commandalias XxXxXx echo huhu
719 commandalias XxXxXxX echo huhu
721 commandalias XxXxXx XxXxXxX
723 uncommandalias echo
724 commandalias XxXxXx echo huhu
726 __EOT
728 check behave:commandalias 0 "${MBOX}" '3694143612 31'
730 t_epilog
733 t_behave_ifelse() {
734 t_prolog t_behave_ifelse
736 # Nestable conditions test
737 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
738 if 0
739 echo 1.err
740 else
741 echo 1.ok
742 endif
743 if 1
744 echo 2.ok
745 else
746 echo 2.err
747 endif
748 if $dietcurd
749 echo 3.err
750 else
751 echo 3.ok
752 endif
753 set dietcurd=yoho
754 if $dietcurd
755 echo 4.ok
756 else
757 echo 4.err
758 endif
759 if $dietcurd == 'yoho'
760 echo 5.ok
761 else
762 echo 5.err
763 endif
764 if $dietcurd @== 'Yoho'
765 echo 5-1.ok
766 else
767 echo 5-1.err
768 endif
769 if $dietcurd == 'Yoho'
770 echo 5-2.err
771 else
772 echo 5-2.ok
773 endif
774 if $dietcurd != 'yoho'
775 echo 6.err
776 else
777 echo 6.ok
778 endif
779 if $dietcurd @!= 'Yoho'
780 echo 6-1.err
781 else
782 echo 6-1.ok
783 endif
784 if $dietcurd != 'Yoho'
785 echo 6-2.ok
786 else
787 echo 6-2.err
788 endif
789 # Nesting
790 if faLse
791 echo 7.err1
792 if tRue
793 echo 7.err2
794 if yEs
795 echo 7.err3
796 else
797 echo 7.err4
798 endif
799 echo 7.err5
800 endif
801 echo 7.err6
802 else
803 echo 7.ok7
804 if YeS
805 echo 7.ok8
806 if No
807 echo 7.err9
808 else
809 echo 7.ok9
810 endif
811 echo 7.ok10
812 else
813 echo 7.err11
814 if yeS
815 echo 7.err12
816 else
817 echo 7.err13
818 endif
819 endif
820 echo 7.ok14
821 endif
822 if r
823 echo 8.ok1
824 if R
825 echo 8.ok2
826 else
827 echo 8.err2
828 endif
829 echo 8.ok3
830 else
831 echo 8.err1
832 endif
833 if s
834 echo 9.err1
835 else
836 echo 9.ok1
837 if S
838 echo 9.err2
839 else
840 echo 9.ok2
841 endif
842 echo 9.ok3
843 endif
844 # `elif'
845 if $dietcurd == 'yohu'
846 echo 10.err1
847 elif $dietcurd == 'yoha'
848 echo 10.err2
849 elif $dietcurd == 'yohe'
850 echo 10.err3
851 elif $dietcurd == 'yoho'
852 echo 10.ok1
853 if $dietcurd == 'yohu'
854 echo 10.err4
855 elif $dietcurd == 'yoha'
856 echo 10.err5
857 elif $dietcurd == 'yohe'
858 echo 10.err6
859 elif $dietcurd == 'yoho'
860 echo 10.ok2
861 if $dietcurd == 'yohu'
862 echo 10.err7
863 elif $dietcurd == 'yoha'
864 echo 10.err8
865 elif $dietcurd == 'yohe'
866 echo 10.err9
867 elif $dietcurd == 'yoho'
868 echo 10.ok3
869 else
870 echo 10.err10
871 endif
872 else
873 echo 10.err11
874 endif
875 else
876 echo 10.err12
877 endif
878 # integer
879 set dietcurd=10
880 if $dietcurd -lt 11
881 echo 11.ok1
882 if $dietcurd -gt 9
883 echo 11.ok2
884 else
885 echo 11.err2
886 endif
887 if $dietcurd -eq 10
888 echo 11.ok3
889 else
890 echo 11.err3
891 endif
892 if $dietcurd -ge 10
893 echo 11.ok4
894 else
895 echo 11.err4
896 endif
897 if $dietcurd -le 10
898 echo 11.ok5
899 else
900 echo 11.err5
901 endif
902 if $dietcurd -ge 11
903 echo 11.err6
904 else
905 echo 11.ok6
906 endif
907 if $dietcurd -le 9
908 echo 11.err7
909 else
910 echo 11.ok7
911 endif
912 else
913 echo 11.err1
914 endif
915 set dietcurd=Abc
916 if $dietcurd < aBd
917 echo 12.ok1
918 if $dietcurd @> abB
919 echo 12.ok2
920 else
921 echo 12.err2
922 endif
923 if $dietcurd @== aBC
924 echo 12.ok3
925 else
926 echo 12.err3
927 endif
928 if $dietcurd @>= AbC
929 echo 12.ok4
930 else
931 echo 12.err4
932 endif
933 if $dietcurd @<= ABc
934 echo 12.ok5
935 else
936 echo 12.err5
937 endif
938 if $dietcurd @>= abd
939 echo 12.err6
940 else
941 echo 12.ok6
942 endif
943 if $dietcurd @<= abb
944 echo 12.err7
945 else
946 echo 12.ok7
947 endif
948 else
949 echo 12.err1
950 endif
951 if $dietcurd < aBc
952 echo 12-1.ok
953 else
954 echo 12-1.err
955 endif
956 if $dietcurd @< aBc
957 echo 12-2.err
958 else
959 echo 12-2.ok
960 endif
961 if $dietcurd > ABc
962 echo 12-3.ok
963 else
964 echo 12-3.err
965 endif
966 if $dietcurd @> ABc
967 echo 12-3.err
968 else
969 echo 12-3.ok
970 endif
971 if $dietcurd @i=% aB
972 echo 13.ok
973 else
974 echo 13.err
975 endif
976 if $dietcurd =% aB
977 echo 13-1.err
978 else
979 echo 13-1.ok
980 endif
981 if $dietcurd @=% bC
982 echo 14.ok
983 else
984 echo 14.err
985 endif
986 if $dietcurd !% aB
987 echo 15-1.ok
988 else
989 echo 15-1.err
990 endif
991 if $dietcurd @!% aB
992 echo 15-2.err
993 else
994 echo 15-2.ok
995 endif
996 if $dietcurd !% bC
997 echo 15-3.ok
998 else
999 echo 15-3.err
1000 endif
1001 if $dietcurd @!% bC
1002 echo 15-4.err
1003 else
1004 echo 15-4.ok
1005 endif
1006 if $dietcurd =% Cd
1007 echo 16.err
1008 else
1009 echo 16.ok
1010 endif
1011 if $dietcurd !% Cd
1012 echo 17.ok
1013 else
1014 echo 17.err
1015 endif
1016 set diet=abc curd=abc
1017 if $diet == $curd
1018 echo 18.ok
1019 else
1020 echo 18.err
1021 endif
1022 set diet=abc curd=abcd
1023 if $diet != $curd
1024 echo 19.ok
1025 else
1026 echo 19.err
1027 endif
1028 # 1. Shitty grouping capabilities as of today
1029 unset diet curd ndefined
1030 if [ [ false ] || [ false ] || [ true ] ] && [ [ false ] || [ true ] ] && \
1031 [ yes ]
1032 echo 20.ok
1033 else
1034 echo 20.err
1035 endif
1036 if [ [ [ [ 0 ] || [ 1 ] ] && [ [ 1 ] || [ 0 ] ] ] && [ 1 ] ] && [ yes ]
1037 echo 21.ok
1038 else
1039 echo 21.err
1040 endif
1041 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] ]
1042 echo 22.ok
1043 else
1044 echo 22.err
1045 endif
1046 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] ]
1047 echo 23.ok
1048 else
1049 echo 23.err
1050 endif
1051 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] && [ no ]
1052 echo 24.err
1053 else
1054 echo 24.ok
1055 endif
1056 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] \
1057 && [ no ] || [ yes ]
1058 echo 25.ok
1059 else
1060 echo 25.err
1061 endif
1062 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
1063 echo 26.ok
1064 else
1065 echo 26.err
1066 endif
1067 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 0 ] ]
1068 echo 27.err
1069 else
1070 echo 27.ok
1071 endif
1072 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 0 ] ] && [ 1 ] ] ] && [ 1 ] ]
1073 echo 28.err
1074 else
1075 echo 28.ok
1076 endif
1077 if [ [ [ [ [ [ [ 0 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
1078 echo 29.err
1079 else
1080 echo 29.ok
1081 endif
1082 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 0 ]
1083 echo 30.err
1084 else
1085 echo 30.ok
1086 endif
1087 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 1 ]
1088 echo 31.ok
1089 else
1090 echo 31.err
1091 endif
1092 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ]
1093 echo 32.err
1094 else
1095 echo 32.ok
1096 endif
1097 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 1 ]
1098 echo 33.ok
1099 else
1100 echo 33.err
1101 endif
1102 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 0 ]
1103 echo 34.err
1104 else
1105 echo 34.ok
1106 endif
1107 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 1 ]
1108 echo 35.ok
1109 else
1110 echo 35.err
1111 endif
1112 set diet=yo curd=ho
1113 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
1114 echo 36.err
1115 else
1116 echo 36.ok
1117 endif
1118 set ndefined
1119 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
1120 echo 37.ok
1121 else
1122 echo 37.err
1123 endif
1124 # 2. Shitty grouping capabilities as of today
1125 unset diet curd ndefined
1126 if [ false || false || true ] && [ false || true ] && yes
1127 echo 40.ok
1128 else
1129 echo 40.err
1130 endif
1131 if [ [ [ 0 || 1 ] && [ 1 || 0 ] ] && 1 ] && [ yes ]
1132 echo 41.ok
1133 else
1134 echo 41.err
1135 endif
1136 if [ 1 || 0 || 0 || 0 ]
1137 echo 42.ok
1138 else
1139 echo 42.err
1140 endif
1141 if [ 1 || 0 || 0 || 0 || [ 1 ] ]
1142 echo 43.ok
1143 else
1144 echo 43.err
1145 endif
1146 if [ 1 || 0 || 0 || 0 || [ 1 ] || 1 ] && no
1147 echo 44.err
1148 else
1149 echo 44.ok
1150 endif
1151 if [ 1 || 0 || 0 || 0 || 1 || [ 1 ] ] && no || [ yes ]
1152 echo 45.ok
1153 else
1154 echo 45.err
1155 endif
1156 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && 1 ] ] && [ 1 ] ]
1157 echo 46.ok
1158 else
1159 echo 46.err
1160 endif
1161 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && [ 1 ] ] ] && 0 ]
1162 echo 47.err
1163 else
1164 echo 47.ok
1165 endif
1166 if [ [ [ [ [ [ [ 1 ] ] && 1 ] && 0 ] && [ 1 ] ] ] && 1 ]
1167 echo 48.err
1168 else
1169 echo 48.ok
1170 endif
1171 if [ [ [ [ [ [ 0 ] && 1 ] && 1 ] && 1 ] ] && 1 ]
1172 echo 49.err
1173 else
1174 echo 49.ok
1175 endif
1176 if 1 || 0 || 0 || 0 && 0
1177 echo 50.err
1178 else
1179 echo 50.ok
1180 endif
1181 if 1 || 0 || 0 || 0 && 1
1182 echo 51.ok
1183 else
1184 echo 51.err
1185 endif
1186 if 0 || 0 || 0 || 1 && 0
1187 echo 52.err
1188 else
1189 echo 52.ok
1190 endif
1191 if 0 || 0 || 0 || 1 && 1
1192 echo 53.ok
1193 else
1194 echo 53.err
1195 endif
1196 if 0 || 0 || 0 || 1 && 0 || 1 && 0
1197 echo 54.err
1198 else
1199 echo 54.ok
1200 endif
1201 if 0 || 0 || 0 || 1 && 0 || 1 && 1
1202 echo 55.ok
1203 else
1204 echo 55.err
1205 endif
1206 set diet=yo curd=ho
1207 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
1208 echo 56.err
1209 else
1210 echo 56.ok
1211 endif
1212 if $diet == 'yo' && $curd == 'ho' && $ndefined
1213 echo 57.err
1214 else
1215 echo 57.ok
1216 endif
1217 set ndefined
1218 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
1219 echo 57.ok
1220 else
1221 echo 57.err
1222 endif
1223 if $diet == 'yo' && $curd == 'ho' && $ndefined
1224 echo 58.ok
1225 else
1226 echo 58.err
1227 endif
1228 if [ [ [ [ [ [ $diet == 'yo' && $curd == 'ho' && $ndefined ] ] ] ] ] ]
1229 echo 59.ok
1230 else
1231 echo 59.err
1232 endif
1233 # Some more en-braced variables
1234 set diet=yo curd=ho
1235 if ${diet} == ${curd}
1236 echo 70.err
1237 else
1238 echo 70.ok
1239 endif
1240 if ${diet} != ${curd}
1241 echo 71.ok
1242 else
1243 echo 71.err
1244 endif
1245 if $diet == ${curd}
1246 echo 72.err
1247 else
1248 echo 72.ok
1249 endif
1250 if ${diet} == $curd
1251 echo 73.err
1252 else
1253 echo 73.ok
1254 endif
1255 # Unary !
1256 if ! 0 && ! ! 1 && ! ! ! ! 2 && 3
1257 echo 80.ok
1258 else
1259 echo 80.err
1260 endif
1261 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ ! 2 ] ] ] && 3
1262 echo 81.ok
1263 else
1264 echo 81.err
1265 endif
1266 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1267 echo 82.ok
1268 else
1269 echo 82.err
1270 endif
1271 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
1272 echo 83.err
1273 else
1274 echo 83.ok
1275 endif
1276 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
1277 echo 84.err
1278 else
1279 echo 84.ok
1280 endif
1281 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1282 echo 85.err
1283 else
1284 echo 85.ok
1285 endif
1286 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1287 echo 86.err
1288 else
1289 echo 86.ok
1290 endif
1291 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] || 3
1292 echo 87.ok
1293 else
1294 echo 87.err
1295 endif
1296 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! ! [ 2 ] ] ] ] ]
1297 echo 88.ok
1298 else
1299 echo 88.err
1300 endif
1301 # Unary !, odd
1302 if ! 0 && ! ! 1 && ! ! ! 0 && 3
1303 echo 90.ok
1304 else
1305 echo 90.err
1306 endif
1307 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ 0 ] ] ] && 3
1308 echo 91.ok
1309 else
1310 echo 91.err
1311 endif
1312 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ [ 0 ] ] ] ] ] && 3
1313 echo 92.ok
1314 else
1315 echo 92.err
1316 endif
1317 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! ! [ ! [ ! 0 ] ] ] ] && ! 3
1318 echo 93.err
1319 else
1320 echo 93.ok
1321 endif
1322 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ ! [ ! [ ! [ ! 0 ] ] ] ] && 3
1323 echo 94.ok
1324 else
1325 echo 94.err
1326 endif
1327 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! ! [ ! [ ! [ ! [ 0 ] ] ] ] ] && 3
1328 echo 95.err
1329 else
1330 echo 95.ok
1331 endif
1332 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! ! 0 ] ] ] ] && 3
1333 echo 96.err
1334 else
1335 echo 96.ok
1336 endif
1337 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ ! 0 ] ] ] ] ] || 3
1338 echo 97.ok
1339 else
1340 echo 97.err
1341 endif
1342 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! [ 0 ] ] ] ] ]
1343 echo 98.ok
1344 else
1345 echo 98.err
1346 endif
1347 __EOT
1349 check behave:if-normal 0 "${MBOX}" '1688759742 719'
1351 if have_feat regex; then
1352 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
1353 set dietcurd=yoho
1354 if $dietcurd =~ '^yo.*'
1355 echo 1.ok
1356 else
1357 echo 1.err
1358 endif
1359 if $dietcurd =~ '^Yo.*'
1360 echo 1-1.err
1361 else
1362 echo 1-1.ok
1363 endif
1364 if $dietcurd @=~ '^Yo.*'
1365 echo 1-2.ok
1366 else
1367 echo 1-2.err
1368 endif
1369 if $dietcurd =~ '^yOho.+'
1370 echo 2.err
1371 else
1372 echo 2.ok
1373 endif
1374 if $dietcurd @!~ '.*Ho$'
1375 echo 3.err
1376 else
1377 echo 3.ok
1378 endif
1379 if $dietcurd !~ '.+yohO$'
1380 echo 4.ok
1381 else
1382 echo 4.err
1383 endif
1384 if [ $dietcurd @i!~ '.+yoho$' ]
1385 echo 5.ok
1386 else
1387 echo 5.err
1388 endif
1389 if ! [ $dietcurd @i=~ '.+yoho$' ]
1390 echo 6.ok
1391 else
1392 echo 6.err
1393 endif
1394 if ! ! [ $dietcurd @i!~ '.+yoho$' ]
1395 echo 7.ok
1396 else
1397 echo 7.err
1398 endif
1399 if ! [ ! [ $dietcurd @i!~ '.+yoho$' ] ]
1400 echo 8.ok
1401 else
1402 echo 8.err
1403 endif
1404 if [ ! [ ! [ $dietcurd @i!~ '.+yoho$' ] ] ]
1405 echo 9.ok
1406 else
1407 echo 9.err
1408 endif
1409 if ! [ ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
1410 echo 10.err
1411 else
1412 echo 10.ok
1413 endif
1414 if ! ! ! $dietcurd !~ '.+yoho$'
1415 echo 11.err
1416 else
1417 echo 11.ok
1418 endif
1419 if ! ! ! $dietcurd =~ '.+yoho$'
1420 echo 12.ok
1421 else
1422 echo 12.err
1423 endif
1424 if ! [ ! ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
1425 echo 13.ok
1426 else
1427 echo 13.err
1428 endif
1429 set diet=abc curd='^abc$'
1430 if $diet =~ $curd
1431 echo 14.ok
1432 else
1433 echo 14.err
1434 endif
1435 set diet=abc curd='^abcd$'
1436 if $diet !~ $curd
1437 echo 15.ok
1438 else
1439 echo 15.err
1440 endif
1441 __EOT
1443 check behave:if-regex 0 "${MBOX}" '1115671789 95'
1444 else
1445 printf 'behave:if-regex: unsupported, skipped\n'
1448 t_epilog
1451 t_behave_localopts() {
1452 t_prolog t_behave_localopts
1454 # Nestable conditions test
1455 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
1456 define t2 {
1457 echo in: t2
1458 set t2=t2
1459 echo $t2
1461 define t1 {
1462 echo in: t1
1463 set gv1=gv1
1464 localopts on
1465 set lv1=lv1 lv2=lv2
1466 set lv3=lv3
1467 call t2
1468 localopts off
1469 set gv2=gv2
1470 echo $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2
1472 define t0 {
1473 echo in: t0
1474 call t1
1475 echo $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2
1476 echo "$gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2"
1478 account trouble {
1479 echo in: trouble
1480 call t0
1482 call t0
1483 unset gv1 gv2
1484 account trouble
1485 echo active trouble: $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t3
1486 account null
1487 echo active null: $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t3
1490 define ll2 {
1491 localopts $1
1492 set x=2
1493 echo ll2=$x
1495 define ll1 {
1496 wysh set y=$1; shift; eval localopts $y; localopts $1; shift
1497 set x=1
1498 echo ll1.1=$x
1499 call ll2 $1
1500 echo ll1.2=$x
1502 define ll0 {
1503 wysh set y=$1; shift; eval localopts $y; localopts $1; shift
1504 set x=0
1505 echo ll0.1=$x
1506 call ll1 $y "$@"
1507 echo ll0.2=$x
1509 define llx {
1510 echo ----- $1: $2 -> $3 -> $4
1511 echo ll-1.1=$x
1512 eval localopts $1
1513 call ll0 "$@"
1514 echo ll-1.2=$x
1515 unset x
1517 define lly {
1518 call llx 'call off' on on on
1519 call llx 'call off' off on on
1520 call llx 'call off' on off on
1521 call llx 'call off' on off off
1522 localopts call-fixate on
1523 call llx 'call-fixate on' on on on
1524 call llx 'call-fixate on' off on on
1525 call llx 'call-fixate on' on off on
1526 call llx 'call-fixate on' on off off
1527 unset x;localopts call on
1528 call llx 'call on' on on on
1529 call llx 'call on' off on on
1530 call llx 'call on' on off on
1531 call llx 'call on' on off off
1533 call lly
1534 __EOT
1536 check behave:localopts 0 "${MBOX}" '4016155249 1246'
1538 t_epilog
1541 t_behave_local() {
1542 t_prolog t_behave_local
1544 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
1545 define du2 {
1546 echo du2-1 du=$du
1547 local set du=$1
1548 echo du2-2 du=$du
1549 local unset du
1550 echo du2-3 du=$du
1552 define du {
1553 local set du=dudu
1554 echo du-1 du=$du
1555 call du2 du2du2
1556 echo du-2 du=$du
1557 local set nodu
1558 echo du-3 du=$du
1560 define ich {
1561 echo ich-1 du=$du
1562 call du
1563 echo ich-2 du=$du
1565 define wir {
1566 localopts $1
1567 set du=wirwir
1568 echo wir-1 du=$du
1569 call ich
1570 echo wir-2 du=$du
1572 echo ------- global-1 du=$du
1573 call ich
1574 echo ------- global-2 du=$du
1575 set du=global
1576 call ich
1577 echo ------- global-3 du=$du
1578 call wir on
1579 echo ------- global-4 du=$du
1580 call wir off
1581 echo ------- global-5 du=$du
1582 __EOT
1584 check behave:local-1 0 "${MBOX}" '2411598140 641'
1586 t_epilog
1589 t_behave_macro_param_shift() {
1590 t_prolog t_behave_macro_param_shift
1592 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>/dev/null
1593 define t2 {
1594 echo in: t2
1595 echo t2.0 has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1596 localopts on
1597 wysh set ignerr=$1
1598 shift
1599 localopts off
1600 echo t2.1 has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1601 if [ $# > 1 ] || [ $ignerr == '' ]
1602 shift 2
1603 else
1604 ignerr shift 2
1605 endif
1606 echo t2.2:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1607 shift 0
1608 echo t2.3:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1609 if [ $# > 0 ]
1610 shift
1611 endif
1612 echo t2.4:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1614 define t1 {
1615 set errexit
1616 echo in: t1
1617 call t2 1 you get four args
1618 echo t1.1: $?';' ignerr ($ignerr) should not exist
1619 call t2 1 you get 'three args'
1620 echo t1.2: $?';' ignerr ($ignerr) should not exist
1621 call t2 1 you 'get two args'
1622 echo t1.3: $?';' ignerr ($ignerr) should not exist
1623 call t2 1 'you get one arg'
1624 echo t1.4: $?';' ignerr ($ignerr) should not exist
1625 ignerr call t2 '' 'you get one arg'
1626 echo t1.5: $?';' ignerr ($ignerr) should not exist
1628 call t1
1629 __EOT
1631 check behave:macro_param_shift 0 "${MBOX}" '1402489146 1682'
1633 t_epilog
1636 t_behave_addrcodec() {
1637 t_prolog t_behave_addrcodec
1639 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
1640 vput addrcodec res e 1 <doog@def>
1641 echo $?/$^ERRNAME $res
1642 eval vput addrcodec res d $res
1643 echo $?/$^ERRNAME $res
1644 vput addrcodec res e 2 . <doog@def>
1645 echo $?/$^ERRNAME $res
1646 eval vput addrcodec res d $res
1647 echo $?/$^ERRNAME $res
1648 vput addrcodec res e 3 Sauer Dr. <doog@def>
1649 echo $?/$^ERRNAME $res
1650 eval vput addrcodec res d $res
1651 echo $?/$^ERRNAME $res
1652 vput addrcodec res e 3.50 Sauer (Ma) Dr. <doog@def>
1653 echo $?/$^ERRNAME $res
1654 eval vput addrcodec res d $res
1655 echo $?/$^ERRNAME $res
1656 vput addrcodec res e 3.51 Sauer (Ma) "Dr." <doog@def>
1657 echo $?/$^ERRNAME $res
1658 eval vput addrcodec res d $res
1659 echo $?/$^ERRNAME $res
1661 vput addrcodec res +e 4 Sauer (Ma) Dr. <doog@def>
1662 echo $?/$^ERRNAME $res
1663 eval vput addrcodec res d $res
1664 echo $?/$^ERRNAME $res
1665 vput addrcodec res +e 5 Sauer (Ma) Braten Dr. <doog@def>
1666 echo $?/$^ERRNAME $res
1667 eval vput addrcodec res d $res
1668 echo $?/$^ERRNAME $res
1669 vput addrcodec res +e 6 Sauer (Ma) Braten Dr. (Heu) <doog@def>
1670 echo $?/$^ERRNAME $res
1671 eval vput addrcodec res d $res
1672 echo $?/$^ERRNAME $res
1673 vput addrcodec res +e 7 Sauer (Ma) Braten Dr. (Heu) <doog@def> (bu)
1674 echo $?/$^ERRNAME $res
1675 eval vput addrcodec res d $res
1676 echo $?/$^ERRNAME $res
1677 vput addrcodec res +e 8 \
1678 Dr. Sauer (Ma) Braten Dr. (Heu) <doog@def> (bu) Boom. Boom
1679 echo $?/$^ERRNAME $res
1680 eval vput addrcodec res d $res
1681 echo $?/$^ERRNAME $res
1682 vput addrcodec res +e 9 Dr.Sauer(Ma)Braten Dr. (Heu) <doog@def>
1683 echo $?/$^ERRNAME $res
1684 eval vput addrcodec res d $res
1685 echo $?/$^ERRNAME $res
1686 vput addrcodec res +e 10 (Ma)Braten Dr. (Heu) <doog@def>
1687 echo $?/$^ERRNAME $res
1688 eval vput addrcodec res d $res
1689 echo $?/$^ERRNAME $res
1690 vput addrcodec res +e 11 (Ma)Braten Dr"." (Heu) <doog@def>
1691 echo $?/$^ERRNAME $res
1692 eval vput addrcodec res d $res
1693 echo $?/$^ERRNAME $res
1694 vput addrcodec res +e 12 Dr. Sauer (Ma) Braten Dr. (u) <doog@def>
1695 echo $?/$^ERRNAME $res
1696 eval vput addrcodec res d $res
1697 echo $?/$^ERRNAME $res
1698 vput addrcodec res +e 13(Ma)Braten Dr. (Heu) <doog@def>
1699 echo $?/$^ERRNAME $res
1700 eval vput addrcodec res d $res
1701 echo $?/$^ERRNAME $res
1702 vput addrcodec res +e 14 Hey, Du <doog@def> Wie() findet Dr. das? ()
1703 echo $?/$^ERRNAME $res
1704 eval vput addrcodec res d $res
1705 echo $?/$^ERRNAME $res
1706 vput addrcodec res +e 15 \
1707 Hey, Du <doog@def> Wie() findet "" Dr. "" das? ()
1708 echo $?/$^ERRNAME $res
1709 eval vput addrcodec res d $res
1710 echo $?/$^ERRNAME $res
1711 vput addrcodec res +e 16 \
1712 "Hey," "Du" <doog@def> "Wie()" findet "" Dr. "" das? ()
1713 echo $?/$^ERRNAME $res
1714 eval vput addrcodec res d $res
1715 echo $?/$^ERRNAME $res
1716 vput addrcodec res +e 17 \
1717 "Hey" Du <doog@def> "Wie() findet " " Dr. """ das? ()
1718 echo $?/$^ERRNAME $res
1719 eval vput addrcodec res d $res
1720 echo $?/$^ERRNAME $res
1721 vput addrcodec res +e 18 \
1722 <doog@def> "Hey" Du "Wie() findet " " Dr. """ das? ()
1723 echo $?/$^ERRNAME $res
1724 eval vput addrcodec res d $res
1725 echo $?/$^ERRNAME $res
1726 vput addrcodec res +e 19 Hey\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1727 echo $?/$^ERRNAME $res
1728 eval vput addrcodec res d $res
1729 echo $?/$^ERRNAME $res
1731 vput addrcodec res ++e 20 Hey\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1732 echo $?/$^ERRNAME $res
1733 vput addrcodec res ++e 21 Hey\,\"" <doog@def> "Wie()" findet \" Dr. \" das?
1734 echo $?/$^ERRNAME $res
1735 eval vput addrcodec res d $res
1736 echo $?/$^ERRNAME $res
1738 vput addrcodec res +++e 22 Hey\\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1739 echo $?/$^ERRNAME $res
1740 eval vput addrcodec res d $res
1741 echo $?/$^ERRNAME $res
1743 vput addrcodec res s \
1744 "23 Hey\\,\\\" \"Wie" () "\" findet \\\" Dr. \\\" das?" <doog@def>
1745 echo $?/$^ERRNAME $res
1747 # Fix for [f3852f88]
1748 vput addrcodec res ++e <from2@exam.ple> 100 (comment) "Quot(e)d"
1749 echo $?/$^ERRNAME $res
1750 eval vput addrcodec res d $res
1751 echo $?/$^ERRNAME $res
1752 vput addrcodec res e <from2@exam.ple> 100 (comment) "Quot(e)d"
1753 echo $?/$^ERRNAME $res
1754 eval vput addrcodec res d $res
1755 echo $?/$^ERRNAME $res
1756 __EOT
1758 check behave:addrcodec-1 0 "${MBOX}" '1047317989 2612'
1760 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
1761 mlist isa1@list
1762 mlsubscribe isa2@list
1764 vput addrcodec res skin Hey\\,\" <isa0@list> "Wie()" find \" Dr. \" das?
1765 echo $?/$^ERRNAME $res
1766 vput addrcodec res skinlist Hey\\,\" <isa0@list> "Wie()" find \" Dr. \" das?
1767 echo $?/$^ERRNAME $res
1768 vput addrcodec res skin Hey\\,\" <isa1@list> "Wie()" find \" Dr. \" das?
1769 echo $?/$^ERRNAME $res
1770 vput addrcodec res skinlist Hey\\,\" <isa1@list> "Wie()" find \" Dr. \" das?
1771 echo $?/$^ERRNAME $res
1772 vput addrcodec res skin Hey\\,\" <isa2@list> "Wie()" find \" Dr. \" das?
1773 echo $?/$^ERRNAME $res
1774 vput addrcodec res skinlist Hey\\,\" <isa2@list> "Wie()" find \" Dr. \" das?
1775 echo $?/$^ERRNAME $res
1776 __EOT
1778 check behave:addrcodec-2 0 "${MBOX}" '1391779299 104'
1780 if have_feat idna; then
1781 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} ${ADDARG_UNI} > "${MBOX}" 2>&1
1782 vput addrcodec res e (heu) <du@blödiän> "stroh" du
1783 echo $?/$^ERRNAME $res
1784 eval vput addrcodec res d $res
1785 echo $?/$^ERRNAME $res
1786 vput addrcodec res e <du@blödiän> du
1787 echo $?/$^ERRNAME $res
1788 eval vput addrcodec res d $res
1789 echo $?/$^ERRNAME $res
1790 vput addrcodec res e du <du@blödiän>
1791 echo $?/$^ERRNAME $res
1792 eval vput addrcodec res d $res
1793 echo $?/$^ERRNAME $res
1794 vput addrcodec res e <du@blödiän>
1795 echo $?/$^ERRNAME $res
1796 eval vput addrcodec res d $res
1797 echo $?/$^ERRNAME $res
1798 vput addrcodec res e du@blödiän
1799 echo $?/$^ERRNAME $res
1800 eval vput addrcodec res d $res
1801 echo $?/$^ERRNAME $res
1802 __EOT
1804 check behave:addrcodec-idna 0 "${MBOX}" '498775983 326'
1805 else
1806 printf 'behave:addrcodec-idna: unsupported, skipped\n'
1809 t_epilog
1812 t_behave_vexpr() {
1813 t_prolog t_behave_vexpr
1815 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>/dev/null
1816 echo ' #0.0'
1817 vput vexpr res = 9223372036854775807
1818 echo $?/$^ERRNAME $res
1819 vput vexpr res = 9223372036854775808
1820 echo $?/$^ERRNAME $res
1821 vput vexpr res = u9223372036854775808
1822 echo $?/$^ERRNAME $res
1823 vput vexpr res @= 9223372036854775808
1824 echo $?/$^ERRNAME $res
1825 vput vexpr res = -9223372036854775808
1826 echo $?/$^ERRNAME $res
1827 vput vexpr res = -9223372036854775809
1828 echo $?/$^ERRNAME $res
1829 vput vexpr res @= -9223372036854775809
1830 echo $?/$^ERRNAME $res
1831 vput vexpr res = U9223372036854775809
1832 echo $?/$^ERRNAME $res
1833 echo ' #0.1'
1834 vput vexpr res = \
1835 0b0111111111111111111111111111111111111111111111111111111111111111
1836 echo $?/$^ERRNAME $res
1837 vput vexpr res = \
1838 S0b1000000000000000000000000000000000000000000000000000000000000000
1839 echo $?/$^ERRNAME $res
1840 vput vexpr res @= \
1841 S0b1000000000000000000000000000000000000000000000000000000000000000
1842 echo $?/$^ERRNAME $res
1843 vput vexpr res = \
1844 U0b1000000000000000000000000000000000000000000000000000000000000000
1845 echo $?/$^ERRNAME $res
1846 vput vexpr res = \
1847 0b1000000000000000000000000000000000000000000000000000000000000000
1848 echo $?/$^ERRNAME $res
1849 vput vexpr res @= \
1850 0b1000000000000000000000000000000000000000000000000000000000000000
1851 echo $?/$^ERRNAME $res
1852 vput vexpr res = \
1853 -0b1000000000000000000000000000000000000000000000000000000000000000
1854 echo $?/$^ERRNAME $res
1855 vput vexpr res = \
1856 S0b1000000000000000000000000000000000000000000000000000000000000001
1857 echo $?/$^ERRNAME $res
1858 vput vexpr res @= \
1859 S0b1000000000000000000000000000000000000000000000000000000000000001
1860 echo $?/$^ERRNAME $res
1861 vput vexpr res @= \
1862 -0b1000000000000000000000000000000000000000000000000000000000000001
1863 echo $?/$^ERRNAME $res
1864 vput vexpr res = \
1865 U0b1000000000000000000000000000000000000000000000000000000000000001
1866 echo $?/$^ERRNAME $res
1867 echo ' #0.2'
1868 vput vexpr res = 0777777777777777777777
1869 echo $?/$^ERRNAME $res
1870 vput vexpr res = S01000000000000000000000
1871 echo $?/$^ERRNAME $res
1872 vput vexpr res @= S01000000000000000000000
1873 echo $?/$^ERRNAME $res
1874 vput vexpr res = U01000000000000000000000
1875 echo $?/$^ERRNAME $res
1876 vput vexpr res = 01000000000000000000000
1877 echo $?/$^ERRNAME $res
1878 vput vexpr res @= 01000000000000000000000
1879 echo $?/$^ERRNAME $res
1880 vput vexpr res = -01000000000000000000000
1881 echo $?/$^ERRNAME $res
1882 vput vexpr res = S01000000000000000000001
1883 echo $?/$^ERRNAME $res
1884 vput vexpr res @= S01000000000000000000001
1885 echo $?/$^ERRNAME $res
1886 vput vexpr res @= -01000000000000000000001
1887 echo $?/$^ERRNAME $res
1888 vput vexpr res = U01000000000000000000001
1889 echo $?/$^ERRNAME $res
1890 echo ' #0.3'
1891 vput vexpr res = 0x7FFFFFFFFFFFFFFF
1892 echo $?/$^ERRNAME $res
1893 vput vexpr res = S0x8000000000000000
1894 echo $?/$^ERRNAME $res
1895 vput vexpr res @= S0x8000000000000000
1896 echo $?/$^ERRNAME $res
1897 vput vexpr res = U0x8000000000000000
1898 echo $?/$^ERRNAME $res
1899 vput vexpr res = 0x8000000000000000
1900 echo $?/$^ERRNAME $res
1901 vput vexpr res @= 0x8000000000000000
1902 echo $?/$^ERRNAME $res
1903 vput vexpr res = -0x8000000000000000
1904 echo $?/$^ERRNAME $res
1905 vput vexpr res = S0x8000000000000001
1906 echo $?/$^ERRNAME $res
1907 vput vexpr res @= S0x8000000000000001
1908 echo $?/$^ERRNAME $res
1909 vput vexpr res @= -0x8000000000000001
1910 echo $?/$^ERRNAME $res
1911 vput vexpr res = u0x8000000000000001
1912 echo $?/$^ERRNAME $res
1913 echo ' #1'
1914 vput vexpr res ~ 0
1915 echo $?/$^ERRNAME $res
1916 vput vexpr res ~ 1
1917 echo $?/$^ERRNAME $res
1918 vput vexpr res ~ -1
1919 echo $?/$^ERRNAME $res
1920 echo ' #2'
1921 vput vexpr res + 0 0
1922 echo $?/$^ERRNAME $res
1923 vput vexpr res + 0 1
1924 echo $?/$^ERRNAME $res
1925 vput vexpr res + 1 1
1926 echo $?/$^ERRNAME $res
1927 echo ' #3'
1928 vput vexpr res + 9223372036854775807 0
1929 echo $?/$^ERRNAME $res
1930 vput vexpr res + 9223372036854775807 1
1931 echo $?/$^ERRNAME $res
1932 vput vexpr res @+ 9223372036854775807 1
1933 echo $?/$^ERRNAME $res
1934 vput vexpr res + 0 9223372036854775807
1935 echo $?/$^ERRNAME $res
1936 vput vexpr res + 1 9223372036854775807
1937 echo $?/$^ERRNAME $res
1938 vput vexpr res @+ 1 9223372036854775807
1939 echo $?/$^ERRNAME $res
1940 echo ' #4'
1941 vput vexpr res + -9223372036854775808 0
1942 echo $?/$^ERRNAME $res
1943 vput vexpr res + -9223372036854775808 -1
1944 echo $?/$^ERRNAME $res
1945 vput vexpr res @+ -9223372036854775808 -1
1946 echo $?/$^ERRNAME $res
1947 vput vexpr res + 0 -9223372036854775808
1948 echo $?/$^ERRNAME $res
1949 vput vexpr res + -1 -9223372036854775808
1950 echo $?/$^ERRNAME $res
1951 vput vexpr res @+ -1 -9223372036854775808
1952 echo $?/$^ERRNAME $res
1953 echo ' #5'
1954 vput vexpr res - 0 0
1955 echo $?/$^ERRNAME $res
1956 vput vexpr res - 0 1
1957 echo $?/$^ERRNAME $res
1958 vput vexpr res - 1 1
1959 echo $?/$^ERRNAME $res
1960 echo ' #6'
1961 vput vexpr res - 9223372036854775807 0
1962 echo $?/$^ERRNAME $res
1963 vput vexpr res - 9223372036854775807 -1
1964 echo $?/$^ERRNAME $res
1965 vput vexpr res @- 9223372036854775807 -1
1966 echo $?/$^ERRNAME $res
1967 vput vexpr res - 0 9223372036854775807
1968 echo $?/$^ERRNAME $res
1969 vput vexpr res - -1 9223372036854775807
1970 echo $?/$^ERRNAME $res
1971 vput vexpr res - -2 9223372036854775807
1972 echo $?/$^ERRNAME $res
1973 vput vexpr res @- -2 9223372036854775807
1974 echo $?/$^ERRNAME $res
1975 echo ' #7'
1976 vput vexpr res - -9223372036854775808 +0
1977 echo $?/$^ERRNAME $res
1978 vput vexpr res - -9223372036854775808 +1
1979 echo $?/$^ERRNAME $res
1980 vput vexpr res @- -9223372036854775808 +1
1981 echo $?/$^ERRNAME $res
1982 vput vexpr res - 0 -9223372036854775808
1983 echo $?/$^ERRNAME $res
1984 vput vexpr res - +1 -9223372036854775808
1985 echo $?/$^ERRNAME $res
1986 vput vexpr res @- +1 -9223372036854775808
1987 echo $?/$^ERRNAME $res
1988 echo ' #8'
1989 vput vexpr res + -13 -2
1990 echo $?/$^ERRNAME $res
1991 vput vexpr res - 0 0
1992 echo $?/$^ERRNAME $res
1993 vput vexpr res - 0 1
1994 echo $?/$^ERRNAME $res
1995 vput vexpr res - 1 1
1996 echo $?/$^ERRNAME $res
1997 vput vexpr res - -13 -2
1998 echo $?/$^ERRNAME $res
1999 echo ' #9'
2000 vput vexpr res * 0 0
2001 echo $?/$^ERRNAME $res
2002 vput vexpr res * 0 1
2003 echo $?/$^ERRNAME $res
2004 vput vexpr res * 1 1
2005 echo $?/$^ERRNAME $res
2006 vput vexpr res * -13 -2
2007 echo $?/$^ERRNAME $res
2008 echo ' #10'
2009 vput vexpr res / 0 0
2010 echo $?/$^ERRNAME $res
2011 vput vexpr res / 0 1
2012 echo $?/$^ERRNAME $res
2013 vput vexpr res / 1 1
2014 echo $?/$^ERRNAME $res
2015 vput vexpr res / -13 -2
2016 echo $?/$^ERRNAME $res
2017 echo ' #11'
2018 vput vexpr res % 0 0
2019 echo $?/$^ERRNAME $res
2020 vput vexpr res % 0 1
2021 echo $?/$^ERRNAME $res
2022 vput vexpr res % 1 1
2023 echo $?/$^ERRNAME $res
2024 vput vexpr res % -13 -2
2025 echo $?/$^ERRNAME $res
2026 __EOT
2028 check behave:vexpr-numeric 0 "${MBOX}" '960821755 1962'
2030 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
2031 vput vexpr res find 'bananarama' 'nana'
2032 echo $?/$^ERRNAME :$res:
2033 vput vexpr res find 'bananarama' 'bana'
2034 echo $?/$^ERRNAME :$res:
2035 vput vexpr res find 'bananarama' 'Bana'
2036 echo $?/$^ERRNAME :$res:
2037 vput vexpr res find 'bananarama' 'rama'
2038 echo $?/$^ERRNAME :$res:
2039 echo ' #1'
2040 vput vexpr res ifind 'bananarama' 'nana'
2041 echo $?/$^ERRNAME :$res:
2042 vput vexpr res ifind 'bananarama' 'bana'
2043 echo $?/$^ERRNAME :$res:
2044 vput vexpr res ifind 'bananarama' 'Bana'
2045 echo $?/$^ERRNAME :$res:
2046 vput vexpr res ifind 'bananarama' 'rama'
2047 echo $?/$^ERRNAME :$res:
2048 echo ' #2'
2049 vput vexpr res substring 'bananarama' 1
2050 echo $?/$^ERRNAME :$res:
2051 vput vexpr res substring 'bananarama' 3
2052 echo $?/$^ERRNAME :$res:
2053 vput vexpr res substring 'bananarama' 5
2054 echo $?/$^ERRNAME :$res:
2055 vput vexpr res substring 'bananarama' 7
2056 echo $?/$^ERRNAME :$res:
2057 vput vexpr res substring 'bananarama' 9
2058 echo $?/$^ERRNAME :$res:
2059 vput vexpr res substring 'bananarama' 10
2060 echo $?/$^ERRNAME :$res:
2061 vput vexpr res substring 'bananarama' 1 3
2062 echo $?/$^ERRNAME :$res:
2063 vput vexpr res substring 'bananarama' 3 3
2064 echo $?/$^ERRNAME :$res:
2065 vput vexpr res substring 'bananarama' 5 3
2066 echo $?/$^ERRNAME :$res:
2067 vput vexpr res substring 'bananarama' 7 3
2068 echo $?/$^ERRNAME :$res:
2069 vput vexpr res substring 'bananarama' 9 3
2070 echo $?/$^ERRNAME :$res:
2071 vput vexpr res substring 'bananarama' 10 3
2072 echo $?/$^ERRNAME :$res:
2073 echo ' #3'
2074 vput vexpr res substring 'bananarama' -1
2075 echo $?/$^ERRNAME :$res:
2076 vput vexpr res substring 'bananarama' -3
2077 echo $?/$^ERRNAME :$res:
2078 vput vexpr res substring 'bananarama' -5
2079 echo $?/$^ERRNAME :$res:
2080 vput vexpr res substring 'bananarama' -7
2081 echo $?/$^ERRNAME :$res:
2082 vput vexpr res substring 'bananarama' -9
2083 echo $?/$^ERRNAME :$res:
2084 vput vexpr res substring 'bananarama' -10
2085 echo $?/$^ERRNAME :$res:
2086 vput vexpr res substring 'bananarama' 1 -3
2087 echo $?/$^ERRNAME :$res:
2088 vput vexpr res substring 'bananarama' 3 -3
2089 echo $?/$^ERRNAME :$res:
2090 vput vexpr res substring 'bananarama' 5 -3
2091 echo $?/$^ERRNAME :$res:
2092 vput vexpr res substring 'bananarama' 7 -3
2093 echo $?/$^ERRNAME :$res:
2094 vput vexpr res substring 'bananarama' 9 -3
2095 echo $?/$^ERRNAME :$res:
2096 vput vexpr res substring 'bananarama' 10 -3
2097 echo $?/$^ERRNAME :$res:
2098 echo ' #4'
2099 vput vexpr res trim 'Cocoon Cocoon'
2100 echo $?/$^ERRNAME :$res:
2101 vput vexpr res trim ' Cocoon Cocoon '
2102 echo $?/$^ERRNAME :$res:
2103 vput vexpr res trim-front 'Cocoon Cocoon'
2104 echo $?/$^ERRNAME :$res:
2105 vput vexpr res trim-front ' Cocoon Cocoon '
2106 echo $?/$^ERRNAME :$res:
2107 vput vexpr res trim-end 'Cocoon Cocoon'
2108 echo $?/$^ERRNAME :$res:
2109 vput vexpr res trim-end ' Cocoon Cocoon '
2110 echo $?/$^ERRNAME :$res:
2111 __EOT
2113 check behave:vexpr-string 0 "${MBOX}" '3182004322 601'
2115 if have_feat regex; then
2116 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
2117 vput vexpr res regex 'bananarama' 'nana'
2118 echo $?/$^ERRNAME :$res:
2119 vput vexpr res regex 'bananarama' 'bana'
2120 echo $?/$^ERRNAME :$res:
2121 vput vexpr res regex 'bananarama' 'Bana'
2122 echo $?/$^ERRNAME :$res:
2123 vput vexpr res regex 'bananarama' 'rama'
2124 echo $?/$^ERRNAME :$res:
2125 echo ' #1'
2126 vput vexpr res iregex 'bananarama' 'nana'
2127 echo $?/$^ERRNAME :$res:
2128 vput vexpr res iregex 'bananarama' 'bana'
2129 echo $?/$^ERRNAME :$res:
2130 vput vexpr res iregex 'bananarama' 'Bana'
2131 echo $?/$^ERRNAME :$res:
2132 vput vexpr res iregex 'bananarama' 'rama'
2133 echo $?/$^ERRNAME :$res:
2134 echo ' #2'
2135 vput vexpr res regex 'bananarama' '(.*)nana(.*)' '\${1}a\${0}u{\$2}'
2136 echo $?/$^ERRNAME :$res:
2137 vput vexpr res regex 'bananarama' '(.*)bana(.*)' '\${1}a\${0}u\$2'
2138 echo $?/$^ERRNAME :$res:
2139 vput vexpr res regex 'bananarama' 'Bana(.+)' '\$1\$0'
2140 echo $?/$^ERRNAME :$res:
2141 vput vexpr res regex 'bananarama' '(.+)rama' '\$1\$0'
2142 echo $?/$^ERRNAME :$res:
2143 echo ' #3'
2144 vput vexpr res iregex 'bananarama' '(.*)nana(.*)' '\${1}a\${0}u{\$2}'
2145 echo $?/$^ERRNAME :$res:
2146 vput vexpr res iregex 'bananarama' '(.*)bana(.*)' '\${1}a\${0}u\$2'
2147 echo $?/$^ERRNAME :$res:
2148 vput vexpr res iregex 'bananarama' 'Bana(.+)' '\$1\$0'
2149 echo $?/$^ERRNAME :$res:
2150 vput vexpr res iregex 'bananarama' '(.+)rama' '\$1\$0'
2151 echo $?/$^ERRNAME :$res:
2152 echo ' #4'
2153 __EOT
2155 check behave:vexpr-regex 0 "${MBOX}" '3270360157 311'
2156 else
2157 printf 'behave:vexpr-regex: unsupported, skipped\n'
2160 t_epilog
2163 t_behave_call_ret() {
2164 t_prolog t_behave_call_ret
2166 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Snomemdebug > "${MBOX}" 2>&1
2167 define w1 {
2168 echon ">$1 "
2169 vput vexpr i + $1 1
2170 if [ $i -le 42 ]
2171 vput vexpr j '&' $i 7
2172 if [ $j -eq 7 ]
2173 echo .
2175 call w1 $i
2176 wysh set i=$? k=$!
2177 vput vexpr j '&' $i 7
2178 echon "<$1/$i/$k "
2179 if [ $j -eq 7 ]
2180 echo .
2182 else
2183 echo ! The end for $1
2185 return $1
2187 # Transport $?/$! up the call chain
2188 define w2 {
2189 echon ">$1 "
2190 vput vexpr i + $1 1
2191 if [ $1 -lt 42 ]
2192 call w2 $i
2193 wysh set i=$? j=$! k=$^ERRNAME
2194 echon "<$1/$i/$k "
2195 return $i $j
2196 else
2197 echo ! The end for $1
2198 return $i $^ERR-BUSY
2200 echoerr au
2202 # Up and down it goes
2203 define w3 {
2204 echon ">$1/$2 "
2205 vput vexpr i + $1 1
2206 if [ $1 -lt 42 ]
2207 call w3 $i $2
2208 wysh set i=$? j=$!
2209 vput vexpr k - $1 $2
2210 if [ $k -eq 21 ]
2211 vput vexpr i + $1 1
2212 vput vexpr j + $2 1
2213 echo "# <$i/$j> .. "
2214 call w3 $i $j
2215 wysh set i=$? j=$!
2217 eval echon "<\$1=\$i/\$^ERRNAME-$j "
2218 return $i $j
2219 else
2220 echo ! The end for $1=$i/$2
2221 if [ "$2" != "" ]
2222 return $i $^ERR-DOM
2223 else
2224 return $i $^ERR-BUSY
2227 echoerr au
2230 call w1 0; echo ?=$? !=$!; echo -----;
2231 call w2 0; echo ?=$? !=$^ERRNAME; echo -----;
2232 call w3 0 1; echo ?=$? !=$^ERRNAME; echo -----;
2233 __EOT
2235 check behave:call_ret 0 "${MBOX}" '1572045517 5922'
2237 t_epilog
2240 t_behave_xcall() {
2241 t_prolog t_behave_xcall
2243 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Snomemdebug > "${MBOX}" 2>&1
2244 define work {
2245 echon "$1 "
2246 vput vexpr i + $1 1
2247 if [ $i -le 1111 ]
2248 vput vexpr j '&' $i 7
2249 if [ $j -eq 7 ]
2250 echo .
2252 \xcall work $i $2
2254 echo ! The end for $1/$2
2255 if [ "$2" != "" ]
2256 return $i $^ERR-BUSY
2259 define xwork {
2260 \xcall work 0 $2
2262 call work 0
2263 echo ?=$? !=$!
2264 call xwork
2265 echo ?=$? !=$!
2266 xcall xwork
2267 echo ?=$? !=$^ERRNAME
2269 call work 0 yes
2270 echo ?=$? !=$^ERRNAME
2271 call xwork 0 yes
2272 echo ?=$? !=$^ERRNAME
2273 __EOT
2275 check behave:xcall-1 0 "${MBOX}" '2401702082 23801'
2279 ${cat} <<- '__EOT' > "${BODY}"
2280 define __w {
2281 echon "$1 "
2282 vput vexpr i + $1 1
2283 if [ $i -le 111 ]
2284 vput vexpr j '&' $i 7
2285 if [ $j -eq 7 ]
2286 echo .
2288 \xcall __w $i $2
2290 echo ! The end for $1
2291 if [ $2 -eq 0 ]
2292 nonexistingcommand
2293 echo would be err with errexit
2294 return
2296 echo calling exit
2297 exit
2299 define work {
2300 echo eins
2301 call __w 0 0
2302 echo zwei, ?=$? !=$!
2303 localopts yes; set errexit
2304 ignerr call __w 0 0
2305 echo drei, ?=$? !=$^ERRNAME
2306 call __w 0 $1
2307 echo vier, ?=$? !=$^ERRNAME, this is an error
2309 ignerr call work 0
2310 echo outer 1, ?=$? !=$^ERRNAME
2311 xxxign call work 0
2312 echo outer 2, ?=$? !=$^ERRNAME, could be error if xxxign non-empty
2313 call work 1
2314 echo outer 3, ?=$? !=$^ERRNAME
2315 echo this is definitely an error
2316 __EOT
2318 < "${BODY}" ${MAILX} ${ARGS} -X'commandalias xxxign ignerr' -Snomemdebug \
2319 > "${MBOX}" 2>&1
2320 check behave:xcall-2 0 "${MBOX}" '3900716531 4200'
2322 < "${BODY}" ${MAILX} ${ARGS} -X'commandalias xxxign " "' -Snomemdebug \
2323 > "${MBOX}" 2>&1
2324 check behave:xcall-3 1 "${MBOX}" '1006776201 2799'
2326 t_epilog
2329 t_behave_vpospar() {
2330 t_prolog t_behave_vpospar
2332 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
2333 vpospar set hey, "'you ", world!
2334 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2335 vput vpospar x quote; echo x<$x>
2336 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2337 vput vpospar y quote;echo y<$y>
2338 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2339 eval vpospar set ${y};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2340 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2342 define infun2 {
2343 echo infun2:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2344 vput vpospar z quote;echo infun2:z<$z>
2347 define infun {
2348 echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2349 vput vpospar y quote;echo infun:y<$y>
2350 eval vpospar set ${x};echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2351 vpospar clear;echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2352 eval call infun2 $x
2353 echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2354 eval vpospar set ${y};echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2357 call infun This "in a" fun
2358 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2359 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2360 __EOT
2361 check behave:vpospar-1 0 "${MBOX}" '155175639 866'
2364 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
2365 set ifs=\'
2366 echo ifs<$ifs> ifs-ws<$ifs-ws>
2367 vpospar set hey, "'you ", world!
2368 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2369 vput vpospar x quote; echo x<$x>
2370 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2371 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2373 set ifs=,
2374 echo ifs<$ifs> ifs-ws<$ifs-ws>
2375 vpospar set hey, "'you ", world!
2376 unset ifs;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2377 set ifs=,
2378 vput vpospar x quote; echo x<$x>
2379 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2380 eval vpospar set ${x};\
2381 unset ifs;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2383 wysh set ifs=$',\t'
2384 echo ifs<$ifs> ifs-ws<$ifs-ws>
2385 vpospar set hey, "'you ", world!
2386 unset ifs; echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2387 wysh set ifs=$',\t'
2388 vput vpospar x quote; echo x<$x>
2389 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2390 eval vpospar set ${x};\
2391 unset ifs;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2392 __EOT
2393 check behave:vpospar-ifs 0 "${MBOX}" '2015927702 706'
2395 t_epilog
2398 t_behave_atxplode() {
2399 t_prolog t_behave_atxplode
2400 TRAP_EXIT_ADDONS="./.t*"
2402 ${cat} > ./.t.sh <<- '___'; ${cat} > ./.t.rc <<- '___'
2403 x() { echo $#; }
2404 xxx() {
2405 printf " (1/$#: <$1>)"
2406 shift
2407 if [ $# -gt 0 ]; then
2408 xxx "$@"
2409 else
2410 echo
2413 yyy() {
2414 eval "$@ ' ball"
2416 set --
2417 x "$@"
2418 x "$@"''
2419 x " $@"
2420 x "$@ "
2421 printf yyy;yyy 'xxx' "b\$'\t'u ' "
2422 printf xxx;xxx arg ,b u.
2423 printf xxx;xxx arg , .
2424 printf xxx;xxx arg ,ball.
2426 define x {
2427 echo $#
2429 define xxx {
2430 echon " (1/$#: <$1>)"
2431 shift
2432 if [ $# -gt 0 ]
2433 \xcall xxx "$@"
2434 endif
2435 echo
2437 define yyy {
2438 eval "$@ ' ball"
2440 vpospar set
2441 call x "$@"
2442 call x "$@"''
2443 call x " $@"
2444 call x "$@ "
2445 echon yyy;call yyy '\call xxx' "b\$'\t'u ' "
2446 echon xxx;call xxx arg ,b u.
2447 echon xxx;call xxx arg , .
2448 echon xxx;call xxx arg ,ball.
2451 ${MAILX} ${ARGS} -X'source ./.t.rc' -Xx > "${MBOX}" 2>&1
2452 check behave:atxplode-1 0 "${MBOX}" '41566293 164'
2454 #${SHELL} ./.t.sh > ./.tshout 2>&1
2455 #check behave:atxplode:disproof-1 0 ./.tshout '41566293 164'
2457 t_epilog
2460 t_behave_read() {
2461 t_prolog t_behave_read
2462 TRAP_EXIT_ADDONS="./.t*"
2464 ${cat} <<- '__EOT' > .tin
2465 hey1, "'you ", world!
2466 hey2, "'you ", bugs bunny!
2467 hey3, "'you ",
2468 hey4, "'you "
2469 __EOT
2471 ${cat} <<- '__EOT' |\
2472 ${MAILX} ${ARGS} -X'readctl create ./.tin' > "${MBOX}" 2>&1
2473 read a b c
2474 echo $?/$^ERRNAME / <$a><$b><$c>
2475 read a b c
2476 echo $?/$^ERRNAME / <$a><$b><$c>
2477 read a b c
2478 echo $?/$^ERRNAME / <$a><$b><$c>
2479 read a b c
2480 echo $?/$^ERRNAME / <$a><$b><$c>
2481 unset a b c;read a b c
2482 echo $?/$^ERRNAME / <$a><$b><$c>
2483 readctl remove ./.tin;echo readctl remove:$?/$^ERRNAME
2484 __EOT
2485 check behave:read-1 0 "${MBOX}" '1527910147 173'
2487 ${cat} <<- '__EOT' > .tin2
2488 hey2.0,:"'you ",:world!:mars.:
2489 hey2.1,:"'you ",:world!
2490 hey2.2,:"'you ",:bugs bunny!
2491 hey2.3,:"'you ",:
2492 hey2.4,:"'you ":
2494 __EOT
2496 ${cat} <<- '__EOT' |\
2497 6< .tin2 ${MAILX} ${ARGS} -X 'readctl create 6' > "${MBOX}" 2>&1
2498 set ifs=:
2499 read a b c
2500 echo $?/$^ERRNAME / <$a><$b><$c>
2501 read a b c
2502 echo $?/$^ERRNAME / <$a><$b><$c>
2503 read a b c
2504 echo $?/$^ERRNAME / <$a><$b><$c>
2505 read a b c
2506 echo $?/$^ERRNAME / <$a><$b><$c>
2507 read a b c
2508 echo $?/$^ERRNAME / <$a><$b><$c>
2509 read a b c
2510 echo $?/$^ERRNAME / <$a><$b><$c>
2511 unset a b c;read a b c
2512 echo $?/$^ERRNAME / <$a><$b><$c>
2513 read a b c
2514 echo $?/$^ERRNAME / <$a><$b><$c>
2515 readctl remove 6;echo readctl remove:$?/$^ERRNAME
2516 __EOT
2517 check behave:read-ifs 0 "${MBOX}" '890153490 298'
2519 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
2520 readctl create .tin
2521 readall d; echo $?/$^ERRNAME / <$d>
2522 wysh set d;readall d;echo $?/$^ERRNAME / <$d>
2523 readctl create .tin2
2524 readall d; echo $?/$^ERRNAME / <$d>
2525 wysh set d;readall d;echo $?/$^ERRNAME / <$d>
2526 readctl remove .tin;echo $?/$^ERRNAME;\
2527 readctl remove .tin2;echo $?/$^ERRNAME
2528 __EOT
2529 check behave:readall 0 "${MBOX}" '860434889 333'
2531 t_epilog
2534 t_behave_mbox() {
2535 t_prolog t_behave_mbox
2536 TRAP_EXIT_ADDONS="./.t*"
2540 while [ ${i} -lt 112 ]; do
2541 printf 'm file://%s\n~s Subject %s\nHello %s!\n~.\n' \
2542 "${MBOX}" "${i}" "${i}"
2543 i=`add ${i} 1`
2544 done
2545 ) | ${MAILX} ${ARGS} > .tall 2>&1
2546 check behave:mbox-1 0 "${MBOX}" '1140119864 13780'
2547 check behave:mbox-1-outerr - ./.tall '4294967295 0' # empty file
2549 printf 'File "%s"\ncopy * "%s"\nFile "%s"\nfrom*' "${MBOX}" .tmbox1 .tmbox1 |
2550 ${MAILX} ${ARGS} -Sshowlast > .tall 2>&1
2551 check behave:mbox-2 0 .tall '2739893312 9103'
2553 printf 'File "%s"\ncopy * "file://%s"\nFile "file://%s"\nfrom*' \
2554 "${MBOX}" .tmbox2 .tmbox2 | ${MAILX} ${ARGS} -Sshowlast > .tall 2>&1
2555 check behave:mbox-3 0 .tall '1702194178 9110'
2557 # only the odd (even)
2559 printf 'File "file://%s"\ncopy ' .tmbox2
2561 while [ ${i} -lt 112 ]; do
2562 j=`modulo ${i} 2`
2563 [ ${j} -eq 1 ] && printf '%s ' "${i}"
2564 i=`add ${i} 1`
2565 done
2566 printf 'file://%s\nFile "file://%s"\nfrom*' .tmbox3 .tmbox3
2567 ) | ${MAILX} ${ARGS} -Sshowlast > .tall 2>&1
2568 check behave:mbox-4 0 .tmbox3 '631132924 6890'
2569 check behave:mbox-5 - .tall '2960975049 4573'
2570 # ...
2572 printf 'file "file://%s"\nmove ' .tmbox2
2574 while [ ${i} -lt 112 ]; do
2575 j=`modulo ${i} 2`
2576 [ ${j} -eq 0 ] && [ ${i} -ne 0 ] && printf '%s ' "${i}"
2577 i=`add ${i} 1`
2578 done
2579 printf 'file://%s\nFile "file://%s"\nfrom*\nFile "file://%s"\nfrom*' \
2580 .tmbox3 .tmbox3 .tmbox2
2581 ) | ${MAILX} ${ARGS} -Sshowlast > .tall #2>&1
2582 check behave:mbox-6 0 .tmbox3 '1387070539 13655'
2583 ${sed} 2d < .tall > .tallx
2584 check behave:mbox-7 - .tallx '2729940494 13645'
2586 # Invalid MBOXes (after [f4db93b3])
2587 echo > .tinvmbox
2588 printf 'copy 1 ./.tinvmbox' | ${MAILX} ${ARGS} -Rf "${MBOX}" > .tall 2>&1
2589 check behave:mbox-8 0 .tinvmbox '999592329 122'
2590 check behave:mbox-9 - ./.tall '3146754194 33'
2592 echo ' ' > .tinvmbox
2593 printf 'copy 1 ./.tinvmbox' | ${MAILX} ${ARGS} -Rf "${MBOX}" > .tall 2>&1
2594 check behave:mbox-10 0 .tinvmbox '3790411604 124'
2595 check behave:mbox-11 - ./.tall '3146754194 33'
2597 { echo; echo; } > .tinvmbox # (not invalid)
2598 printf 'copy 1 ./.tinvmbox' | ${MAILX} ${ARGS} -Rf "${MBOX}" > .tall 2>&1
2599 check behave:mbox-12 0 .tinvmbox '534457575 123'
2600 check behave:mbox-13 - ./.tall '3146754194 33'
2602 # *mbox-rfc4155*, plus
2603 ${cat} <<-_EOT > ./.tinv1
2606 From MAILER-DAEMON-1 Wed Oct 2 01:50:07 1996
2607 Date: Wed, 02 Oct 1996 01:50:07 +0000
2609 Subject: Bad bad message 1
2611 From me to you, blinde Kuh!
2613 From MAILER-DAEMON-2 Wed Oct 2 01:50:07 1996
2614 Date: Wed, 02 Oct 1996 01:50:07 +0000
2616 Subject: Bad bad message 2
2618 From me to you, blindes Kalb!
2619 _EOT
2620 ${cp} ./.tinv1 ./.tinv2
2622 printf \
2623 'define mboxfix {
2624 \\localopts yes; \\wysh set mbox-rfc4155;\\wysh File "${1}";\\
2625 \\eval copy * "${2}"
2627 call mboxfix ./.tinv1 ./.tok' | ${MAILX} ${ARGS} > .tall 2>&1
2628 ex0_test behave:mbox-14-estat
2629 ${cat} ./.tinv1 ./.tok >> .tall
2630 check behave:mbox-14 - ./.tall '739301109 616'
2632 printf \
2633 'wysh file ./.tinv1 # ^From not repaired, but missing trailing NL is
2634 wysh File ./.tok # Just move away to nowhere
2635 set mbox-rfc4155
2636 wysh file ./.tinv2 # Fully repaired
2637 File ./.tok' | ${MAILX} ${ARGS} > /dev/null 2>&1 # xxx errors, paths..
2638 ex0_test behave:mbox-15-estat
2639 check behave:mbox-15-1 - ./.tinv1 '3178048820 332'
2640 check behave:mbox-15-2 - ./.tinv2 '4151504442 314'
2642 t_epilog
2645 t_behave_maildir() {
2646 t_prolog t_behave_maildir
2647 TRAP_EXIT_ADDONS="./.t*"
2651 while [ ${i} -lt 112 ]; do
2652 printf 'm file://%s\n~s Subject %s\nHello %s!\n~.\n' \
2653 "${MBOX}" "${i}" "${i}"
2654 i=`add ${i} 1`
2655 done
2656 ) | ${MAILX} ${ARGS}
2657 check behave:maildir-1 0 "${MBOX}" '1140119864 13780'
2659 printf 'File "%s"
2660 copy * "%s"
2661 File "%s"
2662 from*
2663 ' "${MBOX}" .tmdir1 .tmdir1 |
2664 ${MAILX} ${ARGS} -Snewfolders=maildir -Sshowlast > .tlst
2665 check behave:maildir-2 0 .tlst '1797938753 9103'
2667 printf 'File "%s"
2668 copy * "maildir://%s"
2669 File "maildir://%s"
2670 from*
2671 ' "${MBOX}" .tmdir2 .tmdir2 |
2672 ${MAILX} ${ARGS} -Sshowlast > .tlst
2673 check behave:maildir-3 0 .tlst '1155631089 9113'
2675 printf 'File "maildir://%s"
2676 copy * "file://%s"
2677 File "file://%s"
2678 from*
2679 ' .tmdir2 .tmbox1 .tmbox1 |
2680 ${MAILX} ${ARGS} -Sshowlast > .tlst
2681 check behave:maildir-4 0 .tmbox1 '2646131190 13220'
2682 check behave:maildir-5 - .tlst '3701297796 9110'
2684 # only the odd (even)
2686 printf 'File "maildir://%s"
2687 copy ' .tmdir2
2689 while [ ${i} -lt 112 ]; do
2690 j=`modulo ${i} 2`
2691 [ ${j} -eq 1 ] && printf '%s ' "${i}"
2692 i=`add ${i} 1`
2693 done
2694 printf ' file://%s
2695 File "file://%s"
2696 from*
2697 ' .tmbox2 .tmbox2
2698 ) | ${MAILX} ${ARGS} -Sshowlast > .tlst
2699 check behave:maildir-6 0 .tmbox2 '142890131 6610'
2700 check behave:maildir-7 - .tlst '960096773 4573'
2701 # ...
2703 printf 'file "maildir://%s"
2704 move ' .tmdir2
2706 while [ ${i} -lt 112 ]; do
2707 j=`modulo ${i} 2`
2708 [ ${j} -eq 0 ] && [ ${i} -ne 0 ] && printf '%s ' "${i}"
2709 i=`add ${i} 1`
2710 done
2711 printf ' file://%s
2712 File "file://%s"
2713 from*
2714 File "maildir://%s"
2715 from*
2716 ' .tmbox2 .tmbox2 .tmdir2
2717 ) | ${MAILX} ${ARGS} -Sshowlast > .tlst
2718 check behave:maildir-8 0 .tmbox2 '3806905791 13100'
2719 ${sed} 2d < .tlst > .tlstx
2720 check behave:maildir-9 - .tlstx '4216815295 13645'
2722 t_epilog
2725 t_behave_record_a_resend() {
2726 t_prolog t_behave_record_a_resend
2727 TRAP_EXIT_ADDONS="./.t.record ./.t.resent"
2729 printf '
2730 set record=%s
2731 m %s\n~s Subject 1.\nHello.\n~.
2732 set record-files add-file-recipients
2733 m %s\n~s Subject 2.\nHello.\n~.
2734 File %s
2735 resend 2 ./.t.resent
2736 Resend 1 ./.t.resent
2737 set record-resent
2738 resend 2 ./.t.resent
2739 Resend 1 ./.t.resent
2740 ' ./.t.record "${MBOX}" "${MBOX}" "${MBOX}" |
2741 ${MAILX} ${ARGS}
2743 check behave:record_a_resend-1 0 "${MBOX}" '3057873538 256'
2744 check behave:record_a_resend-2 - .t.record '391356429 460'
2745 check behave:record_a_resend-3 - .t.resent '2685231691 648'
2747 t_epilog
2750 t_behave_e_H_L_opts() {
2751 t_prolog t_behave_e_H_L_opts
2752 TRAP_EXIT_ADDONS="./.tsendmail.sh ./.t.mbox"
2754 touch ./.t.mbox
2755 ${MAILX} ${ARGS} -ef ./.t.mbox
2756 echo ${?} > "${MBOX}"
2758 ${cat} <<-_EOT > ./.tsendmail.sh
2759 #!${SHELL} -
2760 (echo 'From Alchemilla Wed Apr 07 17:03:33 2017' && ${cat} && echo
2761 ) >> "./.t.mbox"
2762 _EOT
2763 chmod 0755 ./.tsendmail.sh
2764 printf 'm me@exam.ple\nLine 1.\nHello.\n~.\n' |
2765 ${MAILX} ${ARGS} -Smta=./.tsendmail.sh
2766 printf 'm you@exam.ple\nLine 1.\nBye.\n~.\n' |
2767 ${MAILX} ${ARGS} -Smta=./.tsendmail.sh
2769 ${MAILX} ${ARGS} -ef ./.t.mbox
2770 echo ${?} >> "${MBOX}"
2771 ${MAILX} ${ARGS} -efL @t@me ./.t.mbox
2772 echo ${?} >> "${MBOX}"
2773 ${MAILX} ${ARGS} -efL @t@you ./.t.mbox
2774 echo ${?} >> "${MBOX}"
2775 ${MAILX} ${ARGS} -efL '@>@Line 1' ./.t.mbox
2776 echo ${?} >> "${MBOX}"
2777 ${MAILX} ${ARGS} -efL '@>@Hello.' ./.t.mbox
2778 echo ${?} >> "${MBOX}"
2779 ${MAILX} ${ARGS} -efL '@>@Bye.' ./.t.mbox
2780 echo ${?} >> "${MBOX}"
2781 ${MAILX} ${ARGS} -efL '@>@Good bye.' ./.t.mbox
2782 echo ${?} >> "${MBOX}"
2784 ${MAILX} ${ARGS} -fH ./.t.mbox >> "${MBOX}"
2785 echo ${?} >> "${MBOX}"
2786 ${MAILX} ${ARGS} -fL @t@me ./.t.mbox >> "${MBOX}"
2787 echo ${?} >> "${MBOX}"
2788 ${MAILX} ${ARGS} -fL @t@you ./.t.mbox >> "${MBOX}"
2789 echo ${?} >> "${MBOX}"
2790 ${MAILX} ${ARGS} -fL '@>@Line 1' ./.t.mbox >> "${MBOX}"
2791 echo ${?} >> "${MBOX}"
2792 ${MAILX} ${ARGS} -fL '@>@Hello.' ./.t.mbox >> "${MBOX}"
2793 echo ${?} >> "${MBOX}"
2794 ${MAILX} ${ARGS} -fL '@>@Bye.' ./.t.mbox >> "${MBOX}"
2795 echo ${?} >> "${MBOX}"
2796 ${MAILX} ${ARGS} -fL '@>@Good bye.' ./.t.mbox >> "${MBOX}" 2>/dev/null
2797 echo ${?} >> "${MBOX}"
2799 check behave:e_H_L_opts - "${MBOX}" '1708955574 678'
2801 t_epilog
2804 t_behave_alternates() {
2805 t_prolog t_behave_alternates
2806 TRAP_EXIT_ADDONS="./.t*"
2808 ${cat} <<-_EOT > ./.tsendmail.sh
2809 #!${SHELL} -
2810 (echo 'From Valeriana Sat Jul 08 15:54:03 2017' && ${cat} && echo
2811 ) >> "${MBOX}"
2812 _EOT
2813 chmod 0755 ./.tsendmail.sh
2815 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Smta=./.tsendmail.sh > ./.tall 2>&1
2816 echo --0
2817 alternates
2818 echo $?/$^ERRNAME
2819 alternates a1@b1 a2@b2 a3@b3
2820 echo $?/$^ERRNAME
2821 alternates
2822 echo $?/$^ERRNAME
2823 vput alternates rv
2824 echo $?/$^ERRNAME <$rv>
2826 echo --1
2827 unalternates a2@b2
2828 vput alternates rv
2829 echo $?/$^ERRNAME <$rv>
2830 unalternates a3@b3
2831 vput alternates rv
2832 echo $?/$^ERRNAME <$rv>
2833 unalternates a1@b1
2834 vput alternates rv
2835 echo $?/$^ERRNAME <$rv>
2837 echo --2
2838 unalternates *
2839 alternates a1@b1 a2@b2 a3@b3
2840 unalternates a3@b3
2841 vput alternates rv
2842 echo $?/$^ERRNAME <$rv>
2843 unalternates a2@b2
2844 vput alternates rv
2845 echo $?/$^ERRNAME <$rv>
2846 unalternates a1@b1
2847 vput alternates rv
2848 echo $?/$^ERRNAME <$rv>
2850 echo --3
2851 alternates a1@b1 a2@b2 a3@b3
2852 unalternates a1@b1
2853 vput alternates rv
2854 echo $?/$^ERRNAME <$rv>
2855 unalternates a2@b2
2856 vput alternates rv
2857 echo $?/$^ERRNAME <$rv>
2858 unalternates a3@b3
2859 vput alternates rv
2860 echo $?/$^ERRNAME <$rv>
2862 echo --4
2863 unalternates *
2864 alternates a1@b1 a2@b2 a3@b3
2865 unalternates *
2866 vput alternates rv
2867 echo $?/$^ERRNAME <$rv>
2869 echo --5
2870 unalternates *
2871 alternates a1@b1 a1@c1 a1@d1 a2@b2 a3@b3 a3@c3 a3@d3
2872 m a1@b1 a1@c1 a1@d1
2873 ~s all alternates, only a1@b1 remains
2874 ~c a2@b2
2875 ~b a3@b3 a3@c3 a3@d3
2876 ~r - '_EOT'
2877 This body is!
2878 This also body is!!
2879 _EOT
2882 echo --6
2883 unalternates *
2884 alternates a1@b1 a1@c1 a2@b2 a3@b3
2885 m a1@b1 a1@c1 a1@d1
2886 ~s a1@b1 a1@d1, and a3@c3 a3@d3 remain
2887 ~c a2@b2
2888 ~b a3@b3 a3@c3 a3@d3
2889 ~r - '_EOT'
2890 This body2 is!
2891 _EOT
2894 echo --7
2895 alternates a1@b1 a2@b2 a3; set allnet
2896 m a1@b1 a1@c1 a1@d1
2897 ~s all alternates via allnet, only a1@b1 remains
2898 ~c a2@b2
2899 ~b a3@b3 a3@c3 a3@d3
2900 ~r - '_EOT'
2901 This body3 is!
2902 _EOT
2905 echo --10
2906 unalternates *
2907 alternates a1@b1
2908 echo $?/$^ERRNAME
2909 vput alternates rv
2910 echo $?/$^ERRNAME <$rv>
2911 alternates a2@b2
2912 echo $?/$^ERRNAME
2913 vput alternates rv
2914 echo $?/$^ERRNAME <$rv>
2915 alternates a3@b3
2916 echo $?/$^ERRNAME
2917 vput alternates rv
2918 echo $?/$^ERRNAME <$rv>
2919 alternates a4@b4
2920 echo $?/$^ERRNAME
2921 vput alternates rv
2922 echo $?/$^ERRNAME <$rv>
2924 unalternates *
2925 vput alternates rv
2926 echo $?/$^ERRNAME <$rv>
2928 echo --11
2929 set posix
2930 alternates a1@b1 a2@b2
2931 echo $?/$^ERRNAME
2932 vput alternates rv
2933 echo $?/$^ERRNAME <$rv>
2934 alternates a3@b3 a4@b4
2935 echo $?/$^ERRNAME
2936 vput alternates rv
2937 echo $?/$^ERRNAME <$rv>
2938 __EOT
2939 check behave:alternates-1 0 "${MBOX}" '142184864 515'
2940 check behave:alternates-2 - .tall '1878598364 505'
2942 t_epilog
2945 t_behave_alias() {
2946 t_prolog t_behave_alias
2947 TRAP_EXIT_ADDONS="./.t*"
2949 ${cat} <<-_EOT > ./.tsendmail.sh
2950 #!${SHELL} -
2951 (echo 'From Hippocastanum Mon Jun 19 15:07:07 2017' && ${cat} && echo
2952 ) >> "${MBOX}"
2953 _EOT
2954 chmod 0755 ./.tsendmail.sh
2956 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Smta=./.tsendmail.sh > ./.tall 2>&1
2957 alias a1 ex1@a1.ple
2958 alias a1 ex2@a1.ple "EX3 <ex3@a1.ple>"
2959 alias a1 ex4@a1.ple
2960 alias a2 ex1@a2.ple ex2@a2.ple ex3@a2.ple ex4@a2.ple
2961 alias a3 a4
2962 alias a4 a5 ex1@a4.ple
2963 alias a5 a6
2964 alias a6 a7 ex1@a6.ple
2965 alias a7 a8
2966 alias a8 ex1@a8.ple
2967 alias a1
2968 alias a2
2969 alias a3
2970 m a1
2971 ~c a2
2972 ~b a3
2973 ~r - '_EOT'
2974 This body is!
2975 This also body is!!
2976 _EOT
2977 __EOT
2978 check behave:alias-1 0 "${MBOX}" '2496925843 272'
2979 check behave:alias-2 - .tall '3548953204 152'
2981 # TODO t_behave_alias: n_ALIAS_MAXEXP is compile-time constant,
2982 # TODO need to somehow provide its contents to the test, then test
2984 t_epilog
2987 t_behave_filetype() {
2988 t_prolog t_behave_filetype
2989 TRAP_EXIT_ADDONS="./.t*"
2991 ${cat} <<-_EOT > ./.tsendmail.sh
2992 #!${SHELL} -
2993 (echo 'From Alchemilla Wed Apr 25 15:12:13 2017' && ${cat} && echo
2994 ) >> "${MBOX}"
2995 _EOT
2996 chmod 0755 ./.tsendmail.sh
2998 printf 'm m1@e.t\nL1\nHy1\n~.\nm m2@e.t\nL2\nHy2\n~@ %s\n~.\n' \
2999 "${SRCDIR}snailmail.jpg" | ${MAILX} ${ARGS} -Smta=./.tsendmail.sh
3000 check behave:filetype-1 0 "${MBOX}" '1594682963 13520'
3002 if (echo | gzip -c) >/dev/null 2>&1; then
3003 ${rm} -f ./.t.mbox*
3005 printf 'File "%s"\ncopy 1 ./.t.mbox.gz\ncopy 2 ./.t.mbox.gz' \
3006 "${MBOX}" | ${MAILX} ${ARGS} \
3007 -X'filetype gz gzip\ -dc gzip\ -c'
3008 printf 'File ./.t.mbox.gz\ncopy * ./.t.mbox\n' |
3009 ${MAILX} ${ARGS} -X'filetype gz gzip\ -dc gzip\ -c'
3010 } > ./.t.out 2>&1
3011 check behave:filetype-2 - "./.t.mbox" '1594682963 13520'
3012 check behave:filetype-3 - "./.t.out" '2392348396 102'
3013 else
3014 echo 'behave:filetype-2: unsupported, skipped'
3015 echo 'behave:filetype-3: unsupported, skipped'
3019 ${rm} -f ./.t.mbox*
3020 printf 'File "%s"\ncopy 1 ./.t.mbox.gz
3021 copy 2 ./.t.mbox.gz
3022 copy 1 ./.t.mbox.gz
3023 copy 2 ./.t.mbox.gz
3024 ' "${MBOX}" |
3025 ${MAILX} ${ARGS} \
3026 -X'filetype gz gzip\ -dc gzip\ -c' \
3027 -X'filetype mbox.gz "${sed} 1,3d|${cat}" \
3028 "echo eins;echo zwei;echo und mit ${sed} bist Du dabei;${cat}"'
3029 printf 'File ./.t.mbox.gz\ncopy * ./.t.mbox\n' |
3030 ${MAILX} ${ARGS} \
3031 -X'filetype gz gzip\ -dc gzip\ -c' \
3032 -X'filetype mbox.gz "${sed} 1,3d|${cat}" kill\ 0'
3033 } > ./.t.out 2>&1
3034 check behave:filetype-4 - "./.t.mbox" '2886541147 27060'
3035 check behave:filetype-5 - "./.t.out" '852335377 172'
3037 t_epilog
3040 t_behave_message_injections() {
3041 t_prolog t_behave_message_injections
3042 TRAP_EXIT_ADDONS="./.t*"
3044 ${cat} <<-_EOT > ./.tsendmail.sh
3045 #!${SHELL} -
3046 (echo 'From Echinacea Tue Jun 20 15:54:02 2017' && ${cat} && echo
3047 ) > "${MBOX}"
3048 _EOT
3049 chmod 0755 ./.tsendmail.sh
3051 echo mysig > ./.tmysig
3053 echo some-body | ${MAILX} ${ARGS} -Smta=./.tsendmail.sh \
3054 -Smessage-inject-head=head-inject \
3055 -Smessage-inject-tail=tail-inject \
3056 -Ssignature=./.tmysig \
3057 ex@am.ple > ./.tall 2>&1
3058 check behave:message_injections-1 0 "${MBOX}" '2434746382 134'
3059 check behave:message_injections-2 - .tall '4294967295 0' # empty file
3061 ${cat} <<-_EOT > ./.template
3062 From: me
3063 To: ex1@am.ple
3064 Cc: ex2@am.ple
3065 Subject: This subject is
3067 Body, body, body me.
3068 _EOT
3069 < ./.template ${MAILX} ${ARGS} -t -Smta=./.tsendmail.sh \
3070 -Smessage-inject-head=head-inject \
3071 -Smessage-inject-tail=tail-inject \
3072 -Ssignature=./.tmysig \
3073 > ./.tall 2>&1
3074 check behave:message_injections-3 0 "${MBOX}" '3114203412 198'
3075 check behave:message_injections-4 - .tall '4294967295 0' # empty file
3077 t_epilog
3080 t_behave_attachments() {
3081 t_prolog t_behave_attachments
3082 TRAP_EXIT_ADDONS="./.t*"
3084 ${cat} <<-_EOT > ./.tsendmail.sh
3085 #!${SHELL} -
3086 (echo 'From Cannabis Sun Feb 18 02:02:46 2018' && ${cat} && echo
3087 ) >> "${MBOX}"
3088 _EOT
3089 chmod 0755 ./.tsendmail.sh
3091 ${cat} <<-_EOT > ./.tx
3092 From steffen Sun Feb 18 02:48:40 2018
3093 Date: Sun, 18 Feb 2018 02:48:40 +0100
3095 Subject: m1
3096 User-Agent: s-nail v14.9.7
3099 From steffen Sun Feb 18 02:48:42 2018
3100 Date: Sun, 18 Feb 2018 02:48:42 +0100
3102 Subject: m2
3103 User-Agent: s-nail v14.9.7
3106 _EOT
3107 echo att1 > ./.t1
3108 printf 'att2-1\natt2-2\natt2-4\n' > ./'.t 2'
3109 printf 'att3-1\natt3-2\natt3-4\n' > ./.t3
3110 printf 'att4-1\natt4-2\natt4-4\n' > './.t 4'
3112 printf \
3113 '!@ ./.t3 "./.t 4" ""
3116 ./.t3
3117 "./.t 2"
3120 !.' \
3121 | ${MAILX} ${ARGS} -Sescape=! -Smta=./.tsendmail.sh \
3122 -a ./.t1 -a './.t 2' \
3123 -s attachment-test \
3124 ex@am.ple > ./.tall 2>&1
3125 check behave:attachments-1 0 "${MBOX}" '4107062253 634'
3126 check behave:attachments-2 - .tall '1928331872 720'
3128 ${rm} -f "${MBOX}"
3129 printf \
3130 'mail ex@amp.ple
3131 !s This the subject is
3132 !@ ./.t3 "#2" "./.t 4" "#1" ""
3135 "./.t 4"
3136 "#2"
3140 mail ex@amp.ple
3141 !s Subject two
3142 !@ ./.t3 "#2" "./.t 4" "#1" ""
3148 mail ex@amp.ple
3149 !s Subject three
3150 !@ ./.t3 "" "#2" "" "./.t 4" "" "#1" ""
3153 ./.t3
3157 mail ex@amp.ple
3158 !s Subject Four
3159 !@ ./.t3 "" "#2" "" "./.t 4" "" "#1" ""
3162 "#1"
3166 mail ex@amp.ple
3167 !s Subject Five
3169 "#2"
3172 !.' \
3173 | ${MAILX} ${ARGS} -Sescape=! -Smta=./.tsendmail.sh -Rf ./.tx \
3174 > ./.tall 2>&1
3175 check behave:attachments-3 0 "${MBOX}" '798122412 2285'
3176 check behave:attachments-4 - .tall '2526106274 1910'
3178 t_epilog
3181 t_behave_compose_hooks() { # TODO monster
3182 t_prolog t_behave_compose_hooks
3183 TRAP_EXIT_ADDONS="./.t*"
3185 (echo line one&&echo line two&&echo line three) > ./.treadctl
3186 (echo echo four&&echo echo five&&echo echo six) > ./.tattach
3188 ${cat} <<-_EOT > ./.tsendmail.sh
3189 #!${SHELL} -
3190 (echo 'From PrimulaVeris Wed Apr 10 22:59:00 2017' && ${cat} && echo
3191 ) >> "${MBOX}"
3192 _EOT
3193 chmod 0755 ./.tsendmail.sh
3195 ${cat} <<'__EOT__' > ./.trc
3196 define bail {
3197 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
3199 define xerr {
3200 vput vexpr es substr "$1" 0 1
3201 if [ "$es" != 2 ]
3202 xcall bail "$2"
3205 define read_mline_res {
3206 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
3207 echo $len/$es/$^ERRNAME: $hl
3208 if [ $es -ne $^ERR-NONE ]
3209 xcall bail read_mline_res
3210 elif [ $len -ne 0 ]
3211 \xcall read_mline_res
3214 define ins_addr {
3215 wysh set xh=$1
3216 echo "~^header list"; read hl; echo $hl;\
3217 call xerr "$hl" "in_addr ($xh) 0-1"
3219 echo "~^header insert $xh diet <$xh@exam.ple> spliced";\
3220 read es; echo $es; call xerr "$es" "ins_addr $xh 1-1"
3221 echo "~^header insert $xh <${xh}2@exam.ple>";\
3222 read es; echo $es; call xerr "$es" "ins_addr $xh 1-2"
3223 echo "~^header insert $xh ${xh}3@exam.ple";\
3224 read es; echo $es; call xerr "$es" "ins_addr $xh 1-3"
3225 echo "~^header list $xh"; read hl; echo $hl;\
3226 call xerr "$hl" "ins_addr $xh 1-4"
3227 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 1-5"
3228 call read_mline_res
3230 if [ "$t_remove" == "" ]
3231 return
3234 echo "~^header remove $xh"; read es; call xerr $es "ins_addr $xh 2-1"
3235 echo "~^header remove $xh"; read es; vput vexpr es substr $es 0 3
3236 if [ $es != 501 ]
3237 xcall bail "ins_addr $xh 2-2"
3239 echo "~^header list $xh"; read es; vput vexpr es substr $es 0 3
3240 if [ $es != 501 ]
3241 xcall bail "ins_addr $xh 2-3"
3243 echo "~^header show $xh"; read es; vput vexpr es substr $es 0 3
3244 if [ $es != 501 ]
3245 xcall bail "ins_addr $xh 2-4"
3249 echo "~^header insert $xh diet <$xh@exam.ple> spliced";\
3250 read es; echo $es; call xerr "$es" "ins_addr $xh 3-1"
3251 echo "~^header insert $xh <${xh}2@exam.ple>";\
3252 read es; echo $es; call xerr "$es" "ins_addr $xh 3-2"
3253 echo "~^header insert $xh ${xh}3@exam.ple";\
3254 read es; echo $es; call xerr "$es" "ins_addr $xh 3-3"
3255 echo "~^header list $xh"; read hl; echo $hl;\
3256 call xerr "$hl" "ins_addr $xh 3-4"
3257 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 3-5"
3258 call read_mline_res
3260 echo "~^header remove-at $xh 1"; read es;\
3261 call xerr $es "ins_addr $xh 3-6"
3262 echo "~^header remove-at $xh 1"; read es;\
3263 call xerr $es "ins_addr $xh 3-7"
3264 echo "~^header remove-at $xh 1"; read es;\
3265 call xerr $es "ins_addr $xh 3-8"
3266 echo "~^header remove-at $xh 1"; read es;\
3267 vput vexpr es substr $es 0 3
3268 if [ $es != 501 ]
3269 xcall bail "ins_addr $xh 3-9"
3271 echo "~^header remove-at $xh T"; read es;\
3272 vput vexpr es substr $es 0 3
3273 if [ $es != 505 ]
3274 xcall bail "ins_addr $xh 3-10"
3276 echo "~^header list $xh"; read es;\
3277 vput vexpr es substr $es 0 3
3278 if [ $es != 501 ]
3279 xcall bail "ins_addr $xh 3-11"
3281 echo "~^header show $xh"; read es;\
3282 vput vexpr es substr $es 0 3
3283 if [ $es != 501 ]
3284 xcall bail "ins_addr $xh 3-12"
3288 echo "~^header insert $xh diet <$xh@exam.ple> spliced";\
3289 read es; echo $es; call xerr "$es" "ins_addr $xh 4-1"
3290 echo "~^header insert $xh <${xh}2@exam.ple> (comment) \"Quot(e)d\"";\
3291 read es; echo $es; call xerr "$es" "ins_addr $xh 4-2"
3292 echo "~^header insert $xh ${xh}3@exam.ple";\
3293 read es; echo $es; call xerr "$es" "ins_addr $xh 4-3"
3294 echo "~^header list $xh"; read hl; echo $hl;\
3295 call xerr "$hl" "header list $xh 3-4"
3296 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 4-5"
3297 call read_mline_res
3299 echo "~^header remove-at $xh 3"; read es;\
3300 call xerr $es "ins_addr $xh 4-6"
3301 echo "~^header remove-at $xh 2"; read es;\
3302 call xerr $es "ins_addr $xh 4-7"
3303 echo "~^header remove-at $xh 1"; read es;\
3304 call xerr $es "ins_addr $xh 4-8"
3305 echo "~^header remove-at $xh 1"; read es;\
3306 vput vexpr es substr $es 0 3
3307 if [ $es != 501 ]
3308 xcall bail "ins_addr $xh 4-9"
3310 echo "~^header remove-at $xh T"; read es;\
3311 vput vexpr es substr $es 0 3
3312 if [ $es != 505 ]
3313 xcall bail "ins_addr $xh 4-10"
3315 echo "~^header list $xh"; read es;\
3316 vput vexpr es substr $es 0 3
3317 if [ $es != 501 ]
3318 xcall bail "ins_addr $xh 4-11"
3320 echo "~^header show $xh"; read es;\
3321 vput vexpr es substr $es 0 3
3322 if [ $es != 501 ]
3323 xcall bail "ins_addr $xh 4-12"
3326 define ins_ref {
3327 wysh set xh=$1 mult=$2
3328 echo "~^header list"; read hl; echo $hl;\
3329 call xerr "$hl" "ins_ref ($xh) 0-1"
3331 echo "~^header insert $xh <$xh@exam.ple>";\
3332 read es; echo $es; call xerr "$es" "ins_ref $xh 1-1"
3333 if [ $mult -ne 0 ]
3334 echo "~^header insert $xh <${xh}2@exam.ple>";\
3335 read es; echo $es; call xerr "$es" "ins_ref $xh 1-2"
3336 echo "~^header insert $xh ${xh}3@exam.ple";\
3337 read es; echo $es; call xerr "$es" "ins_ref $xh 1-3"
3338 else
3339 echo "~^header insert $xh <${xh}2@exam.ple>"; read es;\
3340 vput vexpr es substr $es 0 3
3341 if [ $es != 506 ]
3342 xcall bail "ins_ref $xh 1-4"
3346 echo "~^header list $xh"; read hl; echo $hl;\
3347 call xerr "$hl" "ins_ref $xh 1-5"
3348 echo "~^header show $xh"; read es; call xerr $es "ins_ref $xh 1-6"
3349 call read_mline_res
3351 if [ "$t_remove" == "" ]
3352 return
3355 echo "~^header remove $xh"; read es;\
3356 call xerr $es "ins_ref $xh 2-1"
3357 echo "~^header remove $xh"; read es;\
3358 vput vexpr es substr $es 0 3
3359 if [ $es != 501 ]
3360 xcall bail "ins_ref $xh 2-2"
3362 echo "~^header list $xh"; read es;\
3363 vput vexpr es substr $es 0 3
3364 if [ $es != 501 ]
3365 xcall bail "$es ins_ref $xh 2-3"
3367 echo "~^header show $xh"; read es;\
3368 vput vexpr es substr $es 0 3
3369 if [ $es != 501 ]
3370 xcall bail "ins_ref $xh 2-4"
3374 echo "~^header insert $xh <$xh@exam.ple>";\
3375 read es; echo $es; call xerr "$es" "ins_ref $xh 3-1"
3376 if [ $mult -ne 0 ]
3377 echo "~^header insert $xh <${xh}2@exam.ple>";\
3378 read es; echo $es; call xerr "$es" "ins_ref $xh 3-2"
3379 echo "~^header insert $xh ${xh}3@exam.ple";\
3380 read es; echo $es; call xerr "$es" "ins_ref $xh 3-3"
3382 echo "~^header list $xh";\
3383 read hl; echo $hl; call xerr "$hl" "ins_ref $xh 3-4"
3384 echo "~^header show $xh";\
3385 read es; call xerr $es "ins_ref $xh 3-5"
3386 call read_mline_res
3388 echo "~^header remove-at $xh 1"; read es;\
3389 call xerr $es "ins_ref $xh 3-6"
3390 if [ $mult -ne 0 ] && [ $xh != subject ]
3391 echo "~^header remove-at $xh 1"; read es;\
3392 call xerr $es "ins_ref $xh 3-7"
3393 echo "~^header remove-at $xh 1"; read es;\
3394 call xerr $es "ins_ref $xh 3-8"
3396 echo "~^header remove-at $xh 1"; read es;\
3397 vput vexpr es substr $es 0 3
3398 if [ $es != 501 ]
3399 xcall bail "ins_ref $xh 3-9"
3401 echo "~^header remove-at $xh T"; read es;\
3402 vput vexpr es substr $es 0 3
3403 if [ $es != 505 ]
3404 xcall bail "ins_ref $xh 3-10"
3406 echo "~^header show $xh"; read es;\
3407 vput vexpr es substr $es 0 3
3408 if [ $es != 501 ]
3409 xcall bail "ins_ref $xh 3-11"
3413 echo "~^header insert $xh <$xh@exam.ple> ";\
3414 read es; echo $es; call xerr "$es" "ins_ref $xh 4-1"
3415 if [ $mult -ne 0 ]
3416 echo "~^header insert $xh <${xh}2@exam.ple> ";\
3417 read es; echo $es; call xerr "$es" "ins_ref $xh 4-2"
3418 echo "~^header insert $xh ${xh}3@exam.ple";\
3419 read es; echo $es; call xerr "$es" "ins_ref $xh 4-3"
3421 echo "~^header list $xh"; read hl; echo $hl;\
3422 call xerr "$hl" "ins_ref $xh 4-4"
3423 echo "~^header show $xh"; read es; call xerr $es "ins_ref $xh 4-5"
3424 call read_mline_res
3426 if [ $mult -ne 0 ] && [ $xh != subject ]
3427 echo "~^header remove-at $xh 3"; read es;\
3428 call xerr $es "ins_ref $xh 4-6"
3429 echo "~^header remove-at $xh 2"; read es;\
3430 call xerr $es "ins_ref $xh 4-7"
3432 echo "~^header remove-at $xh 1"; read es;\
3433 call xerr $es "ins_ref $xh 4-8"
3434 echo "~^header remove-at $xh 1"; read es;\
3435 vput vexpr es substr $es 0 3
3436 if [ $es != 501 ]
3437 xcall bail "ins_ref $xh 4-9"
3439 echo "~^header remove-at $xh T"; read es;\
3440 vput vexpr es substr $es 0 3
3441 if [ $es != 505 ]
3442 xcall bail "ins_ref $xh 4-10"
3444 echo "~^header show $xh"; read es;\
3445 vput vexpr es substr $es 0 3
3446 if [ $es != 501 ]
3447 xcall bail "ins_ref $xh 4-11"
3450 define t_header {
3451 echo t_header ENTER
3452 # In collect.c order
3453 call ins_addr from
3454 call ins_ref sender 0 # Not a "ref", but works
3455 call ins_addr To
3456 call ins_addr cC
3457 call ins_addr bCc
3458 call ins_addr reply-To
3459 call ins_addr mail-Followup-to
3460 call ins_ref messAge-id 0
3461 call ins_ref rEfErEncEs 1
3462 call ins_ref in-Reply-to 1
3463 call ins_ref subject 1 # Not a "ref", but works (with tweaks)
3464 call ins_addr freeForm1
3465 call ins_addr freeform2
3467 echo "~^header show MAILX-Command"; read es; call xerr $es "t_header 1000"
3468 call read_mline_res
3469 echo "~^header show MAILX-raw-TO"; read es; call xerr $es "t_header 1001"
3470 call read_mline_res
3472 echo t_header LEAVE
3474 define t_attach {
3475 echo t_attach ENTER
3477 echo "~^attachment";\
3478 read hl; echo $hl; vput vexpr es substr "$hl" 0 3
3479 if [ "$es" != 501 ]
3480 xcall bail "attach 0-1"
3483 echo "~^attach attribute ./.treadctl";\
3484 read hl; echo $hl; vput vexpr es substr "$hl" 0 3
3485 if [ "$es" != 501 ]
3486 xcall bail "attach 0-2"
3488 echo "~^attachment attribute-at 1";\
3489 read hl; echo $hl; vput vexpr es substr "$hl" 0 3
3490 if [ "$es" != 501 ]
3491 xcall bail "attach 0-3"
3494 echo "~^attachment insert ./.treadctl=ascii";\
3495 read hl; echo $hl; call xerr "$hl" "attach 1-1"
3496 echo "~^attachment list";\
3497 read es; echo $es;call xerr "$es" "attach 1-2"
3498 call read_mline_res
3499 echo "~^attachment attribute ./.treadctl";\
3500 read es; echo $es;call xerr "$es" "attach 1-3"
3501 call read_mline_res
3502 echo "~^attachment attribute .treadctl";\
3503 read es; echo $es;call xerr "$es" "attach 1-4"
3504 call read_mline_res
3505 echo "~^attachment attribute-at 1";\
3506 read es; echo $es;call xerr "$es" "attach 1-5"
3507 call read_mline_res
3509 echo "~^attachment attribute-set ./.treadctl filename rctl";\
3510 read es; echo $es;call xerr "$es" "attach 1-6"
3511 echo "~^attachment attribute-set .treadctl content-description Au";\
3512 read es; echo $es;call xerr "$es" "attach 1-7"
3513 echo "~^attachment attribute-set-at 1 content-id <10.du@ich>";\
3514 read es; echo $es;call xerr "$es" "attach 1-8"
3516 echo "~^attachment attribute ./.treadctl";\
3517 read es; echo $es;call xerr "$es" "attach 1-9"
3518 call read_mline_res
3519 echo "~^attachment attribute .treadctl";\
3520 read es; echo $es;call xerr "$es" "attach 1-10"
3521 call read_mline_res
3522 echo "~^attachment attribute rctl";\
3523 read es; echo $es;call xerr "$es" "attach 1-11"
3524 call read_mline_res
3525 echo "~^attachment attribute-at 1";\
3526 read es; echo $es;call xerr "$es" "attach 1-12"
3527 call read_mline_res
3530 echo "~^attachment insert ./.tattach=latin1";\
3531 read hl; echo $hl; call xerr "$hl" "attach 2-1"
3532 echo "~^attachment list";\
3533 read es; echo $es;call xerr "$es" "attach 2-2"
3534 call read_mline_res
3535 echo "~^attachment attribute ./.tattach";\
3536 read es; echo $es;call xerr "$es" "attach 2-3"
3537 call read_mline_res
3538 echo "~^attachment attribute .tattach";\
3539 read es; echo $es;call xerr "$es" "attach 2-4"
3540 call read_mline_res
3541 echo "~^attachment attribute-at 2";\
3542 read es; echo $es;call xerr "$es" "attach 2-5"
3543 call read_mline_res
3545 echo "~^attachment attribute-set ./.tattach filename tat";\
3546 read es; echo $es;call xerr "$es" "attach 2-6"
3547 echo \
3548 "~^attachment attribute-set .tattach content-description Au2";\
3549 read es; echo $es;call xerr "$es" "attach 2-7"
3550 echo "~^attachment attribute-set-at 2 content-id <20.du@wir>";\
3551 read es; echo $es;call xerr "$es" "attach 2-8"
3552 echo \
3553 "~^attachment attribute-set-at 2 content-type application/x-sh";\
3554 read es; echo $es;call xerr "$es" "attach 2-9"
3556 echo "~^attachment attribute ./.tattach";\
3557 read es; echo $es;call xerr "$es" "attach 2-10"
3558 call read_mline_res
3559 echo "~^attachment attribute .tattach";\
3560 read es; echo $es;call xerr "$es" "attach 2-11"
3561 call read_mline_res
3562 echo "~^attachment attribute tat";\
3563 read es; echo $es;call xerr "$es" "attach 2-12"
3564 call read_mline_res
3565 echo "~^attachment attribute-at 2";\
3566 read es; echo $es;call xerr "$es" "attach 2-13"
3567 call read_mline_res
3570 if [ "$t_remove" == "" ]
3571 return
3574 echo "~^attachment remove ./.treadctl"; read es;\
3575 call xerr $es "attach 3-1"
3576 echo "~^attachment remove ./.tattach"; read es;\
3577 call xerr $es "attach 3-2"
3578 echo "~^ attachment remove ./.treadctl"; read es;\
3579 vput vexpr es substr $es 0 3
3580 if [ $es != 501 ]
3581 xcall bail "attach 3-3"
3583 echo "~^ attachment remove ./.tattach"; read es;\
3584 vput vexpr es substr $es 0 3
3585 if [ $es != 501 ]
3586 xcall bail "attach 3-4"
3588 echo "~^attachment list"; read es;\
3589 vput vexpr es substr $es 0 3
3590 if [ $es != 501 ]
3591 xcall bail "attach 3-5"
3595 echo "~^attachment insert ./.tattach=latin1";\
3596 read hl; echo $hl; call xerr "$hl" "attach 4-1"
3597 echo "~^attachment insert ./.tattach=latin1";\
3598 read hl; echo $hl; call xerr "$hl" "attach 4-2"
3599 echo "~^attachment list";\
3600 read es; echo $es;call xerr "$es" "attach 4-3"
3601 call read_mline_res
3602 echo "~^ attachment remove .tattach"; read es;\
3603 vput vexpr es substr $es 0 3
3604 if [ $es != 506 ]
3605 xcall bail "attach 4-4 $es"
3607 echo "~^attachment remove-at T"; read es;\
3608 vput vexpr es substr $es 0 3
3609 if [ $es != 505 ]
3610 xcall bail "attach 4-5"
3612 echo "~^attachment remove ./.tattach"; read es;\
3613 call xerr $es "attach 4-6"
3614 echo "~^attachment remove ./.tattach"; read es;\
3615 call xerr $es "attach 4-7"
3616 echo "~^ attachment remove ./.tattach"; read es;\
3617 vput vexpr es substr $es 0 3
3618 if [ $es != 501 ]
3619 xcall bail "attach 4-8 $es"
3621 echo "~^attachment list"; read es;\
3622 vput vexpr es substr $es 0 3
3623 if [ $es != 501 ]
3624 xcall bail "attach 4-9"
3628 echo "~^attachment insert ./.tattach=latin1";\
3629 read hl; echo $hl; call xerr "$hl" "attach 5-1"
3630 echo "~^attachment insert ./.tattach=latin1";\
3631 read hl; echo $hl; call xerr "$hl" "attach 5-2"
3632 echo "~^attachment insert ./.tattach=latin1";\
3633 read hl; echo $hl; call xerr "$hl" "attach 5-3"
3634 echo "~^attachment list";\
3635 read es; echo $es;call xerr "$es" "attach 5-4"
3636 call read_mline_res
3638 echo "~^attachment remove-at 3"; read es;\
3639 call xerr $es "attach 5-5"
3640 echo "~^attachment remove-at 3"; read es;\
3641 vput vexpr es substr $es 0 3
3642 if [ $es != 501 ]
3643 xcall bail "attach 5-6"
3645 echo "~^attachment remove-at 2"; read es;\
3646 call xerr $es "attach 5-7"
3647 echo "~^attachment remove-at 2"; read es;\
3648 vput vexpr es substr $es 0 3
3649 if [ $es != 501 ]
3650 xcall bail "attach 5-8"
3652 echo "~^attachment remove-at 1"; read es;\
3653 call xerr $es "attach 5-9"
3654 echo "~^attachment remove-at 1"; read es;\
3655 vput vexpr es substr $es 0 3
3656 if [ $es != 501 ]
3657 xcall bail "attach 5-10"
3660 echo "~^attachment list"; read es;\
3661 vput vexpr es substr $es 0 3
3662 if [ $es != 501 ]
3663 xcall bail "attach 5-11"
3667 echo "~^attachment insert ./.tattach=latin1";\
3668 read hl; echo $hl; call xerr "$hl" "attach 6-1"
3669 echo "~^attachment insert ./.tattach=latin1";\
3670 read hl; echo $hl; call xerr "$hl" "attach 6-2"
3671 echo "~^attachment insert ./.tattach=latin1";\
3672 read hl; echo $hl; call xerr "$hl" "attach 6-3"
3673 echo "~^attachment list";\
3674 read es; echo $es;call xerr "$es" "attach 6-4"
3675 call read_mline_res
3677 echo "~^attachment remove-at 1"; read es;\
3678 call xerr $es "attach 6-5"
3679 echo "~^attachment remove-at 1"; read es;\
3680 call xerr $es "attach 6-6"
3681 echo "~^attachment remove-at 1"; read es;\
3682 call xerr $es "attach 6-7"
3683 echo "~^attachment remove-at 1"; read es;\
3684 vput vexpr es substr $es 0 3
3685 if [ $es != 501 ]
3686 xcall bail "attach 6-8"
3689 echo "~^attachment list"; read es;\
3690 vput vexpr es substr $es 0 3
3691 if [ $es != 501 ]
3692 xcall bail "attach 6-9"
3695 echo t_attach LEAVE
3697 define t_ocs {
3698 read ver
3699 echo t_ocs
3700 call t_header
3701 call t_attach
3703 define t_oce {
3704 echo on-compose-enter, mailx-command<$mailx-command>
3705 alternates alter1@exam.ple alter2@exam.ple
3706 alternates
3707 set autocc='alter1@exam.ple alter2@exam.ple'
3708 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3709 echo mailx-subject<$mailx-subject>
3710 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3711 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3712 mailx-raw-bcc<$mailx-raw-bcc>
3713 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
3714 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3716 define t_ocl {
3717 echo on-compose-leave, mailx-command<$mailx-command>
3718 vput alternates al
3719 eval alternates $al alter3@exam.ple alter4@exam.ple
3720 alternates
3721 set autobcc='alter3@exam.ple alter4@exam.ple'
3722 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3723 echo mailx-subject<$mailx-subject>
3724 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3725 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3726 mailx-raw-bcc<$mailx-raw-bcc>
3727 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
3728 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3730 define t_occ {
3731 echo on-compose-cleanup, mailx-command<$mailx-command>
3732 unalternates *
3733 alternates
3734 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3735 echo mailx-subject<$mailx-subject>
3736 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3737 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3738 mailx-raw-bcc<$mailx-raw-bcc>
3739 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
3740 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3742 wysh set on-compose-splice=t_ocs \
3743 on-compose-enter=t_oce on-compose-leave=t_ocl \
3744 on-compose-cleanup=t_occ
3745 __EOT__
3747 ${rm} -f "${MBOX}"
3748 printf 'm this-goes@nowhere\nbody\n!.\n' |
3749 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
3750 -X'source ./.trc' -Smta=./.tsendmail.sh \
3751 >./.tall 2>&1
3752 ${cat} ./.tall >> "${MBOX}"
3753 check behave:compose_hooks-1 0 "${MBOX}" '522535560 10101'
3755 ${rm} -f "${MBOX}"
3756 printf 'm this-goes@nowhere\nbody\n!.\n' |
3757 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
3758 -St_remove=1 -X'source ./.trc' -Smta=./.tsendmail.sh \
3759 >./.tall 2>&1
3760 ${cat} ./.tall >> "${MBOX}"
3761 check behave:compose_hooks-2 0 "${MBOX}" '3654000499 12535'
3765 # Some state machine stress, shell compose hook, localopts for hook, etc.
3766 # readctl in child. ~r as HERE document
3767 ${rm} -f "${MBOX}"
3768 printf 'm ex@am.ple\nbody\n!.
3769 echon ${mailx-command}${mailx-subject}
3770 echon ${mailx-from}${mailx-sender}
3771 echon ${mailx-to}${mailx-cc}${mailx-bcc}
3772 echon ${mailx-raw-to}${mailx-raw-cc}${mailx-raw-bcc}
3773 echon ${mailx-orig-from}${mailx-orig-to}${mailx-orig-gcc}${mailx-orig-bcc}
3774 var t_oce t_ocs t_ocs_sh t_ocl t_occ autocc
3775 ' | ${MAILX} ${ARGS} -Snomemdebug -Sescape=! \
3776 -Smta=./.tsendmail.sh \
3778 define bail {
3779 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
3781 define xerr {
3782 vput vexpr es substr "$1" 0 1
3783 if [ "$es" != 2 ]
3784 xcall bail "$2"
3787 define read_mline_res {
3788 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
3789 echo $len/$es/$^ERRNAME: $hl
3790 if [ $es -ne $^ERR-NONE ]
3791 xcall bail read_mline_res
3792 elif [ $len -ne 0 ]
3793 \xcall read_mline_res
3796 define _work {
3797 vput vexpr i + 1 "$2"
3798 if [ $i -lt 111 ]
3799 vput vexpr j % $i 10
3800 if [ $j -ne 0 ]
3801 set j=xcall
3802 else
3803 echon "$i.. "
3804 set j=call
3806 eval \\$j _work $1 $i
3807 return $?
3809 vput vexpr i + $i "$1"
3810 return $i
3812 define _read {
3813 wysh set line; read line;wysh set es=$? en=$^ERRNAME ;\
3814 echo read:$es/$en: $line
3815 if [ "${es}" -ne -1 ]
3816 xcall _read
3818 readctl remove $cwd/.treadctl; echo readctl remove:$?/$^ERRNAME
3820 define t_ocs {
3821 read ver
3822 echo t_ocs
3823 echo "~^header list"; read hl; echo $hl;\
3824 vput vexpr es substr "$hl" 0 1
3825 if [ "$es" != 2 ]
3826 xcall bail "header list"
3827 endif
3829 call _work 1; echo $?
3830 echo "~^header insert cc splicy diet <splice@exam.ple> spliced";\
3831 read es; echo $es; vput vexpr es substr "$es" 0 1
3832 if [ "$es" != 2 ]
3833 xcall bail "be diet"
3834 endif
3835 echo "~^header insert cc <splice2@exam.ple>";\
3836 read es; echo $es; vput vexpr es substr "$es" 0 1
3837 if [ "$es" != 2 ]
3838 xcall bail "be diet2"
3839 endif
3841 call _work 2; echo $?
3842 echo "~^header insert bcc juicy juice <juice@exam.ple> spliced";\
3843 read es; echo $es;vput vexpr es substr "$es" 0 1
3844 if [ "$es" != 2 ]
3845 xcall bail "be juicy"
3846 endif
3847 echo "~^header insert bcc juice2@exam.ple";\
3848 read es; echo $es;vput vexpr es substr "$es" 0 1
3849 if [ "$es" != 2 ]
3850 xcall bail "be juicy2"
3851 endif
3852 echo "~^header insert bcc juice3 <juice3@exam.ple>";\
3853 read es; echo $es;vput vexpr es substr "$es" 0 1
3854 if [ "$es" != 2 ]
3855 xcall bail "be juicy3"
3856 endif
3857 echo "~^header insert bcc juice4@exam.ple";\
3858 read es; echo $es;vput vexpr es substr "$es" 0 1
3859 if [ "$es" != 2 ]
3860 xcall bail "be juicy4"
3861 endif
3863 echo "~^header remove-at bcc 3";\
3864 read es; echo $es;vput vexpr es substr "$es" 0 1
3865 if [ "$es" != 2 ]
3866 xcall bail "remove juicy5"
3867 endif
3868 echo "~^header remove-at bcc 2";\
3869 read es; echo $es;vput vexpr es substr "$es" 0 1
3870 if [ "$es" != 2 ]
3871 xcall bail "remove juicy6"
3872 endif
3873 echo "~^header remove-at bcc 3";\
3874 read es; echo $es;vput vexpr es substr "$es" 0 3
3875 if [ "$es" != 501 ]
3876 xcall bail "failed to remove-at"
3877 endif
3878 # Add duplicates which ought to be removed!
3879 echo "~^header insert bcc juice4@exam.ple";\
3880 read es; echo $es;vput vexpr es substr "$es" 0 1
3881 if [ "$es" != 2 ]
3882 xcall bail "be juicy4-1"
3883 endif
3884 echo "~^header insert bcc juice4@exam.ple";\
3885 read es; echo $es;vput vexpr es substr "$es" 0 1
3886 if [ "$es" != 2 ]
3887 xcall bail "be juicy4-2"
3888 endif
3889 echo "~^header insert bcc juice4@exam.ple";\
3890 read es; echo $es;vput vexpr es substr "$es" 0 1
3891 if [ "$es" != 2 ]
3892 xcall bail "be juicy4-3"
3893 endif
3894 echo "~:set t_ocs"
3897 call _work 3; echo $?
3898 echo "~r - '__EOT'"
3899 vput ! i echo just knock if you can hear me;\
3900 i=0;\
3901 while [ $i -lt 24 ]; do printf "%s " $i; i=`expr $i + 1`; done;\
3902 echo relax
3903 echon shell-cmd says $?/$^ERRNAME: $i
3904 echo "~x will not become interpreted, we are reading until __EOT"
3905 echo "__EOT"
3906 read r_status; echo "~~r status output: $r_status"
3907 echo "~:echo $? $! $^ERRNAME"
3908 read r_status
3909 echo "~~r status from parent: $r_status"
3912 call _work 4; echo $?
3913 vput cwd cwd;echo cwd:$?
3914 readctl create $cwd/.treadctl ;echo readctl:$?/$^ERRNAME;\
3915 call _read
3918 call _work 5; echo $?
3919 echo "~^header show MAILX-Command"; read es;\
3920 call xerr $es "t_header 1000"; call read_mline_res
3921 echo "~^header show MAILX-raw-TO"; read es;\
3922 call xerr $es "t_header 1001"; xcall read_mline_res
3924 echoerr IT IS WRONG IF YOU SEE THIS
3926 define t_oce {
3927 echo on-compose-enter, mailx-command<$mailx-command>
3928 set t_oce autobcc=oce@exam.ple
3929 alternates alter1@exam.ple alter2@exam.ple
3930 alternates
3931 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3932 echo mailx-subject<$mailx-subject>
3933 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3934 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3935 mailx-raw-bcc<$mailx-raw-bcc>
3936 echo mailx-orig-from<$mailx-orig-from> \
3937 mailx-orig-to<$mailx-orig-to> \
3938 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3940 define t_ocl {
3941 echo on-compose-leave, mailx-command<$mailx-command>
3942 set t_ocl autocc=ocl@exam.ple
3943 unalternates *
3944 alternates alter3@exam.ple alter4@exam.ple
3945 alternates
3946 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3947 echo mailx-subject<$mailx-subject>
3948 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3949 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3950 mailx-raw-bcc<$mailx-raw-bcc>
3951 echo mailx-orig-from<$mailx-orig-from> \
3952 mailx-orig-to<$mailx-orig-to> \
3953 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3955 define t_occ {
3956 echo on-compose-cleanup, mailx-command<$mailx-command>
3957 set t_occ autocc=occ@exam.ple
3958 unalternates *
3959 alternates
3960 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3961 echo mailx-subject<$mailx-subject>
3962 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3963 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3964 mailx-raw-bcc<$mailx-raw-bcc>
3965 echo mailx-orig-from<$mailx-orig-from> \
3966 mailx-orig-to<$mailx-orig-to> \
3967 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3969 wysh set on-compose-splice=t_ocs \
3970 on-compose-splice-shell="read ver;printf \"t_ocs-shell\\n\
3971 ~t shell@exam.ple\\n~:set t_ocs_sh\\n\"" \
3972 on-compose-enter=t_oce on-compose-leave=t_ocl \
3973 on-compose-cleanup=t_occ
3974 ' > ./.tnotes 2>&1
3975 ex0_test behave:compose_hooks-3-estat
3976 ${cat} ./.tnotes >> "${MBOX}"
3978 check behave:compose_hooks-3 - "${MBOX}" '679526364 2431'
3980 # Reply, forward, resend, Resend
3982 ${rm} -f "${MBOX}"
3983 printf 'set from=f1@z\nm t1@z\nb1\n!.\nset from=f2@z\nm t2@z\nb2\n!.\n' |
3984 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! \
3985 -Smta=./.tsendmail.sh
3987 printf '
3988 echo start: $? $! $^ERRNAME
3989 File %s
3990 echo File: $? $! $^ERRNAME;echo;echo
3991 reply 1
3992 this is content of reply 1
3994 echo reply 1: $? $! $^ERRNAME;echo;echo
3995 Reply 1 2
3996 this is content of Reply 1 2
3998 echo Reply 1 2: $? $! $^ERRNAME;echo;echo
3999 forward 1 fwdex@am.ple
4000 this is content of forward 1
4002 echo forward 1: $? $! $^ERRNAME;echo;echo
4003 resend 1 2 resendex@am.ple
4004 echo resend 1 2: $? $! $^ERRNAME;echo;echo
4005 Resend 1 2 Resendex@am.ple
4006 echo Resend 1 2: $? $! $^ERRNAME;echo;echo
4007 ' "${MBOX}" |
4008 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! \
4009 -Smta=./.tsendmail.sh \
4011 define bail {
4012 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
4014 define xerr {
4015 vput vexpr es substr "$1" 0 1
4016 if [ "$es" != 2 ]
4017 xcall bail "$2"
4020 define read_mline_res {
4021 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
4022 echo mline_res:$len/$es/$^ERRNAME: $hl
4023 if [ $es -ne $^ERR-NONE ]
4024 xcall bail read_mline_res
4025 elif [ $len -ne 0 ]
4026 \xcall read_mline_res
4029 define work_hl {
4030 echo "~^header show $1"; read es;\
4031 call xerr $es "work_hl $1"; echo $1; call read_mline_res
4032 if [ $# -gt 1 ]
4033 shift
4034 xcall work_hl "$@"
4037 define t_ocs {
4038 read ver
4039 echo t_ocs version $ver
4040 echo "~^header list"; read hl; echo $hl;\
4041 echoerr the header list is $hl;\
4042 call xerr "$hl" "header list"
4043 eval vpospar set $hl
4044 shift
4045 xcall work_hl "$@"
4046 echoerr IT IS WRONG IF YOU SEE THIS
4048 define t_oce {
4049 echo on-XY-enter, mailx-command<$mailx-command>
4050 set t_oce autobcc=oce@exam.ple
4051 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
4052 echo mailx-subject<$mailx-subject>
4053 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
4054 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
4055 mailx-raw-bcc<$mailx-raw-bcc>
4056 echo mailx-orig-from<$mailx-orig-from> \
4057 mailx-orig-to<$mailx-orig-to> \
4058 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
4060 define t_ocl {
4061 echo on-XY-leave, mailx-command<$mailx-command>
4062 set t_ocl autocc=ocl@exam.ple
4063 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
4064 echo mailx-subject<$mailx-subject>
4065 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
4066 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
4067 mailx-raw-bcc<$mailx-raw-bcc>
4068 echo mailx-orig-from<$mailx-orig-from> \
4069 mailx-orig-to<$mailx-orig-to> \
4070 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
4072 define t_occ {
4073 echo on-XY-cleanup, mailx-command<$mailx-command>
4074 set t_occ autocc=occ@exam.ple
4075 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
4076 echo mailx-subject<$mailx-subject>
4077 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
4078 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
4079 mailx-raw-bcc<$mailx-raw-bcc>
4080 echo mailx-orig-from<$mailx-orig-from> \
4081 mailx-orig-to<$mailx-orig-to> \
4082 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
4084 wysh set on-compose-splice=t_ocs \
4085 on-compose-enter=t_oce on-compose-leave=t_ocl \
4086 on-compose-cleanup=t_occ \
4087 on-resend-enter=t_oce on-resend-cleanup=t_occ
4088 ' > ./.tnotes 2>&1
4089 ex0_test behave:compose_hooks-4-estat
4090 ${cat} ./.tnotes >> "${MBOX}"
4092 check behave:compose_hooks-4 - "${MBOX}" '3038884027 7516'
4094 t_epilog
4097 t_behave_C_opt_customhdr() {
4098 t_prolog t_behave_C_opt_customhdr
4099 TRAP_EXIT_ADDONS="./.t*"
4101 ${cat} <<-_EOT > ./.tsendmail.sh
4102 #!${SHELL} -
4103 (echo 'From CimicifugaRacemosa Mon Dec 25 21:33:40 2017' &&
4104 ${cat} && echo
4105 ) >> "${MBOX}"
4106 _EOT
4107 chmod 0755 ./.tsendmail.sh
4109 echo bla |
4110 ${MAILX} ${ARGS} -Smta=./.tsendmail.sh \
4111 -C 'C-One : Custom One Body' \
4112 -C 'C-Two:CustomTwoBody' \
4113 -S customhdr='chdr1: chdr1 body, chdr2:chdr2 body' \
4114 this-goes@nowhere >./.tall 2>&1
4115 ex0_test behave:C_opt_customhdr-1-estat
4116 ${cat} ./.tall >> "${MBOX}"
4117 check behave:C_opt_customhdr-1 0 "${MBOX}" '2400078426 195'
4119 ${rm} -f "${MBOX}"
4120 printf 'm this-goes@nowhere\nbody\n!.
4121 unset customhdr
4122 m this-goes2@nowhere\nbody2\n!.
4123 set customhdr=%ccustom1 : custom1 body%c
4124 m this-goes2@nowhere\nbody2\n!.
4125 set customhdr=%ccustom1 : custom1\\, body , custom2: custom2 body%c
4126 m this-goes3@nowhere\nbody3\n!.
4127 ' "'" "'" "'" "'" |
4128 ${MAILX} ${ARGS} -Smta=./.tsendmail.sh -Sescape=! \
4129 -C 'C-One : Custom One Body' \
4130 -C 'C-Two:CustomTwoBody' \
4131 -S customhdr='chdr1: chdr1 body, chdr2:chdr2 body' \
4132 >./.tall 2>&1
4133 ex0_test behave:C_opt_customhdr-2-estat
4134 ${cat} ./.tall >> "${MBOX}"
4135 check behave:C_opt_customhdr-2 0 "${MBOX}" '3546878678 752'
4137 t_epilog
4140 t_behave_mass_recipients() {
4141 t_prolog t_behave_mass_recipients
4142 TRAP_EXIT_ADDONS="./.t*"
4144 ${cat} <<-_EOT > ./.tsendmail.sh
4145 #!${SHELL} -
4146 (echo 'From Eucalyptus Sat Jul 08 21:14:57 2017' && ${cat} && echo
4147 ) >> "${MBOX}"
4148 _EOT
4149 chmod 0755 ./.tsendmail.sh
4151 ${cat} <<'__EOT__' > ./.trc
4152 define bail {
4153 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
4155 define ins_addr {
4156 wysh set nr=$1 hn=$2
4157 echo "~$hn $hn$nr@$hn"; echo '~:echo $?'; read es
4158 if [ "$es" -ne 0 ]
4159 xcall bail "ins_addr $hn 1-$nr"
4161 vput vexpr nr + $nr 1
4162 if [ "$nr" -le "$maximum" ]
4163 xcall ins_addr $nr $hn
4166 define bld_alter {
4167 wysh set nr=$1 hn=$2
4168 alternates $hn$nr@$hn
4169 vput vexpr nr + $nr 2
4170 if [ "$nr" -le "$maximum" ]
4171 xcall bld_alter $nr $hn
4174 define t_ocs {
4175 read ver
4176 call ins_addr 1 t
4177 call ins_addr 1 c
4178 call ins_addr 1 b
4180 define t_ocl {
4181 if [ "$t_remove" != '' ]
4182 call bld_alter 1 t
4183 call bld_alter 2 c
4186 set on-compose-splice=t_ocs on-compose-leave=t_ocl
4187 __EOT__
4189 printf 'm this-goes@nowhere\nbody\n!.\n' |
4190 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
4191 -X'source ./.trc' -Smta=./.tsendmail.sh -Smaximum=2001 \
4192 >./.tall 2>&1
4193 ex0_test behave:mass_recipients-1-estat
4194 ${cat} ./.tall >> "${MBOX}"
4195 check behave:mass_recipients-1 - "${MBOX}" '2912243346 51526'
4197 ${rm} -f "${MBOX}"
4198 printf 'm this-goes@nowhere\nbody\n!.\n' |
4199 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
4200 -St_remove=1 -X'source ./.trc' -Smta=./.tsendmail.sh -Smaximum=2001 \
4201 >./.tall 2>&1
4202 ex0_test behave:mass_recipients-2-estat
4203 ${cat} ./.tall >> "${MBOX}"
4204 check behave:mass_recipients-2 - "${MBOX}" '4097804632 34394'
4206 t_epilog
4209 t_behave_mime_types_load_control() {
4210 t_prolog t_behave_mime_types_load_control
4211 TRAP_EXIT_ADDONS="./.t*"
4213 ${cat} <<-_EOT > ./.tmts1
4214 @ application/mathml+xml mathml
4215 _EOT
4216 ${cat} <<-_EOT > ./.tmts2
4217 @ x-conference/x-cooltalk ice
4218 @ aga-aga aga
4219 @ application/aga-aga aga
4220 _EOT
4222 ${cat} <<-_EOT > ./.tmts1.mathml
4223 <head>nonsense ML</head>
4224 _EOT
4225 ${cat} <<-_EOT > ./.tmts2.ice
4226 Icy, icy road.
4227 _EOT
4228 printf 'of which the c\x01rack is coming soon' > ./.tmtsx.doom
4229 printf 'of which the c\x01rack is coming soon' > ./.tmtsx.aga
4231 printf '
4232 m %s
4233 Schub-di-du
4234 ~@ ./.tmts1.mathml
4235 ~@ ./.tmts2.ice
4236 ~@ ./.tmtsx.doom
4237 ~@ ./.tmtsx.aga
4239 File %s
4240 from*
4241 type
4243 ' "${MBOX}" "${MBOX}" |
4244 ${MAILX} ${ARGS} \
4245 -Smimetypes-load-control=f=./.tmts1,f=./.tmts2 \
4246 > ./.tout 2>&1
4247 ex0_test behave:mime_types_load_control-1-estat
4248 ${cat} "${MBOX}" >> ./.tout
4249 check behave:mime_types_load_control-1 - ./.tout '1441260727 2449'
4251 echo type | ${MAILX} ${ARGS} -R \
4252 -Smimetypes-load-control=f=./.tmts1,f=./.tmts3 \
4253 -f "${MBOX}" >> ./.tout 2>&1
4254 check behave:mime_types_load_control-2 0 ./.tout '1441391438 3646'
4256 t_epilog
4259 t_behave_lreply_futh_rth_etc() {
4260 t_prolog t_behave_lreply_futh_rth_etc
4261 TRAP_EXIT_ADDONS="./.t*"
4263 ${cat} <<-_EOT > ./.tsendmail.sh
4264 #!${SHELL} -
4265 (echo 'From HumulusLupulus Thu Jul 27 14:41:20 2017' && ${cat} && echo
4266 ) >> "${MBOX}"
4267 _EOT
4268 chmod 0755 ./.tsendmail.sh
4270 ${cat} <<-_EOT > ./.tmbox
4271 From neverneverland Sun Jul 23 13:46:25 2017
4272 Subject: Bugstop: five miles out 1
4273 Reply-To: mister originator2 <mr2@originator>, bugstop@five.miles.out
4274 From: mister originator <mr@originator>
4275 To: bugstop-commit@five.miles.out, laber@backe.eu
4276 Cc: is@a.list
4277 Mail-Followup-To: bugstop@five.miles.out, laber@backe.eu, is@a.list
4278 In-reply-to: <20170719111113.bkcMz%laber@backe.eu>
4279 Date: Wed, 19 Jul 2017 09:22:57 -0400
4280 Message-Id: <20170719132257.766AF781267@originator>
4281 Status: RO
4283 > |Sorry, I think I misunderstand something. I would think that
4285 That's appalling.
4287 From neverneverland Fri Jul 7 22:39:11 2017
4288 Subject: Bugstop: five miles out 2
4289 Reply-To: mister originator2<mr2@originator>,bugstop@five.miles.out,is@a.list
4290 Content-Transfer-Encoding: 7bit
4291 From: mister originator <mr@originator>
4292 To: bugstop-commit@five.miles.out
4293 Cc: is@a.list
4294 Message-ID: <149945963975.28888.6950788126957753723.reportbug@five.miles.out>
4295 Date: Fri, 07 Jul 2017 16:33:59 -0400
4296 Status: R
4298 capable of changing back.
4300 From neverneverland Fri Jul 7 22:42:00 2017
4301 Subject: Bugstop: five miles out 3
4302 Reply-To: mister originator2 <mr2@originator>, bugstop@five.miles.out
4303 Content-Transfer-Encoding: 7bit
4304 From: mister originator <mr@originator>
4305 To: bugstop-commit@five.miles.out
4306 Cc: is@a.list
4307 Message-ID: <149945963975.28888.6950788126957753746.reportbug@five.miles.out>
4308 Date: Fri, 07 Jul 2017 16:33:59 -0400
4309 List-Post: <mailto:bugstop@five.miles.out>
4310 Status: R
4312 are you ready, boots?
4314 From neverneverland Sat Aug 19 23:15:00 2017
4315 Subject: Bugstop: five miles out 4
4316 Reply-To: mister originator2 <mr2@originator>, bugstop@five.miles.out
4317 Content-Transfer-Encoding: 7bit
4318 From: mister originator <mr@originator>
4319 To: bugstop@five.miles.out
4320 Cc: is@a.list
4321 Message-ID: <149945963975.28888.6950788126qtewrqwer.reportbug@five.miles.out>
4322 Date: Fri, 07 Jul 2017 16:33:59 -0400
4323 List-Post: <mailto:bugstop@five.miles.out>
4324 Status: R
4326 are you ready, boots?
4327 _EOT
4331 ${cat} <<-'_EOT' | ${MAILX} ${ARGS} -Sescape=! -Smta=./.tsendmail.sh \
4332 -Rf ./.tmbox >> "${MBOX}" 2>&1
4333 define r {
4334 wysh set m="This is text of \"reply ${1}."
4335 reply 1 2 3
4336 !I m
4339 !I m
4342 !I m
4345 echo -----After reply $1.1 - $1.3: $?/$^ERRNAME
4347 define R {
4348 wysh set m="This is text of \"Reply ${1}."
4349 eval Reply $2
4350 !I m
4351 !I 2
4354 echo -----After Reply $1.$2: $?/$^ERRNAME
4356 define _Lh {
4357 read protover
4358 echo '~I m'
4359 echo '~I n'
4360 echo '".'
4362 define _Ls {
4363 wysh set m="This is text of \"Lreply ${1}." on-compose-splice=_Lh n=$2
4364 eval Lreply $2
4366 define L {
4367 # We need two indirections for this test: one for the case that Lreply
4368 # fails because of missing recipients: we need to read EOF next, thus
4369 # place this in _Ls last; and second for the succeeding cases EOF is
4370 # not what these should read, so go over the backside and splice it in!
4371 call _Ls "$@"
4372 echo -----After Lreply $1.$2: $?/$^ERRNAME
4374 define x {
4375 localopts call-fixate yes
4376 call r $1
4377 call R $1 1; call R $1 2; call R $1 3; call R $1 4
4378 call L $1 1; call L $1 2; call L $1 3
4380 define tweak {
4381 echo;echo '===== CHANGING === '"$*"' =====';echo
4382 eval "$@"
4385 set from=laber@backe.eu
4386 mlist is@a.list
4387 call x 1
4388 call tweak set reply-to-honour
4389 call x 2
4390 call tweak set followup-to
4391 call x 3
4392 call tweak set followup-to-honour
4393 call x 4
4394 call tweak mlist bugstop@five.miles.out
4395 call x 5
4396 call tweak mlsubscribe bugstop@five.miles.out
4397 call x 6
4398 call tweak set recipients-in-cc
4399 call x 7
4400 _EOT
4402 check behave:lreply_futh_rth_etc-1 0 "${MBOX}" '940818845 29373'
4406 ${cat} <<-_EOT > ./.tmbox
4407 From tom@i-i.example Thu Oct 26 03:15:55 2017
4408 Date: Wed, 25 Oct 2017 21:15:46 -0400
4409 From: tom <tom@i-i.example>
4410 To: Steffen Nurpmeso <steffen@sdaoden.eu>
4411 Cc: tom <tom@i-i.example>
4412 Subject: Re: xxxx yyyyyyyy configure does not really like a missing zzzzz
4413 Message-ID: <20171026011546.GA11643@i-i.example>
4414 Reply-To: tom@i-i.example
4415 References: <20171025214601.T2pNd%steffen@sdaoden.eu>
4416 In-Reply-To: <20171025214601.T2pNd%steffen@sdaoden.eu>
4417 Status: R
4419 The report's useful :-)
4420 _EOT
4422 printf 'reply 1\nthank you\n!.\n' |
4423 ${MAILX} ${ARGS} -Sescape=! -Smta=./.tsendmail.sh -Sreply-to-honour \
4424 -Rf ./.tmbox > "${MBOX}" 2>&1
4425 check behave:lreply_futh_rth_etc-2 0 "${MBOX}" '1045866991 331'
4427 t_epilog
4430 t_behave_xxxheads_rfc2047() {
4431 t_prolog t_behave_xxxheads_rfc2047
4432 TRAP_EXIT_ADDONS="./.t*"
4434 ${cat} <<-_EOT > ./.tsendmail.sh
4435 #!${SHELL} -
4436 (echo 'From GentianaLutea Mon Dec 04 17:15:29 2017' && ${cat} &&
4437 echo) >> "${MBOX}"
4438 _EOT
4439 chmod 0755 ./.tsendmail.sh
4442 ${rm} -f "${MBOX}"
4443 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
4444 -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̲' \
4445 "${MBOX}"
4446 check behave:xxxheads_rfc2047-1 0 "${MBOX}" '3370931614 375'
4448 # Single word (overlong line split -- bad standard! Requires injection of
4449 # artificial data!! But can be prevented by using RFC 2047 encoding)
4450 ${rm} -f "${MBOX}"
4451 i=`${awk} 'BEGIN{for(i=0; i<92; ++i) printf "0123456789_"}'`
4452 echo | ${MAILX} ${ARGS} -s "${i}" "${MBOX}"
4453 check behave:xxxheads_rfc2047-2 0 "${MBOX}" '489922370 1718'
4455 # Combination of encoded words, space and tabs of varying sort
4456 ${rm} -f "${MBOX}"
4457 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
4458 -s "1Abrä Kaspas1 2Abra Katä b_kaspas2 \
4459 3Abrä Kaspas3 4Abrä Kaspas4 5Abrä Kaspas5 \
4460 6Abra Kaspas6 7Abrä Kaspas7 8Abra Kaspas8 \
4461 9Abra Kaspastäb4-3 10Abra Kaspas1 _ 11Abra Katäb1 \
4462 12Abra Kadabrä1 After Tab after Täb this is NUTS" \
4463 "${MBOX}"
4464 check behave:xxxheads_rfc2047-3 0 "${MBOX}" '1676887734 591'
4466 # Overlong multibyte sequence that must be forcefully split
4467 # todo This works even before v15.0, but only by accident
4468 ${rm} -f "${MBOX}"
4469 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
4470 -s "✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
4471 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
4472 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄" \
4473 "${MBOX}"
4474 check behave:xxxheads_rfc2047-4 0 "${MBOX}" '3029301775 659'
4476 # Trailing WS
4477 ${rm} -f "${MBOX}"
4478 echo | ${MAILX} ${ARGS} \
4479 -s "1-1 B2 B3 B4 B5 B6 B\
4480 1-2 B2 B3 B4 B5 B6 B\
4481 1-3 B2 B3 B4 B5 B6 B\
4482 1-4 B2 B3 B4 B5 B6 B\
4483 1-5 B2 B3 B4 B5 B6 B\
4484 1-6 B2 B3 B4 B5 B6 " \
4485 "${MBOX}"
4486 check behave:xxxheads_rfc2047-5 0 "${MBOX}" '4126167195 297'
4488 # Leading and trailing WS
4489 ${rm} -f "${MBOX}"
4490 echo | ${MAILX} ${ARGS} \
4491 -s " 2-1 B2 B3 B4 B5 B6 B\
4492 1-2 B2 B3 B4 B5 B6 B\
4493 1-3 B2 B3 B4 B5 B6 B\
4494 1-4 B2 B3 B4 B5 B6 " \
4495 "${MBOX}"
4496 check behave:xxxheads_rfc2047-6 0 "${MBOX}" '3600624479 236'
4498 # RFC 2047 in an address field! (Missing test caused v14.9.6!)
4499 ${rm} -f "${MBOX}"
4500 echo "Dat Früchtchen riecht häußlich" |
4501 ${MAILX} ${ARGS} ${ADDARG_UNI} -Sfullnames -Smta=./.tsendmail.sh \
4502 -s Hühöttchen \
4503 'Schnödes "Früchtchen" <do@du> (Hä!)'
4504 check behave:xxxheads_rfc2047-7 0 "${MBOX}" '800505986 368'
4506 # RFC 2047 in an address field, and iconv involved
4507 if have_feat iconv; then
4508 ${rm} -f "${MBOX}"
4509 ${cat} > ./.trebox <<_EOT
4510 From zaza@exam.ple Fri Mar 2 21:31:56 2018
4511 Date: Fri, 2 Mar 2018 20:31:45 +0000
4512 From: z=?iso-8859-1?Q?=E1?=za <zaza@exam.ple>
4513 To: dude <dude@exam.ple>
4514 Subject: houston(...)
4515 Message-ID: <abra@1>
4516 MIME-Version: 1.0
4517 Content-Type: text/plain; charset=iso-8859-1
4518 Content-Disposition: inline
4519 Content-Transfer-Encoding: 8bit
4521 _EOT
4522 echo reply | ${MAILX} ${ARGS} ${ADDARG_UNI} \
4523 -Sfullnames -Sreply-in-same-charset \
4524 -Smta=./.tsendmail.sh -Rf ./.trebox
4525 check behave:xxxheads_rfc2047-8 0 "${MBOX}" '2821484185 280'
4526 else
4527 echo 'behave:xxxheads_rfc2047-8: iconv unsupported, skipped'
4530 t_epilog
4533 t_behave_rfc2231() {
4534 t_prolog t_behave_rfc2231
4535 TRAP_EXIT_ADDONS="./.t*"
4538 mkdir ./.ttt || exit 1
4539 cd ./.ttt || exit 2
4540 : > "ma'ger.txt"
4541 : > "mä'ger.txt"
4542 : > 'diet\ is \curd.txt'
4543 : > 'diet "is" curd.txt'
4544 : > höde-tröge.txt
4545 : > 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
4546 : > höde__tröge__müde__dätte__hätte__vuelle__guelle__aese__aesse__sauerliche__kräuter__österliche__grüße__mäh.txt
4547 : > hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt
4548 : > ✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt
4550 echo bla | ${MAILX} ${ARGS} ${ADDARG_UNI} \
4551 -a "./.ttt/ma'ger.txt" -a "./.ttt/mä'ger.txt" \
4552 -a './.ttt/diet\ is \curd.txt' -a './.ttt/diet "is" curd.txt' \
4553 -a ./.ttt/höde-tröge.txt \
4554 -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 \
4555 -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 \
4556 -a ./.ttt/hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt \
4557 -a ./.ttt/✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt \
4558 "${MBOX}"
4559 check behave:rfc2231-1 0 "${MBOX}" '684985954 3092'
4561 # `resend' test, reusing $MBOX
4562 printf "Resend ./.t2\nx\n" | ${MAILX} ${ARGS} -Rf "${MBOX}"
4563 check behave:rfc2231-2 0 ./.t2 '684985954 3092'
4565 printf "resend ./.t3\nx\n" | ${MAILX} ${ARGS} -Rf "${MBOX}"
4566 check behave:rfc2231-3 0 ./.t3 '3130352658 3148'
4568 t_epilog
4571 t_behave_iconv_mbyte_base64() { # TODO uses sed(1) and special *headline*!!
4572 t_prolog t_behave_iconv_mbyte_base64
4573 TRAP_EXIT_ADDONS="./.t*"
4575 if [ -n "${UTF8_LOCALE}" ] && have_feat iconv; then
4576 if (</dev/null iconv -f ascii -t iso-2022-jp) >/dev/null 2>&1 ||
4577 (</dev/null iconv -f ascii -t euc-jp) >/dev/null 2>&1; then
4579 else
4580 echo 'behave:iconv_mbyte_base64: unsupported, skipped'
4581 return
4583 else
4584 echo 'behave:iconv_mbyte_base64: unsupported, skipped'
4585 return
4588 ${cat} <<-_EOT > ./.tsendmail.sh
4589 #!${SHELL} -
4590 (echo 'From DroseriaRotundifolia Thu Aug 03 17:26:25 2017' && ${cat} &&
4591 echo) >> "${MBOX}"
4592 _EOT
4593 chmod 0755 ./.tsendmail.sh
4595 if (</dev/null iconv -f ascii -t iso-2022-jp) >/dev/null 2>&1; then
4596 ${cat} <<-'_EOT' | LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} \
4597 -Smta=./.tsendmail.sh \
4598 -Sescape=! -Smime-encoding=base64 2>./.terr
4599 set ttycharset=utf-8 sendcharsets=iso-2022-jp
4600 m t1@exam.ple
4601 !s Japanese from UTF-8 to ISO-2022-JP
4602 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
4604 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
4607 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
4609 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
4612 set ttycharset=iso-2022-jp charset-7bit=iso-2022-jp sendcharsets=utf-8
4613 m t2@exam.ple
4614 !s Japanese from ISO-2022-JP to UTF-8, eh, no, also ISO-2022-JP
4615 \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
4617 \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
4620 \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
4622 \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
4624 _EOT
4625 # May not presume iconv output as long as roundtrip possible [489a7122]
4626 ex0_test behave:iconv_mbyte_base64-1-estat
4627 ${awk} 'BEGIN{h=1}/^$/{++h;next}{if(h % 2 == 1)print}' \
4628 < "${MBOX}" > ./.tcksum
4629 check behave:iconv_mbyte_base64-1 - ./.tcksum '2694609714 520'
4630 check behave:iconv_mbyte_base64-2 - ./.terr '4294967295 0'
4632 printf 'eval f 1; eval write ./.twrite; eval type 1; eval type 2\n' |
4633 LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} \
4634 -S headline="%>%a%m %-18f %-16d %i%-s" \
4635 -Rf "${MBOX}" >./.tlog 2>&1
4636 check behave:iconv_mbyte_base64-3 0 ./.twrite '1259742080 686'
4637 #check behave:iconv_mbyte_base64-4 - ./.tlog '3214068822 2123'
4638 ${sed} -e '/^\[-- M/d' < ./.tlog > ./.txlog
4639 check behave:iconv_mbyte_base64-4 - ./.txlog '3659773472 2035'
4640 else
4641 echo 'behave:iconv_mbyte_base64: ISO-2022-JP unsupported, skipping 1-4'
4644 if (</dev/null iconv -f ascii -t euc-jp) >/dev/null 2>&1; then
4645 rm -f "${MBOX}" ./.twrite
4646 ${cat} <<-'_EOT' | LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} \
4647 -Smta=./.tsendmail.sh \
4648 -Sescape=! -Smime-encoding=base64 2>./.terr
4649 set ttycharset=utf-8 sendcharsets=euc-jp
4650 m t1@exam.ple
4651 !s Japanese from UTF-8 to EUC-JP
4652 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
4654 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
4657 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
4659 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
4662 set ttycharset=EUC-JP sendcharsets=utf-8
4663 m t2@exam.ple
4664 !s Japanese from EUC-JP to UTF-8
4665 ¥·¥¸¥å¥¦¥«¥é²Ê¡Ê¥·¥¸¥å¥¦¥«¥é¤«¡¢³Ø̾ Paridae¡Ë¤Ï¡¢Ä»Îॹ¥º¥áÌܤβʤǤ¢¤ë¡£¥·¥¸¥å¥¦¥«¥é¡Ê»Í½½¿ý¡Ë¤ÈÁí¾Î¤µ¤ì¤ë¤¬¡¢¶¹µÁ¤Ë¤Ï¤³¤Î1¼ï¤ò¥·¥¸¥å¥¦¥«¥é¤È¸Æ¤Ö¡£
4667 ¥«¥ó¥à¥ê¥¬¥é¡Ê³Ø̾Parus cristatus¡Ë¤Ï¡¢¥¹¥º¥áÌÜ¥·¥¸¥å¥¦¥«¥é²Ê¤ËʬÎव¤ì¤ëÄ»Îà¤Î°ì¼ï¡£
4670 ¥«¥ó¥à¥ê¥¬¥é¡Ê³Ø̾Parus cristatus¡Ë¤Ï¡¢¥¹¥º¥áÌÜ¥·¥¸¥å¥¦¥«¥é²Ê¤ËʬÎव¤ì¤ëÄ»Îà¤Î°ì¼ï¡£
4672 ¥·¥¸¥å¥¦¥«¥é²Ê¡Ê¥·¥¸¥å¥¦¥«¥é¤«¡¢³Ø̾ Paridae¡Ë¤Ï¡¢Ä»Îॹ¥º¥áÌܤβʤǤ¢¤ë¡£¥·¥¸¥å¥¦¥«¥é¡Ê»Í½½¿ý¡Ë¤ÈÁí¾Î¤µ¤ì¤ë¤¬¡¢¶¹µÁ¤Ë¤Ï¤³¤Î1¼ï¤ò¥·¥¸¥å¥¦¥«¥é¤È¸Æ¤Ö¡£
4674 _EOT
4675 ex0_test behave:iconv_mbyte_base64-5-estat
4676 ${awk} 'BEGIN{h=1}/^$/{++h;next}{if(h % 2 == 1)print}' \
4677 < "${MBOX}" > ./.tcksum
4678 check behave:iconv_mbyte_base64-5 - ./.tcksum '2870183985 473'
4679 check behave:iconv_mbyte_base64-6 - ./.terr '4294967295 0'
4681 printf 'eval f 1; eval write ./.twrite; eval type 1; eval type 2\n' |
4682 LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} \
4683 -S headline="%>%a%m %-18f %-16d %i%-s" \
4684 -Rf "${MBOX}" >./.tlog 2>&1
4685 check behave:iconv_mbyte_base64-7 0 ./.twrite '1259742080 686'
4686 #check behave:iconv_mbyte_base64-8 - ./.tlog '2506063395 2075'
4687 ${sed} -e '/^\[-- M/d' < ./.tlog > ./.txlog
4688 check behave:iconv_mbyte_base64-8 - ./.txlog '2528199891 1988'
4689 else
4690 echo 'behave:iconv_mbyte_base64: EUC-JP unsupported, skipping 5-8'
4693 t_epilog
4696 t_behave_iconv_mainbody() {
4697 t_prolog t_behave_iconv_mainbody
4698 TRAP_EXIT_ADDONS="./.t*"
4700 if [ -n "${UTF8_LOCALE}" ] && have_feat iconv; then
4702 else
4703 echo 'behave:iconv_mainbody: unsupported, skipped'
4704 return
4707 ${cat} <<-_EOT > ./.tsendmail.sh
4708 #!${SHELL} -
4709 (echo 'From HamamelisVirginiana Fri Oct 20 16:23:21 2017' && ${cat} &&
4710 echo) >> "${MBOX}"
4711 _EOT
4712 chmod 0755 ./.tsendmail.sh
4714 printf '–' | ${MAILX} ${ARGS} ${ADDARG_UNI} -Smta=./.tsendmail.sh \
4715 -S charset-7bit=us-ascii -S charset-8bit=utf-8 \
4716 -s '–' over-the@rain.bow 2>./.terr
4717 check behave:iconv_mainbody-1 0 "${MBOX}" '3634015017 251'
4718 check behave:iconv_mainbody-2 - ./.terr '4294967295 0'
4720 printf '–' | ${MAILX} ${ARGS} ${ADDARG_UNI} -Smta=./.tsendmail.sh \
4721 -S charset-7bit=us-ascii -S charset-8bit=us-ascii \
4722 -s '–' over-the@rain.bow 2>./.terr
4723 exn0_test behave:iconv_mainbody-3
4724 check behave:iconv_mainbody-3 - "${MBOX}" '3634015017 251'
4725 check behave:iconv_mainbody-4 - ./.terr '2579894983 148'
4727 # The different iconv(3) implementations use different replacement sequence
4728 # types (character-wise, byte-wise, and the character(s) used differ)
4729 i="${MAILX_ICONV_MODE}"
4730 if [ -n "${i}" ]; then
4731 printf 'p\nx\n' | ${MAILX} ${ARGS} -Rf "${MBOX}" >./.tout 2>./.terr
4732 j=${?}
4733 ex0_test behave:iconv_mainbody-5-0 ${j}
4734 check behave:iconv_mainbody-5-1 - ./.terr '4294967295 0'
4735 if [ ${i} -eq 13 ]; then
4736 check behave:iconv_mainbody-5-2 - ./.tout '189327996 283'
4737 elif [ ${i} -eq 12 ]; then
4738 check behave:iconv_mainbody-5-3 - ./.tout '1959197095 283'
4739 elif [ ${i} -eq 3 ]; then
4740 check behave:iconv_mainbody-5-4 - ./.tout '3196380198 279'
4741 else
4742 check behave:iconv_mainbody-5-5 - ./.tout '3760313827 279'
4744 else
4745 echo 'behave:iconv_mainbody-5: unsupported, skipped'
4748 t_epilog
4751 t_behave_binary_mainbody() {
4752 t_prolog t_behave_binary_mainbody
4753 TRAP_EXIT_ADDONS="./.t*"
4755 printf 'abra\0\nka\r\ndabra' |
4756 ${MAILX} ${ARGS} ${ADDARG_UNI} -s 'binary with carriage-return!' \
4757 "${MBOX}" 2>./.terr
4758 check behave:binary_mainbody-1 0 "${MBOX}" '2430168141 243'
4759 check behave:binary_mainbody-2 - ./.terr '4294967295 0'
4761 printf 'p\necho\necho writing now\nwrite ./.twrite\n' |
4762 ${MAILX} ${ARGS} -Rf \
4763 -Spipe-application/octet-stream="@* ${cat} > ./.tcat" \
4764 "${MBOX}" >./.tall 2>&1
4765 check behave:binary_mainbody-3 0 ./.tall '1151843761 324'
4766 check behave:binary_mainbody-4 - ./.tcat '3817108933 15'
4767 check behave:binary_mainbody-5 - ./.twrite '3817108933 15'
4769 t_epilog
4772 t_behave_q_t_etc_opts() {
4773 t_prolog t_behave_q_t_etc_opts
4774 TRAP_EXIT_ADDONS="./.t*"
4776 # Three tests for MIME encoding and (a bit) content classification.
4777 # At the same time testing -q FILE, < FILE and -t FILE
4778 t__put_body > ./.tin
4780 ${rm} -f "${MBOX}"
4781 < ./.tin ${MAILX} ${ARGS} ${ADDARG_UNI} \
4782 -a ./.tin -s "`t__put_subject`" "${MBOX}"
4783 check behave:q_t_etc_opts-1 0 "${MBOX}" '3570973309 6646'
4785 ${rm} -f "${MBOX}"
4786 < /dev/null ${MAILX} ${ARGS} ${ADDARG_UNI} \
4787 -a ./.tin -s "`t__put_subject`" -q ./.tin "${MBOX}"
4788 check behave:q_t_etc_opts-2 0 "${MBOX}" '3570973309 6646'
4790 ${rm} -f "${MBOX}"
4791 ( echo "To: ${MBOX}" && echo "Subject: `t__put_subject`" && echo &&
4792 ${cat} ./.tin
4793 ) | ${MAILX} ${ARGS} ${ADDARG_UNI} -Snodot -a ./.tin -t
4794 check behave:q_t_etc_opts-3 0 "${MBOX}" '3570973309 6646'
4796 t_epilog
4799 t_behave_s_mime() {
4800 have_feat smime || {
4801 echo 'behave:s/mime: unsupported, skipped'
4802 return
4805 t_prolog t_behave_s_mime
4806 TRAP_EXIT_ADDONS="./.t.conf ./.tkey.pem ./.tcert.pem ./.tpair.pem"
4807 TRAP_EXIT_ADDONS="${TRAP_EXIT_ADDONS} ./.VERIFY ./.DECRYPT ./.ENCRYPT"
4808 TRAP_EXIT_ADDONS="${TRAP_EXIT_ADDONS} ./.tsendmail.sh"
4810 printf 'behave:s/mime: .. generating test key and certificate ..\n'
4811 ${cat} <<-_EOT > ./.t.conf
4812 [ req ]
4813 default_bits = 1024
4814 default_keyfile = keyfile.pem
4815 distinguished_name = req_distinguished_name
4816 attributes = req_attributes
4817 prompt = no
4818 output_password =
4820 [ req_distinguished_name ]
4821 C = GB
4822 ST = Over the
4823 L = rainbow
4824 O = S-nail
4825 OU = S-nail.smime
4826 CN = S-nail.test
4827 emailAddress = test@localhost
4829 [ req_attributes ]
4830 challengePassword =
4831 _EOT
4832 openssl req -x509 -nodes -days 3650 -config ./.t.conf \
4833 -newkey rsa:1024 -keyout ./.tkey.pem -out ./.tcert.pem >/dev/null 2>&1
4834 ${cat} ./.tkey.pem ./.tcert.pem > ./.tpair.pem
4836 # Sign/verify
4837 printf 'behave:s/mime:sign/verify: '
4838 echo bla | ${MAILX} ${ARGS} \
4839 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
4840 -Ssmime-sign -Sfrom=test@localhost \
4841 -s 'S/MIME test' ./.VERIFY
4842 if [ $? -eq 0 ]; then
4843 printf 'ok\n'
4844 else
4845 printf 'failed\n'
4846 ESTAT=1
4847 t_epilog
4848 return
4851 ${awk} '
4852 BEGIN{ skip=0 }
4853 /^Content-Description: /{ skip = 2; print; next }
4854 /^$/{ if(skip) --skip }
4855 { if(!skip) print }
4857 < ./.VERIFY > "${MBOX}"
4858 check behave:s/mime:sign/verify:checksum - "${MBOX}" '2900817158 648'
4860 printf 'behave:s/mime:sign/verify:verify '
4861 printf 'verify\nx\n' |
4862 ${MAILX} ${ARGS} \
4863 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
4864 -Ssmime-sign -Sfrom=test@localhost \
4865 -Serrexit -R \
4866 -f ./.VERIFY >/dev/null 2>&1
4867 if [ $? -eq 0 ]; then
4868 printf 'ok\n'
4869 else
4870 printf 'failed\n'
4871 ESTAT=1
4872 t_epilog
4873 return
4876 printf 'behave:s/mime:sign/verify:disproof-1 '
4877 if openssl smime -verify -CAfile ./.tcert.pem \
4878 -in ./.VERIFY >/dev/null 2>&1; then
4879 printf 'ok\n'
4880 else
4881 printf 'failed\n'
4882 ESTAT=1
4883 t_epilog
4884 return
4887 # (signing +) encryption / decryption
4888 ${cat} <<-_EOT > ./.tsendmail.sh
4889 #!${SHELL} -
4890 (echo 'From Euphrasia Thu Apr 27 17:56:23 2017' && ${cat}) > ./.ENCRYPT
4891 _EOT
4892 chmod 0755 ./.tsendmail.sh
4894 printf 'behave:s/mime:encrypt+sign: '
4895 echo bla |
4896 ${MAILX} ${ARGS} \
4897 -Ssmime-force-encryption \
4898 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
4899 -Smta=./.tsendmail.sh \
4900 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
4901 -Ssmime-sign -Sfrom=test@localhost \
4902 -s 'S/MIME test' recei@ver.com
4903 if [ $? -eq 0 ]; then
4904 printf 'ok\n'
4905 else
4906 ESTAT=1
4907 printf 'error: encrypt+sign failed\n'
4910 ${sed} -e '/^$/,$d' < ./.ENCRYPT > "${MBOX}"
4911 check behave:s/mime:encrypt+sign:checksum - "${MBOX}" '1937410597 327'
4913 printf 'behave:s/mime:decrypt+verify: '
4914 printf 'decrypt ./.DECRYPT\nfi ./.DECRYPT\nverify\nx\n' |
4915 ${MAILX} ${ARGS} \
4916 -Ssmime-force-encryption \
4917 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
4918 -Smta=./.tsendmail.sh \
4919 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
4920 -Ssmime-sign -Sfrom=test@localhost \
4921 -Serrexit -R \
4922 -f ./.ENCRYPT >/dev/null 2>&1
4923 if [ $? -eq 0 ]; then
4924 printf 'ok\n'
4925 else
4926 ESTAT=1
4927 printf 'failed\n'
4930 ${awk} '
4931 BEGIN{ skip=0 }
4932 /^Content-Description: /{ skip = 2; print; next }
4933 /^$/{ if(skip) --skip }
4934 { if(!skip) print }
4936 < ./.DECRYPT > "${MBOX}"
4937 check behave:s/mime:decrypt+verify:checksum - "${MBOX}" '1720739247 931'
4939 printf 'behave:s/mime:decrypt+verify:disproof-1: '
4940 if (openssl smime -decrypt -inkey ./.tkey.pem -in ./.ENCRYPT |
4941 openssl smime -verify -CAfile ./.tcert.pem) >/dev/null 2>&1; then
4942 printf 'ok\n'
4943 else
4944 printf 'failed\n'
4945 ESTAT=1
4948 printf "behave:s/mime:encrypt: "
4949 echo bla | ${MAILX} ${ARGS} \
4950 -Ssmime-force-encryption \
4951 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
4952 -Smta=./.tsendmail.sh \
4953 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
4954 -Sfrom=test@localhost \
4955 -s 'S/MIME test' recei@ver.com
4956 if [ $? -eq 0 ]; then
4957 printf 'ok\n'
4958 else
4959 ESTAT=1
4960 printf 'failed\n'
4963 # Same as behave:s/mime:encrypt+sign:checksum above
4964 ${sed} -e '/^$/,$d' < ./.ENCRYPT > "${MBOX}"
4965 check behave:s/mime:encrypt:checksum - "${MBOX}" '1937410597 327'
4967 ${rm} -f ./.DECRYPT
4968 printf 'decrypt ./.DECRYPT\nx\n' | ${MAILX} ${ARGS} \
4969 -Ssmime-force-encryption \
4970 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
4971 -Smta=./.tsendmail.sh \
4972 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
4973 -Sfrom=test@localhost \
4974 -Serrexit -R \
4975 -f ./.ENCRYPT >/dev/null 2>&1
4976 check behave:s/mime:decrypt 0 "./.DECRYPT" '2624716890 422'
4978 printf 'behave:s/mime:decrypt:disproof-1: '
4979 if openssl smime -decrypt -inkey ./.tkey.pem \
4980 -in ./.ENCRYPT >/dev/null 2>&1; then
4981 printf 'ok\n'
4982 else
4983 printf 'failed\n'
4984 ESTAT=1
4987 t_epilog
4990 # t_content()
4991 # Some basic tests regarding correct sending of mails, via STDIN / -t / -q,
4992 # including basic MIME Content-Transfer-Encoding correctness (quoted-printable)
4993 # Note we unfortunately need to place some statements without proper
4994 # indentation because of continuation problems
4995 # xxx Note: t_content() was the first test (series) written. Today many
4996 # xxx aspects are (better) covered by other tests above, some are not.
4997 # xxx At some future date and time, convert the last remains not covered
4998 # xxx elsewhere to a real t_behave_* test and drop t_content()
4999 t_content() {
5000 t_prolog t_content
5002 # Test for [260e19d] (Juergen Daubert)
5003 ${rm} -f "${MBOX}"
5004 echo body | ${MAILX} ${ARGS} "${MBOX}"
5005 check content:004 0 "${MBOX}" '2917662811 98'
5007 # "Test for" [d6f316a] (Gavin Troy)
5008 ${rm} -f "${MBOX}"
5009 printf "m ${MBOX}\n~s subject1\nEmail body\n~.\nfi ${MBOX}\np\nx\n" |
5010 ${MAILX} ${ARGS} ${ADDARG_UNI} -Spipe-text/plain="@* ${cat}" > "${BODY}"
5011 check content:006 0 "${MBOX}" '2099098650 122'
5012 check content:006-1 - "${BODY}" '794542938 174'
5014 # "Test for" [c299c45] (Peter Hofmann) TODO shouldn't end up QP-encoded?
5015 ${rm} -f "${MBOX}"
5016 ${awk} 'BEGIN{
5017 for(i = 0; i < 10000; ++i)
5018 printf "\xC3\xBC"
5019 #printf "\xF0\x90\x87\x90"
5020 }' | ${MAILX} ${ARGS} ${ADDARG_UNI} -s TestSubject "${MBOX}"
5021 check content:007 0 "${MBOX}" '534262374 61816'
5023 t_epilog
5026 t__put_subject() {
5027 # MIME encoding (QP) stress message subject
5028 printf 'Äbrä Kä?dä=brö Fü?di=bus? '\
5029 'adadaddsssssssddddddddddddddddddddd'\
5030 'ddddddddddddddddddddddddddddddddddd'\
5031 'ddddddddddddddddddddddddddddddddddd'\
5032 'dddddddddddddddddddd Hallelulja? Od'\
5033 'er?? eeeeeeeeeeeeeeeeeeeeeeeeeeeeee'\
5034 'eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'\
5035 'eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee f'\
5036 'fffffffffffffffffffffffffffffffffff'\
5037 'fffffffffffffffffffff ggggggggggggg'\
5038 'ggggggggggggggggggggggggggggggggggg'\
5039 'ggggggggggggggggggggggggggggggggggg'\
5040 'ggggggggggggggggggggggggggggggggggg'\
5041 'gggggggggggggggg'
5044 t__put_body() {
5045 # MIME encoding (QP) stress message body
5046 printf \
5047 'Ich bin eine DÖS-Datäi mit sehr langen Zeilen und auch '\
5048 'sonst bin ich ganz schön am Schleudern, da kannste denke '\
5049 "wasde willst, gelle, gelle, gelle, gelle, gelle.\r\n"\
5050 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst \r\n"\
5051 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1\r\n"\
5052 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12\r\n"\
5053 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123\r\n"\
5054 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1234\r\n"\
5055 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12345\r\n"\
5056 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123456\r\n"\
5057 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1234567\r\n"\
5058 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12345678\r\n"\
5059 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123456789\r\n"\
5060 "Unn ausserdem habe ich trailing SP/HT/SP/HT whitespace \r\n"\
5061 "Unn ausserdem habe ich trailing HT/SP/HT/SP whitespace \r\n"\
5062 "auf den zeilen vorher.\r\n"\
5063 "From am Zeilenbeginn und From der Mitte gibt es auch.\r\n"\
5064 ".\r\n"\
5065 "Die letzte Zeile war nur ein Punkt.\r\n"\
5066 "..\r\n"\
5067 "Das waren deren zwei.\r\n"\
5068 " \r\n"\
5069 "Die letzte Zeile war ein Leerschritt.\n"\
5070 "=VIER = EQUAL SIGNS=ON A LINE=\r\n"\
5071 "Prösterchen.\r\n"\
5072 ".\n"\
5073 "Die letzte Zeile war nur ein Punkt, mit Unix Zeilenende.\n"\
5074 "..\n"\
5075 "Das waren deren zwei. ditto.\n"\
5076 "Prösterchen.\n"\
5077 "Unn ausseerdem habe ich trailing SP/HT/SP/HT whitespace \n"\
5078 "Unn ausseerdem habe ich trailing HT/SP/HT/SP whitespace \n"\
5079 "auf den zeilen vorher.\n"\
5080 "ditto.\n"\
5081 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.\n"\
5082 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.1"\
5083 "\n"\
5084 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
5085 "\n"\
5086 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
5087 "3\n"\
5088 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
5089 "34\n"\
5090 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
5091 "345\n"\
5092 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
5093 "3456\n"\
5094 "QP am Zeilenende über soft-nl hinweg\n"\
5095 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
5096 "ö123\n"\
5097 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
5098 "1ö23\n"\
5099 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
5100 "12ö3\n"\
5101 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
5102 "123ö\n"\
5103 "=VIER = EQUAL SIGNS=ON A LINE=\n"\
5104 " \n"\
5105 "Die letzte Zeile war ein Leerschritt.\n"\
5109 t_all() {
5110 # if have_feat devel; then
5111 # ARGS="${ARGS} -Smemdebug"
5112 # export ARGS
5113 # fi
5115 if [ -n "${UTF8_LOCALE}" ]; then
5116 printf 'Using Unicode locale %s\n' "${UTF8_LOCALE}"
5117 else
5118 printf 'No Unicode locale found, disabling Unicode tests\n'
5121 t_behave
5122 t_content
5125 if [ -z "${CHECK_ONLY}${MAE_TEST}" ]; then
5126 cc_all_configs
5127 elif [ -z "${MAE_TEST}" ] || [ ${#} -eq 0 ]; then
5128 t_all
5129 else
5130 while [ ${#} -gt 0 ]; do
5131 ${1}
5132 shift
5133 done
5136 [ ${ESTAT} -eq 0 ] && echo Ok || echo >&2 'Errors occurred'
5138 exit ${ESTAT}
5139 # s-sh-mode