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