Build system: $INCS was added too late to be recognized by targets!
[s-mailx.git] / cc-test.sh
blob0da316f315b587868d709d23f15f27667d69590a
1 #!/bin/sh -
2 #@ Synopsis: ./cc-test.sh --check-only [s-mailx-binary]
3 #@ ./cc-test.sh --mae-test s-mailx-binary [:TESTNAME:]
4 #@ [./cc-test.sh # Note: performs hundreds of compilations!]
5 #@ The latter generates output files.
6 #@ TODO All ex0_test should say TESTNUMBER-estat instead of having own numbers
7 #@ TODO _All_ the tests should happen in a temporary subdir.
8 # Public Domain
10 # Instead of figuring out the environment in here, require a configured build
11 # system and include that! Our makefile and configure ensure that this test
12 # does not run in the configured, but the user environment nonetheless!
14 if [ -f ./mk-config.ev ]; then
16 elif [ -f snailmail.jpg ] && [ -f .obj/mk-config.ev ]; then
17 cd .obj
18 i=../
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 echo >&2 'Hit RETURN to run "make config CONFIG=null'
25 read l
26 make config CONFIG=null
28 . ./mk-config.ev
29 if [ -z "${MAILX__CC_TEST_RUNNING}" ]; then
30 MAILX__CC_TEST_RUNNING=1
31 export MAILX__CC_TEST_RUNNING
32 exec "${SHELL}" "${i}${0}" "${@}"
35 # We need *stealthmua* regardless of $SOURCE_DATE_EPOCH, the program name as
36 # such is a compile-time variable
37 ARGS='-:/ -# -Sdotlock-ignore-error -Sexpandaddr=restrict'
38 ARGS="${ARGS}"' -Smime-encoding=quoted-printable -Snosave -Sstealthmua'
39 ADDARG_UNI=-Sttycharset=UTF-8
40 CONF=../make.rc
41 BODY=./.cc-body.txt
42 MBOX=./.cc-test.mbox
43 ERR=./.cc-test.err # Covers only some which cannot be checksummed; not quoted!
44 MAIL=/dev/null
45 #UTF8_LOCALE= autodetected unless set
47 # Note valgrind has problems with FDs in forked childs, which causes some tests
48 # to fail (the FD is rewound and thus will be dumped twice)
49 MEMTESTER=
50 #MEMTESTER='valgrind --leak-check=full --log-file=.vl-%p '
52 ## -- (>8 -- 8<) -- ##
54 ( set -o noglob ) >/dev/null 2>&1 && noglob_shell=1 || unset noglob_shell
56 msg() {
57 fmt=${1}
58 shift
59 printf >&2 -- "${fmt}\\n" "${@}"
62 ## -- >8 -- 8< -- ##
64 export ARGS ADDARG_UNI CONF BODY MBOX MAIL MAKE awk cat cksum rm sed grep
66 LC_ALL=C LANG=C
67 TZ=UTC
68 # Wed Oct 2 01:50:07 UTC 1996
69 SOURCE_DATE_EPOCH=844221007
71 export LC_ALL LANG TZ SOURCE_DATE_EPOCH
72 unset POSIXLY_CORRECT LOGNAME USER
74 usage() {
75 echo >&2 "Synopsis: ./cc-test.sh [--check-only s-mailx-binary]"
76 echo >&2 "Synopsis: ./cc-test.sh --mae-test s-mailx-binary [:TESTNAME:]"
77 exit 1
80 CHECK_ONLY= MAE_TEST= MAILX=
81 if [ "${1}" = --check-only ]; then
82 CHECK_ONLY=1
83 MAILX=${2}
84 [ -x "${MAILX}" ] || usage
85 shift 2
86 elif [ "${1}" = --mae-test ]; then
87 MAE_TEST=1
88 MAILX=${2}
89 [ -x "${MAILX}" ] || usage
90 shift 2
92 RAWMAILX=${MAILX}
93 MAILX="${MEMTESTER}${MAILX}"
94 export RAWMAILX MAILX
96 if [ -n "${CHECK_ONLY}${MAE_TEST}" ] && [ -z "${UTF8_LOCALE}" ]; then
97 # Try ourselfs via nl_langinfo(CODESET) first (requires a new version)
98 if command -v "${RAWMAILX}" >/dev/null 2>&1 &&
99 ("${RAWMAILX}" -:/ -Xxit) >/dev/null 2>&1; then
100 i=`LC_ALL=C.utf8 "${RAWMAILX}" ${ARGS} -X '
101 \define cset_test {
102 \if [ "${ttycharset}" @i=% utf ]
103 \echo $LC_ALL
104 \xit 0
105 \end
106 \if [ "${#}" -gt 0 ]
107 \wysh set LC_ALL=${1}
108 \shift
109 \eval xcall cset_test "${@}"
110 \end
111 \xit 1
113 \call cset_test C.UTF-8 POSIX.utf8 POSIX.UTF-8 \
114 en_EN.utf8 en_EN.UTF-8 en_US.utf8 en_US.UTF-8
116 [ $? -eq 0 ] && UTF8_LOCALE=$i
119 if [ -z "${UTF8_LOCALE}" ] && (locale yesexpr) >/dev/null 2>&1; then
120 UTF8_LOCALE=`locale -a | { m=
121 while read n; do
122 if { echo ${n} |
123 ${grep} -i -e utf8 -e utf-8; } >/dev/null 2>&1; then
124 m=${n}
125 if { echo ${n} |
126 ${grep} -e POSIX -e en_EN -e en_US; } >/dev/null 2>&1; then
127 break
130 done
131 echo ${m}
136 ESTAT=0
138 TRAP_EXIT_ADDONS=
139 trap "${rm} -rf \"${BODY}\" \"${MBOX}\" \"${ERR}\" \${TRAP_EXIT_ADDONS}" EXIT
140 trap "exit 1" HUP INT TERM
142 have_feat() {
143 ( "${RAWMAILX}" ${ARGS} -X'echo $features' -Xx |
144 ${grep} +${1} ) >/dev/null 2>&1
147 t_prolog() {
148 ${rm} -rf "${BODY}" "${MBOX}" ${TRAP_EXIT_ADDONS}
149 TRAP_EXIT_ADDONS=
150 [ ${#} -gt 0 ] && printf '[%s]\n' "${1}"
152 t_epilog() {
153 t_prolog
156 check() {
157 restat=${?} tid=${1} eestat=${2} f=${3} s=${4}
158 [ "${eestat}" != - ] && [ "${restat}" != "${eestat}" ] &&
159 err "${tid}" 'unexpected exit status: '"${restat} != ${eestat}"
160 csum="`${cksum} < ${f}`"
161 if [ "${csum}" = "${s}" ]; then
162 maex=
163 printf '%s: ok\n' "${tid}"
164 else
165 maex=yes
166 ESTAT=1
167 printf '%s: error: checksum mismatch (got %s)\n' "${tid}" "${csum}"
170 if [ -n "${MAE_TEST}" ]; then
171 x=mae-test-`echo ${tid} | ${tr} "/:=" "__-"`
172 ${cp} -f "${f}" ./"${x}"
174 if [ -n "${maex}" ] && [ -d ../.git ] &&
175 command -v diff >/dev/null 2>&1 &&
176 (git rev-parse --verify test-out) >/dev/null 2>&1 &&
177 git show test-out:"${x}" > ./"${x}".old 2>/dev/null; then
178 diff -ru ./"${x}".old ./"${x}" > "${x}".diff
183 err() {
184 ESTAT=1
185 printf '%s: error: %s\n' ${1} "${2}"
188 ex0_test() {
189 # $1=test name [$2=status]
190 __qm__=${?}
191 [ ${#} -gt 1 ] && __qm__=${2}
192 if [ ${__qm__} -ne 0 ]; then
193 err $1 'unexpected non-0 exit status'
194 else
195 printf '%s: ok\n' "${1}"
199 exn0_test() {
200 # $1=test name [$2=status]
201 __qm__=${?}
202 [ ${#} -gt 1 ] && __qm__=${2}
203 if [ ${__qm__} -eq 0 ]; then
204 err $1 'unexpected 0 exit status'
205 else
206 printf '%s: ok\n' "${1}"
210 if ( [ "$((1 + 1))" = 2 ] ) >/dev/null 2>&1; then
211 add() {
212 echo "$((${1} + ${2}))"
214 else
215 add() {
216 echo `${awk} 'BEGIN{print '${1}' + '${2}'}'`
220 if ( [ "$((2 % 3))" = 2 ] ) >/dev/null 2>&1; then
221 modulo() {
222 echo "$((${1} % ${2}))"
224 else
225 modulo() {
226 echo `${awk} 'BEGIN{print '${1}' % '${2}'}'`
230 # t_behave()
231 # Basic (easily testable) behaviour tests
232 t_behave() {
233 t_behave_X_opt_input_command_stack
234 t_behave_X_errexit
235 t_behave_S_freeze
236 t_behave_wysh
237 t_behave_input_inject_semicolon_seq
238 t_behave_commandalias
239 t_behave_ifelse
240 t_behave_localopts
241 t_behave_local
242 t_behave_macro_param_shift
243 t_behave_addrcodec
244 t_behave_vexpr
245 t_behave_call_ret
246 t_behave_xcall
247 t_behave_vpospar
248 t_behave_atxplode
249 t_behave_read
251 t_behave_mbox
252 t_behave_maildir
253 t_behave_record_a_resend
254 t_behave_e_H_L_opts
256 t_behave_alternates
257 t_behave_alias
258 # FIXME t_behave_mlist
259 t_behave_filetype
261 t_behave_message_injections
262 t_behave_attachments
263 t_behave_compose_hooks
264 t_behave_C_opt_customhdr
266 t_behave_mass_recipients
267 t_behave_mime_types_load_control
268 t_behave_lreply_futh_rth_etc
270 t_behave_mime_if_not_ascii
271 t_behave_xxxheads_rfc2047
272 t_behave_rfc2231
273 t_behave_iconv_mbyte_base64
274 t_behave_iconv_mainbody
275 t_behave_binary_mainbody
276 t_behave_q_t_etc_opts
278 t_behave_s_mime
281 t_behave_X_opt_input_command_stack() {
282 t_prolog t_behave_X_opt_input_command_stack
284 ${cat} <<- '__EOT' > "${BODY}"
285 echo 1
286 define mac0 {
287 echo mac0-1 via1 $0
289 call mac0
290 echo 2
291 source '\
292 echo "define mac1 {";\
293 echo " echo mac1-1 via1 \$0";\
294 echo " call mac0";\
295 echo " echo mac1-2";\
296 echo " call mac2";\
297 echo " echo mac1-3";\
298 echo "}";\
299 echo "echo 1-1";\
300 echo "define mac2 {";\
301 echo " echo mac2-1 via1 \$0";\
302 echo " call mac0";\
303 echo " echo mac2-2";\
304 echo "}";\
305 echo "echo 1-2";\
306 echo "call mac1";\
307 echo "echo 1-3";\
308 echo "source \"\
309 echo echo 1-1-1 via1 \$0;\
310 echo call mac0;\
311 echo echo 1-1-2;\
312 | \"";\
313 echo "echo 1-4";\
315 echo 3
316 call mac2
317 echo 4
318 undefine *
319 __EOT
321 # The -X option supports multiline arguments, and those can internally use
322 # reverse solidus newline escaping. And all -X options are joined...
323 APO=\'
324 < "${BODY}" ${MAILX} ${ARGS} \
325 -X 'e\' \
326 -X ' c\' \
327 -X ' h\' \
328 -X ' o \' \
329 -X 1 \
331 define mac0 {
332 echo mac0-1 via2 $0
334 call mac0
335 echo 2
338 source '${APO}'\
339 echo "define mac1 {";\
340 echo " echo mac1-1 via2 \$0";\
341 echo " call mac0";\
342 echo " echo mac1-2";\
343 echo " call mac2";\
344 echo " echo mac1-3";\
345 echo "}";\
346 echo "echo 1-1";\
347 echo "define mac2 {";\
348 echo " echo mac2-1 via2 \$0";\
349 echo " call mac0";\
350 echo " echo mac2-2";\
351 echo "}";\
352 echo "echo 1-2";\
353 echo "call mac1";\
354 echo "echo 1-3";\
355 echo "source \"\
356 echo echo 1-1-1 via2 \$0;\
357 echo call mac0;\
358 echo echo 1-1-2;\
359 | \"";\
360 echo "echo 1-4";\
361 | '${APO}'
362 echo 3
365 call mac2
366 echo 4
367 undefine *
368 ' > "${MBOX}"
370 check behave:x_opt_input_command_stack 0 "${MBOX}" '1786542668 416'
372 t_epilog
375 t_behave_X_errexit() {
376 t_prolog t_behave_X_errexit
377 if have_feat uistrings; then :; else
378 echo 'behave:x_errexit: unsupported, skipped'
379 return
382 ${cat} <<- '__EOT' > "${BODY}"
383 echo one
384 echos nono
385 echo two
386 __EOT
388 </dev/null ${MAILX} ${ARGS} -Snomemdebug \
389 -X'echo one' -X' echos nono ' -X'echo two' \
390 > "${MBOX}" 2>&1
391 check behave:x_errexit-1 0 "${MBOX}" '916157812 53'
393 </dev/null ${MAILX} ${ARGS} -X'source '"${BODY}" -Snomemdebug \
394 > "${MBOX}" 2>&1
395 check behave:x_errexit-2 0 "${MBOX}" '916157812 53'
397 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Snomemdebug \
398 > "${MBOX}" 2>&1
399 check behave:x_errexit-3 0 "${MBOX}" '916157812 53'
403 </dev/null ${MAILX} ${ARGS} -Serrexit -Snomemdebug \
404 -X'echo one' -X' echos nono ' -X'echo two' \
405 > "${MBOX}" 2>&1
406 check behave:x_errexit-4 1 "${MBOX}" '2118430867 49'
408 </dev/null ${MAILX} ${ARGS} -X'source '"${BODY}" -Serrexit -Snomemdebug \
409 > "${MBOX}" 2>&1
410 check behave:x_errexit-5 1 "${MBOX}" '2118430867 49'
412 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Serrexit -Snomemdebug \
413 > "${MBOX}" 2>&1
414 check behave:x_errexit-6 1 "${MBOX}" '12955965 172'
416 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Sposix -Snomemdebug \
417 > "${MBOX}" 2>&1
418 check behave:x_errexit-7 1 "${MBOX}" '12955965 172'
420 ## Repeat 4-7 with ignerr set
422 ${sed} -e 's/^echos /ignerr echos /' < "${BODY}" > "${MBOX}"
424 </dev/null ${MAILX} ${ARGS} -Serrexit -Snomemdebug \
425 -X'echo one' -X'ignerr echos nono ' -X'echo two' \
426 > "${BODY}" 2>&1
427 check behave:x_errexit-8 0 "${BODY}" '916157812 53'
429 </dev/null ${MAILX} ${ARGS} -X'source '"${MBOX}" -Serrexit -Snomemdebug \
430 > "${BODY}" 2>&1
431 check behave:x_errexit-9 0 "${BODY}" '916157812 53'
433 </dev/null MAILRC="${MBOX}" ${MAILX} ${ARGS} -:u -Serrexit -Snomemdebug \
434 > "${BODY}" 2>&1
435 check behave:x_errexit-10 0 "${BODY}" '916157812 53'
437 </dev/null MAILRC="${MBOX}" ${MAILX} ${ARGS} -:u -Sposix -Snomemdebug \
438 > "${BODY}" 2>&1
439 check behave:x_errexit-11 0 "${BODY}" '916157812 53'
441 t_epilog
444 t_behave_S_freeze() {
445 t_prolog t_behave_S_freeze
446 oterm=$TERM
447 unset TERM
449 # Test basic assumption
450 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} \
451 -X'echo asksub<$asksub> dietcurd<$dietcurd>' \
452 -Xx > "${MBOX}" 2>&1
453 check behave:s_freeze-1 0 "${MBOX}" '270686329 21'
456 ${cat} <<- '__EOT' > "${BODY}"
457 echo asksub<$asksub>
458 set asksub
459 echo asksub<$asksub>
460 __EOT
461 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
462 -Snoasksub -Sasksub -Snoasksub \
463 -X'echo asksub<$asksub>' -X'set asksub' -X'echo asksub<$asksub>' \
464 -Xx > "${MBOX}" 2>&1
465 check behave:s_freeze-2 0 "${MBOX}" '3182942628 37'
467 ${cat} <<- '__EOT' > "${BODY}"
468 echo asksub<$asksub>
469 unset asksub
470 echo asksub<$asksub>
471 __EOT
472 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
473 -Snoasksub -Sasksub \
474 -X'echo asksub<$asksub>' -X'unset asksub' -X'echo asksub<$asksub>' \
475 -Xx > "${MBOX}" 2>&1
476 check behave:s_freeze-3 0 "${MBOX}" '2006554293 39'
479 ${cat} <<- '__EOT' > "${BODY}"
480 echo dietcurd<$dietcurd>
481 set dietcurd=cherry
482 echo dietcurd<$dietcurd>
483 __EOT
484 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
485 -Sdietcurd=strawberry -Snodietcurd -Sdietcurd=vanilla \
486 -X'echo dietcurd<$dietcurd>' -X'unset dietcurd' \
487 -X'echo dietcurd<$dietcurd>' \
488 -Xx > "${MBOX}" 2>&1
489 check behave:s_freeze-4 0 "${MBOX}" '1985768109 65'
491 ${cat} <<- '__EOT' > "${BODY}"
492 echo dietcurd<$dietcurd>
493 unset dietcurd
494 echo dietcurd<$dietcurd>
495 __EOT
496 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
497 -Sdietcurd=strawberry -Snodietcurd \
498 -X'echo dietcurd<$dietcurd>' -X'set dietcurd=vanilla' \
499 -X'echo dietcurd<$dietcurd>' \
500 -Xx > "${MBOX}" 2>&1
501 check behave:s_freeze-5 0 "${MBOX}" '151574279 51'
503 # TODO once we have a detached one with env=1..
504 if [ -n "`</dev/null ${MAILX} ${ARGS} -X'!echo \$TERM' -Xx`" ]; then
505 echo 'behave:s_freeze-{6,7}: shell sets $TERM, skipped'
506 else
507 ${cat} <<- '__EOT' > "${BODY}"
508 !echo "shell says TERM<$TERM>"
509 echo TERM<$TERM>
510 !echo "shell says TERM<$TERM>"
511 set TERM=cherry
512 !echo "shell says TERM<$TERM>"
513 echo TERM<$TERM>
514 !echo "shell says TERM<$TERM>"
515 __EOT
516 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
517 -STERM=strawberry -SnoTERM -STERM=vanilla \
518 -X'echo mail<$TERM>' -X'unset TERM' \
519 -X'!echo "shell says TERM<$TERM>"' -X'echo TERM<$TERM>' \
520 -Xx > "${MBOX}" 2>&1
521 check behave:s_freeze-6 0 "${MBOX}" '1211476036 167'
523 ${cat} <<- '__EOT' > "${BODY}"
524 !echo "shell says TERM<$TERM>"
525 echo TERM<$TERM>
526 !echo "shell says TERM<$TERM>"
527 set TERM=cherry
528 !echo "shell says TERM<$TERM>"
529 echo TERM<$TERM>
530 !echo "shell says TERM<$TERM>"
531 __EOT
532 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
533 -STERM=strawberry -SnoTERM \
534 -X'echo TERM<$TERM>' -X'set TERM=vanilla' \
535 -X'!echo "shell says TERM<$TERM>"' -X'echo TERM<$TERM>' \
536 -Xx > "${MBOX}" 2>&1
537 check behave:s_freeze-7 0 "${MBOX}" '3365080441 132'
540 TERM=$oterm
541 t_epilog
544 t_behave_wysh() {
545 t_prolog t_behave_wysh
547 ${cat} <<- '__EOT' > "${BODY}"
549 echo abcd
550 echo a'b'c'd'
551 echo a"b"c"d"
552 echo a$'b'c$'d'
553 echo 'abcd'
554 echo "abcd"
555 echo $'abcd'
556 echo a\ b\ c\ d
557 echo a 'b c' d
558 echo a "b c" d
559 echo a $'b c' d
561 echo 'a$`"\'
562 echo "a\$\`'\"\\"
563 echo $'a\$`\'\"\\'
564 echo $'a\$`\'"\\'
565 # DIET=CURD TIED=
566 echo 'a${DIET}b${TIED}c\${DIET}d\${TIED}e' # COMMENT
567 echo "a${DIET}b${TIED}c\${DIET}d\${TIED}e"
568 echo $'a${DIET}b${TIED}c\${DIET}d\${TIED}e'
570 echo a$'\101\0101\x41\u0041\u41\U00000041\U41'c
571 echo a$'\u0041\u41\u0C1\U00000041\U41'c
572 echo a$'\377'c
573 echo a$'\0377'c
574 echo a$'\400'c
575 echo a$'\0400'c
576 echo a$'\U1100001'c
578 echo a$'b\0c'd
579 echo a$'b\00c'de
580 echo a$'b\000c'df
581 echo a$'b\0000c'dg
582 echo a$'b\x0c'dh
583 echo a$'b\x00c'di
584 echo a$'b\u0'dj
585 echo a$'b\u00'dk
586 echo a$'b\u000'dl
587 echo a$'b\u0000'dm
588 echo a$'b\U0'dn
589 echo a$'b\U00'do
590 echo a$'b\U000'dp
591 echo a$'b\U0000'dq
592 echo a$'b\U00000'dr
593 echo a$'b\U000000'ds
594 echo a$'b\U0000000'dt
595 echo a$'b\U00000000'du
597 echo a$'\cI'b
598 echo a$'\011'b
599 echo a$'\x9'b
600 echo a$'\u9'b
601 echo a$'\U9'b
602 echo a$'\c@'b c d
603 __EOT
605 if [ -z "${UTF8_LOCALE}" ]; then
606 echo 'Skip behave:wysh_unicode, no UTF8_LOCALE'
607 else
608 < "${BODY}" DIET=CURD TIED= \
609 LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} > "${MBOX}" 2>>${ERR}
610 check behave:wysh_unicode 0 "${MBOX}" '475805847 317'
613 < "${BODY}" DIET=CURD TIED= ${MAILX} ${ARGS} > "${MBOX}" 2>>${ERR}
614 check behave:wysh_c 0 "${MBOX}" '1473887148 321'
616 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
617 wysh set mager='\hey\'
618 varshow mager
619 wysh set mager="\hey\\"
620 varshow mager
621 wysh set mager=$'\hey\\'
622 varshow mager
623 __EOT
624 check behave:wysh-3 0 "${MBOX}" '1289698238 69'
626 t_epilog
629 t_behave_input_inject_semicolon_seq() {
630 t_prolog t_behave_input_inject_semicolon_seq
632 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
633 define mydeepmac {
634 echon '(mydeepmac)';
636 define mymac {
637 echon this_is_mymac;call mydeepmac;echon ';';
639 echon one';';call mymac;echon two";";call mymac;echo three$';';
640 define mymac {
641 echon this_is_mymac;call mydeepmac;echon ,TOO'!;';
643 echon one';';call mymac;echon two";";call mymac;echo three$';';
644 __EOT
646 check behave:input_inject_semicolon_seq 0 "${MBOX}" '512117110 140'
648 t_epilog
651 t_behave_commandalias() {
652 t_prolog t_behave_commandalias
654 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
655 commandalias echo echo hoho
656 echo stop.
657 commandalias X Xx
658 commandalias Xx XxX
659 commandalias XxX XxXx
660 commandalias XxXx XxXxX
661 commandalias XxXxX XxXxXx
662 commandalias XxXxXx echo huhu
663 commandalias XxXxXxX echo huhu
665 commandalias XxXxXx XxXxXxX
667 uncommandalias echo
668 commandalias XxXxXx echo huhu
670 __EOT
672 check behave:commandalias 0 "${MBOX}" '1638809585 36'
674 t_epilog
677 t_behave_ifelse() {
678 t_prolog t_behave_ifelse
680 # Nestable conditions test
681 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
682 if 0
683 echo 1.err
684 else
685 echo 1.ok
686 endif
687 if 1
688 echo 2.ok
689 else
690 echo 2.err
691 endif
692 if $dietcurd
693 echo 3.err
694 else
695 echo 3.ok
696 endif
697 set dietcurd=yoho
698 if $dietcurd
699 echo 4.ok
700 else
701 echo 4.err
702 endif
703 if $dietcurd == 'yoho'
704 echo 5.ok
705 else
706 echo 5.err
707 endif
708 if $dietcurd @== 'Yoho'
709 echo 5-1.ok
710 else
711 echo 5-1.err
712 endif
713 if $dietcurd == 'Yoho'
714 echo 5-2.err
715 else
716 echo 5-2.ok
717 endif
718 if $dietcurd != 'yoho'
719 echo 6.err
720 else
721 echo 6.ok
722 endif
723 if $dietcurd @!= 'Yoho'
724 echo 6-1.err
725 else
726 echo 6-1.ok
727 endif
728 if $dietcurd != 'Yoho'
729 echo 6-2.ok
730 else
731 echo 6-2.err
732 endif
733 # Nesting
734 if faLse
735 echo 7.err1
736 if tRue
737 echo 7.err2
738 if yEs
739 echo 7.err3
740 else
741 echo 7.err4
742 endif
743 echo 7.err5
744 endif
745 echo 7.err6
746 else
747 echo 7.ok7
748 if YeS
749 echo 7.ok8
750 if No
751 echo 7.err9
752 else
753 echo 7.ok9
754 endif
755 echo 7.ok10
756 else
757 echo 7.err11
758 if yeS
759 echo 7.err12
760 else
761 echo 7.err13
762 endif
763 endif
764 echo 7.ok14
765 endif
766 if r
767 echo 8.ok1
768 if R
769 echo 8.ok2
770 else
771 echo 8.err2
772 endif
773 echo 8.ok3
774 else
775 echo 8.err1
776 endif
777 if s
778 echo 9.err1
779 else
780 echo 9.ok1
781 if S
782 echo 9.err2
783 else
784 echo 9.ok2
785 endif
786 echo 9.ok3
787 endif
788 # `elif'
789 if $dietcurd == 'yohu'
790 echo 10.err1
791 elif $dietcurd == 'yoha'
792 echo 10.err2
793 elif $dietcurd == 'yohe'
794 echo 10.err3
795 elif $dietcurd == 'yoho'
796 echo 10.ok1
797 if $dietcurd == 'yohu'
798 echo 10.err4
799 elif $dietcurd == 'yoha'
800 echo 10.err5
801 elif $dietcurd == 'yohe'
802 echo 10.err6
803 elif $dietcurd == 'yoho'
804 echo 10.ok2
805 if $dietcurd == 'yohu'
806 echo 10.err7
807 elif $dietcurd == 'yoha'
808 echo 10.err8
809 elif $dietcurd == 'yohe'
810 echo 10.err9
811 elif $dietcurd == 'yoho'
812 echo 10.ok3
813 else
814 echo 10.err10
815 endif
816 else
817 echo 10.err11
818 endif
819 else
820 echo 10.err12
821 endif
822 # integer
823 set dietcurd=10
824 if $dietcurd -lt 11
825 echo 11.ok1
826 if $dietcurd -gt 9
827 echo 11.ok2
828 else
829 echo 11.err2
830 endif
831 if $dietcurd -eq 10
832 echo 11.ok3
833 else
834 echo 11.err3
835 endif
836 if $dietcurd -ge 10
837 echo 11.ok4
838 else
839 echo 11.err4
840 endif
841 if $dietcurd -le 10
842 echo 11.ok5
843 else
844 echo 11.err5
845 endif
846 if $dietcurd -ge 11
847 echo 11.err6
848 else
849 echo 11.ok6
850 endif
851 if $dietcurd -le 9
852 echo 11.err7
853 else
854 echo 11.ok7
855 endif
856 else
857 echo 11.err1
858 endif
859 set dietcurd=Abc
860 if $dietcurd < aBd
861 echo 12.ok1
862 if $dietcurd @> abB
863 echo 12.ok2
864 else
865 echo 12.err2
866 endif
867 if $dietcurd @== aBC
868 echo 12.ok3
869 else
870 echo 12.err3
871 endif
872 if $dietcurd @>= AbC
873 echo 12.ok4
874 else
875 echo 12.err4
876 endif
877 if $dietcurd @<= ABc
878 echo 12.ok5
879 else
880 echo 12.err5
881 endif
882 if $dietcurd @>= abd
883 echo 12.err6
884 else
885 echo 12.ok6
886 endif
887 if $dietcurd @<= abb
888 echo 12.err7
889 else
890 echo 12.ok7
891 endif
892 else
893 echo 12.err1
894 endif
895 if $dietcurd < aBc
896 echo 12-1.ok
897 else
898 echo 12-1.err
899 endif
900 if $dietcurd @< aBc
901 echo 12-2.err
902 else
903 echo 12-2.ok
904 endif
905 if $dietcurd > ABc
906 echo 12-3.ok
907 else
908 echo 12-3.err
909 endif
910 if $dietcurd @> ABc
911 echo 12-3.err
912 else
913 echo 12-3.ok
914 endif
915 if $dietcurd @i=% aB
916 echo 13.ok
917 else
918 echo 13.err
919 endif
920 if $dietcurd =% aB
921 echo 13-1.err
922 else
923 echo 13-1.ok
924 endif
925 if $dietcurd @=% bC
926 echo 14.ok
927 else
928 echo 14.err
929 endif
930 if $dietcurd !% aB
931 echo 15-1.ok
932 else
933 echo 15-1.err
934 endif
935 if $dietcurd @!% aB
936 echo 15-2.err
937 else
938 echo 15-2.ok
939 endif
940 if $dietcurd !% bC
941 echo 15-3.ok
942 else
943 echo 15-3.err
944 endif
945 if $dietcurd @!% bC
946 echo 15-4.err
947 else
948 echo 15-4.ok
949 endif
950 if $dietcurd =% Cd
951 echo 16.err
952 else
953 echo 16.ok
954 endif
955 if $dietcurd !% Cd
956 echo 17.ok
957 else
958 echo 17.err
959 endif
960 set diet=abc curd=abc
961 if $diet == $curd
962 echo 18.ok
963 else
964 echo 18.err
965 endif
966 set diet=abc curd=abcd
967 if $diet != $curd
968 echo 19.ok
969 else
970 echo 19.err
971 endif
972 # 1. Shitty grouping capabilities as of today
973 unset diet curd ndefined
974 if [ [ false ] || [ false ] || [ true ] ] && [ [ false ] || [ true ] ] && \
975 [ yes ]
976 echo 20.ok
977 else
978 echo 20.err
979 endif
980 if [ [ [ [ 0 ] || [ 1 ] ] && [ [ 1 ] || [ 0 ] ] ] && [ 1 ] ] && [ yes ]
981 echo 21.ok
982 else
983 echo 21.err
984 endif
985 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] ]
986 echo 22.ok
987 else
988 echo 22.err
989 endif
990 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] ]
991 echo 23.ok
992 else
993 echo 23.err
994 endif
995 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] && [ no ]
996 echo 24.err
997 else
998 echo 24.ok
999 endif
1000 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] \
1001 && [ no ] || [ yes ]
1002 echo 25.ok
1003 else
1004 echo 25.err
1005 endif
1006 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
1007 echo 26.ok
1008 else
1009 echo 26.err
1010 endif
1011 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 0 ] ]
1012 echo 27.err
1013 else
1014 echo 27.ok
1015 endif
1016 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 0 ] ] && [ 1 ] ] ] && [ 1 ] ]
1017 echo 28.err
1018 else
1019 echo 28.ok
1020 endif
1021 if [ [ [ [ [ [ [ 0 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
1022 echo 29.err
1023 else
1024 echo 29.ok
1025 endif
1026 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 0 ]
1027 echo 30.err
1028 else
1029 echo 30.ok
1030 endif
1031 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 1 ]
1032 echo 31.ok
1033 else
1034 echo 31.err
1035 endif
1036 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ]
1037 echo 32.err
1038 else
1039 echo 32.ok
1040 endif
1041 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 1 ]
1042 echo 33.ok
1043 else
1044 echo 33.err
1045 endif
1046 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 0 ]
1047 echo 34.err
1048 else
1049 echo 34.ok
1050 endif
1051 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 1 ]
1052 echo 35.ok
1053 else
1054 echo 35.err
1055 endif
1056 set diet=yo curd=ho
1057 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
1058 echo 36.err
1059 else
1060 echo 36.ok
1061 endif
1062 set ndefined
1063 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
1064 echo 37.ok
1065 else
1066 echo 37.err
1067 endif
1068 # 2. Shitty grouping capabilities as of today
1069 unset diet curd ndefined
1070 if [ false || false || true ] && [ false || true ] && yes
1071 echo 40.ok
1072 else
1073 echo 40.err
1074 endif
1075 if [ [ [ 0 || 1 ] && [ 1 || 0 ] ] && 1 ] && [ yes ]
1076 echo 41.ok
1077 else
1078 echo 41.err
1079 endif
1080 if [ 1 || 0 || 0 || 0 ]
1081 echo 42.ok
1082 else
1083 echo 42.err
1084 endif
1085 if [ 1 || 0 || 0 || 0 || [ 1 ] ]
1086 echo 43.ok
1087 else
1088 echo 43.err
1089 endif
1090 if [ 1 || 0 || 0 || 0 || [ 1 ] || 1 ] && no
1091 echo 44.err
1092 else
1093 echo 44.ok
1094 endif
1095 if [ 1 || 0 || 0 || 0 || 1 || [ 1 ] ] && no || [ yes ]
1096 echo 45.ok
1097 else
1098 echo 45.err
1099 endif
1100 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && 1 ] ] && [ 1 ] ]
1101 echo 46.ok
1102 else
1103 echo 46.err
1104 endif
1105 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && [ 1 ] ] ] && 0 ]
1106 echo 47.err
1107 else
1108 echo 47.ok
1109 endif
1110 if [ [ [ [ [ [ [ 1 ] ] && 1 ] && 0 ] && [ 1 ] ] ] && 1 ]
1111 echo 48.err
1112 else
1113 echo 48.ok
1114 endif
1115 if [ [ [ [ [ [ 0 ] && 1 ] && 1 ] && 1 ] ] && 1 ]
1116 echo 49.err
1117 else
1118 echo 49.ok
1119 endif
1120 if 1 || 0 || 0 || 0 && 0
1121 echo 50.err
1122 else
1123 echo 50.ok
1124 endif
1125 if 1 || 0 || 0 || 0 && 1
1126 echo 51.ok
1127 else
1128 echo 51.err
1129 endif
1130 if 0 || 0 || 0 || 1 && 0
1131 echo 52.err
1132 else
1133 echo 52.ok
1134 endif
1135 if 0 || 0 || 0 || 1 && 1
1136 echo 53.ok
1137 else
1138 echo 53.err
1139 endif
1140 if 0 || 0 || 0 || 1 && 0 || 1 && 0
1141 echo 54.err
1142 else
1143 echo 54.ok
1144 endif
1145 if 0 || 0 || 0 || 1 && 0 || 1 && 1
1146 echo 55.ok
1147 else
1148 echo 55.err
1149 endif
1150 set diet=yo curd=ho
1151 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
1152 echo 56.err
1153 else
1154 echo 56.ok
1155 endif
1156 if $diet == 'yo' && $curd == 'ho' && $ndefined
1157 echo 57.err
1158 else
1159 echo 57.ok
1160 endif
1161 set ndefined
1162 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
1163 echo 57.ok
1164 else
1165 echo 57.err
1166 endif
1167 if $diet == 'yo' && $curd == 'ho' && $ndefined
1168 echo 58.ok
1169 else
1170 echo 58.err
1171 endif
1172 if [ [ [ [ [ [ $diet == 'yo' && $curd == 'ho' && $ndefined ] ] ] ] ] ]
1173 echo 59.ok
1174 else
1175 echo 59.err
1176 endif
1177 # Some more en-braced variables
1178 set diet=yo curd=ho
1179 if ${diet} == ${curd}
1180 echo 70.err
1181 else
1182 echo 70.ok
1183 endif
1184 if ${diet} != ${curd}
1185 echo 71.ok
1186 else
1187 echo 71.err
1188 endif
1189 if $diet == ${curd}
1190 echo 72.err
1191 else
1192 echo 72.ok
1193 endif
1194 if ${diet} == $curd
1195 echo 73.err
1196 else
1197 echo 73.ok
1198 endif
1199 # Unary !
1200 if ! 0 && ! ! 1 && ! ! ! ! 2 && 3
1201 echo 80.ok
1202 else
1203 echo 80.err
1204 endif
1205 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ ! 2 ] ] ] && 3
1206 echo 81.ok
1207 else
1208 echo 81.err
1209 endif
1210 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1211 echo 82.ok
1212 else
1213 echo 82.err
1214 endif
1215 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
1216 echo 83.err
1217 else
1218 echo 83.ok
1219 endif
1220 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
1221 echo 84.err
1222 else
1223 echo 84.ok
1224 endif
1225 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1226 echo 85.err
1227 else
1228 echo 85.ok
1229 endif
1230 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1231 echo 86.err
1232 else
1233 echo 86.ok
1234 endif
1235 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] || 3
1236 echo 87.ok
1237 else
1238 echo 87.err
1239 endif
1240 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! ! [ 2 ] ] ] ] ]
1241 echo 88.ok
1242 else
1243 echo 88.err
1244 endif
1245 # Unary !, odd
1246 if ! 0 && ! ! 1 && ! ! ! 0 && 3
1247 echo 90.ok
1248 else
1249 echo 90.err
1250 endif
1251 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ 0 ] ] ] && 3
1252 echo 91.ok
1253 else
1254 echo 91.err
1255 endif
1256 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ [ 0 ] ] ] ] ] && 3
1257 echo 92.ok
1258 else
1259 echo 92.err
1260 endif
1261 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! ! [ ! [ ! 0 ] ] ] ] && ! 3
1262 echo 93.err
1263 else
1264 echo 93.ok
1265 endif
1266 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ ! [ ! [ ! [ ! 0 ] ] ] ] && 3
1267 echo 94.ok
1268 else
1269 echo 94.err
1270 endif
1271 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! ! [ ! [ ! [ ! [ 0 ] ] ] ] ] && 3
1272 echo 95.err
1273 else
1274 echo 95.ok
1275 endif
1276 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! ! 0 ] ] ] ] && 3
1277 echo 96.err
1278 else
1279 echo 96.ok
1280 endif
1281 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ ! 0 ] ] ] ] ] || 3
1282 echo 97.ok
1283 else
1284 echo 97.err
1285 endif
1286 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! [ 0 ] ] ] ] ]
1287 echo 98.ok
1288 else
1289 echo 98.err
1290 endif
1291 __EOT
1293 check behave:if-normal 0 "${MBOX}" '1688759742 719'
1295 if have_feat regex; then
1296 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
1297 set dietcurd=yoho
1298 if $dietcurd =~ '^yo.*'
1299 echo 1.ok
1300 else
1301 echo 1.err
1302 endif
1303 if $dietcurd =~ '^Yo.*'
1304 echo 1-1.err
1305 else
1306 echo 1-1.ok
1307 endif
1308 if $dietcurd @=~ '^Yo.*'
1309 echo 1-2.ok
1310 else
1311 echo 1-2.err
1312 endif
1313 if $dietcurd =~ '^yOho.+'
1314 echo 2.err
1315 else
1316 echo 2.ok
1317 endif
1318 if $dietcurd @!~ '.*Ho$'
1319 echo 3.err
1320 else
1321 echo 3.ok
1322 endif
1323 if $dietcurd !~ '.+yohO$'
1324 echo 4.ok
1325 else
1326 echo 4.err
1327 endif
1328 if [ $dietcurd @i!~ '.+yoho$' ]
1329 echo 5.ok
1330 else
1331 echo 5.err
1332 endif
1333 if ! [ $dietcurd @i=~ '.+yoho$' ]
1334 echo 6.ok
1335 else
1336 echo 6.err
1337 endif
1338 if ! ! [ $dietcurd @i!~ '.+yoho$' ]
1339 echo 7.ok
1340 else
1341 echo 7.err
1342 endif
1343 if ! [ ! [ $dietcurd @i!~ '.+yoho$' ] ]
1344 echo 8.ok
1345 else
1346 echo 8.err
1347 endif
1348 if [ ! [ ! [ $dietcurd @i!~ '.+yoho$' ] ] ]
1349 echo 9.ok
1350 else
1351 echo 9.err
1352 endif
1353 if ! [ ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
1354 echo 10.err
1355 else
1356 echo 10.ok
1357 endif
1358 if ! ! ! $dietcurd !~ '.+yoho$'
1359 echo 11.err
1360 else
1361 echo 11.ok
1362 endif
1363 if ! ! ! $dietcurd =~ '.+yoho$'
1364 echo 12.ok
1365 else
1366 echo 12.err
1367 endif
1368 if ! [ ! ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
1369 echo 13.ok
1370 else
1371 echo 13.err
1372 endif
1373 set diet=abc curd='^abc$'
1374 if $diet =~ $curd
1375 echo 14.ok
1376 else
1377 echo 14.err
1378 endif
1379 set diet=abc curd='^abcd$'
1380 if $diet !~ $curd
1381 echo 15.ok
1382 else
1383 echo 15.err
1384 endif
1385 __EOT
1387 check behave:if-regex 0 "${MBOX}" '1115671789 95'
1388 else
1389 printf 'behave:if-regex: unsupported, skipped\n'
1392 t_epilog
1395 t_behave_localopts() {
1396 t_prolog t_behave_localopts
1398 # Nestable conditions test
1399 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
1400 define t2 {
1401 echo in: t2
1402 set t2=t2
1403 echo $t2
1405 define t1 {
1406 echo in: t1
1407 set gv1=gv1
1408 localopts on
1409 set lv1=lv1 lv2=lv2
1410 set lv3=lv3
1411 call t2
1412 localopts off
1413 set gv2=gv2
1414 echo $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2
1416 define t0 {
1417 echo in: t0
1418 call t1
1419 echo $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2
1420 echo "$gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2"
1422 account trouble {
1423 echo in: trouble
1424 call t0
1426 call t0
1427 unset gv1 gv2
1428 account trouble
1429 echo active trouble: $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t3
1430 account null
1431 echo active null: $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t3
1434 define ll2 {
1435 localopts $1
1436 set x=2
1437 echo ll2=$x
1439 define ll1 {
1440 wysh set y=$1; shift; eval localopts $y; localopts $1; shift
1441 set x=1
1442 echo ll1.1=$x
1443 call ll2 $1
1444 echo ll1.2=$x
1446 define ll0 {
1447 wysh set y=$1; shift; eval localopts $y; localopts $1; shift
1448 set x=0
1449 echo ll0.1=$x
1450 call ll1 $y "$@"
1451 echo ll0.2=$x
1453 define llx {
1454 echo ----- $1: $2 -> $3 -> $4
1455 echo ll-1.1=$x
1456 eval localopts $1
1457 call ll0 "$@"
1458 echo ll-1.2=$x
1459 unset x
1461 define lly {
1462 call llx 'call off' on on on
1463 call llx 'call off' off on on
1464 call llx 'call off' on off on
1465 call llx 'call off' on off off
1466 localopts call-fixate on
1467 call llx 'call-fixate on' on on on
1468 call llx 'call-fixate on' off on on
1469 call llx 'call-fixate on' on off on
1470 call llx 'call-fixate on' on off off
1471 unset x;localopts call on
1472 call llx 'call on' on on on
1473 call llx 'call on' off on on
1474 call llx 'call on' on off on
1475 call llx 'call on' on off off
1477 call lly
1478 __EOT
1480 check behave:localopts 0 "${MBOX}" '4016155249 1246'
1482 t_epilog
1485 t_behave_local() {
1486 t_prolog t_behave_local
1488 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
1489 define du2 {
1490 echo du2-1 du=$du
1491 local set du=$1
1492 echo du2-2 du=$du
1493 local unset du
1494 echo du2-3 du=$du
1496 define du {
1497 local set du=dudu
1498 echo du-1 du=$du
1499 call du2 du2du2
1500 echo du-2 du=$du
1501 local set nodu
1502 echo du-3 du=$du
1504 define ich {
1505 echo ich-1 du=$du
1506 call du
1507 echo ich-2 du=$du
1509 define wir {
1510 localopts $1
1511 set du=wirwir
1512 echo wir-1 du=$du
1513 call ich
1514 echo wir-2 du=$du
1516 echo ------- global-1 du=$du
1517 call ich
1518 echo ------- global-2 du=$du
1519 set du=global
1520 call ich
1521 echo ------- global-3 du=$du
1522 call wir on
1523 echo ------- global-4 du=$du
1524 call wir off
1525 echo ------- global-5 du=$du
1526 __EOT
1528 check behave:local-1 0 "${MBOX}" '2411598140 641'
1530 t_epilog
1533 t_behave_macro_param_shift() {
1534 t_prolog t_behave_macro_param_shift
1536 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>>${ERR}
1537 define t2 {
1538 echo in: t2
1539 echo t2.0 has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1540 localopts on
1541 wysh set ignerr=$1
1542 shift
1543 localopts off
1544 echo t2.1 has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1545 if [ $# > 1 ] || [ $ignerr == '' ]
1546 shift 2
1547 else
1548 ignerr shift 2
1549 endif
1550 echo t2.2:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1551 shift 0
1552 echo t2.3:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1553 if [ $# > 0 ]
1554 shift
1555 endif
1556 echo t2.4:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1558 define t1 {
1559 set errexit
1560 echo in: t1
1561 call t2 1 you get four args
1562 echo t1.1: $?';' ignerr ($ignerr) should not exist
1563 call t2 1 you get 'three args'
1564 echo t1.2: $?';' ignerr ($ignerr) should not exist
1565 call t2 1 you 'get two args'
1566 echo t1.3: $?';' ignerr ($ignerr) should not exist
1567 call t2 1 'you get one arg'
1568 echo t1.4: $?';' ignerr ($ignerr) should not exist
1569 ignerr call t2 '' 'you get one arg'
1570 echo t1.5: $?';' ignerr ($ignerr) should not exist
1572 call t1
1573 __EOT
1575 check behave:macro_param_shift 0 "${MBOX}" '1402489146 1682'
1577 t_epilog
1580 t_behave_addrcodec() {
1581 t_prolog t_behave_addrcodec
1583 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
1584 vput addrcodec res e 1 <doog@def>
1585 echo $?/$^ERRNAME $res
1586 eval vput addrcodec res d $res
1587 echo $?/$^ERRNAME $res
1588 vput addrcodec res e 2 . <doog@def>
1589 echo $?/$^ERRNAME $res
1590 eval vput addrcodec res d $res
1591 echo $?/$^ERRNAME $res
1592 vput addrcodec res e 3 Sauer Dr. <doog@def>
1593 echo $?/$^ERRNAME $res
1594 eval vput addrcodec res d $res
1595 echo $?/$^ERRNAME $res
1596 vput addrcodec res e 3.50 Sauer (Ma) Dr. <doog@def>
1597 echo $?/$^ERRNAME $res
1598 eval vput addrcodec res d $res
1599 echo $?/$^ERRNAME $res
1600 vput addrcodec res e 3.51 Sauer (Ma) "Dr." <doog@def>
1601 echo $?/$^ERRNAME $res
1602 eval vput addrcodec res d $res
1603 echo $?/$^ERRNAME $res
1605 vput addrcodec res +e 4 Sauer (Ma) Dr. <doog@def>
1606 echo $?/$^ERRNAME $res
1607 eval vput addrcodec res d $res
1608 echo $?/$^ERRNAME $res
1609 vput addrcodec res +e 5 Sauer (Ma) Braten Dr. <doog@def>
1610 echo $?/$^ERRNAME $res
1611 eval vput addrcodec res d $res
1612 echo $?/$^ERRNAME $res
1613 vput addrcodec res +e 6 Sauer (Ma) Braten Dr. (Heu) <doog@def>
1614 echo $?/$^ERRNAME $res
1615 eval vput addrcodec res d $res
1616 echo $?/$^ERRNAME $res
1617 vput addrcodec res +e 7 Sauer (Ma) Braten Dr. (Heu) <doog@def> (bu)
1618 echo $?/$^ERRNAME $res
1619 eval vput addrcodec res d $res
1620 echo $?/$^ERRNAME $res
1621 vput addrcodec res +e 8 \
1622 Dr. Sauer (Ma) Braten Dr. (Heu) <doog@def> (bu) Boom. Boom
1623 echo $?/$^ERRNAME $res
1624 eval vput addrcodec res d $res
1625 echo $?/$^ERRNAME $res
1626 vput addrcodec res +e 9 Dr.Sauer(Ma)Braten Dr. (Heu) <doog@def>
1627 echo $?/$^ERRNAME $res
1628 eval vput addrcodec res d $res
1629 echo $?/$^ERRNAME $res
1630 vput addrcodec res +e 10 (Ma)Braten Dr. (Heu) <doog@def>
1631 echo $?/$^ERRNAME $res
1632 eval vput addrcodec res d $res
1633 echo $?/$^ERRNAME $res
1634 vput addrcodec res +e 11 (Ma)Braten Dr"." (Heu) <doog@def>
1635 echo $?/$^ERRNAME $res
1636 eval vput addrcodec res d $res
1637 echo $?/$^ERRNAME $res
1638 vput addrcodec res +e 12 Dr. Sauer (Ma) Braten Dr. (u) <doog@def>
1639 echo $?/$^ERRNAME $res
1640 eval vput addrcodec res d $res
1641 echo $?/$^ERRNAME $res
1642 vput addrcodec res +e 13(Ma)Braten Dr. (Heu) <doog@def>
1643 echo $?/$^ERRNAME $res
1644 eval vput addrcodec res d $res
1645 echo $?/$^ERRNAME $res
1646 vput addrcodec res +e 14 Hey, Du <doog@def> Wie() findet Dr. das? ()
1647 echo $?/$^ERRNAME $res
1648 eval vput addrcodec res d $res
1649 echo $?/$^ERRNAME $res
1650 vput addrcodec res +e 15 \
1651 Hey, Du <doog@def> Wie() findet "" Dr. "" das? ()
1652 echo $?/$^ERRNAME $res
1653 eval vput addrcodec res d $res
1654 echo $?/$^ERRNAME $res
1655 vput addrcodec res +e 16 \
1656 "Hey," "Du" <doog@def> "Wie()" findet "" Dr. "" das? ()
1657 echo $?/$^ERRNAME $res
1658 eval vput addrcodec res d $res
1659 echo $?/$^ERRNAME $res
1660 vput addrcodec res +e 17 \
1661 "Hey" Du <doog@def> "Wie() findet " " Dr. """ das? ()
1662 echo $?/$^ERRNAME $res
1663 eval vput addrcodec res d $res
1664 echo $?/$^ERRNAME $res
1665 vput addrcodec res +e 18 \
1666 <doog@def> "Hey" Du "Wie() findet " " Dr. """ das? ()
1667 echo $?/$^ERRNAME $res
1668 eval vput addrcodec res d $res
1669 echo $?/$^ERRNAME $res
1670 vput addrcodec res +e 19 Hey\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1671 echo $?/$^ERRNAME $res
1672 eval vput addrcodec res d $res
1673 echo $?/$^ERRNAME $res
1675 vput addrcodec res ++e 20 Hey\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1676 echo $?/$^ERRNAME $res
1677 vput addrcodec res ++e 21 Hey\,\"" <doog@def> "Wie()" findet \" Dr. \" das?
1678 echo $?/$^ERRNAME $res
1679 eval vput addrcodec res d $res
1680 echo $?/$^ERRNAME $res
1682 vput addrcodec res +++e 22 Hey\\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1683 echo $?/$^ERRNAME $res
1684 eval vput addrcodec res d $res
1685 echo $?/$^ERRNAME $res
1687 vput addrcodec res s \
1688 "23 Hey\\,\\\" \"Wie" () "\" findet \\\" Dr. \\\" das?" <doog@def>
1689 echo $?/$^ERRNAME $res
1691 # Fix for [f3852f88]
1692 vput addrcodec res ++e <from2@exam.ple> 100 (comment) "Quot(e)d"
1693 echo $?/$^ERRNAME $res
1694 eval vput addrcodec res d $res
1695 echo $?/$^ERRNAME $res
1696 vput addrcodec res e <from2@exam.ple> 100 (comment) "Quot(e)d"
1697 echo $?/$^ERRNAME $res
1698 eval vput addrcodec res d $res
1699 echo $?/$^ERRNAME $res
1700 __EOT
1702 check behave:addrcodec-1 0 "${MBOX}" '1047317989 2612'
1704 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
1705 mlist isa1@list
1706 mlsubscribe isa2@list
1708 vput addrcodec res skin Hey\\,\" <isa0@list> "Wie()" find \" Dr. \" das?
1709 echo $?/$^ERRNAME $res
1710 vput addrcodec res skinlist Hey\\,\" <isa0@list> "Wie()" find \" Dr. \" das?
1711 echo $?/$^ERRNAME $res
1712 vput addrcodec res skin Hey\\,\" <isa1@list> "Wie()" find \" Dr. \" das?
1713 echo $?/$^ERRNAME $res
1714 vput addrcodec res skinlist Hey\\,\" <isa1@list> "Wie()" find \" Dr. \" das?
1715 echo $?/$^ERRNAME $res
1716 vput addrcodec res skin Hey\\,\" <isa2@list> "Wie()" find \" Dr. \" das?
1717 echo $?/$^ERRNAME $res
1718 vput addrcodec res skinlist Hey\\,\" <isa2@list> "Wie()" find \" Dr. \" das?
1719 echo $?/$^ERRNAME $res
1720 __EOT
1722 check behave:addrcodec-2 0 "${MBOX}" '1391779299 104'
1724 if have_feat idna; then
1725 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} ${ADDARG_UNI} > "${MBOX}" 2>&1
1726 vput addrcodec res e (heu) <du@blödiän> "stroh" du
1727 echo $?/$^ERRNAME $res
1728 eval vput addrcodec res d $res
1729 echo $?/$^ERRNAME $res
1730 vput addrcodec res e <du@blödiän> du
1731 echo $?/$^ERRNAME $res
1732 eval vput addrcodec res d $res
1733 echo $?/$^ERRNAME $res
1734 vput addrcodec res e du <du@blödiän>
1735 echo $?/$^ERRNAME $res
1736 eval vput addrcodec res d $res
1737 echo $?/$^ERRNAME $res
1738 vput addrcodec res e <du@blödiän>
1739 echo $?/$^ERRNAME $res
1740 eval vput addrcodec res d $res
1741 echo $?/$^ERRNAME $res
1742 vput addrcodec res e du@blödiän
1743 echo $?/$^ERRNAME $res
1744 eval vput addrcodec res d $res
1745 echo $?/$^ERRNAME $res
1746 __EOT
1748 check behave:addrcodec-idna 0 "${MBOX}" '498775983 326'
1749 else
1750 printf 'behave:addrcodec-idna: unsupported, skipped\n'
1753 t_epilog
1756 t_behave_vexpr() {
1757 t_prolog t_behave_vexpr
1759 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>>${ERR}
1760 echo ' #0.0'
1761 vput vexpr res = 9223372036854775807
1762 echo $?/$^ERRNAME $res
1763 vput vexpr res = 9223372036854775808
1764 echo $?/$^ERRNAME $res
1765 vput vexpr res = u9223372036854775808
1766 echo $?/$^ERRNAME $res
1767 vput vexpr res @= 9223372036854775808
1768 echo $?/$^ERRNAME $res
1769 vput vexpr res = -9223372036854775808
1770 echo $?/$^ERRNAME $res
1771 vput vexpr res = -9223372036854775809
1772 echo $?/$^ERRNAME $res
1773 vput vexpr res @= -9223372036854775809
1774 echo $?/$^ERRNAME $res
1775 vput vexpr res = U9223372036854775809
1776 echo $?/$^ERRNAME $res
1777 echo ' #0.1'
1778 vput vexpr res = \
1779 0b0111111111111111111111111111111111111111111111111111111111111111
1780 echo $?/$^ERRNAME $res
1781 vput vexpr res = \
1782 S0b1000000000000000000000000000000000000000000000000000000000000000
1783 echo $?/$^ERRNAME $res
1784 vput vexpr res @= \
1785 S0b1000000000000000000000000000000000000000000000000000000000000000
1786 echo $?/$^ERRNAME $res
1787 vput vexpr res = \
1788 U0b1000000000000000000000000000000000000000000000000000000000000000
1789 echo $?/$^ERRNAME $res
1790 vput vexpr res = \
1791 0b1000000000000000000000000000000000000000000000000000000000000000
1792 echo $?/$^ERRNAME $res
1793 vput vexpr res @= \
1794 0b1000000000000000000000000000000000000000000000000000000000000000
1795 echo $?/$^ERRNAME $res
1796 vput vexpr res = \
1797 -0b1000000000000000000000000000000000000000000000000000000000000000
1798 echo $?/$^ERRNAME $res
1799 vput vexpr res = \
1800 S0b1000000000000000000000000000000000000000000000000000000000000001
1801 echo $?/$^ERRNAME $res
1802 vput vexpr res @= \
1803 S0b1000000000000000000000000000000000000000000000000000000000000001
1804 echo $?/$^ERRNAME $res
1805 vput vexpr res @= \
1806 -0b1000000000000000000000000000000000000000000000000000000000000001
1807 echo $?/$^ERRNAME $res
1808 vput vexpr res = \
1809 U0b1000000000000000000000000000000000000000000000000000000000000001
1810 echo $?/$^ERRNAME $res
1811 echo ' #0.2'
1812 vput vexpr res = 0777777777777777777777
1813 echo $?/$^ERRNAME $res
1814 vput vexpr res = S01000000000000000000000
1815 echo $?/$^ERRNAME $res
1816 vput vexpr res @= S01000000000000000000000
1817 echo $?/$^ERRNAME $res
1818 vput vexpr res = U01000000000000000000000
1819 echo $?/$^ERRNAME $res
1820 vput vexpr res = 01000000000000000000000
1821 echo $?/$^ERRNAME $res
1822 vput vexpr res @= 01000000000000000000000
1823 echo $?/$^ERRNAME $res
1824 vput vexpr res = -01000000000000000000000
1825 echo $?/$^ERRNAME $res
1826 vput vexpr res = S01000000000000000000001
1827 echo $?/$^ERRNAME $res
1828 vput vexpr res @= S01000000000000000000001
1829 echo $?/$^ERRNAME $res
1830 vput vexpr res @= -01000000000000000000001
1831 echo $?/$^ERRNAME $res
1832 vput vexpr res = U01000000000000000000001
1833 echo $?/$^ERRNAME $res
1834 echo ' #0.3'
1835 vput vexpr res = 0x7FFFFFFFFFFFFFFF
1836 echo $?/$^ERRNAME $res
1837 vput vexpr res = S0x8000000000000000
1838 echo $?/$^ERRNAME $res
1839 vput vexpr res @= S0x8000000000000000
1840 echo $?/$^ERRNAME $res
1841 vput vexpr res = U0x8000000000000000
1842 echo $?/$^ERRNAME $res
1843 vput vexpr res = 0x8000000000000000
1844 echo $?/$^ERRNAME $res
1845 vput vexpr res @= 0x8000000000000000
1846 echo $?/$^ERRNAME $res
1847 vput vexpr res = -0x8000000000000000
1848 echo $?/$^ERRNAME $res
1849 vput vexpr res = S0x8000000000000001
1850 echo $?/$^ERRNAME $res
1851 vput vexpr res @= S0x8000000000000001
1852 echo $?/$^ERRNAME $res
1853 vput vexpr res @= -0x8000000000000001
1854 echo $?/$^ERRNAME $res
1855 vput vexpr res = u0x8000000000000001
1856 echo $?/$^ERRNAME $res
1857 echo ' #1'
1858 vput vexpr res ~ 0
1859 echo $?/$^ERRNAME $res
1860 vput vexpr res ~ 1
1861 echo $?/$^ERRNAME $res
1862 vput vexpr res ~ -1
1863 echo $?/$^ERRNAME $res
1864 echo ' #2'
1865 vput vexpr res + 0 0
1866 echo $?/$^ERRNAME $res
1867 vput vexpr res + 0 1
1868 echo $?/$^ERRNAME $res
1869 vput vexpr res + 1 1
1870 echo $?/$^ERRNAME $res
1871 echo ' #3'
1872 vput vexpr res + 9223372036854775807 0
1873 echo $?/$^ERRNAME $res
1874 vput vexpr res + 9223372036854775807 1
1875 echo $?/$^ERRNAME $res
1876 vput vexpr res @+ 9223372036854775807 1
1877 echo $?/$^ERRNAME $res
1878 vput vexpr res + 0 9223372036854775807
1879 echo $?/$^ERRNAME $res
1880 vput vexpr res + 1 9223372036854775807
1881 echo $?/$^ERRNAME $res
1882 vput vexpr res @+ 1 9223372036854775807
1883 echo $?/$^ERRNAME $res
1884 echo ' #4'
1885 vput vexpr res + -9223372036854775808 0
1886 echo $?/$^ERRNAME $res
1887 vput vexpr res + -9223372036854775808 -1
1888 echo $?/$^ERRNAME $res
1889 vput vexpr res @+ -9223372036854775808 -1
1890 echo $?/$^ERRNAME $res
1891 vput vexpr res + 0 -9223372036854775808
1892 echo $?/$^ERRNAME $res
1893 vput vexpr res + -1 -9223372036854775808
1894 echo $?/$^ERRNAME $res
1895 vput vexpr res @+ -1 -9223372036854775808
1896 echo $?/$^ERRNAME $res
1897 echo ' #5'
1898 vput vexpr res - 0 0
1899 echo $?/$^ERRNAME $res
1900 vput vexpr res - 0 1
1901 echo $?/$^ERRNAME $res
1902 vput vexpr res - 1 1
1903 echo $?/$^ERRNAME $res
1904 echo ' #6'
1905 vput vexpr res - 9223372036854775807 0
1906 echo $?/$^ERRNAME $res
1907 vput vexpr res - 9223372036854775807 -1
1908 echo $?/$^ERRNAME $res
1909 vput vexpr res @- 9223372036854775807 -1
1910 echo $?/$^ERRNAME $res
1911 vput vexpr res - 0 9223372036854775807
1912 echo $?/$^ERRNAME $res
1913 vput vexpr res - -1 9223372036854775807
1914 echo $?/$^ERRNAME $res
1915 vput vexpr res - -2 9223372036854775807
1916 echo $?/$^ERRNAME $res
1917 vput vexpr res @- -2 9223372036854775807
1918 echo $?/$^ERRNAME $res
1919 echo ' #7'
1920 vput vexpr res - -9223372036854775808 +0
1921 echo $?/$^ERRNAME $res
1922 vput vexpr res - -9223372036854775808 +1
1923 echo $?/$^ERRNAME $res
1924 vput vexpr res @- -9223372036854775808 +1
1925 echo $?/$^ERRNAME $res
1926 vput vexpr res - 0 -9223372036854775808
1927 echo $?/$^ERRNAME $res
1928 vput vexpr res - +1 -9223372036854775808
1929 echo $?/$^ERRNAME $res
1930 vput vexpr res @- +1 -9223372036854775808
1931 echo $?/$^ERRNAME $res
1932 echo ' #8'
1933 vput vexpr res + -13 -2
1934 echo $?/$^ERRNAME $res
1935 vput vexpr res - 0 0
1936 echo $?/$^ERRNAME $res
1937 vput vexpr res - 0 1
1938 echo $?/$^ERRNAME $res
1939 vput vexpr res - 1 1
1940 echo $?/$^ERRNAME $res
1941 vput vexpr res - -13 -2
1942 echo $?/$^ERRNAME $res
1943 echo ' #9'
1944 vput vexpr res * 0 0
1945 echo $?/$^ERRNAME $res
1946 vput vexpr res * 0 1
1947 echo $?/$^ERRNAME $res
1948 vput vexpr res * 1 1
1949 echo $?/$^ERRNAME $res
1950 vput vexpr res * -13 -2
1951 echo $?/$^ERRNAME $res
1952 echo ' #10'
1953 vput vexpr res / 0 0
1954 echo $?/$^ERRNAME $res
1955 vput vexpr res / 0 1
1956 echo $?/$^ERRNAME $res
1957 vput vexpr res / 1 1
1958 echo $?/$^ERRNAME $res
1959 vput vexpr res / -13 -2
1960 echo $?/$^ERRNAME $res
1961 echo ' #11'
1962 vput vexpr res % 0 0
1963 echo $?/$^ERRNAME $res
1964 vput vexpr res % 0 1
1965 echo $?/$^ERRNAME $res
1966 vput vexpr res % 1 1
1967 echo $?/$^ERRNAME $res
1968 vput vexpr res % -13 -2
1969 echo $?/$^ERRNAME $res
1970 __EOT
1972 check behave:vexpr-numeric 0 "${MBOX}" '960821755 1962'
1974 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
1975 vput vexpr res find 'bananarama' 'nana'
1976 echo $?/$^ERRNAME :$res:
1977 vput vexpr res find 'bananarama' 'bana'
1978 echo $?/$^ERRNAME :$res:
1979 vput vexpr res find 'bananarama' 'Bana'
1980 echo $?/$^ERRNAME :$res:
1981 vput vexpr res find 'bananarama' 'rama'
1982 echo $?/$^ERRNAME :$res:
1983 echo ' #1'
1984 vput vexpr res ifind 'bananarama' 'nana'
1985 echo $?/$^ERRNAME :$res:
1986 vput vexpr res ifind 'bananarama' 'bana'
1987 echo $?/$^ERRNAME :$res:
1988 vput vexpr res ifind 'bananarama' 'Bana'
1989 echo $?/$^ERRNAME :$res:
1990 vput vexpr res ifind 'bananarama' 'rama'
1991 echo $?/$^ERRNAME :$res:
1992 echo ' #2'
1993 vput vexpr res substring 'bananarama' 1
1994 echo $?/$^ERRNAME :$res:
1995 vput vexpr res substring 'bananarama' 3
1996 echo $?/$^ERRNAME :$res:
1997 vput vexpr res substring 'bananarama' 5
1998 echo $?/$^ERRNAME :$res:
1999 vput vexpr res substring 'bananarama' 7
2000 echo $?/$^ERRNAME :$res:
2001 vput vexpr res substring 'bananarama' 9
2002 echo $?/$^ERRNAME :$res:
2003 vput vexpr res substring 'bananarama' 10
2004 echo $?/$^ERRNAME :$res:
2005 vput vexpr res substring 'bananarama' 1 3
2006 echo $?/$^ERRNAME :$res:
2007 vput vexpr res substring 'bananarama' 3 3
2008 echo $?/$^ERRNAME :$res:
2009 vput vexpr res substring 'bananarama' 5 3
2010 echo $?/$^ERRNAME :$res:
2011 vput vexpr res substring 'bananarama' 7 3
2012 echo $?/$^ERRNAME :$res:
2013 vput vexpr res substring 'bananarama' 9 3
2014 echo $?/$^ERRNAME :$res:
2015 vput vexpr res substring 'bananarama' 10 3
2016 echo $?/$^ERRNAME :$res:
2017 echo ' #3'
2018 vput vexpr res substring 'bananarama' -1
2019 echo $?/$^ERRNAME :$res:
2020 vput vexpr res substring 'bananarama' -3
2021 echo $?/$^ERRNAME :$res:
2022 vput vexpr res substring 'bananarama' -5
2023 echo $?/$^ERRNAME :$res:
2024 vput vexpr res substring 'bananarama' -7
2025 echo $?/$^ERRNAME :$res:
2026 vput vexpr res substring 'bananarama' -9
2027 echo $?/$^ERRNAME :$res:
2028 vput vexpr res substring 'bananarama' -10
2029 echo $?/$^ERRNAME :$res:
2030 vput vexpr res substring 'bananarama' 1 -3
2031 echo $?/$^ERRNAME :$res:
2032 vput vexpr res substring 'bananarama' 3 -3
2033 echo $?/$^ERRNAME :$res:
2034 vput vexpr res substring 'bananarama' 5 -3
2035 echo $?/$^ERRNAME :$res:
2036 vput vexpr res substring 'bananarama' 7 -3
2037 echo $?/$^ERRNAME :$res:
2038 vput vexpr res substring 'bananarama' 9 -3
2039 echo $?/$^ERRNAME :$res:
2040 vput vexpr res substring 'bananarama' 10 -3
2041 echo $?/$^ERRNAME :$res:
2042 echo ' #4'
2043 vput vexpr res trim 'Cocoon Cocoon'
2044 echo $?/$^ERRNAME :$res:
2045 vput vexpr res trim ' Cocoon Cocoon '
2046 echo $?/$^ERRNAME :$res:
2047 vput vexpr res trim-front 'Cocoon Cocoon'
2048 echo $?/$^ERRNAME :$res:
2049 vput vexpr res trim-front ' Cocoon Cocoon '
2050 echo $?/$^ERRNAME :$res:
2051 vput vexpr res trim-end 'Cocoon Cocoon'
2052 echo $?/$^ERRNAME :$res:
2053 vput vexpr res trim-end ' Cocoon Cocoon '
2054 echo $?/$^ERRNAME :$res:
2055 __EOT
2057 check behave:vexpr-string 0 "${MBOX}" '3182004322 601'
2059 if have_feat regex; then
2060 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
2061 vput vexpr res regex 'bananarama' 'nana'
2062 echo $?/$^ERRNAME :$res:
2063 vput vexpr res regex 'bananarama' 'bana'
2064 echo $?/$^ERRNAME :$res:
2065 vput vexpr res regex 'bananarama' 'Bana'
2066 echo $?/$^ERRNAME :$res:
2067 vput vexpr res regex 'bananarama' 'rama'
2068 echo $?/$^ERRNAME :$res:
2069 echo ' #1'
2070 vput vexpr res iregex 'bananarama' 'nana'
2071 echo $?/$^ERRNAME :$res:
2072 vput vexpr res iregex 'bananarama' 'bana'
2073 echo $?/$^ERRNAME :$res:
2074 vput vexpr res iregex 'bananarama' 'Bana'
2075 echo $?/$^ERRNAME :$res:
2076 vput vexpr res iregex 'bananarama' 'rama'
2077 echo $?/$^ERRNAME :$res:
2078 echo ' #2'
2079 vput vexpr res regex 'bananarama' '(.*)nana(.*)' '\${1}a\${0}u{\$2}'
2080 echo $?/$^ERRNAME :$res:
2081 vput vexpr res regex 'bananarama' '(.*)bana(.*)' '\${1}a\${0}u\$2'
2082 echo $?/$^ERRNAME :$res:
2083 vput vexpr res regex 'bananarama' 'Bana(.+)' '\$1\$0'
2084 echo $?/$^ERRNAME :$res:
2085 vput vexpr res regex 'bananarama' '(.+)rama' '\$1\$0'
2086 echo $?/$^ERRNAME :$res:
2087 echo ' #3'
2088 vput vexpr res iregex 'bananarama' '(.*)nana(.*)' '\${1}a\${0}u{\$2}'
2089 echo $?/$^ERRNAME :$res:
2090 vput vexpr res iregex 'bananarama' '(.*)bana(.*)' '\${1}a\${0}u\$2'
2091 echo $?/$^ERRNAME :$res:
2092 vput vexpr res iregex 'bananarama' 'Bana(.+)' '\$1\$0'
2093 echo $?/$^ERRNAME :$res:
2094 vput vexpr res iregex 'bananarama' '(.+)rama' '\$1\$0'
2095 echo $?/$^ERRNAME :$res:
2096 echo ' #4'
2097 __EOT
2099 check behave:vexpr-regex 0 "${MBOX}" '3270360157 311'
2100 else
2101 printf 'behave:vexpr-regex: unsupported, skipped\n'
2104 t_epilog
2107 t_behave_call_ret() {
2108 t_prolog t_behave_call_ret
2110 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Snomemdebug > "${MBOX}" 2>&1
2111 define w1 {
2112 echon ">$1 "
2113 vput vexpr i + $1 1
2114 if [ $i -le 42 ]
2115 vput vexpr j '&' $i 7
2116 if [ $j -eq 7 ]
2117 echo .
2119 call w1 $i
2120 wysh set i=$? k=$!
2121 vput vexpr j '&' $i 7
2122 echon "<$1/$i/$k "
2123 if [ $j -eq 7 ]
2124 echo .
2126 else
2127 echo ! The end for $1
2129 return $1
2131 # Transport $?/$! up the call chain
2132 define w2 {
2133 echon ">$1 "
2134 vput vexpr i + $1 1
2135 if [ $1 -lt 42 ]
2136 call w2 $i
2137 wysh set i=$? j=$! k=$^ERRNAME
2138 echon "<$1/$i/$k "
2139 return $i $j
2140 else
2141 echo ! The end for $1
2142 return $i $^ERR-BUSY
2144 echoerr au
2146 # Up and down it goes
2147 define w3 {
2148 echon ">$1/$2 "
2149 vput vexpr i + $1 1
2150 if [ $1 -lt 42 ]
2151 call w3 $i $2
2152 wysh set i=$? j=$!
2153 vput vexpr k - $1 $2
2154 if [ $k -eq 21 ]
2155 vput vexpr i + $1 1
2156 vput vexpr j + $2 1
2157 echo "# <$i/$j> .. "
2158 call w3 $i $j
2159 wysh set i=$? j=$!
2161 eval echon "<\$1=\$i/\$^ERRNAME-$j "
2162 return $i $j
2163 else
2164 echo ! The end for $1=$i/$2
2165 if [ "$2" != "" ]
2166 return $i $^ERR-DOM
2167 else
2168 return $i $^ERR-BUSY
2171 echoerr au
2174 call w1 0; echo ?=$? !=$!; echo -----;
2175 call w2 0; echo ?=$? !=$^ERRNAME; echo -----;
2176 call w3 0 1; echo ?=$? !=$^ERRNAME; echo -----;
2177 __EOT
2179 check behave:call_ret 0 "${MBOX}" '1572045517 5922'
2181 t_epilog
2184 t_behave_xcall() {
2185 t_prolog t_behave_xcall
2187 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Snomemdebug > "${MBOX}" 2>&1
2188 define work {
2189 echon "$1 "
2190 vput vexpr i + $1 1
2191 if [ $i -le 1111 ]
2192 vput vexpr j '&' $i 7
2193 if [ $j -eq 7 ]
2194 echo .
2196 \xcall work $i $2
2198 echo ! The end for $1/$2
2199 if [ "$2" != "" ]
2200 return $i $^ERR-BUSY
2203 define xwork {
2204 \xcall work 0 $2
2206 call work 0
2207 echo ?=$? !=$!
2208 call xwork
2209 echo ?=$? !=$!
2210 xcall xwork
2211 echo ?=$? !=$^ERRNAME
2213 call work 0 yes
2214 echo ?=$? !=$^ERRNAME
2215 call xwork 0 yes
2216 echo ?=$? !=$^ERRNAME
2217 __EOT
2219 check behave:xcall-1 0 "${MBOX}" '2401702082 23801'
2223 if have_feat uistrings; then
2224 ${cat} <<- '__EOT' > "${BODY}"
2225 define __w {
2226 echon "$1 "
2227 vput vexpr i + $1 1
2228 if [ $i -le 111 ]
2229 vput vexpr j '&' $i 7
2230 if [ $j -eq 7 ]
2231 echo .
2233 \xcall __w $i $2
2235 echo ! The end for $1
2236 if [ $2 -eq 0 ]
2237 nonexistingcommand
2238 echo would be err with errexit
2239 return
2241 echo calling exit
2242 exit
2244 define work {
2245 echo eins
2246 call __w 0 0
2247 echo zwei, ?=$? !=$!
2248 localopts yes; set errexit
2249 ignerr call __w 0 0
2250 echo drei, ?=$? !=$^ERRNAME
2251 call __w 0 $1
2252 echo vier, ?=$? !=$^ERRNAME, this is an error
2254 ignerr call work 0
2255 echo outer 1, ?=$? !=$^ERRNAME
2256 xxxign call work 0
2257 echo outer 2, ?=$? !=$^ERRNAME, could be error if xxxign non-empty
2258 call work 1
2259 echo outer 3, ?=$? !=$^ERRNAME
2260 echo this is definitely an error
2261 __EOT
2263 < "${BODY}" ${MAILX} ${ARGS} -X'commandalias xxxign ignerr' \
2264 -Snomemdebug > "${MBOX}" 2>&1
2265 check behave:xcall-2 0 "${MBOX}" '3900716531 4200'
2267 < "${BODY}" ${MAILX} ${ARGS} -X'commandalias xxxign " "' \
2268 -Snomemdebug > "${MBOX}" 2>&1
2269 check behave:xcall-3 1 "${MBOX}" '1006776201 2799'
2270 else
2271 echo 'behave:xcall-2: unsupported, skipped'
2272 echo 'behave:xcall-3: unsupported, skipped'
2275 t_epilog
2278 t_behave_vpospar() {
2279 t_prolog t_behave_vpospar
2281 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
2282 vpospar set hey, "'you ", world!
2283 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2284 vput vpospar x quote; echo x<$x>
2285 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2286 vput vpospar y quote;echo y<$y>
2287 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2288 eval vpospar set ${y};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2289 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2291 define infun2 {
2292 echo infun2:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2293 vput vpospar z quote;echo infun2:z<$z>
2296 define infun {
2297 echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2298 vput vpospar y quote;echo infun:y<$y>
2299 eval vpospar set ${x};echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2300 vpospar clear;echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2301 eval call infun2 $x
2302 echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2303 eval vpospar set ${y};echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2306 call infun This "in a" fun
2307 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2308 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2309 __EOT
2310 check behave:vpospar-1 0 "${MBOX}" '155175639 866'
2313 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
2314 set ifs=\'
2315 echo ifs<$ifs> ifs-ws<$ifs-ws>
2316 vpospar set hey, "'you ", world!
2317 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2318 vput vpospar x quote; echo x<$x>
2319 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2320 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2322 set ifs=,
2323 echo ifs<$ifs> ifs-ws<$ifs-ws>
2324 vpospar set hey, "'you ", world!
2325 unset ifs;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2326 set ifs=,
2327 vput vpospar x quote; echo x<$x>
2328 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2329 eval vpospar set ${x};\
2330 unset ifs;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2332 wysh set ifs=$',\t'
2333 echo ifs<$ifs> ifs-ws<$ifs-ws>
2334 vpospar set hey, "'you ", world!
2335 unset ifs; echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2336 wysh set ifs=$',\t'
2337 vput vpospar x quote; echo x<$x>
2338 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2339 eval vpospar set ${x};\
2340 unset ifs;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2341 __EOT
2342 check behave:vpospar-ifs 0 "${MBOX}" '2015927702 706'
2344 t_epilog
2347 t_behave_atxplode() {
2348 t_prolog t_behave_atxplode
2349 TRAP_EXIT_ADDONS="./.t*"
2351 ${cat} > ./.t.sh <<- '___'; ${cat} > ./.t.rc <<- '___'
2352 x() { echo $#; }
2353 xxx() {
2354 printf " (1/$#: <$1>)"
2355 shift
2356 if [ $# -gt 0 ]; then
2357 xxx "$@"
2358 else
2359 echo
2362 yyy() {
2363 eval "$@ ' ball"
2365 set --
2366 x "$@"
2367 x "$@"''
2368 x " $@"
2369 x "$@ "
2370 printf yyy;yyy 'xxx' "b\$'\t'u ' "
2371 printf xxx;xxx arg ,b u.
2372 printf xxx;xxx arg , .
2373 printf xxx;xxx arg ,ball.
2375 define x {
2376 echo $#
2378 define xxx {
2379 echon " (1/$#: <$1>)"
2380 shift
2381 if [ $# -gt 0 ]
2382 \xcall xxx "$@"
2383 endif
2384 echo
2386 define yyy {
2387 eval "$@ ' ball"
2389 vpospar set
2390 call x "$@"
2391 call x "$@"''
2392 call x " $@"
2393 call x "$@ "
2394 echon yyy;call yyy '\call xxx' "b\$'\t'u ' "
2395 echon xxx;call xxx arg ,b u.
2396 echon xxx;call xxx arg , .
2397 echon xxx;call xxx arg ,ball.
2400 ${MAILX} ${ARGS} -X'source ./.t.rc' -Xx > "${MBOX}" 2>&1
2401 check behave:atxplode-1 0 "${MBOX}" '41566293 164'
2403 #${SHELL} ./.t.sh > ./.tshout 2>&1
2404 #check behave:atxplode:disproof-1 0 ./.tshout '41566293 164'
2406 t_epilog
2409 t_behave_read() {
2410 t_prolog t_behave_read
2411 TRAP_EXIT_ADDONS="./.t*"
2413 ${cat} <<- '__EOT' > .tin
2414 hey1, "'you ", world!
2415 hey2, "'you ", bugs bunny!
2416 hey3, "'you ",
2417 hey4, "'you "
2418 __EOT
2420 ${cat} <<- '__EOT' |\
2421 ${MAILX} ${ARGS} -X'readctl create ./.tin' > "${MBOX}" 2>&1
2422 read a b c
2423 echo $?/$^ERRNAME / <$a><$b><$c>
2424 read a b c
2425 echo $?/$^ERRNAME / <$a><$b><$c>
2426 read a b c
2427 echo $?/$^ERRNAME / <$a><$b><$c>
2428 read a b c
2429 echo $?/$^ERRNAME / <$a><$b><$c>
2430 unset a b c;read a b c
2431 echo $?/$^ERRNAME / <$a><$b><$c>
2432 readctl remove ./.tin;echo readctl remove:$?/$^ERRNAME
2433 __EOT
2434 check behave:read-1 0 "${MBOX}" '1527910147 173'
2436 ${cat} <<- '__EOT' > .tin2
2437 hey2.0,:"'you ",:world!:mars.:
2438 hey2.1,:"'you ",:world!
2439 hey2.2,:"'you ",:bugs bunny!
2440 hey2.3,:"'you ",:
2441 hey2.4,:"'you ":
2443 __EOT
2445 ${cat} <<- '__EOT' |\
2446 6< .tin2 ${MAILX} ${ARGS} -X 'readctl create 6' > "${MBOX}" 2>&1
2447 set ifs=:
2448 read a b c
2449 echo $?/$^ERRNAME / <$a><$b><$c>
2450 read a b c
2451 echo $?/$^ERRNAME / <$a><$b><$c>
2452 read a b c
2453 echo $?/$^ERRNAME / <$a><$b><$c>
2454 read a b c
2455 echo $?/$^ERRNAME / <$a><$b><$c>
2456 read a b c
2457 echo $?/$^ERRNAME / <$a><$b><$c>
2458 read a b c
2459 echo $?/$^ERRNAME / <$a><$b><$c>
2460 unset a b c;read a b c
2461 echo $?/$^ERRNAME / <$a><$b><$c>
2462 read a b c
2463 echo $?/$^ERRNAME / <$a><$b><$c>
2464 readctl remove 6;echo readctl remove:$?/$^ERRNAME
2465 __EOT
2466 check behave:read-ifs 0 "${MBOX}" '890153490 298'
2468 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
2469 readctl create .tin
2470 readall d; echo $?/$^ERRNAME / <$d>
2471 wysh set d;readall d;echo $?/$^ERRNAME / <$d>
2472 readctl create .tin2
2473 readall d; echo $?/$^ERRNAME / <$d>
2474 wysh set d;readall d;echo $?/$^ERRNAME / <$d>
2475 readctl remove .tin;echo $?/$^ERRNAME;\
2476 readctl remove .tin2;echo $?/$^ERRNAME
2477 echo '### now with empty lines'
2478 ! printf 'one line\n\ntwo line\n\n' > ./.temptynl
2479 readctl create .temptynl;echo $?/$^ERRNAME
2480 readall d; echo "$?/$^ERRNAME / <$d>"
2481 readctl remove .temptynl;echo $?/$^ERRNAME
2482 __EOT
2483 check readall 0 "${MBOX}" '4113506527 405'
2485 t_epilog
2488 t_behave_mbox() {
2489 t_prolog t_behave_mbox
2490 TRAP_EXIT_ADDONS="./.t*"
2494 while [ ${i} -lt 113 ]; do
2495 printf 'm file://%s\n~s Subject %s\nHello %s!\n~.\n' \
2496 "${MBOX}" "${i}" "${i}"
2497 i=`add ${i} 1`
2498 done
2499 ) | ${MAILX} ${ARGS} > .tall 2>&1
2500 check behave:mbox-1 0 "${MBOX}" '1872102723 13784'
2501 check behave:mbox-1-outerr - ./.tall '4294967295 0' # empty file
2503 printf 'File "%s"\ncopy * "%s"\nFile "%s"\nfrom*' "${MBOX}" .tmbox1 .tmbox1 |
2504 ${MAILX} ${ARGS} -Sshowlast > .tall 2>&1
2505 check behave:mbox-2 0 .tall '3498373999 9103'
2507 printf 'File "%s"\ncopy * "file://%s"\nFile "file://%s"\nfrom*' \
2508 "${MBOX}" .tmbox2 .tmbox2 | ${MAILX} ${ARGS} -Sshowlast > .tall 2>&1
2509 check behave:mbox-3 0 .tall '381610797 9110'
2511 # copy only the odd (but the first), move the even
2513 printf 'File "file://%s"\ncopy ' .tmbox2
2515 while [ ${i} -lt 113 ]; do
2516 printf '%s ' "${i}"
2517 i=`add ${i} 2`
2518 done
2519 printf 'file://%s\nFile "file://%s"\nfrom*' .tmbox3 .tmbox3
2520 ) | ${MAILX} ${ARGS} -Sshowlast > .tall 2>&1
2521 check behave:mbox-4 0 .tmbox3 '4145104131 6890'
2522 check behave:mbox-5 - .tall '361127721 4573'
2523 # ...
2525 printf 'file "file://%s"\nmove ' .tmbox2
2527 while [ ${i} -lt 113 ]; do
2528 printf '%s ' "${i}"
2529 i=`add ${i} 2`
2530 done
2531 printf 'file://%s\nFile "file://%s"\nfrom*\nFile "file://%s"\nfrom*' \
2532 .tmbox3 .tmbox3 .tmbox2
2533 ) | ${MAILX} ${ARGS} -Sshowlast > .tall 2>>${ERR}
2534 check behave:mbox-6 0 .tmbox3 '3249991493 13784'
2535 if have_feat uistrings; then
2536 ${sed} 2d < .tall > .tallx
2537 else
2538 ${cp} .tall .tallx
2540 check behave:mbox-7 - .tallx '1584413080 13645'
2542 # Invalid MBOXes (after [f4db93b3])
2543 echo > .tinvmbox
2544 printf 'copy 1 ./.tinvmbox' | ${MAILX} ${ARGS} -Rf "${MBOX}" > .tall 2>&1
2545 check behave:mbox-8 0 .tinvmbox '896415941 122'
2546 check behave:mbox-9 - ./.tall '3146754194 33'
2548 echo ' ' > .tinvmbox
2549 printf 'copy 1 ./.tinvmbox' | ${MAILX} ${ARGS} -Rf "${MBOX}" > .tall 2>&1
2550 check behave:mbox-10 0 .tinvmbox '4011310616 124'
2551 check behave:mbox-11 - ./.tall '3146754194 33'
2553 { echo; echo; } > .tinvmbox # (not invalid)
2554 printf 'copy 1 ./.tinvmbox' | ${MAILX} ${ARGS} -Rf "${MBOX}" > .tall 2>&1
2555 check behave:mbox-12 0 .tinvmbox '287409579 123'
2556 check behave:mbox-13 - ./.tall '3146754194 33'
2558 # *mbox-rfc4155*, plus
2559 ${cat} <<-_EOT > ./.tinv1
2562 From MAILER-DAEMON-1 Wed Oct 2 01:50:07 1996
2563 Date: Wed, 02 Oct 1996 01:50:07 +0000
2565 Subject: Bad bad message 1
2567 From me to you, blinde Kuh!
2569 From MAILER-DAEMON-2 Wed Oct 2 01:50:07 1996
2570 Date: Wed, 02 Oct 1996 01:50:07 +0000
2572 Subject: Bad bad message 2
2574 From me to you, blindes Kalb!
2575 _EOT
2576 ${cp} ./.tinv1 ./.tinv2
2578 printf \
2579 'define mboxfix {
2580 \\localopts yes; \\wysh set mbox-rfc4155;\\wysh File "${1}";\\
2581 \\eval copy * "${2}"
2583 call mboxfix ./.tinv1 ./.tok' | ${MAILX} ${ARGS} > .tall 2>&1
2584 ex0_test behave:mbox-14-estat
2585 ${cat} ./.tinv1 ./.tok >> .tall
2586 check behave:mbox-14 - ./.tall '739301109 616'
2588 printf \
2589 'wysh file ./.tinv1 # ^From not repaired, but missing trailing NL is
2590 wysh File ./.tok # Just move away to nowhere
2591 set mbox-rfc4155
2592 wysh file ./.tinv2 # Fully repaired
2593 File ./.tok' | ${MAILX} ${ARGS} >>${ERR} 2>&1
2594 ex0_test behave:mbox-15-estat
2595 check behave:mbox-15-1 - ./.tinv1 '3178048820 332'
2596 check behave:mbox-15-2 - ./.tinv2 '4151504442 314'
2598 t_epilog
2601 t_behave_maildir() {
2602 t_prolog t_behave_maildir
2603 TRAP_EXIT_ADDONS="./.t*"
2607 while [ ${i} -lt 112 ]; do
2608 printf 'm file://%s\n~s Subject %s\nHello %s!\n~.\n' \
2609 "${MBOX}" "${i}" "${i}"
2610 i=`add ${i} 1`
2611 done
2612 ) | ${MAILX} ${ARGS}
2613 check behave:maildir-1 0 "${MBOX}" '1140119864 13780'
2615 printf 'File "%s"
2616 copy * "%s"
2617 File "%s"
2618 from*
2619 ' "${MBOX}" .tmdir1 .tmdir1 |
2620 ${MAILX} ${ARGS} -Snewfolders=maildir -Sshowlast > .tlst
2621 check behave:maildir-2 0 .tlst '1797938753 9103'
2623 printf 'File "%s"
2624 copy * "maildir://%s"
2625 File "maildir://%s"
2626 from*
2627 ' "${MBOX}" .tmdir2 .tmdir2 |
2628 ${MAILX} ${ARGS} -Sshowlast > .tlst
2629 check behave:maildir-3 0 .tlst '1155631089 9113'
2631 printf 'File "maildir://%s"
2632 copy * "file://%s"
2633 File "file://%s"
2634 from*
2635 ' .tmdir2 .tmbox1 .tmbox1 |
2636 ${MAILX} ${ARGS} -Sshowlast > .tlst
2637 check behave:maildir-4 0 .tmbox1 '2646131190 13220'
2638 check behave:maildir-5 - .tlst '3701297796 9110'
2640 # only the odd (even)
2642 printf 'File "maildir://%s"
2643 copy ' .tmdir2
2645 while [ ${i} -lt 112 ]; do
2646 j=`modulo ${i} 2`
2647 [ ${j} -eq 1 ] && printf '%s ' "${i}"
2648 i=`add ${i} 1`
2649 done
2650 printf ' file://%s
2651 File "file://%s"
2652 from*
2653 ' .tmbox2 .tmbox2
2654 ) | ${MAILX} ${ARGS} -Sshowlast > .tlst
2655 check behave:maildir-6 0 .tmbox2 '142890131 6610'
2656 check behave:maildir-7 - .tlst '960096773 4573'
2657 # ...
2659 printf 'file "maildir://%s"
2660 move ' .tmdir2
2662 while [ ${i} -lt 112 ]; do
2663 j=`modulo ${i} 2`
2664 [ ${j} -eq 0 ] && [ ${i} -ne 0 ] && printf '%s ' "${i}"
2665 i=`add ${i} 1`
2666 done
2667 printf ' file://%s
2668 File "file://%s"
2669 from*
2670 File "maildir://%s"
2671 from*
2672 ' .tmbox2 .tmbox2 .tmdir2
2673 ) | ${MAILX} ${ARGS} -Sshowlast > .tlst
2674 check behave:maildir-8 0 .tmbox2 '3806905791 13100'
2675 ${sed} 2d < .tlst > .tlstx
2676 check behave:maildir-9 - .tlstx '4216815295 13645'
2678 t_epilog
2681 t_behave_record_a_resend() {
2682 t_prolog t_behave_record_a_resend
2683 TRAP_EXIT_ADDONS="./.t.record ./.t.resent"
2685 printf '
2686 set record=%s
2687 m %s\n~s Subject 1.\nHello.\n~.
2688 set record-files add-file-recipients
2689 m %s\n~s Subject 2.\nHello.\n~.
2690 File %s
2691 resend 2 ./.t.resent
2692 Resend 1 ./.t.resent
2693 set record-resent
2694 resend 2 ./.t.resent
2695 Resend 1 ./.t.resent
2696 ' ./.t.record "${MBOX}" "${MBOX}" "${MBOX}" |
2697 ${MAILX} ${ARGS}
2699 check behave:record_a_resend-1 0 "${MBOX}" '3057873538 256'
2700 check behave:record_a_resend-2 - .t.record '391356429 460'
2701 check behave:record_a_resend-3 - .t.resent '2685231691 648'
2703 t_epilog
2706 t_behave_e_H_L_opts() {
2707 t_prolog t_behave_e_H_L_opts
2708 TRAP_EXIT_ADDONS="./.tsendmail.sh ./.t.mbox"
2710 touch ./.t.mbox
2711 ${MAILX} ${ARGS} -ef ./.t.mbox
2712 echo ${?} > "${MBOX}"
2714 ${cat} <<-_EOT > ./.tsendmail.sh
2715 #!${SHELL} -
2716 (echo 'From Alchemilla Wed Apr 07 17:03:33 2017' && ${cat} && echo
2717 ) >> "./.t.mbox"
2718 _EOT
2719 chmod 0755 ./.tsendmail.sh
2720 printf 'm me@exam.ple\nLine 1.\nHello.\n~.\n' |
2721 ${MAILX} ${ARGS} -Smta=./.tsendmail.sh
2722 printf 'm you@exam.ple\nLine 1.\nBye.\n~.\n' |
2723 ${MAILX} ${ARGS} -Smta=./.tsendmail.sh
2725 ${MAILX} ${ARGS} -ef ./.t.mbox
2726 echo ${?} >> "${MBOX}"
2727 ${MAILX} ${ARGS} -efL @t@me ./.t.mbox
2728 echo ${?} >> "${MBOX}"
2729 ${MAILX} ${ARGS} -efL @t@you ./.t.mbox
2730 echo ${?} >> "${MBOX}"
2731 ${MAILX} ${ARGS} -efL '@>@Line 1' ./.t.mbox
2732 echo ${?} >> "${MBOX}"
2733 ${MAILX} ${ARGS} -efL '@>@Hello.' ./.t.mbox
2734 echo ${?} >> "${MBOX}"
2735 ${MAILX} ${ARGS} -efL '@>@Bye.' ./.t.mbox
2736 echo ${?} >> "${MBOX}"
2737 ${MAILX} ${ARGS} -efL '@>@Good bye.' ./.t.mbox
2738 echo ${?} >> "${MBOX}"
2740 ${MAILX} ${ARGS} -fH ./.t.mbox >> "${MBOX}"
2741 echo ${?} >> "${MBOX}"
2742 ${MAILX} ${ARGS} -fL @t@me ./.t.mbox >> "${MBOX}"
2743 echo ${?} >> "${MBOX}"
2744 ${MAILX} ${ARGS} -fL @t@you ./.t.mbox >> "${MBOX}"
2745 echo ${?} >> "${MBOX}"
2746 ${MAILX} ${ARGS} -fL '@>@Line 1' ./.t.mbox >> "${MBOX}"
2747 echo ${?} >> "${MBOX}"
2748 ${MAILX} ${ARGS} -fL '@>@Hello.' ./.t.mbox >> "${MBOX}"
2749 echo ${?} >> "${MBOX}"
2750 ${MAILX} ${ARGS} -fL '@>@Bye.' ./.t.mbox >> "${MBOX}"
2751 echo ${?} >> "${MBOX}"
2752 ${MAILX} ${ARGS} -fL '@>@Good bye.' ./.t.mbox >> "${MBOX}" 2>>${ERR}
2753 echo ${?} >> "${MBOX}"
2755 check behave:e_H_L_opts - "${MBOX}" '1708955574 678'
2757 t_epilog
2760 t_behave_alternates() {
2761 t_prolog t_behave_alternates
2762 TRAP_EXIT_ADDONS="./.t*"
2764 ${cat} <<-_EOT > ./.tsendmail.sh
2765 #!${SHELL} -
2766 (echo 'From Valeriana Sat Jul 08 15:54:03 2017' && ${cat} && echo
2767 ) >> "${MBOX}"
2768 _EOT
2769 chmod 0755 ./.tsendmail.sh
2771 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Smta=./.tsendmail.sh > ./.tall 2>&1
2772 echo --0
2773 alternates
2774 echo $?/$^ERRNAME
2775 alternates a1@b1 a2@b2 a3@b3
2776 echo $?/$^ERRNAME
2777 alternates
2778 echo $?/$^ERRNAME
2779 vput alternates rv
2780 echo $?/$^ERRNAME <$rv>
2782 echo --1
2783 unalternates a2@b2
2784 vput alternates rv
2785 echo $?/$^ERRNAME <$rv>
2786 unalternates a3@b3
2787 vput alternates rv
2788 echo $?/$^ERRNAME <$rv>
2789 unalternates a1@b1
2790 vput alternates rv
2791 echo $?/$^ERRNAME <$rv>
2793 echo --2
2794 unalternates *
2795 alternates a1@b1 a2@b2 a3@b3
2796 unalternates a3@b3
2797 vput alternates rv
2798 echo $?/$^ERRNAME <$rv>
2799 unalternates a2@b2
2800 vput alternates rv
2801 echo $?/$^ERRNAME <$rv>
2802 unalternates a1@b1
2803 vput alternates rv
2804 echo $?/$^ERRNAME <$rv>
2806 echo --3
2807 alternates a1@b1 a2@b2 a3@b3
2808 unalternates a1@b1
2809 vput alternates rv
2810 echo $?/$^ERRNAME <$rv>
2811 unalternates a2@b2
2812 vput alternates rv
2813 echo $?/$^ERRNAME <$rv>
2814 unalternates a3@b3
2815 vput alternates rv
2816 echo $?/$^ERRNAME <$rv>
2818 echo --4
2819 unalternates *
2820 alternates a1@b1 a2@b2 a3@b3
2821 unalternates *
2822 vput alternates rv
2823 echo $?/$^ERRNAME <$rv>
2825 echo --5
2826 unalternates *
2827 alternates a1@b1 a1@c1 a1@d1 a2@b2 a3@b3 a3@c3 a3@d3
2828 m a1@b1 a1@c1 a1@d1
2829 ~s all alternates, only a1@b1 remains
2830 ~c a2@b2
2831 ~b a3@b3 a3@c3 a3@d3
2832 ~r - '_EOT'
2833 This body is!
2834 This also body is!!
2835 _EOT
2838 echo --6
2839 unalternates *
2840 alternates a1@b1 a1@c1 a2@b2 a3@b3
2841 m a1@b1 a1@c1 a1@d1
2842 ~s a1@b1 a1@d1, and a3@c3 a3@d3 remain
2843 ~c a2@b2
2844 ~b a3@b3 a3@c3 a3@d3
2845 ~r - '_EOT'
2846 This body2 is!
2847 _EOT
2850 echo --7
2851 alternates a1@b1 a2@b2 a3; set allnet
2852 m a1@b1 a1@c1 a1@d1
2853 ~s all alternates via allnet, only a1@b1 remains
2854 ~c a2@b2
2855 ~b a3@b3 a3@c3 a3@d3
2856 ~r - '_EOT'
2857 This body3 is!
2858 _EOT
2861 echo --10
2862 unalternates *
2863 alternates a1@b1
2864 echo $?/$^ERRNAME
2865 vput alternates rv
2866 echo $?/$^ERRNAME <$rv>
2867 alternates a2@b2
2868 echo $?/$^ERRNAME
2869 vput alternates rv
2870 echo $?/$^ERRNAME <$rv>
2871 alternates a3@b3
2872 echo $?/$^ERRNAME
2873 vput alternates rv
2874 echo $?/$^ERRNAME <$rv>
2875 alternates a4@b4
2876 echo $?/$^ERRNAME
2877 vput alternates rv
2878 echo $?/$^ERRNAME <$rv>
2880 unalternates *
2881 vput alternates rv
2882 echo $?/$^ERRNAME <$rv>
2884 echo --11
2885 set posix
2886 alternates a1@b1 a2@b2
2887 echo $?/$^ERRNAME
2888 vput alternates rv
2889 echo $?/$^ERRNAME <$rv>
2890 alternates a3@b3 a4@b4
2891 echo $?/$^ERRNAME
2892 vput alternates rv
2893 echo $?/$^ERRNAME <$rv>
2894 __EOT
2896 check behave:alternates-1 0 "${MBOX}" '142184864 515'
2897 if have_feat uistrings; then
2898 check behave:alternates-2 - .tall '1878598364 505'
2899 else
2900 echo 'behave:alternates-2: unsupported, skipped'
2903 t_epilog
2906 t_behave_alias() {
2907 t_prolog t_behave_alias
2908 TRAP_EXIT_ADDONS="./.t*"
2910 ${cat} <<-_EOT > ./.tsendmail.sh
2911 #!${SHELL} -
2912 (echo 'From Hippocastanum Mon Jun 19 15:07:07 2017' && ${cat} && echo
2913 ) >> "${MBOX}"
2914 _EOT
2915 chmod 0755 ./.tsendmail.sh
2917 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Smta=./.tsendmail.sh > ./.tall 2>&1
2918 alias a1 ex1@a1.ple
2919 alias a1 ex2@a1.ple "EX3 <ex3@a1.ple>"
2920 alias a1 ex4@a1.ple
2921 alias a2 ex1@a2.ple ex2@a2.ple ex3@a2.ple ex4@a2.ple
2922 alias a3 a4
2923 alias a4 a5 ex1@a4.ple
2924 alias a5 a6
2925 alias a6 a7 ex1@a6.ple
2926 alias a7 a8
2927 alias a8 ex1@a8.ple
2928 alias a1
2929 alias a2
2930 alias a3
2931 m a1
2932 ~c a2
2933 ~b a3
2934 ~r - '_EOT'
2935 This body is!
2936 This also body is!!
2937 _EOT
2938 __EOT
2939 check behave:alias-1 0 "${MBOX}" '2496925843 272'
2940 check behave:alias-2 - .tall '3548953204 152'
2942 # TODO t_behave_alias: n_ALIAS_MAXEXP is compile-time constant,
2943 # TODO need to somehow provide its contents to the test, then test
2945 t_epilog
2948 t_behave_filetype() {
2949 t_prolog t_behave_filetype
2950 TRAP_EXIT_ADDONS="./.t*"
2952 ${cat} <<-_EOT > ./.tsendmail.sh
2953 #!${SHELL} -
2954 (echo 'From Alchemilla Wed Apr 25 15:12:13 2017' && ${cat} && echo
2955 ) >> "${MBOX}"
2956 _EOT
2957 chmod 0755 ./.tsendmail.sh
2959 printf 'm m1@e.t\nL1\nHy1\n~.\nm m2@e.t\nL2\nHy2\n~@ %s\n~.\n' \
2960 "${SRCDIR}snailmail.jpg" | ${MAILX} ${ARGS} -Smta=./.tsendmail.sh
2961 check behave:filetype-1 0 "${MBOX}" '1594682963 13520'
2963 if (echo | gzip -c) >/dev/null 2>&1; then
2964 ${rm} -f ./.t.mbox*
2966 printf 'File "%s"\ncopy 1 ./.t.mbox.gz\ncopy 2 ./.t.mbox.gz' \
2967 "${MBOX}" | ${MAILX} ${ARGS} \
2968 -X'filetype gz gzip\ -dc gzip\ -c'
2969 printf 'File ./.t.mbox.gz\ncopy * ./.t.mbox\n' |
2970 ${MAILX} ${ARGS} -X'filetype gz gzip\ -dc gzip\ -c'
2971 } > ./.t.out 2>&1
2972 check behave:filetype-2 - "./.t.mbox" '1594682963 13520'
2973 check behave:filetype-3 - "./.t.out" '2392348396 102'
2974 else
2975 echo 'behave:filetype-2: unsupported, skipped'
2976 echo 'behave:filetype-3: unsupported, skipped'
2980 ${rm} -f ./.t.mbox*
2981 printf 'File "%s"\ncopy 1 ./.t.mbox.gz
2982 copy 2 ./.t.mbox.gz
2983 copy 1 ./.t.mbox.gz
2984 copy 2 ./.t.mbox.gz
2985 ' "${MBOX}" |
2986 ${MAILX} ${ARGS} \
2987 -X'filetype gz gzip\ -dc gzip\ -c' \
2988 -X'filetype mbox.gz "${sed} 1,3d|${cat}" \
2989 "echo eins;echo zwei;echo und mit ${sed} bist Du dabei;${cat}"'
2990 printf 'File ./.t.mbox.gz\ncopy * ./.t.mbox\n' |
2991 ${MAILX} ${ARGS} \
2992 -X'filetype gz gzip\ -dc gzip\ -c' \
2993 -X'filetype mbox.gz "${sed} 1,3d|${cat}" kill\ 0'
2994 } > ./.t.out 2>&1
2995 check behave:filetype-4 - "./.t.mbox" '2886541147 27060'
2996 check behave:filetype-5 - "./.t.out" '852335377 172'
2998 t_epilog
3001 t_behave_message_injections() {
3002 t_prolog t_behave_message_injections
3003 TRAP_EXIT_ADDONS="./.t*"
3005 ${cat} <<-_EOT > ./.tsendmail.sh
3006 #!${SHELL} -
3007 (echo 'From Echinacea Tue Jun 20 15:54:02 2017' && ${cat} && echo
3008 ) > "${MBOX}"
3009 _EOT
3010 chmod 0755 ./.tsendmail.sh
3012 echo mysig > ./.tmysig
3014 echo some-body | ${MAILX} ${ARGS} -Smta=./.tsendmail.sh \
3015 -Smessage-inject-head=head-inject \
3016 -Smessage-inject-tail=tail-inject \
3017 -Ssignature=./.tmysig \
3018 ex@am.ple > ./.tall 2>&1
3019 check behave:message_injections-1 0 "${MBOX}" '2434746382 134'
3020 check behave:message_injections-2 - .tall '4294967295 0' # empty file
3022 ${cat} <<-_EOT > ./.template
3023 From: me
3024 To: ex1@am.ple
3025 Cc: ex2@am.ple
3026 Subject: This subject is
3028 Body, body, body me.
3029 _EOT
3030 < ./.template ${MAILX} ${ARGS} -t -Smta=./.tsendmail.sh \
3031 -Smessage-inject-head=head-inject \
3032 -Smessage-inject-tail=tail-inject \
3033 -Ssignature=./.tmysig \
3034 > ./.tall 2>&1
3035 check behave:message_injections-3 0 "${MBOX}" '3114203412 198'
3036 check behave:message_injections-4 - .tall '4294967295 0' # empty file
3038 t_epilog
3041 t_behave_attachments() {
3042 t_prolog t_behave_attachments
3043 TRAP_EXIT_ADDONS="./.t*"
3045 ${cat} <<-_EOT > ./.tsendmail.sh
3046 #!${SHELL} -
3047 (echo 'From Cannabis Sun Feb 18 02:02:46 2018' && ${cat} && echo
3048 ) >> "${MBOX}"
3049 _EOT
3050 chmod 0755 ./.tsendmail.sh
3052 ${cat} <<-_EOT > ./.tx
3053 From steffen Sun Feb 18 02:48:40 2018
3054 Date: Sun, 18 Feb 2018 02:48:40 +0100
3056 Subject: m1
3057 User-Agent: s-nail v14.9.7
3060 From steffen Sun Feb 18 02:48:42 2018
3061 Date: Sun, 18 Feb 2018 02:48:42 +0100
3063 Subject: m2
3064 User-Agent: s-nail v14.9.7
3067 _EOT
3068 echo att1 > ./.t1
3069 printf 'att2-1\natt2-2\natt2-4\n' > ./'.t 2'
3070 printf 'att3-1\natt3-2\natt3-4\n' > ./.t3
3071 printf 'att4-1\natt4-2\natt4-4\n' > './.t 4'
3073 printf \
3074 '!@ ./.t3 "./.t 4" ""
3077 ./.t3
3078 "./.t 2"
3081 !.' \
3082 | ${MAILX} ${ARGS} -Sescape=! -Smta=./.tsendmail.sh \
3083 -a ./.t1 -a './.t 2' \
3084 -s attachment-test \
3085 ex@am.ple > ./.tall 2>&1
3086 check behave:attachments-1 0 "${MBOX}" '4107062253 634'
3087 if have_feat uistrings; then
3088 check behave:attachments-2 - .tall '1928331872 720'
3089 else
3090 echo 'behave:attachments-2: unsupported, skipped'
3093 ${rm} -f "${MBOX}"
3094 printf \
3095 'mail ex@amp.ple
3096 !s This the subject is
3097 !@ ./.t3 "#2" "./.t 4" "#1" ""
3100 "./.t 4"
3101 "#2"
3105 mail ex@amp.ple
3106 !s Subject two
3107 !@ ./.t3 "#2" "./.t 4" "#1" ""
3113 mail ex@amp.ple
3114 !s Subject three
3115 !@ ./.t3 "" "#2" "" "./.t 4" "" "#1" ""
3118 ./.t3
3122 mail ex@amp.ple
3123 !s Subject Four
3124 !@ ./.t3 "" "#2" "" "./.t 4" "" "#1" ""
3127 "#1"
3131 mail ex@amp.ple
3132 !s Subject Five
3134 "#2"
3137 !.' \
3138 | ${MAILX} ${ARGS} -Sescape=! -Smta=./.tsendmail.sh -Rf ./.tx \
3139 > ./.tall 2>&1
3140 check behave:attachments-3 0 "${MBOX}" '798122412 2285'
3141 if have_feat uistrings; then
3142 check behave:attachments-4 - .tall '2526106274 1910'
3143 else
3144 echo 'behave:attachments-4: unsupported, skipped'
3147 t_epilog
3150 t_behave_compose_hooks() { # TODO monster
3151 t_prolog t_behave_compose_hooks
3152 if have_feat uistrings; then :; else
3153 echo 'behave:compose_hooks: unsupported, skipped'
3154 return
3156 TRAP_EXIT_ADDONS="./.t*"
3158 (echo line one&&echo line two&&echo line three) > ./.treadctl
3159 (echo echo four&&echo echo five&&echo echo six) > ./.tattach
3161 ${cat} <<-_EOT > ./.tsendmail.sh
3162 #!${SHELL} -
3163 (echo 'From PrimulaVeris Wed Apr 10 22:59:00 2017' && ${cat} && echo
3164 ) >> "${MBOX}"
3165 _EOT
3166 chmod 0755 ./.tsendmail.sh
3168 ${cat} <<'__EOT__' > ./.trc
3169 define bail {
3170 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
3172 define xerr {
3173 vput vexpr es substr "$1" 0 1
3174 if [ "$es" != 2 ]
3175 xcall bail "$2"
3178 define read_mline_res {
3179 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
3180 echo $len/$es/$^ERRNAME: $hl
3181 if [ $es -ne $^ERR-NONE ]
3182 xcall bail read_mline_res
3183 elif [ $len -ne 0 ]
3184 \xcall read_mline_res
3187 define ins_addr {
3188 wysh set xh=$1
3189 echo "~^header list"; read hl; echo $hl;\
3190 call xerr "$hl" "in_addr ($xh) 0-1"
3192 echo "~^header insert $xh diet <$xh@exam.ple> spliced";\
3193 read es; echo $es; call xerr "$es" "ins_addr $xh 1-1"
3194 echo "~^header insert $xh <${xh}2@exam.ple>";\
3195 read es; echo $es; call xerr "$es" "ins_addr $xh 1-2"
3196 echo "~^header insert $xh ${xh}3@exam.ple";\
3197 read es; echo $es; call xerr "$es" "ins_addr $xh 1-3"
3198 echo "~^header list $xh"; read hl; echo $hl;\
3199 call xerr "$hl" "ins_addr $xh 1-4"
3200 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 1-5"
3201 call read_mline_res
3203 if [ "$t_remove" == "" ]
3204 return
3207 echo "~^header remove $xh"; read es; call xerr $es "ins_addr $xh 2-1"
3208 echo "~^header remove $xh"; read es; vput vexpr es substr $es 0 3
3209 if [ $es != 501 ]
3210 xcall bail "ins_addr $xh 2-2"
3212 echo "~^header list $xh"; read es; vput vexpr es substr $es 0 3
3213 if [ $es != 501 ]
3214 xcall bail "ins_addr $xh 2-3"
3216 echo "~^header show $xh"; read es; vput vexpr es substr $es 0 3
3217 if [ $es != 501 ]
3218 xcall bail "ins_addr $xh 2-4"
3222 echo "~^header insert $xh diet <$xh@exam.ple> spliced";\
3223 read es; echo $es; call xerr "$es" "ins_addr $xh 3-1"
3224 echo "~^header insert $xh <${xh}2@exam.ple>";\
3225 read es; echo $es; call xerr "$es" "ins_addr $xh 3-2"
3226 echo "~^header insert $xh ${xh}3@exam.ple";\
3227 read es; echo $es; call xerr "$es" "ins_addr $xh 3-3"
3228 echo "~^header list $xh"; read hl; echo $hl;\
3229 call xerr "$hl" "ins_addr $xh 3-4"
3230 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 3-5"
3231 call read_mline_res
3233 echo "~^header remove-at $xh 1"; read es;\
3234 call xerr $es "ins_addr $xh 3-6"
3235 echo "~^header remove-at $xh 1"; read es;\
3236 call xerr $es "ins_addr $xh 3-7"
3237 echo "~^header remove-at $xh 1"; read es;\
3238 call xerr $es "ins_addr $xh 3-8"
3239 echo "~^header remove-at $xh 1"; read es;\
3240 vput vexpr es substr $es 0 3
3241 if [ $es != 501 ]
3242 xcall bail "ins_addr $xh 3-9"
3244 echo "~^header remove-at $xh T"; read es;\
3245 vput vexpr es substr $es 0 3
3246 if [ $es != 505 ]
3247 xcall bail "ins_addr $xh 3-10"
3249 echo "~^header list $xh"; read es;\
3250 vput vexpr es substr $es 0 3
3251 if [ $es != 501 ]
3252 xcall bail "ins_addr $xh 3-11"
3254 echo "~^header show $xh"; read es;\
3255 vput vexpr es substr $es 0 3
3256 if [ $es != 501 ]
3257 xcall bail "ins_addr $xh 3-12"
3261 echo "~^header insert $xh diet <$xh@exam.ple> spliced";\
3262 read es; echo $es; call xerr "$es" "ins_addr $xh 4-1"
3263 echo "~^header insert $xh <${xh}2@exam.ple> (comment) \"Quot(e)d\"";\
3264 read es; echo $es; call xerr "$es" "ins_addr $xh 4-2"
3265 echo "~^header insert $xh ${xh}3@exam.ple";\
3266 read es; echo $es; call xerr "$es" "ins_addr $xh 4-3"
3267 echo "~^header list $xh"; read hl; echo $hl;\
3268 call xerr "$hl" "header list $xh 3-4"
3269 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 4-5"
3270 call read_mline_res
3272 echo "~^header remove-at $xh 3"; read es;\
3273 call xerr $es "ins_addr $xh 4-6"
3274 echo "~^header remove-at $xh 2"; read es;\
3275 call xerr $es "ins_addr $xh 4-7"
3276 echo "~^header remove-at $xh 1"; read es;\
3277 call xerr $es "ins_addr $xh 4-8"
3278 echo "~^header remove-at $xh 1"; read es;\
3279 vput vexpr es substr $es 0 3
3280 if [ $es != 501 ]
3281 xcall bail "ins_addr $xh 4-9"
3283 echo "~^header remove-at $xh T"; read es;\
3284 vput vexpr es substr $es 0 3
3285 if [ $es != 505 ]
3286 xcall bail "ins_addr $xh 4-10"
3288 echo "~^header list $xh"; read es;\
3289 vput vexpr es substr $es 0 3
3290 if [ $es != 501 ]
3291 xcall bail "ins_addr $xh 4-11"
3293 echo "~^header show $xh"; read es;\
3294 vput vexpr es substr $es 0 3
3295 if [ $es != 501 ]
3296 xcall bail "ins_addr $xh 4-12"
3299 define ins_ref {
3300 wysh set xh=$1 mult=$2
3301 echo "~^header list"; read hl; echo $hl;\
3302 call xerr "$hl" "ins_ref ($xh) 0-1"
3304 echo "~^header insert $xh <$xh@exam.ple>";\
3305 read es; echo $es; call xerr "$es" "ins_ref $xh 1-1"
3306 if [ $mult -ne 0 ]
3307 echo "~^header insert $xh <${xh}2@exam.ple>";\
3308 read es; echo $es; call xerr "$es" "ins_ref $xh 1-2"
3309 echo "~^header insert $xh ${xh}3@exam.ple";\
3310 read es; echo $es; call xerr "$es" "ins_ref $xh 1-3"
3311 else
3312 echo "~^header insert $xh <${xh}2@exam.ple>"; read es;\
3313 vput vexpr es substr $es 0 3
3314 if [ $es != 506 ]
3315 xcall bail "ins_ref $xh 1-4"
3319 echo "~^header list $xh"; read hl; echo $hl;\
3320 call xerr "$hl" "ins_ref $xh 1-5"
3321 echo "~^header show $xh"; read es; call xerr $es "ins_ref $xh 1-6"
3322 call read_mline_res
3324 if [ "$t_remove" == "" ]
3325 return
3328 echo "~^header remove $xh"; read es;\
3329 call xerr $es "ins_ref $xh 2-1"
3330 echo "~^header remove $xh"; read es;\
3331 vput vexpr es substr $es 0 3
3332 if [ $es != 501 ]
3333 xcall bail "ins_ref $xh 2-2"
3335 echo "~^header list $xh"; read es;\
3336 vput vexpr es substr $es 0 3
3337 if [ $es != 501 ]
3338 xcall bail "$es ins_ref $xh 2-3"
3340 echo "~^header show $xh"; read es;\
3341 vput vexpr es substr $es 0 3
3342 if [ $es != 501 ]
3343 xcall bail "ins_ref $xh 2-4"
3347 echo "~^header insert $xh <$xh@exam.ple>";\
3348 read es; echo $es; call xerr "$es" "ins_ref $xh 3-1"
3349 if [ $mult -ne 0 ]
3350 echo "~^header insert $xh <${xh}2@exam.ple>";\
3351 read es; echo $es; call xerr "$es" "ins_ref $xh 3-2"
3352 echo "~^header insert $xh ${xh}3@exam.ple";\
3353 read es; echo $es; call xerr "$es" "ins_ref $xh 3-3"
3355 echo "~^header list $xh";\
3356 read hl; echo $hl; call xerr "$hl" "ins_ref $xh 3-4"
3357 echo "~^header show $xh";\
3358 read es; call xerr $es "ins_ref $xh 3-5"
3359 call read_mline_res
3361 echo "~^header remove-at $xh 1"; read es;\
3362 call xerr $es "ins_ref $xh 3-6"
3363 if [ $mult -ne 0 ] && [ $xh != subject ]
3364 echo "~^header remove-at $xh 1"; read es;\
3365 call xerr $es "ins_ref $xh 3-7"
3366 echo "~^header remove-at $xh 1"; read es;\
3367 call xerr $es "ins_ref $xh 3-8"
3369 echo "~^header remove-at $xh 1"; read es;\
3370 vput vexpr es substr $es 0 3
3371 if [ $es != 501 ]
3372 xcall bail "ins_ref $xh 3-9"
3374 echo "~^header remove-at $xh T"; read es;\
3375 vput vexpr es substr $es 0 3
3376 if [ $es != 505 ]
3377 xcall bail "ins_ref $xh 3-10"
3379 echo "~^header show $xh"; read es;\
3380 vput vexpr es substr $es 0 3
3381 if [ $es != 501 ]
3382 xcall bail "ins_ref $xh 3-11"
3386 echo "~^header insert $xh <$xh@exam.ple> ";\
3387 read es; echo $es; call xerr "$es" "ins_ref $xh 4-1"
3388 if [ $mult -ne 0 ]
3389 echo "~^header insert $xh <${xh}2@exam.ple> ";\
3390 read es; echo $es; call xerr "$es" "ins_ref $xh 4-2"
3391 echo "~^header insert $xh ${xh}3@exam.ple";\
3392 read es; echo $es; call xerr "$es" "ins_ref $xh 4-3"
3394 echo "~^header list $xh"; read hl; echo $hl;\
3395 call xerr "$hl" "ins_ref $xh 4-4"
3396 echo "~^header show $xh"; read es; call xerr $es "ins_ref $xh 4-5"
3397 call read_mline_res
3399 if [ $mult -ne 0 ] && [ $xh != subject ]
3400 echo "~^header remove-at $xh 3"; read es;\
3401 call xerr $es "ins_ref $xh 4-6"
3402 echo "~^header remove-at $xh 2"; read es;\
3403 call xerr $es "ins_ref $xh 4-7"
3405 echo "~^header remove-at $xh 1"; read es;\
3406 call xerr $es "ins_ref $xh 4-8"
3407 echo "~^header remove-at $xh 1"; read es;\
3408 vput vexpr es substr $es 0 3
3409 if [ $es != 501 ]
3410 xcall bail "ins_ref $xh 4-9"
3412 echo "~^header remove-at $xh T"; read es;\
3413 vput vexpr es substr $es 0 3
3414 if [ $es != 505 ]
3415 xcall bail "ins_ref $xh 4-10"
3417 echo "~^header show $xh"; read es;\
3418 vput vexpr es substr $es 0 3
3419 if [ $es != 501 ]
3420 xcall bail "ins_ref $xh 4-11"
3423 define t_header {
3424 echo t_header ENTER
3425 # In collect.c order
3426 call ins_addr from
3427 call ins_ref sender 0 # Not a "ref", but works
3428 call ins_addr To
3429 call ins_addr cC
3430 call ins_addr bCc
3431 call ins_addr reply-To
3432 call ins_addr mail-Followup-to
3433 call ins_ref messAge-id 0
3434 call ins_ref rEfErEncEs 1
3435 call ins_ref in-Reply-to 1
3436 call ins_ref subject 1 # Not a "ref", but works (with tweaks)
3437 call ins_addr freeForm1
3438 call ins_addr freeform2
3440 echo "~^header show MAILX-Command"; read es; call xerr $es "t_header 1000"
3441 call read_mline_res
3442 echo "~^header show MAILX-raw-TO"; read es; call xerr $es "t_header 1001"
3443 call read_mline_res
3445 echo t_header LEAVE
3447 define t_attach {
3448 echo t_attach ENTER
3450 echo "~^attachment";\
3451 read hl; echo $hl; vput vexpr es substr "$hl" 0 3
3452 if [ "$es" != 501 ]
3453 xcall bail "attach 0-1"
3456 echo "~^attach attribute ./.treadctl";\
3457 read hl; echo $hl; vput vexpr es substr "$hl" 0 3
3458 if [ "$es" != 501 ]
3459 xcall bail "attach 0-2"
3461 echo "~^attachment attribute-at 1";\
3462 read hl; echo $hl; vput vexpr es substr "$hl" 0 3
3463 if [ "$es" != 501 ]
3464 xcall bail "attach 0-3"
3467 echo "~^attachment insert ./.treadctl=ascii";\
3468 read hl; echo $hl; call xerr "$hl" "attach 1-1"
3469 echo "~^attachment list";\
3470 read es; echo $es;call xerr "$es" "attach 1-2"
3471 call read_mline_res
3472 echo "~^attachment attribute ./.treadctl";\
3473 read es; echo $es;call xerr "$es" "attach 1-3"
3474 call read_mline_res
3475 echo "~^attachment attribute .treadctl";\
3476 read es; echo $es;call xerr "$es" "attach 1-4"
3477 call read_mline_res
3478 echo "~^attachment attribute-at 1";\
3479 read es; echo $es;call xerr "$es" "attach 1-5"
3480 call read_mline_res
3482 echo "~^attachment attribute-set ./.treadctl filename rctl";\
3483 read es; echo $es;call xerr "$es" "attach 1-6"
3484 echo "~^attachment attribute-set .treadctl content-description Au";\
3485 read es; echo $es;call xerr "$es" "attach 1-7"
3486 echo "~^attachment attribute-set-at 1 content-id <10.du@ich>";\
3487 read es; echo $es;call xerr "$es" "attach 1-8"
3489 echo "~^attachment attribute ./.treadctl";\
3490 read es; echo $es;call xerr "$es" "attach 1-9"
3491 call read_mline_res
3492 echo "~^attachment attribute .treadctl";\
3493 read es; echo $es;call xerr "$es" "attach 1-10"
3494 call read_mline_res
3495 echo "~^attachment attribute rctl";\
3496 read es; echo $es;call xerr "$es" "attach 1-11"
3497 call read_mline_res
3498 echo "~^attachment attribute-at 1";\
3499 read es; echo $es;call xerr "$es" "attach 1-12"
3500 call read_mline_res
3503 echo "~^attachment insert ./.tattach=latin1";\
3504 read hl; echo $hl; call xerr "$hl" "attach 2-1"
3505 echo "~^attachment list";\
3506 read es; echo $es;call xerr "$es" "attach 2-2"
3507 call read_mline_res
3508 echo "~^attachment attribute ./.tattach";\
3509 read es; echo $es;call xerr "$es" "attach 2-3"
3510 call read_mline_res
3511 echo "~^attachment attribute .tattach";\
3512 read es; echo $es;call xerr "$es" "attach 2-4"
3513 call read_mline_res
3514 echo "~^attachment attribute-at 2";\
3515 read es; echo $es;call xerr "$es" "attach 2-5"
3516 call read_mline_res
3518 echo "~^attachment attribute-set ./.tattach filename tat";\
3519 read es; echo $es;call xerr "$es" "attach 2-6"
3520 echo \
3521 "~^attachment attribute-set .tattach content-description Au2";\
3522 read es; echo $es;call xerr "$es" "attach 2-7"
3523 echo "~^attachment attribute-set-at 2 content-id <20.du@wir>";\
3524 read es; echo $es;call xerr "$es" "attach 2-8"
3525 echo \
3526 "~^attachment attribute-set-at 2 content-type application/x-sh";\
3527 read es; echo $es;call xerr "$es" "attach 2-9"
3529 echo "~^attachment attribute ./.tattach";\
3530 read es; echo $es;call xerr "$es" "attach 2-10"
3531 call read_mline_res
3532 echo "~^attachment attribute .tattach";\
3533 read es; echo $es;call xerr "$es" "attach 2-11"
3534 call read_mline_res
3535 echo "~^attachment attribute tat";\
3536 read es; echo $es;call xerr "$es" "attach 2-12"
3537 call read_mline_res
3538 echo "~^attachment attribute-at 2";\
3539 read es; echo $es;call xerr "$es" "attach 2-13"
3540 call read_mline_res
3543 if [ "$t_remove" == "" ]
3544 return
3547 echo "~^attachment remove ./.treadctl"; read es;\
3548 call xerr $es "attach 3-1"
3549 echo "~^attachment remove ./.tattach"; read es;\
3550 call xerr $es "attach 3-2"
3551 echo "~^ attachment remove ./.treadctl"; read es;\
3552 vput vexpr es substr $es 0 3
3553 if [ $es != 501 ]
3554 xcall bail "attach 3-3"
3556 echo "~^ attachment remove ./.tattach"; read es;\
3557 vput vexpr es substr $es 0 3
3558 if [ $es != 501 ]
3559 xcall bail "attach 3-4"
3561 echo "~^attachment list"; read es;\
3562 vput vexpr es substr $es 0 3
3563 if [ $es != 501 ]
3564 xcall bail "attach 3-5"
3568 echo "~^attachment insert ./.tattach=latin1";\
3569 read hl; echo $hl; call xerr "$hl" "attach 4-1"
3570 echo "~^attachment insert ./.tattach=latin1";\
3571 read hl; echo $hl; call xerr "$hl" "attach 4-2"
3572 echo "~^attachment list";\
3573 read es; echo $es;call xerr "$es" "attach 4-3"
3574 call read_mline_res
3575 echo "~^ attachment remove .tattach"; read es;\
3576 vput vexpr es substr $es 0 3
3577 if [ $es != 506 ]
3578 xcall bail "attach 4-4 $es"
3580 echo "~^attachment remove-at T"; read es;\
3581 vput vexpr es substr $es 0 3
3582 if [ $es != 505 ]
3583 xcall bail "attach 4-5"
3585 echo "~^attachment remove ./.tattach"; read es;\
3586 call xerr $es "attach 4-6"
3587 echo "~^attachment remove ./.tattach"; read es;\
3588 call xerr $es "attach 4-7"
3589 echo "~^ attachment remove ./.tattach"; read es;\
3590 vput vexpr es substr $es 0 3
3591 if [ $es != 501 ]
3592 xcall bail "attach 4-8 $es"
3594 echo "~^attachment list"; read es;\
3595 vput vexpr es substr $es 0 3
3596 if [ $es != 501 ]
3597 xcall bail "attach 4-9"
3601 echo "~^attachment insert ./.tattach=latin1";\
3602 read hl; echo $hl; call xerr "$hl" "attach 5-1"
3603 echo "~^attachment insert ./.tattach=latin1";\
3604 read hl; echo $hl; call xerr "$hl" "attach 5-2"
3605 echo "~^attachment insert ./.tattach=latin1";\
3606 read hl; echo $hl; call xerr "$hl" "attach 5-3"
3607 echo "~^attachment list";\
3608 read es; echo $es;call xerr "$es" "attach 5-4"
3609 call read_mline_res
3611 echo "~^attachment remove-at 3"; read es;\
3612 call xerr $es "attach 5-5"
3613 echo "~^attachment remove-at 3"; read es;\
3614 vput vexpr es substr $es 0 3
3615 if [ $es != 501 ]
3616 xcall bail "attach 5-6"
3618 echo "~^attachment remove-at 2"; read es;\
3619 call xerr $es "attach 5-7"
3620 echo "~^attachment remove-at 2"; read es;\
3621 vput vexpr es substr $es 0 3
3622 if [ $es != 501 ]
3623 xcall bail "attach 5-8"
3625 echo "~^attachment remove-at 1"; read es;\
3626 call xerr $es "attach 5-9"
3627 echo "~^attachment remove-at 1"; read es;\
3628 vput vexpr es substr $es 0 3
3629 if [ $es != 501 ]
3630 xcall bail "attach 5-10"
3633 echo "~^attachment list"; read es;\
3634 vput vexpr es substr $es 0 3
3635 if [ $es != 501 ]
3636 xcall bail "attach 5-11"
3640 echo "~^attachment insert ./.tattach=latin1";\
3641 read hl; echo $hl; call xerr "$hl" "attach 6-1"
3642 echo "~^attachment insert ./.tattach=latin1";\
3643 read hl; echo $hl; call xerr "$hl" "attach 6-2"
3644 echo "~^attachment insert ./.tattach=latin1";\
3645 read hl; echo $hl; call xerr "$hl" "attach 6-3"
3646 echo "~^attachment list";\
3647 read es; echo $es;call xerr "$es" "attach 6-4"
3648 call read_mline_res
3650 echo "~^attachment remove-at 1"; read es;\
3651 call xerr $es "attach 6-5"
3652 echo "~^attachment remove-at 1"; read es;\
3653 call xerr $es "attach 6-6"
3654 echo "~^attachment remove-at 1"; read es;\
3655 call xerr $es "attach 6-7"
3656 echo "~^attachment remove-at 1"; read es;\
3657 vput vexpr es substr $es 0 3
3658 if [ $es != 501 ]
3659 xcall bail "attach 6-8"
3662 echo "~^attachment list"; read es;\
3663 vput vexpr es substr $es 0 3
3664 if [ $es != 501 ]
3665 xcall bail "attach 6-9"
3668 echo t_attach LEAVE
3670 define t_ocs {
3671 read ver
3672 echo t_ocs
3673 call t_header
3674 call t_attach
3676 define t_oce {
3677 echo on-compose-enter, mailx-command<$mailx-command>
3678 alternates alter1@exam.ple alter2@exam.ple
3679 alternates
3680 set autocc='alter1@exam.ple alter2@exam.ple'
3681 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3682 echo mailx-subject<$mailx-subject>
3683 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3684 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3685 mailx-raw-bcc<$mailx-raw-bcc>
3686 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
3687 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3689 define t_ocl {
3690 echo on-compose-leave, mailx-command<$mailx-command>
3691 vput alternates al
3692 eval alternates $al alter3@exam.ple alter4@exam.ple
3693 alternates
3694 set autobcc='alter3@exam.ple alter4@exam.ple'
3695 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3696 echo mailx-subject<$mailx-subject>
3697 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3698 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3699 mailx-raw-bcc<$mailx-raw-bcc>
3700 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
3701 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3703 define t_occ {
3704 echo on-compose-cleanup, mailx-command<$mailx-command>
3705 unalternates *
3706 alternates
3707 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3708 echo mailx-subject<$mailx-subject>
3709 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3710 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3711 mailx-raw-bcc<$mailx-raw-bcc>
3712 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
3713 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3715 wysh set on-compose-splice=t_ocs \
3716 on-compose-enter=t_oce on-compose-leave=t_ocl \
3717 on-compose-cleanup=t_occ
3718 __EOT__
3720 ${rm} -f "${MBOX}"
3721 printf 'm this-goes@nowhere\nbody\n!.\n' |
3722 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
3723 -X'source ./.trc' -Smta=./.tsendmail.sh \
3724 >./.tall 2>&1
3725 ${cat} ./.tall >> "${MBOX}"
3726 check behave:compose_hooks-1 0 "${MBOX}" '522535560 10101'
3728 ${rm} -f "${MBOX}"
3729 printf 'm this-goes@nowhere\nbody\n!.\n' |
3730 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
3731 -St_remove=1 -X'source ./.trc' -Smta=./.tsendmail.sh \
3732 >./.tall 2>&1
3733 ${cat} ./.tall >> "${MBOX}"
3734 check behave:compose_hooks-2 0 "${MBOX}" '3654000499 12535'
3738 # Some state machine stress, shell compose hook, localopts for hook, etc.
3739 # readctl in child. ~r as HERE document
3740 ${rm} -f "${MBOX}"
3741 printf 'm ex@am.ple\nbody\n!.
3742 echon ${mailx-command}${mailx-subject}
3743 echon ${mailx-from}${mailx-sender}
3744 echon ${mailx-to}${mailx-cc}${mailx-bcc}
3745 echon ${mailx-raw-to}${mailx-raw-cc}${mailx-raw-bcc}
3746 echon ${mailx-orig-from}${mailx-orig-to}${mailx-orig-gcc}${mailx-orig-bcc}
3747 var t_oce t_ocs t_ocs_sh t_ocl t_occ autocc
3748 ' | ${MAILX} ${ARGS} -Snomemdebug -Sescape=! \
3749 -Smta=./.tsendmail.sh \
3751 define bail {
3752 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
3754 define xerr {
3755 vput vexpr es substr "$1" 0 1
3756 if [ "$es" != 2 ]
3757 xcall bail "$2"
3760 define read_mline_res {
3761 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
3762 echo $len/$es/$^ERRNAME: $hl
3763 if [ $es -ne $^ERR-NONE ]
3764 xcall bail read_mline_res
3765 elif [ $len -ne 0 ]
3766 \xcall read_mline_res
3769 define _work {
3770 vput vexpr i + 1 "$2"
3771 if [ $i -lt 111 ]
3772 vput vexpr j % $i 10
3773 if [ $j -ne 0 ]
3774 set j=xcall
3775 else
3776 echon "$i.. "
3777 set j=call
3779 eval \\$j _work $1 $i
3780 return $?
3782 vput vexpr i + $i "$1"
3783 return $i
3785 define _read {
3786 wysh set line; read line;wysh set es=$? en=$^ERRNAME ;\
3787 echo read:$es/$en: $line
3788 if [ "${es}" -ne -1 ]
3789 xcall _read
3791 readctl remove $cwd/.treadctl; echo readctl remove:$?/$^ERRNAME
3793 define t_ocs {
3794 read ver
3795 echo t_ocs
3796 echo "~^header list"; read hl; echo $hl;\
3797 vput vexpr es substr "$hl" 0 1
3798 if [ "$es" != 2 ]
3799 xcall bail "header list"
3800 endif
3802 call _work 1; echo $?
3803 echo "~^header insert cc splicy diet <splice@exam.ple> spliced";\
3804 read es; echo $es; vput vexpr es substr "$es" 0 1
3805 if [ "$es" != 2 ]
3806 xcall bail "be diet"
3807 endif
3808 echo "~^header insert cc <splice2@exam.ple>";\
3809 read es; echo $es; vput vexpr es substr "$es" 0 1
3810 if [ "$es" != 2 ]
3811 xcall bail "be diet2"
3812 endif
3814 call _work 2; echo $?
3815 echo "~^header insert bcc juicy juice <juice@exam.ple> spliced";\
3816 read es; echo $es;vput vexpr es substr "$es" 0 1
3817 if [ "$es" != 2 ]
3818 xcall bail "be juicy"
3819 endif
3820 echo "~^header insert bcc juice2@exam.ple";\
3821 read es; echo $es;vput vexpr es substr "$es" 0 1
3822 if [ "$es" != 2 ]
3823 xcall bail "be juicy2"
3824 endif
3825 echo "~^header insert bcc juice3 <juice3@exam.ple>";\
3826 read es; echo $es;vput vexpr es substr "$es" 0 1
3827 if [ "$es" != 2 ]
3828 xcall bail "be juicy3"
3829 endif
3830 echo "~^header insert bcc juice4@exam.ple";\
3831 read es; echo $es;vput vexpr es substr "$es" 0 1
3832 if [ "$es" != 2 ]
3833 xcall bail "be juicy4"
3834 endif
3836 echo "~^header remove-at bcc 3";\
3837 read es; echo $es;vput vexpr es substr "$es" 0 1
3838 if [ "$es" != 2 ]
3839 xcall bail "remove juicy5"
3840 endif
3841 echo "~^header remove-at bcc 2";\
3842 read es; echo $es;vput vexpr es substr "$es" 0 1
3843 if [ "$es" != 2 ]
3844 xcall bail "remove juicy6"
3845 endif
3846 echo "~^header remove-at bcc 3";\
3847 read es; echo $es;vput vexpr es substr "$es" 0 3
3848 if [ "$es" != 501 ]
3849 xcall bail "failed to remove-at"
3850 endif
3851 # Add duplicates which ought to be removed!
3852 echo "~^header insert bcc juice4@exam.ple";\
3853 read es; echo $es;vput vexpr es substr "$es" 0 1
3854 if [ "$es" != 2 ]
3855 xcall bail "be juicy4-1"
3856 endif
3857 echo "~^header insert bcc juice4@exam.ple";\
3858 read es; echo $es;vput vexpr es substr "$es" 0 1
3859 if [ "$es" != 2 ]
3860 xcall bail "be juicy4-2"
3861 endif
3862 echo "~^header insert bcc juice4@exam.ple";\
3863 read es; echo $es;vput vexpr es substr "$es" 0 1
3864 if [ "$es" != 2 ]
3865 xcall bail "be juicy4-3"
3866 endif
3867 echo "~:set t_ocs"
3870 call _work 3; echo $?
3871 echo "~r - '__EOT'"
3872 vput ! i echo just knock if you can hear me;\
3873 i=0;\
3874 while [ $i -lt 24 ]; do printf "%s " $i; i=`expr $i + 1`; done;\
3875 echo relax
3876 echon shell-cmd says $?/$^ERRNAME: $i
3877 echo "~x will not become interpreted, we are reading until __EOT"
3878 echo "__EOT"
3879 read r_status; echo "~~r status output: $r_status"
3880 echo "~:echo $? $! $^ERRNAME"
3881 read r_status
3882 echo "~~r status from parent: $r_status"
3885 call _work 4; echo $?
3886 vput cwd cwd;echo cwd:$?
3887 readctl create $cwd/.treadctl ;echo readctl:$?/$^ERRNAME;\
3888 call _read
3891 call _work 5; echo $?
3892 echo "~^header show MAILX-Command"; read es;\
3893 call xerr $es "t_header 1000"; call read_mline_res
3894 echo "~^header show MAILX-raw-TO"; read es;\
3895 call xerr $es "t_header 1001"; xcall read_mline_res
3897 echoerr IT IS WRONG IF YOU SEE THIS
3899 define t_oce {
3900 echo on-compose-enter, mailx-command<$mailx-command>
3901 set t_oce autobcc=oce@exam.ple
3902 alternates alter1@exam.ple alter2@exam.ple
3903 alternates
3904 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3905 echo mailx-subject<$mailx-subject>
3906 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3907 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3908 mailx-raw-bcc<$mailx-raw-bcc>
3909 echo mailx-orig-from<$mailx-orig-from> \
3910 mailx-orig-to<$mailx-orig-to> \
3911 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3913 define t_ocl {
3914 echo on-compose-leave, mailx-command<$mailx-command>
3915 set t_ocl autocc=ocl@exam.ple
3916 unalternates *
3917 alternates alter3@exam.ple alter4@exam.ple
3918 alternates
3919 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3920 echo mailx-subject<$mailx-subject>
3921 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3922 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3923 mailx-raw-bcc<$mailx-raw-bcc>
3924 echo mailx-orig-from<$mailx-orig-from> \
3925 mailx-orig-to<$mailx-orig-to> \
3926 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3928 define t_occ {
3929 echo on-compose-cleanup, mailx-command<$mailx-command>
3930 set t_occ autocc=occ@exam.ple
3931 unalternates *
3932 alternates
3933 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3934 echo mailx-subject<$mailx-subject>
3935 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3936 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3937 mailx-raw-bcc<$mailx-raw-bcc>
3938 echo mailx-orig-from<$mailx-orig-from> \
3939 mailx-orig-to<$mailx-orig-to> \
3940 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3942 wysh set on-compose-splice=t_ocs \
3943 on-compose-splice-shell="read ver;echo t_ocs-shell;\
3944 echo \"~t shell@exam.ple\"; echo \"~:set t_ocs_sh\"" \
3945 on-compose-enter=t_oce on-compose-leave=t_ocl \
3946 on-compose-cleanup=t_occ
3947 ' > ./.tnotes 2>&1
3948 ex0_test behave:compose_hooks-3-estat
3949 ${cat} ./.tnotes >> "${MBOX}"
3951 check behave:compose_hooks-3 - "${MBOX}" '679526364 2431'
3953 # Reply, forward, resend, Resend
3955 ${rm} -f "${MBOX}"
3956 printf 'set from=f1@z\nm t1@z\nb1\n!.\nset from=f2@z\nm t2@z\nb2\n!.\n' |
3957 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! \
3958 -Smta=./.tsendmail.sh
3960 printf '
3961 echo start: $? $! $^ERRNAME
3962 File %s
3963 echo File: $? $! $^ERRNAME;echo;echo
3964 reply 1
3965 this is content of reply 1
3967 echo reply 1: $? $! $^ERRNAME;echo;echo
3968 Reply 1 2
3969 this is content of Reply 1 2
3971 echo Reply 1 2: $? $! $^ERRNAME;echo;echo
3972 forward 1 fwdex@am.ple
3973 this is content of forward 1
3975 echo forward 1: $? $! $^ERRNAME;echo;echo
3976 resend 1 2 resendex@am.ple
3977 echo resend 1 2: $? $! $^ERRNAME;echo;echo
3978 Resend 1 2 Resendex@am.ple
3979 echo Resend 1 2: $? $! $^ERRNAME;echo;echo
3980 ' "${MBOX}" |
3981 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! \
3982 -Smta=./.tsendmail.sh \
3984 define bail {
3985 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
3987 define xerr {
3988 vput vexpr es substr "$1" 0 1
3989 if [ "$es" != 2 ]
3990 xcall bail "$2"
3993 define read_mline_res {
3994 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
3995 echo mline_res:$len/$es/$^ERRNAME: $hl
3996 if [ $es -ne $^ERR-NONE ]
3997 xcall bail read_mline_res
3998 elif [ $len -ne 0 ]
3999 \xcall read_mline_res
4002 define work_hl {
4003 echo "~^header show $1"; read es;\
4004 call xerr $es "work_hl $1"; echo $1; call read_mline_res
4005 if [ $# -gt 1 ]
4006 shift
4007 xcall work_hl "$@"
4010 define t_ocs {
4011 read ver
4012 echo t_ocs version $ver
4013 echo "~^header list"; read hl; echo $hl;\
4014 echoerr the header list is $hl;\
4015 call xerr "$hl" "header list"
4016 eval vpospar set $hl
4017 shift
4018 xcall work_hl "$@"
4019 echoerr IT IS WRONG IF YOU SEE THIS
4021 define t_oce {
4022 echo on-XY-enter, mailx-command<$mailx-command>
4023 set t_oce autobcc=oce@exam.ple
4024 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
4025 echo mailx-subject<$mailx-subject>
4026 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
4027 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
4028 mailx-raw-bcc<$mailx-raw-bcc>
4029 echo mailx-orig-from<$mailx-orig-from> \
4030 mailx-orig-to<$mailx-orig-to> \
4031 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
4033 define t_ocl {
4034 echo on-XY-leave, mailx-command<$mailx-command>
4035 set t_ocl autocc=ocl@exam.ple
4036 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
4037 echo mailx-subject<$mailx-subject>
4038 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
4039 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
4040 mailx-raw-bcc<$mailx-raw-bcc>
4041 echo mailx-orig-from<$mailx-orig-from> \
4042 mailx-orig-to<$mailx-orig-to> \
4043 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
4045 define t_occ {
4046 echo on-XY-cleanup, mailx-command<$mailx-command>
4047 set t_occ autocc=occ@exam.ple
4048 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
4049 echo mailx-subject<$mailx-subject>
4050 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
4051 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
4052 mailx-raw-bcc<$mailx-raw-bcc>
4053 echo mailx-orig-from<$mailx-orig-from> \
4054 mailx-orig-to<$mailx-orig-to> \
4055 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
4057 wysh set on-compose-splice=t_ocs \
4058 on-compose-enter=t_oce on-compose-leave=t_ocl \
4059 on-compose-cleanup=t_occ \
4060 on-resend-enter=t_oce on-resend-cleanup=t_occ
4061 ' > ./.tnotes 2>&1
4062 ex0_test behave:compose_hooks-4-estat
4063 ${cat} ./.tnotes >> "${MBOX}"
4065 check behave:compose_hooks-4 - "${MBOX}" '3038884027 7516'
4067 t_epilog
4070 t_behave_C_opt_customhdr() {
4071 t_prolog t_behave_C_opt_customhdr
4072 TRAP_EXIT_ADDONS="./.t*"
4074 ${cat} <<-_EOT > ./.tsendmail.sh
4075 #!${SHELL} -
4076 (echo 'From CimicifugaRacemosa Mon Dec 25 21:33:40 2017' &&
4077 ${cat} && echo
4078 ) >> "${MBOX}"
4079 _EOT
4080 chmod 0755 ./.tsendmail.sh
4082 echo bla |
4083 ${MAILX} ${ARGS} -Smta=./.tsendmail.sh \
4084 -C 'C-One : Custom One Body' \
4085 -C 'C-Two:CustomTwoBody' \
4086 -S customhdr='chdr1: chdr1 body, chdr2:chdr2 body' \
4087 this-goes@nowhere >./.tall 2>&1
4088 ex0_test behave:C_opt_customhdr-1-estat
4089 ${cat} ./.tall >> "${MBOX}"
4090 check behave:C_opt_customhdr-1 0 "${MBOX}" '2400078426 195'
4092 ${rm} -f "${MBOX}"
4093 printf 'm this-goes@nowhere\nbody\n!.
4094 unset customhdr
4095 m this-goes2@nowhere\nbody2\n!.
4096 set customhdr=%ccustom1 : custom1 body%c
4097 m this-goes2@nowhere\nbody2\n!.
4098 set customhdr=%ccustom1 : custom1\\, body , custom2: custom2 body%c
4099 m this-goes3@nowhere\nbody3\n!.
4100 ' "'" "'" "'" "'" |
4101 ${MAILX} ${ARGS} -Smta=./.tsendmail.sh -Sescape=! \
4102 -C 'C-One : Custom One Body' \
4103 -C 'C-Two:CustomTwoBody' \
4104 -S customhdr='chdr1: chdr1 body, chdr2:chdr2 body' \
4105 >./.tall 2>&1
4106 ex0_test behave:C_opt_customhdr-2-estat
4107 ${cat} ./.tall >> "${MBOX}"
4108 check behave:C_opt_customhdr-2 0 "${MBOX}" '3546878678 752'
4110 t_epilog
4113 t_behave_mass_recipients() {
4114 t_prolog t_behave_mass_recipients
4115 TRAP_EXIT_ADDONS="./.t*"
4117 ${cat} <<-_EOT > ./.tsendmail.sh
4118 #!${SHELL} -
4119 (echo 'From Eucalyptus Sat Jul 08 21:14:57 2017' && ${cat} && echo
4120 ) >> "${MBOX}"
4121 _EOT
4122 chmod 0755 ./.tsendmail.sh
4124 ${cat} <<'__EOT__' > ./.trc
4125 define bail {
4126 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
4128 define ins_addr {
4129 wysh set nr=$1 hn=$2
4130 echo "~$hn $hn$nr@$hn"; echo '~:echo $?'; read es
4131 if [ "$es" -ne 0 ]
4132 xcall bail "ins_addr $hn 1-$nr"
4134 vput vexpr nr + $nr 1
4135 if [ "$nr" -le "$maximum" ]
4136 xcall ins_addr $nr $hn
4139 define bld_alter {
4140 wysh set nr=$1 hn=$2
4141 alternates $hn$nr@$hn
4142 vput vexpr nr + $nr 2
4143 if [ "$nr" -le "$maximum" ]
4144 xcall bld_alter $nr $hn
4147 define t_ocs {
4148 read ver
4149 call ins_addr 1 t
4150 call ins_addr 1 c
4151 call ins_addr 1 b
4153 define t_ocl {
4154 if [ "$t_remove" != '' ]
4155 call bld_alter 1 t
4156 call bld_alter 2 c
4159 set on-compose-splice=t_ocs on-compose-leave=t_ocl
4160 __EOT__
4162 printf 'm this-goes@nowhere\nbody\n!.\n' |
4163 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
4164 -X'source ./.trc' -Smta=./.tsendmail.sh -Smaximum=2001 \
4165 >./.tall 2>&1
4166 ex0_test behave:mass_recipients-1-estat
4167 ${cat} ./.tall >> "${MBOX}"
4168 check behave:mass_recipients-1 - "${MBOX}" '2912243346 51526'
4170 ${rm} -f "${MBOX}"
4171 printf 'm this-goes@nowhere\nbody\n!.\n' |
4172 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
4173 -St_remove=1 -X'source ./.trc' -Smta=./.tsendmail.sh -Smaximum=2001 \
4174 >./.tall 2>&1
4175 ex0_test behave:mass_recipients-2-estat
4176 ${cat} ./.tall >> "${MBOX}"
4177 check behave:mass_recipients-2 - "${MBOX}" '4097804632 34394'
4179 t_epilog
4182 t_behave_mime_types_load_control() {
4183 t_prolog t_behave_mime_types_load_control
4184 if have_feat uistrings; then :; else
4185 echo 'behave:mime_types_load_control: unsupported, skipped'
4186 return
4188 TRAP_EXIT_ADDONS="./.t*"
4190 ${cat} <<-_EOT > ./.tmts1
4191 @ application/mathml+xml mathml
4192 _EOT
4193 ${cat} <<-_EOT > ./.tmts2
4194 @ x-conference/x-cooltalk ice
4195 @ aga-aga aga
4196 @ application/aga-aga aga
4197 _EOT
4199 ${cat} <<-_EOT > ./.tmts1.mathml
4200 <head>nonsense ML</head>
4201 _EOT
4202 ${cat} <<-_EOT > ./.tmts2.ice
4203 Icy, icy road.
4204 _EOT
4205 printf 'of which the c\x01rack is coming soon' > ./.tmtsx.doom
4206 printf 'of which the c\x01rack is coming soon' > ./.tmtsx.aga
4208 printf '
4209 m %s
4210 Schub-di-du
4211 ~@ ./.tmts1.mathml
4212 ~@ ./.tmts2.ice
4213 ~@ ./.tmtsx.doom
4214 ~@ ./.tmtsx.aga
4216 File %s
4217 from*
4218 type
4220 ' "${MBOX}" "${MBOX}" |
4221 ${MAILX} ${ARGS} \
4222 -Smimetypes-load-control=f=./.tmts1,f=./.tmts2 \
4223 > ./.tout 2>&1
4224 ex0_test behave:mime_types_load_control-1-estat
4225 ${cat} "${MBOX}" >> ./.tout
4226 check behave:mime_types_load_control-1 - ./.tout '1441260727 2449'
4228 echo type | ${MAILX} ${ARGS} -R \
4229 -Smimetypes-load-control=f=./.tmts1,f=./.tmts3 \
4230 -f "${MBOX}" >> ./.tout 2>&1
4231 check behave:mime_types_load_control-2 0 ./.tout '1441391438 3646'
4233 t_epilog
4236 t_behave_lreply_futh_rth_etc() {
4237 t_prolog t_behave_lreply_futh_rth_etc
4238 TRAP_EXIT_ADDONS="./.t*"
4240 ${cat} <<-_EOT > ./.tsendmail.sh
4241 #!${SHELL} -
4242 (echo 'From HumulusLupulus Thu Jul 27 14:41:20 2017' && ${cat} && echo
4243 ) >> "${MBOX}"
4244 _EOT
4245 chmod 0755 ./.tsendmail.sh
4247 ${cat} <<-_EOT > ./.tmbox
4248 From neverneverland Sun Jul 23 13:46:25 2017
4249 Subject: Bugstop: five miles out 1
4250 Reply-To: mister originator2 <mr2@originator>, bugstop@five.miles.out
4251 From: mister originator <mr@originator>
4252 To: bugstop-commit@five.miles.out, laber@backe.eu
4253 Cc: is@a.list
4254 Mail-Followup-To: bugstop@five.miles.out, laber@backe.eu, is@a.list
4255 In-reply-to: <20170719111113.bkcMz%laber@backe.eu>
4256 Date: Wed, 19 Jul 2017 09:22:57 -0400
4257 Message-Id: <20170719132257.766AF781267@originator>
4258 Status: RO
4260 > |Sorry, I think I misunderstand something. I would think that
4262 That's appalling.
4264 From neverneverland Fri Jul 7 22:39:11 2017
4265 Subject: Bugstop: five miles out 2
4266 Reply-To: mister originator2<mr2@originator>,bugstop@five.miles.out,is@a.list
4267 Content-Transfer-Encoding: 7bit
4268 From: mister originator <mr@originator>
4269 To: bugstop-commit@five.miles.out
4270 Cc: is@a.list
4271 Message-ID: <149945963975.28888.6950788126957753723.reportbug@five.miles.out>
4272 Date: Fri, 07 Jul 2017 16:33:59 -0400
4273 Status: R
4275 capable of changing back.
4277 From neverneverland Fri Jul 7 22:42:00 2017
4278 Subject: Bugstop: five miles out 3
4279 Reply-To: mister originator2 <mr2@originator>, bugstop@five.miles.out
4280 Content-Transfer-Encoding: 7bit
4281 From: mister originator <mr@originator>
4282 To: bugstop-commit@five.miles.out
4283 Cc: is@a.list
4284 Message-ID: <149945963975.28888.6950788126957753746.reportbug@five.miles.out>
4285 Date: Fri, 07 Jul 2017 16:33:59 -0400
4286 List-Post: <mailto:bugstop@five.miles.out>
4287 Status: R
4289 are you ready, boots?
4291 From neverneverland Sat Aug 19 23:15:00 2017
4292 Subject: Bugstop: five miles out 4
4293 Reply-To: mister originator2 <mr2@originator>, bugstop@five.miles.out
4294 Content-Transfer-Encoding: 7bit
4295 From: mister originator <mr@originator>
4296 To: bugstop@five.miles.out
4297 Cc: is@a.list
4298 Message-ID: <149945963975.28888.6950788126qtewrqwer.reportbug@five.miles.out>
4299 Date: Fri, 07 Jul 2017 16:33:59 -0400
4300 List-Post: <mailto:bugstop@five.miles.out>
4301 Status: R
4303 are you ready, boots?
4304 _EOT
4308 ${cat} <<-'_EOT' | ${MAILX} ${ARGS} -Sescape=! -Smta=./.tsendmail.sh \
4309 -Rf ./.tmbox >> "${MBOX}" 2>&1
4310 define r {
4311 wysh set m="This is text of \"reply ${1}."
4312 reply 1 2 3
4313 !I m
4316 !I m
4319 !I m
4322 echo -----After reply $1.1 - $1.3: $?/$^ERRNAME
4324 define R {
4325 wysh set m="This is text of \"Reply ${1}."
4326 eval Reply $2
4327 !I m
4328 !I 2
4331 echo -----After Reply $1.$2: $?/$^ERRNAME
4333 define _Lh {
4334 read protover
4335 echo '~I m'
4336 echo '~I n'
4337 echo '".'
4339 define _Ls {
4340 wysh set m="This is text of \"Lreply ${1}." on-compose-splice=_Lh n=$2
4341 eval Lreply $2
4343 define L {
4344 # We need two indirections for this test: one for the case that Lreply
4345 # fails because of missing recipients: we need to read EOF next, thus
4346 # place this in _Ls last; and second for the succeeding cases EOF is
4347 # not what these should read, so go over the backside and splice it in!
4348 call _Ls "$@"
4349 echo -----After Lreply $1.$2: $?/$^ERRNAME
4351 define x {
4352 localopts call-fixate yes
4353 call r $1
4354 call R $1 1; call R $1 2; call R $1 3; call R $1 4
4355 call L $1 1; call L $1 2; call L $1 3
4357 define tweak {
4358 echo;echo '===== CHANGING === '"$*"' =====';echo
4359 eval "$@"
4362 set from=laber@backe.eu
4363 mlist is@a.list
4364 call x 1
4365 call tweak set reply-to-honour
4366 call x 2
4367 call tweak set followup-to
4368 call x 3
4369 call tweak set followup-to-honour
4370 call x 4
4371 call tweak mlist bugstop@five.miles.out
4372 call x 5
4373 call tweak mlsubscribe bugstop@five.miles.out
4374 call x 6
4375 call tweak set recipients-in-cc
4376 call x 7
4377 _EOT
4379 ex0_test behave:lreply_futh_rth_etc-1-estat
4380 if have_feat uistrings; then # xxx should not be so, skip??
4381 check behave:lreply_futh_rth_etc-1 - "${MBOX}" '940818845 29373'
4382 else
4383 check behave:lreply_futh_rth_etc-1 - "${MBOX}" '3917430455 29259'
4388 ${cat} <<-_EOT > ./.tmbox
4389 From tom@i-i.example Thu Oct 26 03:15:55 2017
4390 Date: Wed, 25 Oct 2017 21:15:46 -0400
4391 From: tom <tom@i-i.example>
4392 To: Steffen Nurpmeso <steffen@sdaoden.eu>
4393 Cc: tom <tom@i-i.example>
4394 Subject: Re: xxxx yyyyyyyy configure does not really like a missing zzzzz
4395 Message-ID: <20171026011546.GA11643@i-i.example>
4396 Reply-To: tom@i-i.example
4397 References: <20171025214601.T2pNd%steffen@sdaoden.eu>
4398 In-Reply-To: <20171025214601.T2pNd%steffen@sdaoden.eu>
4399 Status: R
4401 The report's useful :-)
4402 _EOT
4404 printf 'reply 1\nthank you\n!.\n' |
4405 ${MAILX} ${ARGS} -Sescape=! -Smta=./.tsendmail.sh -Sreply-to-honour \
4406 -Rf ./.tmbox > "${MBOX}" 2>&1
4407 check behave:lreply_futh_rth_etc-2 0 "${MBOX}" '1045866991 331'
4409 t_epilog
4412 t_behave_mime_if_not_ascii() {
4413 t_prolog t_behave_mime_if_not_ascii
4415 </dev/null ${MAILX} ${ARGS} -s Subject "${MBOX}" >> "${MBOX}" 2>&1
4416 check behave:mime_if_not_ascii-1 0 "${MBOX}" '2287855519 110'
4418 </dev/null ${MAILX} ${ARGS} -Scharset-7bit=not-ascii -s Subject "${MBOX}" \
4419 >> "${MBOX}" 2>&1
4420 check behave:mime_if_not_ascii-2 0 "${MBOX}" '70754682 282'
4422 t_epilog
4425 t_behave_xxxheads_rfc2047() {
4426 t_prolog t_behave_xxxheads_rfc2047
4427 TRAP_EXIT_ADDONS="./.t*"
4429 ${cat} <<-_EOT > ./.tsendmail.sh
4430 #!${SHELL} -
4431 (echo 'From GentianaLutea Mon Dec 04 17:15:29 2017' && ${cat} &&
4432 echo) >> "${MBOX}"
4433 _EOT
4434 chmod 0755 ./.tsendmail.sh
4437 ${rm} -f "${MBOX}"
4438 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
4439 -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̲' \
4440 "${MBOX}"
4441 check behave:xxxheads_rfc2047-1 0 "${MBOX}" '3370931614 375'
4443 # Single word (overlong line split -- bad standard! Requires injection of
4444 # artificial data!! But can be prevented by using RFC 2047 encoding)
4445 ${rm} -f "${MBOX}"
4446 i=`${awk} 'BEGIN{for(i=0; i<92; ++i) printf "0123456789_"}'`
4447 echo | ${MAILX} ${ARGS} -s "${i}" "${MBOX}"
4448 check behave:xxxheads_rfc2047-2 0 "${MBOX}" '489922370 1718'
4450 # Combination of encoded words, space and tabs of varying sort
4451 ${rm} -f "${MBOX}"
4452 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
4453 -s "1Abrä Kaspas1 2Abra Katä b_kaspas2 \
4454 3Abrä Kaspas3 4Abrä Kaspas4 5Abrä Kaspas5 \
4455 6Abra Kaspas6 7Abrä Kaspas7 8Abra Kaspas8 \
4456 9Abra Kaspastäb4-3 10Abra Kaspas1 _ 11Abra Katäb1 \
4457 12Abra Kadabrä1 After Tab after Täb this is NUTS" \
4458 "${MBOX}"
4459 check behave:xxxheads_rfc2047-3 0 "${MBOX}" '1676887734 591'
4461 # Overlong multibyte sequence that must be forcefully split
4462 # todo This works even before v15.0, but only by accident
4463 ${rm} -f "${MBOX}"
4464 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
4465 -s "✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
4466 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
4467 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄" \
4468 "${MBOX}"
4469 check behave:xxxheads_rfc2047-4 0 "${MBOX}" '3029301775 659'
4471 # Trailing WS
4472 ${rm} -f "${MBOX}"
4473 echo | ${MAILX} ${ARGS} \
4474 -s "1-1 B2 B3 B4 B5 B6 B\
4475 1-2 B2 B3 B4 B5 B6 B\
4476 1-3 B2 B3 B4 B5 B6 B\
4477 1-4 B2 B3 B4 B5 B6 B\
4478 1-5 B2 B3 B4 B5 B6 B\
4479 1-6 B2 B3 B4 B5 B6 " \
4480 "${MBOX}"
4481 check behave:xxxheads_rfc2047-5 0 "${MBOX}" '4126167195 297'
4483 # Leading and trailing WS
4484 ${rm} -f "${MBOX}"
4485 echo | ${MAILX} ${ARGS} \
4486 -s " 2-1 B2 B3 B4 B5 B6 B\
4487 1-2 B2 B3 B4 B5 B6 B\
4488 1-3 B2 B3 B4 B5 B6 B\
4489 1-4 B2 B3 B4 B5 B6 " \
4490 "${MBOX}"
4491 check behave:xxxheads_rfc2047-6 0 "${MBOX}" '3600624479 236'
4493 # RFC 2047 in an address field! (Missing test caused v14.9.6!)
4494 ${rm} -f "${MBOX}"
4495 echo "Dat Früchtchen riecht häußlich" |
4496 ${MAILX} ${ARGS} ${ADDARG_UNI} -Sfullnames -Smta=./.tsendmail.sh \
4497 -s Hühöttchen \
4498 'Schnödes "Früchtchen" <do@du> (Hä!)'
4499 check behave:xxxheads_rfc2047-7 0 "${MBOX}" '800505986 368'
4501 # RFC 2047 in an address field, and iconv involved
4502 if have_feat iconv; then
4503 ${rm} -f "${MBOX}"
4504 ${cat} > ./.trebox <<_EOT
4505 From zaza@exam.ple Fri Mar 2 21:31:56 2018
4506 Date: Fri, 2 Mar 2018 20:31:45 +0000
4507 From: z=?iso-8859-1?Q?=E1?=za <zaza@exam.ple>
4508 To: dude <dude@exam.ple>
4509 Subject: houston(...)
4510 Message-ID: <abra@1>
4511 MIME-Version: 1.0
4512 Content-Type: text/plain; charset=iso-8859-1
4513 Content-Disposition: inline
4514 Content-Transfer-Encoding: 8bit
4516 _EOT
4517 echo reply | ${MAILX} ${ARGS} ${ADDARG_UNI} \
4518 -Sfullnames -Sreply-in-same-charset \
4519 -Smta=./.tsendmail.sh -Rf ./.trebox
4520 check behave:xxxheads_rfc2047-8 0 "${MBOX}" '2821484185 280'
4521 else
4522 echo 'behave:xxxheads_rfc2047-8: iconv unsupported, skipped'
4525 t_epilog
4528 t_behave_rfc2231() {
4529 t_prolog t_behave_rfc2231
4530 TRAP_EXIT_ADDONS="./.t*"
4533 mkdir ./.ttt || exit 1
4534 cd ./.ttt || exit 2
4535 : > "ma'ger.txt"
4536 : > "mä'ger.txt"
4537 : > 'diet\ is \curd.txt'
4538 : > 'diet "is" curd.txt'
4539 : > höde-tröge.txt
4540 : > 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
4541 : > höde__tröge__müde__dätte__hätte__vuelle__guelle__aese__aesse__sauerliche__kräuter__österliche__grüße__mäh.txt
4542 : > hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt
4543 : > ✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt
4545 echo bla | ${MAILX} ${ARGS} ${ADDARG_UNI} \
4546 -a "./.ttt/ma'ger.txt" -a "./.ttt/mä'ger.txt" \
4547 -a './.ttt/diet\ is \curd.txt' -a './.ttt/diet "is" curd.txt' \
4548 -a ./.ttt/höde-tröge.txt \
4549 -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 \
4550 -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 \
4551 -a ./.ttt/hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt \
4552 -a ./.ttt/✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt \
4553 "${MBOX}"
4554 check behave:rfc2231-1 0 "${MBOX}" '684985954 3092'
4556 # `resend' test, reusing $MBOX
4557 printf "Resend ./.t2\nx\n" | ${MAILX} ${ARGS} -Rf "${MBOX}"
4558 check behave:rfc2231-2 0 ./.t2 '684985954 3092'
4560 printf "resend ./.t3\nx\n" | ${MAILX} ${ARGS} -Rf "${MBOX}"
4561 check behave:rfc2231-3 0 ./.t3 '3130352658 3148'
4563 t_epilog
4566 t_behave_iconv_mbyte_base64() { # TODO uses sed(1) and special *headline*!!
4567 t_prolog t_behave_iconv_mbyte_base64
4568 TRAP_EXIT_ADDONS="./.t*"
4570 if [ -n "${UTF8_LOCALE}" ] && have_feat iconv; then
4571 if (</dev/null iconv -f ascii -t iso-2022-jp) >/dev/null 2>&1 ||
4572 (</dev/null iconv -f ascii -t euc-jp) >/dev/null 2>&1; then
4574 else
4575 echo 'behave:iconv_mbyte_base64: unsupported, skipped'
4576 return
4578 else
4579 echo 'behave:iconv_mbyte_base64: unsupported, skipped'
4580 return
4583 ${cat} <<-_EOT > ./.tsendmail.sh
4584 #!${SHELL} -
4585 (echo 'From DroseriaRotundifolia Thu Aug 03 17:26:25 2017' && ${cat} &&
4586 echo) >> "${MBOX}"
4587 _EOT
4588 chmod 0755 ./.tsendmail.sh
4590 if (</dev/null iconv -f ascii -t iso-2022-jp) >/dev/null 2>&1; then
4591 ${cat} <<-'_EOT' | LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} \
4592 -Smta=./.tsendmail.sh \
4593 -Sescape=! -Smime-encoding=base64 2>./.terr
4594 set ttycharset=utf-8 sendcharsets=iso-2022-jp
4595 m t1@exam.ple
4596 !s Japanese from UTF-8 to ISO-2022-JP
4597 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
4599 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
4602 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
4604 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
4607 set ttycharset=iso-2022-jp charset-7bit=iso-2022-jp sendcharsets=utf-8
4608 m t2@exam.ple
4609 !s Japanese from ISO-2022-JP to UTF-8, eh, no, also ISO-2022-JP
4610 \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
4612 \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
4615 \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
4617 \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
4619 _EOT
4620 # May not presume iconv output as long as roundtrip possible [489a7122]
4621 ex0_test behave:iconv_mbyte_base64-1-estat
4622 ${awk} 'BEGIN{h=1}/^$/{++h;next}{if(h % 2 == 1)print}' \
4623 < "${MBOX}" > ./.tcksum
4624 check behave:iconv_mbyte_base64-1 - ./.tcksum '2694609714 520'
4625 check behave:iconv_mbyte_base64-2 - ./.terr '4294967295 0'
4627 printf 'eval f 1; eval write ./.twrite; eval type 1; eval type 2\n' |
4628 LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} \
4629 -S headline="%>%a%m %-18f %-16d %i%-s" \
4630 -Rf "${MBOX}" >./.tlog 2>&1
4631 check behave:iconv_mbyte_base64-3 0 ./.twrite '1259742080 686'
4632 #check behave:iconv_mbyte_base64-4 - ./.tlog '3214068822 2123'
4633 ${sed} -e '/^\[-- M/d' < ./.tlog > ./.txlog
4634 check behave:iconv_mbyte_base64-4 - ./.txlog '3659773472 2035'
4635 else
4636 echo 'behave:iconv_mbyte_base64: ISO-2022-JP unsupported, skipping 1-4'
4639 if (</dev/null iconv -f ascii -t euc-jp) >/dev/null 2>&1; then
4640 rm -f "${MBOX}" ./.twrite
4641 ${cat} <<-'_EOT' | LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} \
4642 -Smta=./.tsendmail.sh \
4643 -Sescape=! -Smime-encoding=base64 2>./.terr
4644 set ttycharset=utf-8 sendcharsets=euc-jp
4645 m t1@exam.ple
4646 !s Japanese from UTF-8 to EUC-JP
4647 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
4649 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
4652 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
4654 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
4657 set ttycharset=EUC-JP sendcharsets=utf-8
4658 m t2@exam.ple
4659 !s Japanese from EUC-JP to UTF-8
4660 ¥·¥¸¥å¥¦¥«¥é²Ê¡Ê¥·¥¸¥å¥¦¥«¥é¤«¡¢³Ø̾ Paridae¡Ë¤Ï¡¢Ä»Îॹ¥º¥áÌܤβʤǤ¢¤ë¡£¥·¥¸¥å¥¦¥«¥é¡Ê»Í½½¿ý¡Ë¤ÈÁí¾Î¤µ¤ì¤ë¤¬¡¢¶¹µÁ¤Ë¤Ï¤³¤Î1¼ï¤ò¥·¥¸¥å¥¦¥«¥é¤È¸Æ¤Ö¡£
4662 ¥«¥ó¥à¥ê¥¬¥é¡Ê³Ø̾Parus cristatus¡Ë¤Ï¡¢¥¹¥º¥áÌÜ¥·¥¸¥å¥¦¥«¥é²Ê¤ËʬÎव¤ì¤ëÄ»Îà¤Î°ì¼ï¡£
4665 ¥«¥ó¥à¥ê¥¬¥é¡Ê³Ø̾Parus cristatus¡Ë¤Ï¡¢¥¹¥º¥áÌÜ¥·¥¸¥å¥¦¥«¥é²Ê¤ËʬÎव¤ì¤ëÄ»Îà¤Î°ì¼ï¡£
4667 ¥·¥¸¥å¥¦¥«¥é²Ê¡Ê¥·¥¸¥å¥¦¥«¥é¤«¡¢³Ø̾ Paridae¡Ë¤Ï¡¢Ä»Îॹ¥º¥áÌܤβʤǤ¢¤ë¡£¥·¥¸¥å¥¦¥«¥é¡Ê»Í½½¿ý¡Ë¤ÈÁí¾Î¤µ¤ì¤ë¤¬¡¢¶¹µÁ¤Ë¤Ï¤³¤Î1¼ï¤ò¥·¥¸¥å¥¦¥«¥é¤È¸Æ¤Ö¡£
4669 _EOT
4670 ex0_test behave:iconv_mbyte_base64-5-estat
4671 ${awk} 'BEGIN{h=1}/^$/{++h;next}{if(h % 2 == 1)print}' \
4672 < "${MBOX}" > ./.tcksum
4673 check behave:iconv_mbyte_base64-5 - ./.tcksum '2870183985 473'
4674 check behave:iconv_mbyte_base64-6 - ./.terr '4294967295 0'
4676 printf 'eval f 1; eval write ./.twrite; eval type 1; eval type 2\n' |
4677 LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} \
4678 -S headline="%>%a%m %-18f %-16d %i%-s" \
4679 -Rf "${MBOX}" >./.tlog 2>&1
4680 check behave:iconv_mbyte_base64-7 0 ./.twrite '1259742080 686'
4681 #check behave:iconv_mbyte_base64-8 - ./.tlog '2506063395 2075'
4682 ${sed} -e '/^\[-- M/d' < ./.tlog > ./.txlog
4683 check behave:iconv_mbyte_base64-8 - ./.txlog '2528199891 1988'
4684 else
4685 echo 'behave:iconv_mbyte_base64: EUC-JP unsupported, skipping 5-8'
4688 t_epilog
4691 t_behave_iconv_mainbody() {
4692 t_prolog t_behave_iconv_mainbody
4693 TRAP_EXIT_ADDONS="./.t*"
4695 if [ -n "${UTF8_LOCALE}" ] && have_feat iconv; then
4697 else
4698 echo 'behave:iconv_mainbody: unsupported, skipped'
4699 return
4702 ${cat} <<-_EOT > ./.tsendmail.sh
4703 #!${SHELL} -
4704 (echo 'From HamamelisVirginiana Fri Oct 20 16:23:21 2017' && ${cat} &&
4705 echo) >> "${MBOX}"
4706 _EOT
4707 chmod 0755 ./.tsendmail.sh
4709 printf '–' | ${MAILX} ${ARGS} ${ADDARG_UNI} -Smta=./.tsendmail.sh \
4710 -S charset-7bit=us-ascii -S charset-8bit=utf-8 \
4711 -s '–' over-the@rain.bow 2>./.terr
4712 check behave:iconv_mainbody-1 0 "${MBOX}" '3634015017 251'
4713 check behave:iconv_mainbody-2 - ./.terr '4294967295 0'
4715 printf '–' | ${MAILX} ${ARGS} ${ADDARG_UNI} -Smta=./.tsendmail.sh \
4716 -S charset-7bit=us-ascii -S charset-8bit=us-ascii \
4717 -s '–' over-the@rain.bow 2>./.terr
4718 exn0_test behave:iconv_mainbody-3
4719 check behave:iconv_mainbody-3 - "${MBOX}" '3634015017 251'
4720 if have_feat uistrings; then
4721 if have_feat docstrings; then # xxx should not be like that
4722 check behave:iconv_mainbody-4 - ./.terr '2579894983 148'
4723 else
4724 check behave:iconv_mainbody-4 - ./.terr '271380835 121'
4726 else
4727 echo 'behave:iconv_mainbody-4: unsupported, skipped'
4730 # The different iconv(3) implementations use different replacement sequence
4731 # types (character-wise, byte-wise, and the character(s) used differ)
4732 i="${MAILX_ICONV_MODE}"
4733 if [ -n "${i}" ]; then
4734 printf 'p\nx\n' | ${MAILX} ${ARGS} -Rf "${MBOX}" >./.tout 2>./.terr
4735 j=${?}
4736 ex0_test behave:iconv_mainbody-5-0 ${j}
4737 check behave:iconv_mainbody-5-1 - ./.terr '4294967295 0'
4738 if [ ${i} -eq 13 ]; then
4739 check behave:iconv_mainbody-5-2 - ./.tout '189327996 283'
4740 elif [ ${i} -eq 12 ]; then
4741 check behave:iconv_mainbody-5-3 - ./.tout '1959197095 283'
4742 elif [ ${i} -eq 3 ]; then
4743 check behave:iconv_mainbody-5-4 - ./.tout '3196380198 279'
4744 else
4745 check behave:iconv_mainbody-5-5 - ./.tout '3760313827 279'
4747 else
4748 echo 'behave:iconv_mainbody-5: unsupported, skipped'
4751 t_epilog
4754 t_behave_binary_mainbody() {
4755 t_prolog t_behave_binary_mainbody
4756 TRAP_EXIT_ADDONS="./.t*"
4758 printf 'abra\0\nka\r\ndabra' |
4759 ${MAILX} ${ARGS} ${ADDARG_UNI} -s 'binary with carriage-return!' \
4760 "${MBOX}" 2>./.terr
4761 check behave:binary_mainbody-1 0 "${MBOX}" '2430168141 243'
4762 check behave:binary_mainbody-2 - ./.terr '4294967295 0'
4764 printf 'p\necho\necho writing now\nwrite ./.twrite\n' |
4765 ${MAILX} ${ARGS} -Rf \
4766 -Spipe-application/octet-stream="@* ${cat} > ./.tcat" \
4767 "${MBOX}" >./.tall 2>&1
4768 check behave:binary_mainbody-3 0 ./.tall '1151843761 324'
4769 check behave:binary_mainbody-4 - ./.tcat '3817108933 15'
4770 check behave:binary_mainbody-5 - ./.twrite '3817108933 15'
4772 t_epilog
4775 t_behave_q_t_etc_opts() {
4776 t_prolog t_behave_q_t_etc_opts
4777 TRAP_EXIT_ADDONS="./.t*"
4779 # Three tests for MIME encoding and (a bit) content classification.
4780 # At the same time testing -q FILE, < FILE and -t FILE
4781 t__put_body > ./.tin
4783 ${rm} -f "${MBOX}"
4784 < ./.tin ${MAILX} ${ARGS} ${ADDARG_UNI} \
4785 -a ./.tin -s "`t__put_subject`" "${MBOX}"
4786 check behave:q_t_etc_opts-1 0 "${MBOX}" '3570973309 6646'
4788 ${rm} -f "${MBOX}"
4789 < /dev/null ${MAILX} ${ARGS} ${ADDARG_UNI} \
4790 -a ./.tin -s "`t__put_subject`" -q ./.tin "${MBOX}"
4791 check behave:q_t_etc_opts-2 0 "${MBOX}" '3570973309 6646'
4793 ${rm} -f "${MBOX}"
4794 ( echo "To: ${MBOX}" && echo "Subject: `t__put_subject`" && echo &&
4795 ${cat} ./.tin
4796 ) | ${MAILX} ${ARGS} ${ADDARG_UNI} -Snodot -a ./.tin -t
4797 check behave:q_t_etc_opts-3 0 "${MBOX}" '3570973309 6646'
4799 t_epilog
4802 t_behave_s_mime() {
4803 have_feat smime || {
4804 echo 'behave:s/mime: unsupported, skipped'
4805 return
4808 t_prolog t_behave_s_mime
4809 TRAP_EXIT_ADDONS="./.t.conf ./.tkey.pem ./.tcert.pem ./.tpair.pem"
4810 TRAP_EXIT_ADDONS="${TRAP_EXIT_ADDONS} ./.VERIFY ./.DECRYPT ./.ENCRYPT"
4811 TRAP_EXIT_ADDONS="${TRAP_EXIT_ADDONS} ./.tsendmail.sh"
4813 printf 'behave:s/mime: .. generating test key and certificate ..\n'
4814 ${cat} <<-_EOT > ./.t.conf
4815 [ req ]
4816 default_bits = 1024
4817 default_keyfile = keyfile.pem
4818 distinguished_name = req_distinguished_name
4819 attributes = req_attributes
4820 prompt = no
4821 output_password =
4823 [ req_distinguished_name ]
4824 C = GB
4825 ST = Over the
4826 L = rainbow
4827 O = S-nail
4828 OU = S-nail.smime
4829 CN = S-nail.test
4830 emailAddress = test@localhost
4832 [ req_attributes ]
4833 challengePassword =
4834 _EOT
4835 openssl req -x509 -nodes -days 3650 -config ./.t.conf \
4836 -newkey rsa:1024 -keyout ./.tkey.pem -out ./.tcert.pem >>${ERR} 2>&1
4837 ${cat} ./.tkey.pem ./.tcert.pem > ./.tpair.pem
4839 # Sign/verify
4840 printf 'behave:s/mime:sign/verify: '
4841 echo bla | ${MAILX} ${ARGS} \
4842 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
4843 -Ssmime-sign -Sfrom=test@localhost \
4844 -s 'S/MIME test' ./.VERIFY
4845 if [ $? -eq 0 ]; then
4846 printf 'ok\n'
4847 else
4848 printf 'failed\n'
4849 ESTAT=1
4850 t_epilog
4851 return
4854 ${awk} '
4855 BEGIN{ skip=0 }
4856 /^Content-Description: /{ skip = 2; print; next }
4857 /^$/{ if(skip) --skip }
4858 { if(!skip) print }
4860 < ./.VERIFY > "${MBOX}"
4861 check behave:s/mime:sign/verify:checksum - "${MBOX}" '2900817158 648'
4863 printf 'behave:s/mime:sign/verify:verify '
4864 printf 'verify\nx\n' |
4865 ${MAILX} ${ARGS} \
4866 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
4867 -Ssmime-sign -Sfrom=test@localhost \
4868 -Serrexit -R \
4869 -f ./.VERIFY >>${ERR} 2>&1
4870 if [ $? -eq 0 ]; then
4871 printf 'ok\n'
4872 else
4873 printf 'failed\n'
4874 ESTAT=1
4875 t_epilog
4876 return
4879 printf 'behave:s/mime:sign/verify:disproof-1 '
4880 if openssl smime -verify -CAfile ./.tcert.pem \
4881 -in ./.VERIFY >>${ERR} 2>&1; then
4882 printf 'ok\n'
4883 else
4884 printf 'failed\n'
4885 ESTAT=1
4886 t_epilog
4887 return
4890 # (signing +) encryption / decryption
4891 ${cat} <<-_EOT > ./.tsendmail.sh
4892 #!${SHELL} -
4893 (echo 'From Euphrasia Thu Apr 27 17:56:23 2017' && ${cat}) > ./.ENCRYPT
4894 _EOT
4895 chmod 0755 ./.tsendmail.sh
4897 printf 'behave:s/mime:encrypt+sign: '
4898 echo bla |
4899 ${MAILX} ${ARGS} \
4900 -Ssmime-force-encryption \
4901 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
4902 -Smta=./.tsendmail.sh \
4903 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
4904 -Ssmime-sign -Sfrom=test@localhost \
4905 -s 'S/MIME test' recei@ver.com
4906 if [ $? -eq 0 ]; then
4907 printf 'ok\n'
4908 else
4909 ESTAT=1
4910 printf 'error: encrypt+sign failed\n'
4913 ${sed} -e '/^$/,$d' < ./.ENCRYPT > "${MBOX}"
4914 check behave:s/mime:encrypt+sign:checksum - "${MBOX}" '1937410597 327'
4916 printf 'behave:s/mime:decrypt+verify: '
4917 printf 'decrypt ./.DECRYPT\nfi ./.DECRYPT\nverify\nx\n' |
4918 ${MAILX} ${ARGS} \
4919 -Ssmime-force-encryption \
4920 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
4921 -Smta=./.tsendmail.sh \
4922 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
4923 -Ssmime-sign -Sfrom=test@localhost \
4924 -Serrexit -R \
4925 -f ./.ENCRYPT >>${ERR} 2>&1
4926 if [ $? -eq 0 ]; then
4927 printf 'ok\n'
4928 else
4929 ESTAT=1
4930 printf 'failed\n'
4933 ${awk} '
4934 BEGIN{ skip=0 }
4935 /^Content-Description: /{ skip = 2; print; next }
4936 /^$/{ if(skip) --skip }
4937 { if(!skip) print }
4939 < ./.DECRYPT > "${MBOX}"
4940 check behave:s/mime:decrypt+verify:checksum - "${MBOX}" '1720739247 931'
4942 printf 'behave:s/mime:decrypt+verify:disproof-1: '
4943 if (openssl smime -decrypt -inkey ./.tkey.pem -in ./.ENCRYPT |
4944 openssl smime -verify -CAfile ./.tcert.pem) >>${ERR} 2>&1; then
4945 printf 'ok\n'
4946 else
4947 printf 'failed\n'
4948 ESTAT=1
4951 printf "behave:s/mime:encrypt: "
4952 echo bla | ${MAILX} ${ARGS} \
4953 -Ssmime-force-encryption \
4954 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
4955 -Smta=./.tsendmail.sh \
4956 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
4957 -Sfrom=test@localhost \
4958 -s 'S/MIME test' recei@ver.com
4959 if [ $? -eq 0 ]; then
4960 printf 'ok\n'
4961 else
4962 ESTAT=1
4963 printf 'failed\n'
4966 # Same as behave:s/mime:encrypt+sign:checksum above
4967 ${sed} -e '/^$/,$d' < ./.ENCRYPT > "${MBOX}"
4968 check behave:s/mime:encrypt:checksum - "${MBOX}" '1937410597 327'
4970 ${rm} -f ./.DECRYPT
4971 printf 'decrypt ./.DECRYPT\nx\n' | ${MAILX} ${ARGS} \
4972 -Ssmime-force-encryption \
4973 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
4974 -Smta=./.tsendmail.sh \
4975 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
4976 -Sfrom=test@localhost \
4977 -Serrexit -R \
4978 -f ./.ENCRYPT >>${ERR} 2>&1
4979 check behave:s/mime:decrypt 0 "./.DECRYPT" '2624716890 422'
4981 printf 'behave:s/mime:decrypt:disproof-1: '
4982 if openssl smime -decrypt -inkey ./.tkey.pem \
4983 -in ./.ENCRYPT >>${ERR} 2>&1; then
4984 printf 'ok\n'
4985 else
4986 printf 'failed\n'
4987 ESTAT=1
4990 t_epilog
4993 # t_content()
4994 # xxx Note: t_content() was the first test (series) written. Today many
4995 # xxx aspects are (better) covered by other tests above, some are not.
4996 # xxx At some future date and time, convert the last remains not covered
4997 # xxx elsewhere to a real t_behave_* test and drop t_content()
4998 t_content() {
4999 t_prolog t_content
5001 # Test for [260e19d] (Juergen Daubert)
5002 ${rm} -f "${MBOX}"
5003 echo body | ${MAILX} ${ARGS} "${MBOX}"
5004 check content:004 0 "${MBOX}" '2917662811 98'
5006 # "Test for" [d6f316a] (Gavin Troy)
5007 ${rm} -f "${MBOX}"
5008 printf "m ${MBOX}\n~s subject1\nEmail body\n~.\nfi ${MBOX}\np\nx\n" |
5009 ${MAILX} ${ARGS} ${ADDARG_UNI} -Spipe-text/plain="@* ${cat}" > "${BODY}"
5010 check content:006 0 "${MBOX}" '2099098650 122'
5011 check content:006-1 - "${BODY}" '794542938 174'
5013 # "Test for" [c299c45] (Peter Hofmann) TODO shouldn't end up QP-encoded?
5014 ${rm} -f "${MBOX}"
5015 ${awk} 'BEGIN{
5016 for(i = 0; i < 10000; ++i)
5017 printf "\xC3\xBC"
5018 #printf "\xF0\x90\x87\x90"
5019 }' | ${MAILX} ${ARGS} ${ADDARG_UNI} -s TestSubject "${MBOX}"
5020 check content:007 0 "${MBOX}" '534262374 61816'
5022 t_epilog
5025 t__put_subject() {
5026 # MIME encoding (QP) stress message subject
5027 printf 'Äbrä Kä?dä=brö Fü?di=bus? '\
5028 'adadaddsssssssddddddddddddddddddddd'\
5029 'ddddddddddddddddddddddddddddddddddd'\
5030 'ddddddddddddddddddddddddddddddddddd'\
5031 'dddddddddddddddddddd Hallelulja? Od'\
5032 'er?? eeeeeeeeeeeeeeeeeeeeeeeeeeeeee'\
5033 'eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'\
5034 'eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee f'\
5035 'fffffffffffffffffffffffffffffffffff'\
5036 'fffffffffffffffffffff ggggggggggggg'\
5037 'ggggggggggggggggggggggggggggggggggg'\
5038 'ggggggggggggggggggggggggggggggggggg'\
5039 'ggggggggggggggggggggggggggggggggggg'\
5040 'gggggggggggggggg'
5043 t__put_body() {
5044 # MIME encoding (QP) stress message body
5045 printf \
5046 'Ich bin eine DÖS-Datäi mit sehr langen Zeilen und auch '\
5047 'sonst bin ich ganz schön am Schleudern, da kannste denke '\
5048 "wasde willst, gelle, gelle, gelle, gelle, gelle.\r\n"\
5049 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst \r\n"\
5050 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1\r\n"\
5051 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12\r\n"\
5052 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123\r\n"\
5053 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1234\r\n"\
5054 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12345\r\n"\
5055 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123456\r\n"\
5056 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1234567\r\n"\
5057 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12345678\r\n"\
5058 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123456789\r\n"\
5059 "Unn ausserdem habe ich trailing SP/HT/SP/HT whitespace \r\n"\
5060 "Unn ausserdem habe ich trailing HT/SP/HT/SP whitespace \r\n"\
5061 "auf den zeilen vorher.\r\n"\
5062 "From am Zeilenbeginn und From der Mitte gibt es auch.\r\n"\
5063 ".\r\n"\
5064 "Die letzte Zeile war nur ein Punkt.\r\n"\
5065 "..\r\n"\
5066 "Das waren deren zwei.\r\n"\
5067 " \r\n"\
5068 "Die letzte Zeile war ein Leerschritt.\n"\
5069 "=VIER = EQUAL SIGNS=ON A LINE=\r\n"\
5070 "Prösterchen.\r\n"\
5071 ".\n"\
5072 "Die letzte Zeile war nur ein Punkt, mit Unix Zeilenende.\n"\
5073 "..\n"\
5074 "Das waren deren zwei. ditto.\n"\
5075 "Prösterchen.\n"\
5076 "Unn ausseerdem habe ich trailing SP/HT/SP/HT whitespace \n"\
5077 "Unn ausseerdem habe ich trailing HT/SP/HT/SP whitespace \n"\
5078 "auf den zeilen vorher.\n"\
5079 "ditto.\n"\
5080 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.\n"\
5081 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.1"\
5082 "\n"\
5083 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
5084 "\n"\
5085 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
5086 "3\n"\
5087 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
5088 "34\n"\
5089 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
5090 "345\n"\
5091 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
5092 "3456\n"\
5093 "QP am Zeilenende über soft-nl hinweg\n"\
5094 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
5095 "ö123\n"\
5096 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
5097 "1ö23\n"\
5098 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
5099 "12ö3\n"\
5100 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
5101 "123ö\n"\
5102 "=VIER = EQUAL SIGNS=ON A LINE=\n"\
5103 " \n"\
5104 "Die letzte Zeile war ein Leerschritt.\n"\
5108 t_all() {
5109 # if have_feat devel; then
5110 # ARGS="${ARGS} -Smemdebug"
5111 # export ARGS
5112 # fi
5114 if [ -n "${UTF8_LOCALE}" ]; then
5115 printf 'Using Unicode locale %s\n' "${UTF8_LOCALE}"
5116 else
5117 printf 'No Unicode locale found, disabling Unicode tests\n'
5120 t_behave
5121 t_content
5124 # cc_all_configs()
5125 # Test all configs TODO doesn't cover all *combinations*, stupid!
5126 cc_all_configs() {
5127 < ${CONF} ${awk} '
5128 BEGIN{
5129 ALWAYS = "OPT_AUTOCC=1 OPT_AMALGAMATION=1"
5130 NOTME["OPT_ALWAYS_UNICODE_LOCALE"] = 1
5131 NOTME["OPT_CROSS_BUILD"] = 1
5132 NOTME["OPT_AUTOCC"] = 1
5133 NOTME["OPT_AMALGAMATION"] = 1
5134 NOTME["OPT_DEBUG"] = 1
5135 NOTME["OPT_DEVEL"] = 1
5136 NOTME["OPT_ASAN_ADDRESS"] = 1
5137 NOTME["OPT_ASAN_MEMORY"] = 1
5138 NOTME["OPT_FORCED_STACKPROT"] = 1
5139 NOTME["OPT_NOMEMDBG"] = 1
5140 NOTME["OPT_NYD2"] = 1
5142 #OPTVALS
5143 OPTNO = 0
5145 MULCHOICE["OPT_IDNA"] = "VAL_IDNA"
5146 MULVALS["VAL_IDNA"] = 1
5148 #VALKEYS[0] = "VAL_RANDOM"
5149 VALVALS["VAL_RANDOM"] = 1
5150 VALNO = 0
5152 /^[[:space:]]*OPT_/{
5153 sub(/^[[:space:]]*/, "")
5154 # This bails for UnixWare 7.1.4 awk(1), but preceeding = with \
5155 # does not seem to be a compliant escape for =
5156 #sub(/=.*$/, "")
5157 $1 = substr($1, 1, index($1, "=") - 1)
5158 if(!NOTME[$1])
5159 OPTVALS[OPTNO++] = $1
5160 next
5162 /^[[:space:]]*VAL_/{
5163 sub(/^[[:space:]]*/, "")
5164 val = substr($0, index($0, "=") + 1)
5165 if(val ~ /^\"/){
5166 val = substr(val, 2)
5167 val = substr(val, 1, length(val) - 1)
5169 $1 = substr($1, 1, index($1, "=") - 1)
5170 if(MULVALS[$1])
5171 MULVALS[$1] = val
5172 else if(VALVALS[$1]){
5173 VALKEYS[VALNO++] = $1
5174 VALVALS[$1] = val
5176 next
5178 function onepass(addons){
5179 a_onepass__worker(addons, "1", "0")
5180 a_onepass__worker(addons, "0", "1")
5182 function a_onepass__worker(addons, b0, b1){
5183 # Doing this completely sequentially and not doing make distclean in
5184 # between runs should effectively result in lesser compilations.
5185 # It is completely dumb nonetheless... TODO
5186 for(ono = 0; ono < OPTNO; ++ono){
5187 myconf = mula = ""
5188 for(i = 0; i < ono; ++i){
5189 myconf = myconf " " OPTVALS[i] "=" b0 " "
5190 if(b0 == "1"){
5191 j = MULCHOICE[OPTVALS[i]]
5192 if(j){
5193 if(i + 1 == ono)
5194 mula = j
5195 else
5196 myconf = myconf " " MULCHOICE[OPTVALS[i]] "=any "
5200 for(i = ono; i < OPTNO; ++i){
5201 myconf = myconf " " OPTVALS[i] "=" b1 " "
5202 if(b1 == "1"){
5203 j = MULCHOICE[OPTVALS[i]]
5204 if(j){
5205 if(i + 1 == OPTNO)
5206 mula = j;
5207 else
5208 myconf = myconf " " MULCHOICE[OPTVALS[i]] "=any "
5213 for(i in VALKEYS)
5214 myconf = VALKEYS[i] "=any " myconf
5216 myconf = myconf " " ALWAYS " " addons
5218 if(mula == "")
5219 print myconf
5220 else{
5221 i = split(MULVALS[mula], ia)
5222 j = "any"
5223 while(i >= 1){
5224 j = ia[i--] " " j
5225 print mula "=\"" j "\" " myconf
5230 END{
5231 # We cannot test NULL because of missing UI strings, which will end
5232 # up with different checksums
5233 print "CONFIG=NULLI OPT_AUTOCC=1"
5234 for(i in VALKEYS){
5235 j = split(VALVALS[VALKEYS[i]], ia)
5236 k = "any"
5237 while(j >= 1){
5238 k = ia[j--] " " k
5239 print VALKEYS[i] "=\"" k "\" CONFIG=NULLI OPT_AUTOCC=1"
5242 print "CONFIG=MINIMAL OPT_AUTOCC=1"
5243 print "CONFIG=NETSEND OPT_AUTOCC=1"
5244 print "CONFIG=MAXIMAL OPT_AUTOCC=1"
5245 for(i in VALKEYS){
5246 j = split(VALVALS[VALKEYS[i]], ia)
5247 k = "any"
5248 while(j >= 1){
5249 k = ia[j--] " " k
5250 print VALKEYS[i] "=\"" k "\" CONFIG=MAXIMAL OPT_AUTOCC=1"
5253 print "CONFIG=DEVEL OPT_AUTOCC=1"
5254 print "CONFIG=ODEVEL OPT_AUTOCC=1"
5256 onepass("OPT_DEBUG=1")
5257 onepass("")
5259 ' | while read c; do
5260 [ -f mk-config.h ] && ${cp} mk-config.h .ccac.h
5261 printf "\n\n##########\n$c\n"
5262 printf "\n\n##########\n$c\n" >&2
5263 ${SHELL} -c "cd .. && ${MAKE} ${c} config"
5264 if [ -f .ccac.h ] && ${cmp} mk-config.h .ccac.h; then
5265 printf 'Skipping after config, nothing changed\n'
5266 printf 'Skipping after config, nothing changed\n' >&2
5267 continue
5269 ${SHELL} -c "cd ../ && ${MAKE} build test"
5270 done
5271 ${rm} -f .ccac.h
5272 cd .. && ${MAKE} distclean
5275 [ -n "${ERR}" ] && echo > ${ERR}
5276 if [ -z "${CHECK_ONLY}${MAE_TEST}" ]; then
5277 cc_all_configs
5278 elif [ -z "${MAE_TEST}" ] || [ ${#} -eq 0 ]; then
5279 t_all
5280 else
5281 while [ ${#} -gt 0 ]; do
5282 ${1}
5283 shift
5284 done
5287 [ ${ESTAT} -eq 0 ] && echo Ok || echo >&2 'Errors occurred'
5289 exit ${ESTAT}
5290 # s-sh-mode