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