cc-test.sh:t_behave_S_freeze(): fix test number in skip message
[s-mailx.git] / cc-test.sh
blob6d8257e8e4c70d379adbd5ba42db9e94597fc0fd
1 #!/bin/sh -
2 #@ Synopsis: ./cc-test.sh [--check-only s-mailx-binary]
3 #@ ./cc-test.sh --mae-test s-mailx-binary [:TESTNAME:]
4 #@ The latter generates output files.
5 #@ TODO _All_ the tests should happen in a temporary subdir.
6 # Public Domain
8 if [ -f ./mk-config.ev ]; then
9 . ./mk-config.ev
10 if [ -z "${MAILX__CC_TEST_RUNNING}" ]; then
11 MAILX__CC_TEST_RUNNING=1
12 export MAILX__CC_TEST_RUNNING
13 exec "${SHELL}" "${0}" "${@}"
15 else
16 echo >&2 'S-nail/S-mailx is not configured.'
17 echo >&2 'This test script requires the shell environment that only the'
18 echo >&2 'configuration script can figure out, even if it will be used to'
19 echo >&2 'test a different binary than the one that would be produced!'
20 exit 41
23 # We need *stealthmua* regardless of $SOURCE_DATE_EPOCH, the program name as
24 # such is a compile-time variable
25 ARGS='-:/ -# -Sdotlock-ignore-error -Sexpandaddr=restrict'
26 ARGS="${ARGS}"' -Smime-encoding=quoted-printable -Snosave -Sstealthmua'
27 ADDARG_UNI=-Sttycharset=UTF-8
28 CONF=./make.rc
29 BODY=./.cc-body.txt
30 MBOX=./.cc-test.mbox
31 MAIL=/dev/null
32 #UTF8_LOCALE= autodetected unless set
34 # Note valgrind has problems with FDs in forked childs, which causes some tests
35 # to fail (the FD is rewound and thus will be dumped twice)
36 MEMTESTER=
37 #MEMTESTER='valgrind --leak-check=full --log-file=.vl-%p '
39 ## -- (>8 -- 8<) -- ##
41 ( set -o noglob ) >/dev/null 2>&1 && noglob_shell=1 || unset noglob_shell
43 msg() {
44 fmt=${1}
45 shift
46 printf >&2 -- "${fmt}\\n" "${@}"
49 ## -- >8 -- 8< -- ##
51 export ARGS ADDARG_UNI CONF BODY MBOX MAIL MAKE awk cat cksum rm sed grep
53 LC_ALL=C LANG=C
54 TZ=UTC
55 # Wed Oct 2 01:50:07 UTC 1996
56 SOURCE_DATE_EPOCH=844221007
58 export LC_ALL LANG TZ SOURCE_DATE_EPOCH
59 unset POSIXLY_CORRECT LOGNAME USER
61 usage() {
62 echo >&2 "Synopsis: ./cc-test.sh [--check-only s-mailx-binary]"
63 echo >&2 "Synopsis: ./cc-test.sh --mae-test s-mailx-binary [:TESTNAME:]"
64 exit 1
67 CHECK_ONLY= MAE_TEST= MAILX=
68 if [ "${1}" = --check-only ]; then
69 CHECK_ONLY=1
70 MAILX=${2}
71 [ -x "${MAILX}" ] || usage
72 shift 2
73 elif [ "${1}" = --mae-test ]; then
74 MAE_TEST=1
75 MAILX=${2}
76 [ -x "${MAILX}" ] || usage
77 shift 2
79 RAWMAILX=${MAILX}
80 MAILX="${MEMTESTER}${MAILX}"
81 export RAWMAILX MAILX
83 if [ -n "${CHECK_ONLY}${MAE_TEST}" ] && [ -z "${UTF8_LOCALE}" ]; then
84 # Try ourselfs for nl_langinfo(CODESET) output first (requires a new version)
85 i=`LC_ALL=C.utf8 "${RAWMAILX}" ${ARGS} -X '
86 \define cset_test {
87 \if [ "${ttycharset}" @i=% utf ]
88 \echo $LC_ALL
89 \xit 0
90 \end
91 \if [ "${#}" -gt 0 ]
92 \wysh set LC_ALL=${1}
93 \shift
94 \eval xcall cset_test "${@}"
95 \end
96 \xit 1
98 \call cset_test C.UTF-8 POSIX.utf8 POSIX.UTF-8 en_EN.utf8 en_EN.UTF-8 \
99 en_US.utf8 en_US.UTF-8
101 [ $? -eq 0 ] && UTF8_LOCALE=$i
103 if [ -z "${UTF8_LOCALE}" ] && (locale yesexpr) >/dev/null 2>&1; then
104 UTF8_LOCALE=`locale -a | { m=
105 while read n; do
106 if { echo ${n} | ${grep} -i 'utf-\{0,1\}8'; } >/dev/null 2>&1; then
107 m=${n}
108 if { echo ${n} | ${grep} -e POSIX -e en_EN -e en_US; }; then
109 exit 0
112 m=${n}
113 done
114 echo ${m}
119 ESTAT=0
121 TRAP_EXIT_ADDONS=
122 trap "${rm} -rf \"${BODY}\" \"${MBOX}\" \${TRAP_EXIT_ADDONS}" EXIT
123 trap "exit 1" HUP INT TERM
125 # cc_all_configs()
126 # Test all configs TODO doesn't cover all *combinations*, stupid!
127 cc_all_configs() {
128 < ${CONF} ${awk} '
129 BEGIN {
130 NOTME["OPT_AUTOCC"] = 1
131 NOTME["OPT_DEBUG"] = 1
132 NOTME["OPT_DEVEL"] = 1
133 NOTME["OPT_NOEXTMD5"] = 1
134 NOTME["OPT_ASAN_ADDRESS"] = 1
135 NOTME["OPT_ASAN_MEMORY"] = 1
136 NOTME["OPT_FORCED_STACKPROT"] = 1
137 NOTME["OPT_NOMEMDBG"] = 1
138 NOTME["OPT_NYD2"] = 1
139 i = 0
141 /^[[:space:]]*OPT_/ {
142 sub(/^[[:space:]]*/, "")
143 # This bails for UnixWare 7.1.4 awk(1), but preceeding = with \
144 # does not seem to be a compliant escape for =
145 #sub(/=.*$/, "")
146 $1 = substr($1, 1, index($1, "=") - 1)
147 if (NOTME[$1])
148 next
149 data[i++] = $1
151 END {
152 # Doing this completely sequentially and not doing make distclean in
153 # between runs should effectively result in lesser compilations.
154 # It is completely dumb nonetheless... TODO
155 for (j = 1; j < i; ++j) {
156 for (k = 1; k < j; ++k)
157 printf data[k] "=1 "
158 for (k = j; k < i; ++k)
159 printf data[k] "=0 "
160 printf "OPT_AUTOCC=1\n"
162 for (j = 1; j < i; ++j) {
163 for (k = 1; k < j; ++k)
164 printf data[k] "=0 "
165 for (k = j; k < i; ++k)
166 printf data[k] "=1 "
167 printf "OPT_AUTOCC=1\n"
169 # With debug
170 for (j = 1; j < i; ++j) {
171 for (k = 1; k < j; ++k)
172 printf data[k] "=1 "
173 for (k = j; k < i; ++k)
174 printf data[k] "=0 "
175 printf "OPT_AUTOCC=1\n"
176 printf "OPT_DEBUG=1\n"
178 for (j = 1; j < i; ++j) {
179 for (k = 1; k < j; ++k)
180 printf data[k] "=0 "
181 for (k = j; k < i; ++k)
182 printf data[k] "=1 "
183 printf "OPT_AUTOCC=1\n"
184 printf "OPT_DEBUG=1\n"
187 printf "CONFIG=NULL OPT_AUTOCC=0\n"
188 printf "CONFIG=NULL OPT_AUTOCC=1\n"
189 printf "CONFIG=NULLI OPT_AUTOCC=0\n"
190 printf "CONFIG=NULLI OPT_AUTOCC=1\n"
191 printf "CONFIG=MINIMAL OPT_AUTOCC=0\n"
192 printf "CONFIG=MINIMAL OPT_AUTOCC=1\n"
193 printf "CONFIG=NETSEND OPT_AUTOCC=0\n"
194 printf "CONFIG=NETSEND OPT_AUTOCC=1\n"
195 printf "CONFIG=MAXIMAL OPT_AUTOCC=0\n"
196 printf "CONFIG=MAXIMAL OPT_AUTOCC=1\n"
197 printf "CONFIG=DEVEL OPT_AUTOCC=0\n"
198 printf "CONFIG=DEVEL OPT_AUTOCC=1\n"
199 printf "CONFIG=ODEVEL OPT_AUTOCC=0\n"
200 printf "CONFIG=ODEVEL OPT_AUTOCC=1\n"
202 ' | while read c; do
203 printf "\n\n##########\n$c\n"
204 printf "\n\n##########\n$c\n" >&2
205 sh -c "${MAKE} ${c} all test"
206 done
207 ${MAKE} distclean
210 have_feat() {
211 ( "${RAWMAILX}" ${ARGS} -X'echo $features' -Xx |
212 ${grep} +${1} ) >/dev/null 2>&1
215 t_prolog() {
216 ${rm} -rf "${BODY}" "${MBOX}" ${TRAP_EXIT_ADDONS}
217 TRAP_EXIT_ADDONS=
218 [ ${#} -gt 0 ] && printf '[%s]\n' "${1}"
220 t_epilog() {
221 t_prolog
224 check() {
225 restat=${?} tid=${1} eestat=${2} f=${3} s=${4}
226 [ "${eestat}" != - ] && [ "${restat}" != "${eestat}" ] &&
227 err "${tid}" 'unexpected exit status: '"${restat} != ${eestat}"
228 csum="`${cksum} < ${f}`"
229 if [ "${csum}" = "${s}" ]; then
230 printf '%s: ok\n' "${tid}"
231 else
232 ESTAT=1
233 printf '%s: error: checksum mismatch (got %s)\n' "${tid}" "${csum}"
235 if [ -n "${MAE_TEST}" ]; then
236 x=`echo ${tid} | ${tr} "/:=" "__-"`
237 ${cp} -f "${f}" ./mae-test-"${x}"
241 err() {
242 ESTAT=1
243 printf '%s: error: %s\n' ${1} "${2}"
246 ex0_test() {
247 [ $? -ne 0 ] && err $1 'unexpected non-0 exit status'
250 exn0_test() {
251 [ $? -eq 0 ] && err $1 'unexpected 0 exit status'
254 if ( [ "$((1 + 1))" = 2 ] ) >/dev/null 2>&1; then
255 add() {
256 echo "$((${1} + ${2}))"
258 else
259 add() {
260 echo `${awk} 'BEGIN{print '${1}' + '${2}'}'`
264 if ( [ "$((2 % 3))" = 2 ] ) >/dev/null 2>&1; then
265 modulo() {
266 echo "$((${1} % ${2}))"
268 else
269 modulo() {
270 echo `${awk} 'BEGIN{print '${1}' % '${2}'}'`
274 # t_behave()
275 # Basic (easily testable) behaviour tests
276 t_behave() {
277 t_behave_X_opt_input_command_stack
278 t_behave_X_errexit
279 t_behave_S_freeze
280 t_behave_wysh
281 t_behave_input_inject_semicolon_seq
282 t_behave_commandalias
283 t_behave_ifelse
284 t_behave_localopts
285 t_behave_macro_param_shift
286 t_behave_addrcodec
287 t_behave_vexpr
288 t_behave_call_ret
289 t_behave_xcall
290 t_behave_vpospar
291 t_behave_atxplode
293 t_behave_mbox
295 t_behave_alternates
296 t_behave_alias
297 # FIXME t_behave_mlist
298 t_behave_filetype
300 t_behave_record_a_resend
302 t_behave_e_H_L_opts
303 t_behave_compose_hooks
304 t_behave_message_injections
305 t_behave_mime_types_load_control
307 t_behave_s_mime
309 t_behave_maildir
310 t_behave_mass_recipients
311 t_behave_lreply_futh_rth_etc
312 t_behave_iconv_mbyte_base64
315 t_behave_X_opt_input_command_stack() {
316 t_prolog t_behave_X_opt_input_command_stack
318 ${cat} <<- '__EOT' > "${BODY}"
319 echo 1
320 define mac0 {
321 echo mac0-1 via1 $0
323 call mac0
324 echo 2
325 source '\
326 echo "define mac1 {";\
327 echo " echo mac1-1 via1 \$0";\
328 echo " call mac0";\
329 echo " echo mac1-2";\
330 echo " call mac2";\
331 echo " echo mac1-3";\
332 echo "}";\
333 echo "echo 1-1";\
334 echo "define mac2 {";\
335 echo " echo mac2-1 via1 \$0";\
336 echo " call mac0";\
337 echo " echo mac2-2";\
338 echo "}";\
339 echo "echo 1-2";\
340 echo "call mac1";\
341 echo "echo 1-3";\
342 echo "source \"\
343 echo echo 1-1-1 via1 \$0;\
344 echo call mac0;\
345 echo echo 1-1-2;\
346 | \"";\
347 echo "echo 1-4";\
349 echo 3
350 call mac2
351 echo 4
352 undefine *
353 __EOT
355 # The -X option supports multiline arguments, and those can internally use
356 # reverse solidus newline escaping. And all -X options are joined...
357 APO=\'
358 < "${BODY}" ${MAILX} ${ARGS} \
359 -X 'e\' \
360 -X ' c\' \
361 -X ' h\' \
362 -X ' o \' \
363 -X 1 \
365 define mac0 {
366 echo mac0-1 via2 $0
368 call mac0
369 echo 2
372 source '${APO}'\
373 echo "define mac1 {";\
374 echo " echo mac1-1 via2 \$0";\
375 echo " call mac0";\
376 echo " echo mac1-2";\
377 echo " call mac2";\
378 echo " echo mac1-3";\
379 echo "}";\
380 echo "echo 1-1";\
381 echo "define mac2 {";\
382 echo " echo mac2-1 via2 \$0";\
383 echo " call mac0";\
384 echo " echo mac2-2";\
385 echo "}";\
386 echo "echo 1-2";\
387 echo "call mac1";\
388 echo "echo 1-3";\
389 echo "source \"\
390 echo echo 1-1-1 via2 \$0;\
391 echo call mac0;\
392 echo echo 1-1-2;\
393 | \"";\
394 echo "echo 1-4";\
395 | '${APO}'
396 echo 3
399 call mac2
400 echo 4
401 undefine *
402 ' > "${MBOX}"
404 check behave:x_opt_input_command_stack 0 "${MBOX}" '1786542668 416'
406 t_epilog
409 t_behave_X_errexit() {
410 t_prolog t_behave_X_errexit
412 ${cat} <<- '__EOT' > "${BODY}"
413 echo one
414 echos nono
415 echo two
416 __EOT
418 </dev/null ${MAILX} ${ARGS} -Snomemdebug \
419 -X'echo one' -X' echos nono ' -X'echo two' \
420 > "${MBOX}" 2>&1
421 check behave:x_errexit-1 0 "${MBOX}" '916157812 53'
423 </dev/null ${MAILX} ${ARGS} -X'source '"${BODY}" -Snomemdebug \
424 > "${MBOX}" 2>&1
425 check behave:x_errexit-2 0 "${MBOX}" '916157812 53'
427 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Snomemdebug \
428 > "${MBOX}" 2>&1
429 check behave:x_errexit-3 0 "${MBOX}" '916157812 53'
433 </dev/null ${MAILX} ${ARGS} -Serrexit -Snomemdebug \
434 -X'echo one' -X' echos nono ' -X'echo two' \
435 > "${MBOX}" 2>&1
436 check behave:x_errexit-4 1 "${MBOX}" '2118430867 49'
438 </dev/null ${MAILX} ${ARGS} -X'source '"${BODY}" -Serrexit -Snomemdebug \
439 > "${MBOX}" 2>&1
440 check behave:x_errexit-5 1 "${MBOX}" '2118430867 49'
442 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Serrexit -Snomemdebug \
443 > "${MBOX}" 2>&1
444 check behave:x_errexit-6 1 "${MBOX}" '12955965 172'
446 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Sposix -Snomemdebug \
447 > "${MBOX}" 2>&1
448 check behave:x_errexit-7 1 "${MBOX}" '12955965 172'
450 ## Repeat 4-7 with ignerr set
452 ${sed} -e 's/^echos /ignerr echos /' < "${BODY}" > "${MBOX}"
454 </dev/null ${MAILX} ${ARGS} -Serrexit -Snomemdebug \
455 -X'echo one' -X'ignerr echos nono ' -X'echo two' \
456 > "${BODY}" 2>&1
457 check behave:x_errexit-8 0 "${BODY}" '916157812 53'
459 </dev/null ${MAILX} ${ARGS} -X'source '"${MBOX}" -Serrexit -Snomemdebug \
460 > "${BODY}" 2>&1
461 check behave:x_errexit-9 0 "${BODY}" '916157812 53'
463 </dev/null MAILRC="${MBOX}" ${MAILX} ${ARGS} -:u -Serrexit -Snomemdebug \
464 > "${BODY}" 2>&1
465 check behave:x_errexit-10 0 "${BODY}" '916157812 53'
467 </dev/null MAILRC="${MBOX}" ${MAILX} ${ARGS} -:u -Sposix -Snomemdebug \
468 > "${BODY}" 2>&1
469 check behave:x_errexit-11 0 "${BODY}" '916157812 53'
471 t_epilog
474 t_behave_S_freeze() {
475 t_prolog t_behave_S_freeze
476 oterm=$TERM
477 unset TERM
479 # Test basic assumption
480 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} \
481 -X'echo asksub<$asksub> dietcurd<$dietcurd>' \
482 -Xx > "${MBOX}" 2>&1
483 check behave:s_freeze-1 0 "${MBOX}" '270686329 21'
486 ${cat} <<- '__EOT' > "${BODY}"
487 echo asksub<$asksub>
488 set asksub
489 echo asksub<$asksub>
490 __EOT
491 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
492 -Snoasksub -Sasksub -Snoasksub \
493 -X'echo asksub<$asksub>' -X'set asksub' -X'echo asksub<$asksub>' \
494 -Xx > "${MBOX}" 2>&1
495 check behave:s_freeze-2 0 "${MBOX}" '3182942628 37'
497 ${cat} <<- '__EOT' > "${BODY}"
498 echo asksub<$asksub>
499 unset asksub
500 echo asksub<$asksub>
501 __EOT
502 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
503 -Snoasksub -Sasksub \
504 -X'echo asksub<$asksub>' -X'unset asksub' -X'echo asksub<$asksub>' \
505 -Xx > "${MBOX}" 2>&1
506 check behave:s_freeze-3 0 "${MBOX}" '2006554293 39'
509 ${cat} <<- '__EOT' > "${BODY}"
510 echo dietcurd<$dietcurd>
511 set dietcurd=cherry
512 echo dietcurd<$dietcurd>
513 __EOT
514 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
515 -Sdietcurd=strawberry -Snodietcurd -Sdietcurd=vanilla \
516 -X'echo dietcurd<$dietcurd>' -X'unset dietcurd' \
517 -X'echo dietcurd<$dietcurd>' \
518 -Xx > "${MBOX}" 2>&1
519 check behave:s_freeze-4 0 "${MBOX}" '1985768109 65'
521 ${cat} <<- '__EOT' > "${BODY}"
522 echo dietcurd<$dietcurd>
523 unset dietcurd
524 echo dietcurd<$dietcurd>
525 __EOT
526 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
527 -Sdietcurd=strawberry -Snodietcurd \
528 -X'echo dietcurd<$dietcurd>' -X'set dietcurd=vanilla' \
529 -X'echo dietcurd<$dietcurd>' \
530 -Xx > "${MBOX}" 2>&1
531 check behave:s_freeze-5 0 "${MBOX}" '151574279 51'
533 # TODO once we have a detached one with env=1..
534 if [ -n "`</dev/null ${MAILX} ${ARGS} -:/ -X'!echo $TERM' -Xx`" ]; then
535 echo 'behave:s_freeze-{6,7}: shell sets $TERM, skipped'
536 else
537 ${cat} <<- '__EOT' > "${BODY}"
538 !echo "shell says TERM<$TERM>"
539 echo TERM<$TERM>
540 !echo "shell says TERM<$TERM>"
541 set TERM=cherry
542 !echo "shell says TERM<$TERM>"
543 echo TERM<$TERM>
544 !echo "shell says TERM<$TERM>"
545 __EOT
546 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
547 -STERM=strawberry -SnoTERM -STERM=vanilla \
548 -X'echo mail<$TERM>' -X'unset TERM' \
549 -X'!echo "shell says TERM<$TERM>"' -X'echo TERM<$TERM>' \
550 -Xx > "${MBOX}" 2>&1
551 check behave:s_freeze-6 0 "${MBOX}" '1211476036 167'
553 ${cat} <<- '__EOT' > "${BODY}"
554 !echo "shell says TERM<$TERM>"
555 echo TERM<$TERM>
556 !echo "shell says TERM<$TERM>"
557 set TERM=cherry
558 !echo "shell says TERM<$TERM>"
559 echo TERM<$TERM>
560 !echo "shell says TERM<$TERM>"
561 __EOT
562 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
563 -STERM=strawberry -SnoTERM \
564 -X'echo TERM<$TERM>' -X'set TERM=vanilla' \
565 -X'!echo "shell says TERM<$TERM>"' -X'echo TERM<$TERM>' \
566 -Xx > "${MBOX}" 2>&1
567 check behave:s_freeze-7 0 "${MBOX}" '3365080441 132'
570 TERM=$oterm
571 t_epilog
574 t_behave_wysh() {
575 t_prolog t_behave_wysh
577 ${cat} <<- '__EOT' > "${BODY}"
579 echo abcd
580 echo a'b'c'd'
581 echo a"b"c"d"
582 echo a$'b'c$'d'
583 echo 'abcd'
584 echo "abcd"
585 echo $'abcd'
586 echo a\ b\ c\ d
587 echo a 'b c' d
588 echo a "b c" d
589 echo a $'b c' d
591 echo 'a$`"\'
592 echo "a\$\`'\"\\"
593 echo $'a\$`\'\"\\'
594 echo $'a\$`\'"\\'
595 # DIET=CURD TIED=
596 echo 'a${DIET}b${TIED}c\${DIET}d\${TIED}e' # COMMENT
597 echo "a${DIET}b${TIED}c\${DIET}d\${TIED}e"
598 echo $'a${DIET}b${TIED}c\${DIET}d\${TIED}e'
600 echo a$'\101\0101\x41\u0041\u41\U00000041\U41'c
601 echo a$'\u0041\u41\u0C1\U00000041\U41'c
602 echo a$'\377'c
603 echo a$'\0377'c
604 echo a$'\400'c
605 echo a$'\0400'c
606 echo a$'\U1100001'c
608 echo a$'b\0c'd
609 echo a$'b\00c'de
610 echo a$'b\000c'df
611 echo a$'b\0000c'dg
612 echo a$'b\x0c'dh
613 echo a$'b\x00c'di
614 echo a$'b\u0'dj
615 echo a$'b\u00'dk
616 echo a$'b\u000'dl
617 echo a$'b\u0000'dm
618 echo a$'b\U0'dn
619 echo a$'b\U00'do
620 echo a$'b\U000'dp
621 echo a$'b\U0000'dq
622 echo a$'b\U00000'dr
623 echo a$'b\U000000'ds
624 echo a$'b\U0000000'dt
625 echo a$'b\U00000000'du
627 echo a$'\cI'b
628 echo a$'\011'b
629 echo a$'\x9'b
630 echo a$'\u9'b
631 echo a$'\U9'b
632 echo a$'\c@'b c d
633 __EOT
635 if [ -z "${UTF8_LOCALE}" ]; then
636 echo 'Skip behave:wysh_unicode, no UTF8_LOCALE'
637 else
638 < "${BODY}" DIET=CURD TIED= \
639 LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} 2>/dev/null > "${MBOX}"
640 check behave:wysh_unicode 0 "${MBOX}" '475805847 317'
643 < "${BODY}" DIET=CURD TIED= ${MAILX} ${ARGS} > "${MBOX}" 2>/dev/null
644 check behave:wysh_c 0 "${MBOX}" '1473887148 321'
646 t_epilog
649 t_behave_input_inject_semicolon_seq() {
650 t_prolog t_behave_input_inject_semicolon_seq
652 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
653 define mydeepmac {
654 echon '(mydeepmac)';
656 define mymac {
657 echon this_is_mymac;call mydeepmac;echon ';';
659 echon one';';call mymac;echon two";";call mymac;echo three$';';
660 define mymac {
661 echon this_is_mymac;call mydeepmac;echon ,TOO'!;';
663 echon one';';call mymac;echon two";";call mymac;echo three$';';
664 __EOT
666 check behave:input_inject_semicolon_seq 0 "${MBOX}" '512117110 140'
668 t_epilog
671 t_behave_commandalias() {
672 t_prolog t_behave_commandalias
674 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
675 commandalias echo echo hoho
676 echo stop.
677 commandalias X Xx
678 commandalias Xx XxX
679 commandalias XxX XxXx
680 commandalias XxXx XxXxX
681 commandalias XxXxX XxXxXx
682 commandalias XxXxXx echo huhu
683 commandalias XxXxXxX echo huhu
685 commandalias XxXxXx XxXxXxX
687 uncommandalias echo
688 commandalias XxXxXx echo huhu
690 __EOT
692 check behave:commandalias 0 "${MBOX}" '3694143612 31'
694 t_epilog
697 t_behave_ifelse() {
698 t_prolog t_behave_ifelse
700 # Nestable conditions test
701 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
702 if 0
703 echo 1.err
704 else
705 echo 1.ok
706 endif
707 if 1
708 echo 2.ok
709 else
710 echo 2.err
711 endif
712 if $dietcurd
713 echo 3.err
714 else
715 echo 3.ok
716 endif
717 set dietcurd=yoho
718 if $dietcurd
719 echo 4.ok
720 else
721 echo 4.err
722 endif
723 if $dietcurd == 'yoho'
724 echo 5.ok
725 else
726 echo 5.err
727 endif
728 if $dietcurd @== 'Yoho'
729 echo 5-1.ok
730 else
731 echo 5-1.err
732 endif
733 if $dietcurd == 'Yoho'
734 echo 5-2.err
735 else
736 echo 5-2.ok
737 endif
738 if $dietcurd != 'yoho'
739 echo 6.err
740 else
741 echo 6.ok
742 endif
743 if $dietcurd @!= 'Yoho'
744 echo 6-1.err
745 else
746 echo 6-1.ok
747 endif
748 if $dietcurd != 'Yoho'
749 echo 6-2.ok
750 else
751 echo 6-2.err
752 endif
753 # Nesting
754 if faLse
755 echo 7.err1
756 if tRue
757 echo 7.err2
758 if yEs
759 echo 7.err3
760 else
761 echo 7.err4
762 endif
763 echo 7.err5
764 endif
765 echo 7.err6
766 else
767 echo 7.ok7
768 if YeS
769 echo 7.ok8
770 if No
771 echo 7.err9
772 else
773 echo 7.ok9
774 endif
775 echo 7.ok10
776 else
777 echo 7.err11
778 if yeS
779 echo 7.err12
780 else
781 echo 7.err13
782 endif
783 endif
784 echo 7.ok14
785 endif
786 if r
787 echo 8.ok1
788 if R
789 echo 8.ok2
790 else
791 echo 8.err2
792 endif
793 echo 8.ok3
794 else
795 echo 8.err1
796 endif
797 if s
798 echo 9.err1
799 else
800 echo 9.ok1
801 if S
802 echo 9.err2
803 else
804 echo 9.ok2
805 endif
806 echo 9.ok3
807 endif
808 # `elif'
809 if $dietcurd == 'yohu'
810 echo 10.err1
811 elif $dietcurd == 'yoha'
812 echo 10.err2
813 elif $dietcurd == 'yohe'
814 echo 10.err3
815 elif $dietcurd == 'yoho'
816 echo 10.ok1
817 if $dietcurd == 'yohu'
818 echo 10.err4
819 elif $dietcurd == 'yoha'
820 echo 10.err5
821 elif $dietcurd == 'yohe'
822 echo 10.err6
823 elif $dietcurd == 'yoho'
824 echo 10.ok2
825 if $dietcurd == 'yohu'
826 echo 10.err7
827 elif $dietcurd == 'yoha'
828 echo 10.err8
829 elif $dietcurd == 'yohe'
830 echo 10.err9
831 elif $dietcurd == 'yoho'
832 echo 10.ok3
833 else
834 echo 10.err10
835 endif
836 else
837 echo 10.err11
838 endif
839 else
840 echo 10.err12
841 endif
842 # integer
843 set dietcurd=10
844 if $dietcurd -lt 11
845 echo 11.ok1
846 if $dietcurd -gt 9
847 echo 11.ok2
848 else
849 echo 11.err2
850 endif
851 if $dietcurd -eq 10
852 echo 11.ok3
853 else
854 echo 11.err3
855 endif
856 if $dietcurd -ge 10
857 echo 11.ok4
858 else
859 echo 11.err4
860 endif
861 if $dietcurd -le 10
862 echo 11.ok5
863 else
864 echo 11.err5
865 endif
866 if $dietcurd -ge 11
867 echo 11.err6
868 else
869 echo 11.ok6
870 endif
871 if $dietcurd -le 9
872 echo 11.err7
873 else
874 echo 11.ok7
875 endif
876 else
877 echo 11.err1
878 endif
879 set dietcurd=Abc
880 if $dietcurd < aBd
881 echo 12.ok1
882 if $dietcurd @> abB
883 echo 12.ok2
884 else
885 echo 12.err2
886 endif
887 if $dietcurd @== aBC
888 echo 12.ok3
889 else
890 echo 12.err3
891 endif
892 if $dietcurd @>= AbC
893 echo 12.ok4
894 else
895 echo 12.err4
896 endif
897 if $dietcurd @<= ABc
898 echo 12.ok5
899 else
900 echo 12.err5
901 endif
902 if $dietcurd @>= abd
903 echo 12.err6
904 else
905 echo 12.ok6
906 endif
907 if $dietcurd @<= abb
908 echo 12.err7
909 else
910 echo 12.ok7
911 endif
912 else
913 echo 12.err1
914 endif
915 if $dietcurd < aBc
916 echo 12-1.ok
917 else
918 echo 12-1.err
919 endif
920 if $dietcurd @< aBc
921 echo 12-2.err
922 else
923 echo 12-2.ok
924 endif
925 if $dietcurd > ABc
926 echo 12-3.ok
927 else
928 echo 12-3.err
929 endif
930 if $dietcurd @> ABc
931 echo 12-3.err
932 else
933 echo 12-3.ok
934 endif
935 if $dietcurd @i=% aB
936 echo 13.ok
937 else
938 echo 13.err
939 endif
940 if $dietcurd =% aB
941 echo 13-1.err
942 else
943 echo 13-1.ok
944 endif
945 if $dietcurd @=% bC
946 echo 14.ok
947 else
948 echo 14.err
949 endif
950 if $dietcurd !% aB
951 echo 15-1.ok
952 else
953 echo 15-1.err
954 endif
955 if $dietcurd @!% aB
956 echo 15-2.err
957 else
958 echo 15-2.ok
959 endif
960 if $dietcurd !% bC
961 echo 15-3.ok
962 else
963 echo 15-3.err
964 endif
965 if $dietcurd @!% bC
966 echo 15-4.err
967 else
968 echo 15-4.ok
969 endif
970 if $dietcurd =% Cd
971 echo 16.err
972 else
973 echo 16.ok
974 endif
975 if $dietcurd !% Cd
976 echo 17.ok
977 else
978 echo 17.err
979 endif
980 set diet=abc curd=abc
981 if $diet == $curd
982 echo 18.ok
983 else
984 echo 18.err
985 endif
986 set diet=abc curd=abcd
987 if $diet != $curd
988 echo 19.ok
989 else
990 echo 19.err
991 endif
992 # 1. Shitty grouping capabilities as of today
993 unset diet curd ndefined
994 if [ [ false ] || [ false ] || [ true ] ] && [ [ false ] || [ true ] ] && \
995 [ yes ]
996 echo 20.ok
997 else
998 echo 20.err
999 endif
1000 if [ [ [ [ 0 ] || [ 1 ] ] && [ [ 1 ] || [ 0 ] ] ] && [ 1 ] ] && [ yes ]
1001 echo 21.ok
1002 else
1003 echo 21.err
1004 endif
1005 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] ]
1006 echo 22.ok
1007 else
1008 echo 22.err
1009 endif
1010 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] ]
1011 echo 23.ok
1012 else
1013 echo 23.err
1014 endif
1015 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] && [ no ]
1016 echo 24.err
1017 else
1018 echo 24.ok
1019 endif
1020 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] \
1021 && [ no ] || [ yes ]
1022 echo 25.ok
1023 else
1024 echo 25.err
1025 endif
1026 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
1027 echo 26.ok
1028 else
1029 echo 26.err
1030 endif
1031 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 0 ] ]
1032 echo 27.err
1033 else
1034 echo 27.ok
1035 endif
1036 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 0 ] ] && [ 1 ] ] ] && [ 1 ] ]
1037 echo 28.err
1038 else
1039 echo 28.ok
1040 endif
1041 if [ [ [ [ [ [ [ 0 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
1042 echo 29.err
1043 else
1044 echo 29.ok
1045 endif
1046 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 0 ]
1047 echo 30.err
1048 else
1049 echo 30.ok
1050 endif
1051 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 1 ]
1052 echo 31.ok
1053 else
1054 echo 31.err
1055 endif
1056 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ]
1057 echo 32.err
1058 else
1059 echo 32.ok
1060 endif
1061 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 1 ]
1062 echo 33.ok
1063 else
1064 echo 33.err
1065 endif
1066 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 0 ]
1067 echo 34.err
1068 else
1069 echo 34.ok
1070 endif
1071 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 1 ]
1072 echo 35.ok
1073 else
1074 echo 35.err
1075 endif
1076 set diet=yo curd=ho
1077 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
1078 echo 36.err
1079 else
1080 echo 36.ok
1081 endif
1082 set ndefined
1083 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
1084 echo 37.ok
1085 else
1086 echo 37.err
1087 endif
1088 # 2. Shitty grouping capabilities as of today
1089 unset diet curd ndefined
1090 if [ false || false || true ] && [ false || true ] && yes
1091 echo 40.ok
1092 else
1093 echo 40.err
1094 endif
1095 if [ [ [ 0 || 1 ] && [ 1 || 0 ] ] && 1 ] && [ yes ]
1096 echo 41.ok
1097 else
1098 echo 41.err
1099 endif
1100 if [ 1 || 0 || 0 || 0 ]
1101 echo 42.ok
1102 else
1103 echo 42.err
1104 endif
1105 if [ 1 || 0 || 0 || 0 || [ 1 ] ]
1106 echo 43.ok
1107 else
1108 echo 43.err
1109 endif
1110 if [ 1 || 0 || 0 || 0 || [ 1 ] || 1 ] && no
1111 echo 44.err
1112 else
1113 echo 44.ok
1114 endif
1115 if [ 1 || 0 || 0 || 0 || 1 || [ 1 ] ] && no || [ yes ]
1116 echo 45.ok
1117 else
1118 echo 45.err
1119 endif
1120 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && 1 ] ] && [ 1 ] ]
1121 echo 46.ok
1122 else
1123 echo 46.err
1124 endif
1125 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && [ 1 ] ] ] && 0 ]
1126 echo 47.err
1127 else
1128 echo 47.ok
1129 endif
1130 if [ [ [ [ [ [ [ 1 ] ] && 1 ] && 0 ] && [ 1 ] ] ] && 1 ]
1131 echo 48.err
1132 else
1133 echo 48.ok
1134 endif
1135 if [ [ [ [ [ [ 0 ] && 1 ] && 1 ] && 1 ] ] && 1 ]
1136 echo 49.err
1137 else
1138 echo 49.ok
1139 endif
1140 if 1 || 0 || 0 || 0 && 0
1141 echo 50.err
1142 else
1143 echo 50.ok
1144 endif
1145 if 1 || 0 || 0 || 0 && 1
1146 echo 51.ok
1147 else
1148 echo 51.err
1149 endif
1150 if 0 || 0 || 0 || 1 && 0
1151 echo 52.err
1152 else
1153 echo 52.ok
1154 endif
1155 if 0 || 0 || 0 || 1 && 1
1156 echo 53.ok
1157 else
1158 echo 53.err
1159 endif
1160 if 0 || 0 || 0 || 1 && 0 || 1 && 0
1161 echo 54.err
1162 else
1163 echo 54.ok
1164 endif
1165 if 0 || 0 || 0 || 1 && 0 || 1 && 1
1166 echo 55.ok
1167 else
1168 echo 55.err
1169 endif
1170 set diet=yo curd=ho
1171 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
1172 echo 56.err
1173 else
1174 echo 56.ok
1175 endif
1176 if $diet == 'yo' && $curd == 'ho' && $ndefined
1177 echo 57.err
1178 else
1179 echo 57.ok
1180 endif
1181 set ndefined
1182 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
1183 echo 57.ok
1184 else
1185 echo 57.err
1186 endif
1187 if $diet == 'yo' && $curd == 'ho' && $ndefined
1188 echo 58.ok
1189 else
1190 echo 58.err
1191 endif
1192 if [ [ [ [ [ [ $diet == 'yo' && $curd == 'ho' && $ndefined ] ] ] ] ] ]
1193 echo 59.ok
1194 else
1195 echo 59.err
1196 endif
1197 # Some more en-braced variables
1198 set diet=yo curd=ho
1199 if ${diet} == ${curd}
1200 echo 70.err
1201 else
1202 echo 70.ok
1203 endif
1204 if ${diet} != ${curd}
1205 echo 71.ok
1206 else
1207 echo 71.err
1208 endif
1209 if $diet == ${curd}
1210 echo 72.err
1211 else
1212 echo 72.ok
1213 endif
1214 if ${diet} == $curd
1215 echo 73.err
1216 else
1217 echo 73.ok
1218 endif
1219 # Unary !
1220 if ! 0 && ! ! 1 && ! ! ! ! 2 && 3
1221 echo 80.ok
1222 else
1223 echo 80.err
1224 endif
1225 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ ! 2 ] ] ] && 3
1226 echo 81.ok
1227 else
1228 echo 81.err
1229 endif
1230 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1231 echo 82.ok
1232 else
1233 echo 82.err
1234 endif
1235 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
1236 echo 83.err
1237 else
1238 echo 83.ok
1239 endif
1240 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
1241 echo 84.err
1242 else
1243 echo 84.ok
1244 endif
1245 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1246 echo 85.err
1247 else
1248 echo 85.ok
1249 endif
1250 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1251 echo 86.err
1252 else
1253 echo 86.ok
1254 endif
1255 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] || 3
1256 echo 87.ok
1257 else
1258 echo 87.err
1259 endif
1260 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! ! [ 2 ] ] ] ] ]
1261 echo 88.ok
1262 else
1263 echo 88.err
1264 endif
1265 # Unary !, odd
1266 if ! 0 && ! ! 1 && ! ! ! 0 && 3
1267 echo 90.ok
1268 else
1269 echo 90.err
1270 endif
1271 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ 0 ] ] ] && 3
1272 echo 91.ok
1273 else
1274 echo 91.err
1275 endif
1276 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ [ 0 ] ] ] ] ] && 3
1277 echo 92.ok
1278 else
1279 echo 92.err
1280 endif
1281 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! ! [ ! [ ! 0 ] ] ] ] && ! 3
1282 echo 93.err
1283 else
1284 echo 93.ok
1285 endif
1286 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ ! [ ! [ ! [ ! 0 ] ] ] ] && 3
1287 echo 94.ok
1288 else
1289 echo 94.err
1290 endif
1291 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! ! [ ! [ ! [ ! [ 0 ] ] ] ] ] && 3
1292 echo 95.err
1293 else
1294 echo 95.ok
1295 endif
1296 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! ! 0 ] ] ] ] && 3
1297 echo 96.err
1298 else
1299 echo 96.ok
1300 endif
1301 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ ! 0 ] ] ] ] ] || 3
1302 echo 97.ok
1303 else
1304 echo 97.err
1305 endif
1306 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! [ 0 ] ] ] ] ]
1307 echo 98.ok
1308 else
1309 echo 98.err
1310 endif
1311 __EOT
1313 check behave:if-normal 0 "${MBOX}" '1688759742 719'
1315 if have_feat regex; then
1316 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
1317 set dietcurd=yoho
1318 if $dietcurd =~ '^yo.*'
1319 echo 1.ok
1320 else
1321 echo 1.err
1322 endif
1323 if $dietcurd =~ '^Yo.*'
1324 echo 1-1.err
1325 else
1326 echo 1-1.ok
1327 endif
1328 if $dietcurd @=~ '^Yo.*'
1329 echo 1-2.ok
1330 else
1331 echo 1-2.err
1332 endif
1333 if $dietcurd =~ '^yOho.+'
1334 echo 2.err
1335 else
1336 echo 2.ok
1337 endif
1338 if $dietcurd @!~ '.*Ho$'
1339 echo 3.err
1340 else
1341 echo 3.ok
1342 endif
1343 if $dietcurd !~ '.+yohO$'
1344 echo 4.ok
1345 else
1346 echo 4.err
1347 endif
1348 if [ $dietcurd @i!~ '.+yoho$' ]
1349 echo 5.ok
1350 else
1351 echo 5.err
1352 endif
1353 if ! [ $dietcurd @i=~ '.+yoho$' ]
1354 echo 6.ok
1355 else
1356 echo 6.err
1357 endif
1358 if ! ! [ $dietcurd @i!~ '.+yoho$' ]
1359 echo 7.ok
1360 else
1361 echo 7.err
1362 endif
1363 if ! [ ! [ $dietcurd @i!~ '.+yoho$' ] ]
1364 echo 8.ok
1365 else
1366 echo 8.err
1367 endif
1368 if [ ! [ ! [ $dietcurd @i!~ '.+yoho$' ] ] ]
1369 echo 9.ok
1370 else
1371 echo 9.err
1372 endif
1373 if ! [ ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
1374 echo 10.err
1375 else
1376 echo 10.ok
1377 endif
1378 if ! ! ! $dietcurd !~ '.+yoho$'
1379 echo 11.err
1380 else
1381 echo 11.ok
1382 endif
1383 if ! ! ! $dietcurd =~ '.+yoho$'
1384 echo 12.ok
1385 else
1386 echo 12.err
1387 endif
1388 if ! [ ! ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
1389 echo 13.ok
1390 else
1391 echo 13.err
1392 endif
1393 set diet=abc curd='^abc$'
1394 if $diet =~ $curd
1395 echo 14.ok
1396 else
1397 echo 14.err
1398 endif
1399 set diet=abc curd='^abcd$'
1400 if $diet !~ $curd
1401 echo 15.ok
1402 else
1403 echo 15.err
1404 endif
1405 __EOT
1407 check behave:if-regex 0 "${MBOX}" '1115671789 95'
1408 else
1409 printf 'behave:if-regex: unsupported, skipped\n'
1412 t_epilog
1415 t_behave_localopts() {
1416 t_prolog t_behave_localopts
1418 # Nestable conditions test
1419 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
1420 define t2 {
1421 echo in: t2
1422 set t2=t2
1423 echo $t2
1425 define t1 {
1426 echo in: t1
1427 set gv1=gv1
1428 localopts on
1429 set lv1=lv1 lv2=lv2
1430 set lv3=lv3
1431 call t2
1432 localopts off
1433 set gv2=gv2
1434 echo $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2
1436 define t0 {
1437 echo in: t0
1438 call t1
1439 echo $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2
1440 echo "$gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2"
1442 account trouble {
1443 echo in: trouble
1444 call t0
1446 call t0
1447 unset gv1 gv2
1448 account trouble
1449 echo active trouble: $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t3
1450 account null
1451 echo active null: $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t3
1454 define ll2 {
1455 localopts $1
1456 set x=2
1457 echo ll2=$x
1459 define ll1 {
1460 wysh set y=$1; shift; eval localopts $y; localopts $1; shift
1461 set x=1
1462 echo ll1.1=$x
1463 call ll2 $1
1464 echo ll1.2=$x
1466 define ll0 {
1467 wysh set y=$1; shift; eval localopts $y; localopts $1; shift
1468 set x=0
1469 echo ll0.1=$x
1470 call ll1 $y "$@"
1471 echo ll0.2=$x
1473 define llx {
1474 echo ----- $1: $2 -> $3 -> $4
1475 echo ll-1.1=$x
1476 eval localopts $1
1477 call ll0 "$@"
1478 echo ll-1.2=$x
1479 unset x
1481 define lly {
1482 call llx 'call off' on on on
1483 call llx 'call off' off on on
1484 call llx 'call off' on off on
1485 call llx 'call off' on off off
1486 localopts call-fixate on
1487 call llx 'call-fixate on' on on on
1488 call llx 'call-fixate on' off on on
1489 call llx 'call-fixate on' on off on
1490 call llx 'call-fixate on' on off off
1491 unset x;localopts call on
1492 call llx 'call on' on on on
1493 call llx 'call on' off on on
1494 call llx 'call on' on off on
1495 call llx 'call on' on off off
1497 call lly
1498 __EOT
1500 check behave:localopts 0 "${MBOX}" '4016155249 1246'
1502 t_epilog
1505 t_behave_macro_param_shift() {
1506 t_prolog t_behave_macro_param_shift
1508 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>/dev/null
1509 define t2 {
1510 echo in: t2
1511 echo t2.0 has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1512 localopts on
1513 wysh set ignerr=$1
1514 shift
1515 localopts off
1516 echo t2.1 has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1517 if [ $# > 1 ] || [ $ignerr == '' ]
1518 shift 2
1519 else
1520 ignerr shift 2
1521 endif
1522 echo t2.2:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1523 shift 0
1524 echo t2.3:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1525 if [ $# > 0 ]
1526 shift
1527 endif
1528 echo t2.4:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1530 define t1 {
1531 set errexit
1532 echo in: t1
1533 call t2 1 you get four args
1534 echo t1.1: $?';' ignerr ($ignerr) should not exist
1535 call t2 1 you get 'three args'
1536 echo t1.2: $?';' ignerr ($ignerr) should not exist
1537 call t2 1 you 'get two args'
1538 echo t1.3: $?';' ignerr ($ignerr) should not exist
1539 call t2 1 'you get one arg'
1540 echo t1.4: $?';' ignerr ($ignerr) should not exist
1541 ignerr call t2 '' 'you get one arg'
1542 echo t1.5: $?';' ignerr ($ignerr) should not exist
1544 call t1
1545 __EOT
1547 check behave:macro_param_shift 0 "${MBOX}" '1402489146 1682'
1549 t_epilog
1552 t_behave_addrcodec() {
1553 t_prolog t_behave_addrcodec
1555 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
1556 vput addrcodec res e 1 <doog@def>
1557 echo $?/$^ERRNAME $res
1558 eval vput addrcodec res d $res
1559 echo $?/$^ERRNAME $res
1560 vput addrcodec res e 2 . <doog@def>
1561 echo $?/$^ERRNAME $res
1562 eval vput addrcodec res d $res
1563 echo $?/$^ERRNAME $res
1564 vput addrcodec res e 3 Sauer Dr. <doog@def>
1565 echo $?/$^ERRNAME $res
1566 eval vput addrcodec res d $res
1567 echo $?/$^ERRNAME $res
1568 vput addrcodec res e 3.50 Sauer (Ma) Dr. <doog@def>
1569 echo $?/$^ERRNAME $res
1570 eval vput addrcodec res d $res
1571 echo $?/$^ERRNAME $res
1572 vput addrcodec res e 3.51 Sauer (Ma) "Dr." <doog@def>
1573 echo $?/$^ERRNAME $res
1574 eval vput addrcodec res d $res
1575 echo $?/$^ERRNAME $res
1577 vput addrcodec res +e 4 Sauer (Ma) Dr. <doog@def>
1578 echo $?/$^ERRNAME $res
1579 eval vput addrcodec res d $res
1580 echo $?/$^ERRNAME $res
1581 vput addrcodec res +e 5 Sauer (Ma) Braten Dr. <doog@def>
1582 echo $?/$^ERRNAME $res
1583 eval vput addrcodec res d $res
1584 echo $?/$^ERRNAME $res
1585 vput addrcodec res +e 6 Sauer (Ma) Braten Dr. (Heu) <doog@def>
1586 echo $?/$^ERRNAME $res
1587 eval vput addrcodec res d $res
1588 echo $?/$^ERRNAME $res
1589 vput addrcodec res +e 7 Sauer (Ma) Braten Dr. (Heu) <doog@def> (bu)
1590 echo $?/$^ERRNAME $res
1591 eval vput addrcodec res d $res
1592 echo $?/$^ERRNAME $res
1593 vput addrcodec res +e 8 \
1594 Dr. Sauer (Ma) Braten Dr. (Heu) <doog@def> (bu) Boom. Boom
1595 echo $?/$^ERRNAME $res
1596 eval vput addrcodec res d $res
1597 echo $?/$^ERRNAME $res
1598 vput addrcodec res +e 9 Dr.Sauer(Ma)Braten Dr. (Heu) <doog@def>
1599 echo $?/$^ERRNAME $res
1600 eval vput addrcodec res d $res
1601 echo $?/$^ERRNAME $res
1602 vput addrcodec res +e 10 (Ma)Braten Dr. (Heu) <doog@def>
1603 echo $?/$^ERRNAME $res
1604 eval vput addrcodec res d $res
1605 echo $?/$^ERRNAME $res
1606 vput addrcodec res +e 11 (Ma)Braten Dr"." (Heu) <doog@def>
1607 echo $?/$^ERRNAME $res
1608 eval vput addrcodec res d $res
1609 echo $?/$^ERRNAME $res
1610 vput addrcodec res +e 12 Dr. Sauer (Ma) Braten Dr. (u) <doog@def>
1611 echo $?/$^ERRNAME $res
1612 eval vput addrcodec res d $res
1613 echo $?/$^ERRNAME $res
1614 vput addrcodec res +e 13(Ma)Braten Dr. (Heu) <doog@def>
1615 echo $?/$^ERRNAME $res
1616 eval vput addrcodec res d $res
1617 echo $?/$^ERRNAME $res
1618 vput addrcodec res +e 14 Hey, Du <doog@def> Wie() findet Dr. das? ()
1619 echo $?/$^ERRNAME $res
1620 eval vput addrcodec res d $res
1621 echo $?/$^ERRNAME $res
1622 vput addrcodec res +e 15 \
1623 Hey, Du <doog@def> Wie() findet "" Dr. "" das? ()
1624 echo $?/$^ERRNAME $res
1625 eval vput addrcodec res d $res
1626 echo $?/$^ERRNAME $res
1627 vput addrcodec res +e 16 \
1628 "Hey," "Du" <doog@def> "Wie()" findet "" Dr. "" das? ()
1629 echo $?/$^ERRNAME $res
1630 eval vput addrcodec res d $res
1631 echo $?/$^ERRNAME $res
1632 vput addrcodec res +e 17 \
1633 "Hey" Du <doog@def> "Wie() findet " " Dr. """ das? ()
1634 echo $?/$^ERRNAME $res
1635 eval vput addrcodec res d $res
1636 echo $?/$^ERRNAME $res
1637 vput addrcodec res +e 18 \
1638 <doog@def> "Hey" Du "Wie() findet " " Dr. """ das? ()
1639 echo $?/$^ERRNAME $res
1640 eval vput addrcodec res d $res
1641 echo $?/$^ERRNAME $res
1642 vput addrcodec res +e 19 Hey\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1643 echo $?/$^ERRNAME $res
1644 eval vput addrcodec res d $res
1645 echo $?/$^ERRNAME $res
1647 vput addrcodec res ++e 20 Hey\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1648 echo $?/$^ERRNAME $res
1649 vput addrcodec res ++e 21 Hey\,\"" <doog@def> "Wie()" findet \" Dr. \" das?
1650 echo $?/$^ERRNAME $res
1651 eval vput addrcodec res d $res
1652 echo $?/$^ERRNAME $res
1654 vput addrcodec res +++e 22 Hey\\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1655 echo $?/$^ERRNAME $res
1656 eval vput addrcodec res d $res
1657 echo $?/$^ERRNAME $res
1659 vput addrcodec res s \
1660 "23 Hey\\,\\\" \"Wie" () "\" findet \\\" Dr. \\\" das?" <doog@def>
1661 echo $?/$^ERRNAME $res
1662 __EOT
1664 check behave:addrcodec 0 "${MBOX}" '429099645 2414'
1666 t_epilog
1669 t_behave_vexpr() {
1670 t_prolog t_behave_vexpr
1672 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>/dev/null
1673 vput vexpr res = 9223372036854775807
1674 echo $?/$^ERRNAME $res
1675 vput vexpr res = 9223372036854775808
1676 echo $?/$^ERRNAME $res
1677 vput vexpr res =@ 9223372036854775808
1678 echo $?/$^ERRNAME $res
1679 vput vexpr res = -9223372036854775808
1680 echo $?/$^ERRNAME $res
1681 vput vexpr res = -9223372036854775809
1682 echo $?/$^ERRNAME $res
1683 vput vexpr res =@ -9223372036854775809
1684 echo $?/$^ERRNAME $res
1685 echo ' #1'
1686 vput vexpr res ~ 0
1687 echo $?/$^ERRNAME $res
1688 vput vexpr res ~ 1
1689 echo $?/$^ERRNAME $res
1690 vput vexpr res ~ -1
1691 echo $?/$^ERRNAME $res
1692 echo ' #2'
1693 vput vexpr res + 0 0
1694 echo $?/$^ERRNAME $res
1695 vput vexpr res + 0 1
1696 echo $?/$^ERRNAME $res
1697 vput vexpr res + 1 1
1698 echo $?/$^ERRNAME $res
1699 echo ' #3'
1700 vput vexpr res + 9223372036854775807 0
1701 echo $?/$^ERRNAME $res
1702 vput vexpr res + 9223372036854775807 1
1703 echo $?/$^ERRNAME $res
1704 vput vexpr res +@ 9223372036854775807 1
1705 echo $?/$^ERRNAME $res
1706 vput vexpr res + 0 9223372036854775807
1707 echo $?/$^ERRNAME $res
1708 vput vexpr res + 1 9223372036854775807
1709 echo $?/$^ERRNAME $res
1710 vput vexpr res +@ 1 9223372036854775807
1711 echo $?/$^ERRNAME $res
1712 echo ' #4'
1713 vput vexpr res + -9223372036854775808 0
1714 echo $?/$^ERRNAME $res
1715 vput vexpr res + -9223372036854775808 -1
1716 echo $?/$^ERRNAME $res
1717 vput vexpr res +@ -9223372036854775808 -1
1718 echo $?/$^ERRNAME $res
1719 vput vexpr res + 0 -9223372036854775808
1720 echo $?/$^ERRNAME $res
1721 vput vexpr res + -1 -9223372036854775808
1722 echo $?/$^ERRNAME $res
1723 vput vexpr res +@ -1 -9223372036854775808
1724 echo $?/$^ERRNAME $res
1725 echo ' #5'
1726 vput vexpr res - 0 0
1727 echo $?/$^ERRNAME $res
1728 vput vexpr res - 0 1
1729 echo $?/$^ERRNAME $res
1730 vput vexpr res - 1 1
1731 echo $?/$^ERRNAME $res
1732 echo ' #6'
1733 vput vexpr res - 9223372036854775807 0
1734 echo $?/$^ERRNAME $res
1735 vput vexpr res - 9223372036854775807 -1
1736 echo $?/$^ERRNAME $res
1737 vput vexpr res -@ 9223372036854775807 -1
1738 echo $?/$^ERRNAME $res
1739 vput vexpr res - 0 9223372036854775807
1740 echo $?/$^ERRNAME $res
1741 vput vexpr res - -1 9223372036854775807
1742 echo $?/$^ERRNAME $res
1743 vput vexpr res - -2 9223372036854775807
1744 echo $?/$^ERRNAME $res
1745 vput vexpr res -@ -2 9223372036854775807
1746 echo $?/$^ERRNAME $res
1747 echo ' #7'
1748 vput vexpr res - -9223372036854775808 +0
1749 echo $?/$^ERRNAME $res
1750 vput vexpr res - -9223372036854775808 +1
1751 echo $?/$^ERRNAME $res
1752 vput vexpr res -@ -9223372036854775808 +1
1753 echo $?/$^ERRNAME $res
1754 vput vexpr res - 0 -9223372036854775808
1755 echo $?/$^ERRNAME $res
1756 vput vexpr res - +1 -9223372036854775808
1757 echo $?/$^ERRNAME $res
1758 vput vexpr res -@ +1 -9223372036854775808
1759 echo $?/$^ERRNAME $res
1760 echo ' #8'
1761 vput vexpr res + -13 -2
1762 echo $?/$^ERRNAME $res
1763 vput vexpr res - 0 0
1764 echo $?/$^ERRNAME $res
1765 vput vexpr res - 0 1
1766 echo $?/$^ERRNAME $res
1767 vput vexpr res - 1 1
1768 echo $?/$^ERRNAME $res
1769 vput vexpr res - -13 -2
1770 echo $?/$^ERRNAME $res
1771 echo ' #9'
1772 vput vexpr res * 0 0
1773 echo $?/$^ERRNAME $res
1774 vput vexpr res * 0 1
1775 echo $?/$^ERRNAME $res
1776 vput vexpr res * 1 1
1777 echo $?/$^ERRNAME $res
1778 vput vexpr res * -13 -2
1779 echo $?/$^ERRNAME $res
1780 echo ' #10'
1781 vput vexpr res / 0 0
1782 echo $?/$^ERRNAME $res
1783 vput vexpr res / 0 1
1784 echo $?/$^ERRNAME $res
1785 vput vexpr res / 1 1
1786 echo $?/$^ERRNAME $res
1787 vput vexpr res / -13 -2
1788 echo $?/$^ERRNAME $res
1789 echo ' #11'
1790 vput vexpr res % 0 0
1791 echo $?/$^ERRNAME $res
1792 vput vexpr res % 0 1
1793 echo $?/$^ERRNAME $res
1794 vput vexpr res % 1 1
1795 echo $?/$^ERRNAME $res
1796 vput vexpr res % -13 -2
1797 echo $?/$^ERRNAME $res
1798 __EOT
1800 check behave:vexpr-numeric 0 "${MBOX}" '1723609217 1048'
1802 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" #2>/dev/null
1803 vput vexpr res find 'bananarama' 'nana'
1804 echo $?/$^ERRNAME :$res:
1805 vput vexpr res find 'bananarama' 'bana'
1806 echo $?/$^ERRNAME :$res:
1807 vput vexpr res find 'bananarama' 'Bana'
1808 echo $?/$^ERRNAME :$res:
1809 vput vexpr res find 'bananarama' 'rama'
1810 echo $?/$^ERRNAME :$res:
1811 echo ' #1'
1812 vput vexpr res ifind 'bananarama' 'nana'
1813 echo $?/$^ERRNAME :$res:
1814 vput vexpr res ifind 'bananarama' 'bana'
1815 echo $?/$^ERRNAME :$res:
1816 vput vexpr res ifind 'bananarama' 'Bana'
1817 echo $?/$^ERRNAME :$res:
1818 vput vexpr res ifind 'bananarama' 'rama'
1819 echo $?/$^ERRNAME :$res:
1820 echo ' #2'
1821 vput vexpr res substring 'bananarama' 1
1822 echo $?/$^ERRNAME :$res:
1823 vput vexpr res substring 'bananarama' 3
1824 echo $?/$^ERRNAME :$res:
1825 vput vexpr res substring 'bananarama' 5
1826 echo $?/$^ERRNAME :$res:
1827 vput vexpr res substring 'bananarama' 7
1828 echo $?/$^ERRNAME :$res:
1829 vput vexpr res substring 'bananarama' 9
1830 echo $?/$^ERRNAME :$res:
1831 vput vexpr res substring 'bananarama' 10
1832 echo $?/$^ERRNAME :$res:
1833 vput vexpr res substring 'bananarama' 1 3
1834 echo $?/$^ERRNAME :$res:
1835 vput vexpr res substring 'bananarama' 3 3
1836 echo $?/$^ERRNAME :$res:
1837 vput vexpr res substring 'bananarama' 5 3
1838 echo $?/$^ERRNAME :$res:
1839 vput vexpr res substring 'bananarama' 7 3
1840 echo $?/$^ERRNAME :$res:
1841 vput vexpr res substring 'bananarama' 9 3
1842 echo $?/$^ERRNAME :$res:
1843 vput vexpr res substring 'bananarama' 10 3
1844 echo $?/$^ERRNAME :$res:
1845 echo ' #3'
1846 vput vexpr res substring 'bananarama' -1
1847 echo $?/$^ERRNAME :$res:
1848 vput vexpr res substring 'bananarama' -3
1849 echo $?/$^ERRNAME :$res:
1850 vput vexpr res substring 'bananarama' -5
1851 echo $?/$^ERRNAME :$res:
1852 vput vexpr res substring 'bananarama' -7
1853 echo $?/$^ERRNAME :$res:
1854 vput vexpr res substring 'bananarama' -9
1855 echo $?/$^ERRNAME :$res:
1856 vput vexpr res substring 'bananarama' -10
1857 echo $?/$^ERRNAME :$res:
1858 vput vexpr res substring 'bananarama' 1 -3
1859 echo $?/$^ERRNAME :$res:
1860 vput vexpr res substring 'bananarama' 3 -3
1861 echo $?/$^ERRNAME :$res:
1862 vput vexpr res substring 'bananarama' 5 -3
1863 echo $?/$^ERRNAME :$res:
1864 vput vexpr res substring 'bananarama' 7 -3
1865 echo $?/$^ERRNAME :$res:
1866 vput vexpr res substring 'bananarama' 9 -3
1867 echo $?/$^ERRNAME :$res:
1868 vput vexpr res substring 'bananarama' 10 -3
1869 echo $?/$^ERRNAME :$res:
1870 echo ' #4'
1871 vput vexpr res trim 'Cocoon Cocoon'
1872 echo $?/$^ERRNAME :$res:
1873 vput vexpr res trim ' Cocoon Cocoon '
1874 echo $?/$^ERRNAME :$res:
1875 vput vexpr res trim-front 'Cocoon Cocoon'
1876 echo $?/$^ERRNAME :$res:
1877 vput vexpr res trim-front ' Cocoon Cocoon '
1878 echo $?/$^ERRNAME :$res:
1879 vput vexpr res trim-end 'Cocoon Cocoon'
1880 echo $?/$^ERRNAME :$res:
1881 vput vexpr res trim-end ' Cocoon Cocoon '
1882 echo $?/$^ERRNAME :$res:
1883 __EOT
1885 check behave:vexpr-string 0 "${MBOX}" '3182004322 601'
1887 if have_feat regex; then
1888 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" #2>/dev/null
1889 vput vexpr res regex 'bananarama' 'nana'
1890 echo $?/$^ERRNAME :$res:
1891 vput vexpr res regex 'bananarama' 'bana'
1892 echo $?/$^ERRNAME :$res:
1893 vput vexpr res regex 'bananarama' 'Bana'
1894 echo $?/$^ERRNAME :$res:
1895 vput vexpr res regex 'bananarama' 'rama'
1896 echo $?/$^ERRNAME :$res:
1897 echo ' #1'
1898 vput vexpr res iregex 'bananarama' 'nana'
1899 echo $?/$^ERRNAME :$res:
1900 vput vexpr res iregex 'bananarama' 'bana'
1901 echo $?/$^ERRNAME :$res:
1902 vput vexpr res iregex 'bananarama' 'Bana'
1903 echo $?/$^ERRNAME :$res:
1904 vput vexpr res iregex 'bananarama' 'rama'
1905 echo $?/$^ERRNAME :$res:
1906 echo ' #2'
1907 vput vexpr res regex 'bananarama' '(.*)nana(.*)' '\${1}a\${0}u{\$2}'
1908 echo $?/$^ERRNAME :$res:
1909 vput vexpr res regex 'bananarama' '(.*)bana(.*)' '\${1}a\${0}u\$2'
1910 echo $?/$^ERRNAME :$res:
1911 vput vexpr res regex 'bananarama' 'Bana(.+)' '\$1\$0'
1912 echo $?/$^ERRNAME :$res:
1913 vput vexpr res regex 'bananarama' '(.+)rama' '\$1\$0'
1914 echo $?/$^ERRNAME :$res:
1915 echo ' #3'
1916 vput vexpr res iregex 'bananarama' '(.*)nana(.*)' '\${1}a\${0}u{\$2}'
1917 echo $?/$^ERRNAME :$res:
1918 vput vexpr res iregex 'bananarama' '(.*)bana(.*)' '\${1}a\${0}u\$2'
1919 echo $?/$^ERRNAME :$res:
1920 vput vexpr res iregex 'bananarama' 'Bana(.+)' '\$1\$0'
1921 echo $?/$^ERRNAME :$res:
1922 vput vexpr res iregex 'bananarama' '(.+)rama' '\$1\$0'
1923 echo $?/$^ERRNAME :$res:
1924 echo ' #4'
1925 __EOT
1927 check behave:vexpr-regex 0 "${MBOX}" '3270360157 311'
1928 else
1929 printf 'behave:vexpr-regex: unsupported, skipped\n'
1932 t_epilog
1935 t_behave_call_ret() {
1936 t_prolog t_behave_call_ret
1938 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Snomemdebug > "${MBOX}" 2>&1
1939 define w1 {
1940 echon ">$1 "
1941 vput vexpr i + $1 1
1942 if [ $i -le 42 ]
1943 vput vexpr j '&' $i 7
1944 if [ $j -eq 7 ]
1945 echo .
1947 call w1 $i
1948 wysh set i=$? k=$!
1949 vput vexpr j '&' $i 7
1950 echon "<$1/$i/$k "
1951 if [ $j -eq 7 ]
1952 echo .
1954 else
1955 echo ! The end for $1
1957 return $1
1959 # Transport $?/$! up the call chain
1960 define w2 {
1961 echon ">$1 "
1962 vput vexpr i + $1 1
1963 if [ $1 -lt 42 ]
1964 call w2 $i
1965 wysh set i=$? j=$! k=$^ERRNAME
1966 echon "<$1/$i/$k "
1967 return $i $j
1968 else
1969 echo ! The end for $1
1970 return $i $^ERR-BUSY
1972 echoerr au
1974 # Up and down it goes
1975 define w3 {
1976 echon ">$1/$2 "
1977 vput vexpr i + $1 1
1978 if [ $1 -lt 42 ]
1979 call w3 $i $2
1980 wysh set i=$? j=$!
1981 vput vexpr k - $1 $2
1982 if [ $k -eq 21 ]
1983 vput vexpr i + $1 1
1984 vput vexpr j + $2 1
1985 echo "# <$i/$j> .. "
1986 call w3 $i $j
1987 wysh set i=$? j=$!
1989 eval echon "<\$1=\$i/\$^ERRNAME-$j "
1990 return $i $j
1991 else
1992 echo ! The end for $1=$i/$2
1993 if [ "$2" != "" ]
1994 return $i $^ERR-DOM
1995 else
1996 return $i $^ERR-BUSY
1999 echoerr au
2002 call w1 0; echo ?=$? !=$!; echo -----;
2003 call w2 0; echo ?=$? !=$^ERRNAME; echo -----;
2004 call w3 0 1; echo ?=$? !=$^ERRNAME; echo -----;
2005 __EOT
2007 check behave:call_ret 0 "${MBOX}" '1572045517 5922'
2009 t_epilog
2012 t_behave_xcall() {
2013 t_prolog t_behave_xcall
2015 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Snomemdebug > "${MBOX}" 2>&1
2016 define work {
2017 echon "$1 "
2018 vput vexpr i + $1 1
2019 if [ $i -le 1111 ]
2020 vput vexpr j '&' $i 7
2021 if [ $j -eq 7 ]
2022 echo .
2024 \xcall work $i $2
2026 echo ! The end for $1/$2
2027 if [ "$2" != "" ]
2028 return $i $^ERR-BUSY
2031 define xwork {
2032 \xcall work 0 $2
2034 call work 0
2035 echo ?=$? !=$!
2036 call xwork
2037 echo ?=$? !=$!
2038 xcall xwork
2039 echo ?=$? !=$^ERRNAME
2041 call work 0 yes
2042 echo ?=$? !=$^ERRNAME
2043 call xwork 0 yes
2044 echo ?=$? !=$^ERRNAME
2045 __EOT
2047 check behave:xcall-1 0 "${MBOX}" '2401702082 23801'
2051 ${cat} <<- '__EOT' > "${BODY}"
2052 define __w {
2053 echon "$1 "
2054 vput vexpr i + $1 1
2055 if [ $i -le 111 ]
2056 vput vexpr j '&' $i 7
2057 if [ $j -eq 7 ]
2058 echo .
2060 \xcall __w $i $2
2062 echo ! The end for $1
2063 if [ $2 -eq 0 ]
2064 nonexistingcommand
2065 echo would be err with errexit
2066 return
2068 echo calling exit
2069 exit
2071 define work {
2072 echo eins
2073 call __w 0 0
2074 echo zwei, ?=$? !=$!
2075 localopts yes; set errexit
2076 ignerr call __w 0 0
2077 echo drei, ?=$? !=$^ERRNAME
2078 call __w 0 $1
2079 echo vier, ?=$? !=$^ERRNAME, this is an error
2081 ignerr call work 0
2082 echo outer 1, ?=$? !=$^ERRNAME
2083 xxxign call work 0
2084 echo outer 2, ?=$? !=$^ERRNAME, could be error if xxxign non-empty
2085 call work 1
2086 echo outer 3, ?=$? !=$^ERRNAME
2087 echo this is definitely an error
2088 __EOT
2090 < "${BODY}" ${MAILX} ${ARGS} -X'commandalias xxxign ignerr' -Snomemdebug \
2091 > "${MBOX}" 2>&1
2092 check behave:xcall-2 0 "${MBOX}" '3900716531 4200'
2094 < "${BODY}" ${MAILX} ${ARGS} -X'commandalias xxxign " "' -Snomemdebug \
2095 > "${MBOX}" 2>&1
2096 check behave:xcall-3 1 "${MBOX}" '1006776201 2799'
2098 t_epilog
2101 t_behave_vpospar() {
2102 t_prolog t_behave_vpospar
2104 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
2105 vpospar set hey, "'you ", world!
2106 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2107 vput vpospar x quote; echo x<$x>
2108 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2109 vput vpospar y quote;echo y<$y>
2110 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2111 eval vpospar set ${y};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2112 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2114 define infun2 {
2115 echo infun2:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2116 vput vpospar z quote;echo infun2:z<$z>
2119 define infun {
2120 echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2121 vput vpospar y quote;echo infun:y<$y>
2122 eval vpospar set ${x};echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2123 vpospar clear;echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2124 eval call infun2 $x
2125 echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2126 eval vpospar set ${y};echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2129 call infun This "in a" fun
2130 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2131 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2132 __EOT
2133 check behave:vpospar-1 0 "${MBOX}" '155175639 866'
2136 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
2137 set ifs=\'
2138 echo ifs<$ifs> ifs-ws<$ifs-ws>
2139 vpospar set hey, "'you ", world!
2140 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2141 vput vpospar x quote; echo x<$x>
2142 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2143 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2145 set ifs=,
2146 echo ifs<$ifs> ifs-ws<$ifs-ws>
2147 vpospar set hey, "'you ", world!
2148 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2149 vput vpospar x quote; echo x<$x>
2150 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2151 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2153 wysh set ifs=$',\t'
2154 echo ifs<$ifs> ifs-ws<$ifs-ws>
2155 vpospar set hey, "'you ", world!
2156 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2157 vput vpospar x quote; echo x<$x>
2158 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2159 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2160 __EOT
2161 check behave:vpospar-ifs 0 "${MBOX}" '2015927702 706'
2163 t_epilog
2166 t_behave_atxplode() {
2167 t_prolog t_behave_atxplode
2168 TRAP_EXIT_ADDONS="./.t*"
2170 ${cat} > ./.t.sh <<- '___'; ${cat} > ./.t.rc <<- '___'
2171 x() { echo $#; }
2172 xxx() {
2173 printf " (1/$#: <$1>)"
2174 shift
2175 if [ $# -gt 0 ]; then
2176 xxx "$@"
2177 else
2178 echo
2181 yyy() {
2182 eval "$@ ' ball"
2184 set --
2185 x "$@"
2186 x "$@"''
2187 x " $@"
2188 x "$@ "
2189 printf yyy;yyy 'xxx' "b\$'\t'u ' "
2190 printf xxx;xxx arg ,b u.
2191 printf xxx;xxx arg , .
2192 printf xxx;xxx arg ,ball.
2194 define x {
2195 echo $#
2197 define xxx {
2198 echon " (1/$#: <$1>)"
2199 shift
2200 if [ $# -gt 0 ]
2201 \xcall xxx "$@"
2202 endif
2203 echo
2205 define yyy {
2206 eval "$@ ' ball"
2208 vpospar set
2209 call x "$@"
2210 call x "$@"''
2211 call x " $@"
2212 call x "$@ "
2213 echon yyy;call yyy '\call xxx' "b\$'\t'u ' "
2214 echon xxx;call xxx arg ,b u.
2215 echon xxx;call xxx arg , .
2216 echon xxx;call xxx arg ,ball.
2219 ${MAILX} ${ARGS} -X'source ./.t.rc' -Xx > "${MBOX}" 2>&1
2220 check behave:atxplode-1 0 "${MBOX}" '41566293 164'
2222 #${SHELL} ./.t.sh > ./.tshout 2>&1
2223 #check behave:atxplode:disproof-1 0 ./.tshout '41566293 164'
2225 t_epilog
2228 t_behave_read() {
2229 t_prolog t_behave_read
2230 TRAP_EXIT_ADDONS="./.t*"
2232 ${cat} <<- '__EOT' > .tin
2233 hey1, "'you ", world!
2234 hey2, "'you ", bugs bunny!
2235 hey3, "'you ",
2236 hey4, "'you "
2237 __EOT
2239 ${cat} <<- '__EOT' |\
2240 ${MAILX} ${ARGS} -X'readctl create ./.tin' > "${MBOX}" 2>&1
2241 read a b c
2242 echo $?/$^ERRNAME / <$a><$b><$c>
2243 read a b c
2244 echo $?/$^ERRNAME / <$a><$b><$c>
2245 read a b c
2246 echo $?/$^ERRNAME / <$a><$b><$c>
2247 read a b c
2248 echo $?/$^ERRNAME / <$a><$b><$c>
2249 unset a b c;read a b c
2250 echo $?/$^ERRNAME / <$a><$b><$c>
2251 readctl remove ./.tin;echo readctl remove:$?/$^ERRNAME
2252 __EOT
2253 check behave:read-1 0 "${MBOX}" '1527910147 173'
2255 ${cat} <<- '__EOT' > .tin2
2256 hey2.0,:"'you ",:world!:mars.:
2257 hey2.1,:"'you ",:world!
2258 hey2.2,:"'you ",:bugs bunny!
2259 hey2.3,:"'you ",:
2260 hey2.4,:"'you ":
2262 __EOT
2264 ${cat} <<- '__EOT' |\
2265 6< .tin2 ${MAILX} ${ARGS} -X 'readctl create 6' > "${MBOX}" 2>&1
2266 set ifs=:
2267 read a b c
2268 echo $?/$^ERRNAME / <$a><$b><$c>
2269 read a b c
2270 echo $?/$^ERRNAME / <$a><$b><$c>
2271 read a b c
2272 echo $?/$^ERRNAME / <$a><$b><$c>
2273 read a b c
2274 echo $?/$^ERRNAME / <$a><$b><$c>
2275 read a b c
2276 echo $?/$^ERRNAME / <$a><$b><$c>
2277 read a b c
2278 echo $?/$^ERRNAME / <$a><$b><$c>
2279 unset a b c;read a b c
2280 echo $?/$^ERRNAME / <$a><$b><$c>
2281 read a b c
2282 echo $?/$^ERRNAME / <$a><$b><$c>
2283 readctl remove 6;echo readctl remove:$?/$^ERRNAME
2284 __EOT
2285 check behave:read-ifs 0 "${MBOX}" '890153490 298'
2287 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
2288 readctl create .tin
2289 readall d; echo $?/$^ERRNAME / <$d>
2290 wysh set d;readall d;echo $?/$^ERRNAME / <$d>
2291 readctl create .tin2
2292 readall d; echo $?/$^ERRNAME / <$d>
2293 wysh set d;readall d;echo $?/$^ERRNAME / <$d>
2294 readctl remove .tin;echo $?/$^ERRNAME;\
2295 readctl remove .tin2;echo $?/$^ERRNAME
2296 __EOT
2297 check behave:readall 0 "${MBOX}" '860434889 333'
2299 t_epilog
2302 t_behave_mbox() {
2303 t_prolog t_behave_mbox
2304 TRAP_EXIT_ADDONS="./.t*"
2308 while [ ${i} -lt 112 ]; do
2309 printf 'm file://%s\n~s Subject %s\nHello %s!\n~.\n' \
2310 "${MBOX}" "${i}" "${i}"
2311 i=`add ${i} 1`
2312 done
2313 ) | ${MAILX} ${ARGS}
2314 check behave:mbox-1 0 "${MBOX}" '1140119864 13780'
2316 printf 'File "%s"\ncopy * "%s"\nFile "%s"\nfrom*' "${MBOX}" .tmbox1 .tmbox1 |
2317 ${MAILX} ${ARGS} > .tlst
2318 check behave:mbox-2 0 .tlst '2739893312 9103'
2320 printf 'File "%s"\ncopy * "file://%s"\nFile "file://%s"\nfrom*' \
2321 "${MBOX}" .tmbox2 .tmbox2 | ${MAILX} ${ARGS} > .tlst
2322 check behave:mbox-3 0 .tlst '1702194178 9110'
2324 # only the odd (even)
2326 printf 'File "file://%s"\ncopy ' .tmbox2
2328 while [ ${i} -lt 112 ]; do
2329 j=`modulo ${i} 2`
2330 [ ${j} -eq 1 ] && printf '%s ' "${i}"
2331 i=`add ${i} 1`
2332 done
2333 printf 'file://%s\nFile "file://%s"\nfrom*' .tmbox3 .tmbox3
2334 ) | ${MAILX} ${ARGS} > .tlst
2335 check behave:mbox-4 0 .tmbox3 '631132924 6890'
2336 check behave:mbox-5 - .tlst '2960975049 4573'
2337 # ...
2339 printf 'file "file://%s"\nmove ' .tmbox2
2341 while [ ${i} -lt 112 ]; do
2342 j=`modulo ${i} 2`
2343 [ ${j} -eq 0 ] && [ ${i} -ne 0 ] && printf '%s ' "${i}"
2344 i=`add ${i} 1`
2345 done
2346 printf 'file://%s\nFile "file://%s"\nfrom*\nFile "file://%s"\nfrom*' \
2347 .tmbox3 .tmbox3 .tmbox2
2348 ) | ${MAILX} ${ARGS} > .tlst
2349 check behave:mbox-6 0 .tmbox3 '1387070539 13655'
2350 ${sed} 2d < .tlst > .tlstx
2351 check behave:mbox-7 - .tlstx '2729940494 13645'
2353 t_epilog
2356 t_behave_alternates() {
2357 t_prolog t_behave_alternates
2358 TRAP_EXIT_ADDONS="./.t*"
2360 ${cat} <<-_EOT > ./.tsendmail.sh
2361 #!${SHELL} -
2362 (echo 'From Valeriana Sat Jul 08 15:54:03 2017' && ${cat} && echo
2363 ) >> "${MBOX}"
2364 _EOT
2365 chmod 0755 ./.tsendmail.sh
2367 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Smta=./.tsendmail.sh > ./.tall 2>&1
2368 echo --0
2369 alternates
2370 echo $?/$^ERRNAME
2371 alternates a1@b1 a2@b2 a3@b3
2372 echo $?/$^ERRNAME
2373 alternates
2374 echo $?/$^ERRNAME
2375 vput alternates rv
2376 echo $?/$^ERRNAME <$rv>
2378 echo --1
2379 unalternates a2@b2
2380 vput alternates rv
2381 echo $?/$^ERRNAME <$rv>
2382 unalternates a3@b3
2383 vput alternates rv
2384 echo $?/$^ERRNAME <$rv>
2385 unalternates a1@b1
2386 vput alternates rv
2387 echo $?/$^ERRNAME <$rv>
2389 echo --2
2390 unalternates *
2391 alternates a1@b1 a2@b2 a3@b3
2392 unalternates a3@b3
2393 vput alternates rv
2394 echo $?/$^ERRNAME <$rv>
2395 unalternates a2@b2
2396 vput alternates rv
2397 echo $?/$^ERRNAME <$rv>
2398 unalternates a1@b1
2399 vput alternates rv
2400 echo $?/$^ERRNAME <$rv>
2402 echo --3
2403 alternates a1@b1 a2@b2 a3@b3
2404 unalternates a1@b1
2405 vput alternates rv
2406 echo $?/$^ERRNAME <$rv>
2407 unalternates a2@b2
2408 vput alternates rv
2409 echo $?/$^ERRNAME <$rv>
2410 unalternates a3@b3
2411 vput alternates rv
2412 echo $?/$^ERRNAME <$rv>
2414 echo --4
2415 unalternates *
2416 alternates a1@b1 a2@b2 a3@b3
2417 unalternates *
2418 vput alternates rv
2419 echo $?/$^ERRNAME <$rv>
2421 echo --5
2422 unalternates *
2423 alternates a1@b1 a1@c1 a1@d1 a2@b2 a3@b3 a3@c3 a3@d3
2424 m a1@b1 a1@c1 a1@d1
2425 ~s all alternates, only a1@b1 remains
2426 ~c a2@b2
2427 ~b a3@b3 a3@c3 a3@d3
2428 ~r - '_EOT'
2429 This body is!
2430 This also body is!!
2431 _EOT
2434 echo --6
2435 unalternates *
2436 alternates a1@b1 a1@c1 a2@b2 a3@b3
2437 m a1@b1 a1@c1 a1@d1
2438 ~s a1@b1 a1@d1, and a3@c3 a3@d3 remain
2439 ~c a2@b2
2440 ~b a3@b3 a3@c3 a3@d3
2441 ~r - '_EOT'
2442 This body2 is!
2443 _EOT
2446 echo --7
2447 alternates a1@b1 a2@b2 a3; set allnet
2448 m a1@b1 a1@c1 a1@d1
2449 ~s all alternates via allnet, only a1@b1 remains
2450 ~c a2@b2
2451 ~b a3@b3 a3@c3 a3@d3
2452 ~r - '_EOT'
2453 This body3 is!
2454 _EOT
2457 echo --10
2458 unalternates *
2459 alternates a1@b1
2460 echo $?/$^ERRNAME
2461 vput alternates rv
2462 echo $?/$^ERRNAME <$rv>
2463 alternates a2@b2
2464 echo $?/$^ERRNAME
2465 vput alternates rv
2466 echo $?/$^ERRNAME <$rv>
2467 alternates a3@b3
2468 echo $?/$^ERRNAME
2469 vput alternates rv
2470 echo $?/$^ERRNAME <$rv>
2471 alternates a4@b4
2472 echo $?/$^ERRNAME
2473 vput alternates rv
2474 echo $?/$^ERRNAME <$rv>
2476 unalternates *
2477 vput alternates rv
2478 echo $?/$^ERRNAME <$rv>
2480 echo --11
2481 set posix
2482 alternates a1@b1 a2@b2
2483 echo $?/$^ERRNAME
2484 vput alternates rv
2485 echo $?/$^ERRNAME <$rv>
2486 alternates a3@b3 a4@b4
2487 echo $?/$^ERRNAME
2488 vput alternates rv
2489 echo $?/$^ERRNAME <$rv>
2490 __EOT
2491 check behave:alternates-1 0 "${MBOX}" '142184864 515'
2492 check behave:alternates-2 - .tall '1878598364 505'
2494 t_epilog
2497 t_behave_alias() {
2498 t_prolog t_behave_alias
2499 TRAP_EXIT_ADDONS="./.t*"
2501 ${cat} <<-_EOT > ./.tsendmail.sh
2502 #!${SHELL} -
2503 (echo 'From Hippocastanum Mon Jun 19 15:07:07 2017' && ${cat} && echo
2504 ) >> "${MBOX}"
2505 _EOT
2506 chmod 0755 ./.tsendmail.sh
2508 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Smta=./.tsendmail.sh > ./.tall 2>&1
2509 alias a1 ex1@a1.ple
2510 alias a1 ex2@a1.ple "EX3 <ex3@a1.ple>"
2511 alias a1 ex4@a1.ple
2512 alias a2 ex1@a2.ple ex2@a2.ple ex3@a2.ple ex4@a2.ple
2513 alias a3 a4
2514 alias a4 a5 ex1@a4.ple
2515 alias a5 a6
2516 alias a6 a7 ex1@a6.ple
2517 alias a7 a8
2518 alias a8 ex1@a8.ple
2519 alias a1
2520 alias a2
2521 alias a3
2522 m a1
2523 ~c a2
2524 ~b a3
2525 ~r - '_EOT'
2526 This body is!
2527 This also body is!!
2528 _EOT
2529 __EOT
2530 check behave:alias-1 0 "${MBOX}" '2496925843 272'
2531 check behave:alias-2 - .tall '3548953204 152'
2533 # TODO t_behave_alias: n_ALIAS_MAXEXP is compile-time constant,
2534 # TODO need to somehow provide its contents to the test, then test
2536 t_epilog
2539 t_behave_filetype() {
2540 t_prolog t_behave_filetype
2541 TRAP_EXIT_ADDONS="./.t*"
2543 ${cat} <<-_EOT > ./.tsendmail.sh
2544 #!${SHELL} -
2545 (echo 'From Alchemilla Wed Apr 25 15:12:13 2017' && ${cat} && echo
2546 ) >> "${MBOX}"
2547 _EOT
2548 chmod 0755 ./.tsendmail.sh
2550 printf 'm m1@e.t\nL1\nHy1\n~.\nm m2@e.t\nL2\nHy2\n~@ %s\n~.\n' \
2551 "${SRCDIR}snailmail.jpg" | ${MAILX} ${ARGS} -Smta=./.tsendmail.sh
2552 check behave:filetype-1 0 "${MBOX}" '1594682963 13520'
2554 if (gzip -h) >/dev/null 2>&1; then
2555 ${rm} -f ./.t.mbox*
2557 printf 'File "%s"\ncopy 1 ./.t.mbox.gz\ncopy 2 ./.t.mbox.gz' \
2558 "${MBOX}" | ${MAILX} ${ARGS} \
2559 -X'filetype gz '"${gzip}"'\ -dc '"${gzip}"'\ -c'
2560 printf 'File ./.t.mbox.gz\ncopy * ./.t.mbox\n' |
2561 ${MAILX} ${ARGS} -X'filetype gz '"${gzip}"'\ -dc '"${gzip}"'\ -c'
2562 } > ./.t.out 2>&1
2563 check behave:filetype-2 - "./.t.mbox" '1594682963 13520'
2564 check behave:filetype-3 - "./.t.out" '2494681730 102'
2565 else
2566 echo 'behave:filetype-2: unsupported, skipped'
2567 echo 'behave:filetype-3: unsupported, skipped'
2571 ${rm} -f ./.t.mbox*
2572 printf 'File "%s"\ncopy 1 ./.t.mbox.gz
2573 copy 2 ./.t.mbox.gz
2574 copy 1 ./.t.mbox.gz
2575 copy 2 ./.t.mbox.gz
2576 ' "${MBOX}" |
2577 ${MAILX} ${ARGS} \
2578 -X'filetype gz gzip\ -dc gzip\ -c' \
2579 -X'filetype mbox.gz "${sed} 1,3d|${cat}" \
2580 "echo eins;echo zwei;echo und mit ${sed} bist Du dabei;${cat}"'
2581 printf 'File ./.t.mbox.gz\ncopy * ./.t.mbox\n' |
2582 ${MAILX} ${ARGS} \
2583 -X'filetype gz gzip\ -dc gzip\ -c' \
2584 -X'filetype mbox.gz "${sed} 1,3d|${cat}" kill\ 0'
2585 } > ./.t.out 2>&1
2586 check behave:filetype-4 - "./.t.mbox" '2886541147 27060'
2587 check behave:filetype-5 - "./.t.out" '838452520 172'
2589 t_epilog
2592 t_behave_record_a_resend() {
2593 t_prolog t_behave_record_a_resend
2594 TRAP_EXIT_ADDONS="./.t.record ./.t.resent"
2596 printf '
2597 set record=%s
2598 m %s\n~s Subject 1.\nHello.\n~.
2599 set record-files add-file-recipients
2600 m %s\n~s Subject 2.\nHello.\n~.
2601 File %s
2602 resend 2 ./.t.resent
2603 Resend 1 ./.t.resent
2604 set record-resent
2605 resend 2 ./.t.resent
2606 Resend 1 ./.t.resent
2607 ' ./.t.record "${MBOX}" "${MBOX}" "${MBOX}" |
2608 ${MAILX} ${ARGS}
2610 check behave:record_a_resend-1 0 "${MBOX}" '3057873538 256'
2611 check behave:record_a_resend-2 - .t.record '391356429 460'
2612 check behave:record_a_resend-3 - .t.resent '2685231691 648'
2614 t_epilog
2617 t_behave_e_H_L_opts() {
2618 t_prolog t_behave_e_H_L_opts
2619 TRAP_EXIT_ADDONS="./.tsendmail.sh ./.t.mbox"
2621 touch ./.t.mbox
2622 ${MAILX} ${ARGS} -ef ./.t.mbox
2623 echo ${?} > "${MBOX}"
2625 ${cat} <<-_EOT > ./.tsendmail.sh
2626 #!${SHELL} -
2627 (echo 'From Alchemilla Wed Apr 07 17:03:33 2017' && ${cat} && echo
2628 ) >> "./.t.mbox"
2629 _EOT
2630 chmod 0755 ./.tsendmail.sh
2631 printf 'm me@exam.ple\nLine 1.\nHello.\n~.\n' |
2632 ${MAILX} ${ARGS} -Smta=./.tsendmail.sh
2633 printf 'm you@exam.ple\nLine 1.\nBye.\n~.\n' |
2634 ${MAILX} ${ARGS} -Smta=./.tsendmail.sh
2636 ${MAILX} ${ARGS} -ef ./.t.mbox
2637 echo ${?} >> "${MBOX}"
2638 ${MAILX} ${ARGS} -efL @t@me ./.t.mbox
2639 echo ${?} >> "${MBOX}"
2640 ${MAILX} ${ARGS} -efL @t@you ./.t.mbox
2641 echo ${?} >> "${MBOX}"
2642 ${MAILX} ${ARGS} -efL '@>@Line 1' ./.t.mbox
2643 echo ${?} >> "${MBOX}"
2644 ${MAILX} ${ARGS} -efL '@>@Hello.' ./.t.mbox
2645 echo ${?} >> "${MBOX}"
2646 ${MAILX} ${ARGS} -efL '@>@Bye.' ./.t.mbox
2647 echo ${?} >> "${MBOX}"
2648 ${MAILX} ${ARGS} -efL '@>@Good bye.' ./.t.mbox
2649 echo ${?} >> "${MBOX}"
2651 ${MAILX} ${ARGS} -fH ./.t.mbox >> "${MBOX}"
2652 echo ${?} >> "${MBOX}"
2653 ${MAILX} ${ARGS} -fL @t@me ./.t.mbox >> "${MBOX}"
2654 echo ${?} >> "${MBOX}"
2655 ${MAILX} ${ARGS} -fL @t@you ./.t.mbox >> "${MBOX}"
2656 echo ${?} >> "${MBOX}"
2657 ${MAILX} ${ARGS} -fL '@>@Line 1' ./.t.mbox >> "${MBOX}"
2658 echo ${?} >> "${MBOX}"
2659 ${MAILX} ${ARGS} -fL '@>@Hello.' ./.t.mbox >> "${MBOX}"
2660 echo ${?} >> "${MBOX}"
2661 ${MAILX} ${ARGS} -fL '@>@Bye.' ./.t.mbox >> "${MBOX}"
2662 echo ${?} >> "${MBOX}"
2663 ${MAILX} ${ARGS} -fL '@>@Good bye.' ./.t.mbox >> "${MBOX}" 2>/dev/null
2664 echo ${?} >> "${MBOX}"
2666 check behave:e_H_L_opts - "${MBOX}" '1708955574 678'
2668 t_epilog
2671 t_behave_compose_hooks() { # TODO monster
2672 t_prolog t_behave_compose_hooks
2673 TRAP_EXIT_ADDONS="./.t*"
2675 (echo line one&&echo line two&&echo line three) > ./.treadctl
2676 (echo echo four&&echo echo five&&echo echo six) > ./.tattach
2678 ${cat} <<-_EOT > ./.tsendmail.sh
2679 #!${SHELL} -
2680 (echo 'From PrimulaVeris Wed Apr 10 22:59:00 2017' && ${cat} && echo
2681 ) >> "${MBOX}"
2682 _EOT
2683 chmod 0755 ./.tsendmail.sh
2685 ${cat} <<'__EOT__' > ./.trc
2686 define bail {
2687 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
2689 define xerr {
2690 vput vexpr es substr "$1" 0 1
2691 if [ "$es" != 2 ]
2692 xcall bail "$2"
2695 define read_mline_res {
2696 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
2697 echo $len/$es/$^ERRNAME: $hl
2698 if [ $es -ne $^ERR-NONE ]
2699 xcall bail read_mline_res
2700 elif [ $len -ne 0 ]
2701 \xcall read_mline_res
2704 define ins_addr {
2705 wysh set xh=$1
2706 echo "~^header list"; read hl; echo $hl;\
2707 call xerr "$hl" "in_addr ($xh) 0-1"
2709 echo "~^header insert $xh diet <$xh@exam.ple> spliced";\
2710 read es; echo $es; call xerr "$es" "ins_addr $xh 1-1"
2711 echo "~^header insert $xh <${xh}2@exam.ple>";\
2712 read es; echo $es; call xerr "$es" "ins_addr $xh 1-2"
2713 echo "~^header insert $xh ${xh}3@exam.ple";\
2714 read es; echo $es; call xerr "$es" "ins_addr $xh 1-3"
2715 echo "~^header list $xh"; read hl; echo $hl;\
2716 call xerr "$hl" "ins_addr $xh 1-4"
2717 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 1-5"
2718 call read_mline_res
2720 if [ "$t_remove" == "" ]
2721 return
2724 echo "~^header remove $xh"; read es; call xerr $es "ins_addr $xh 2-1"
2725 echo "~^header remove $xh"; read es; vput vexpr es substr $es 0 3
2726 if [ $es != 501 ]
2727 xcall bail "ins_addr $xh 2-2"
2729 echo "~^header list $xh"; read es; vput vexpr es substr $es 0 3
2730 if [ $es != 501 ]
2731 xcall bail "ins_addr $xh 2-3"
2733 echo "~^header show $xh"; read es; vput vexpr es substr $es 0 3
2734 if [ $es != 501 ]
2735 xcall bail "ins_addr $xh 2-4"
2739 echo "~^header insert $xh diet <$xh@exam.ple> spliced";\
2740 read es; echo $es; call xerr "$es" "ins_addr $xh 3-1"
2741 echo "~^header insert $xh <${xh}2@exam.ple>";\
2742 read es; echo $es; call xerr "$es" "ins_addr $xh 3-2"
2743 echo "~^header insert $xh ${xh}3@exam.ple";\
2744 read es; echo $es; call xerr "$es" "ins_addr $xh 3-3"
2745 echo "~^header list $xh"; read hl; echo $hl;\
2746 call xerr "$hl" "ins_addr $xh 3-4"
2747 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 3-5"
2748 call read_mline_res
2750 echo "~^header remove-at $xh 1"; read es;\
2751 call xerr $es "ins_addr $xh 3-6"
2752 echo "~^header remove-at $xh 1"; read es;\
2753 call xerr $es "ins_addr $xh 3-7"
2754 echo "~^header remove-at $xh 1"; read es;\
2755 call xerr $es "ins_addr $xh 3-8"
2756 echo "~^header remove-at $xh 1"; read es;\
2757 vput vexpr es substr $es 0 3
2758 if [ $es != 501 ]
2759 xcall bail "ins_addr $xh 3-9"
2761 echo "~^header remove-at $xh T"; read es;\
2762 vput vexpr es substr $es 0 3
2763 if [ $es != 505 ]
2764 xcall bail "ins_addr $xh 3-10"
2766 echo "~^header list $xh"; read es;\
2767 vput vexpr es substr $es 0 3
2768 if [ $es != 501 ]
2769 xcall bail "ins_addr $xh 3-11"
2771 echo "~^header show $xh"; read es;\
2772 vput vexpr es substr $es 0 3
2773 if [ $es != 501 ]
2774 xcall bail "ins_addr $xh 3-12"
2778 echo "~^header insert $xh diet <$xh@exam.ple> spliced";\
2779 read es; echo $es; call xerr "$es" "ins_addr $xh 4-1"
2780 echo "~^header insert $xh <${xh}2@exam.ple> (comment) \"Quot(e)d\"";\
2781 read es; echo $es; call xerr "$es" "ins_addr $xh 4-2"
2782 echo "~^header insert $xh ${xh}3@exam.ple";\
2783 read es; echo $es; call xerr "$es" "ins_addr $xh 4-3"
2784 echo "~^header list $xh"; read hl; echo $hl;\
2785 call xerr "$hl" "header list $xh 3-4"
2786 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 4-5"
2787 call read_mline_res
2789 echo "~^header remove-at $xh 3"; read es;\
2790 call xerr $es "ins_addr $xh 4-6"
2791 echo "~^header remove-at $xh 2"; read es;\
2792 call xerr $es "ins_addr $xh 4-7"
2793 echo "~^header remove-at $xh 1"; read es;\
2794 call xerr $es "ins_addr $xh 4-8"
2795 echo "~^header remove-at $xh 1"; read es;\
2796 vput vexpr es substr $es 0 3
2797 if [ $es != 501 ]
2798 xcall bail "ins_addr $xh 4-9"
2800 echo "~^header remove-at $xh T"; read es;\
2801 vput vexpr es substr $es 0 3
2802 if [ $es != 505 ]
2803 xcall bail "ins_addr $xh 4-10"
2805 echo "~^header list $xh"; read es;\
2806 vput vexpr es substr $es 0 3
2807 if [ $es != 501 ]
2808 xcall bail "ins_addr $xh 4-11"
2810 echo "~^header show $xh"; read es;\
2811 vput vexpr es substr $es 0 3
2812 if [ $es != 501 ]
2813 xcall bail "ins_addr $xh 4-12"
2816 define ins_ref {
2817 wysh set xh=$1 mult=$2
2818 echo "~^header list"; read hl; echo $hl;\
2819 call xerr "$hl" "ins_ref ($xh) 0-1"
2821 echo "~^header insert $xh <$xh@exam.ple>";\
2822 read es; echo $es; call xerr "$es" "ins_ref $xh 1-1"
2823 if [ $mult -ne 0 ]
2824 echo "~^header insert $xh <${xh}2@exam.ple>";\
2825 read es; echo $es; call xerr "$es" "ins_ref $xh 1-2"
2826 echo "~^header insert $xh ${xh}3@exam.ple";\
2827 read es; echo $es; call xerr "$es" "ins_ref $xh 1-3"
2828 else
2829 echo "~^header insert $xh <${xh}2@exam.ple>"; read es;\
2830 vput vexpr es substr $es 0 3
2831 if [ $es != 506 ]
2832 xcall bail "ins_ref $xh 1-4"
2836 echo "~^header list $xh"; read hl; echo $hl;\
2837 call xerr "$hl" "ins_ref $xh 1-5"
2838 echo "~^header show $xh"; read es; call xerr $es "ins_ref $xh 1-6"
2839 call read_mline_res
2841 if [ "$t_remove" == "" ]
2842 return
2845 echo "~^header remove $xh"; read es;\
2846 call xerr $es "ins_ref $xh 2-1"
2847 echo "~^header remove $xh"; read es;\
2848 vput vexpr es substr $es 0 3
2849 if [ $es != 501 ]
2850 xcall bail "ins_ref $xh 2-2"
2852 echo "~^header list $xh"; read es;\
2853 vput vexpr es substr $es 0 3
2854 if [ $es != 501 ]
2855 xcall bail "$es ins_ref $xh 2-3"
2857 echo "~^header show $xh"; read es;\
2858 vput vexpr es substr $es 0 3
2859 if [ $es != 501 ]
2860 xcall bail "ins_ref $xh 2-4"
2864 echo "~^header insert $xh <$xh@exam.ple>";\
2865 read es; echo $es; call xerr "$es" "ins_ref $xh 3-1"
2866 if [ $mult -ne 0 ]
2867 echo "~^header insert $xh <${xh}2@exam.ple>";\
2868 read es; echo $es; call xerr "$es" "ins_ref $xh 3-2"
2869 echo "~^header insert $xh ${xh}3@exam.ple";\
2870 read es; echo $es; call xerr "$es" "ins_ref $xh 3-3"
2872 echo "~^header list $xh";\
2873 read hl; echo $hl; call xerr "$hl" "ins_ref $xh 3-4"
2874 echo "~^header show $xh";\
2875 read es; call xerr $es "ins_ref $xh 3-5"
2876 call read_mline_res
2878 echo "~^header remove-at $xh 1"; read es;\
2879 call xerr $es "ins_ref $xh 3-6"
2880 if [ $mult -ne 0 ] && [ $xh != subject ]
2881 echo "~^header remove-at $xh 1"; read es;\
2882 call xerr $es "ins_ref $xh 3-7"
2883 echo "~^header remove-at $xh 1"; read es;\
2884 call xerr $es "ins_ref $xh 3-8"
2886 echo "~^header remove-at $xh 1"; read es;\
2887 vput vexpr es substr $es 0 3
2888 if [ $es != 501 ]
2889 xcall bail "ins_ref $xh 3-9"
2891 echo "~^header remove-at $xh T"; read es;\
2892 vput vexpr es substr $es 0 3
2893 if [ $es != 505 ]
2894 xcall bail "ins_ref $xh 3-10"
2896 echo "~^header show $xh"; read es;\
2897 vput vexpr es substr $es 0 3
2898 if [ $es != 501 ]
2899 xcall bail "ins_ref $xh 3-11"
2903 echo "~^header insert $xh <$xh@exam.ple> ";\
2904 read es; echo $es; call xerr "$es" "ins_ref $xh 4-1"
2905 if [ $mult -ne 0 ]
2906 echo "~^header insert $xh <${xh}2@exam.ple> ";\
2907 read es; echo $es; call xerr "$es" "ins_ref $xh 4-2"
2908 echo "~^header insert $xh ${xh}3@exam.ple";\
2909 read es; echo $es; call xerr "$es" "ins_ref $xh 4-3"
2911 echo "~^header list $xh"; read hl; echo $hl;\
2912 call xerr "$hl" "ins_ref $xh 4-4"
2913 echo "~^header show $xh"; read es; call xerr $es "ins_ref $xh 4-5"
2914 call read_mline_res
2916 if [ $mult -ne 0 ] && [ $xh != subject ]
2917 echo "~^header remove-at $xh 3"; read es;\
2918 call xerr $es "ins_ref $xh 4-6"
2919 echo "~^header remove-at $xh 2"; read es;\
2920 call xerr $es "ins_ref $xh 4-7"
2922 echo "~^header remove-at $xh 1"; read es;\
2923 call xerr $es "ins_ref $xh 4-8"
2924 echo "~^header remove-at $xh 1"; read es;\
2925 vput vexpr es substr $es 0 3
2926 if [ $es != 501 ]
2927 xcall bail "ins_ref $xh 4-9"
2929 echo "~^header remove-at $xh T"; read es;\
2930 vput vexpr es substr $es 0 3
2931 if [ $es != 505 ]
2932 xcall bail "ins_ref $xh 4-10"
2934 echo "~^header show $xh"; read es;\
2935 vput vexpr es substr $es 0 3
2936 if [ $es != 501 ]
2937 xcall bail "ins_ref $xh 4-11"
2940 define t_header {
2941 echo t_header ENTER
2942 # In collect.c order
2943 call ins_addr from
2944 call ins_ref sender 0 # Not a "ref", but works
2945 call ins_addr To
2946 call ins_addr cC
2947 call ins_addr bCc
2948 call ins_addr reply-To
2949 call ins_addr mail-Followup-to
2950 call ins_ref messAge-id 0
2951 call ins_ref rEfErEncEs 1
2952 call ins_ref in-Reply-to 1
2953 call ins_ref subject 1 # Not a "ref", but works (with tweaks)
2954 call ins_addr freeForm1
2955 call ins_addr freeform2
2957 echo "~^header show MAILX-Command"; read es; call xerr $es "t_header 1000"
2958 call read_mline_res
2959 echo "~^header show MAILX-raw-TO"; read es; call xerr $es "t_header 1001"
2960 call read_mline_res
2962 echo t_header LEAVE
2964 define t_attach {
2965 echo t_attach ENTER
2967 echo "~^attachment";\
2968 read hl; echo $hl; vput vexpr es substr "$hl" 0 3
2969 if [ "$es" != 501 ]
2970 xcall bail "attach 0-1"
2973 echo "~^attach attribute ./.treadctl";\
2974 read hl; echo $hl; vput vexpr es substr "$hl" 0 3
2975 if [ "$es" != 501 ]
2976 xcall bail "attach 0-2"
2978 echo "~^attachment attribute-at 1";\
2979 read hl; echo $hl; vput vexpr es substr "$hl" 0 3
2980 if [ "$es" != 501 ]
2981 xcall bail "attach 0-3"
2984 echo "~^attachment insert ./.treadctl=ascii";\
2985 read hl; echo $hl; call xerr "$hl" "attach 1-1"
2986 echo "~^attachment list";\
2987 read es; echo $es;call xerr "$es" "attach 1-2"
2988 call read_mline_res
2989 echo "~^attachment attribute ./.treadctl";\
2990 read es; echo $es;call xerr "$es" "attach 1-3"
2991 call read_mline_res
2992 echo "~^attachment attribute .treadctl";\
2993 read es; echo $es;call xerr "$es" "attach 1-4"
2994 call read_mline_res
2995 echo "~^attachment attribute-at 1";\
2996 read es; echo $es;call xerr "$es" "attach 1-5"
2997 call read_mline_res
2999 echo "~^attachment attribute-set ./.treadctl filename rctl";\
3000 read es; echo $es;call xerr "$es" "attach 1-6"
3001 echo "~^attachment attribute-set .treadctl content-description Au";\
3002 read es; echo $es;call xerr "$es" "attach 1-7"
3003 echo "~^attachment attribute-set-at 1 content-id <10.du@ich>";\
3004 read es; echo $es;call xerr "$es" "attach 1-8"
3006 echo "~^attachment attribute ./.treadctl";\
3007 read es; echo $es;call xerr "$es" "attach 1-9"
3008 call read_mline_res
3009 echo "~^attachment attribute .treadctl";\
3010 read es; echo $es;call xerr "$es" "attach 1-10"
3011 call read_mline_res
3012 echo "~^attachment attribute rctl";\
3013 read es; echo $es;call xerr "$es" "attach 1-11"
3014 call read_mline_res
3015 echo "~^attachment attribute-at 1";\
3016 read es; echo $es;call xerr "$es" "attach 1-12"
3017 call read_mline_res
3020 echo "~^attachment insert ./.tattach=latin1";\
3021 read hl; echo $hl; call xerr "$hl" "attach 2-1"
3022 echo "~^attachment list";\
3023 read es; echo $es;call xerr "$es" "attach 2-2"
3024 call read_mline_res
3025 echo "~^attachment attribute ./.tattach";\
3026 read es; echo $es;call xerr "$es" "attach 2-3"
3027 call read_mline_res
3028 echo "~^attachment attribute .tattach";\
3029 read es; echo $es;call xerr "$es" "attach 2-4"
3030 call read_mline_res
3031 echo "~^attachment attribute-at 2";\
3032 read es; echo $es;call xerr "$es" "attach 2-5"
3033 call read_mline_res
3035 echo "~^attachment attribute-set ./.tattach filename tat";\
3036 read es; echo $es;call xerr "$es" "attach 2-6"
3037 echo \
3038 "~^attachment attribute-set .tattach content-description Au2";\
3039 read es; echo $es;call xerr "$es" "attach 2-7"
3040 echo "~^attachment attribute-set-at 2 content-id <20.du@wir>";\
3041 read es; echo $es;call xerr "$es" "attach 2-8"
3042 echo \
3043 "~^attachment attribute-set-at 2 content-type application/x-sh";\
3044 read es; echo $es;call xerr "$es" "attach 2-9"
3046 echo "~^attachment attribute ./.tattach";\
3047 read es; echo $es;call xerr "$es" "attach 2-10"
3048 call read_mline_res
3049 echo "~^attachment attribute .tattach";\
3050 read es; echo $es;call xerr "$es" "attach 2-11"
3051 call read_mline_res
3052 echo "~^attachment attribute tat";\
3053 read es; echo $es;call xerr "$es" "attach 2-12"
3054 call read_mline_res
3055 echo "~^attachment attribute-at 2";\
3056 read es; echo $es;call xerr "$es" "attach 2-13"
3057 call read_mline_res
3060 if [ "$t_remove" == "" ]
3061 return
3064 echo "~^attachment remove ./.treadctl"; read es;\
3065 call xerr $es "attach 3-1"
3066 echo "~^attachment remove ./.tattach"; read es;\
3067 call xerr $es "attach 3-2"
3068 echo "~^ attachment remove ./.treadctl"; read es;\
3069 vput vexpr es substr $es 0 3
3070 if [ $es != 501 ]
3071 xcall bail "attach 3-3"
3073 echo "~^ attachment remove ./.tattach"; read es;\
3074 vput vexpr es substr $es 0 3
3075 if [ $es != 501 ]
3076 xcall bail "attach 3-4"
3078 echo "~^attachment list"; read es;\
3079 vput vexpr es substr $es 0 3
3080 if [ $es != 501 ]
3081 xcall bail "attach 3-5"
3085 echo "~^attachment insert ./.tattach=latin1";\
3086 read hl; echo $hl; call xerr "$hl" "attach 4-1"
3087 echo "~^attachment insert ./.tattach=latin1";\
3088 read hl; echo $hl; call xerr "$hl" "attach 4-2"
3089 echo "~^attachment list";\
3090 read es; echo $es;call xerr "$es" "attach 4-3"
3091 call read_mline_res
3092 echo "~^ attachment remove .tattach"; read es;\
3093 vput vexpr es substr $es 0 3
3094 if [ $es != 506 ]
3095 xcall bail "attach 4-4 $es"
3097 echo "~^attachment remove-at T"; read es;\
3098 vput vexpr es substr $es 0 3
3099 if [ $es != 505 ]
3100 xcall bail "attach 4-5"
3102 echo "~^attachment remove ./.tattach"; read es;\
3103 call xerr $es "attach 4-6"
3104 echo "~^attachment remove ./.tattach"; read es;\
3105 call xerr $es "attach 4-7"
3106 echo "~^ attachment remove ./.tattach"; read es;\
3107 vput vexpr es substr $es 0 3
3108 if [ $es != 501 ]
3109 xcall bail "attach 4-8 $es"
3111 echo "~^attachment list"; read es;\
3112 vput vexpr es substr $es 0 3
3113 if [ $es != 501 ]
3114 xcall bail "attach 4-9"
3118 echo "~^attachment insert ./.tattach=latin1";\
3119 read hl; echo $hl; call xerr "$hl" "attach 5-1"
3120 echo "~^attachment insert ./.tattach=latin1";\
3121 read hl; echo $hl; call xerr "$hl" "attach 5-2"
3122 echo "~^attachment insert ./.tattach=latin1";\
3123 read hl; echo $hl; call xerr "$hl" "attach 5-3"
3124 echo "~^attachment list";\
3125 read es; echo $es;call xerr "$es" "attach 5-4"
3126 call read_mline_res
3128 echo "~^attachment remove-at 3"; read es;\
3129 call xerr $es "attach 5-5"
3130 echo "~^attachment remove-at 3"; read es;\
3131 vput vexpr es substr $es 0 3
3132 if [ $es != 501 ]
3133 xcall bail "attach 5-6"
3135 echo "~^attachment remove-at 2"; read es;\
3136 call xerr $es "attach 5-7"
3137 echo "~^attachment remove-at 2"; read es;\
3138 vput vexpr es substr $es 0 3
3139 if [ $es != 501 ]
3140 xcall bail "attach 5-8"
3142 echo "~^attachment remove-at 1"; read es;\
3143 call xerr $es "attach 5-9"
3144 echo "~^attachment remove-at 1"; read es;\
3145 vput vexpr es substr $es 0 3
3146 if [ $es != 501 ]
3147 xcall bail "attach 5-10"
3150 echo "~^attachment list"; read es;\
3151 vput vexpr es substr $es 0 3
3152 if [ $es != 501 ]
3153 xcall bail "attach 5-11"
3157 echo "~^attachment insert ./.tattach=latin1";\
3158 read hl; echo $hl; call xerr "$hl" "attach 6-1"
3159 echo "~^attachment insert ./.tattach=latin1";\
3160 read hl; echo $hl; call xerr "$hl" "attach 6-2"
3161 echo "~^attachment insert ./.tattach=latin1";\
3162 read hl; echo $hl; call xerr "$hl" "attach 6-3"
3163 echo "~^attachment list";\
3164 read es; echo $es;call xerr "$es" "attach 6-4"
3165 call read_mline_res
3167 echo "~^attachment remove-at 1"; read es;\
3168 call xerr $es "attach 6-5"
3169 echo "~^attachment remove-at 1"; read es;\
3170 call xerr $es "attach 6-6"
3171 echo "~^attachment remove-at 1"; read es;\
3172 call xerr $es "attach 6-7"
3173 echo "~^attachment remove-at 1"; read es;\
3174 vput vexpr es substr $es 0 3
3175 if [ $es != 501 ]
3176 xcall bail "attach 6-8"
3179 echo "~^attachment list"; read es;\
3180 vput vexpr es substr $es 0 3
3181 if [ $es != 501 ]
3182 xcall bail "attach 6-9"
3185 echo t_attach LEAVE
3187 define t_ocs {
3188 read ver
3189 echo t_ocs
3190 call t_header
3191 call t_attach
3193 define t_oce {
3194 echo on-compose-enter, mailx-command<$mailx-command>
3195 alternates alter1@exam.ple alter2@exam.ple
3196 alternates
3197 set autocc='alter1@exam.ple alter2@exam.ple'
3198 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3199 echo mailx-subject<$mailx-subject>
3200 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3201 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3202 mailx-raw-bcc<$mailx-raw-bcc>
3203 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
3204 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3206 define t_ocl {
3207 echo on-compose-leave, mailx-command<$mailx-command>
3208 vput alternates al
3209 eval alternates $al alter3@exam.ple alter4@exam.ple
3210 alternates
3211 set autobcc='alter3@exam.ple alter4@exam.ple'
3212 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3213 echo mailx-subject<$mailx-subject>
3214 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3215 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3216 mailx-raw-bcc<$mailx-raw-bcc>
3217 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
3218 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3220 define t_occ {
3221 echo on-compose-cleanup, mailx-command<$mailx-command>
3222 unalternates *
3223 alternates
3224 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3225 echo mailx-subject<$mailx-subject>
3226 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3227 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3228 mailx-raw-bcc<$mailx-raw-bcc>
3229 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
3230 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3232 wysh set on-compose-splice=t_ocs \
3233 on-compose-enter=t_oce on-compose-leave=t_ocl \
3234 on-compose-cleanup=t_occ
3235 __EOT__
3237 ${rm} -f "${MBOX}"
3238 printf 'm this-goes@nowhere\nbody\n!.\n' |
3239 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
3240 -X'source ./.trc' -Smta=./.tsendmail.sh \
3241 >./.tall 2>&1
3242 ${cat} ./.tall >> "${MBOX}"
3243 check behave:compose_hooks-1 0 "${MBOX}" '522535560 10101'
3245 ${rm} -f "${MBOX}"
3246 printf 'm this-goes@nowhere\nbody\n!.\n' |
3247 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
3248 -St_remove=1 -X'source ./.trc' -Smta=./.tsendmail.sh \
3249 >./.tall 2>&1
3250 ${cat} ./.tall >> "${MBOX}"
3251 check behave:compose_hooks-2 0 "${MBOX}" '3654000499 12535'
3255 # Some state machine stress, shell compose hook, localopts for hook, etc.
3256 # readctl in child. ~r as HERE document
3257 ${rm} -f "${MBOX}"
3258 printf 'm ex@am.ple\nbody\n!.\nvar t_oce t_ocs t_ocs_sh t_ocl t_occ autocc' |
3259 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! \
3260 -Smta=./.tsendmail.sh \
3262 define bail {
3263 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
3265 define xerr {
3266 vput vexpr es substr "$1" 0 1
3267 if [ "$es" != 2 ]
3268 xcall bail "$2"
3271 define read_mline_res {
3272 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
3273 echo $len/$es/$^ERRNAME: $hl
3274 if [ $es -ne $^ERR-NONE ]
3275 xcall bail read_mline_res
3276 elif [ $len -ne 0 ]
3277 \xcall read_mline_res
3280 define _work {
3281 vput vexpr i + 1 "$2"
3282 if [ $i -lt 111 ]
3283 vput vexpr j % $i 10
3284 if [ $j -ne 0 ]
3285 set j=xcall
3286 else
3287 echon "$i.. "
3288 set j=call
3290 eval \\$j _work $1 $i
3291 return $?
3293 vput vexpr i + $i "$1"
3294 return $i
3296 define _read {
3297 wysh set line; read line;wysh set es=$? en=$^ERRNAME ;\
3298 echo read:$es/$en: $line
3299 if [ "${es}" -ne -1 ]
3300 xcall _read
3302 readctl remove $cwd/.treadctl; echo readctl remove:$?/$^ERRNAME
3304 define t_ocs {
3305 read ver
3306 echo t_ocs
3307 echo "~^header list"; read hl; echo $hl;\
3308 vput vexpr es substr "$hl" 0 1
3309 if [ "$es" != 2 ]
3310 xcall bail "header list"
3311 endif
3313 call _work 1; echo $?
3314 echo "~^header insert cc splicy diet <splice@exam.ple> spliced";\
3315 read es; echo $es; vput vexpr es substr "$es" 0 1
3316 if [ "$es" != 2 ]
3317 xcall bail "be diet"
3318 endif
3319 echo "~^header insert cc <splice2@exam.ple>";\
3320 read es; echo $es; vput vexpr es substr "$es" 0 1
3321 if [ "$es" != 2 ]
3322 xcall bail "be diet2"
3323 endif
3325 call _work 2; echo $?
3326 echo "~^header insert bcc juicy juice <juice@exam.ple> spliced";\
3327 read es; echo $es;vput vexpr es substr "$es" 0 1
3328 if [ "$es" != 2 ]
3329 xcall bail "be juicy"
3330 endif
3331 echo "~^header insert bcc juice2@exam.ple";\
3332 read es; echo $es;vput vexpr es substr "$es" 0 1
3333 if [ "$es" != 2 ]
3334 xcall bail "be juicy2"
3335 endif
3336 echo "~^header insert bcc juice3 <juice3@exam.ple>";\
3337 read es; echo $es;vput vexpr es substr "$es" 0 1
3338 if [ "$es" != 2 ]
3339 xcall bail "be juicy3"
3340 endif
3341 echo "~^header insert bcc juice4@exam.ple";\
3342 read es; echo $es;vput vexpr es substr "$es" 0 1
3343 if [ "$es" != 2 ]
3344 xcall bail "be juicy4"
3345 endif
3347 echo "~^header remove-at bcc 3";\
3348 read es; echo $es;vput vexpr es substr "$es" 0 1
3349 if [ "$es" != 2 ]
3350 xcall bail "remove juicy5"
3351 endif
3352 echo "~^header remove-at bcc 2";\
3353 read es; echo $es;vput vexpr es substr "$es" 0 1
3354 if [ "$es" != 2 ]
3355 xcall bail "remove juicy6"
3356 endif
3357 echo "~^header remove-at bcc 3";\
3358 read es; echo $es;vput vexpr es substr "$es" 0 3
3359 if [ "$es" != 501 ]
3360 xcall bail "failed to remove-at"
3361 endif
3362 # Add duplicates which ought to be removed!
3363 echo "~^header insert bcc juice4@exam.ple";\
3364 read es; echo $es;vput vexpr es substr "$es" 0 1
3365 if [ "$es" != 2 ]
3366 xcall bail "be juicy4-1"
3367 endif
3368 echo "~^header insert bcc juice4@exam.ple";\
3369 read es; echo $es;vput vexpr es substr "$es" 0 1
3370 if [ "$es" != 2 ]
3371 xcall bail "be juicy4-2"
3372 endif
3373 echo "~^header insert bcc juice4@exam.ple";\
3374 read es; echo $es;vput vexpr es substr "$es" 0 1
3375 if [ "$es" != 2 ]
3376 xcall bail "be juicy4-3"
3377 endif
3378 echo "~:set t_ocs"
3381 call _work 3; echo $?
3382 echo "~r - '__EOT'"
3383 vput ! i echo just knock if you can hear me;\
3384 i=0;\
3385 while [ $i -lt 24 ]; do printf "%s " $i; i=`expr $i + 1`; done;\
3386 echo relax
3387 echon shell-cmd says $?/$^ERRNAME: $i
3388 echo "~x will not become interpreted, we are reading until __EOT"
3389 echo "__EOT"
3390 read r_status; echo "~~r status output: $r_status"
3391 echo "~:echo $? $! $^ERRNAME"
3392 read r_status
3393 echo "~~r status from parent: $r_status"
3396 call _work 4; echo $?
3397 vput cwd cwd;echo cwd:$?
3398 readctl create $cwd/.treadctl ;echo readctl:$?/$^ERRNAME;\
3399 call _read
3402 call _work 5; echo $?
3403 echo "~^header show MAILX-Command"; read es;\
3404 call xerr $es "t_header 1000"; call read_mline_res
3405 echo "~^header show MAILX-raw-TO"; read es;\
3406 call xerr $es "t_header 1001"; xcall read_mline_res
3408 echoerr IT IS WRONG IF YOU SEE THIS
3410 define t_oce {
3411 echo on-compose-enter, mailx-command<$mailx-command>
3412 set t_oce autobcc=oce@exam.ple
3413 alternates alter1@exam.ple alter2@exam.ple
3414 alternates
3415 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3416 echo mailx-subject<$mailx-subject>
3417 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3418 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3419 mailx-raw-bcc<$mailx-raw-bcc>
3420 echo mailx-orig-from<$mailx-orig-from> \
3421 mailx-orig-to<$mailx-orig-to> \
3422 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3424 define t_ocl {
3425 echo on-compose-leave, mailx-command<$mailx-command>
3426 set t_ocl autocc=ocl@exam.ple
3427 unalternates *
3428 alternates alter3@exam.ple alter4@exam.ple
3429 alternates
3430 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3431 echo mailx-subject<$mailx-subject>
3432 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3433 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3434 mailx-raw-bcc<$mailx-raw-bcc>
3435 echo mailx-orig-from<$mailx-orig-from> \
3436 mailx-orig-to<$mailx-orig-to> \
3437 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3439 define t_occ {
3440 echo on-compose-cleanup, mailx-command<$mailx-command>
3441 set t_occ autocc=occ@exam.ple
3442 unalternates *
3443 alternates
3444 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3445 echo mailx-subject<$mailx-subject>
3446 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3447 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3448 mailx-raw-bcc<$mailx-raw-bcc>
3449 echo mailx-orig-from<$mailx-orig-from> \
3450 mailx-orig-to<$mailx-orig-to> \
3451 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3453 wysh set on-compose-splice=t_ocs \
3454 on-compose-splice-shell="read ver;printf \"t_ocs-shell\\n\
3455 ~t shell@exam.ple\\n~:set t_ocs_sh\\n\"" \
3456 on-compose-enter=t_oce on-compose-leave=t_ocl \
3457 on-compose-cleanup=t_occ
3458 ' > ./.tnotes 2>&1
3459 ex0_test behave:compose_hooks-3
3460 ${cat} ./.tnotes >> "${MBOX}"
3462 check behave:compose_hooks-3 - "${MBOX}" '679526364 2431'
3464 # Reply, forward, resend, Resend
3466 ${rm} -f "${MBOX}"
3467 printf 'set from=f1@z\nm t1@z\nb1\n!.\nset from=f2@z\nm t2@z\nb2\n!.\n' |
3468 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! \
3469 -Smta=./.tsendmail.sh
3471 printf '
3472 echo start: $? $! $^ERRNAME
3473 File %s
3474 echo File: $? $! $^ERRNAME;echo;echo
3475 reply 1
3476 this is content of reply 1
3478 echo reply 1: $? $! $^ERRNAME;echo;echo
3479 Reply 1 2
3480 this is content of Reply 1 2
3482 echo Reply 1 2: $? $! $^ERRNAME;echo;echo
3483 forward 1 fwdex@am.ple
3484 this is content of forward 1
3486 echo forward 1: $? $! $^ERRNAME;echo;echo
3487 resend 1 2 resendex@am.ple
3488 echo resend 1 2: $? $! $^ERRNAME;echo;echo
3489 Resend 1 2 Resendex@am.ple
3490 echo Resend 1 2: $? $! $^ERRNAME;echo;echo
3491 ' "${MBOX}" |
3492 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! \
3493 -Smta=./.tsendmail.sh \
3495 define bail {
3496 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
3498 define xerr {
3499 vput vexpr es substr "$1" 0 1
3500 if [ "$es" != 2 ]
3501 xcall bail "$2"
3504 define read_mline_res {
3505 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
3506 echo mline_res:$len/$es/$^ERRNAME: $hl
3507 if [ $es -ne $^ERR-NONE ]
3508 xcall bail read_mline_res
3509 elif [ $len -ne 0 ]
3510 \xcall read_mline_res
3513 define work_hl {
3514 echo "~^header show $1"; read es;\
3515 call xerr $es "work_hl $1"; echo $1; call read_mline_res
3516 if [ $# -gt 1 ]
3517 shift
3518 xcall work_hl "$@"
3521 define t_ocs {
3522 read ver
3523 echo t_ocs version $ver
3524 echo "~^header list"; read hl; echo $hl;\
3525 echoerr the header list is $hl;\
3526 call xerr "$hl" "header list"
3527 eval vpospar set $hl
3528 shift
3529 xcall work_hl "$@"
3530 echoerr IT IS WRONG IF YOU SEE THIS
3532 define t_oce {
3533 echo on-XY-enter, mailx-command<$mailx-command>
3534 set t_oce autobcc=oce@exam.ple
3535 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3536 echo mailx-subject<$mailx-subject>
3537 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3538 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3539 mailx-raw-bcc<$mailx-raw-bcc>
3540 echo mailx-orig-from<$mailx-orig-from> \
3541 mailx-orig-to<$mailx-orig-to> \
3542 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3544 define t_ocl {
3545 echo on-XY-leave, mailx-command<$mailx-command>
3546 set t_ocl autocc=ocl@exam.ple
3547 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3548 echo mailx-subject<$mailx-subject>
3549 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3550 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3551 mailx-raw-bcc<$mailx-raw-bcc>
3552 echo mailx-orig-from<$mailx-orig-from> \
3553 mailx-orig-to<$mailx-orig-to> \
3554 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3556 define t_occ {
3557 echo on-XY-cleanup, mailx-command<$mailx-command>
3558 set t_occ autocc=occ@exam.ple
3559 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3560 echo mailx-subject<$mailx-subject>
3561 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3562 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3563 mailx-raw-bcc<$mailx-raw-bcc>
3564 echo mailx-orig-from<$mailx-orig-from> \
3565 mailx-orig-to<$mailx-orig-to> \
3566 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3568 wysh set on-compose-splice=t_ocs \
3569 on-compose-enter=t_oce on-compose-leave=t_ocl \
3570 on-compose-cleanup=t_occ \
3571 on-resend-enter=t_oce on-resend-cleanup=t_occ
3572 ' > ./.tnotes 2>&1
3573 ex0_test behave:compose_hooks-4
3574 ${cat} ./.tnotes >> "${MBOX}"
3576 check behave:compose_hooks-4 - "${MBOX}" '3038884027 7516'
3578 t_epilog
3581 t_behave_message_injections() {
3582 t_prolog t_behave_message_injections
3583 TRAP_EXIT_ADDONS="./.t*"
3585 ${cat} <<-_EOT > ./.tsendmail.sh
3586 #!${SHELL} -
3587 (echo 'From Echinacea Tue Jun 20 15:54:02 2017' && ${cat} && echo
3588 ) > "${MBOX}"
3589 _EOT
3590 chmod 0755 ./.tsendmail.sh
3592 echo mysig > ./.tmysig
3594 echo some-body | ${MAILX} ${ARGS} -Smta=./.tsendmail.sh \
3595 -Smessage-inject-head=head-inject \
3596 -Smessage-inject-tail=tail-inject \
3597 -Ssignature=./.tmysig \
3598 ex@am.ple > ./.tall 2>&1
3599 check behave:message_injections-1 0 "${MBOX}" '2434746382 134'
3600 check behave:message_injections-2 - .tall '4294967295 0' # empty file
3602 ${cat} <<-_EOT > ./.template
3603 From: me
3604 To: ex1@am.ple
3605 Cc: ex2@am.ple
3606 Subject: This subject is
3608 Body, body, body me.
3609 _EOT
3610 < ./.template ${MAILX} ${ARGS} -t -Smta=./.tsendmail.sh \
3611 -Smessage-inject-head=head-inject \
3612 -Smessage-inject-tail=tail-inject \
3613 -Ssignature=./.tmysig \
3614 > ./.tall 2>&1
3615 check behave:message_injections-3 0 "${MBOX}" '3114203412 198'
3616 check behave:message_injections-4 - .tall '4294967295 0' # empty file
3618 t_epilog
3621 t_behave_mime_types_load_control() {
3622 t_prolog t_behave_mime_types_load_control
3623 TRAP_EXIT_ADDONS="./.t*"
3625 ${cat} <<-_EOT > ./.tmts1
3626 @ application/mathml+xml mathml
3627 _EOT
3628 ${cat} <<-_EOT > ./.tmts2
3629 @ x-conference/x-cooltalk ice
3630 @ aga-aga aga
3631 @ application/aga-aga aga
3632 _EOT
3634 ${cat} <<-_EOT > ./.tmts1.mathml
3635 <head>nonsense ML</head>
3636 _EOT
3637 ${cat} <<-_EOT > ./.tmts2.ice
3638 Icy, icy road.
3639 _EOT
3640 printf 'of which the c\x01rack is coming soon' > ./.tmtsx.doom
3641 printf 'of which the c\x01rack is coming soon' > ./.tmtsx.aga
3643 printf '
3644 m %s
3645 Schub-di-du
3646 ~@ ./.tmts1.mathml
3647 ~@ ./.tmts2.ice
3648 ~@ ./.tmtsx.doom
3649 ~@ ./.tmtsx.aga
3651 File %s
3652 from*
3653 type
3655 ' "${MBOX}" "${MBOX}" |
3656 ${MAILX} ${ARGS} \
3657 -Smimetypes-load-control=f=./.tmts1,f=./.tmts2 \
3658 > ./.tout 2>&1
3659 ex0_test behave:mime_types_load_control
3661 ${cat} "${MBOX}" >> ./.tout
3662 check behave:mime_types_load_control-1 - ./.tout '1441260727 2449'
3664 echo type | ${MAILX} ${ARGS} -R \
3665 -Smimetypes-load-control=f=./.tmts1,f=./.tmts3 \
3666 -f "${MBOX}" >> ./.tout 2>&1
3667 check behave:mime_types_load_control-2 0 ./.tout '1441391438 3646'
3669 t_epilog
3672 t_behave_s_mime() {
3673 have_feat smime || {
3674 echo 'behave:s/mime: unsupported, skipped'
3675 return
3678 t_prolog t_behave_s_mime
3679 TRAP_EXIT_ADDONS="./.t.conf ./.tkey.pem ./.tcert.pem ./.tpair.pem"
3680 TRAP_EXIT_ADDONS="${TRAP_EXIT_ADDONS} ./.VERIFY ./.DECRYPT ./.ENCRYPT"
3681 TRAP_EXIT_ADDONS="${TRAP_EXIT_ADDONS} ./.tsendmail.sh"
3683 printf 'behave:s/mime: .. generating test key and certificate ..\n'
3684 ${cat} <<-_EOT > ./.t.conf
3685 [ req ]
3686 default_bits = 1024
3687 default_keyfile = keyfile.pem
3688 distinguished_name = req_distinguished_name
3689 attributes = req_attributes
3690 prompt = no
3691 output_password =
3693 [ req_distinguished_name ]
3694 C = GB
3695 ST = Over the
3696 L = rainbow
3697 O = S-nail
3698 OU = S-nail.smime
3699 CN = S-nail.test
3700 emailAddress = test@localhost
3702 [ req_attributes ]
3703 challengePassword =
3704 _EOT
3705 openssl req -x509 -nodes -days 3650 -config ./.t.conf \
3706 -newkey rsa:1024 -keyout ./.tkey.pem -out ./.tcert.pem >/dev/null 2>&1
3707 ${cat} ./.tkey.pem ./.tcert.pem > ./.tpair.pem
3709 # Sign/verify
3710 printf 'behave:s/mime:sign/verify: '
3711 echo bla | ${MAILX} ${ARGS} \
3712 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
3713 -Ssmime-sign -Sfrom=test@localhost \
3714 -s 'S/MIME test' ./.VERIFY
3715 if [ $? -eq 0 ]; then
3716 printf 'ok\n'
3717 else
3718 printf 'failed\n'
3719 ESTAT=1
3720 t_epilog
3721 return
3724 ${awk} '
3725 BEGIN{ skip=0 }
3726 /^Content-Description: /{ skip = 2; print; next }
3727 /^$/{ if(skip) --skip }
3728 { if(!skip) print }
3730 < ./.VERIFY > "${MBOX}"
3731 check behave:s/mime:sign/verify:checksum - "${MBOX}" '2900817158 648'
3733 printf 'behave:s/mime:sign/verify:verify '
3734 printf 'verify\nx\n' |
3735 ${MAILX} ${ARGS} \
3736 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
3737 -Ssmime-sign -Sfrom=test@localhost \
3738 -Serrexit -R \
3739 -f ./.VERIFY >/dev/null 2>&1
3740 if [ $? -eq 0 ]; then
3741 printf 'ok\n'
3742 else
3743 printf 'failed\n'
3744 ESTAT=1
3745 t_epilog
3746 return
3749 printf 'behave:s/mime:sign/verify:disproof-1 '
3750 if openssl smime -verify -CAfile ./.tcert.pem \
3751 -in ./.VERIFY >/dev/null 2>&1; then
3752 printf 'ok\n'
3753 else
3754 printf 'failed\n'
3755 ESTAT=1
3756 t_epilog
3757 return
3760 # (signing +) encryption / decryption
3761 ${cat} <<-_EOT > ./.tsendmail.sh
3762 #!${SHELL} -
3763 (echo 'From Euphrasia Thu Apr 27 17:56:23 2017' && ${cat}) > ./.ENCRYPT
3764 _EOT
3765 chmod 0755 ./.tsendmail.sh
3767 printf 'behave:s/mime:encrypt+sign: '
3768 echo bla |
3769 ${MAILX} ${ARGS} \
3770 -Ssmime-force-encryption \
3771 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
3772 -Smta=./.tsendmail.sh \
3773 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
3774 -Ssmime-sign -Sfrom=test@localhost \
3775 -s 'S/MIME test' recei@ver.com
3776 if [ $? -eq 0 ]; then
3777 printf 'ok\n'
3778 else
3779 ESTAT=1
3780 printf 'error: encrypt+sign failed\n'
3783 ${sed} -e '/^$/,$d' < ./.ENCRYPT > "${MBOX}"
3784 check behave:s/mime:encrypt+sign:checksum - "${MBOX}" '1937410597 327'
3786 printf 'behave:s/mime:decrypt+verify: '
3787 printf 'decrypt ./.DECRYPT\nfi ./.DECRYPT\nverify\nx\n' |
3788 ${MAILX} ${ARGS} \
3789 -Ssmime-force-encryption \
3790 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
3791 -Smta=./.tsendmail.sh \
3792 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
3793 -Ssmime-sign -Sfrom=test@localhost \
3794 -Serrexit -R \
3795 -f ./.ENCRYPT >/dev/null 2>&1
3796 if [ $? -eq 0 ]; then
3797 printf 'ok\n'
3798 else
3799 ESTAT=1
3800 printf 'failed\n'
3803 ${awk} '
3804 BEGIN{ skip=0 }
3805 /^Content-Description: /{ skip = 2; print; next }
3806 /^$/{ if(skip) --skip }
3807 { if(!skip) print }
3809 < ./.DECRYPT > "${MBOX}"
3810 check behave:s/mime:decrypt+verify:checksum - "${MBOX}" '1720739247 931'
3812 printf 'behave:s/mime:decrypt+verify:disproof-1: '
3813 if (openssl smime -decrypt -inkey ./.tkey.pem -in ./.ENCRYPT |
3814 openssl smime -verify -CAfile ./.tcert.pem) >/dev/null 2>&1; then
3815 printf 'ok\n'
3816 else
3817 printf 'failed\n'
3818 ESTAT=1
3821 printf "behave:s/mime:encrypt: "
3822 echo bla | ${MAILX} ${ARGS} \
3823 -Ssmime-force-encryption \
3824 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
3825 -Smta=./.tsendmail.sh \
3826 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
3827 -Sfrom=test@localhost \
3828 -s 'S/MIME test' recei@ver.com
3829 if [ $? -eq 0 ]; then
3830 printf 'ok\n'
3831 else
3832 ESTAT=1
3833 printf 'failed\n'
3836 # Same as behave:s/mime:encrypt+sign:checksum above
3837 ${sed} -e '/^$/,$d' < ./.ENCRYPT > "${MBOX}"
3838 check behave:s/mime:encrypt:checksum - "${MBOX}" '1937410597 327'
3840 ${rm} -f ./.DECRYPT
3841 printf 'decrypt ./.DECRYPT\nx\n' | ${MAILX} ${ARGS} \
3842 -Ssmime-force-encryption \
3843 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
3844 -Smta=./.tsendmail.sh \
3845 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
3846 -Sfrom=test@localhost \
3847 -Serrexit -R \
3848 -f ./.ENCRYPT >/dev/null 2>&1
3849 check behave:s/mime:decrypt 0 "./.DECRYPT" '2624716890 422'
3851 printf 'behave:s/mime:decrypt:disproof-1: '
3852 if openssl smime -decrypt -inkey ./.tkey.pem \
3853 -in ./.ENCRYPT >/dev/null 2>&1; then
3854 printf 'ok\n'
3855 else
3856 printf 'failed\n'
3857 ESTAT=1
3860 t_epilog
3863 t_behave_maildir() {
3864 t_prolog t_behave_maildir
3865 TRAP_EXIT_ADDONS="./.t*"
3869 while [ ${i} -lt 112 ]; do
3870 printf 'm file://%s\n~s Subject %s\nHello %s!\n~.\n' \
3871 "${MBOX}" "${i}" "${i}"
3872 i=`add ${i} 1`
3873 done
3874 ) | ${MAILX} ${ARGS}
3875 check behave:maildir-1 0 "${MBOX}" '1140119864 13780'
3877 printf 'File "%s"
3878 copy * "%s"
3879 File "%s"
3880 from*
3881 ' "${MBOX}" .tmdir1 .tmdir1 |
3882 ${MAILX} ${ARGS} -Snewfolders=maildir > .tlst
3883 check behave:maildir-2 0 .tlst '1797938753 9103'
3885 printf 'File "%s"
3886 copy * "maildir://%s"
3887 File "maildir://%s"
3888 from*
3889 ' "${MBOX}" .tmdir2 .tmdir2 |
3890 ${MAILX} ${ARGS} > .tlst
3891 check behave:maildir-3 0 .tlst '1155631089 9113'
3893 printf 'File "maildir://%s"
3894 copy * "file://%s"
3895 File "file://%s"
3896 from*
3897 ' .tmdir2 .tmbox1 .tmbox1 |
3898 ${MAILX} ${ARGS} > .tlst
3899 check behave:maildir-4 0 .tmbox1 '2646131190 13220'
3900 check behave:maildir-5 - .tlst '3701297796 9110'
3902 # only the odd (even)
3904 printf 'File "maildir://%s"
3905 copy ' .tmdir2
3907 while [ ${i} -lt 112 ]; do
3908 j=`modulo ${i} 2`
3909 [ ${j} -eq 1 ] && printf '%s ' "${i}"
3910 i=`add ${i} 1`
3911 done
3912 printf ' file://%s
3913 File "file://%s"
3914 from*
3915 ' .tmbox2 .tmbox2
3916 ) | ${MAILX} ${ARGS} > .tlst
3917 check behave:maildir-6 0 .tmbox2 '142890131 6610'
3918 check behave:maildir-7 - .tlst '960096773 4573'
3919 # ...
3921 printf 'file "maildir://%s"
3922 move ' .tmdir2
3924 while [ ${i} -lt 112 ]; do
3925 j=`modulo ${i} 2`
3926 [ ${j} -eq 0 ] && [ ${i} -ne 0 ] && printf '%s ' "${i}"
3927 i=`add ${i} 1`
3928 done
3929 printf ' file://%s
3930 File "file://%s"
3931 from*
3932 File "maildir://%s"
3933 from*
3934 ' .tmbox2 .tmbox2 .tmdir2
3935 ) | ${MAILX} ${ARGS} > .tlst
3936 check behave:maildir-8 0 .tmbox2 '3806905791 13100'
3937 ${sed} 2d < .tlst > .tlstx
3938 check behave:maildir-9 - .tlstx '4216815295 13645'
3940 t_epilog
3943 t_behave_mass_recipients() {
3944 t_prolog t_behave_mass_recipients
3945 TRAP_EXIT_ADDONS="./.t*"
3947 ${cat} <<-_EOT > ./.tsendmail.sh
3948 #!${SHELL} -
3949 (echo 'From Eucalyptus Sat Jul 08 21:14:57 2017' && ${cat} && echo
3950 ) >> "${MBOX}"
3951 _EOT
3952 chmod 0755 ./.tsendmail.sh
3954 ${cat} <<'__EOT__' > ./.trc
3955 define bail {
3956 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
3958 define ins_addr {
3959 wysh set nr=$1 hn=$2
3960 echo "~$hn $hn$nr@$hn"; echo '~:echo $?'; read es
3961 if [ "$es" -ne 0 ]
3962 xcall bail "ins_addr $hn 1-$nr"
3964 vput vexpr nr + $nr 1
3965 if [ "$nr" -le "$maximum" ]
3966 xcall ins_addr $nr $hn
3969 define bld_alter {
3970 wysh set nr=$1 hn=$2
3971 alternates $hn$nr@$hn
3972 vput vexpr nr + $nr 2
3973 if [ "$nr" -le "$maximum" ]
3974 xcall bld_alter $nr $hn
3977 define t_ocs {
3978 read ver
3979 call ins_addr 1 t
3980 call ins_addr 1 c
3981 call ins_addr 1 b
3983 define t_ocl {
3984 if [ "$t_remove" != '' ]
3985 call bld_alter 1 t
3986 call bld_alter 2 c
3989 set on-compose-splice=t_ocs on-compose-leave=t_ocl
3990 __EOT__
3992 ${rm} -f "${MBOX}"
3993 printf 'm this-goes@nowhere\nbody\n!.\n' |
3994 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
3995 -X'source ./.trc' -Smta=./.tsendmail.sh -Smaximum=2001 \
3996 >./.tall 2>&1
3997 ${cat} ./.tall >> "${MBOX}"
3998 check behave:mass_recipients-1 0 "${MBOX}" '2912243346 51526'
4000 ${rm} -f "${MBOX}"
4001 printf 'm this-goes@nowhere\nbody\n!.\n' |
4002 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
4003 -St_remove=1 -X'source ./.trc' -Smta=./.tsendmail.sh -Smaximum=2001 \
4004 >./.tall 2>&1
4005 ${cat} ./.tall >> "${MBOX}"
4006 check behave:mass_recipients-2 0 "${MBOX}" '4097804632 34394'
4008 t_epilog
4011 t_behave_lreply_futh_rth_etc() {
4012 t_prolog t_behave_lreply_futh_rth_etc
4013 TRAP_EXIT_ADDONS="./.t*"
4015 ${cat} <<-_EOT > ./.tsendmail.sh
4016 #!${SHELL} -
4017 (echo 'From HumulusLupulus Thu Jul 27 14:41:20 2017' && ${cat} && echo
4018 ) >> "${MBOX}"
4019 _EOT
4020 chmod 0755 ./.tsendmail.sh
4022 ${cat} <<-_EOT > ./.tmbox
4023 From neverneverland Sun Jul 23 13:46:25 2017
4024 Subject: Bugstop: five miles out 1
4025 Reply-To: mister originator2 <mr2@originator>, bugstop@five.miles.out
4026 From: mister originator <mr@originator>
4027 To: bugstop-commit@five.miles.out, laber@backe.eu
4028 Cc: is@a.list
4029 Mail-Followup-To: bugstop@five.miles.out, laber@backe.eu, is@a.list
4030 In-reply-to: <20170719111113.bkcMz%laber@backe.eu>
4031 Date: Wed, 19 Jul 2017 09:22:57 -0400
4032 Message-Id: <20170719132257.766AF781267@originator>
4033 Status: RO
4035 > |Sorry, I think I misunderstand something. I would think that
4037 That's appalling.
4039 From neverneverland Fri Jul 7 22:39:11 2017
4040 Subject: Bugstop: five miles out 2
4041 Reply-To: mister originator2<mr2@originator>,bugstop@five.miles.out,is@a.list
4042 Content-Transfer-Encoding: 7bit
4043 From: mister originator <mr@originator>
4044 To: bugstop-commit@five.miles.out
4045 Cc: is@a.list
4046 Message-ID: <149945963975.28888.6950788126957753723.reportbug@five.miles.out>
4047 Date: Fri, 07 Jul 2017 16:33:59 -0400
4048 Status: R
4050 capable of changing back.
4052 From neverneverland Fri Jul 7 22:42:00 2017
4053 Subject: Bugstop: five miles out 3
4054 Reply-To: mister originator2 <mr2@originator>, bugstop@five.miles.out
4055 Content-Transfer-Encoding: 7bit
4056 From: mister originator <mr@originator>
4057 To: bugstop-commit@five.miles.out
4058 Cc: is@a.list
4059 Message-ID: <149945963975.28888.6950788126957753746.reportbug@five.miles.out>
4060 Date: Fri, 07 Jul 2017 16:33:59 -0400
4061 List-Post: <mailto:bugstop@five.miles.out>
4062 Status: R
4064 are you ready, boots?
4066 From neverneverland Sat Aug 19 23:15:00 2017
4067 Subject: Bugstop: five miles out 4
4068 Reply-To: mister originator2 <mr2@originator>, bugstop@five.miles.out
4069 Content-Transfer-Encoding: 7bit
4070 From: mister originator <mr@originator>
4071 To: bugstop@five.miles.out
4072 Cc: is@a.list
4073 Message-ID: <149945963975.28888.6950788126qtewrqwer.reportbug@five.miles.out>
4074 Date: Fri, 07 Jul 2017 16:33:59 -0400
4075 List-Post: <mailto:bugstop@five.miles.out>
4076 Status: R
4078 are you ready, boots?
4079 _EOT
4083 ${cat} <<-'_EOT' | ${MAILX} ${ARGS} -Sescape=! -Smta=./.tsendmail.sh \
4084 -Rf ./.tmbox >> "${MBOX}" 2>&1
4085 define r {
4086 wysh set m="This is text of \"reply ${1}."
4087 reply 1 2 3
4088 !I m
4091 !I m
4094 !I m
4097 echo -----After reply $1.1 - $1.3: $?/$^ERRNAME
4099 define R {
4100 wysh set m="This is text of \"Reply ${1}."
4101 eval Reply $2
4102 !I m
4103 !I 2
4106 echo -----After Reply $1.$2: $?/$^ERRNAME
4108 define _Lh {
4109 read protover
4110 echo '~I m'
4111 echo '~I n'
4112 echo '".'
4114 define _Ls {
4115 wysh set m="This is text of \"Lreply ${1}." on-compose-splice=_Lh n=$2
4116 eval Lreply $2
4118 define L {
4119 # We need two indirections for this test: one for the case that Lreply
4120 # fails because of missing recipients: we need to read EOF next, thus
4121 # place this in _Ls last; and second for the succeeding cases EOF is
4122 # not what these should read, so go over the backside and splice it in!
4123 call _Ls "$@"
4124 echo -----After Lreply $1.$2: $?/$^ERRNAME
4126 define x {
4127 localopts call-fixate yes
4128 call r $1
4129 call R $1 1; call R $1 2; call R $1 3; call R $1 4
4130 call L $1 1; call L $1 2; call L $1 3
4132 define tweak {
4133 echo;echo '===== CHANGING === '"$*"' =====';echo
4134 eval "$@"
4137 set from=laber@backe.eu
4138 mlist is@a.list
4139 call x 1
4140 call tweak set reply-to-honour
4141 call x 2
4142 call tweak set followup-to
4143 call x 3
4144 call tweak set followup-to-honour
4145 call x 4
4146 call tweak mlist bugstop@five.miles.out
4147 call x 5
4148 call tweak mlsubscribe bugstop@five.miles.out
4149 call x 6
4150 call tweak set recipients-in-cc
4151 call x 7
4152 _EOT
4154 check behave:lreply_futh_rth_etc 0 "${MBOX}" '940818845 29373'
4156 t_epilog
4159 t_behave_iconv_mbyte_base64() {
4160 t_prolog t_behave_iconv_mbyte_base64
4161 TRAP_EXIT_ADDONS="./.t*"
4163 if [ -n "${UTF8_LOCALE}" ] && have_feat iconv &&
4164 ( ${iconv} -l | ${grep} -i -e iso-2022-jp -e euc-jp) >/dev/null 2>&1
4165 then
4167 else
4168 echo 'behave:iconv_mbyte_base64: unsupported, skipped'
4169 return
4172 ${cat} <<-_EOT > ./.tsendmail.sh
4173 #!${SHELL} -
4174 (echo 'From DroseriaRotundifolia Thu Aug 03 17:26:25 2017' && ${cat} &&
4175 echo) >> "${MBOX}"
4176 _EOT
4177 chmod 0755 ./.tsendmail.sh
4179 if ( ${iconv} -l | ${grep} -i iso-2022-jp ) >/dev/null 2>&1; then
4180 cat <<-'_EOT' | LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} \
4181 -Smta=./.tsendmail.sh \
4182 -Sescape=! -Smime-encoding=base64 2>./.terr
4183 set ttycharset=utf-8 sendcharsets=iso-2022-jp
4184 m t1@exam.ple
4185 !s Japanese from UTF-8 to ISO-2022-JP
4186 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
4188 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
4191 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
4193 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
4196 set ttycharset=iso-2022-jp charset-7bit=iso-2022-jp sendcharsets=utf-8
4197 m t2@exam.ple
4198 !s Japanese from ISO-2022-JP to UTF-8, eh, no, also ISO-2022-JP
4199 \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
4201 \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
4204 \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
4206 \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
4208 _EOT
4209 check behave:iconv_mbyte_base64-1 0 "${MBOX}" '3428985079 1976'
4210 check behave:iconv_mbyte_base64-2 - ./.terr '4294967295 0'
4212 printf 'eval f 1; write ./.twrite\n' |
4213 ${MAILX} ${ARGS} ${ADDARG_UNI} -Rf "${MBOX}" >./.tlog 2>&1
4214 check behave:iconv_mbyte_base64-3 0 ./.twrite '1259742080 686'
4215 check behave:iconv_mbyte_base64-4 - ./.tlog '3956097665 119'
4216 else
4217 echo 'behave:iconv_mbyte_base64: ISO-2022-JP unsupported, skipping 1-4'
4220 if ( ${iconv} -l | ${grep} -i euc-jp ) >/dev/null 2>&1; then
4221 rm -f "${MBOX}" ./.twrite
4222 cat <<-'_EOT' | LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} \
4223 -Smta=./.tsendmail.sh \
4224 -Sescape=! -Smime-encoding=base64 2>./.terr
4225 set ttycharset=utf-8 sendcharsets=euc-jp
4226 m t1@exam.ple
4227 !s Japanese from UTF-8 to EUC-JP
4228 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
4230 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
4233 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
4235 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
4238 set ttycharset=EUC-JP sendcharsets=utf-8
4239 m t2@exam.ple
4240 !s Japanese from EUC-JP to UTF-8
4241 ¥·¥¸¥å¥¦¥«¥é²Ê¡Ê¥·¥¸¥å¥¦¥«¥é¤«¡¢³Ø̾ Paridae¡Ë¤Ï¡¢Ä»Îॹ¥º¥áÌܤβʤǤ¢¤ë¡£¥·¥¸¥å¥¦¥«¥é¡Ê»Í½½¿ý¡Ë¤ÈÁí¾Î¤µ¤ì¤ë¤¬¡¢¶¹µÁ¤Ë¤Ï¤³¤Î1¼ï¤ò¥·¥¸¥å¥¦¥«¥é¤È¸Æ¤Ö¡£
4243 ¥«¥ó¥à¥ê¥¬¥é¡Ê³Ø̾Parus cristatus¡Ë¤Ï¡¢¥¹¥º¥áÌÜ¥·¥¸¥å¥¦¥«¥é²Ê¤ËʬÎव¤ì¤ëÄ»Îà¤Î°ì¼ï¡£
4246 ¥«¥ó¥à¥ê¥¬¥é¡Ê³Ø̾Parus cristatus¡Ë¤Ï¡¢¥¹¥º¥áÌÜ¥·¥¸¥å¥¦¥«¥é²Ê¤ËʬÎव¤ì¤ëÄ»Îà¤Î°ì¼ï¡£
4248 ¥·¥¸¥å¥¦¥«¥é²Ê¡Ê¥·¥¸¥å¥¦¥«¥é¤«¡¢³Ø̾ Paridae¡Ë¤Ï¡¢Ä»Îॹ¥º¥áÌܤβʤǤ¢¤ë¡£¥·¥¸¥å¥¦¥«¥é¡Ê»Í½½¿ý¡Ë¤ÈÁí¾Î¤µ¤ì¤ë¤¬¡¢¶¹µÁ¤Ë¤Ï¤³¤Î1¼ï¤ò¥·¥¸¥å¥¦¥«¥é¤È¸Æ¤Ö¡£
4250 _EOT
4251 check behave:iconv_mbyte_base64-5 0 "${MBOX}" '1686827547 2051'
4252 check behave:iconv_mbyte_base64-6 - ./.terr '4294967295 0'
4254 printf 'eval f 1; write ./.twrite\n' |
4255 ${MAILX} ${ARGS} ${ADDARG_UNI} -Rf "${MBOX}" >./.tlog 2>&1
4256 check behave:iconv_mbyte_base64-7 0 ./.twrite '1259742080 686'
4257 check behave:iconv_mbyte_base64-8 - ./.tlog '500059195 119'
4258 else
4259 echo 'behave:iconv_mbyte_base64: EUC-JP unsupported, skipping 5-8'
4262 t_epilog
4265 # t_content()
4266 # Some basic tests regarding correct sending of mails, via STDIN / -t / -q,
4267 # including basic MIME Content-Transfer-Encoding correctness (quoted-printable)
4268 # Note we unfortunately need to place some statements without proper
4269 # indentation because of continuation problems
4270 t_content() {
4271 t_prolog t_content
4273 # MIME encoding (QP) stress message body
4274 printf \
4275 'Ich bin eine DÖS-Datäi mit sehr langen Zeilen und auch '\
4276 'sonst bin ich ganz schön am Schleudern, da kannste denke '\
4277 "wasde willst, gelle, gelle, gelle, gelle, gelle.\r\n"\
4278 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst \r\n"\
4279 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1\r\n"\
4280 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12\r\n"\
4281 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123\r\n"\
4282 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1234\r\n"\
4283 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12345\r\n"\
4284 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123456\r\n"\
4285 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1234567\r\n"\
4286 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12345678\r\n"\
4287 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123456789\r\n"\
4288 "Unn ausserdem habe ich trailing SP/HT/SP/HT whitespace \r\n"\
4289 "Unn ausserdem habe ich trailing HT/SP/HT/SP whitespace \r\n"\
4290 "auf den zeilen vorher.\r\n"\
4291 "From am Zeilenbeginn und From der Mitte gibt es auch.\r\n"\
4292 ".\r\n"\
4293 "Die letzte Zeile war nur ein Punkt.\r\n"\
4294 "..\r\n"\
4295 "Das waren deren zwei.\r\n"\
4296 " \r\n"\
4297 "Die letzte Zeile war ein Leerschritt.\n"\
4298 "=VIER = EQUAL SIGNS=ON A LINE=\r\n"\
4299 "Prösterchen.\r\n"\
4300 ".\n"\
4301 "Die letzte Zeile war nur ein Punkt, mit Unix Zeilenende.\n"\
4302 "..\n"\
4303 "Das waren deren zwei. ditto.\n"\
4304 "Prösterchen.\n"\
4305 "Unn ausseerdem habe ich trailing SP/HT/SP/HT whitespace \n"\
4306 "Unn ausseerdem habe ich trailing HT/SP/HT/SP whitespace \n"\
4307 "auf den zeilen vorher.\n"\
4308 "ditto.\n"\
4309 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.\n"\
4310 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.1"\
4311 "\n"\
4312 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
4313 "\n"\
4314 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
4315 "3\n"\
4316 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
4317 "34\n"\
4318 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
4319 "345\n"\
4320 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
4321 "3456\n"\
4322 "QP am Zeilenende über soft-nl hinweg\n"\
4323 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
4324 "ö123\n"\
4325 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
4326 "1ö23\n"\
4327 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
4328 "12ö3\n"\
4329 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
4330 "123ö\n"\
4331 "=VIER = EQUAL SIGNS=ON A LINE=\n"\
4332 " \n"\
4333 "Die letzte Zeile war ein Leerschritt.\n"\
4334 ' '\
4335 > "${BODY}"
4337 # MIME encoding (QP) stress message subject
4338 SUB="Äbrä Kä?dä=brö Fü?di=bus? \
4339 adadaddsssssssddddddddddddddddddddd\
4340 ddddddddddddddddddddddddddddddddddd\
4341 ddddddddddddddddddddddddddddddddddd\
4342 dddddddddddddddddddd Hallelulja? Od\
4343 er?? eeeeeeeeeeeeeeeeeeeeeeeeeeeeee\
4344 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\
4345 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee f\
4346 fffffffffffffffffffffffffffffffffff\
4347 fffffffffffffffffffff ggggggggggggg\
4348 ggggggggggggggggggggggggggggggggggg\
4349 ggggggggggggggggggggggggggggggggggg\
4350 ggggggggggggggggggggggggggggggggggg\
4351 gggggggggggggggg"
4353 # Three tests for MIME encoding and (a bit) content classification.
4354 # At the same time testing -q FILE, < FILE and -t FILE
4356 ${rm} -f "${MBOX}"
4357 < "${BODY}" ${MAILX} ${ARGS} ${ADDARG_UNI} \
4358 -a "${BODY}" -s "${SUB}" "${MBOX}"
4359 check content:001 0 "${MBOX}" '1145066634 6654'
4361 ${rm} -f "${MBOX}"
4362 < /dev/null ${MAILX} ${ARGS} ${ADDARG_UNI} \
4363 -a "${BODY}" -s "${SUB}" -q "${BODY}" "${MBOX}"
4364 check content:002 0 "${MBOX}" '1145066634 6654'
4366 ${rm} -f "${MBOX}"
4367 ( echo "To: ${MBOX}" && echo "Subject: ${SUB}" && echo &&
4368 ${cat} "${BODY}"
4369 ) | ${MAILX} ${ARGS} ${ADDARG_UNI} -Snodot -a "${BODY}" -t
4370 check content:003 0 "${MBOX}" '1145066634 6654'
4372 # Test for [260e19d] (Juergen Daubert)
4373 ${rm} -f "${MBOX}"
4374 echo body | ${MAILX} ${ARGS} "${MBOX}"
4375 check content:004 0 "${MBOX}" '2917662811 98'
4377 # Sending of multiple mails in a single invocation
4378 ${rm} -f "${MBOX}"
4379 ( printf "m ${MBOX}\n~s subject1\nE-Mail Körper 1\n~.\n" &&
4380 printf "m ${MBOX}\n~s subject2\nEmail body 2\n~.\n" &&
4381 echo x
4382 ) | ${MAILX} ${ARGS} ${ADDARG_UNI}
4383 check content:005 0 "${MBOX}" '2098659767 358'
4385 ## $BODY CHANGED
4387 # "Test for" [d6f316a] (Gavin Troy)
4388 ${rm} -f "${MBOX}"
4389 printf "m ${MBOX}\n~s subject1\nEmail body\n~.\nfi ${MBOX}\np\nx\n" |
4390 ${MAILX} ${ARGS} ${ADDARG_UNI} -Spipe-text/plain="@* ${cat}" > "${BODY}"
4391 check content:006 0 "${MBOX}" '2099098650 122'
4392 check content:006-1 - "${BODY}" '794542938 174'
4394 # "Test for" [c299c45] (Peter Hofmann) TODO shouldn't end up QP-encoded?
4395 ${rm} -f "${MBOX}"
4396 ${awk} 'BEGIN{
4397 for(i = 0; i < 10000; ++i)
4398 printf "\xC3\xBC"
4399 #printf "\xF0\x90\x87\x90"
4400 }' | ${MAILX} ${ARGS} ${ADDARG_UNI} -s TestSubject "${MBOX}"
4401 check content:007 0 "${MBOX}" '534262374 61816'
4403 ## Test some more corner cases for header bodies (as good as we can today) ##
4406 ${rm} -f "${MBOX}"
4407 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
4408 -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̲' \
4409 "${MBOX}"
4410 check content:008 0 "${MBOX}" '3370931614 375'
4412 # Single word (overlong line split -- bad standard! Requires injection of
4413 # artificial data!! But can be prevented by using RFC 2047 encoding)
4414 ${rm} -f "${MBOX}"
4415 i=`${awk} 'BEGIN{for(i=0; i<92; ++i) printf "0123456789_"}'`
4416 echo | ${MAILX} ${ARGS} -s "${i}" "${MBOX}"
4417 check content:009 0 "${MBOX}" '489922370 1718'
4419 # Combination of encoded words, space and tabs of varying sort
4420 ${rm} -f "${MBOX}"
4421 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
4422 -s "1Abrä Kaspas1 2Abra Katä b_kaspas2 \
4423 3Abrä Kaspas3 4Abrä Kaspas4 5Abrä Kaspas5 \
4424 6Abra Kaspas6 7Abrä Kaspas7 8Abra Kaspas8 \
4425 9Abra Kaspastäb4-3 10Abra Kaspas1 _ 11Abra Katäb1 \
4426 12Abra Kadabrä1 After Tab after Täb this is NUTS" \
4427 "${MBOX}"
4428 check content:010 0 "${MBOX}" '1676887734 591'
4430 # Overlong multibyte sequence that must be forcefully split
4431 # todo This works even before v15.0, but only by accident
4432 ${rm} -f "${MBOX}"
4433 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
4434 -s "✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
4435 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
4436 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄" \
4437 "${MBOX}"
4438 check content:011 0 "${MBOX}" '3029301775 659'
4440 # Trailing WS
4441 ${rm} -f "${MBOX}"
4442 echo | ${MAILX} ${ARGS} \
4443 -s "1-1 B2 B3 B4 B5 B6 B\
4444 1-2 B2 B3 B4 B5 B6 B\
4445 1-3 B2 B3 B4 B5 B6 B\
4446 1-4 B2 B3 B4 B5 B6 B\
4447 1-5 B2 B3 B4 B5 B6 B\
4448 1-6 B2 B3 B4 B5 B6 " \
4449 "${MBOX}"
4450 check content:012 0 "${MBOX}" '4126167195 297'
4452 # Leading and trailing WS
4453 ${rm} -f "${MBOX}"
4454 echo | ${MAILX} ${ARGS} \
4455 -s " 2-1 B2 B3 B4 B5 B6 B\
4456 1-2 B2 B3 B4 B5 B6 B\
4457 1-3 B2 B3 B4 B5 B6 B\
4458 1-4 B2 B3 B4 B5 B6 " \
4459 "${MBOX}"
4460 check content:013 0 "${MBOX}" '3600624479 236'
4462 # Quick'n dirty RFC 2231 test; i had more when implementing it, but until we
4463 # have a (better) test framework materialize a quick shot
4464 ${rm} -f "${MBOX}"
4465 TRAP_EXIT_ADDONS=./.ttt
4467 mkdir ./.ttt || exit 1
4468 cd ./.ttt || exit 2
4469 : > "ma'ger.txt"
4470 : > "mä'ger.txt"
4471 : > 'diet\ is \curd.txt'
4472 : > 'diet "is" curd.txt'
4473 : > höde-tröge.txt
4474 : > höde__tröge__müde__dätte__hätte__vülle__gülle__äse__äße__säuerliche__kräuter__österliche__grüße__mäh.txt
4475 : > höde__tröge__müde__dätte__hätte__vuelle__guelle__aese__aesse__sauerliche__kräuter__österliche__grüße__mäh.txt
4476 : > hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt
4477 : > ✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt
4479 echo bla | ${MAILX} ${ARGS} ${ADDARG_UNI} \
4480 -a "./.ttt/ma'ger.txt" -a "./.ttt/mä'ger.txt" \
4481 -a './.ttt/diet\ is \curd.txt' -a './.ttt/diet "is" curd.txt' \
4482 -a ./.ttt/höde-tröge.txt \
4483 -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 \
4484 -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 \
4485 -a ./.ttt/hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt \
4486 -a ./.ttt/✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt \
4487 "${MBOX}"
4488 check content:014-1 0 "${MBOX}" '684985954 3092'
4490 # `resend' test, reusing $MBOX
4491 ${rm} -f "${BODY}"
4492 printf "Resend ${BODY}\nx\n" | ${MAILX} ${ARGS} -Rf "${MBOX}"
4493 check content:014-2 0 "${BODY}" '684985954 3092'
4495 ${rm} -f "${BODY}"
4496 printf "resend ${BODY}\nx\n" | ${MAILX} ${ARGS} -Rf "${MBOX}"
4497 check content:014-3 0 "${BODY}" '3130352658 3148'
4499 t_epilog
4502 t_all() {
4503 # if have_feat devel; then
4504 # ARGS="${ARGS} -Smemdebug"
4505 # export ARGS
4506 # fi
4508 if [ -n "${UTF8_LOCALE}" ]; then
4509 printf 'Using Unicode locale %s\n' "${UTF8_LOCALE}"
4510 else
4511 printf 'No Unicode locale found, disabling Unicode tests\n'
4514 t_behave
4515 t_content
4518 if [ -z "${CHECK_ONLY}${MAE_TEST}" ]; then
4519 cc_all_configs
4520 elif [ -z "${MAE_TEST}" ] || [ ${#} -eq 0 ]; then
4521 t_all
4522 else
4523 while [ ${#} -gt 0 ]; do
4524 ${1}
4525 shift
4526 done
4529 [ ${ESTAT} -eq 0 ] && echo Ok || echo >&2 'Errors occurred'
4531 exit ${ESTAT}
4532 # s-sh-mode