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