Fix [9e1c55f6]: make t_behave_attachments() reproducible!
[s-mailx.git] / cc-test.sh
blob34e2235394f32bac840ff5fb859c35905bc6057e
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_NOEXTMD5"] = 1
138 NOTME["OPT_ASAN_ADDRESS"] = 1
139 NOTME["OPT_ASAN_MEMORY"] = 1
140 NOTME["OPT_FORCED_STACKPROT"] = 1
141 NOTME["OPT_NOMEMDBG"] = 1
142 NOTME["OPT_NYD2"] = 1
143 i = 0
145 /^[[:space:]]*OPT_/ {
146 sub(/^[[:space:]]*/, "")
147 # This bails for UnixWare 7.1.4 awk(1), but preceeding = with \
148 # does not seem to be a compliant escape for =
149 #sub(/=.*$/, "")
150 $1 = substr($1, 1, index($1, "=") - 1)
151 if (NOTME[$1])
152 next
153 data[i++] = $1
155 END {
156 # Doing this completely sequentially and not doing make distclean in
157 # between runs should effectively result in lesser compilations.
158 # It is completely dumb nonetheless... TODO
159 for (j = 1; j < i; ++j) {
160 for (k = 1; k < j; ++k)
161 printf data[k] "=1 "
162 for (k = j; k < i; ++k)
163 printf data[k] "=0 "
164 printf "OPT_AUTOCC=1\n"
166 for (j = 1; j < i; ++j) {
167 for (k = 1; k < j; ++k)
168 printf data[k] "=0 "
169 for (k = j; k < i; ++k)
170 printf data[k] "=1 "
171 printf "OPT_AUTOCC=1\n"
173 # With debug
174 for (j = 1; j < i; ++j) {
175 for (k = 1; k < j; ++k)
176 printf data[k] "=1 "
177 for (k = j; k < i; ++k)
178 printf data[k] "=0 "
179 printf "OPT_AUTOCC=1\n"
180 printf "OPT_DEBUG=1\n"
182 for (j = 1; j < i; ++j) {
183 for (k = 1; k < j; ++k)
184 printf data[k] "=0 "
185 for (k = j; k < i; ++k)
186 printf data[k] "=1 "
187 printf "OPT_AUTOCC=1\n"
188 printf "OPT_DEBUG=1\n"
191 printf "CONFIG=NULL OPT_AUTOCC=0\n"
192 printf "CONFIG=NULL OPT_AUTOCC=1\n"
193 printf "CONFIG=NULLI OPT_AUTOCC=0\n"
194 printf "CONFIG=NULLI OPT_AUTOCC=1\n"
195 printf "CONFIG=MINIMAL OPT_AUTOCC=0\n"
196 printf "CONFIG=MINIMAL OPT_AUTOCC=1\n"
197 printf "CONFIG=NETSEND OPT_AUTOCC=0\n"
198 printf "CONFIG=NETSEND OPT_AUTOCC=1\n"
199 printf "CONFIG=MAXIMAL OPT_AUTOCC=0\n"
200 printf "CONFIG=MAXIMAL OPT_AUTOCC=1\n"
201 printf "CONFIG=DEVEL OPT_AUTOCC=0\n"
202 printf "CONFIG=DEVEL OPT_AUTOCC=1\n"
203 printf "CONFIG=ODEVEL OPT_AUTOCC=0\n"
204 printf "CONFIG=ODEVEL OPT_AUTOCC=1\n"
206 ' | while read c; do
207 printf "\n\n##########\n$c\n"
208 printf "\n\n##########\n$c\n" >&2
209 sh -c "${MAKE} ${c} all test"
210 done
211 ${MAKE} distclean
214 have_feat() {
215 ( "${RAWMAILX}" ${ARGS} -X'echo $features' -Xx |
216 ${grep} +${1} ) >/dev/null 2>&1
219 t_prolog() {
220 ${rm} -rf "${BODY}" "${MBOX}" ${TRAP_EXIT_ADDONS}
221 TRAP_EXIT_ADDONS=
222 [ ${#} -gt 0 ] && printf '[%s]\n' "${1}"
224 t_epilog() {
225 t_prolog
228 check() {
229 restat=${?} tid=${1} eestat=${2} f=${3} s=${4}
230 [ "${eestat}" != - ] && [ "${restat}" != "${eestat}" ] &&
231 err "${tid}" 'unexpected exit status: '"${restat} != ${eestat}"
232 csum="`${cksum} < ${f}`"
233 if [ "${csum}" = "${s}" ]; then
234 printf '%s: ok\n' "${tid}"
235 else
236 ESTAT=1
237 printf '%s: error: checksum mismatch (got %s)\n' "${tid}" "${csum}"
239 if [ -n "${MAE_TEST}" ]; then
240 x=`echo ${tid} | ${tr} "/:=" "__-"`
241 ${cp} -f "${f}" ./mae-test-"${x}"
245 err() {
246 ESTAT=1
247 printf '%s: error: %s\n' ${1} "${2}"
250 ex0_test() {
251 # $1=test name [$2=status]
252 __qm__=${?}
253 [ ${#} -gt 1 ] && __qm__=${2}
254 if [ ${__qm__} -ne 0 ]; then
255 err $1 'unexpected non-0 exit status'
256 else
257 printf '%s: ok\n' "${1}"
261 exn0_test() {
262 # $1=test name [$2=status]
263 __qm__=${?}
264 [ ${#} -gt 1 ] && __qm__=${2}
265 if [ ${__qm__} -eq 0 ]; then
266 err $1 'unexpected 0 exit status'
267 else
268 printf '%s: ok\n' "${1}"
272 if ( [ "$((1 + 1))" = 2 ] ) >/dev/null 2>&1; then
273 add() {
274 echo "$((${1} + ${2}))"
276 else
277 add() {
278 echo `${awk} 'BEGIN{print '${1}' + '${2}'}'`
282 if ( [ "$((2 % 3))" = 2 ] ) >/dev/null 2>&1; then
283 modulo() {
284 echo "$((${1} % ${2}))"
286 else
287 modulo() {
288 echo `${awk} 'BEGIN{print '${1}' % '${2}'}'`
292 # t_behave()
293 # Basic (easily testable) behaviour tests
294 t_behave() {
295 t_behave_X_opt_input_command_stack
296 t_behave_X_errexit
297 t_behave_S_freeze
298 t_behave_wysh
299 t_behave_input_inject_semicolon_seq
300 t_behave_commandalias
301 t_behave_ifelse
302 t_behave_localopts
303 t_behave_local
304 t_behave_macro_param_shift
305 t_behave_addrcodec
306 t_behave_vexpr
307 t_behave_call_ret
308 t_behave_xcall
309 t_behave_vpospar
310 t_behave_atxplode
311 t_behave_read
313 t_behave_mbox
314 t_behave_maildir
315 t_behave_record_a_resend
316 t_behave_e_H_L_opts
318 t_behave_alternates
319 t_behave_alias
320 # FIXME t_behave_mlist
321 t_behave_filetype
323 t_behave_message_injections
324 t_behave_attachments
325 t_behave_compose_hooks
326 t_behave_C_opt_customhdr
328 t_behave_mass_recipients
329 t_behave_mime_types_load_control
330 t_behave_lreply_futh_rth_etc
332 t_behave_xxxheads_rfc2047
333 t_behave_rfc2231
334 t_behave_iconv_mbyte_base64
335 t_behave_iconv_mainbody
336 t_behave_binary_mainbody
337 t_behave_q_t_etc_opts
339 t_behave_s_mime
342 t_behave_X_opt_input_command_stack() {
343 t_prolog t_behave_X_opt_input_command_stack
345 ${cat} <<- '__EOT' > "${BODY}"
346 echo 1
347 define mac0 {
348 echo mac0-1 via1 $0
350 call mac0
351 echo 2
352 source '\
353 echo "define mac1 {";\
354 echo " echo mac1-1 via1 \$0";\
355 echo " call mac0";\
356 echo " echo mac1-2";\
357 echo " call mac2";\
358 echo " echo mac1-3";\
359 echo "}";\
360 echo "echo 1-1";\
361 echo "define mac2 {";\
362 echo " echo mac2-1 via1 \$0";\
363 echo " call mac0";\
364 echo " echo mac2-2";\
365 echo "}";\
366 echo "echo 1-2";\
367 echo "call mac1";\
368 echo "echo 1-3";\
369 echo "source \"\
370 echo echo 1-1-1 via1 \$0;\
371 echo call mac0;\
372 echo echo 1-1-2;\
373 | \"";\
374 echo "echo 1-4";\
376 echo 3
377 call mac2
378 echo 4
379 undefine *
380 __EOT
382 # The -X option supports multiline arguments, and those can internally use
383 # reverse solidus newline escaping. And all -X options are joined...
384 APO=\'
385 < "${BODY}" ${MAILX} ${ARGS} \
386 -X 'e\' \
387 -X ' c\' \
388 -X ' h\' \
389 -X ' o \' \
390 -X 1 \
392 define mac0 {
393 echo mac0-1 via2 $0
395 call mac0
396 echo 2
399 source '${APO}'\
400 echo "define mac1 {";\
401 echo " echo mac1-1 via2 \$0";\
402 echo " call mac0";\
403 echo " echo mac1-2";\
404 echo " call mac2";\
405 echo " echo mac1-3";\
406 echo "}";\
407 echo "echo 1-1";\
408 echo "define mac2 {";\
409 echo " echo mac2-1 via2 \$0";\
410 echo " call mac0";\
411 echo " echo mac2-2";\
412 echo "}";\
413 echo "echo 1-2";\
414 echo "call mac1";\
415 echo "echo 1-3";\
416 echo "source \"\
417 echo echo 1-1-1 via2 \$0;\
418 echo call mac0;\
419 echo echo 1-1-2;\
420 | \"";\
421 echo "echo 1-4";\
422 | '${APO}'
423 echo 3
426 call mac2
427 echo 4
428 undefine *
429 ' > "${MBOX}"
431 check behave:x_opt_input_command_stack 0 "${MBOX}" '1786542668 416'
433 t_epilog
436 t_behave_X_errexit() {
437 t_prolog t_behave_X_errexit
439 ${cat} <<- '__EOT' > "${BODY}"
440 echo one
441 echos nono
442 echo two
443 __EOT
445 </dev/null ${MAILX} ${ARGS} -Snomemdebug \
446 -X'echo one' -X' echos nono ' -X'echo two' \
447 > "${MBOX}" 2>&1
448 check behave:x_errexit-1 0 "${MBOX}" '916157812 53'
450 </dev/null ${MAILX} ${ARGS} -X'source '"${BODY}" -Snomemdebug \
451 > "${MBOX}" 2>&1
452 check behave:x_errexit-2 0 "${MBOX}" '916157812 53'
454 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Snomemdebug \
455 > "${MBOX}" 2>&1
456 check behave:x_errexit-3 0 "${MBOX}" '916157812 53'
460 </dev/null ${MAILX} ${ARGS} -Serrexit -Snomemdebug \
461 -X'echo one' -X' echos nono ' -X'echo two' \
462 > "${MBOX}" 2>&1
463 check behave:x_errexit-4 1 "${MBOX}" '2118430867 49'
465 </dev/null ${MAILX} ${ARGS} -X'source '"${BODY}" -Serrexit -Snomemdebug \
466 > "${MBOX}" 2>&1
467 check behave:x_errexit-5 1 "${MBOX}" '2118430867 49'
469 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Serrexit -Snomemdebug \
470 > "${MBOX}" 2>&1
471 check behave:x_errexit-6 1 "${MBOX}" '12955965 172'
473 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Sposix -Snomemdebug \
474 > "${MBOX}" 2>&1
475 check behave:x_errexit-7 1 "${MBOX}" '12955965 172'
477 ## Repeat 4-7 with ignerr set
479 ${sed} -e 's/^echos /ignerr echos /' < "${BODY}" > "${MBOX}"
481 </dev/null ${MAILX} ${ARGS} -Serrexit -Snomemdebug \
482 -X'echo one' -X'ignerr echos nono ' -X'echo two' \
483 > "${BODY}" 2>&1
484 check behave:x_errexit-8 0 "${BODY}" '916157812 53'
486 </dev/null ${MAILX} ${ARGS} -X'source '"${MBOX}" -Serrexit -Snomemdebug \
487 > "${BODY}" 2>&1
488 check behave:x_errexit-9 0 "${BODY}" '916157812 53'
490 </dev/null MAILRC="${MBOX}" ${MAILX} ${ARGS} -:u -Serrexit -Snomemdebug \
491 > "${BODY}" 2>&1
492 check behave:x_errexit-10 0 "${BODY}" '916157812 53'
494 </dev/null MAILRC="${MBOX}" ${MAILX} ${ARGS} -:u -Sposix -Snomemdebug \
495 > "${BODY}" 2>&1
496 check behave:x_errexit-11 0 "${BODY}" '916157812 53'
498 t_epilog
501 t_behave_S_freeze() {
502 t_prolog t_behave_S_freeze
503 oterm=$TERM
504 unset TERM
506 # Test basic assumption
507 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} \
508 -X'echo asksub<$asksub> dietcurd<$dietcurd>' \
509 -Xx > "${MBOX}" 2>&1
510 check behave:s_freeze-1 0 "${MBOX}" '270686329 21'
513 ${cat} <<- '__EOT' > "${BODY}"
514 echo asksub<$asksub>
515 set asksub
516 echo asksub<$asksub>
517 __EOT
518 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
519 -Snoasksub -Sasksub -Snoasksub \
520 -X'echo asksub<$asksub>' -X'set asksub' -X'echo asksub<$asksub>' \
521 -Xx > "${MBOX}" 2>&1
522 check behave:s_freeze-2 0 "${MBOX}" '3182942628 37'
524 ${cat} <<- '__EOT' > "${BODY}"
525 echo asksub<$asksub>
526 unset asksub
527 echo asksub<$asksub>
528 __EOT
529 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
530 -Snoasksub -Sasksub \
531 -X'echo asksub<$asksub>' -X'unset asksub' -X'echo asksub<$asksub>' \
532 -Xx > "${MBOX}" 2>&1
533 check behave:s_freeze-3 0 "${MBOX}" '2006554293 39'
536 ${cat} <<- '__EOT' > "${BODY}"
537 echo dietcurd<$dietcurd>
538 set dietcurd=cherry
539 echo dietcurd<$dietcurd>
540 __EOT
541 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
542 -Sdietcurd=strawberry -Snodietcurd -Sdietcurd=vanilla \
543 -X'echo dietcurd<$dietcurd>' -X'unset dietcurd' \
544 -X'echo dietcurd<$dietcurd>' \
545 -Xx > "${MBOX}" 2>&1
546 check behave:s_freeze-4 0 "${MBOX}" '1985768109 65'
548 ${cat} <<- '__EOT' > "${BODY}"
549 echo dietcurd<$dietcurd>
550 unset dietcurd
551 echo dietcurd<$dietcurd>
552 __EOT
553 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
554 -Sdietcurd=strawberry -Snodietcurd \
555 -X'echo dietcurd<$dietcurd>' -X'set dietcurd=vanilla' \
556 -X'echo dietcurd<$dietcurd>' \
557 -Xx > "${MBOX}" 2>&1
558 check behave:s_freeze-5 0 "${MBOX}" '151574279 51'
560 # TODO once we have a detached one with env=1..
561 if [ -n "`</dev/null ${MAILX} ${ARGS} -X'!echo \$TERM' -Xx`" ]; then
562 echo 'behave:s_freeze-{6,7}: shell sets $TERM, skipped'
563 else
564 ${cat} <<- '__EOT' > "${BODY}"
565 !echo "shell says TERM<$TERM>"
566 echo TERM<$TERM>
567 !echo "shell says TERM<$TERM>"
568 set TERM=cherry
569 !echo "shell says TERM<$TERM>"
570 echo TERM<$TERM>
571 !echo "shell says TERM<$TERM>"
572 __EOT
573 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
574 -STERM=strawberry -SnoTERM -STERM=vanilla \
575 -X'echo mail<$TERM>' -X'unset TERM' \
576 -X'!echo "shell says TERM<$TERM>"' -X'echo TERM<$TERM>' \
577 -Xx > "${MBOX}" 2>&1
578 check behave:s_freeze-6 0 "${MBOX}" '1211476036 167'
580 ${cat} <<- '__EOT' > "${BODY}"
581 !echo "shell says TERM<$TERM>"
582 echo TERM<$TERM>
583 !echo "shell says TERM<$TERM>"
584 set TERM=cherry
585 !echo "shell says TERM<$TERM>"
586 echo TERM<$TERM>
587 !echo "shell says TERM<$TERM>"
588 __EOT
589 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
590 -STERM=strawberry -SnoTERM \
591 -X'echo TERM<$TERM>' -X'set TERM=vanilla' \
592 -X'!echo "shell says TERM<$TERM>"' -X'echo TERM<$TERM>' \
593 -Xx > "${MBOX}" 2>&1
594 check behave:s_freeze-7 0 "${MBOX}" '3365080441 132'
597 TERM=$oterm
598 t_epilog
601 t_behave_wysh() {
602 t_prolog t_behave_wysh
604 ${cat} <<- '__EOT' > "${BODY}"
606 echo abcd
607 echo a'b'c'd'
608 echo a"b"c"d"
609 echo a$'b'c$'d'
610 echo 'abcd'
611 echo "abcd"
612 echo $'abcd'
613 echo a\ b\ c\ d
614 echo a 'b c' d
615 echo a "b c" d
616 echo a $'b c' d
618 echo 'a$`"\'
619 echo "a\$\`'\"\\"
620 echo $'a\$`\'\"\\'
621 echo $'a\$`\'"\\'
622 # DIET=CURD TIED=
623 echo 'a${DIET}b${TIED}c\${DIET}d\${TIED}e' # COMMENT
624 echo "a${DIET}b${TIED}c\${DIET}d\${TIED}e"
625 echo $'a${DIET}b${TIED}c\${DIET}d\${TIED}e'
627 echo a$'\101\0101\x41\u0041\u41\U00000041\U41'c
628 echo a$'\u0041\u41\u0C1\U00000041\U41'c
629 echo a$'\377'c
630 echo a$'\0377'c
631 echo a$'\400'c
632 echo a$'\0400'c
633 echo a$'\U1100001'c
635 echo a$'b\0c'd
636 echo a$'b\00c'de
637 echo a$'b\000c'df
638 echo a$'b\0000c'dg
639 echo a$'b\x0c'dh
640 echo a$'b\x00c'di
641 echo a$'b\u0'dj
642 echo a$'b\u00'dk
643 echo a$'b\u000'dl
644 echo a$'b\u0000'dm
645 echo a$'b\U0'dn
646 echo a$'b\U00'do
647 echo a$'b\U000'dp
648 echo a$'b\U0000'dq
649 echo a$'b\U00000'dr
650 echo a$'b\U000000'ds
651 echo a$'b\U0000000'dt
652 echo a$'b\U00000000'du
654 echo a$'\cI'b
655 echo a$'\011'b
656 echo a$'\x9'b
657 echo a$'\u9'b
658 echo a$'\U9'b
659 echo a$'\c@'b c d
660 __EOT
662 if [ -z "${UTF8_LOCALE}" ]; then
663 echo 'Skip behave:wysh_unicode, no UTF8_LOCALE'
664 else
665 < "${BODY}" DIET=CURD TIED= \
666 LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} 2>/dev/null > "${MBOX}"
667 check behave:wysh_unicode 0 "${MBOX}" '475805847 317'
670 < "${BODY}" DIET=CURD TIED= ${MAILX} ${ARGS} > "${MBOX}" 2>/dev/null
671 check behave:wysh_c 0 "${MBOX}" '1473887148 321'
673 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
674 wysh set mager='\hey\'
675 varshow mager
676 wysh set mager="\hey\\"
677 varshow mager
678 wysh set mager=$'\hey\\'
679 varshow mager
680 __EOT
681 check behave:wysh-3 0 "${MBOX}" '1289698238 69'
683 t_epilog
686 t_behave_input_inject_semicolon_seq() {
687 t_prolog t_behave_input_inject_semicolon_seq
689 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
690 define mydeepmac {
691 echon '(mydeepmac)';
693 define mymac {
694 echon this_is_mymac;call mydeepmac;echon ';';
696 echon one';';call mymac;echon two";";call mymac;echo three$';';
697 define mymac {
698 echon this_is_mymac;call mydeepmac;echon ,TOO'!;';
700 echon one';';call mymac;echon two";";call mymac;echo three$';';
701 __EOT
703 check behave:input_inject_semicolon_seq 0 "${MBOX}" '512117110 140'
705 t_epilog
708 t_behave_commandalias() {
709 t_prolog t_behave_commandalias
711 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
712 commandalias echo echo hoho
713 echo stop.
714 commandalias X Xx
715 commandalias Xx XxX
716 commandalias XxX XxXx
717 commandalias XxXx XxXxX
718 commandalias XxXxX XxXxXx
719 commandalias XxXxXx echo huhu
720 commandalias XxXxXxX echo huhu
722 commandalias XxXxXx XxXxXxX
724 uncommandalias echo
725 commandalias XxXxXx echo huhu
727 __EOT
729 check behave:commandalias 0 "${MBOX}" '3694143612 31'
731 t_epilog
734 t_behave_ifelse() {
735 t_prolog t_behave_ifelse
737 # Nestable conditions test
738 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
739 if 0
740 echo 1.err
741 else
742 echo 1.ok
743 endif
744 if 1
745 echo 2.ok
746 else
747 echo 2.err
748 endif
749 if $dietcurd
750 echo 3.err
751 else
752 echo 3.ok
753 endif
754 set dietcurd=yoho
755 if $dietcurd
756 echo 4.ok
757 else
758 echo 4.err
759 endif
760 if $dietcurd == 'yoho'
761 echo 5.ok
762 else
763 echo 5.err
764 endif
765 if $dietcurd @== 'Yoho'
766 echo 5-1.ok
767 else
768 echo 5-1.err
769 endif
770 if $dietcurd == 'Yoho'
771 echo 5-2.err
772 else
773 echo 5-2.ok
774 endif
775 if $dietcurd != 'yoho'
776 echo 6.err
777 else
778 echo 6.ok
779 endif
780 if $dietcurd @!= 'Yoho'
781 echo 6-1.err
782 else
783 echo 6-1.ok
784 endif
785 if $dietcurd != 'Yoho'
786 echo 6-2.ok
787 else
788 echo 6-2.err
789 endif
790 # Nesting
791 if faLse
792 echo 7.err1
793 if tRue
794 echo 7.err2
795 if yEs
796 echo 7.err3
797 else
798 echo 7.err4
799 endif
800 echo 7.err5
801 endif
802 echo 7.err6
803 else
804 echo 7.ok7
805 if YeS
806 echo 7.ok8
807 if No
808 echo 7.err9
809 else
810 echo 7.ok9
811 endif
812 echo 7.ok10
813 else
814 echo 7.err11
815 if yeS
816 echo 7.err12
817 else
818 echo 7.err13
819 endif
820 endif
821 echo 7.ok14
822 endif
823 if r
824 echo 8.ok1
825 if R
826 echo 8.ok2
827 else
828 echo 8.err2
829 endif
830 echo 8.ok3
831 else
832 echo 8.err1
833 endif
834 if s
835 echo 9.err1
836 else
837 echo 9.ok1
838 if S
839 echo 9.err2
840 else
841 echo 9.ok2
842 endif
843 echo 9.ok3
844 endif
845 # `elif'
846 if $dietcurd == 'yohu'
847 echo 10.err1
848 elif $dietcurd == 'yoha'
849 echo 10.err2
850 elif $dietcurd == 'yohe'
851 echo 10.err3
852 elif $dietcurd == 'yoho'
853 echo 10.ok1
854 if $dietcurd == 'yohu'
855 echo 10.err4
856 elif $dietcurd == 'yoha'
857 echo 10.err5
858 elif $dietcurd == 'yohe'
859 echo 10.err6
860 elif $dietcurd == 'yoho'
861 echo 10.ok2
862 if $dietcurd == 'yohu'
863 echo 10.err7
864 elif $dietcurd == 'yoha'
865 echo 10.err8
866 elif $dietcurd == 'yohe'
867 echo 10.err9
868 elif $dietcurd == 'yoho'
869 echo 10.ok3
870 else
871 echo 10.err10
872 endif
873 else
874 echo 10.err11
875 endif
876 else
877 echo 10.err12
878 endif
879 # integer
880 set dietcurd=10
881 if $dietcurd -lt 11
882 echo 11.ok1
883 if $dietcurd -gt 9
884 echo 11.ok2
885 else
886 echo 11.err2
887 endif
888 if $dietcurd -eq 10
889 echo 11.ok3
890 else
891 echo 11.err3
892 endif
893 if $dietcurd -ge 10
894 echo 11.ok4
895 else
896 echo 11.err4
897 endif
898 if $dietcurd -le 10
899 echo 11.ok5
900 else
901 echo 11.err5
902 endif
903 if $dietcurd -ge 11
904 echo 11.err6
905 else
906 echo 11.ok6
907 endif
908 if $dietcurd -le 9
909 echo 11.err7
910 else
911 echo 11.ok7
912 endif
913 else
914 echo 11.err1
915 endif
916 set dietcurd=Abc
917 if $dietcurd < aBd
918 echo 12.ok1
919 if $dietcurd @> abB
920 echo 12.ok2
921 else
922 echo 12.err2
923 endif
924 if $dietcurd @== aBC
925 echo 12.ok3
926 else
927 echo 12.err3
928 endif
929 if $dietcurd @>= AbC
930 echo 12.ok4
931 else
932 echo 12.err4
933 endif
934 if $dietcurd @<= ABc
935 echo 12.ok5
936 else
937 echo 12.err5
938 endif
939 if $dietcurd @>= abd
940 echo 12.err6
941 else
942 echo 12.ok6
943 endif
944 if $dietcurd @<= abb
945 echo 12.err7
946 else
947 echo 12.ok7
948 endif
949 else
950 echo 12.err1
951 endif
952 if $dietcurd < aBc
953 echo 12-1.ok
954 else
955 echo 12-1.err
956 endif
957 if $dietcurd @< aBc
958 echo 12-2.err
959 else
960 echo 12-2.ok
961 endif
962 if $dietcurd > ABc
963 echo 12-3.ok
964 else
965 echo 12-3.err
966 endif
967 if $dietcurd @> ABc
968 echo 12-3.err
969 else
970 echo 12-3.ok
971 endif
972 if $dietcurd @i=% aB
973 echo 13.ok
974 else
975 echo 13.err
976 endif
977 if $dietcurd =% aB
978 echo 13-1.err
979 else
980 echo 13-1.ok
981 endif
982 if $dietcurd @=% bC
983 echo 14.ok
984 else
985 echo 14.err
986 endif
987 if $dietcurd !% aB
988 echo 15-1.ok
989 else
990 echo 15-1.err
991 endif
992 if $dietcurd @!% aB
993 echo 15-2.err
994 else
995 echo 15-2.ok
996 endif
997 if $dietcurd !% bC
998 echo 15-3.ok
999 else
1000 echo 15-3.err
1001 endif
1002 if $dietcurd @!% bC
1003 echo 15-4.err
1004 else
1005 echo 15-4.ok
1006 endif
1007 if $dietcurd =% Cd
1008 echo 16.err
1009 else
1010 echo 16.ok
1011 endif
1012 if $dietcurd !% Cd
1013 echo 17.ok
1014 else
1015 echo 17.err
1016 endif
1017 set diet=abc curd=abc
1018 if $diet == $curd
1019 echo 18.ok
1020 else
1021 echo 18.err
1022 endif
1023 set diet=abc curd=abcd
1024 if $diet != $curd
1025 echo 19.ok
1026 else
1027 echo 19.err
1028 endif
1029 # 1. Shitty grouping capabilities as of today
1030 unset diet curd ndefined
1031 if [ [ false ] || [ false ] || [ true ] ] && [ [ false ] || [ true ] ] && \
1032 [ yes ]
1033 echo 20.ok
1034 else
1035 echo 20.err
1036 endif
1037 if [ [ [ [ 0 ] || [ 1 ] ] && [ [ 1 ] || [ 0 ] ] ] && [ 1 ] ] && [ yes ]
1038 echo 21.ok
1039 else
1040 echo 21.err
1041 endif
1042 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] ]
1043 echo 22.ok
1044 else
1045 echo 22.err
1046 endif
1047 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] ]
1048 echo 23.ok
1049 else
1050 echo 23.err
1051 endif
1052 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] && [ no ]
1053 echo 24.err
1054 else
1055 echo 24.ok
1056 endif
1057 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] \
1058 && [ no ] || [ yes ]
1059 echo 25.ok
1060 else
1061 echo 25.err
1062 endif
1063 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
1064 echo 26.ok
1065 else
1066 echo 26.err
1067 endif
1068 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 0 ] ]
1069 echo 27.err
1070 else
1071 echo 27.ok
1072 endif
1073 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 0 ] ] && [ 1 ] ] ] && [ 1 ] ]
1074 echo 28.err
1075 else
1076 echo 28.ok
1077 endif
1078 if [ [ [ [ [ [ [ 0 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
1079 echo 29.err
1080 else
1081 echo 29.ok
1082 endif
1083 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 0 ]
1084 echo 30.err
1085 else
1086 echo 30.ok
1087 endif
1088 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 1 ]
1089 echo 31.ok
1090 else
1091 echo 31.err
1092 endif
1093 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ]
1094 echo 32.err
1095 else
1096 echo 32.ok
1097 endif
1098 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 1 ]
1099 echo 33.ok
1100 else
1101 echo 33.err
1102 endif
1103 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 0 ]
1104 echo 34.err
1105 else
1106 echo 34.ok
1107 endif
1108 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 1 ]
1109 echo 35.ok
1110 else
1111 echo 35.err
1112 endif
1113 set diet=yo curd=ho
1114 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
1115 echo 36.err
1116 else
1117 echo 36.ok
1118 endif
1119 set ndefined
1120 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
1121 echo 37.ok
1122 else
1123 echo 37.err
1124 endif
1125 # 2. Shitty grouping capabilities as of today
1126 unset diet curd ndefined
1127 if [ false || false || true ] && [ false || true ] && yes
1128 echo 40.ok
1129 else
1130 echo 40.err
1131 endif
1132 if [ [ [ 0 || 1 ] && [ 1 || 0 ] ] && 1 ] && [ yes ]
1133 echo 41.ok
1134 else
1135 echo 41.err
1136 endif
1137 if [ 1 || 0 || 0 || 0 ]
1138 echo 42.ok
1139 else
1140 echo 42.err
1141 endif
1142 if [ 1 || 0 || 0 || 0 || [ 1 ] ]
1143 echo 43.ok
1144 else
1145 echo 43.err
1146 endif
1147 if [ 1 || 0 || 0 || 0 || [ 1 ] || 1 ] && no
1148 echo 44.err
1149 else
1150 echo 44.ok
1151 endif
1152 if [ 1 || 0 || 0 || 0 || 1 || [ 1 ] ] && no || [ yes ]
1153 echo 45.ok
1154 else
1155 echo 45.err
1156 endif
1157 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && 1 ] ] && [ 1 ] ]
1158 echo 46.ok
1159 else
1160 echo 46.err
1161 endif
1162 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && [ 1 ] ] ] && 0 ]
1163 echo 47.err
1164 else
1165 echo 47.ok
1166 endif
1167 if [ [ [ [ [ [ [ 1 ] ] && 1 ] && 0 ] && [ 1 ] ] ] && 1 ]
1168 echo 48.err
1169 else
1170 echo 48.ok
1171 endif
1172 if [ [ [ [ [ [ 0 ] && 1 ] && 1 ] && 1 ] ] && 1 ]
1173 echo 49.err
1174 else
1175 echo 49.ok
1176 endif
1177 if 1 || 0 || 0 || 0 && 0
1178 echo 50.err
1179 else
1180 echo 50.ok
1181 endif
1182 if 1 || 0 || 0 || 0 && 1
1183 echo 51.ok
1184 else
1185 echo 51.err
1186 endif
1187 if 0 || 0 || 0 || 1 && 0
1188 echo 52.err
1189 else
1190 echo 52.ok
1191 endif
1192 if 0 || 0 || 0 || 1 && 1
1193 echo 53.ok
1194 else
1195 echo 53.err
1196 endif
1197 if 0 || 0 || 0 || 1 && 0 || 1 && 0
1198 echo 54.err
1199 else
1200 echo 54.ok
1201 endif
1202 if 0 || 0 || 0 || 1 && 0 || 1 && 1
1203 echo 55.ok
1204 else
1205 echo 55.err
1206 endif
1207 set diet=yo curd=ho
1208 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
1209 echo 56.err
1210 else
1211 echo 56.ok
1212 endif
1213 if $diet == 'yo' && $curd == 'ho' && $ndefined
1214 echo 57.err
1215 else
1216 echo 57.ok
1217 endif
1218 set ndefined
1219 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
1220 echo 57.ok
1221 else
1222 echo 57.err
1223 endif
1224 if $diet == 'yo' && $curd == 'ho' && $ndefined
1225 echo 58.ok
1226 else
1227 echo 58.err
1228 endif
1229 if [ [ [ [ [ [ $diet == 'yo' && $curd == 'ho' && $ndefined ] ] ] ] ] ]
1230 echo 59.ok
1231 else
1232 echo 59.err
1233 endif
1234 # Some more en-braced variables
1235 set diet=yo curd=ho
1236 if ${diet} == ${curd}
1237 echo 70.err
1238 else
1239 echo 70.ok
1240 endif
1241 if ${diet} != ${curd}
1242 echo 71.ok
1243 else
1244 echo 71.err
1245 endif
1246 if $diet == ${curd}
1247 echo 72.err
1248 else
1249 echo 72.ok
1250 endif
1251 if ${diet} == $curd
1252 echo 73.err
1253 else
1254 echo 73.ok
1255 endif
1256 # Unary !
1257 if ! 0 && ! ! 1 && ! ! ! ! 2 && 3
1258 echo 80.ok
1259 else
1260 echo 80.err
1261 endif
1262 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ ! 2 ] ] ] && 3
1263 echo 81.ok
1264 else
1265 echo 81.err
1266 endif
1267 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1268 echo 82.ok
1269 else
1270 echo 82.err
1271 endif
1272 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
1273 echo 83.err
1274 else
1275 echo 83.ok
1276 endif
1277 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
1278 echo 84.err
1279 else
1280 echo 84.ok
1281 endif
1282 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1283 echo 85.err
1284 else
1285 echo 85.ok
1286 endif
1287 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1288 echo 86.err
1289 else
1290 echo 86.ok
1291 endif
1292 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] || 3
1293 echo 87.ok
1294 else
1295 echo 87.err
1296 endif
1297 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! ! [ 2 ] ] ] ] ]
1298 echo 88.ok
1299 else
1300 echo 88.err
1301 endif
1302 # Unary !, odd
1303 if ! 0 && ! ! 1 && ! ! ! 0 && 3
1304 echo 90.ok
1305 else
1306 echo 90.err
1307 endif
1308 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ 0 ] ] ] && 3
1309 echo 91.ok
1310 else
1311 echo 91.err
1312 endif
1313 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ [ 0 ] ] ] ] ] && 3
1314 echo 92.ok
1315 else
1316 echo 92.err
1317 endif
1318 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! ! [ ! [ ! 0 ] ] ] ] && ! 3
1319 echo 93.err
1320 else
1321 echo 93.ok
1322 endif
1323 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ ! [ ! [ ! [ ! 0 ] ] ] ] && 3
1324 echo 94.ok
1325 else
1326 echo 94.err
1327 endif
1328 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! ! [ ! [ ! [ ! [ 0 ] ] ] ] ] && 3
1329 echo 95.err
1330 else
1331 echo 95.ok
1332 endif
1333 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! ! 0 ] ] ] ] && 3
1334 echo 96.err
1335 else
1336 echo 96.ok
1337 endif
1338 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ ! 0 ] ] ] ] ] || 3
1339 echo 97.ok
1340 else
1341 echo 97.err
1342 endif
1343 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! [ 0 ] ] ] ] ]
1344 echo 98.ok
1345 else
1346 echo 98.err
1347 endif
1348 __EOT
1350 check behave:if-normal 0 "${MBOX}" '1688759742 719'
1352 if have_feat regex; then
1353 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
1354 set dietcurd=yoho
1355 if $dietcurd =~ '^yo.*'
1356 echo 1.ok
1357 else
1358 echo 1.err
1359 endif
1360 if $dietcurd =~ '^Yo.*'
1361 echo 1-1.err
1362 else
1363 echo 1-1.ok
1364 endif
1365 if $dietcurd @=~ '^Yo.*'
1366 echo 1-2.ok
1367 else
1368 echo 1-2.err
1369 endif
1370 if $dietcurd =~ '^yOho.+'
1371 echo 2.err
1372 else
1373 echo 2.ok
1374 endif
1375 if $dietcurd @!~ '.*Ho$'
1376 echo 3.err
1377 else
1378 echo 3.ok
1379 endif
1380 if $dietcurd !~ '.+yohO$'
1381 echo 4.ok
1382 else
1383 echo 4.err
1384 endif
1385 if [ $dietcurd @i!~ '.+yoho$' ]
1386 echo 5.ok
1387 else
1388 echo 5.err
1389 endif
1390 if ! [ $dietcurd @i=~ '.+yoho$' ]
1391 echo 6.ok
1392 else
1393 echo 6.err
1394 endif
1395 if ! ! [ $dietcurd @i!~ '.+yoho$' ]
1396 echo 7.ok
1397 else
1398 echo 7.err
1399 endif
1400 if ! [ ! [ $dietcurd @i!~ '.+yoho$' ] ]
1401 echo 8.ok
1402 else
1403 echo 8.err
1404 endif
1405 if [ ! [ ! [ $dietcurd @i!~ '.+yoho$' ] ] ]
1406 echo 9.ok
1407 else
1408 echo 9.err
1409 endif
1410 if ! [ ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
1411 echo 10.err
1412 else
1413 echo 10.ok
1414 endif
1415 if ! ! ! $dietcurd !~ '.+yoho$'
1416 echo 11.err
1417 else
1418 echo 11.ok
1419 endif
1420 if ! ! ! $dietcurd =~ '.+yoho$'
1421 echo 12.ok
1422 else
1423 echo 12.err
1424 endif
1425 if ! [ ! ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
1426 echo 13.ok
1427 else
1428 echo 13.err
1429 endif
1430 set diet=abc curd='^abc$'
1431 if $diet =~ $curd
1432 echo 14.ok
1433 else
1434 echo 14.err
1435 endif
1436 set diet=abc curd='^abcd$'
1437 if $diet !~ $curd
1438 echo 15.ok
1439 else
1440 echo 15.err
1441 endif
1442 __EOT
1444 check behave:if-regex 0 "${MBOX}" '1115671789 95'
1445 else
1446 printf 'behave:if-regex: unsupported, skipped\n'
1449 t_epilog
1452 t_behave_localopts() {
1453 t_prolog t_behave_localopts
1455 # Nestable conditions test
1456 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
1457 define t2 {
1458 echo in: t2
1459 set t2=t2
1460 echo $t2
1462 define t1 {
1463 echo in: t1
1464 set gv1=gv1
1465 localopts on
1466 set lv1=lv1 lv2=lv2
1467 set lv3=lv3
1468 call t2
1469 localopts off
1470 set gv2=gv2
1471 echo $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2
1473 define t0 {
1474 echo in: t0
1475 call t1
1476 echo $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2
1477 echo "$gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2"
1479 account trouble {
1480 echo in: trouble
1481 call t0
1483 call t0
1484 unset gv1 gv2
1485 account trouble
1486 echo active trouble: $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t3
1487 account null
1488 echo active null: $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t3
1491 define ll2 {
1492 localopts $1
1493 set x=2
1494 echo ll2=$x
1496 define ll1 {
1497 wysh set y=$1; shift; eval localopts $y; localopts $1; shift
1498 set x=1
1499 echo ll1.1=$x
1500 call ll2 $1
1501 echo ll1.2=$x
1503 define ll0 {
1504 wysh set y=$1; shift; eval localopts $y; localopts $1; shift
1505 set x=0
1506 echo ll0.1=$x
1507 call ll1 $y "$@"
1508 echo ll0.2=$x
1510 define llx {
1511 echo ----- $1: $2 -> $3 -> $4
1512 echo ll-1.1=$x
1513 eval localopts $1
1514 call ll0 "$@"
1515 echo ll-1.2=$x
1516 unset x
1518 define lly {
1519 call llx 'call off' on on on
1520 call llx 'call off' off on on
1521 call llx 'call off' on off on
1522 call llx 'call off' on off off
1523 localopts call-fixate on
1524 call llx 'call-fixate on' on on on
1525 call llx 'call-fixate on' off on on
1526 call llx 'call-fixate on' on off on
1527 call llx 'call-fixate on' on off off
1528 unset x;localopts call on
1529 call llx 'call on' on on on
1530 call llx 'call on' off on on
1531 call llx 'call on' on off on
1532 call llx 'call on' on off off
1534 call lly
1535 __EOT
1537 check behave:localopts 0 "${MBOX}" '4016155249 1246'
1539 t_epilog
1542 t_behave_local() {
1543 t_prolog t_behave_local
1545 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
1546 define du2 {
1547 echo du2-1 du=$du
1548 local set du=$1
1549 echo du2-2 du=$du
1550 local unset du
1551 echo du2-3 du=$du
1553 define du {
1554 local set du=dudu
1555 echo du-1 du=$du
1556 call du2 du2du2
1557 echo du-2 du=$du
1558 local set nodu
1559 echo du-3 du=$du
1561 define ich {
1562 echo ich-1 du=$du
1563 call du
1564 echo ich-2 du=$du
1566 define wir {
1567 localopts $1
1568 set du=wirwir
1569 echo wir-1 du=$du
1570 call ich
1571 echo wir-2 du=$du
1573 echo ------- global-1 du=$du
1574 call ich
1575 echo ------- global-2 du=$du
1576 set du=global
1577 call ich
1578 echo ------- global-3 du=$du
1579 call wir on
1580 echo ------- global-4 du=$du
1581 call wir off
1582 echo ------- global-5 du=$du
1583 __EOT
1585 check behave:local-1 0 "${MBOX}" '2411598140 641'
1587 t_epilog
1590 t_behave_macro_param_shift() {
1591 t_prolog t_behave_macro_param_shift
1593 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>/dev/null
1594 define t2 {
1595 echo in: t2
1596 echo t2.0 has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1597 localopts on
1598 wysh set ignerr=$1
1599 shift
1600 localopts off
1601 echo t2.1 has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1602 if [ $# > 1 ] || [ $ignerr == '' ]
1603 shift 2
1604 else
1605 ignerr shift 2
1606 endif
1607 echo t2.2:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1608 shift 0
1609 echo t2.3:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1610 if [ $# > 0 ]
1611 shift
1612 endif
1613 echo t2.4:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1615 define t1 {
1616 set errexit
1617 echo in: t1
1618 call t2 1 you get four args
1619 echo t1.1: $?';' ignerr ($ignerr) should not exist
1620 call t2 1 you get 'three args'
1621 echo t1.2: $?';' ignerr ($ignerr) should not exist
1622 call t2 1 you 'get two args'
1623 echo t1.3: $?';' ignerr ($ignerr) should not exist
1624 call t2 1 'you get one arg'
1625 echo t1.4: $?';' ignerr ($ignerr) should not exist
1626 ignerr call t2 '' 'you get one arg'
1627 echo t1.5: $?';' ignerr ($ignerr) should not exist
1629 call t1
1630 __EOT
1632 check behave:macro_param_shift 0 "${MBOX}" '1402489146 1682'
1634 t_epilog
1637 t_behave_addrcodec() {
1638 t_prolog t_behave_addrcodec
1640 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
1641 vput addrcodec res e 1 <doog@def>
1642 echo $?/$^ERRNAME $res
1643 eval vput addrcodec res d $res
1644 echo $?/$^ERRNAME $res
1645 vput addrcodec res e 2 . <doog@def>
1646 echo $?/$^ERRNAME $res
1647 eval vput addrcodec res d $res
1648 echo $?/$^ERRNAME $res
1649 vput addrcodec res e 3 Sauer Dr. <doog@def>
1650 echo $?/$^ERRNAME $res
1651 eval vput addrcodec res d $res
1652 echo $?/$^ERRNAME $res
1653 vput addrcodec res e 3.50 Sauer (Ma) Dr. <doog@def>
1654 echo $?/$^ERRNAME $res
1655 eval vput addrcodec res d $res
1656 echo $?/$^ERRNAME $res
1657 vput addrcodec res e 3.51 Sauer (Ma) "Dr." <doog@def>
1658 echo $?/$^ERRNAME $res
1659 eval vput addrcodec res d $res
1660 echo $?/$^ERRNAME $res
1662 vput addrcodec res +e 4 Sauer (Ma) Dr. <doog@def>
1663 echo $?/$^ERRNAME $res
1664 eval vput addrcodec res d $res
1665 echo $?/$^ERRNAME $res
1666 vput addrcodec res +e 5 Sauer (Ma) Braten Dr. <doog@def>
1667 echo $?/$^ERRNAME $res
1668 eval vput addrcodec res d $res
1669 echo $?/$^ERRNAME $res
1670 vput addrcodec res +e 6 Sauer (Ma) Braten Dr. (Heu) <doog@def>
1671 echo $?/$^ERRNAME $res
1672 eval vput addrcodec res d $res
1673 echo $?/$^ERRNAME $res
1674 vput addrcodec res +e 7 Sauer (Ma) Braten Dr. (Heu) <doog@def> (bu)
1675 echo $?/$^ERRNAME $res
1676 eval vput addrcodec res d $res
1677 echo $?/$^ERRNAME $res
1678 vput addrcodec res +e 8 \
1679 Dr. Sauer (Ma) Braten Dr. (Heu) <doog@def> (bu) Boom. Boom
1680 echo $?/$^ERRNAME $res
1681 eval vput addrcodec res d $res
1682 echo $?/$^ERRNAME $res
1683 vput addrcodec res +e 9 Dr.Sauer(Ma)Braten Dr. (Heu) <doog@def>
1684 echo $?/$^ERRNAME $res
1685 eval vput addrcodec res d $res
1686 echo $?/$^ERRNAME $res
1687 vput addrcodec res +e 10 (Ma)Braten Dr. (Heu) <doog@def>
1688 echo $?/$^ERRNAME $res
1689 eval vput addrcodec res d $res
1690 echo $?/$^ERRNAME $res
1691 vput addrcodec res +e 11 (Ma)Braten Dr"." (Heu) <doog@def>
1692 echo $?/$^ERRNAME $res
1693 eval vput addrcodec res d $res
1694 echo $?/$^ERRNAME $res
1695 vput addrcodec res +e 12 Dr. Sauer (Ma) Braten Dr. (u) <doog@def>
1696 echo $?/$^ERRNAME $res
1697 eval vput addrcodec res d $res
1698 echo $?/$^ERRNAME $res
1699 vput addrcodec res +e 13(Ma)Braten Dr. (Heu) <doog@def>
1700 echo $?/$^ERRNAME $res
1701 eval vput addrcodec res d $res
1702 echo $?/$^ERRNAME $res
1703 vput addrcodec res +e 14 Hey, Du <doog@def> Wie() findet Dr. das? ()
1704 echo $?/$^ERRNAME $res
1705 eval vput addrcodec res d $res
1706 echo $?/$^ERRNAME $res
1707 vput addrcodec res +e 15 \
1708 Hey, Du <doog@def> Wie() findet "" Dr. "" das? ()
1709 echo $?/$^ERRNAME $res
1710 eval vput addrcodec res d $res
1711 echo $?/$^ERRNAME $res
1712 vput addrcodec res +e 16 \
1713 "Hey," "Du" <doog@def> "Wie()" findet "" Dr. "" das? ()
1714 echo $?/$^ERRNAME $res
1715 eval vput addrcodec res d $res
1716 echo $?/$^ERRNAME $res
1717 vput addrcodec res +e 17 \
1718 "Hey" Du <doog@def> "Wie() findet " " Dr. """ das? ()
1719 echo $?/$^ERRNAME $res
1720 eval vput addrcodec res d $res
1721 echo $?/$^ERRNAME $res
1722 vput addrcodec res +e 18 \
1723 <doog@def> "Hey" Du "Wie() findet " " Dr. """ das? ()
1724 echo $?/$^ERRNAME $res
1725 eval vput addrcodec res d $res
1726 echo $?/$^ERRNAME $res
1727 vput addrcodec res +e 19 Hey\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1728 echo $?/$^ERRNAME $res
1729 eval vput addrcodec res d $res
1730 echo $?/$^ERRNAME $res
1732 vput addrcodec res ++e 20 Hey\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1733 echo $?/$^ERRNAME $res
1734 vput addrcodec res ++e 21 Hey\,\"" <doog@def> "Wie()" findet \" Dr. \" das?
1735 echo $?/$^ERRNAME $res
1736 eval vput addrcodec res d $res
1737 echo $?/$^ERRNAME $res
1739 vput addrcodec res +++e 22 Hey\\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1740 echo $?/$^ERRNAME $res
1741 eval vput addrcodec res d $res
1742 echo $?/$^ERRNAME $res
1744 vput addrcodec res s \
1745 "23 Hey\\,\\\" \"Wie" () "\" findet \\\" Dr. \\\" das?" <doog@def>
1746 echo $?/$^ERRNAME $res
1748 # Fix for [f3852f88]
1749 vput addrcodec res ++e <from2@exam.ple> 100 (comment) "Quot(e)d"
1750 echo $?/$^ERRNAME $res
1751 eval vput addrcodec res d $res
1752 echo $?/$^ERRNAME $res
1753 vput addrcodec res e <from2@exam.ple> 100 (comment) "Quot(e)d"
1754 echo $?/$^ERRNAME $res
1755 eval vput addrcodec res d $res
1756 echo $?/$^ERRNAME $res
1757 __EOT
1759 check behave:addrcodec-1 0 "${MBOX}" '1047317989 2612'
1761 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
1762 mlist isa1@list
1763 mlsubscribe isa2@list
1765 vput addrcodec res skin Hey\\,\" <isa0@list> "Wie()" find \" Dr. \" das?
1766 echo $?/$^ERRNAME $res
1767 vput addrcodec res skinlist Hey\\,\" <isa0@list> "Wie()" find \" Dr. \" das?
1768 echo $?/$^ERRNAME $res
1769 vput addrcodec res skin Hey\\,\" <isa1@list> "Wie()" find \" Dr. \" das?
1770 echo $?/$^ERRNAME $res
1771 vput addrcodec res skinlist Hey\\,\" <isa1@list> "Wie()" find \" Dr. \" das?
1772 echo $?/$^ERRNAME $res
1773 vput addrcodec res skin Hey\\,\" <isa2@list> "Wie()" find \" Dr. \" das?
1774 echo $?/$^ERRNAME $res
1775 vput addrcodec res skinlist Hey\\,\" <isa2@list> "Wie()" find \" Dr. \" das?
1776 echo $?/$^ERRNAME $res
1777 __EOT
1779 check behave:addrcodec-2 0 "${MBOX}" '1391779299 104'
1781 if have_feat idna; then
1782 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} ${ADDARG_UNI} > "${MBOX}" 2>&1
1783 vput addrcodec res e (heu) <du@blödiän> "stroh" du
1784 echo $?/$^ERRNAME $res
1785 eval vput addrcodec res d $res
1786 echo $?/$^ERRNAME $res
1787 vput addrcodec res e <du@blödiän> du
1788 echo $?/$^ERRNAME $res
1789 eval vput addrcodec res d $res
1790 echo $?/$^ERRNAME $res
1791 vput addrcodec res e du <du@blödiän>
1792 echo $?/$^ERRNAME $res
1793 eval vput addrcodec res d $res
1794 echo $?/$^ERRNAME $res
1795 vput addrcodec res e <du@blödiän>
1796 echo $?/$^ERRNAME $res
1797 eval vput addrcodec res d $res
1798 echo $?/$^ERRNAME $res
1799 vput addrcodec res e du@blödiän
1800 echo $?/$^ERRNAME $res
1801 eval vput addrcodec res d $res
1802 echo $?/$^ERRNAME $res
1803 __EOT
1805 check behave:addrcodec-idna 0 "${MBOX}" '498775983 326'
1806 else
1807 printf 'behave:addrcodec-idna: unsupported, skipped\n'
1810 t_epilog
1813 t_behave_vexpr() {
1814 t_prolog t_behave_vexpr
1816 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>/dev/null
1817 echo ' #0.0'
1818 vput vexpr res = 9223372036854775807
1819 echo $?/$^ERRNAME $res
1820 vput vexpr res = 9223372036854775808
1821 echo $?/$^ERRNAME $res
1822 vput vexpr res = u9223372036854775808
1823 echo $?/$^ERRNAME $res
1824 vput vexpr res @= 9223372036854775808
1825 echo $?/$^ERRNAME $res
1826 vput vexpr res = -9223372036854775808
1827 echo $?/$^ERRNAME $res
1828 vput vexpr res = -9223372036854775809
1829 echo $?/$^ERRNAME $res
1830 vput vexpr res @= -9223372036854775809
1831 echo $?/$^ERRNAME $res
1832 vput vexpr res = U9223372036854775809
1833 echo $?/$^ERRNAME $res
1834 echo ' #0.1'
1835 vput vexpr res = \
1836 0b0111111111111111111111111111111111111111111111111111111111111111
1837 echo $?/$^ERRNAME $res
1838 vput vexpr res = \
1839 S0b1000000000000000000000000000000000000000000000000000000000000000
1840 echo $?/$^ERRNAME $res
1841 vput vexpr res @= \
1842 S0b1000000000000000000000000000000000000000000000000000000000000000
1843 echo $?/$^ERRNAME $res
1844 vput vexpr res = \
1845 U0b1000000000000000000000000000000000000000000000000000000000000000
1846 echo $?/$^ERRNAME $res
1847 vput vexpr res = \
1848 0b1000000000000000000000000000000000000000000000000000000000000000
1849 echo $?/$^ERRNAME $res
1850 vput vexpr res @= \
1851 0b1000000000000000000000000000000000000000000000000000000000000000
1852 echo $?/$^ERRNAME $res
1853 vput vexpr res = \
1854 -0b1000000000000000000000000000000000000000000000000000000000000000
1855 echo $?/$^ERRNAME $res
1856 vput vexpr res = \
1857 S0b1000000000000000000000000000000000000000000000000000000000000001
1858 echo $?/$^ERRNAME $res
1859 vput vexpr res @= \
1860 S0b1000000000000000000000000000000000000000000000000000000000000001
1861 echo $?/$^ERRNAME $res
1862 vput vexpr res @= \
1863 -0b1000000000000000000000000000000000000000000000000000000000000001
1864 echo $?/$^ERRNAME $res
1865 vput vexpr res = \
1866 U0b1000000000000000000000000000000000000000000000000000000000000001
1867 echo $?/$^ERRNAME $res
1868 echo ' #0.2'
1869 vput vexpr res = 0777777777777777777777
1870 echo $?/$^ERRNAME $res
1871 vput vexpr res = S01000000000000000000000
1872 echo $?/$^ERRNAME $res
1873 vput vexpr res @= S01000000000000000000000
1874 echo $?/$^ERRNAME $res
1875 vput vexpr res = U01000000000000000000000
1876 echo $?/$^ERRNAME $res
1877 vput vexpr res = 01000000000000000000000
1878 echo $?/$^ERRNAME $res
1879 vput vexpr res @= 01000000000000000000000
1880 echo $?/$^ERRNAME $res
1881 vput vexpr res = -01000000000000000000000
1882 echo $?/$^ERRNAME $res
1883 vput vexpr res = S01000000000000000000001
1884 echo $?/$^ERRNAME $res
1885 vput vexpr res @= S01000000000000000000001
1886 echo $?/$^ERRNAME $res
1887 vput vexpr res @= -01000000000000000000001
1888 echo $?/$^ERRNAME $res
1889 vput vexpr res = U01000000000000000000001
1890 echo $?/$^ERRNAME $res
1891 echo ' #0.3'
1892 vput vexpr res = 0x7FFFFFFFFFFFFFFF
1893 echo $?/$^ERRNAME $res
1894 vput vexpr res = S0x8000000000000000
1895 echo $?/$^ERRNAME $res
1896 vput vexpr res @= S0x8000000000000000
1897 echo $?/$^ERRNAME $res
1898 vput vexpr res = U0x8000000000000000
1899 echo $?/$^ERRNAME $res
1900 vput vexpr res = 0x8000000000000000
1901 echo $?/$^ERRNAME $res
1902 vput vexpr res @= 0x8000000000000000
1903 echo $?/$^ERRNAME $res
1904 vput vexpr res = -0x8000000000000000
1905 echo $?/$^ERRNAME $res
1906 vput vexpr res = S0x8000000000000001
1907 echo $?/$^ERRNAME $res
1908 vput vexpr res @= S0x8000000000000001
1909 echo $?/$^ERRNAME $res
1910 vput vexpr res @= -0x8000000000000001
1911 echo $?/$^ERRNAME $res
1912 vput vexpr res = u0x8000000000000001
1913 echo $?/$^ERRNAME $res
1914 echo ' #1'
1915 vput vexpr res ~ 0
1916 echo $?/$^ERRNAME $res
1917 vput vexpr res ~ 1
1918 echo $?/$^ERRNAME $res
1919 vput vexpr res ~ -1
1920 echo $?/$^ERRNAME $res
1921 echo ' #2'
1922 vput vexpr res + 0 0
1923 echo $?/$^ERRNAME $res
1924 vput vexpr res + 0 1
1925 echo $?/$^ERRNAME $res
1926 vput vexpr res + 1 1
1927 echo $?/$^ERRNAME $res
1928 echo ' #3'
1929 vput vexpr res + 9223372036854775807 0
1930 echo $?/$^ERRNAME $res
1931 vput vexpr res + 9223372036854775807 1
1932 echo $?/$^ERRNAME $res
1933 vput vexpr res @+ 9223372036854775807 1
1934 echo $?/$^ERRNAME $res
1935 vput vexpr res + 0 9223372036854775807
1936 echo $?/$^ERRNAME $res
1937 vput vexpr res + 1 9223372036854775807
1938 echo $?/$^ERRNAME $res
1939 vput vexpr res @+ 1 9223372036854775807
1940 echo $?/$^ERRNAME $res
1941 echo ' #4'
1942 vput vexpr res + -9223372036854775808 0
1943 echo $?/$^ERRNAME $res
1944 vput vexpr res + -9223372036854775808 -1
1945 echo $?/$^ERRNAME $res
1946 vput vexpr res @+ -9223372036854775808 -1
1947 echo $?/$^ERRNAME $res
1948 vput vexpr res + 0 -9223372036854775808
1949 echo $?/$^ERRNAME $res
1950 vput vexpr res + -1 -9223372036854775808
1951 echo $?/$^ERRNAME $res
1952 vput vexpr res @+ -1 -9223372036854775808
1953 echo $?/$^ERRNAME $res
1954 echo ' #5'
1955 vput vexpr res - 0 0
1956 echo $?/$^ERRNAME $res
1957 vput vexpr res - 0 1
1958 echo $?/$^ERRNAME $res
1959 vput vexpr res - 1 1
1960 echo $?/$^ERRNAME $res
1961 echo ' #6'
1962 vput vexpr res - 9223372036854775807 0
1963 echo $?/$^ERRNAME $res
1964 vput vexpr res - 9223372036854775807 -1
1965 echo $?/$^ERRNAME $res
1966 vput vexpr res @- 9223372036854775807 -1
1967 echo $?/$^ERRNAME $res
1968 vput vexpr res - 0 9223372036854775807
1969 echo $?/$^ERRNAME $res
1970 vput vexpr res - -1 9223372036854775807
1971 echo $?/$^ERRNAME $res
1972 vput vexpr res - -2 9223372036854775807
1973 echo $?/$^ERRNAME $res
1974 vput vexpr res @- -2 9223372036854775807
1975 echo $?/$^ERRNAME $res
1976 echo ' #7'
1977 vput vexpr res - -9223372036854775808 +0
1978 echo $?/$^ERRNAME $res
1979 vput vexpr res - -9223372036854775808 +1
1980 echo $?/$^ERRNAME $res
1981 vput vexpr res @- -9223372036854775808 +1
1982 echo $?/$^ERRNAME $res
1983 vput vexpr res - 0 -9223372036854775808
1984 echo $?/$^ERRNAME $res
1985 vput vexpr res - +1 -9223372036854775808
1986 echo $?/$^ERRNAME $res
1987 vput vexpr res @- +1 -9223372036854775808
1988 echo $?/$^ERRNAME $res
1989 echo ' #8'
1990 vput vexpr res + -13 -2
1991 echo $?/$^ERRNAME $res
1992 vput vexpr res - 0 0
1993 echo $?/$^ERRNAME $res
1994 vput vexpr res - 0 1
1995 echo $?/$^ERRNAME $res
1996 vput vexpr res - 1 1
1997 echo $?/$^ERRNAME $res
1998 vput vexpr res - -13 -2
1999 echo $?/$^ERRNAME $res
2000 echo ' #9'
2001 vput vexpr res * 0 0
2002 echo $?/$^ERRNAME $res
2003 vput vexpr res * 0 1
2004 echo $?/$^ERRNAME $res
2005 vput vexpr res * 1 1
2006 echo $?/$^ERRNAME $res
2007 vput vexpr res * -13 -2
2008 echo $?/$^ERRNAME $res
2009 echo ' #10'
2010 vput vexpr res / 0 0
2011 echo $?/$^ERRNAME $res
2012 vput vexpr res / 0 1
2013 echo $?/$^ERRNAME $res
2014 vput vexpr res / 1 1
2015 echo $?/$^ERRNAME $res
2016 vput vexpr res / -13 -2
2017 echo $?/$^ERRNAME $res
2018 echo ' #11'
2019 vput vexpr res % 0 0
2020 echo $?/$^ERRNAME $res
2021 vput vexpr res % 0 1
2022 echo $?/$^ERRNAME $res
2023 vput vexpr res % 1 1
2024 echo $?/$^ERRNAME $res
2025 vput vexpr res % -13 -2
2026 echo $?/$^ERRNAME $res
2027 __EOT
2029 check behave:vexpr-numeric 0 "${MBOX}" '960821755 1962'
2031 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
2032 vput vexpr res find 'bananarama' 'nana'
2033 echo $?/$^ERRNAME :$res:
2034 vput vexpr res find 'bananarama' 'bana'
2035 echo $?/$^ERRNAME :$res:
2036 vput vexpr res find 'bananarama' 'Bana'
2037 echo $?/$^ERRNAME :$res:
2038 vput vexpr res find 'bananarama' 'rama'
2039 echo $?/$^ERRNAME :$res:
2040 echo ' #1'
2041 vput vexpr res ifind 'bananarama' 'nana'
2042 echo $?/$^ERRNAME :$res:
2043 vput vexpr res ifind 'bananarama' 'bana'
2044 echo $?/$^ERRNAME :$res:
2045 vput vexpr res ifind 'bananarama' 'Bana'
2046 echo $?/$^ERRNAME :$res:
2047 vput vexpr res ifind 'bananarama' 'rama'
2048 echo $?/$^ERRNAME :$res:
2049 echo ' #2'
2050 vput vexpr res substring 'bananarama' 1
2051 echo $?/$^ERRNAME :$res:
2052 vput vexpr res substring 'bananarama' 3
2053 echo $?/$^ERRNAME :$res:
2054 vput vexpr res substring 'bananarama' 5
2055 echo $?/$^ERRNAME :$res:
2056 vput vexpr res substring 'bananarama' 7
2057 echo $?/$^ERRNAME :$res:
2058 vput vexpr res substring 'bananarama' 9
2059 echo $?/$^ERRNAME :$res:
2060 vput vexpr res substring 'bananarama' 10
2061 echo $?/$^ERRNAME :$res:
2062 vput vexpr res substring 'bananarama' 1 3
2063 echo $?/$^ERRNAME :$res:
2064 vput vexpr res substring 'bananarama' 3 3
2065 echo $?/$^ERRNAME :$res:
2066 vput vexpr res substring 'bananarama' 5 3
2067 echo $?/$^ERRNAME :$res:
2068 vput vexpr res substring 'bananarama' 7 3
2069 echo $?/$^ERRNAME :$res:
2070 vput vexpr res substring 'bananarama' 9 3
2071 echo $?/$^ERRNAME :$res:
2072 vput vexpr res substring 'bananarama' 10 3
2073 echo $?/$^ERRNAME :$res:
2074 echo ' #3'
2075 vput vexpr res substring 'bananarama' -1
2076 echo $?/$^ERRNAME :$res:
2077 vput vexpr res substring 'bananarama' -3
2078 echo $?/$^ERRNAME :$res:
2079 vput vexpr res substring 'bananarama' -5
2080 echo $?/$^ERRNAME :$res:
2081 vput vexpr res substring 'bananarama' -7
2082 echo $?/$^ERRNAME :$res:
2083 vput vexpr res substring 'bananarama' -9
2084 echo $?/$^ERRNAME :$res:
2085 vput vexpr res substring 'bananarama' -10
2086 echo $?/$^ERRNAME :$res:
2087 vput vexpr res substring 'bananarama' 1 -3
2088 echo $?/$^ERRNAME :$res:
2089 vput vexpr res substring 'bananarama' 3 -3
2090 echo $?/$^ERRNAME :$res:
2091 vput vexpr res substring 'bananarama' 5 -3
2092 echo $?/$^ERRNAME :$res:
2093 vput vexpr res substring 'bananarama' 7 -3
2094 echo $?/$^ERRNAME :$res:
2095 vput vexpr res substring 'bananarama' 9 -3
2096 echo $?/$^ERRNAME :$res:
2097 vput vexpr res substring 'bananarama' 10 -3
2098 echo $?/$^ERRNAME :$res:
2099 echo ' #4'
2100 vput vexpr res trim 'Cocoon Cocoon'
2101 echo $?/$^ERRNAME :$res:
2102 vput vexpr res trim ' Cocoon Cocoon '
2103 echo $?/$^ERRNAME :$res:
2104 vput vexpr res trim-front 'Cocoon Cocoon'
2105 echo $?/$^ERRNAME :$res:
2106 vput vexpr res trim-front ' Cocoon Cocoon '
2107 echo $?/$^ERRNAME :$res:
2108 vput vexpr res trim-end 'Cocoon Cocoon'
2109 echo $?/$^ERRNAME :$res:
2110 vput vexpr res trim-end ' Cocoon Cocoon '
2111 echo $?/$^ERRNAME :$res:
2112 __EOT
2114 check behave:vexpr-string 0 "${MBOX}" '3182004322 601'
2116 if have_feat regex; then
2117 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
2118 vput vexpr res regex 'bananarama' 'nana'
2119 echo $?/$^ERRNAME :$res:
2120 vput vexpr res regex 'bananarama' 'bana'
2121 echo $?/$^ERRNAME :$res:
2122 vput vexpr res regex 'bananarama' 'Bana'
2123 echo $?/$^ERRNAME :$res:
2124 vput vexpr res regex 'bananarama' 'rama'
2125 echo $?/$^ERRNAME :$res:
2126 echo ' #1'
2127 vput vexpr res iregex 'bananarama' 'nana'
2128 echo $?/$^ERRNAME :$res:
2129 vput vexpr res iregex 'bananarama' 'bana'
2130 echo $?/$^ERRNAME :$res:
2131 vput vexpr res iregex 'bananarama' 'Bana'
2132 echo $?/$^ERRNAME :$res:
2133 vput vexpr res iregex 'bananarama' 'rama'
2134 echo $?/$^ERRNAME :$res:
2135 echo ' #2'
2136 vput vexpr res regex 'bananarama' '(.*)nana(.*)' '\${1}a\${0}u{\$2}'
2137 echo $?/$^ERRNAME :$res:
2138 vput vexpr res regex 'bananarama' '(.*)bana(.*)' '\${1}a\${0}u\$2'
2139 echo $?/$^ERRNAME :$res:
2140 vput vexpr res regex 'bananarama' 'Bana(.+)' '\$1\$0'
2141 echo $?/$^ERRNAME :$res:
2142 vput vexpr res regex 'bananarama' '(.+)rama' '\$1\$0'
2143 echo $?/$^ERRNAME :$res:
2144 echo ' #3'
2145 vput vexpr res iregex 'bananarama' '(.*)nana(.*)' '\${1}a\${0}u{\$2}'
2146 echo $?/$^ERRNAME :$res:
2147 vput vexpr res iregex 'bananarama' '(.*)bana(.*)' '\${1}a\${0}u\$2'
2148 echo $?/$^ERRNAME :$res:
2149 vput vexpr res iregex 'bananarama' 'Bana(.+)' '\$1\$0'
2150 echo $?/$^ERRNAME :$res:
2151 vput vexpr res iregex 'bananarama' '(.+)rama' '\$1\$0'
2152 echo $?/$^ERRNAME :$res:
2153 echo ' #4'
2154 __EOT
2156 check behave:vexpr-regex 0 "${MBOX}" '3270360157 311'
2157 else
2158 printf 'behave:vexpr-regex: unsupported, skipped\n'
2161 t_epilog
2164 t_behave_call_ret() {
2165 t_prolog t_behave_call_ret
2167 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Snomemdebug > "${MBOX}" 2>&1
2168 define w1 {
2169 echon ">$1 "
2170 vput vexpr i + $1 1
2171 if [ $i -le 42 ]
2172 vput vexpr j '&' $i 7
2173 if [ $j -eq 7 ]
2174 echo .
2176 call w1 $i
2177 wysh set i=$? k=$!
2178 vput vexpr j '&' $i 7
2179 echon "<$1/$i/$k "
2180 if [ $j -eq 7 ]
2181 echo .
2183 else
2184 echo ! The end for $1
2186 return $1
2188 # Transport $?/$! up the call chain
2189 define w2 {
2190 echon ">$1 "
2191 vput vexpr i + $1 1
2192 if [ $1 -lt 42 ]
2193 call w2 $i
2194 wysh set i=$? j=$! k=$^ERRNAME
2195 echon "<$1/$i/$k "
2196 return $i $j
2197 else
2198 echo ! The end for $1
2199 return $i $^ERR-BUSY
2201 echoerr au
2203 # Up and down it goes
2204 define w3 {
2205 echon ">$1/$2 "
2206 vput vexpr i + $1 1
2207 if [ $1 -lt 42 ]
2208 call w3 $i $2
2209 wysh set i=$? j=$!
2210 vput vexpr k - $1 $2
2211 if [ $k -eq 21 ]
2212 vput vexpr i + $1 1
2213 vput vexpr j + $2 1
2214 echo "# <$i/$j> .. "
2215 call w3 $i $j
2216 wysh set i=$? j=$!
2218 eval echon "<\$1=\$i/\$^ERRNAME-$j "
2219 return $i $j
2220 else
2221 echo ! The end for $1=$i/$2
2222 if [ "$2" != "" ]
2223 return $i $^ERR-DOM
2224 else
2225 return $i $^ERR-BUSY
2228 echoerr au
2231 call w1 0; echo ?=$? !=$!; echo -----;
2232 call w2 0; echo ?=$? !=$^ERRNAME; echo -----;
2233 call w3 0 1; echo ?=$? !=$^ERRNAME; echo -----;
2234 __EOT
2236 check behave:call_ret 0 "${MBOX}" '1572045517 5922'
2238 t_epilog
2241 t_behave_xcall() {
2242 t_prolog t_behave_xcall
2244 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Snomemdebug > "${MBOX}" 2>&1
2245 define work {
2246 echon "$1 "
2247 vput vexpr i + $1 1
2248 if [ $i -le 1111 ]
2249 vput vexpr j '&' $i 7
2250 if [ $j -eq 7 ]
2251 echo .
2253 \xcall work $i $2
2255 echo ! The end for $1/$2
2256 if [ "$2" != "" ]
2257 return $i $^ERR-BUSY
2260 define xwork {
2261 \xcall work 0 $2
2263 call work 0
2264 echo ?=$? !=$!
2265 call xwork
2266 echo ?=$? !=$!
2267 xcall xwork
2268 echo ?=$? !=$^ERRNAME
2270 call work 0 yes
2271 echo ?=$? !=$^ERRNAME
2272 call xwork 0 yes
2273 echo ?=$? !=$^ERRNAME
2274 __EOT
2276 check behave:xcall-1 0 "${MBOX}" '2401702082 23801'
2280 ${cat} <<- '__EOT' > "${BODY}"
2281 define __w {
2282 echon "$1 "
2283 vput vexpr i + $1 1
2284 if [ $i -le 111 ]
2285 vput vexpr j '&' $i 7
2286 if [ $j -eq 7 ]
2287 echo .
2289 \xcall __w $i $2
2291 echo ! The end for $1
2292 if [ $2 -eq 0 ]
2293 nonexistingcommand
2294 echo would be err with errexit
2295 return
2297 echo calling exit
2298 exit
2300 define work {
2301 echo eins
2302 call __w 0 0
2303 echo zwei, ?=$? !=$!
2304 localopts yes; set errexit
2305 ignerr call __w 0 0
2306 echo drei, ?=$? !=$^ERRNAME
2307 call __w 0 $1
2308 echo vier, ?=$? !=$^ERRNAME, this is an error
2310 ignerr call work 0
2311 echo outer 1, ?=$? !=$^ERRNAME
2312 xxxign call work 0
2313 echo outer 2, ?=$? !=$^ERRNAME, could be error if xxxign non-empty
2314 call work 1
2315 echo outer 3, ?=$? !=$^ERRNAME
2316 echo this is definitely an error
2317 __EOT
2319 < "${BODY}" ${MAILX} ${ARGS} -X'commandalias xxxign ignerr' -Snomemdebug \
2320 > "${MBOX}" 2>&1
2321 check behave:xcall-2 0 "${MBOX}" '3900716531 4200'
2323 < "${BODY}" ${MAILX} ${ARGS} -X'commandalias xxxign " "' -Snomemdebug \
2324 > "${MBOX}" 2>&1
2325 check behave:xcall-3 1 "${MBOX}" '1006776201 2799'
2327 t_epilog
2330 t_behave_vpospar() {
2331 t_prolog t_behave_vpospar
2333 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
2334 vpospar set hey, "'you ", world!
2335 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2336 vput vpospar x quote; echo x<$x>
2337 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2338 vput vpospar y quote;echo y<$y>
2339 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2340 eval vpospar set ${y};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2341 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2343 define infun2 {
2344 echo infun2:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2345 vput vpospar z quote;echo infun2:z<$z>
2348 define infun {
2349 echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2350 vput vpospar y quote;echo infun:y<$y>
2351 eval vpospar set ${x};echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2352 vpospar clear;echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2353 eval call infun2 $x
2354 echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2355 eval vpospar set ${y};echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2358 call infun This "in a" fun
2359 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2360 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2361 __EOT
2362 check behave:vpospar-1 0 "${MBOX}" '155175639 866'
2365 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
2366 set ifs=\'
2367 echo ifs<$ifs> ifs-ws<$ifs-ws>
2368 vpospar set hey, "'you ", world!
2369 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2370 vput vpospar x quote; echo x<$x>
2371 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2372 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2374 set ifs=,
2375 echo ifs<$ifs> ifs-ws<$ifs-ws>
2376 vpospar set hey, "'you ", world!
2377 unset ifs;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2378 set ifs=,
2379 vput vpospar x quote; echo x<$x>
2380 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2381 eval vpospar set ${x};\
2382 unset ifs;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2384 wysh set ifs=$',\t'
2385 echo ifs<$ifs> ifs-ws<$ifs-ws>
2386 vpospar set hey, "'you ", world!
2387 unset ifs; echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2388 wysh set ifs=$',\t'
2389 vput vpospar x quote; echo x<$x>
2390 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2391 eval vpospar set ${x};\
2392 unset ifs;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2393 __EOT
2394 check behave:vpospar-ifs 0 "${MBOX}" '2015927702 706'
2396 t_epilog
2399 t_behave_atxplode() {
2400 t_prolog t_behave_atxplode
2401 TRAP_EXIT_ADDONS="./.t*"
2403 ${cat} > ./.t.sh <<- '___'; ${cat} > ./.t.rc <<- '___'
2404 x() { echo $#; }
2405 xxx() {
2406 printf " (1/$#: <$1>)"
2407 shift
2408 if [ $# -gt 0 ]; then
2409 xxx "$@"
2410 else
2411 echo
2414 yyy() {
2415 eval "$@ ' ball"
2417 set --
2418 x "$@"
2419 x "$@"''
2420 x " $@"
2421 x "$@ "
2422 printf yyy;yyy 'xxx' "b\$'\t'u ' "
2423 printf xxx;xxx arg ,b u.
2424 printf xxx;xxx arg , .
2425 printf xxx;xxx arg ,ball.
2427 define x {
2428 echo $#
2430 define xxx {
2431 echon " (1/$#: <$1>)"
2432 shift
2433 if [ $# -gt 0 ]
2434 \xcall xxx "$@"
2435 endif
2436 echo
2438 define yyy {
2439 eval "$@ ' ball"
2441 vpospar set
2442 call x "$@"
2443 call x "$@"''
2444 call x " $@"
2445 call x "$@ "
2446 echon yyy;call yyy '\call xxx' "b\$'\t'u ' "
2447 echon xxx;call xxx arg ,b u.
2448 echon xxx;call xxx arg , .
2449 echon xxx;call xxx arg ,ball.
2452 ${MAILX} ${ARGS} -X'source ./.t.rc' -Xx > "${MBOX}" 2>&1
2453 check behave:atxplode-1 0 "${MBOX}" '41566293 164'
2455 #${SHELL} ./.t.sh > ./.tshout 2>&1
2456 #check behave:atxplode:disproof-1 0 ./.tshout '41566293 164'
2458 t_epilog
2461 t_behave_read() {
2462 t_prolog t_behave_read
2463 TRAP_EXIT_ADDONS="./.t*"
2465 ${cat} <<- '__EOT' > .tin
2466 hey1, "'you ", world!
2467 hey2, "'you ", bugs bunny!
2468 hey3, "'you ",
2469 hey4, "'you "
2470 __EOT
2472 ${cat} <<- '__EOT' |\
2473 ${MAILX} ${ARGS} -X'readctl create ./.tin' > "${MBOX}" 2>&1
2474 read a b c
2475 echo $?/$^ERRNAME / <$a><$b><$c>
2476 read a b c
2477 echo $?/$^ERRNAME / <$a><$b><$c>
2478 read a b c
2479 echo $?/$^ERRNAME / <$a><$b><$c>
2480 read a b c
2481 echo $?/$^ERRNAME / <$a><$b><$c>
2482 unset a b c;read a b c
2483 echo $?/$^ERRNAME / <$a><$b><$c>
2484 readctl remove ./.tin;echo readctl remove:$?/$^ERRNAME
2485 __EOT
2486 check behave:read-1 0 "${MBOX}" '1527910147 173'
2488 ${cat} <<- '__EOT' > .tin2
2489 hey2.0,:"'you ",:world!:mars.:
2490 hey2.1,:"'you ",:world!
2491 hey2.2,:"'you ",:bugs bunny!
2492 hey2.3,:"'you ",:
2493 hey2.4,:"'you ":
2495 __EOT
2497 ${cat} <<- '__EOT' |\
2498 6< .tin2 ${MAILX} ${ARGS} -X 'readctl create 6' > "${MBOX}" 2>&1
2499 set ifs=:
2500 read a b c
2501 echo $?/$^ERRNAME / <$a><$b><$c>
2502 read a b c
2503 echo $?/$^ERRNAME / <$a><$b><$c>
2504 read a b c
2505 echo $?/$^ERRNAME / <$a><$b><$c>
2506 read a b c
2507 echo $?/$^ERRNAME / <$a><$b><$c>
2508 read a b c
2509 echo $?/$^ERRNAME / <$a><$b><$c>
2510 read a b c
2511 echo $?/$^ERRNAME / <$a><$b><$c>
2512 unset a b c;read a b c
2513 echo $?/$^ERRNAME / <$a><$b><$c>
2514 read a b c
2515 echo $?/$^ERRNAME / <$a><$b><$c>
2516 readctl remove 6;echo readctl remove:$?/$^ERRNAME
2517 __EOT
2518 check behave:read-ifs 0 "${MBOX}" '890153490 298'
2520 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
2521 readctl create .tin
2522 readall d; echo $?/$^ERRNAME / <$d>
2523 wysh set d;readall d;echo $?/$^ERRNAME / <$d>
2524 readctl create .tin2
2525 readall d; echo $?/$^ERRNAME / <$d>
2526 wysh set d;readall d;echo $?/$^ERRNAME / <$d>
2527 readctl remove .tin;echo $?/$^ERRNAME;\
2528 readctl remove .tin2;echo $?/$^ERRNAME
2529 __EOT
2530 check behave:readall 0 "${MBOX}" '860434889 333'
2532 t_epilog
2535 t_behave_mbox() {
2536 t_prolog t_behave_mbox
2537 TRAP_EXIT_ADDONS="./.t*"
2541 while [ ${i} -lt 112 ]; do
2542 printf 'm file://%s\n~s Subject %s\nHello %s!\n~.\n' \
2543 "${MBOX}" "${i}" "${i}"
2544 i=`add ${i} 1`
2545 done
2546 ) | ${MAILX} ${ARGS}
2547 check behave:mbox-1 0 "${MBOX}" '1140119864 13780'
2549 printf 'File "%s"\ncopy * "%s"\nFile "%s"\nfrom*' "${MBOX}" .tmbox1 .tmbox1 |
2550 ${MAILX} ${ARGS} -Sshowlast > .tlst
2551 check behave:mbox-2 0 .tlst '2739893312 9103'
2553 printf 'File "%s"\ncopy * "file://%s"\nFile "file://%s"\nfrom*' \
2554 "${MBOX}" .tmbox2 .tmbox2 | ${MAILX} ${ARGS} -Sshowlast > .tlst
2555 check behave:mbox-3 0 .tlst '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 > .tlst
2568 check behave:mbox-4 0 .tmbox3 '631132924 6890'
2569 check behave:mbox-5 - .tlst '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 > .tlst
2582 check behave:mbox-6 0 .tmbox3 '1387070539 13655'
2583 ${sed} 2d < .tlst > .tlstx
2584 check behave:mbox-7 - .tlstx '2729940494 13645'
2586 t_epilog
2589 t_behave_maildir() {
2590 t_prolog t_behave_maildir
2591 TRAP_EXIT_ADDONS="./.t*"
2595 while [ ${i} -lt 112 ]; do
2596 printf 'm file://%s\n~s Subject %s\nHello %s!\n~.\n' \
2597 "${MBOX}" "${i}" "${i}"
2598 i=`add ${i} 1`
2599 done
2600 ) | ${MAILX} ${ARGS}
2601 check behave:maildir-1 0 "${MBOX}" '1140119864 13780'
2603 printf 'File "%s"
2604 copy * "%s"
2605 File "%s"
2606 from*
2607 ' "${MBOX}" .tmdir1 .tmdir1 |
2608 ${MAILX} ${ARGS} -Snewfolders=maildir -Sshowlast > .tlst
2609 check behave:maildir-2 0 .tlst '1797938753 9103'
2611 printf 'File "%s"
2612 copy * "maildir://%s"
2613 File "maildir://%s"
2614 from*
2615 ' "${MBOX}" .tmdir2 .tmdir2 |
2616 ${MAILX} ${ARGS} -Sshowlast > .tlst
2617 check behave:maildir-3 0 .tlst '1155631089 9113'
2619 printf 'File "maildir://%s"
2620 copy * "file://%s"
2621 File "file://%s"
2622 from*
2623 ' .tmdir2 .tmbox1 .tmbox1 |
2624 ${MAILX} ${ARGS} -Sshowlast > .tlst
2625 check behave:maildir-4 0 .tmbox1 '2646131190 13220'
2626 check behave:maildir-5 - .tlst '3701297796 9110'
2628 # only the odd (even)
2630 printf 'File "maildir://%s"
2631 copy ' .tmdir2
2633 while [ ${i} -lt 112 ]; do
2634 j=`modulo ${i} 2`
2635 [ ${j} -eq 1 ] && printf '%s ' "${i}"
2636 i=`add ${i} 1`
2637 done
2638 printf ' file://%s
2639 File "file://%s"
2640 from*
2641 ' .tmbox2 .tmbox2
2642 ) | ${MAILX} ${ARGS} -Sshowlast > .tlst
2643 check behave:maildir-6 0 .tmbox2 '142890131 6610'
2644 check behave:maildir-7 - .tlst '960096773 4573'
2645 # ...
2647 printf 'file "maildir://%s"
2648 move ' .tmdir2
2650 while [ ${i} -lt 112 ]; do
2651 j=`modulo ${i} 2`
2652 [ ${j} -eq 0 ] && [ ${i} -ne 0 ] && printf '%s ' "${i}"
2653 i=`add ${i} 1`
2654 done
2655 printf ' file://%s
2656 File "file://%s"
2657 from*
2658 File "maildir://%s"
2659 from*
2660 ' .tmbox2 .tmbox2 .tmdir2
2661 ) | ${MAILX} ${ARGS} -Sshowlast > .tlst
2662 check behave:maildir-8 0 .tmbox2 '3806905791 13100'
2663 ${sed} 2d < .tlst > .tlstx
2664 check behave:maildir-9 - .tlstx '4216815295 13645'
2666 t_epilog
2669 t_behave_record_a_resend() {
2670 t_prolog t_behave_record_a_resend
2671 TRAP_EXIT_ADDONS="./.t.record ./.t.resent"
2673 printf '
2674 set record=%s
2675 m %s\n~s Subject 1.\nHello.\n~.
2676 set record-files add-file-recipients
2677 m %s\n~s Subject 2.\nHello.\n~.
2678 File %s
2679 resend 2 ./.t.resent
2680 Resend 1 ./.t.resent
2681 set record-resent
2682 resend 2 ./.t.resent
2683 Resend 1 ./.t.resent
2684 ' ./.t.record "${MBOX}" "${MBOX}" "${MBOX}" |
2685 ${MAILX} ${ARGS}
2687 check behave:record_a_resend-1 0 "${MBOX}" '3057873538 256'
2688 check behave:record_a_resend-2 - .t.record '391356429 460'
2689 check behave:record_a_resend-3 - .t.resent '2685231691 648'
2691 t_epilog
2694 t_behave_e_H_L_opts() {
2695 t_prolog t_behave_e_H_L_opts
2696 TRAP_EXIT_ADDONS="./.tsendmail.sh ./.t.mbox"
2698 touch ./.t.mbox
2699 ${MAILX} ${ARGS} -ef ./.t.mbox
2700 echo ${?} > "${MBOX}"
2702 ${cat} <<-_EOT > ./.tsendmail.sh
2703 #!${SHELL} -
2704 (echo 'From Alchemilla Wed Apr 07 17:03:33 2017' && ${cat} && echo
2705 ) >> "./.t.mbox"
2706 _EOT
2707 chmod 0755 ./.tsendmail.sh
2708 printf 'm me@exam.ple\nLine 1.\nHello.\n~.\n' |
2709 ${MAILX} ${ARGS} -Smta=./.tsendmail.sh
2710 printf 'm you@exam.ple\nLine 1.\nBye.\n~.\n' |
2711 ${MAILX} ${ARGS} -Smta=./.tsendmail.sh
2713 ${MAILX} ${ARGS} -ef ./.t.mbox
2714 echo ${?} >> "${MBOX}"
2715 ${MAILX} ${ARGS} -efL @t@me ./.t.mbox
2716 echo ${?} >> "${MBOX}"
2717 ${MAILX} ${ARGS} -efL @t@you ./.t.mbox
2718 echo ${?} >> "${MBOX}"
2719 ${MAILX} ${ARGS} -efL '@>@Line 1' ./.t.mbox
2720 echo ${?} >> "${MBOX}"
2721 ${MAILX} ${ARGS} -efL '@>@Hello.' ./.t.mbox
2722 echo ${?} >> "${MBOX}"
2723 ${MAILX} ${ARGS} -efL '@>@Bye.' ./.t.mbox
2724 echo ${?} >> "${MBOX}"
2725 ${MAILX} ${ARGS} -efL '@>@Good bye.' ./.t.mbox
2726 echo ${?} >> "${MBOX}"
2728 ${MAILX} ${ARGS} -fH ./.t.mbox >> "${MBOX}"
2729 echo ${?} >> "${MBOX}"
2730 ${MAILX} ${ARGS} -fL @t@me ./.t.mbox >> "${MBOX}"
2731 echo ${?} >> "${MBOX}"
2732 ${MAILX} ${ARGS} -fL @t@you ./.t.mbox >> "${MBOX}"
2733 echo ${?} >> "${MBOX}"
2734 ${MAILX} ${ARGS} -fL '@>@Line 1' ./.t.mbox >> "${MBOX}"
2735 echo ${?} >> "${MBOX}"
2736 ${MAILX} ${ARGS} -fL '@>@Hello.' ./.t.mbox >> "${MBOX}"
2737 echo ${?} >> "${MBOX}"
2738 ${MAILX} ${ARGS} -fL '@>@Bye.' ./.t.mbox >> "${MBOX}"
2739 echo ${?} >> "${MBOX}"
2740 ${MAILX} ${ARGS} -fL '@>@Good bye.' ./.t.mbox >> "${MBOX}" 2>/dev/null
2741 echo ${?} >> "${MBOX}"
2743 check behave:e_H_L_opts - "${MBOX}" '1708955574 678'
2745 t_epilog
2748 t_behave_alternates() {
2749 t_prolog t_behave_alternates
2750 TRAP_EXIT_ADDONS="./.t*"
2752 ${cat} <<-_EOT > ./.tsendmail.sh
2753 #!${SHELL} -
2754 (echo 'From Valeriana Sat Jul 08 15:54:03 2017' && ${cat} && echo
2755 ) >> "${MBOX}"
2756 _EOT
2757 chmod 0755 ./.tsendmail.sh
2759 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Smta=./.tsendmail.sh > ./.tall 2>&1
2760 echo --0
2761 alternates
2762 echo $?/$^ERRNAME
2763 alternates a1@b1 a2@b2 a3@b3
2764 echo $?/$^ERRNAME
2765 alternates
2766 echo $?/$^ERRNAME
2767 vput alternates rv
2768 echo $?/$^ERRNAME <$rv>
2770 echo --1
2771 unalternates a2@b2
2772 vput alternates rv
2773 echo $?/$^ERRNAME <$rv>
2774 unalternates a3@b3
2775 vput alternates rv
2776 echo $?/$^ERRNAME <$rv>
2777 unalternates a1@b1
2778 vput alternates rv
2779 echo $?/$^ERRNAME <$rv>
2781 echo --2
2782 unalternates *
2783 alternates a1@b1 a2@b2 a3@b3
2784 unalternates a3@b3
2785 vput alternates rv
2786 echo $?/$^ERRNAME <$rv>
2787 unalternates a2@b2
2788 vput alternates rv
2789 echo $?/$^ERRNAME <$rv>
2790 unalternates a1@b1
2791 vput alternates rv
2792 echo $?/$^ERRNAME <$rv>
2794 echo --3
2795 alternates a1@b1 a2@b2 a3@b3
2796 unalternates a1@b1
2797 vput alternates rv
2798 echo $?/$^ERRNAME <$rv>
2799 unalternates a2@b2
2800 vput alternates rv
2801 echo $?/$^ERRNAME <$rv>
2802 unalternates a3@b3
2803 vput alternates rv
2804 echo $?/$^ERRNAME <$rv>
2806 echo --4
2807 unalternates *
2808 alternates a1@b1 a2@b2 a3@b3
2809 unalternates *
2810 vput alternates rv
2811 echo $?/$^ERRNAME <$rv>
2813 echo --5
2814 unalternates *
2815 alternates a1@b1 a1@c1 a1@d1 a2@b2 a3@b3 a3@c3 a3@d3
2816 m a1@b1 a1@c1 a1@d1
2817 ~s all alternates, only a1@b1 remains
2818 ~c a2@b2
2819 ~b a3@b3 a3@c3 a3@d3
2820 ~r - '_EOT'
2821 This body is!
2822 This also body is!!
2823 _EOT
2826 echo --6
2827 unalternates *
2828 alternates a1@b1 a1@c1 a2@b2 a3@b3
2829 m a1@b1 a1@c1 a1@d1
2830 ~s a1@b1 a1@d1, and a3@c3 a3@d3 remain
2831 ~c a2@b2
2832 ~b a3@b3 a3@c3 a3@d3
2833 ~r - '_EOT'
2834 This body2 is!
2835 _EOT
2838 echo --7
2839 alternates a1@b1 a2@b2 a3; set allnet
2840 m a1@b1 a1@c1 a1@d1
2841 ~s all alternates via allnet, only a1@b1 remains
2842 ~c a2@b2
2843 ~b a3@b3 a3@c3 a3@d3
2844 ~r - '_EOT'
2845 This body3 is!
2846 _EOT
2849 echo --10
2850 unalternates *
2851 alternates a1@b1
2852 echo $?/$^ERRNAME
2853 vput alternates rv
2854 echo $?/$^ERRNAME <$rv>
2855 alternates a2@b2
2856 echo $?/$^ERRNAME
2857 vput alternates rv
2858 echo $?/$^ERRNAME <$rv>
2859 alternates a3@b3
2860 echo $?/$^ERRNAME
2861 vput alternates rv
2862 echo $?/$^ERRNAME <$rv>
2863 alternates a4@b4
2864 echo $?/$^ERRNAME
2865 vput alternates rv
2866 echo $?/$^ERRNAME <$rv>
2868 unalternates *
2869 vput alternates rv
2870 echo $?/$^ERRNAME <$rv>
2872 echo --11
2873 set posix
2874 alternates a1@b1 a2@b2
2875 echo $?/$^ERRNAME
2876 vput alternates rv
2877 echo $?/$^ERRNAME <$rv>
2878 alternates a3@b3 a4@b4
2879 echo $?/$^ERRNAME
2880 vput alternates rv
2881 echo $?/$^ERRNAME <$rv>
2882 __EOT
2883 check behave:alternates-1 0 "${MBOX}" '142184864 515'
2884 check behave:alternates-2 - .tall '1878598364 505'
2886 t_epilog
2889 t_behave_alias() {
2890 t_prolog t_behave_alias
2891 TRAP_EXIT_ADDONS="./.t*"
2893 ${cat} <<-_EOT > ./.tsendmail.sh
2894 #!${SHELL} -
2895 (echo 'From Hippocastanum Mon Jun 19 15:07:07 2017' && ${cat} && echo
2896 ) >> "${MBOX}"
2897 _EOT
2898 chmod 0755 ./.tsendmail.sh
2900 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Smta=./.tsendmail.sh > ./.tall 2>&1
2901 alias a1 ex1@a1.ple
2902 alias a1 ex2@a1.ple "EX3 <ex3@a1.ple>"
2903 alias a1 ex4@a1.ple
2904 alias a2 ex1@a2.ple ex2@a2.ple ex3@a2.ple ex4@a2.ple
2905 alias a3 a4
2906 alias a4 a5 ex1@a4.ple
2907 alias a5 a6
2908 alias a6 a7 ex1@a6.ple
2909 alias a7 a8
2910 alias a8 ex1@a8.ple
2911 alias a1
2912 alias a2
2913 alias a3
2914 m a1
2915 ~c a2
2916 ~b a3
2917 ~r - '_EOT'
2918 This body is!
2919 This also body is!!
2920 _EOT
2921 __EOT
2922 check behave:alias-1 0 "${MBOX}" '2496925843 272'
2923 check behave:alias-2 - .tall '3548953204 152'
2925 # TODO t_behave_alias: n_ALIAS_MAXEXP is compile-time constant,
2926 # TODO need to somehow provide its contents to the test, then test
2928 t_epilog
2931 t_behave_filetype() {
2932 t_prolog t_behave_filetype
2933 TRAP_EXIT_ADDONS="./.t*"
2935 ${cat} <<-_EOT > ./.tsendmail.sh
2936 #!${SHELL} -
2937 (echo 'From Alchemilla Wed Apr 25 15:12:13 2017' && ${cat} && echo
2938 ) >> "${MBOX}"
2939 _EOT
2940 chmod 0755 ./.tsendmail.sh
2942 printf 'm m1@e.t\nL1\nHy1\n~.\nm m2@e.t\nL2\nHy2\n~@ %s\n~.\n' \
2943 "${SRCDIR}snailmail.jpg" | ${MAILX} ${ARGS} -Smta=./.tsendmail.sh
2944 check behave:filetype-1 0 "${MBOX}" '1594682963 13520'
2946 if (echo | gzip -c) >/dev/null 2>&1; then
2947 ${rm} -f ./.t.mbox*
2949 printf 'File "%s"\ncopy 1 ./.t.mbox.gz\ncopy 2 ./.t.mbox.gz' \
2950 "${MBOX}" | ${MAILX} ${ARGS} \
2951 -X'filetype gz gzip\ -dc gzip\ -c'
2952 printf 'File ./.t.mbox.gz\ncopy * ./.t.mbox\n' |
2953 ${MAILX} ${ARGS} -X'filetype gz gzip\ -dc gzip\ -c'
2954 } > ./.t.out 2>&1
2955 check behave:filetype-2 - "./.t.mbox" '1594682963 13520'
2956 check behave:filetype-3 - "./.t.out" '2392348396 102'
2957 else
2958 echo 'behave:filetype-2: unsupported, skipped'
2959 echo 'behave:filetype-3: unsupported, skipped'
2963 ${rm} -f ./.t.mbox*
2964 printf 'File "%s"\ncopy 1 ./.t.mbox.gz
2965 copy 2 ./.t.mbox.gz
2966 copy 1 ./.t.mbox.gz
2967 copy 2 ./.t.mbox.gz
2968 ' "${MBOX}" |
2969 ${MAILX} ${ARGS} \
2970 -X'filetype gz gzip\ -dc gzip\ -c' \
2971 -X'filetype mbox.gz "${sed} 1,3d|${cat}" \
2972 "echo eins;echo zwei;echo und mit ${sed} bist Du dabei;${cat}"'
2973 printf 'File ./.t.mbox.gz\ncopy * ./.t.mbox\n' |
2974 ${MAILX} ${ARGS} \
2975 -X'filetype gz gzip\ -dc gzip\ -c' \
2976 -X'filetype mbox.gz "${sed} 1,3d|${cat}" kill\ 0'
2977 } > ./.t.out 2>&1
2978 check behave:filetype-4 - "./.t.mbox" '2886541147 27060'
2979 check behave:filetype-5 - "./.t.out" '852335377 172'
2981 t_epilog
2984 t_behave_message_injections() {
2985 t_prolog t_behave_message_injections
2986 TRAP_EXIT_ADDONS="./.t*"
2988 ${cat} <<-_EOT > ./.tsendmail.sh
2989 #!${SHELL} -
2990 (echo 'From Echinacea Tue Jun 20 15:54:02 2017' && ${cat} && echo
2991 ) > "${MBOX}"
2992 _EOT
2993 chmod 0755 ./.tsendmail.sh
2995 echo mysig > ./.tmysig
2997 echo some-body | ${MAILX} ${ARGS} -Smta=./.tsendmail.sh \
2998 -Smessage-inject-head=head-inject \
2999 -Smessage-inject-tail=tail-inject \
3000 -Ssignature=./.tmysig \
3001 ex@am.ple > ./.tall 2>&1
3002 check behave:message_injections-1 0 "${MBOX}" '2434746382 134'
3003 check behave:message_injections-2 - .tall '4294967295 0' # empty file
3005 ${cat} <<-_EOT > ./.template
3006 From: me
3007 To: ex1@am.ple
3008 Cc: ex2@am.ple
3009 Subject: This subject is
3011 Body, body, body me.
3012 _EOT
3013 < ./.template ${MAILX} ${ARGS} -t -Smta=./.tsendmail.sh \
3014 -Smessage-inject-head=head-inject \
3015 -Smessage-inject-tail=tail-inject \
3016 -Ssignature=./.tmysig \
3017 > ./.tall 2>&1
3018 check behave:message_injections-3 0 "${MBOX}" '3114203412 198'
3019 check behave:message_injections-4 - .tall '4294967295 0' # empty file
3021 t_epilog
3024 t_behave_attachments() {
3025 t_prolog t_behave_attachments
3026 TRAP_EXIT_ADDONS="./.t*"
3028 ${cat} <<-_EOT > ./.tsendmail.sh
3029 #!${SHELL} -
3030 (echo 'From Cannabis Sun Feb 18 02:02:46 2018' && ${cat} && echo
3031 ) >> "${MBOX}"
3032 _EOT
3033 chmod 0755 ./.tsendmail.sh
3035 ${cat} <<-_EOT > ./.tx
3036 From steffen Sun Feb 18 02:48:40 2018
3037 Date: Sun, 18 Feb 2018 02:48:40 +0100
3039 Subject: m1
3040 User-Agent: s-nail v14.9.7
3043 From steffen Sun Feb 18 02:48:42 2018
3044 Date: Sun, 18 Feb 2018 02:48:42 +0100
3046 Subject: m2
3047 User-Agent: s-nail v14.9.7
3050 _EOT
3051 echo att1 > ./.t1
3052 printf 'att2-1\natt2-2\natt2-4\n' > ./'.t 2'
3053 printf 'att3-1\natt3-2\natt3-4\n' > ./.t3
3054 printf 'att4-1\natt4-2\natt4-4\n' > './.t 4'
3056 printf '\
3057 !@ ./.t3 "./.t 4" ""
3060 ./.t3
3061 "./.t 2"
3065 ' | ${MAILX} ${ARGS} -Sescape=! -Smta=./.tsendmail.sh \
3066 -a ./.t1 -a './.t 2' \
3067 -s attachment-test \
3068 ex@am.ple > ./.tall 2>&1
3069 check behave:attachments-1 0 "${MBOX}" '4107062253 634'
3070 check behave:attachments-2 - .tall '1928331872 720'
3072 ${rm} -f "${MBOX}"
3073 printf '\
3074 mail ex@amp.ple
3075 !s This the subject is
3076 !@ ./.t3 "#2" "./.t 4" "#1" ""
3079 "./.t 4"
3080 "#2"
3084 mail ex@amp.ple
3085 !s Subject two
3086 !@ ./.t3 "#2" "./.t 4" "#1" ""
3092 mail ex@amp.ple
3093 !s Subject three
3094 !@ ./.t3 "" "#2" "" "./.t 4" "" "#1" ""
3097 ./.t3
3101 mail ex@amp.ple
3102 !s Subject Four
3103 !@ ./.t3 "" "#2" "" "./.t 4" "" "#1" ""
3106 "#1"
3110 mail ex@amp.ple
3111 !s Subject Five
3113 "#2"
3117 ' | ${MAILX} ${ARGS} -Sescape=! -Smta=./.tsendmail.sh -Rf ./.tx \
3118 > ./.tall 2>&1
3119 check behave:attachments-3 0 "${MBOX}" '798122412 2285'
3120 check behave:attachments-4 - .tall '2526106274 1910'
3122 t_epilog
3125 t_behave_compose_hooks() { # TODO monster
3126 t_prolog t_behave_compose_hooks
3127 TRAP_EXIT_ADDONS="./.t*"
3129 (echo line one&&echo line two&&echo line three) > ./.treadctl
3130 (echo echo four&&echo echo five&&echo echo six) > ./.tattach
3132 ${cat} <<-_EOT > ./.tsendmail.sh
3133 #!${SHELL} -
3134 (echo 'From PrimulaVeris Wed Apr 10 22:59:00 2017' && ${cat} && echo
3135 ) >> "${MBOX}"
3136 _EOT
3137 chmod 0755 ./.tsendmail.sh
3139 ${cat} <<'__EOT__' > ./.trc
3140 define bail {
3141 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
3143 define xerr {
3144 vput vexpr es substr "$1" 0 1
3145 if [ "$es" != 2 ]
3146 xcall bail "$2"
3149 define read_mline_res {
3150 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
3151 echo $len/$es/$^ERRNAME: $hl
3152 if [ $es -ne $^ERR-NONE ]
3153 xcall bail read_mline_res
3154 elif [ $len -ne 0 ]
3155 \xcall read_mline_res
3158 define ins_addr {
3159 wysh set xh=$1
3160 echo "~^header list"; read hl; echo $hl;\
3161 call xerr "$hl" "in_addr ($xh) 0-1"
3163 echo "~^header insert $xh diet <$xh@exam.ple> spliced";\
3164 read es; echo $es; call xerr "$es" "ins_addr $xh 1-1"
3165 echo "~^header insert $xh <${xh}2@exam.ple>";\
3166 read es; echo $es; call xerr "$es" "ins_addr $xh 1-2"
3167 echo "~^header insert $xh ${xh}3@exam.ple";\
3168 read es; echo $es; call xerr "$es" "ins_addr $xh 1-3"
3169 echo "~^header list $xh"; read hl; echo $hl;\
3170 call xerr "$hl" "ins_addr $xh 1-4"
3171 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 1-5"
3172 call read_mline_res
3174 if [ "$t_remove" == "" ]
3175 return
3178 echo "~^header remove $xh"; read es; call xerr $es "ins_addr $xh 2-1"
3179 echo "~^header remove $xh"; read es; vput vexpr es substr $es 0 3
3180 if [ $es != 501 ]
3181 xcall bail "ins_addr $xh 2-2"
3183 echo "~^header list $xh"; read es; vput vexpr es substr $es 0 3
3184 if [ $es != 501 ]
3185 xcall bail "ins_addr $xh 2-3"
3187 echo "~^header show $xh"; read es; vput vexpr es substr $es 0 3
3188 if [ $es != 501 ]
3189 xcall bail "ins_addr $xh 2-4"
3193 echo "~^header insert $xh diet <$xh@exam.ple> spliced";\
3194 read es; echo $es; call xerr "$es" "ins_addr $xh 3-1"
3195 echo "~^header insert $xh <${xh}2@exam.ple>";\
3196 read es; echo $es; call xerr "$es" "ins_addr $xh 3-2"
3197 echo "~^header insert $xh ${xh}3@exam.ple";\
3198 read es; echo $es; call xerr "$es" "ins_addr $xh 3-3"
3199 echo "~^header list $xh"; read hl; echo $hl;\
3200 call xerr "$hl" "ins_addr $xh 3-4"
3201 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 3-5"
3202 call read_mline_res
3204 echo "~^header remove-at $xh 1"; read es;\
3205 call xerr $es "ins_addr $xh 3-6"
3206 echo "~^header remove-at $xh 1"; read es;\
3207 call xerr $es "ins_addr $xh 3-7"
3208 echo "~^header remove-at $xh 1"; read es;\
3209 call xerr $es "ins_addr $xh 3-8"
3210 echo "~^header remove-at $xh 1"; read es;\
3211 vput vexpr es substr $es 0 3
3212 if [ $es != 501 ]
3213 xcall bail "ins_addr $xh 3-9"
3215 echo "~^header remove-at $xh T"; read es;\
3216 vput vexpr es substr $es 0 3
3217 if [ $es != 505 ]
3218 xcall bail "ins_addr $xh 3-10"
3220 echo "~^header list $xh"; read es;\
3221 vput vexpr es substr $es 0 3
3222 if [ $es != 501 ]
3223 xcall bail "ins_addr $xh 3-11"
3225 echo "~^header show $xh"; read es;\
3226 vput vexpr es substr $es 0 3
3227 if [ $es != 501 ]
3228 xcall bail "ins_addr $xh 3-12"
3232 echo "~^header insert $xh diet <$xh@exam.ple> spliced";\
3233 read es; echo $es; call xerr "$es" "ins_addr $xh 4-1"
3234 echo "~^header insert $xh <${xh}2@exam.ple> (comment) \"Quot(e)d\"";\
3235 read es; echo $es; call xerr "$es" "ins_addr $xh 4-2"
3236 echo "~^header insert $xh ${xh}3@exam.ple";\
3237 read es; echo $es; call xerr "$es" "ins_addr $xh 4-3"
3238 echo "~^header list $xh"; read hl; echo $hl;\
3239 call xerr "$hl" "header list $xh 3-4"
3240 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 4-5"
3241 call read_mline_res
3243 echo "~^header remove-at $xh 3"; read es;\
3244 call xerr $es "ins_addr $xh 4-6"
3245 echo "~^header remove-at $xh 2"; read es;\
3246 call xerr $es "ins_addr $xh 4-7"
3247 echo "~^header remove-at $xh 1"; read es;\
3248 call xerr $es "ins_addr $xh 4-8"
3249 echo "~^header remove-at $xh 1"; read es;\
3250 vput vexpr es substr $es 0 3
3251 if [ $es != 501 ]
3252 xcall bail "ins_addr $xh 4-9"
3254 echo "~^header remove-at $xh T"; read es;\
3255 vput vexpr es substr $es 0 3
3256 if [ $es != 505 ]
3257 xcall bail "ins_addr $xh 4-10"
3259 echo "~^header list $xh"; read es;\
3260 vput vexpr es substr $es 0 3
3261 if [ $es != 501 ]
3262 xcall bail "ins_addr $xh 4-11"
3264 echo "~^header show $xh"; read es;\
3265 vput vexpr es substr $es 0 3
3266 if [ $es != 501 ]
3267 xcall bail "ins_addr $xh 4-12"
3270 define ins_ref {
3271 wysh set xh=$1 mult=$2
3272 echo "~^header list"; read hl; echo $hl;\
3273 call xerr "$hl" "ins_ref ($xh) 0-1"
3275 echo "~^header insert $xh <$xh@exam.ple>";\
3276 read es; echo $es; call xerr "$es" "ins_ref $xh 1-1"
3277 if [ $mult -ne 0 ]
3278 echo "~^header insert $xh <${xh}2@exam.ple>";\
3279 read es; echo $es; call xerr "$es" "ins_ref $xh 1-2"
3280 echo "~^header insert $xh ${xh}3@exam.ple";\
3281 read es; echo $es; call xerr "$es" "ins_ref $xh 1-3"
3282 else
3283 echo "~^header insert $xh <${xh}2@exam.ple>"; read es;\
3284 vput vexpr es substr $es 0 3
3285 if [ $es != 506 ]
3286 xcall bail "ins_ref $xh 1-4"
3290 echo "~^header list $xh"; read hl; echo $hl;\
3291 call xerr "$hl" "ins_ref $xh 1-5"
3292 echo "~^header show $xh"; read es; call xerr $es "ins_ref $xh 1-6"
3293 call read_mline_res
3295 if [ "$t_remove" == "" ]
3296 return
3299 echo "~^header remove $xh"; read es;\
3300 call xerr $es "ins_ref $xh 2-1"
3301 echo "~^header remove $xh"; read es;\
3302 vput vexpr es substr $es 0 3
3303 if [ $es != 501 ]
3304 xcall bail "ins_ref $xh 2-2"
3306 echo "~^header list $xh"; read es;\
3307 vput vexpr es substr $es 0 3
3308 if [ $es != 501 ]
3309 xcall bail "$es ins_ref $xh 2-3"
3311 echo "~^header show $xh"; read es;\
3312 vput vexpr es substr $es 0 3
3313 if [ $es != 501 ]
3314 xcall bail "ins_ref $xh 2-4"
3318 echo "~^header insert $xh <$xh@exam.ple>";\
3319 read es; echo $es; call xerr "$es" "ins_ref $xh 3-1"
3320 if [ $mult -ne 0 ]
3321 echo "~^header insert $xh <${xh}2@exam.ple>";\
3322 read es; echo $es; call xerr "$es" "ins_ref $xh 3-2"
3323 echo "~^header insert $xh ${xh}3@exam.ple";\
3324 read es; echo $es; call xerr "$es" "ins_ref $xh 3-3"
3326 echo "~^header list $xh";\
3327 read hl; echo $hl; call xerr "$hl" "ins_ref $xh 3-4"
3328 echo "~^header show $xh";\
3329 read es; call xerr $es "ins_ref $xh 3-5"
3330 call read_mline_res
3332 echo "~^header remove-at $xh 1"; read es;\
3333 call xerr $es "ins_ref $xh 3-6"
3334 if [ $mult -ne 0 ] && [ $xh != subject ]
3335 echo "~^header remove-at $xh 1"; read es;\
3336 call xerr $es "ins_ref $xh 3-7"
3337 echo "~^header remove-at $xh 1"; read es;\
3338 call xerr $es "ins_ref $xh 3-8"
3340 echo "~^header remove-at $xh 1"; read es;\
3341 vput vexpr es substr $es 0 3
3342 if [ $es != 501 ]
3343 xcall bail "ins_ref $xh 3-9"
3345 echo "~^header remove-at $xh T"; read es;\
3346 vput vexpr es substr $es 0 3
3347 if [ $es != 505 ]
3348 xcall bail "ins_ref $xh 3-10"
3350 echo "~^header show $xh"; read es;\
3351 vput vexpr es substr $es 0 3
3352 if [ $es != 501 ]
3353 xcall bail "ins_ref $xh 3-11"
3357 echo "~^header insert $xh <$xh@exam.ple> ";\
3358 read es; echo $es; call xerr "$es" "ins_ref $xh 4-1"
3359 if [ $mult -ne 0 ]
3360 echo "~^header insert $xh <${xh}2@exam.ple> ";\
3361 read es; echo $es; call xerr "$es" "ins_ref $xh 4-2"
3362 echo "~^header insert $xh ${xh}3@exam.ple";\
3363 read es; echo $es; call xerr "$es" "ins_ref $xh 4-3"
3365 echo "~^header list $xh"; read hl; echo $hl;\
3366 call xerr "$hl" "ins_ref $xh 4-4"
3367 echo "~^header show $xh"; read es; call xerr $es "ins_ref $xh 4-5"
3368 call read_mline_res
3370 if [ $mult -ne 0 ] && [ $xh != subject ]
3371 echo "~^header remove-at $xh 3"; read es;\
3372 call xerr $es "ins_ref $xh 4-6"
3373 echo "~^header remove-at $xh 2"; read es;\
3374 call xerr $es "ins_ref $xh 4-7"
3376 echo "~^header remove-at $xh 1"; read es;\
3377 call xerr $es "ins_ref $xh 4-8"
3378 echo "~^header remove-at $xh 1"; read es;\
3379 vput vexpr es substr $es 0 3
3380 if [ $es != 501 ]
3381 xcall bail "ins_ref $xh 4-9"
3383 echo "~^header remove-at $xh T"; read es;\
3384 vput vexpr es substr $es 0 3
3385 if [ $es != 505 ]
3386 xcall bail "ins_ref $xh 4-10"
3388 echo "~^header show $xh"; read es;\
3389 vput vexpr es substr $es 0 3
3390 if [ $es != 501 ]
3391 xcall bail "ins_ref $xh 4-11"
3394 define t_header {
3395 echo t_header ENTER
3396 # In collect.c order
3397 call ins_addr from
3398 call ins_ref sender 0 # Not a "ref", but works
3399 call ins_addr To
3400 call ins_addr cC
3401 call ins_addr bCc
3402 call ins_addr reply-To
3403 call ins_addr mail-Followup-to
3404 call ins_ref messAge-id 0
3405 call ins_ref rEfErEncEs 1
3406 call ins_ref in-Reply-to 1
3407 call ins_ref subject 1 # Not a "ref", but works (with tweaks)
3408 call ins_addr freeForm1
3409 call ins_addr freeform2
3411 echo "~^header show MAILX-Command"; read es; call xerr $es "t_header 1000"
3412 call read_mline_res
3413 echo "~^header show MAILX-raw-TO"; read es; call xerr $es "t_header 1001"
3414 call read_mline_res
3416 echo t_header LEAVE
3418 define t_attach {
3419 echo t_attach ENTER
3421 echo "~^attachment";\
3422 read hl; echo $hl; vput vexpr es substr "$hl" 0 3
3423 if [ "$es" != 501 ]
3424 xcall bail "attach 0-1"
3427 echo "~^attach attribute ./.treadctl";\
3428 read hl; echo $hl; vput vexpr es substr "$hl" 0 3
3429 if [ "$es" != 501 ]
3430 xcall bail "attach 0-2"
3432 echo "~^attachment attribute-at 1";\
3433 read hl; echo $hl; vput vexpr es substr "$hl" 0 3
3434 if [ "$es" != 501 ]
3435 xcall bail "attach 0-3"
3438 echo "~^attachment insert ./.treadctl=ascii";\
3439 read hl; echo $hl; call xerr "$hl" "attach 1-1"
3440 echo "~^attachment list";\
3441 read es; echo $es;call xerr "$es" "attach 1-2"
3442 call read_mline_res
3443 echo "~^attachment attribute ./.treadctl";\
3444 read es; echo $es;call xerr "$es" "attach 1-3"
3445 call read_mline_res
3446 echo "~^attachment attribute .treadctl";\
3447 read es; echo $es;call xerr "$es" "attach 1-4"
3448 call read_mline_res
3449 echo "~^attachment attribute-at 1";\
3450 read es; echo $es;call xerr "$es" "attach 1-5"
3451 call read_mline_res
3453 echo "~^attachment attribute-set ./.treadctl filename rctl";\
3454 read es; echo $es;call xerr "$es" "attach 1-6"
3455 echo "~^attachment attribute-set .treadctl content-description Au";\
3456 read es; echo $es;call xerr "$es" "attach 1-7"
3457 echo "~^attachment attribute-set-at 1 content-id <10.du@ich>";\
3458 read es; echo $es;call xerr "$es" "attach 1-8"
3460 echo "~^attachment attribute ./.treadctl";\
3461 read es; echo $es;call xerr "$es" "attach 1-9"
3462 call read_mline_res
3463 echo "~^attachment attribute .treadctl";\
3464 read es; echo $es;call xerr "$es" "attach 1-10"
3465 call read_mline_res
3466 echo "~^attachment attribute rctl";\
3467 read es; echo $es;call xerr "$es" "attach 1-11"
3468 call read_mline_res
3469 echo "~^attachment attribute-at 1";\
3470 read es; echo $es;call xerr "$es" "attach 1-12"
3471 call read_mline_res
3474 echo "~^attachment insert ./.tattach=latin1";\
3475 read hl; echo $hl; call xerr "$hl" "attach 2-1"
3476 echo "~^attachment list";\
3477 read es; echo $es;call xerr "$es" "attach 2-2"
3478 call read_mline_res
3479 echo "~^attachment attribute ./.tattach";\
3480 read es; echo $es;call xerr "$es" "attach 2-3"
3481 call read_mline_res
3482 echo "~^attachment attribute .tattach";\
3483 read es; echo $es;call xerr "$es" "attach 2-4"
3484 call read_mline_res
3485 echo "~^attachment attribute-at 2";\
3486 read es; echo $es;call xerr "$es" "attach 2-5"
3487 call read_mline_res
3489 echo "~^attachment attribute-set ./.tattach filename tat";\
3490 read es; echo $es;call xerr "$es" "attach 2-6"
3491 echo \
3492 "~^attachment attribute-set .tattach content-description Au2";\
3493 read es; echo $es;call xerr "$es" "attach 2-7"
3494 echo "~^attachment attribute-set-at 2 content-id <20.du@wir>";\
3495 read es; echo $es;call xerr "$es" "attach 2-8"
3496 echo \
3497 "~^attachment attribute-set-at 2 content-type application/x-sh";\
3498 read es; echo $es;call xerr "$es" "attach 2-9"
3500 echo "~^attachment attribute ./.tattach";\
3501 read es; echo $es;call xerr "$es" "attach 2-10"
3502 call read_mline_res
3503 echo "~^attachment attribute .tattach";\
3504 read es; echo $es;call xerr "$es" "attach 2-11"
3505 call read_mline_res
3506 echo "~^attachment attribute tat";\
3507 read es; echo $es;call xerr "$es" "attach 2-12"
3508 call read_mline_res
3509 echo "~^attachment attribute-at 2";\
3510 read es; echo $es;call xerr "$es" "attach 2-13"
3511 call read_mline_res
3514 if [ "$t_remove" == "" ]
3515 return
3518 echo "~^attachment remove ./.treadctl"; read es;\
3519 call xerr $es "attach 3-1"
3520 echo "~^attachment remove ./.tattach"; read es;\
3521 call xerr $es "attach 3-2"
3522 echo "~^ attachment remove ./.treadctl"; read es;\
3523 vput vexpr es substr $es 0 3
3524 if [ $es != 501 ]
3525 xcall bail "attach 3-3"
3527 echo "~^ attachment remove ./.tattach"; read es;\
3528 vput vexpr es substr $es 0 3
3529 if [ $es != 501 ]
3530 xcall bail "attach 3-4"
3532 echo "~^attachment list"; read es;\
3533 vput vexpr es substr $es 0 3
3534 if [ $es != 501 ]
3535 xcall bail "attach 3-5"
3539 echo "~^attachment insert ./.tattach=latin1";\
3540 read hl; echo $hl; call xerr "$hl" "attach 4-1"
3541 echo "~^attachment insert ./.tattach=latin1";\
3542 read hl; echo $hl; call xerr "$hl" "attach 4-2"
3543 echo "~^attachment list";\
3544 read es; echo $es;call xerr "$es" "attach 4-3"
3545 call read_mline_res
3546 echo "~^ attachment remove .tattach"; read es;\
3547 vput vexpr es substr $es 0 3
3548 if [ $es != 506 ]
3549 xcall bail "attach 4-4 $es"
3551 echo "~^attachment remove-at T"; read es;\
3552 vput vexpr es substr $es 0 3
3553 if [ $es != 505 ]
3554 xcall bail "attach 4-5"
3556 echo "~^attachment remove ./.tattach"; read es;\
3557 call xerr $es "attach 4-6"
3558 echo "~^attachment remove ./.tattach"; read es;\
3559 call xerr $es "attach 4-7"
3560 echo "~^ attachment remove ./.tattach"; read es;\
3561 vput vexpr es substr $es 0 3
3562 if [ $es != 501 ]
3563 xcall bail "attach 4-8 $es"
3565 echo "~^attachment list"; read es;\
3566 vput vexpr es substr $es 0 3
3567 if [ $es != 501 ]
3568 xcall bail "attach 4-9"
3572 echo "~^attachment insert ./.tattach=latin1";\
3573 read hl; echo $hl; call xerr "$hl" "attach 5-1"
3574 echo "~^attachment insert ./.tattach=latin1";\
3575 read hl; echo $hl; call xerr "$hl" "attach 5-2"
3576 echo "~^attachment insert ./.tattach=latin1";\
3577 read hl; echo $hl; call xerr "$hl" "attach 5-3"
3578 echo "~^attachment list";\
3579 read es; echo $es;call xerr "$es" "attach 5-4"
3580 call read_mline_res
3582 echo "~^attachment remove-at 3"; read es;\
3583 call xerr $es "attach 5-5"
3584 echo "~^attachment remove-at 3"; read es;\
3585 vput vexpr es substr $es 0 3
3586 if [ $es != 501 ]
3587 xcall bail "attach 5-6"
3589 echo "~^attachment remove-at 2"; read es;\
3590 call xerr $es "attach 5-7"
3591 echo "~^attachment remove-at 2"; read es;\
3592 vput vexpr es substr $es 0 3
3593 if [ $es != 501 ]
3594 xcall bail "attach 5-8"
3596 echo "~^attachment remove-at 1"; read es;\
3597 call xerr $es "attach 5-9"
3598 echo "~^attachment remove-at 1"; read es;\
3599 vput vexpr es substr $es 0 3
3600 if [ $es != 501 ]
3601 xcall bail "attach 5-10"
3604 echo "~^attachment list"; read es;\
3605 vput vexpr es substr $es 0 3
3606 if [ $es != 501 ]
3607 xcall bail "attach 5-11"
3611 echo "~^attachment insert ./.tattach=latin1";\
3612 read hl; echo $hl; call xerr "$hl" "attach 6-1"
3613 echo "~^attachment insert ./.tattach=latin1";\
3614 read hl; echo $hl; call xerr "$hl" "attach 6-2"
3615 echo "~^attachment insert ./.tattach=latin1";\
3616 read hl; echo $hl; call xerr "$hl" "attach 6-3"
3617 echo "~^attachment list";\
3618 read es; echo $es;call xerr "$es" "attach 6-4"
3619 call read_mline_res
3621 echo "~^attachment remove-at 1"; read es;\
3622 call xerr $es "attach 6-5"
3623 echo "~^attachment remove-at 1"; read es;\
3624 call xerr $es "attach 6-6"
3625 echo "~^attachment remove-at 1"; read es;\
3626 call xerr $es "attach 6-7"
3627 echo "~^attachment remove-at 1"; read es;\
3628 vput vexpr es substr $es 0 3
3629 if [ $es != 501 ]
3630 xcall bail "attach 6-8"
3633 echo "~^attachment list"; read es;\
3634 vput vexpr es substr $es 0 3
3635 if [ $es != 501 ]
3636 xcall bail "attach 6-9"
3639 echo t_attach LEAVE
3641 define t_ocs {
3642 read ver
3643 echo t_ocs
3644 call t_header
3645 call t_attach
3647 define t_oce {
3648 echo on-compose-enter, mailx-command<$mailx-command>
3649 alternates alter1@exam.ple alter2@exam.ple
3650 alternates
3651 set autocc='alter1@exam.ple alter2@exam.ple'
3652 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3653 echo mailx-subject<$mailx-subject>
3654 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3655 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3656 mailx-raw-bcc<$mailx-raw-bcc>
3657 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
3658 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3660 define t_ocl {
3661 echo on-compose-leave, mailx-command<$mailx-command>
3662 vput alternates al
3663 eval alternates $al alter3@exam.ple alter4@exam.ple
3664 alternates
3665 set autobcc='alter3@exam.ple alter4@exam.ple'
3666 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3667 echo mailx-subject<$mailx-subject>
3668 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3669 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3670 mailx-raw-bcc<$mailx-raw-bcc>
3671 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
3672 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3674 define t_occ {
3675 echo on-compose-cleanup, mailx-command<$mailx-command>
3676 unalternates *
3677 alternates
3678 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3679 echo mailx-subject<$mailx-subject>
3680 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3681 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3682 mailx-raw-bcc<$mailx-raw-bcc>
3683 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
3684 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3686 wysh set on-compose-splice=t_ocs \
3687 on-compose-enter=t_oce on-compose-leave=t_ocl \
3688 on-compose-cleanup=t_occ
3689 __EOT__
3691 ${rm} -f "${MBOX}"
3692 printf 'm this-goes@nowhere\nbody\n!.\n' |
3693 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
3694 -X'source ./.trc' -Smta=./.tsendmail.sh \
3695 >./.tall 2>&1
3696 ${cat} ./.tall >> "${MBOX}"
3697 check behave:compose_hooks-1 0 "${MBOX}" '522535560 10101'
3699 ${rm} -f "${MBOX}"
3700 printf 'm this-goes@nowhere\nbody\n!.\n' |
3701 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
3702 -St_remove=1 -X'source ./.trc' -Smta=./.tsendmail.sh \
3703 >./.tall 2>&1
3704 ${cat} ./.tall >> "${MBOX}"
3705 check behave:compose_hooks-2 0 "${MBOX}" '3654000499 12535'
3709 # Some state machine stress, shell compose hook, localopts for hook, etc.
3710 # readctl in child. ~r as HERE document
3711 ${rm} -f "${MBOX}"
3712 printf 'm ex@am.ple\nbody\n!.
3713 echon ${mailx-command}${mailx-subject}
3714 echon ${mailx-from}${mailx-sender}
3715 echon ${mailx-to}${mailx-cc}${mailx-bcc}
3716 echon ${mailx-raw-to}${mailx-raw-cc}${mailx-raw-bcc}
3717 echon ${mailx-orig-from}${mailx-orig-to}${mailx-orig-gcc}${mailx-orig-bcc}
3718 var t_oce t_ocs t_ocs_sh t_ocl t_occ autocc
3719 ' | ${MAILX} ${ARGS} -Snomemdebug -Sescape=! \
3720 -Smta=./.tsendmail.sh \
3722 define bail {
3723 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
3725 define xerr {
3726 vput vexpr es substr "$1" 0 1
3727 if [ "$es" != 2 ]
3728 xcall bail "$2"
3731 define read_mline_res {
3732 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
3733 echo $len/$es/$^ERRNAME: $hl
3734 if [ $es -ne $^ERR-NONE ]
3735 xcall bail read_mline_res
3736 elif [ $len -ne 0 ]
3737 \xcall read_mline_res
3740 define _work {
3741 vput vexpr i + 1 "$2"
3742 if [ $i -lt 111 ]
3743 vput vexpr j % $i 10
3744 if [ $j -ne 0 ]
3745 set j=xcall
3746 else
3747 echon "$i.. "
3748 set j=call
3750 eval \\$j _work $1 $i
3751 return $?
3753 vput vexpr i + $i "$1"
3754 return $i
3756 define _read {
3757 wysh set line; read line;wysh set es=$? en=$^ERRNAME ;\
3758 echo read:$es/$en: $line
3759 if [ "${es}" -ne -1 ]
3760 xcall _read
3762 readctl remove $cwd/.treadctl; echo readctl remove:$?/$^ERRNAME
3764 define t_ocs {
3765 read ver
3766 echo t_ocs
3767 echo "~^header list"; read hl; echo $hl;\
3768 vput vexpr es substr "$hl" 0 1
3769 if [ "$es" != 2 ]
3770 xcall bail "header list"
3771 endif
3773 call _work 1; echo $?
3774 echo "~^header insert cc splicy diet <splice@exam.ple> spliced";\
3775 read es; echo $es; vput vexpr es substr "$es" 0 1
3776 if [ "$es" != 2 ]
3777 xcall bail "be diet"
3778 endif
3779 echo "~^header insert cc <splice2@exam.ple>";\
3780 read es; echo $es; vput vexpr es substr "$es" 0 1
3781 if [ "$es" != 2 ]
3782 xcall bail "be diet2"
3783 endif
3785 call _work 2; echo $?
3786 echo "~^header insert bcc juicy juice <juice@exam.ple> spliced";\
3787 read es; echo $es;vput vexpr es substr "$es" 0 1
3788 if [ "$es" != 2 ]
3789 xcall bail "be juicy"
3790 endif
3791 echo "~^header insert bcc juice2@exam.ple";\
3792 read es; echo $es;vput vexpr es substr "$es" 0 1
3793 if [ "$es" != 2 ]
3794 xcall bail "be juicy2"
3795 endif
3796 echo "~^header insert bcc juice3 <juice3@exam.ple>";\
3797 read es; echo $es;vput vexpr es substr "$es" 0 1
3798 if [ "$es" != 2 ]
3799 xcall bail "be juicy3"
3800 endif
3801 echo "~^header insert bcc juice4@exam.ple";\
3802 read es; echo $es;vput vexpr es substr "$es" 0 1
3803 if [ "$es" != 2 ]
3804 xcall bail "be juicy4"
3805 endif
3807 echo "~^header remove-at bcc 3";\
3808 read es; echo $es;vput vexpr es substr "$es" 0 1
3809 if [ "$es" != 2 ]
3810 xcall bail "remove juicy5"
3811 endif
3812 echo "~^header remove-at bcc 2";\
3813 read es; echo $es;vput vexpr es substr "$es" 0 1
3814 if [ "$es" != 2 ]
3815 xcall bail "remove juicy6"
3816 endif
3817 echo "~^header remove-at bcc 3";\
3818 read es; echo $es;vput vexpr es substr "$es" 0 3
3819 if [ "$es" != 501 ]
3820 xcall bail "failed to remove-at"
3821 endif
3822 # Add duplicates which ought to be removed!
3823 echo "~^header insert bcc juice4@exam.ple";\
3824 read es; echo $es;vput vexpr es substr "$es" 0 1
3825 if [ "$es" != 2 ]
3826 xcall bail "be juicy4-1"
3827 endif
3828 echo "~^header insert bcc juice4@exam.ple";\
3829 read es; echo $es;vput vexpr es substr "$es" 0 1
3830 if [ "$es" != 2 ]
3831 xcall bail "be juicy4-2"
3832 endif
3833 echo "~^header insert bcc juice4@exam.ple";\
3834 read es; echo $es;vput vexpr es substr "$es" 0 1
3835 if [ "$es" != 2 ]
3836 xcall bail "be juicy4-3"
3837 endif
3838 echo "~:set t_ocs"
3841 call _work 3; echo $?
3842 echo "~r - '__EOT'"
3843 vput ! i echo just knock if you can hear me;\
3844 i=0;\
3845 while [ $i -lt 24 ]; do printf "%s " $i; i=`expr $i + 1`; done;\
3846 echo relax
3847 echon shell-cmd says $?/$^ERRNAME: $i
3848 echo "~x will not become interpreted, we are reading until __EOT"
3849 echo "__EOT"
3850 read r_status; echo "~~r status output: $r_status"
3851 echo "~:echo $? $! $^ERRNAME"
3852 read r_status
3853 echo "~~r status from parent: $r_status"
3856 call _work 4; echo $?
3857 vput cwd cwd;echo cwd:$?
3858 readctl create $cwd/.treadctl ;echo readctl:$?/$^ERRNAME;\
3859 call _read
3862 call _work 5; echo $?
3863 echo "~^header show MAILX-Command"; read es;\
3864 call xerr $es "t_header 1000"; call read_mline_res
3865 echo "~^header show MAILX-raw-TO"; read es;\
3866 call xerr $es "t_header 1001"; xcall read_mline_res
3868 echoerr IT IS WRONG IF YOU SEE THIS
3870 define t_oce {
3871 echo on-compose-enter, mailx-command<$mailx-command>
3872 set t_oce autobcc=oce@exam.ple
3873 alternates alter1@exam.ple alter2@exam.ple
3874 alternates
3875 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3876 echo mailx-subject<$mailx-subject>
3877 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3878 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3879 mailx-raw-bcc<$mailx-raw-bcc>
3880 echo mailx-orig-from<$mailx-orig-from> \
3881 mailx-orig-to<$mailx-orig-to> \
3882 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3884 define t_ocl {
3885 echo on-compose-leave, mailx-command<$mailx-command>
3886 set t_ocl autocc=ocl@exam.ple
3887 unalternates *
3888 alternates alter3@exam.ple alter4@exam.ple
3889 alternates
3890 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3891 echo mailx-subject<$mailx-subject>
3892 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3893 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3894 mailx-raw-bcc<$mailx-raw-bcc>
3895 echo mailx-orig-from<$mailx-orig-from> \
3896 mailx-orig-to<$mailx-orig-to> \
3897 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3899 define t_occ {
3900 echo on-compose-cleanup, mailx-command<$mailx-command>
3901 set t_occ autocc=occ@exam.ple
3902 unalternates *
3903 alternates
3904 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3905 echo mailx-subject<$mailx-subject>
3906 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3907 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3908 mailx-raw-bcc<$mailx-raw-bcc>
3909 echo mailx-orig-from<$mailx-orig-from> \
3910 mailx-orig-to<$mailx-orig-to> \
3911 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3913 wysh set on-compose-splice=t_ocs \
3914 on-compose-splice-shell="read ver;printf \"t_ocs-shell\\n\
3915 ~t shell@exam.ple\\n~:set t_ocs_sh\\n\"" \
3916 on-compose-enter=t_oce on-compose-leave=t_ocl \
3917 on-compose-cleanup=t_occ
3918 ' > ./.tnotes 2>&1
3919 ex0_test behave:compose_hooks-3-estat
3920 ${cat} ./.tnotes >> "${MBOX}"
3922 check behave:compose_hooks-3 - "${MBOX}" '679526364 2431'
3924 # Reply, forward, resend, Resend
3926 ${rm} -f "${MBOX}"
3927 printf 'set from=f1@z\nm t1@z\nb1\n!.\nset from=f2@z\nm t2@z\nb2\n!.\n' |
3928 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! \
3929 -Smta=./.tsendmail.sh
3931 printf '
3932 echo start: $? $! $^ERRNAME
3933 File %s
3934 echo File: $? $! $^ERRNAME;echo;echo
3935 reply 1
3936 this is content of reply 1
3938 echo reply 1: $? $! $^ERRNAME;echo;echo
3939 Reply 1 2
3940 this is content of Reply 1 2
3942 echo Reply 1 2: $? $! $^ERRNAME;echo;echo
3943 forward 1 fwdex@am.ple
3944 this is content of forward 1
3946 echo forward 1: $? $! $^ERRNAME;echo;echo
3947 resend 1 2 resendex@am.ple
3948 echo resend 1 2: $? $! $^ERRNAME;echo;echo
3949 Resend 1 2 Resendex@am.ple
3950 echo Resend 1 2: $? $! $^ERRNAME;echo;echo
3951 ' "${MBOX}" |
3952 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! \
3953 -Smta=./.tsendmail.sh \
3955 define bail {
3956 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
3958 define xerr {
3959 vput vexpr es substr "$1" 0 1
3960 if [ "$es" != 2 ]
3961 xcall bail "$2"
3964 define read_mline_res {
3965 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
3966 echo mline_res:$len/$es/$^ERRNAME: $hl
3967 if [ $es -ne $^ERR-NONE ]
3968 xcall bail read_mline_res
3969 elif [ $len -ne 0 ]
3970 \xcall read_mline_res
3973 define work_hl {
3974 echo "~^header show $1"; read es;\
3975 call xerr $es "work_hl $1"; echo $1; call read_mline_res
3976 if [ $# -gt 1 ]
3977 shift
3978 xcall work_hl "$@"
3981 define t_ocs {
3982 read ver
3983 echo t_ocs version $ver
3984 echo "~^header list"; read hl; echo $hl;\
3985 echoerr the header list is $hl;\
3986 call xerr "$hl" "header list"
3987 eval vpospar set $hl
3988 shift
3989 xcall work_hl "$@"
3990 echoerr IT IS WRONG IF YOU SEE THIS
3992 define t_oce {
3993 echo on-XY-enter, mailx-command<$mailx-command>
3994 set t_oce autobcc=oce@exam.ple
3995 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3996 echo mailx-subject<$mailx-subject>
3997 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3998 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3999 mailx-raw-bcc<$mailx-raw-bcc>
4000 echo mailx-orig-from<$mailx-orig-from> \
4001 mailx-orig-to<$mailx-orig-to> \
4002 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
4004 define t_ocl {
4005 echo on-XY-leave, mailx-command<$mailx-command>
4006 set t_ocl autocc=ocl@exam.ple
4007 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
4008 echo mailx-subject<$mailx-subject>
4009 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
4010 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
4011 mailx-raw-bcc<$mailx-raw-bcc>
4012 echo mailx-orig-from<$mailx-orig-from> \
4013 mailx-orig-to<$mailx-orig-to> \
4014 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
4016 define t_occ {
4017 echo on-XY-cleanup, mailx-command<$mailx-command>
4018 set t_occ autocc=occ@exam.ple
4019 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
4020 echo mailx-subject<$mailx-subject>
4021 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
4022 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
4023 mailx-raw-bcc<$mailx-raw-bcc>
4024 echo mailx-orig-from<$mailx-orig-from> \
4025 mailx-orig-to<$mailx-orig-to> \
4026 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
4028 wysh set on-compose-splice=t_ocs \
4029 on-compose-enter=t_oce on-compose-leave=t_ocl \
4030 on-compose-cleanup=t_occ \
4031 on-resend-enter=t_oce on-resend-cleanup=t_occ
4032 ' > ./.tnotes 2>&1
4033 ex0_test behave:compose_hooks-4-estat
4034 ${cat} ./.tnotes >> "${MBOX}"
4036 check behave:compose_hooks-4 - "${MBOX}" '3038884027 7516'
4038 t_epilog
4041 t_behave_C_opt_customhdr() {
4042 t_prolog t_behave_C_opt_customhdr
4043 TRAP_EXIT_ADDONS="./.t*"
4045 ${cat} <<-_EOT > ./.tsendmail.sh
4046 #!${SHELL} -
4047 (echo 'From CimicifugaRacemosa Mon Dec 25 21:33:40 2017' &&
4048 ${cat} && echo
4049 ) >> "${MBOX}"
4050 _EOT
4051 chmod 0755 ./.tsendmail.sh
4053 echo bla |
4054 ${MAILX} ${ARGS} -Smta=./.tsendmail.sh \
4055 -C 'C-One : Custom One Body' \
4056 -C 'C-Two:CustomTwoBody' \
4057 -S customhdr='chdr1: chdr1 body, chdr2:chdr2 body' \
4058 this-goes@nowhere >./.tall 2>&1
4059 ex0_test behave:C_opt_customhdr-1-estat
4060 ${cat} ./.tall >> "${MBOX}"
4061 check behave:C_opt_customhdr-1 0 "${MBOX}" '2400078426 195'
4063 ${rm} -f "${MBOX}"
4064 printf 'm this-goes@nowhere\nbody\n!.
4065 unset customhdr
4066 m this-goes2@nowhere\nbody2\n!.
4067 set customhdr=%ccustom1 : custom1 body%c
4068 m this-goes2@nowhere\nbody2\n!.
4069 set customhdr=%ccustom1 : custom1\\, body , custom2: custom2 body%c
4070 m this-goes3@nowhere\nbody3\n!.
4071 ' "'" "'" "'" "'" |
4072 ${MAILX} ${ARGS} -Smta=./.tsendmail.sh -Sescape=! \
4073 -C 'C-One : Custom One Body' \
4074 -C 'C-Two:CustomTwoBody' \
4075 -S customhdr='chdr1: chdr1 body, chdr2:chdr2 body' \
4076 >./.tall 2>&1
4077 ex0_test behave:C_opt_customhdr-2-estat
4078 ${cat} ./.tall >> "${MBOX}"
4079 check behave:C_opt_customhdr-2 0 "${MBOX}" '3546878678 752'
4081 t_epilog
4084 t_behave_mass_recipients() {
4085 t_prolog t_behave_mass_recipients
4086 TRAP_EXIT_ADDONS="./.t*"
4088 ${cat} <<-_EOT > ./.tsendmail.sh
4089 #!${SHELL} -
4090 (echo 'From Eucalyptus Sat Jul 08 21:14:57 2017' && ${cat} && echo
4091 ) >> "${MBOX}"
4092 _EOT
4093 chmod 0755 ./.tsendmail.sh
4095 ${cat} <<'__EOT__' > ./.trc
4096 define bail {
4097 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
4099 define ins_addr {
4100 wysh set nr=$1 hn=$2
4101 echo "~$hn $hn$nr@$hn"; echo '~:echo $?'; read es
4102 if [ "$es" -ne 0 ]
4103 xcall bail "ins_addr $hn 1-$nr"
4105 vput vexpr nr + $nr 1
4106 if [ "$nr" -le "$maximum" ]
4107 xcall ins_addr $nr $hn
4110 define bld_alter {
4111 wysh set nr=$1 hn=$2
4112 alternates $hn$nr@$hn
4113 vput vexpr nr + $nr 2
4114 if [ "$nr" -le "$maximum" ]
4115 xcall bld_alter $nr $hn
4118 define t_ocs {
4119 read ver
4120 call ins_addr 1 t
4121 call ins_addr 1 c
4122 call ins_addr 1 b
4124 define t_ocl {
4125 if [ "$t_remove" != '' ]
4126 call bld_alter 1 t
4127 call bld_alter 2 c
4130 set on-compose-splice=t_ocs on-compose-leave=t_ocl
4131 __EOT__
4133 printf 'm this-goes@nowhere\nbody\n!.\n' |
4134 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
4135 -X'source ./.trc' -Smta=./.tsendmail.sh -Smaximum=2001 \
4136 >./.tall 2>&1
4137 ex0_test behave:mass_recipients-1-estat
4138 ${cat} ./.tall >> "${MBOX}"
4139 check behave:mass_recipients-1 - "${MBOX}" '2912243346 51526'
4141 ${rm} -f "${MBOX}"
4142 printf 'm this-goes@nowhere\nbody\n!.\n' |
4143 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
4144 -St_remove=1 -X'source ./.trc' -Smta=./.tsendmail.sh -Smaximum=2001 \
4145 >./.tall 2>&1
4146 ex0_test behave:mass_recipients-2-estat
4147 ${cat} ./.tall >> "${MBOX}"
4148 check behave:mass_recipients-2 - "${MBOX}" '4097804632 34394'
4150 t_epilog
4153 t_behave_mime_types_load_control() {
4154 t_prolog t_behave_mime_types_load_control
4155 TRAP_EXIT_ADDONS="./.t*"
4157 ${cat} <<-_EOT > ./.tmts1
4158 @ application/mathml+xml mathml
4159 _EOT
4160 ${cat} <<-_EOT > ./.tmts2
4161 @ x-conference/x-cooltalk ice
4162 @ aga-aga aga
4163 @ application/aga-aga aga
4164 _EOT
4166 ${cat} <<-_EOT > ./.tmts1.mathml
4167 <head>nonsense ML</head>
4168 _EOT
4169 ${cat} <<-_EOT > ./.tmts2.ice
4170 Icy, icy road.
4171 _EOT
4172 printf 'of which the c\x01rack is coming soon' > ./.tmtsx.doom
4173 printf 'of which the c\x01rack is coming soon' > ./.tmtsx.aga
4175 printf '
4176 m %s
4177 Schub-di-du
4178 ~@ ./.tmts1.mathml
4179 ~@ ./.tmts2.ice
4180 ~@ ./.tmtsx.doom
4181 ~@ ./.tmtsx.aga
4183 File %s
4184 from*
4185 type
4187 ' "${MBOX}" "${MBOX}" |
4188 ${MAILX} ${ARGS} \
4189 -Smimetypes-load-control=f=./.tmts1,f=./.tmts2 \
4190 > ./.tout 2>&1
4191 ex0_test behave:mime_types_load_control-1-estat
4192 ${cat} "${MBOX}" >> ./.tout
4193 check behave:mime_types_load_control-1 - ./.tout '1441260727 2449'
4195 echo type | ${MAILX} ${ARGS} -R \
4196 -Smimetypes-load-control=f=./.tmts1,f=./.tmts3 \
4197 -f "${MBOX}" >> ./.tout 2>&1
4198 check behave:mime_types_load_control-2 0 ./.tout '1441391438 3646'
4200 t_epilog
4203 t_behave_lreply_futh_rth_etc() {
4204 t_prolog t_behave_lreply_futh_rth_etc
4205 TRAP_EXIT_ADDONS="./.t*"
4207 ${cat} <<-_EOT > ./.tsendmail.sh
4208 #!${SHELL} -
4209 (echo 'From HumulusLupulus Thu Jul 27 14:41:20 2017' && ${cat} && echo
4210 ) >> "${MBOX}"
4211 _EOT
4212 chmod 0755 ./.tsendmail.sh
4214 ${cat} <<-_EOT > ./.tmbox
4215 From neverneverland Sun Jul 23 13:46:25 2017
4216 Subject: Bugstop: five miles out 1
4217 Reply-To: mister originator2 <mr2@originator>, bugstop@five.miles.out
4218 From: mister originator <mr@originator>
4219 To: bugstop-commit@five.miles.out, laber@backe.eu
4220 Cc: is@a.list
4221 Mail-Followup-To: bugstop@five.miles.out, laber@backe.eu, is@a.list
4222 In-reply-to: <20170719111113.bkcMz%laber@backe.eu>
4223 Date: Wed, 19 Jul 2017 09:22:57 -0400
4224 Message-Id: <20170719132257.766AF781267@originator>
4225 Status: RO
4227 > |Sorry, I think I misunderstand something. I would think that
4229 That's appalling.
4231 From neverneverland Fri Jul 7 22:39:11 2017
4232 Subject: Bugstop: five miles out 2
4233 Reply-To: mister originator2<mr2@originator>,bugstop@five.miles.out,is@a.list
4234 Content-Transfer-Encoding: 7bit
4235 From: mister originator <mr@originator>
4236 To: bugstop-commit@five.miles.out
4237 Cc: is@a.list
4238 Message-ID: <149945963975.28888.6950788126957753723.reportbug@five.miles.out>
4239 Date: Fri, 07 Jul 2017 16:33:59 -0400
4240 Status: R
4242 capable of changing back.
4244 From neverneverland Fri Jul 7 22:42:00 2017
4245 Subject: Bugstop: five miles out 3
4246 Reply-To: mister originator2 <mr2@originator>, bugstop@five.miles.out
4247 Content-Transfer-Encoding: 7bit
4248 From: mister originator <mr@originator>
4249 To: bugstop-commit@five.miles.out
4250 Cc: is@a.list
4251 Message-ID: <149945963975.28888.6950788126957753746.reportbug@five.miles.out>
4252 Date: Fri, 07 Jul 2017 16:33:59 -0400
4253 List-Post: <mailto:bugstop@five.miles.out>
4254 Status: R
4256 are you ready, boots?
4258 From neverneverland Sat Aug 19 23:15:00 2017
4259 Subject: Bugstop: five miles out 4
4260 Reply-To: mister originator2 <mr2@originator>, bugstop@five.miles.out
4261 Content-Transfer-Encoding: 7bit
4262 From: mister originator <mr@originator>
4263 To: bugstop@five.miles.out
4264 Cc: is@a.list
4265 Message-ID: <149945963975.28888.6950788126qtewrqwer.reportbug@five.miles.out>
4266 Date: Fri, 07 Jul 2017 16:33:59 -0400
4267 List-Post: <mailto:bugstop@five.miles.out>
4268 Status: R
4270 are you ready, boots?
4271 _EOT
4275 ${cat} <<-'_EOT' | ${MAILX} ${ARGS} -Sescape=! -Smta=./.tsendmail.sh \
4276 -Rf ./.tmbox >> "${MBOX}" 2>&1
4277 define r {
4278 wysh set m="This is text of \"reply ${1}."
4279 reply 1 2 3
4280 !I m
4283 !I m
4286 !I m
4289 echo -----After reply $1.1 - $1.3: $?/$^ERRNAME
4291 define R {
4292 wysh set m="This is text of \"Reply ${1}."
4293 eval Reply $2
4294 !I m
4295 !I 2
4298 echo -----After Reply $1.$2: $?/$^ERRNAME
4300 define _Lh {
4301 read protover
4302 echo '~I m'
4303 echo '~I n'
4304 echo '".'
4306 define _Ls {
4307 wysh set m="This is text of \"Lreply ${1}." on-compose-splice=_Lh n=$2
4308 eval Lreply $2
4310 define L {
4311 # We need two indirections for this test: one for the case that Lreply
4312 # fails because of missing recipients: we need to read EOF next, thus
4313 # place this in _Ls last; and second for the succeeding cases EOF is
4314 # not what these should read, so go over the backside and splice it in!
4315 call _Ls "$@"
4316 echo -----After Lreply $1.$2: $?/$^ERRNAME
4318 define x {
4319 localopts call-fixate yes
4320 call r $1
4321 call R $1 1; call R $1 2; call R $1 3; call R $1 4
4322 call L $1 1; call L $1 2; call L $1 3
4324 define tweak {
4325 echo;echo '===== CHANGING === '"$*"' =====';echo
4326 eval "$@"
4329 set from=laber@backe.eu
4330 mlist is@a.list
4331 call x 1
4332 call tweak set reply-to-honour
4333 call x 2
4334 call tweak set followup-to
4335 call x 3
4336 call tweak set followup-to-honour
4337 call x 4
4338 call tweak mlist bugstop@five.miles.out
4339 call x 5
4340 call tweak mlsubscribe bugstop@five.miles.out
4341 call x 6
4342 call tweak set recipients-in-cc
4343 call x 7
4344 _EOT
4346 check behave:lreply_futh_rth_etc-1 0 "${MBOX}" '940818845 29373'
4350 ${cat} <<-_EOT > ./.tmbox
4351 From tom@i-i.example Thu Oct 26 03:15:55 2017
4352 Date: Wed, 25 Oct 2017 21:15:46 -0400
4353 From: tom <tom@i-i.example>
4354 To: Steffen Nurpmeso <steffen@sdaoden.eu>
4355 Cc: tom <tom@i-i.example>
4356 Subject: Re: xxxx yyyyyyyy configure does not really like a missing zzzzz
4357 Message-ID: <20171026011546.GA11643@i-i.example>
4358 Reply-To: tom@i-i.example
4359 References: <20171025214601.T2pNd%steffen@sdaoden.eu>
4360 In-Reply-To: <20171025214601.T2pNd%steffen@sdaoden.eu>
4361 Status: R
4363 The report's useful :-)
4364 _EOT
4366 printf 'reply 1\nthank you\n!.\n' |
4367 ${MAILX} ${ARGS} -Sescape=! -Smta=./.tsendmail.sh -Sreply-to-honour \
4368 -Rf ./.tmbox > "${MBOX}" 2>&1
4369 check behave:lreply_futh_rth_etc-2 0 "${MBOX}" '1045866991 331'
4371 t_epilog
4374 t_behave_xxxheads_rfc2047() {
4375 t_prolog t_behave_xxxheads_rfc2047
4376 TRAP_EXIT_ADDONS="./.t*"
4378 ${cat} <<-_EOT > ./.tsendmail.sh
4379 #!${SHELL} -
4380 (echo 'From GentianaLutea Mon Dec 04 17:15:29 2017' && ${cat} &&
4381 echo) >> "${MBOX}"
4382 _EOT
4383 chmod 0755 ./.tsendmail.sh
4386 ${rm} -f "${MBOX}"
4387 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
4388 -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̲' \
4389 "${MBOX}"
4390 check behave:xxxheads_rfc2047-1 0 "${MBOX}" '3370931614 375'
4392 # Single word (overlong line split -- bad standard! Requires injection of
4393 # artificial data!! But can be prevented by using RFC 2047 encoding)
4394 ${rm} -f "${MBOX}"
4395 i=`${awk} 'BEGIN{for(i=0; i<92; ++i) printf "0123456789_"}'`
4396 echo | ${MAILX} ${ARGS} -s "${i}" "${MBOX}"
4397 check behave:xxxheads_rfc2047-2 0 "${MBOX}" '489922370 1718'
4399 # Combination of encoded words, space and tabs of varying sort
4400 ${rm} -f "${MBOX}"
4401 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
4402 -s "1Abrä Kaspas1 2Abra Katä b_kaspas2 \
4403 3Abrä Kaspas3 4Abrä Kaspas4 5Abrä Kaspas5 \
4404 6Abra Kaspas6 7Abrä Kaspas7 8Abra Kaspas8 \
4405 9Abra Kaspastäb4-3 10Abra Kaspas1 _ 11Abra Katäb1 \
4406 12Abra Kadabrä1 After Tab after Täb this is NUTS" \
4407 "${MBOX}"
4408 check behave:xxxheads_rfc2047-3 0 "${MBOX}" '1676887734 591'
4410 # Overlong multibyte sequence that must be forcefully split
4411 # todo This works even before v15.0, but only by accident
4412 ${rm} -f "${MBOX}"
4413 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
4414 -s "✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
4415 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
4416 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄" \
4417 "${MBOX}"
4418 check behave:xxxheads_rfc2047-4 0 "${MBOX}" '3029301775 659'
4420 # Trailing WS
4421 ${rm} -f "${MBOX}"
4422 echo | ${MAILX} ${ARGS} \
4423 -s "1-1 B2 B3 B4 B5 B6 B\
4424 1-2 B2 B3 B4 B5 B6 B\
4425 1-3 B2 B3 B4 B5 B6 B\
4426 1-4 B2 B3 B4 B5 B6 B\
4427 1-5 B2 B3 B4 B5 B6 B\
4428 1-6 B2 B3 B4 B5 B6 " \
4429 "${MBOX}"
4430 check behave:xxxheads_rfc2047-5 0 "${MBOX}" '4126167195 297'
4432 # Leading and trailing WS
4433 ${rm} -f "${MBOX}"
4434 echo | ${MAILX} ${ARGS} \
4435 -s " 2-1 B2 B3 B4 B5 B6 B\
4436 1-2 B2 B3 B4 B5 B6 B\
4437 1-3 B2 B3 B4 B5 B6 B\
4438 1-4 B2 B3 B4 B5 B6 " \
4439 "${MBOX}"
4440 check behave:xxxheads_rfc2047-6 0 "${MBOX}" '3600624479 236'
4442 # RFC 2047 in an address field! (Missing test caused v14.9.6!)
4443 ${rm} -f "${MBOX}"
4444 echo "Dat Früchtchen riecht häußlich" |
4445 ${MAILX} ${ARGS} ${ADDARG_UNI} -Sfullnames -Smta=./.tsendmail.sh \
4446 -s Hühöttchen \
4447 'Schnödes "Früchtchen" <do@du> (Hä!)'
4448 check behave:xxxheads_rfc2047-7 0 "${MBOX}" '800505986 368'
4450 t_epilog
4453 t_behave_rfc2231() {
4454 t_prolog t_behave_rfc2231
4455 TRAP_EXIT_ADDONS="./.t*"
4458 mkdir ./.ttt || exit 1
4459 cd ./.ttt || exit 2
4460 : > "ma'ger.txt"
4461 : > "mä'ger.txt"
4462 : > 'diet\ is \curd.txt'
4463 : > 'diet "is" curd.txt'
4464 : > höde-tröge.txt
4465 : > 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
4466 : > höde__tröge__müde__dätte__hätte__vuelle__guelle__aese__aesse__sauerliche__kräuter__österliche__grüße__mäh.txt
4467 : > hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt
4468 : > ✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt
4470 echo bla | ${MAILX} ${ARGS} ${ADDARG_UNI} \
4471 -a "./.ttt/ma'ger.txt" -a "./.ttt/mä'ger.txt" \
4472 -a './.ttt/diet\ is \curd.txt' -a './.ttt/diet "is" curd.txt' \
4473 -a ./.ttt/höde-tröge.txt \
4474 -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 \
4475 -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 \
4476 -a ./.ttt/hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt \
4477 -a ./.ttt/✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt \
4478 "${MBOX}"
4479 check behave:rfc2231-1 0 "${MBOX}" '684985954 3092'
4481 # `resend' test, reusing $MBOX
4482 printf "Resend ./.t2\nx\n" | ${MAILX} ${ARGS} -Rf "${MBOX}"
4483 check behave:rfc2231-2 0 ./.t2 '684985954 3092'
4485 printf "resend ./.t3\nx\n" | ${MAILX} ${ARGS} -Rf "${MBOX}"
4486 check behave:rfc2231-3 0 ./.t3 '3130352658 3148'
4488 t_epilog
4491 t_behave_iconv_mbyte_base64() {
4492 t_prolog t_behave_iconv_mbyte_base64
4493 TRAP_EXIT_ADDONS="./.t*"
4495 if [ -n "${UTF8_LOCALE}" ] && have_feat iconv &&
4496 (</dev/null iconv -f ascii -t iso-2022-jp) >/dev/null 2>&1 ||
4497 (</dev/null iconv -f ascii -t euc-jp) >/dev/null 2>&1; then
4499 else
4500 echo 'behave:iconv_mbyte_base64: unsupported, skipped'
4501 return
4504 ${cat} <<-_EOT > ./.tsendmail.sh
4505 #!${SHELL} -
4506 (echo 'From DroseriaRotundifolia Thu Aug 03 17:26:25 2017' && ${cat} &&
4507 echo) >> "${MBOX}"
4508 _EOT
4509 chmod 0755 ./.tsendmail.sh
4511 if (</dev/null iconv -f ascii -t iso-2022-jp) >/dev/null 2>&1; then
4512 ${cat} <<-'_EOT' | LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} \
4513 -Smta=./.tsendmail.sh \
4514 -Sescape=! -Smime-encoding=base64 2>./.terr
4515 set ttycharset=utf-8 sendcharsets=iso-2022-jp
4516 m t1@exam.ple
4517 !s Japanese from UTF-8 to ISO-2022-JP
4518 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
4520 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
4523 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
4525 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
4528 set ttycharset=iso-2022-jp charset-7bit=iso-2022-jp sendcharsets=utf-8
4529 m t2@exam.ple
4530 !s Japanese from ISO-2022-JP to UTF-8, eh, no, also ISO-2022-JP
4531 \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
4533 \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
4536 \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
4538 \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
4540 _EOT
4541 check behave:iconv_mbyte_base64-1 0 "${MBOX}" '3428985079 1976'
4542 check behave:iconv_mbyte_base64-2 - ./.terr '4294967295 0'
4544 printf 'eval f 1; write ./.twrite\n' |
4545 ${MAILX} ${ARGS} ${ADDARG_UNI} -Rf "${MBOX}" >./.tlog 2>&1
4546 check behave:iconv_mbyte_base64-3 0 ./.twrite '1259742080 686'
4547 check behave:iconv_mbyte_base64-4 - ./.tlog '3956097665 119'
4548 else
4549 echo 'behave:iconv_mbyte_base64: ISO-2022-JP unsupported, skipping 1-4'
4552 if (</dev/null iconv -f ascii -t euc-jp) >/dev/null 2>&1; then
4553 rm -f "${MBOX}" ./.twrite
4554 ${cat} <<-'_EOT' | LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} \
4555 -Smta=./.tsendmail.sh \
4556 -Sescape=! -Smime-encoding=base64 2>./.terr
4557 set ttycharset=utf-8 sendcharsets=euc-jp
4558 m t1@exam.ple
4559 !s Japanese from UTF-8 to EUC-JP
4560 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
4562 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
4565 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
4567 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
4570 set ttycharset=EUC-JP sendcharsets=utf-8
4571 m t2@exam.ple
4572 !s Japanese from EUC-JP to UTF-8
4573 ¥·¥¸¥å¥¦¥«¥é²Ê¡Ê¥·¥¸¥å¥¦¥«¥é¤«¡¢³Ø̾ Paridae¡Ë¤Ï¡¢Ä»Îॹ¥º¥áÌܤβʤǤ¢¤ë¡£¥·¥¸¥å¥¦¥«¥é¡Ê»Í½½¿ý¡Ë¤ÈÁí¾Î¤µ¤ì¤ë¤¬¡¢¶¹µÁ¤Ë¤Ï¤³¤Î1¼ï¤ò¥·¥¸¥å¥¦¥«¥é¤È¸Æ¤Ö¡£
4575 ¥«¥ó¥à¥ê¥¬¥é¡Ê³Ø̾Parus cristatus¡Ë¤Ï¡¢¥¹¥º¥áÌÜ¥·¥¸¥å¥¦¥«¥é²Ê¤ËʬÎव¤ì¤ëÄ»Îà¤Î°ì¼ï¡£
4578 ¥«¥ó¥à¥ê¥¬¥é¡Ê³Ø̾Parus cristatus¡Ë¤Ï¡¢¥¹¥º¥áÌÜ¥·¥¸¥å¥¦¥«¥é²Ê¤ËʬÎव¤ì¤ëÄ»Îà¤Î°ì¼ï¡£
4580 ¥·¥¸¥å¥¦¥«¥é²Ê¡Ê¥·¥¸¥å¥¦¥«¥é¤«¡¢³Ø̾ Paridae¡Ë¤Ï¡¢Ä»Îॹ¥º¥áÌܤβʤǤ¢¤ë¡£¥·¥¸¥å¥¦¥«¥é¡Ê»Í½½¿ý¡Ë¤ÈÁí¾Î¤µ¤ì¤ë¤¬¡¢¶¹µÁ¤Ë¤Ï¤³¤Î1¼ï¤ò¥·¥¸¥å¥¦¥«¥é¤È¸Æ¤Ö¡£
4582 _EOT
4583 check behave:iconv_mbyte_base64-5 0 "${MBOX}" '1686827547 2051'
4584 check behave:iconv_mbyte_base64-6 - ./.terr '4294967295 0'
4586 printf 'eval f 1; write ./.twrite\n' |
4587 ${MAILX} ${ARGS} ${ADDARG_UNI} -Rf "${MBOX}" >./.tlog 2>&1
4588 check behave:iconv_mbyte_base64-7 0 ./.twrite '1259742080 686'
4589 check behave:iconv_mbyte_base64-8 - ./.tlog '500059195 119'
4590 else
4591 echo 'behave:iconv_mbyte_base64: EUC-JP unsupported, skipping 5-8'
4594 t_epilog
4597 t_behave_iconv_mainbody() {
4598 t_prolog t_behave_iconv_mainbody
4599 TRAP_EXIT_ADDONS="./.t*"
4601 if [ -n "${UTF8_LOCALE}" ] && have_feat iconv; then
4603 else
4604 echo 'behave:iconv_mainbody: unsupported, skipped'
4605 return
4608 ${cat} <<-_EOT > ./.tsendmail.sh
4609 #!${SHELL} -
4610 (echo 'From HamamelisVirginiana Fri Oct 20 16:23:21 2017' && ${cat} &&
4611 echo) >> "${MBOX}"
4612 _EOT
4613 chmod 0755 ./.tsendmail.sh
4615 printf '–' | ${MAILX} ${ARGS} ${ADDARG_UNI} -Smta=./.tsendmail.sh \
4616 -S charset-7bit=us-ascii -S charset-8bit=utf-8 \
4617 -s '–' over-the@rain.bow 2>./.terr
4618 check behave:iconv_mainbody-1 0 "${MBOX}" '3634015017 251'
4619 check behave:iconv_mainbody-2 - ./.terr '4294967295 0'
4621 printf '–' | ${MAILX} ${ARGS} ${ADDARG_UNI} -Smta=./.tsendmail.sh \
4622 -S charset-7bit=us-ascii -S charset-8bit=us-ascii \
4623 -s '–' over-the@rain.bow 2>./.terr
4624 exn0_test behave:iconv_mainbody-3
4625 check behave:iconv_mainbody-3 - "${MBOX}" '3634015017 251'
4626 check behave:iconv_mainbody-4 - ./.terr '2579894983 148'
4628 # The different iconv(3) implementations use different replacement sequence
4629 # types (character-wise, byte-wise, and the character(s) used differ)
4630 i="${MAILX_ICONV_MODE}"
4631 if [ -n "${i}" ]; then
4632 printf 'p\nx\n' | ${MAILX} ${ARGS} -Rf "${MBOX}" >./.tout 2>./.terr
4633 j=${?}
4634 ex0_test behave:iconv_mainbody-5-0 ${j}
4635 check behave:iconv_mainbody-5-1 - ./.terr '4294967295 0'
4636 if [ ${i} -eq 13 ]; then
4637 check behave:iconv_mainbody-5-2 - ./.tout '189327996 283'
4638 elif [ ${i} -eq 12 ]; then
4639 check behave:iconv_mainbody-5-3 - ./.tout '1959197095 283'
4640 elif [ ${i} -eq 3 ]; then
4641 check behave:iconv_mainbody-5-4 - ./.tout '3196380198 279'
4642 else
4643 check behave:iconv_mainbody-5-5 - ./.tout '3760313827 279'
4645 else
4646 echo 'behave:iconv_mainbody-5: unsupported, skipped'
4649 t_epilog
4652 t_behave_binary_mainbody() {
4653 t_prolog t_behave_binary_mainbody
4654 TRAP_EXIT_ADDONS="./.t*"
4656 printf 'abra\0\nka\r\ndabra' |
4657 ${MAILX} ${ARGS} ${ADDARG_UNI} -s 'binary with carriage-return!' \
4658 "${MBOX}" 2>./.terr
4659 check behave:binary_mainbody-1 0 "${MBOX}" '2430168141 243'
4660 check behave:binary_mainbody-2 - ./.terr '4294967295 0'
4662 printf 'p\necho\necho writing now\nwrite ./.twrite\n' |
4663 ${MAILX} ${ARGS} -Rf \
4664 -Spipe-application/octet-stream="@* ${cat} > ./.tcat" \
4665 "${MBOX}" >./.tall 2>&1
4666 check behave:binary_mainbody-3 0 ./.tall '1151843761 324'
4667 check behave:binary_mainbody-4 - ./.tcat '3817108933 15'
4668 check behave:binary_mainbody-5 - ./.twrite '3817108933 15'
4670 t_epilog
4673 t_behave_q_t_etc_opts() {
4674 t_prolog t_behave_q_t_etc_opts
4675 TRAP_EXIT_ADDONS="./.t*"
4677 # Three tests for MIME encoding and (a bit) content classification.
4678 # At the same time testing -q FILE, < FILE and -t FILE
4679 t__put_body > ./.tin
4681 ${rm} -f "${MBOX}"
4682 < ./.tin ${MAILX} ${ARGS} ${ADDARG_UNI} \
4683 -a ./.tin -s "`t__put_subject`" "${MBOX}"
4684 check behave:q_t_etc_opts-1 0 "${MBOX}" '3570973309 6646'
4686 ${rm} -f "${MBOX}"
4687 < /dev/null ${MAILX} ${ARGS} ${ADDARG_UNI} \
4688 -a ./.tin -s "`t__put_subject`" -q ./.tin "${MBOX}"
4689 check behave:q_t_etc_opts-2 0 "${MBOX}" '3570973309 6646'
4691 ${rm} -f "${MBOX}"
4692 ( echo "To: ${MBOX}" && echo "Subject: `t__put_subject`" && echo &&
4693 ${cat} ./.tin
4694 ) | ${MAILX} ${ARGS} ${ADDARG_UNI} -Snodot -a ./.tin -t
4695 check behave:q_t_etc_opts-3 0 "${MBOX}" '3570973309 6646'
4697 t_epilog
4700 t_behave_s_mime() {
4701 have_feat smime || {
4702 echo 'behave:s/mime: unsupported, skipped'
4703 return
4706 t_prolog t_behave_s_mime
4707 TRAP_EXIT_ADDONS="./.t.conf ./.tkey.pem ./.tcert.pem ./.tpair.pem"
4708 TRAP_EXIT_ADDONS="${TRAP_EXIT_ADDONS} ./.VERIFY ./.DECRYPT ./.ENCRYPT"
4709 TRAP_EXIT_ADDONS="${TRAP_EXIT_ADDONS} ./.tsendmail.sh"
4711 printf 'behave:s/mime: .. generating test key and certificate ..\n'
4712 ${cat} <<-_EOT > ./.t.conf
4713 [ req ]
4714 default_bits = 1024
4715 default_keyfile = keyfile.pem
4716 distinguished_name = req_distinguished_name
4717 attributes = req_attributes
4718 prompt = no
4719 output_password =
4721 [ req_distinguished_name ]
4722 C = GB
4723 ST = Over the
4724 L = rainbow
4725 O = S-nail
4726 OU = S-nail.smime
4727 CN = S-nail.test
4728 emailAddress = test@localhost
4730 [ req_attributes ]
4731 challengePassword =
4732 _EOT
4733 openssl req -x509 -nodes -days 3650 -config ./.t.conf \
4734 -newkey rsa:1024 -keyout ./.tkey.pem -out ./.tcert.pem >/dev/null 2>&1
4735 ${cat} ./.tkey.pem ./.tcert.pem > ./.tpair.pem
4737 # Sign/verify
4738 printf 'behave:s/mime:sign/verify: '
4739 echo bla | ${MAILX} ${ARGS} \
4740 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
4741 -Ssmime-sign -Sfrom=test@localhost \
4742 -s 'S/MIME test' ./.VERIFY
4743 if [ $? -eq 0 ]; then
4744 printf 'ok\n'
4745 else
4746 printf 'failed\n'
4747 ESTAT=1
4748 t_epilog
4749 return
4752 ${awk} '
4753 BEGIN{ skip=0 }
4754 /^Content-Description: /{ skip = 2; print; next }
4755 /^$/{ if(skip) --skip }
4756 { if(!skip) print }
4758 < ./.VERIFY > "${MBOX}"
4759 check behave:s/mime:sign/verify:checksum - "${MBOX}" '2900817158 648'
4761 printf 'behave:s/mime:sign/verify:verify '
4762 printf 'verify\nx\n' |
4763 ${MAILX} ${ARGS} \
4764 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
4765 -Ssmime-sign -Sfrom=test@localhost \
4766 -Serrexit -R \
4767 -f ./.VERIFY >/dev/null 2>&1
4768 if [ $? -eq 0 ]; then
4769 printf 'ok\n'
4770 else
4771 printf 'failed\n'
4772 ESTAT=1
4773 t_epilog
4774 return
4777 printf 'behave:s/mime:sign/verify:disproof-1 '
4778 if openssl smime -verify -CAfile ./.tcert.pem \
4779 -in ./.VERIFY >/dev/null 2>&1; then
4780 printf 'ok\n'
4781 else
4782 printf 'failed\n'
4783 ESTAT=1
4784 t_epilog
4785 return
4788 # (signing +) encryption / decryption
4789 ${cat} <<-_EOT > ./.tsendmail.sh
4790 #!${SHELL} -
4791 (echo 'From Euphrasia Thu Apr 27 17:56:23 2017' && ${cat}) > ./.ENCRYPT
4792 _EOT
4793 chmod 0755 ./.tsendmail.sh
4795 printf 'behave:s/mime:encrypt+sign: '
4796 echo bla |
4797 ${MAILX} ${ARGS} \
4798 -Ssmime-force-encryption \
4799 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
4800 -Smta=./.tsendmail.sh \
4801 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
4802 -Ssmime-sign -Sfrom=test@localhost \
4803 -s 'S/MIME test' recei@ver.com
4804 if [ $? -eq 0 ]; then
4805 printf 'ok\n'
4806 else
4807 ESTAT=1
4808 printf 'error: encrypt+sign failed\n'
4811 ${sed} -e '/^$/,$d' < ./.ENCRYPT > "${MBOX}"
4812 check behave:s/mime:encrypt+sign:checksum - "${MBOX}" '1937410597 327'
4814 printf 'behave:s/mime:decrypt+verify: '
4815 printf 'decrypt ./.DECRYPT\nfi ./.DECRYPT\nverify\nx\n' |
4816 ${MAILX} ${ARGS} \
4817 -Ssmime-force-encryption \
4818 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
4819 -Smta=./.tsendmail.sh \
4820 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
4821 -Ssmime-sign -Sfrom=test@localhost \
4822 -Serrexit -R \
4823 -f ./.ENCRYPT >/dev/null 2>&1
4824 if [ $? -eq 0 ]; then
4825 printf 'ok\n'
4826 else
4827 ESTAT=1
4828 printf 'failed\n'
4831 ${awk} '
4832 BEGIN{ skip=0 }
4833 /^Content-Description: /{ skip = 2; print; next }
4834 /^$/{ if(skip) --skip }
4835 { if(!skip) print }
4837 < ./.DECRYPT > "${MBOX}"
4838 check behave:s/mime:decrypt+verify:checksum - "${MBOX}" '1720739247 931'
4840 printf 'behave:s/mime:decrypt+verify:disproof-1: '
4841 if (openssl smime -decrypt -inkey ./.tkey.pem -in ./.ENCRYPT |
4842 openssl smime -verify -CAfile ./.tcert.pem) >/dev/null 2>&1; then
4843 printf 'ok\n'
4844 else
4845 printf 'failed\n'
4846 ESTAT=1
4849 printf "behave:s/mime:encrypt: "
4850 echo bla | ${MAILX} ${ARGS} \
4851 -Ssmime-force-encryption \
4852 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
4853 -Smta=./.tsendmail.sh \
4854 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
4855 -Sfrom=test@localhost \
4856 -s 'S/MIME test' recei@ver.com
4857 if [ $? -eq 0 ]; then
4858 printf 'ok\n'
4859 else
4860 ESTAT=1
4861 printf 'failed\n'
4864 # Same as behave:s/mime:encrypt+sign:checksum above
4865 ${sed} -e '/^$/,$d' < ./.ENCRYPT > "${MBOX}"
4866 check behave:s/mime:encrypt:checksum - "${MBOX}" '1937410597 327'
4868 ${rm} -f ./.DECRYPT
4869 printf 'decrypt ./.DECRYPT\nx\n' | ${MAILX} ${ARGS} \
4870 -Ssmime-force-encryption \
4871 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
4872 -Smta=./.tsendmail.sh \
4873 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
4874 -Sfrom=test@localhost \
4875 -Serrexit -R \
4876 -f ./.ENCRYPT >/dev/null 2>&1
4877 check behave:s/mime:decrypt 0 "./.DECRYPT" '2624716890 422'
4879 printf 'behave:s/mime:decrypt:disproof-1: '
4880 if openssl smime -decrypt -inkey ./.tkey.pem \
4881 -in ./.ENCRYPT >/dev/null 2>&1; then
4882 printf 'ok\n'
4883 else
4884 printf 'failed\n'
4885 ESTAT=1
4888 t_epilog
4891 # t_content()
4892 # Some basic tests regarding correct sending of mails, via STDIN / -t / -q,
4893 # including basic MIME Content-Transfer-Encoding correctness (quoted-printable)
4894 # Note we unfortunately need to place some statements without proper
4895 # indentation because of continuation problems
4896 # xxx Note: t_content() was the first test (series) written. Today many
4897 # xxx aspects are (better) covered by other tests above, some are not.
4898 # xxx At some future date and time, convert the last remains not covered
4899 # xxx elsewhere to a real t_behave_* test and drop t_content()
4900 t_content() {
4901 t_prolog t_content
4903 # Test for [260e19d] (Juergen Daubert)
4904 ${rm} -f "${MBOX}"
4905 echo body | ${MAILX} ${ARGS} "${MBOX}"
4906 check content:004 0 "${MBOX}" '2917662811 98'
4908 # "Test for" [d6f316a] (Gavin Troy)
4909 ${rm} -f "${MBOX}"
4910 printf "m ${MBOX}\n~s subject1\nEmail body\n~.\nfi ${MBOX}\np\nx\n" |
4911 ${MAILX} ${ARGS} ${ADDARG_UNI} -Spipe-text/plain="@* ${cat}" > "${BODY}"
4912 check content:006 0 "${MBOX}" '2099098650 122'
4913 check content:006-1 - "${BODY}" '794542938 174'
4915 # "Test for" [c299c45] (Peter Hofmann) TODO shouldn't end up QP-encoded?
4916 ${rm} -f "${MBOX}"
4917 ${awk} 'BEGIN{
4918 for(i = 0; i < 10000; ++i)
4919 printf "\xC3\xBC"
4920 #printf "\xF0\x90\x87\x90"
4921 }' | ${MAILX} ${ARGS} ${ADDARG_UNI} -s TestSubject "${MBOX}"
4922 check content:007 0 "${MBOX}" '534262374 61816'
4924 t_epilog
4927 t__put_subject() {
4928 # MIME encoding (QP) stress message subject
4929 printf 'Äbrä Kä?dä=brö Fü?di=bus? '\
4930 'adadaddsssssssddddddddddddddddddddd'\
4931 'ddddddddddddddddddddddddddddddddddd'\
4932 'ddddddddddddddddddddddddddddddddddd'\
4933 'dddddddddddddddddddd Hallelulja? Od'\
4934 'er?? eeeeeeeeeeeeeeeeeeeeeeeeeeeeee'\
4935 'eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'\
4936 'eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee f'\
4937 'fffffffffffffffffffffffffffffffffff'\
4938 'fffffffffffffffffffff ggggggggggggg'\
4939 'ggggggggggggggggggggggggggggggggggg'\
4940 'ggggggggggggggggggggggggggggggggggg'\
4941 'ggggggggggggggggggggggggggggggggggg'\
4942 'gggggggggggggggg'
4945 t__put_body() {
4946 # MIME encoding (QP) stress message body
4947 printf \
4948 'Ich bin eine DÖS-Datäi mit sehr langen Zeilen und auch '\
4949 'sonst bin ich ganz schön am Schleudern, da kannste denke '\
4950 "wasde willst, gelle, gelle, gelle, gelle, gelle.\r\n"\
4951 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst \r\n"\
4952 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1\r\n"\
4953 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12\r\n"\
4954 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123\r\n"\
4955 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1234\r\n"\
4956 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12345\r\n"\
4957 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123456\r\n"\
4958 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1234567\r\n"\
4959 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12345678\r\n"\
4960 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123456789\r\n"\
4961 "Unn ausserdem habe ich trailing SP/HT/SP/HT whitespace \r\n"\
4962 "Unn ausserdem habe ich trailing HT/SP/HT/SP whitespace \r\n"\
4963 "auf den zeilen vorher.\r\n"\
4964 "From am Zeilenbeginn und From der Mitte gibt es auch.\r\n"\
4965 ".\r\n"\
4966 "Die letzte Zeile war nur ein Punkt.\r\n"\
4967 "..\r\n"\
4968 "Das waren deren zwei.\r\n"\
4969 " \r\n"\
4970 "Die letzte Zeile war ein Leerschritt.\n"\
4971 "=VIER = EQUAL SIGNS=ON A LINE=\r\n"\
4972 "Prösterchen.\r\n"\
4973 ".\n"\
4974 "Die letzte Zeile war nur ein Punkt, mit Unix Zeilenende.\n"\
4975 "..\n"\
4976 "Das waren deren zwei. ditto.\n"\
4977 "Prösterchen.\n"\
4978 "Unn ausseerdem habe ich trailing SP/HT/SP/HT whitespace \n"\
4979 "Unn ausseerdem habe ich trailing HT/SP/HT/SP whitespace \n"\
4980 "auf den zeilen vorher.\n"\
4981 "ditto.\n"\
4982 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.\n"\
4983 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.1"\
4984 "\n"\
4985 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
4986 "\n"\
4987 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
4988 "3\n"\
4989 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
4990 "34\n"\
4991 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
4992 "345\n"\
4993 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
4994 "3456\n"\
4995 "QP am Zeilenende über soft-nl hinweg\n"\
4996 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
4997 "ö123\n"\
4998 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
4999 "1ö23\n"\
5000 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
5001 "12ö3\n"\
5002 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
5003 "123ö\n"\
5004 "=VIER = EQUAL SIGNS=ON A LINE=\n"\
5005 " \n"\
5006 "Die letzte Zeile war ein Leerschritt.\n"\
5010 t_all() {
5011 # if have_feat devel; then
5012 # ARGS="${ARGS} -Smemdebug"
5013 # export ARGS
5014 # fi
5016 if [ -n "${UTF8_LOCALE}" ]; then
5017 printf 'Using Unicode locale %s\n' "${UTF8_LOCALE}"
5018 else
5019 printf 'No Unicode locale found, disabling Unicode tests\n'
5022 t_behave
5023 t_content
5026 if [ -z "${CHECK_ONLY}${MAE_TEST}" ]; then
5027 cc_all_configs
5028 elif [ -z "${MAE_TEST}" ] || [ ${#} -eq 0 ]; then
5029 t_all
5030 else
5031 while [ ${#} -gt 0 ]; do
5032 ${1}
5033 shift
5034 done
5037 [ ${ESTAT} -eq 0 ] && echo Ok || echo >&2 'Errors occurred'
5039 exit ${ESTAT}
5040 # s-sh-mode