make-release.txt: OpenPGP replaced after USB stick loss
[s-mailx.git] / cc-test.sh
blobec4421e367a1edf254b1d6406d99f32738f3d2b0
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 # Instead of figuring out the environment in here, require a configured build
9 # system and include that! Our makefile and configure ensure that this test
10 # does not run in the configured, but the user environment nonetheless!
11 if [ -f ./mk-config.ev ]; then
12 . ./mk-config.ev
13 if [ -z "${MAILX__CC_TEST_RUNNING}" ]; then
14 MAILX__CC_TEST_RUNNING=1
15 export MAILX__CC_TEST_RUNNING
16 exec "${SHELL}" "${0}" "${@}"
18 else
19 echo >&2 'S-nail/S-mailx is not configured.'
20 echo >&2 'This test script requires the shell environment that only the'
21 echo >&2 'configuration script can figure out, even if it will be used to'
22 echo >&2 'test a different binary than the one that would be produced!'
23 exit 41
26 # We need *stealthmua* regardless of $SOURCE_DATE_EPOCH, the program name as
27 # such is a compile-time variable
28 ARGS='-:/ -# -Sdotlock-ignore-error -Sexpandaddr=restrict'
29 ARGS="${ARGS}"' -Smime-encoding=quoted-printable -Snosave -Sstealthmua'
30 ADDARG_UNI=-Sttycharset=UTF-8
31 CONF=./make.rc
32 BODY=./.cc-body.txt
33 MBOX=./.cc-test.mbox
34 MAIL=/dev/null
35 #UTF8_LOCALE= autodetected unless set
37 # Note valgrind has problems with FDs in forked childs, which causes some tests
38 # to fail (the FD is rewound and thus will be dumped twice)
39 MEMTESTER=
40 #MEMTESTER='valgrind --leak-check=full --log-file=.vl-%p '
42 ## -- (>8 -- 8<) -- ##
44 ( set -o noglob ) >/dev/null 2>&1 && noglob_shell=1 || unset noglob_shell
46 msg() {
47 fmt=${1}
48 shift
49 printf >&2 -- "${fmt}\\n" "${@}"
52 ## -- >8 -- 8< -- ##
54 export ARGS ADDARG_UNI CONF BODY MBOX MAIL MAKE awk cat cksum rm sed grep
56 LC_ALL=C LANG=C
57 TZ=UTC
58 # Wed Oct 2 01:50:07 UTC 1996
59 SOURCE_DATE_EPOCH=844221007
61 export LC_ALL LANG TZ SOURCE_DATE_EPOCH
62 unset POSIXLY_CORRECT LOGNAME USER
64 usage() {
65 echo >&2 "Synopsis: ./cc-test.sh [--check-only s-mailx-binary]"
66 echo >&2 "Synopsis: ./cc-test.sh --mae-test s-mailx-binary [:TESTNAME:]"
67 exit 1
70 CHECK_ONLY= MAE_TEST= MAILX=
71 if [ "${1}" = --check-only ]; then
72 CHECK_ONLY=1
73 MAILX=${2}
74 [ -x "${MAILX}" ] || usage
75 shift 2
76 elif [ "${1}" = --mae-test ]; then
77 MAE_TEST=1
78 MAILX=${2}
79 [ -x "${MAILX}" ] || usage
80 shift 2
82 RAWMAILX=${MAILX}
83 MAILX="${MEMTESTER}${MAILX}"
84 export RAWMAILX MAILX
86 if [ -n "${CHECK_ONLY}${MAE_TEST}" ] && [ -z "${UTF8_LOCALE}" ]; then
87 # Try ourselfs for nl_langinfo(CODESET) output first (requires a new version)
88 i=`LC_ALL=C.utf8 "${RAWMAILX}" ${ARGS} -X '
89 \define cset_test {
90 \if [ "${ttycharset}" @i=% utf ]
91 \echo $LC_ALL
92 \xit 0
93 \end
94 \if [ "${#}" -gt 0 ]
95 \wysh set LC_ALL=${1}
96 \shift
97 \eval xcall cset_test "${@}"
98 \end
99 \xit 1
101 \call cset_test C.UTF-8 POSIX.utf8 POSIX.UTF-8 en_EN.utf8 en_EN.UTF-8 \
102 en_US.utf8 en_US.UTF-8
104 [ $? -eq 0 ] && UTF8_LOCALE=$i
106 if [ -z "${UTF8_LOCALE}" ] && (locale yesexpr) >/dev/null 2>&1; then
107 UTF8_LOCALE=`locale -a | { m=
108 while read n; do
109 if { echo ${n} | ${grep} -i 'utf-\{0,1\}8'; } >/dev/null 2>&1; then
110 m=${n}
111 if { echo ${n} | ${grep} -e POSIX -e en_EN -e en_US; }; then
112 exit 0
115 m=${n}
116 done
117 echo ${m}
122 ESTAT=0
124 TRAP_EXIT_ADDONS=
125 trap "${rm} -rf \"${BODY}\" \"${MBOX}\" \${TRAP_EXIT_ADDONS}" EXIT
126 trap "exit 1" HUP INT TERM
128 # cc_all_configs()
129 # Test all configs TODO doesn't cover all *combinations*, stupid!
130 cc_all_configs() {
131 < ${CONF} ${awk} '
132 BEGIN {
133 NOTME["OPT_AUTOCC"] = 1
134 NOTME["OPT_DEBUG"] = 1
135 NOTME["OPT_DEVEL"] = 1
136 NOTME["OPT_NOEXTMD5"] = 1
137 NOTME["OPT_ASAN_ADDRESS"] = 1
138 NOTME["OPT_ASAN_MEMORY"] = 1
139 NOTME["OPT_FORCED_STACKPROT"] = 1
140 NOTME["OPT_NOMEMDBG"] = 1
141 NOTME["OPT_NYD2"] = 1
142 i = 0
144 /^[[:space:]]*OPT_/ {
145 sub(/^[[:space:]]*/, "")
146 # This bails for UnixWare 7.1.4 awk(1), but preceeding = with \
147 # does not seem to be a compliant escape for =
148 #sub(/=.*$/, "")
149 $1 = substr($1, 1, index($1, "=") - 1)
150 if (NOTME[$1])
151 next
152 data[i++] = $1
154 END {
155 # Doing this completely sequentially and not doing make distclean in
156 # between runs should effectively result in lesser compilations.
157 # It is completely dumb nonetheless... TODO
158 for (j = 1; j < i; ++j) {
159 for (k = 1; k < j; ++k)
160 printf data[k] "=1 "
161 for (k = j; k < i; ++k)
162 printf data[k] "=0 "
163 printf "OPT_AUTOCC=1\n"
165 for (j = 1; j < i; ++j) {
166 for (k = 1; k < j; ++k)
167 printf data[k] "=0 "
168 for (k = j; k < i; ++k)
169 printf data[k] "=1 "
170 printf "OPT_AUTOCC=1\n"
172 # With debug
173 for (j = 1; j < i; ++j) {
174 for (k = 1; k < j; ++k)
175 printf data[k] "=1 "
176 for (k = j; k < i; ++k)
177 printf data[k] "=0 "
178 printf "OPT_AUTOCC=1\n"
179 printf "OPT_DEBUG=1\n"
181 for (j = 1; j < i; ++j) {
182 for (k = 1; k < j; ++k)
183 printf data[k] "=0 "
184 for (k = j; k < i; ++k)
185 printf data[k] "=1 "
186 printf "OPT_AUTOCC=1\n"
187 printf "OPT_DEBUG=1\n"
190 printf "CONFIG=NULL OPT_AUTOCC=0\n"
191 printf "CONFIG=NULL OPT_AUTOCC=1\n"
192 printf "CONFIG=NULLI OPT_AUTOCC=0\n"
193 printf "CONFIG=NULLI OPT_AUTOCC=1\n"
194 printf "CONFIG=MINIMAL OPT_AUTOCC=0\n"
195 printf "CONFIG=MINIMAL OPT_AUTOCC=1\n"
196 printf "CONFIG=NETSEND OPT_AUTOCC=0\n"
197 printf "CONFIG=NETSEND OPT_AUTOCC=1\n"
198 printf "CONFIG=MAXIMAL OPT_AUTOCC=0\n"
199 printf "CONFIG=MAXIMAL OPT_AUTOCC=1\n"
200 printf "CONFIG=DEVEL OPT_AUTOCC=0\n"
201 printf "CONFIG=DEVEL OPT_AUTOCC=1\n"
202 printf "CONFIG=ODEVEL OPT_AUTOCC=0\n"
203 printf "CONFIG=ODEVEL OPT_AUTOCC=1\n"
205 ' | while read c; do
206 printf "\n\n##########\n$c\n"
207 printf "\n\n##########\n$c\n" >&2
208 sh -c "${MAKE} ${c} all test"
209 done
210 ${MAKE} distclean
213 have_feat() {
214 ( "${RAWMAILX}" ${ARGS} -X'echo $features' -Xx |
215 ${grep} +${1} ) >/dev/null 2>&1
218 t_prolog() {
219 ${rm} -rf "${BODY}" "${MBOX}" ${TRAP_EXIT_ADDONS}
220 TRAP_EXIT_ADDONS=
221 [ ${#} -gt 0 ] && printf '[%s]\n' "${1}"
223 t_epilog() {
224 t_prolog
227 check() {
228 restat=${?} tid=${1} eestat=${2} f=${3} s=${4}
229 [ "${eestat}" != - ] && [ "${restat}" != "${eestat}" ] &&
230 err "${tid}" 'unexpected exit status: '"${restat} != ${eestat}"
231 csum="`${cksum} < ${f}`"
232 if [ "${csum}" = "${s}" ]; then
233 printf '%s: ok\n' "${tid}"
234 else
235 ESTAT=1
236 printf '%s: error: checksum mismatch (got %s)\n' "${tid}" "${csum}"
238 if [ -n "${MAE_TEST}" ]; then
239 x=`echo ${tid} | ${tr} "/:=" "__-"`
240 ${cp} -f "${f}" ./mae-test-"${x}"
244 err() {
245 ESTAT=1
246 printf '%s: error: %s\n' ${1} "${2}"
249 ex0_test() {
250 # $1=test name [$2=status]
251 __qm__=${?}
252 [ ${#} -gt 1 ] && __qm__=${2}
253 if [ ${__qm__} -ne 0 ]; then
254 err $1 'unexpected non-0 exit status'
255 else
256 printf '%s: ok\n' "${1}"
260 exn0_test() {
261 # $1=test name [$2=status]
262 __qm__=${?}
263 [ ${#} -gt 1 ] && __qm__=${2}
264 if [ ${__qm__} -eq 0 ]; then
265 err $1 'unexpected 0 exit status'
266 else
267 printf '%s: ok\n' "${1}"
271 if ( [ "$((1 + 1))" = 2 ] ) >/dev/null 2>&1; then
272 add() {
273 echo "$((${1} + ${2}))"
275 else
276 add() {
277 echo `${awk} 'BEGIN{print '${1}' + '${2}'}'`
281 if ( [ "$((2 % 3))" = 2 ] ) >/dev/null 2>&1; then
282 modulo() {
283 echo "$((${1} % ${2}))"
285 else
286 modulo() {
287 echo `${awk} 'BEGIN{print '${1}' % '${2}'}'`
291 # t_behave()
292 # Basic (easily testable) behaviour tests
293 t_behave() {
294 t_behave_X_opt_input_command_stack
295 t_behave_X_errexit
296 t_behave_S_freeze
297 t_behave_wysh
298 t_behave_input_inject_semicolon_seq
299 t_behave_commandalias
300 t_behave_ifelse
301 t_behave_localopts
302 t_behave_macro_param_shift
303 t_behave_addrcodec
304 t_behave_vexpr
305 t_behave_call_ret
306 t_behave_xcall
307 t_behave_vpospar
308 t_behave_atxplode
310 t_behave_mbox
312 t_behave_alternates
313 t_behave_alias
314 # FIXME t_behave_mlist
315 t_behave_filetype
317 t_behave_record_a_resend
319 t_behave_e_H_L_opts
320 t_behave_compose_hooks
321 t_behave_message_injections
322 t_behave_mime_types_load_control
324 t_behave_s_mime
326 t_behave_maildir
327 t_behave_mass_recipients
328 t_behave_lreply_futh_rth_etc
329 t_behave_iconv_mbyte_base64
330 t_behave_iconv_mainbody
333 t_behave_X_opt_input_command_stack() {
334 t_prolog t_behave_X_opt_input_command_stack
336 ${cat} <<- '__EOT' > "${BODY}"
337 echo 1
338 define mac0 {
339 echo mac0-1 via1 $0
341 call mac0
342 echo 2
343 source '\
344 echo "define mac1 {";\
345 echo " echo mac1-1 via1 \$0";\
346 echo " call mac0";\
347 echo " echo mac1-2";\
348 echo " call mac2";\
349 echo " echo mac1-3";\
350 echo "}";\
351 echo "echo 1-1";\
352 echo "define mac2 {";\
353 echo " echo mac2-1 via1 \$0";\
354 echo " call mac0";\
355 echo " echo mac2-2";\
356 echo "}";\
357 echo "echo 1-2";\
358 echo "call mac1";\
359 echo "echo 1-3";\
360 echo "source \"\
361 echo echo 1-1-1 via1 \$0;\
362 echo call mac0;\
363 echo echo 1-1-2;\
364 | \"";\
365 echo "echo 1-4";\
367 echo 3
368 call mac2
369 echo 4
370 undefine *
371 __EOT
373 # The -X option supports multiline arguments, and those can internally use
374 # reverse solidus newline escaping. And all -X options are joined...
375 APO=\'
376 < "${BODY}" ${MAILX} ${ARGS} \
377 -X 'e\' \
378 -X ' c\' \
379 -X ' h\' \
380 -X ' o \' \
381 -X 1 \
383 define mac0 {
384 echo mac0-1 via2 $0
386 call mac0
387 echo 2
390 source '${APO}'\
391 echo "define mac1 {";\
392 echo " echo mac1-1 via2 \$0";\
393 echo " call mac0";\
394 echo " echo mac1-2";\
395 echo " call mac2";\
396 echo " echo mac1-3";\
397 echo "}";\
398 echo "echo 1-1";\
399 echo "define mac2 {";\
400 echo " echo mac2-1 via2 \$0";\
401 echo " call mac0";\
402 echo " echo mac2-2";\
403 echo "}";\
404 echo "echo 1-2";\
405 echo "call mac1";\
406 echo "echo 1-3";\
407 echo "source \"\
408 echo echo 1-1-1 via2 \$0;\
409 echo call mac0;\
410 echo echo 1-1-2;\
411 | \"";\
412 echo "echo 1-4";\
413 | '${APO}'
414 echo 3
417 call mac2
418 echo 4
419 undefine *
420 ' > "${MBOX}"
422 check behave:x_opt_input_command_stack 0 "${MBOX}" '1786542668 416'
424 t_epilog
427 t_behave_X_errexit() {
428 t_prolog t_behave_X_errexit
430 ${cat} <<- '__EOT' > "${BODY}"
431 echo one
432 echos nono
433 echo two
434 __EOT
436 </dev/null ${MAILX} ${ARGS} -Snomemdebug \
437 -X'echo one' -X' echos nono ' -X'echo two' \
438 > "${MBOX}" 2>&1
439 check behave:x_errexit-1 0 "${MBOX}" '916157812 53'
441 </dev/null ${MAILX} ${ARGS} -X'source '"${BODY}" -Snomemdebug \
442 > "${MBOX}" 2>&1
443 check behave:x_errexit-2 0 "${MBOX}" '916157812 53'
445 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Snomemdebug \
446 > "${MBOX}" 2>&1
447 check behave:x_errexit-3 0 "${MBOX}" '916157812 53'
451 </dev/null ${MAILX} ${ARGS} -Serrexit -Snomemdebug \
452 -X'echo one' -X' echos nono ' -X'echo two' \
453 > "${MBOX}" 2>&1
454 check behave:x_errexit-4 1 "${MBOX}" '2118430867 49'
456 </dev/null ${MAILX} ${ARGS} -X'source '"${BODY}" -Serrexit -Snomemdebug \
457 > "${MBOX}" 2>&1
458 check behave:x_errexit-5 1 "${MBOX}" '2118430867 49'
460 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Serrexit -Snomemdebug \
461 > "${MBOX}" 2>&1
462 check behave:x_errexit-6 1 "${MBOX}" '12955965 172'
464 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Sposix -Snomemdebug \
465 > "${MBOX}" 2>&1
466 check behave:x_errexit-7 1 "${MBOX}" '12955965 172'
468 ## Repeat 4-7 with ignerr set
470 ${sed} -e 's/^echos /ignerr echos /' < "${BODY}" > "${MBOX}"
472 </dev/null ${MAILX} ${ARGS} -Serrexit -Snomemdebug \
473 -X'echo one' -X'ignerr echos nono ' -X'echo two' \
474 > "${BODY}" 2>&1
475 check behave:x_errexit-8 0 "${BODY}" '916157812 53'
477 </dev/null ${MAILX} ${ARGS} -X'source '"${MBOX}" -Serrexit -Snomemdebug \
478 > "${BODY}" 2>&1
479 check behave:x_errexit-9 0 "${BODY}" '916157812 53'
481 </dev/null MAILRC="${MBOX}" ${MAILX} ${ARGS} -:u -Serrexit -Snomemdebug \
482 > "${BODY}" 2>&1
483 check behave:x_errexit-10 0 "${BODY}" '916157812 53'
485 </dev/null MAILRC="${MBOX}" ${MAILX} ${ARGS} -:u -Sposix -Snomemdebug \
486 > "${BODY}" 2>&1
487 check behave:x_errexit-11 0 "${BODY}" '916157812 53'
489 t_epilog
492 t_behave_S_freeze() {
493 t_prolog t_behave_S_freeze
494 oterm=$TERM
495 unset TERM
497 # Test basic assumption
498 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} \
499 -X'echo asksub<$asksub> dietcurd<$dietcurd>' \
500 -Xx > "${MBOX}" 2>&1
501 check behave:s_freeze-1 0 "${MBOX}" '270686329 21'
504 ${cat} <<- '__EOT' > "${BODY}"
505 echo asksub<$asksub>
506 set asksub
507 echo asksub<$asksub>
508 __EOT
509 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
510 -Snoasksub -Sasksub -Snoasksub \
511 -X'echo asksub<$asksub>' -X'set asksub' -X'echo asksub<$asksub>' \
512 -Xx > "${MBOX}" 2>&1
513 check behave:s_freeze-2 0 "${MBOX}" '3182942628 37'
515 ${cat} <<- '__EOT' > "${BODY}"
516 echo asksub<$asksub>
517 unset asksub
518 echo asksub<$asksub>
519 __EOT
520 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
521 -Snoasksub -Sasksub \
522 -X'echo asksub<$asksub>' -X'unset asksub' -X'echo asksub<$asksub>' \
523 -Xx > "${MBOX}" 2>&1
524 check behave:s_freeze-3 0 "${MBOX}" '2006554293 39'
527 ${cat} <<- '__EOT' > "${BODY}"
528 echo dietcurd<$dietcurd>
529 set dietcurd=cherry
530 echo dietcurd<$dietcurd>
531 __EOT
532 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
533 -Sdietcurd=strawberry -Snodietcurd -Sdietcurd=vanilla \
534 -X'echo dietcurd<$dietcurd>' -X'unset dietcurd' \
535 -X'echo dietcurd<$dietcurd>' \
536 -Xx > "${MBOX}" 2>&1
537 check behave:s_freeze-4 0 "${MBOX}" '1985768109 65'
539 ${cat} <<- '__EOT' > "${BODY}"
540 echo dietcurd<$dietcurd>
541 unset dietcurd
542 echo dietcurd<$dietcurd>
543 __EOT
544 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
545 -Sdietcurd=strawberry -Snodietcurd \
546 -X'echo dietcurd<$dietcurd>' -X'set dietcurd=vanilla' \
547 -X'echo dietcurd<$dietcurd>' \
548 -Xx > "${MBOX}" 2>&1
549 check behave:s_freeze-5 0 "${MBOX}" '151574279 51'
551 # TODO once we have a detached one with env=1..
552 if [ -n "`</dev/null ${MAILX} ${ARGS} -X'!echo \$TERM' -Xx`" ]; then
553 echo 'behave:s_freeze-{6,7}: shell sets $TERM, skipped'
554 else
555 ${cat} <<- '__EOT' > "${BODY}"
556 !echo "shell says TERM<$TERM>"
557 echo TERM<$TERM>
558 !echo "shell says TERM<$TERM>"
559 set TERM=cherry
560 !echo "shell says TERM<$TERM>"
561 echo TERM<$TERM>
562 !echo "shell says TERM<$TERM>"
563 __EOT
564 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
565 -STERM=strawberry -SnoTERM -STERM=vanilla \
566 -X'echo mail<$TERM>' -X'unset TERM' \
567 -X'!echo "shell says TERM<$TERM>"' -X'echo TERM<$TERM>' \
568 -Xx > "${MBOX}" 2>&1
569 check behave:s_freeze-6 0 "${MBOX}" '1211476036 167'
571 ${cat} <<- '__EOT' > "${BODY}"
572 !echo "shell says TERM<$TERM>"
573 echo TERM<$TERM>
574 !echo "shell says TERM<$TERM>"
575 set TERM=cherry
576 !echo "shell says TERM<$TERM>"
577 echo TERM<$TERM>
578 !echo "shell says TERM<$TERM>"
579 __EOT
580 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u \
581 -STERM=strawberry -SnoTERM \
582 -X'echo TERM<$TERM>' -X'set TERM=vanilla' \
583 -X'!echo "shell says TERM<$TERM>"' -X'echo TERM<$TERM>' \
584 -Xx > "${MBOX}" 2>&1
585 check behave:s_freeze-7 0 "${MBOX}" '3365080441 132'
588 TERM=$oterm
589 t_epilog
592 t_behave_wysh() {
593 t_prolog t_behave_wysh
595 ${cat} <<- '__EOT' > "${BODY}"
597 echo abcd
598 echo a'b'c'd'
599 echo a"b"c"d"
600 echo a$'b'c$'d'
601 echo 'abcd'
602 echo "abcd"
603 echo $'abcd'
604 echo a\ b\ c\ d
605 echo a 'b c' d
606 echo a "b c" d
607 echo a $'b c' d
609 echo 'a$`"\'
610 echo "a\$\`'\"\\"
611 echo $'a\$`\'\"\\'
612 echo $'a\$`\'"\\'
613 # DIET=CURD TIED=
614 echo 'a${DIET}b${TIED}c\${DIET}d\${TIED}e' # COMMENT
615 echo "a${DIET}b${TIED}c\${DIET}d\${TIED}e"
616 echo $'a${DIET}b${TIED}c\${DIET}d\${TIED}e'
618 echo a$'\101\0101\x41\u0041\u41\U00000041\U41'c
619 echo a$'\u0041\u41\u0C1\U00000041\U41'c
620 echo a$'\377'c
621 echo a$'\0377'c
622 echo a$'\400'c
623 echo a$'\0400'c
624 echo a$'\U1100001'c
626 echo a$'b\0c'd
627 echo a$'b\00c'de
628 echo a$'b\000c'df
629 echo a$'b\0000c'dg
630 echo a$'b\x0c'dh
631 echo a$'b\x00c'di
632 echo a$'b\u0'dj
633 echo a$'b\u00'dk
634 echo a$'b\u000'dl
635 echo a$'b\u0000'dm
636 echo a$'b\U0'dn
637 echo a$'b\U00'do
638 echo a$'b\U000'dp
639 echo a$'b\U0000'dq
640 echo a$'b\U00000'dr
641 echo a$'b\U000000'ds
642 echo a$'b\U0000000'dt
643 echo a$'b\U00000000'du
645 echo a$'\cI'b
646 echo a$'\011'b
647 echo a$'\x9'b
648 echo a$'\u9'b
649 echo a$'\U9'b
650 echo a$'\c@'b c d
651 __EOT
653 if [ -z "${UTF8_LOCALE}" ]; then
654 echo 'Skip behave:wysh_unicode, no UTF8_LOCALE'
655 else
656 < "${BODY}" DIET=CURD TIED= \
657 LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} 2>/dev/null > "${MBOX}"
658 check behave:wysh_unicode 0 "${MBOX}" '475805847 317'
661 < "${BODY}" DIET=CURD TIED= ${MAILX} ${ARGS} > "${MBOX}" 2>/dev/null
662 check behave:wysh_c 0 "${MBOX}" '1473887148 321'
664 t_epilog
667 t_behave_input_inject_semicolon_seq() {
668 t_prolog t_behave_input_inject_semicolon_seq
670 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
671 define mydeepmac {
672 echon '(mydeepmac)';
674 define mymac {
675 echon this_is_mymac;call mydeepmac;echon ';';
677 echon one';';call mymac;echon two";";call mymac;echo three$';';
678 define mymac {
679 echon this_is_mymac;call mydeepmac;echon ,TOO'!;';
681 echon one';';call mymac;echon two";";call mymac;echo three$';';
682 __EOT
684 check behave:input_inject_semicolon_seq 0 "${MBOX}" '512117110 140'
686 t_epilog
689 t_behave_commandalias() {
690 t_prolog t_behave_commandalias
692 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
693 commandalias echo echo hoho
694 echo stop.
695 commandalias X Xx
696 commandalias Xx XxX
697 commandalias XxX XxXx
698 commandalias XxXx XxXxX
699 commandalias XxXxX XxXxXx
700 commandalias XxXxXx echo huhu
701 commandalias XxXxXxX echo huhu
703 commandalias XxXxXx XxXxXxX
705 uncommandalias echo
706 commandalias XxXxXx echo huhu
708 __EOT
710 check behave:commandalias 0 "${MBOX}" '3694143612 31'
712 t_epilog
715 t_behave_ifelse() {
716 t_prolog t_behave_ifelse
718 # Nestable conditions test
719 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
720 if 0
721 echo 1.err
722 else
723 echo 1.ok
724 endif
725 if 1
726 echo 2.ok
727 else
728 echo 2.err
729 endif
730 if $dietcurd
731 echo 3.err
732 else
733 echo 3.ok
734 endif
735 set dietcurd=yoho
736 if $dietcurd
737 echo 4.ok
738 else
739 echo 4.err
740 endif
741 if $dietcurd == 'yoho'
742 echo 5.ok
743 else
744 echo 5.err
745 endif
746 if $dietcurd @== 'Yoho'
747 echo 5-1.ok
748 else
749 echo 5-1.err
750 endif
751 if $dietcurd == 'Yoho'
752 echo 5-2.err
753 else
754 echo 5-2.ok
755 endif
756 if $dietcurd != 'yoho'
757 echo 6.err
758 else
759 echo 6.ok
760 endif
761 if $dietcurd @!= 'Yoho'
762 echo 6-1.err
763 else
764 echo 6-1.ok
765 endif
766 if $dietcurd != 'Yoho'
767 echo 6-2.ok
768 else
769 echo 6-2.err
770 endif
771 # Nesting
772 if faLse
773 echo 7.err1
774 if tRue
775 echo 7.err2
776 if yEs
777 echo 7.err3
778 else
779 echo 7.err4
780 endif
781 echo 7.err5
782 endif
783 echo 7.err6
784 else
785 echo 7.ok7
786 if YeS
787 echo 7.ok8
788 if No
789 echo 7.err9
790 else
791 echo 7.ok9
792 endif
793 echo 7.ok10
794 else
795 echo 7.err11
796 if yeS
797 echo 7.err12
798 else
799 echo 7.err13
800 endif
801 endif
802 echo 7.ok14
803 endif
804 if r
805 echo 8.ok1
806 if R
807 echo 8.ok2
808 else
809 echo 8.err2
810 endif
811 echo 8.ok3
812 else
813 echo 8.err1
814 endif
815 if s
816 echo 9.err1
817 else
818 echo 9.ok1
819 if S
820 echo 9.err2
821 else
822 echo 9.ok2
823 endif
824 echo 9.ok3
825 endif
826 # `elif'
827 if $dietcurd == 'yohu'
828 echo 10.err1
829 elif $dietcurd == 'yoha'
830 echo 10.err2
831 elif $dietcurd == 'yohe'
832 echo 10.err3
833 elif $dietcurd == 'yoho'
834 echo 10.ok1
835 if $dietcurd == 'yohu'
836 echo 10.err4
837 elif $dietcurd == 'yoha'
838 echo 10.err5
839 elif $dietcurd == 'yohe'
840 echo 10.err6
841 elif $dietcurd == 'yoho'
842 echo 10.ok2
843 if $dietcurd == 'yohu'
844 echo 10.err7
845 elif $dietcurd == 'yoha'
846 echo 10.err8
847 elif $dietcurd == 'yohe'
848 echo 10.err9
849 elif $dietcurd == 'yoho'
850 echo 10.ok3
851 else
852 echo 10.err10
853 endif
854 else
855 echo 10.err11
856 endif
857 else
858 echo 10.err12
859 endif
860 # integer
861 set dietcurd=10
862 if $dietcurd -lt 11
863 echo 11.ok1
864 if $dietcurd -gt 9
865 echo 11.ok2
866 else
867 echo 11.err2
868 endif
869 if $dietcurd -eq 10
870 echo 11.ok3
871 else
872 echo 11.err3
873 endif
874 if $dietcurd -ge 10
875 echo 11.ok4
876 else
877 echo 11.err4
878 endif
879 if $dietcurd -le 10
880 echo 11.ok5
881 else
882 echo 11.err5
883 endif
884 if $dietcurd -ge 11
885 echo 11.err6
886 else
887 echo 11.ok6
888 endif
889 if $dietcurd -le 9
890 echo 11.err7
891 else
892 echo 11.ok7
893 endif
894 else
895 echo 11.err1
896 endif
897 set dietcurd=Abc
898 if $dietcurd < aBd
899 echo 12.ok1
900 if $dietcurd @> abB
901 echo 12.ok2
902 else
903 echo 12.err2
904 endif
905 if $dietcurd @== aBC
906 echo 12.ok3
907 else
908 echo 12.err3
909 endif
910 if $dietcurd @>= AbC
911 echo 12.ok4
912 else
913 echo 12.err4
914 endif
915 if $dietcurd @<= ABc
916 echo 12.ok5
917 else
918 echo 12.err5
919 endif
920 if $dietcurd @>= abd
921 echo 12.err6
922 else
923 echo 12.ok6
924 endif
925 if $dietcurd @<= abb
926 echo 12.err7
927 else
928 echo 12.ok7
929 endif
930 else
931 echo 12.err1
932 endif
933 if $dietcurd < aBc
934 echo 12-1.ok
935 else
936 echo 12-1.err
937 endif
938 if $dietcurd @< aBc
939 echo 12-2.err
940 else
941 echo 12-2.ok
942 endif
943 if $dietcurd > ABc
944 echo 12-3.ok
945 else
946 echo 12-3.err
947 endif
948 if $dietcurd @> ABc
949 echo 12-3.err
950 else
951 echo 12-3.ok
952 endif
953 if $dietcurd @i=% aB
954 echo 13.ok
955 else
956 echo 13.err
957 endif
958 if $dietcurd =% aB
959 echo 13-1.err
960 else
961 echo 13-1.ok
962 endif
963 if $dietcurd @=% bC
964 echo 14.ok
965 else
966 echo 14.err
967 endif
968 if $dietcurd !% aB
969 echo 15-1.ok
970 else
971 echo 15-1.err
972 endif
973 if $dietcurd @!% aB
974 echo 15-2.err
975 else
976 echo 15-2.ok
977 endif
978 if $dietcurd !% bC
979 echo 15-3.ok
980 else
981 echo 15-3.err
982 endif
983 if $dietcurd @!% bC
984 echo 15-4.err
985 else
986 echo 15-4.ok
987 endif
988 if $dietcurd =% Cd
989 echo 16.err
990 else
991 echo 16.ok
992 endif
993 if $dietcurd !% Cd
994 echo 17.ok
995 else
996 echo 17.err
997 endif
998 set diet=abc curd=abc
999 if $diet == $curd
1000 echo 18.ok
1001 else
1002 echo 18.err
1003 endif
1004 set diet=abc curd=abcd
1005 if $diet != $curd
1006 echo 19.ok
1007 else
1008 echo 19.err
1009 endif
1010 # 1. Shitty grouping capabilities as of today
1011 unset diet curd ndefined
1012 if [ [ false ] || [ false ] || [ true ] ] && [ [ false ] || [ true ] ] && \
1013 [ yes ]
1014 echo 20.ok
1015 else
1016 echo 20.err
1017 endif
1018 if [ [ [ [ 0 ] || [ 1 ] ] && [ [ 1 ] || [ 0 ] ] ] && [ 1 ] ] && [ yes ]
1019 echo 21.ok
1020 else
1021 echo 21.err
1022 endif
1023 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] ]
1024 echo 22.ok
1025 else
1026 echo 22.err
1027 endif
1028 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] ]
1029 echo 23.ok
1030 else
1031 echo 23.err
1032 endif
1033 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] && [ no ]
1034 echo 24.err
1035 else
1036 echo 24.ok
1037 endif
1038 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] \
1039 && [ no ] || [ yes ]
1040 echo 25.ok
1041 else
1042 echo 25.err
1043 endif
1044 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
1045 echo 26.ok
1046 else
1047 echo 26.err
1048 endif
1049 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 0 ] ]
1050 echo 27.err
1051 else
1052 echo 27.ok
1053 endif
1054 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 0 ] ] && [ 1 ] ] ] && [ 1 ] ]
1055 echo 28.err
1056 else
1057 echo 28.ok
1058 endif
1059 if [ [ [ [ [ [ [ 0 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
1060 echo 29.err
1061 else
1062 echo 29.ok
1063 endif
1064 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 0 ]
1065 echo 30.err
1066 else
1067 echo 30.ok
1068 endif
1069 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 1 ]
1070 echo 31.ok
1071 else
1072 echo 31.err
1073 endif
1074 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ]
1075 echo 32.err
1076 else
1077 echo 32.ok
1078 endif
1079 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 1 ]
1080 echo 33.ok
1081 else
1082 echo 33.err
1083 endif
1084 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 0 ]
1085 echo 34.err
1086 else
1087 echo 34.ok
1088 endif
1089 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 1 ]
1090 echo 35.ok
1091 else
1092 echo 35.err
1093 endif
1094 set diet=yo curd=ho
1095 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
1096 echo 36.err
1097 else
1098 echo 36.ok
1099 endif
1100 set ndefined
1101 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
1102 echo 37.ok
1103 else
1104 echo 37.err
1105 endif
1106 # 2. Shitty grouping capabilities as of today
1107 unset diet curd ndefined
1108 if [ false || false || true ] && [ false || true ] && yes
1109 echo 40.ok
1110 else
1111 echo 40.err
1112 endif
1113 if [ [ [ 0 || 1 ] && [ 1 || 0 ] ] && 1 ] && [ yes ]
1114 echo 41.ok
1115 else
1116 echo 41.err
1117 endif
1118 if [ 1 || 0 || 0 || 0 ]
1119 echo 42.ok
1120 else
1121 echo 42.err
1122 endif
1123 if [ 1 || 0 || 0 || 0 || [ 1 ] ]
1124 echo 43.ok
1125 else
1126 echo 43.err
1127 endif
1128 if [ 1 || 0 || 0 || 0 || [ 1 ] || 1 ] && no
1129 echo 44.err
1130 else
1131 echo 44.ok
1132 endif
1133 if [ 1 || 0 || 0 || 0 || 1 || [ 1 ] ] && no || [ yes ]
1134 echo 45.ok
1135 else
1136 echo 45.err
1137 endif
1138 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && 1 ] ] && [ 1 ] ]
1139 echo 46.ok
1140 else
1141 echo 46.err
1142 endif
1143 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && [ 1 ] ] ] && 0 ]
1144 echo 47.err
1145 else
1146 echo 47.ok
1147 endif
1148 if [ [ [ [ [ [ [ 1 ] ] && 1 ] && 0 ] && [ 1 ] ] ] && 1 ]
1149 echo 48.err
1150 else
1151 echo 48.ok
1152 endif
1153 if [ [ [ [ [ [ 0 ] && 1 ] && 1 ] && 1 ] ] && 1 ]
1154 echo 49.err
1155 else
1156 echo 49.ok
1157 endif
1158 if 1 || 0 || 0 || 0 && 0
1159 echo 50.err
1160 else
1161 echo 50.ok
1162 endif
1163 if 1 || 0 || 0 || 0 && 1
1164 echo 51.ok
1165 else
1166 echo 51.err
1167 endif
1168 if 0 || 0 || 0 || 1 && 0
1169 echo 52.err
1170 else
1171 echo 52.ok
1172 endif
1173 if 0 || 0 || 0 || 1 && 1
1174 echo 53.ok
1175 else
1176 echo 53.err
1177 endif
1178 if 0 || 0 || 0 || 1 && 0 || 1 && 0
1179 echo 54.err
1180 else
1181 echo 54.ok
1182 endif
1183 if 0 || 0 || 0 || 1 && 0 || 1 && 1
1184 echo 55.ok
1185 else
1186 echo 55.err
1187 endif
1188 set diet=yo curd=ho
1189 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
1190 echo 56.err
1191 else
1192 echo 56.ok
1193 endif
1194 if $diet == 'yo' && $curd == 'ho' && $ndefined
1195 echo 57.err
1196 else
1197 echo 57.ok
1198 endif
1199 set ndefined
1200 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
1201 echo 57.ok
1202 else
1203 echo 57.err
1204 endif
1205 if $diet == 'yo' && $curd == 'ho' && $ndefined
1206 echo 58.ok
1207 else
1208 echo 58.err
1209 endif
1210 if [ [ [ [ [ [ $diet == 'yo' && $curd == 'ho' && $ndefined ] ] ] ] ] ]
1211 echo 59.ok
1212 else
1213 echo 59.err
1214 endif
1215 # Some more en-braced variables
1216 set diet=yo curd=ho
1217 if ${diet} == ${curd}
1218 echo 70.err
1219 else
1220 echo 70.ok
1221 endif
1222 if ${diet} != ${curd}
1223 echo 71.ok
1224 else
1225 echo 71.err
1226 endif
1227 if $diet == ${curd}
1228 echo 72.err
1229 else
1230 echo 72.ok
1231 endif
1232 if ${diet} == $curd
1233 echo 73.err
1234 else
1235 echo 73.ok
1236 endif
1237 # Unary !
1238 if ! 0 && ! ! 1 && ! ! ! ! 2 && 3
1239 echo 80.ok
1240 else
1241 echo 80.err
1242 endif
1243 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ ! 2 ] ] ] && 3
1244 echo 81.ok
1245 else
1246 echo 81.err
1247 endif
1248 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1249 echo 82.ok
1250 else
1251 echo 82.err
1252 endif
1253 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
1254 echo 83.err
1255 else
1256 echo 83.ok
1257 endif
1258 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
1259 echo 84.err
1260 else
1261 echo 84.ok
1262 endif
1263 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1264 echo 85.err
1265 else
1266 echo 85.ok
1267 endif
1268 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1269 echo 86.err
1270 else
1271 echo 86.ok
1272 endif
1273 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] || 3
1274 echo 87.ok
1275 else
1276 echo 87.err
1277 endif
1278 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! ! [ 2 ] ] ] ] ]
1279 echo 88.ok
1280 else
1281 echo 88.err
1282 endif
1283 # Unary !, odd
1284 if ! 0 && ! ! 1 && ! ! ! 0 && 3
1285 echo 90.ok
1286 else
1287 echo 90.err
1288 endif
1289 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ 0 ] ] ] && 3
1290 echo 91.ok
1291 else
1292 echo 91.err
1293 endif
1294 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ [ 0 ] ] ] ] ] && 3
1295 echo 92.ok
1296 else
1297 echo 92.err
1298 endif
1299 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! ! [ ! [ ! 0 ] ] ] ] && ! 3
1300 echo 93.err
1301 else
1302 echo 93.ok
1303 endif
1304 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ ! [ ! [ ! [ ! 0 ] ] ] ] && 3
1305 echo 94.ok
1306 else
1307 echo 94.err
1308 endif
1309 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! ! [ ! [ ! [ ! [ 0 ] ] ] ] ] && 3
1310 echo 95.err
1311 else
1312 echo 95.ok
1313 endif
1314 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! ! 0 ] ] ] ] && 3
1315 echo 96.err
1316 else
1317 echo 96.ok
1318 endif
1319 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ ! 0 ] ] ] ] ] || 3
1320 echo 97.ok
1321 else
1322 echo 97.err
1323 endif
1324 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! [ 0 ] ] ] ] ]
1325 echo 98.ok
1326 else
1327 echo 98.err
1328 endif
1329 __EOT
1331 check behave:if-normal 0 "${MBOX}" '1688759742 719'
1333 if have_feat regex; then
1334 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
1335 set dietcurd=yoho
1336 if $dietcurd =~ '^yo.*'
1337 echo 1.ok
1338 else
1339 echo 1.err
1340 endif
1341 if $dietcurd =~ '^Yo.*'
1342 echo 1-1.err
1343 else
1344 echo 1-1.ok
1345 endif
1346 if $dietcurd @=~ '^Yo.*'
1347 echo 1-2.ok
1348 else
1349 echo 1-2.err
1350 endif
1351 if $dietcurd =~ '^yOho.+'
1352 echo 2.err
1353 else
1354 echo 2.ok
1355 endif
1356 if $dietcurd @!~ '.*Ho$'
1357 echo 3.err
1358 else
1359 echo 3.ok
1360 endif
1361 if $dietcurd !~ '.+yohO$'
1362 echo 4.ok
1363 else
1364 echo 4.err
1365 endif
1366 if [ $dietcurd @i!~ '.+yoho$' ]
1367 echo 5.ok
1368 else
1369 echo 5.err
1370 endif
1371 if ! [ $dietcurd @i=~ '.+yoho$' ]
1372 echo 6.ok
1373 else
1374 echo 6.err
1375 endif
1376 if ! ! [ $dietcurd @i!~ '.+yoho$' ]
1377 echo 7.ok
1378 else
1379 echo 7.err
1380 endif
1381 if ! [ ! [ $dietcurd @i!~ '.+yoho$' ] ]
1382 echo 8.ok
1383 else
1384 echo 8.err
1385 endif
1386 if [ ! [ ! [ $dietcurd @i!~ '.+yoho$' ] ] ]
1387 echo 9.ok
1388 else
1389 echo 9.err
1390 endif
1391 if ! [ ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
1392 echo 10.err
1393 else
1394 echo 10.ok
1395 endif
1396 if ! ! ! $dietcurd !~ '.+yoho$'
1397 echo 11.err
1398 else
1399 echo 11.ok
1400 endif
1401 if ! ! ! $dietcurd =~ '.+yoho$'
1402 echo 12.ok
1403 else
1404 echo 12.err
1405 endif
1406 if ! [ ! ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
1407 echo 13.ok
1408 else
1409 echo 13.err
1410 endif
1411 set diet=abc curd='^abc$'
1412 if $diet =~ $curd
1413 echo 14.ok
1414 else
1415 echo 14.err
1416 endif
1417 set diet=abc curd='^abcd$'
1418 if $diet !~ $curd
1419 echo 15.ok
1420 else
1421 echo 15.err
1422 endif
1423 __EOT
1425 check behave:if-regex 0 "${MBOX}" '1115671789 95'
1426 else
1427 printf 'behave:if-regex: unsupported, skipped\n'
1430 t_epilog
1433 t_behave_localopts() {
1434 t_prolog t_behave_localopts
1436 # Nestable conditions test
1437 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
1438 define t2 {
1439 echo in: t2
1440 set t2=t2
1441 echo $t2
1443 define t1 {
1444 echo in: t1
1445 set gv1=gv1
1446 localopts on
1447 set lv1=lv1 lv2=lv2
1448 set lv3=lv3
1449 call t2
1450 localopts off
1451 set gv2=gv2
1452 echo $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2
1454 define t0 {
1455 echo in: t0
1456 call t1
1457 echo $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2
1458 echo "$gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2"
1460 account trouble {
1461 echo in: trouble
1462 call t0
1464 call t0
1465 unset gv1 gv2
1466 account trouble
1467 echo active trouble: $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t3
1468 account null
1469 echo active null: $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t3
1472 define ll2 {
1473 localopts $1
1474 set x=2
1475 echo ll2=$x
1477 define ll1 {
1478 wysh set y=$1; shift; eval localopts $y; localopts $1; shift
1479 set x=1
1480 echo ll1.1=$x
1481 call ll2 $1
1482 echo ll1.2=$x
1484 define ll0 {
1485 wysh set y=$1; shift; eval localopts $y; localopts $1; shift
1486 set x=0
1487 echo ll0.1=$x
1488 call ll1 $y "$@"
1489 echo ll0.2=$x
1491 define llx {
1492 echo ----- $1: $2 -> $3 -> $4
1493 echo ll-1.1=$x
1494 eval localopts $1
1495 call ll0 "$@"
1496 echo ll-1.2=$x
1497 unset x
1499 define lly {
1500 call llx 'call off' on on on
1501 call llx 'call off' off on on
1502 call llx 'call off' on off on
1503 call llx 'call off' on off off
1504 localopts call-fixate on
1505 call llx 'call-fixate on' on on on
1506 call llx 'call-fixate on' off on on
1507 call llx 'call-fixate on' on off on
1508 call llx 'call-fixate on' on off off
1509 unset x;localopts call on
1510 call llx 'call on' on on on
1511 call llx 'call on' off on on
1512 call llx 'call on' on off on
1513 call llx 'call on' on off off
1515 call lly
1516 __EOT
1518 check behave:localopts 0 "${MBOX}" '4016155249 1246'
1520 t_epilog
1523 t_behave_macro_param_shift() {
1524 t_prolog t_behave_macro_param_shift
1526 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>/dev/null
1527 define t2 {
1528 echo in: t2
1529 echo t2.0 has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1530 localopts on
1531 wysh set ignerr=$1
1532 shift
1533 localopts off
1534 echo t2.1 has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1535 if [ $# > 1 ] || [ $ignerr == '' ]
1536 shift 2
1537 else
1538 ignerr shift 2
1539 endif
1540 echo t2.2:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1541 shift 0
1542 echo t2.3:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1543 if [ $# > 0 ]
1544 shift
1545 endif
1546 echo t2.4:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1548 define t1 {
1549 set errexit
1550 echo in: t1
1551 call t2 1 you get four args
1552 echo t1.1: $?';' ignerr ($ignerr) should not exist
1553 call t2 1 you get 'three args'
1554 echo t1.2: $?';' ignerr ($ignerr) should not exist
1555 call t2 1 you 'get two args'
1556 echo t1.3: $?';' ignerr ($ignerr) should not exist
1557 call t2 1 'you get one arg'
1558 echo t1.4: $?';' ignerr ($ignerr) should not exist
1559 ignerr call t2 '' 'you get one arg'
1560 echo t1.5: $?';' ignerr ($ignerr) should not exist
1562 call t1
1563 __EOT
1565 check behave:macro_param_shift 0 "${MBOX}" '1402489146 1682'
1567 t_epilog
1570 t_behave_addrcodec() {
1571 t_prolog t_behave_addrcodec
1573 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
1574 vput addrcodec res e 1 <doog@def>
1575 echo $?/$^ERRNAME $res
1576 eval vput addrcodec res d $res
1577 echo $?/$^ERRNAME $res
1578 vput addrcodec res e 2 . <doog@def>
1579 echo $?/$^ERRNAME $res
1580 eval vput addrcodec res d $res
1581 echo $?/$^ERRNAME $res
1582 vput addrcodec res e 3 Sauer Dr. <doog@def>
1583 echo $?/$^ERRNAME $res
1584 eval vput addrcodec res d $res
1585 echo $?/$^ERRNAME $res
1586 vput addrcodec res e 3.50 Sauer (Ma) Dr. <doog@def>
1587 echo $?/$^ERRNAME $res
1588 eval vput addrcodec res d $res
1589 echo $?/$^ERRNAME $res
1590 vput addrcodec res e 3.51 Sauer (Ma) "Dr." <doog@def>
1591 echo $?/$^ERRNAME $res
1592 eval vput addrcodec res d $res
1593 echo $?/$^ERRNAME $res
1595 vput addrcodec res +e 4 Sauer (Ma) Dr. <doog@def>
1596 echo $?/$^ERRNAME $res
1597 eval vput addrcodec res d $res
1598 echo $?/$^ERRNAME $res
1599 vput addrcodec res +e 5 Sauer (Ma) Braten Dr. <doog@def>
1600 echo $?/$^ERRNAME $res
1601 eval vput addrcodec res d $res
1602 echo $?/$^ERRNAME $res
1603 vput addrcodec res +e 6 Sauer (Ma) Braten Dr. (Heu) <doog@def>
1604 echo $?/$^ERRNAME $res
1605 eval vput addrcodec res d $res
1606 echo $?/$^ERRNAME $res
1607 vput addrcodec res +e 7 Sauer (Ma) Braten Dr. (Heu) <doog@def> (bu)
1608 echo $?/$^ERRNAME $res
1609 eval vput addrcodec res d $res
1610 echo $?/$^ERRNAME $res
1611 vput addrcodec res +e 8 \
1612 Dr. Sauer (Ma) Braten Dr. (Heu) <doog@def> (bu) Boom. Boom
1613 echo $?/$^ERRNAME $res
1614 eval vput addrcodec res d $res
1615 echo $?/$^ERRNAME $res
1616 vput addrcodec res +e 9 Dr.Sauer(Ma)Braten Dr. (Heu) <doog@def>
1617 echo $?/$^ERRNAME $res
1618 eval vput addrcodec res d $res
1619 echo $?/$^ERRNAME $res
1620 vput addrcodec res +e 10 (Ma)Braten Dr. (Heu) <doog@def>
1621 echo $?/$^ERRNAME $res
1622 eval vput addrcodec res d $res
1623 echo $?/$^ERRNAME $res
1624 vput addrcodec res +e 11 (Ma)Braten Dr"." (Heu) <doog@def>
1625 echo $?/$^ERRNAME $res
1626 eval vput addrcodec res d $res
1627 echo $?/$^ERRNAME $res
1628 vput addrcodec res +e 12 Dr. Sauer (Ma) Braten Dr. (u) <doog@def>
1629 echo $?/$^ERRNAME $res
1630 eval vput addrcodec res d $res
1631 echo $?/$^ERRNAME $res
1632 vput addrcodec res +e 13(Ma)Braten Dr. (Heu) <doog@def>
1633 echo $?/$^ERRNAME $res
1634 eval vput addrcodec res d $res
1635 echo $?/$^ERRNAME $res
1636 vput addrcodec res +e 14 Hey, Du <doog@def> Wie() findet Dr. das? ()
1637 echo $?/$^ERRNAME $res
1638 eval vput addrcodec res d $res
1639 echo $?/$^ERRNAME $res
1640 vput addrcodec res +e 15 \
1641 Hey, Du <doog@def> Wie() findet "" Dr. "" das? ()
1642 echo $?/$^ERRNAME $res
1643 eval vput addrcodec res d $res
1644 echo $?/$^ERRNAME $res
1645 vput addrcodec res +e 16 \
1646 "Hey," "Du" <doog@def> "Wie()" findet "" Dr. "" das? ()
1647 echo $?/$^ERRNAME $res
1648 eval vput addrcodec res d $res
1649 echo $?/$^ERRNAME $res
1650 vput addrcodec res +e 17 \
1651 "Hey" Du <doog@def> "Wie() findet " " Dr. """ das? ()
1652 echo $?/$^ERRNAME $res
1653 eval vput addrcodec res d $res
1654 echo $?/$^ERRNAME $res
1655 vput addrcodec res +e 18 \
1656 <doog@def> "Hey" Du "Wie() findet " " Dr. """ das? ()
1657 echo $?/$^ERRNAME $res
1658 eval vput addrcodec res d $res
1659 echo $?/$^ERRNAME $res
1660 vput addrcodec res +e 19 Hey\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1661 echo $?/$^ERRNAME $res
1662 eval vput addrcodec res d $res
1663 echo $?/$^ERRNAME $res
1665 vput addrcodec res ++e 20 Hey\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1666 echo $?/$^ERRNAME $res
1667 vput addrcodec res ++e 21 Hey\,\"" <doog@def> "Wie()" findet \" Dr. \" das?
1668 echo $?/$^ERRNAME $res
1669 eval vput addrcodec res d $res
1670 echo $?/$^ERRNAME $res
1672 vput addrcodec res +++e 22 Hey\\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1673 echo $?/$^ERRNAME $res
1674 eval vput addrcodec res d $res
1675 echo $?/$^ERRNAME $res
1677 vput addrcodec res s \
1678 "23 Hey\\,\\\" \"Wie" () "\" findet \\\" Dr. \\\" das?" <doog@def>
1679 echo $?/$^ERRNAME $res
1680 __EOT
1682 check behave:addrcodec-1 0 "${MBOX}" '429099645 2414'
1684 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
1685 mlist isa1@list
1686 mlsubscribe isa2@list
1688 vput addrcodec res skin Hey\\,\" <isa0@list> "Wie()" find \" Dr. \" das?
1689 echo $?/$^ERRNAME $res
1690 vput addrcodec res skinlist Hey\\,\" <isa0@list> "Wie()" find \" Dr. \" das?
1691 echo $?/$^ERRNAME $res
1692 vput addrcodec res skin Hey\\,\" <isa1@list> "Wie()" find \" Dr. \" das?
1693 echo $?/$^ERRNAME $res
1694 vput addrcodec res skinlist Hey\\,\" <isa1@list> "Wie()" find \" Dr. \" das?
1695 echo $?/$^ERRNAME $res
1696 vput addrcodec res skin Hey\\,\" <isa2@list> "Wie()" find \" Dr. \" das?
1697 echo $?/$^ERRNAME $res
1698 vput addrcodec res skinlist Hey\\,\" <isa2@list> "Wie()" find \" Dr. \" das?
1699 echo $?/$^ERRNAME $res
1700 __EOT
1702 check behave:addrcodec-2 0 "${MBOX}" '1391779299 104'
1704 t_epilog
1707 t_behave_vexpr() {
1708 t_prolog t_behave_vexpr
1710 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>/dev/null
1711 vput vexpr res = 9223372036854775807
1712 echo $?/$^ERRNAME $res
1713 vput vexpr res = 9223372036854775808
1714 echo $?/$^ERRNAME $res
1715 vput vexpr res =@ 9223372036854775808
1716 echo $?/$^ERRNAME $res
1717 vput vexpr res = -9223372036854775808
1718 echo $?/$^ERRNAME $res
1719 vput vexpr res = -9223372036854775809
1720 echo $?/$^ERRNAME $res
1721 vput vexpr res =@ -9223372036854775809
1722 echo $?/$^ERRNAME $res
1723 echo ' #1'
1724 vput vexpr res ~ 0
1725 echo $?/$^ERRNAME $res
1726 vput vexpr res ~ 1
1727 echo $?/$^ERRNAME $res
1728 vput vexpr res ~ -1
1729 echo $?/$^ERRNAME $res
1730 echo ' #2'
1731 vput vexpr res + 0 0
1732 echo $?/$^ERRNAME $res
1733 vput vexpr res + 0 1
1734 echo $?/$^ERRNAME $res
1735 vput vexpr res + 1 1
1736 echo $?/$^ERRNAME $res
1737 echo ' #3'
1738 vput vexpr res + 9223372036854775807 0
1739 echo $?/$^ERRNAME $res
1740 vput vexpr res + 9223372036854775807 1
1741 echo $?/$^ERRNAME $res
1742 vput vexpr res +@ 9223372036854775807 1
1743 echo $?/$^ERRNAME $res
1744 vput vexpr res + 0 9223372036854775807
1745 echo $?/$^ERRNAME $res
1746 vput vexpr res + 1 9223372036854775807
1747 echo $?/$^ERRNAME $res
1748 vput vexpr res +@ 1 9223372036854775807
1749 echo $?/$^ERRNAME $res
1750 echo ' #4'
1751 vput vexpr res + -9223372036854775808 0
1752 echo $?/$^ERRNAME $res
1753 vput vexpr res + -9223372036854775808 -1
1754 echo $?/$^ERRNAME $res
1755 vput vexpr res +@ -9223372036854775808 -1
1756 echo $?/$^ERRNAME $res
1757 vput vexpr res + 0 -9223372036854775808
1758 echo $?/$^ERRNAME $res
1759 vput vexpr res + -1 -9223372036854775808
1760 echo $?/$^ERRNAME $res
1761 vput vexpr res +@ -1 -9223372036854775808
1762 echo $?/$^ERRNAME $res
1763 echo ' #5'
1764 vput vexpr res - 0 0
1765 echo $?/$^ERRNAME $res
1766 vput vexpr res - 0 1
1767 echo $?/$^ERRNAME $res
1768 vput vexpr res - 1 1
1769 echo $?/$^ERRNAME $res
1770 echo ' #6'
1771 vput vexpr res - 9223372036854775807 0
1772 echo $?/$^ERRNAME $res
1773 vput vexpr res - 9223372036854775807 -1
1774 echo $?/$^ERRNAME $res
1775 vput vexpr res -@ 9223372036854775807 -1
1776 echo $?/$^ERRNAME $res
1777 vput vexpr res - 0 9223372036854775807
1778 echo $?/$^ERRNAME $res
1779 vput vexpr res - -1 9223372036854775807
1780 echo $?/$^ERRNAME $res
1781 vput vexpr res - -2 9223372036854775807
1782 echo $?/$^ERRNAME $res
1783 vput vexpr res -@ -2 9223372036854775807
1784 echo $?/$^ERRNAME $res
1785 echo ' #7'
1786 vput vexpr res - -9223372036854775808 +0
1787 echo $?/$^ERRNAME $res
1788 vput vexpr res - -9223372036854775808 +1
1789 echo $?/$^ERRNAME $res
1790 vput vexpr res -@ -9223372036854775808 +1
1791 echo $?/$^ERRNAME $res
1792 vput vexpr res - 0 -9223372036854775808
1793 echo $?/$^ERRNAME $res
1794 vput vexpr res - +1 -9223372036854775808
1795 echo $?/$^ERRNAME $res
1796 vput vexpr res -@ +1 -9223372036854775808
1797 echo $?/$^ERRNAME $res
1798 echo ' #8'
1799 vput vexpr res + -13 -2
1800 echo $?/$^ERRNAME $res
1801 vput vexpr res - 0 0
1802 echo $?/$^ERRNAME $res
1803 vput vexpr res - 0 1
1804 echo $?/$^ERRNAME $res
1805 vput vexpr res - 1 1
1806 echo $?/$^ERRNAME $res
1807 vput vexpr res - -13 -2
1808 echo $?/$^ERRNAME $res
1809 echo ' #9'
1810 vput vexpr res * 0 0
1811 echo $?/$^ERRNAME $res
1812 vput vexpr res * 0 1
1813 echo $?/$^ERRNAME $res
1814 vput vexpr res * 1 1
1815 echo $?/$^ERRNAME $res
1816 vput vexpr res * -13 -2
1817 echo $?/$^ERRNAME $res
1818 echo ' #10'
1819 vput vexpr res / 0 0
1820 echo $?/$^ERRNAME $res
1821 vput vexpr res / 0 1
1822 echo $?/$^ERRNAME $res
1823 vput vexpr res / 1 1
1824 echo $?/$^ERRNAME $res
1825 vput vexpr res / -13 -2
1826 echo $?/$^ERRNAME $res
1827 echo ' #11'
1828 vput vexpr res % 0 0
1829 echo $?/$^ERRNAME $res
1830 vput vexpr res % 0 1
1831 echo $?/$^ERRNAME $res
1832 vput vexpr res % 1 1
1833 echo $?/$^ERRNAME $res
1834 vput vexpr res % -13 -2
1835 echo $?/$^ERRNAME $res
1836 __EOT
1838 check behave:vexpr-numeric 0 "${MBOX}" '1723609217 1048'
1840 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" #2>/dev/null
1841 vput vexpr res find 'bananarama' 'nana'
1842 echo $?/$^ERRNAME :$res:
1843 vput vexpr res find 'bananarama' 'bana'
1844 echo $?/$^ERRNAME :$res:
1845 vput vexpr res find 'bananarama' 'Bana'
1846 echo $?/$^ERRNAME :$res:
1847 vput vexpr res find 'bananarama' 'rama'
1848 echo $?/$^ERRNAME :$res:
1849 echo ' #1'
1850 vput vexpr res ifind 'bananarama' 'nana'
1851 echo $?/$^ERRNAME :$res:
1852 vput vexpr res ifind 'bananarama' 'bana'
1853 echo $?/$^ERRNAME :$res:
1854 vput vexpr res ifind 'bananarama' 'Bana'
1855 echo $?/$^ERRNAME :$res:
1856 vput vexpr res ifind 'bananarama' 'rama'
1857 echo $?/$^ERRNAME :$res:
1858 echo ' #2'
1859 vput vexpr res substring 'bananarama' 1
1860 echo $?/$^ERRNAME :$res:
1861 vput vexpr res substring 'bananarama' 3
1862 echo $?/$^ERRNAME :$res:
1863 vput vexpr res substring 'bananarama' 5
1864 echo $?/$^ERRNAME :$res:
1865 vput vexpr res substring 'bananarama' 7
1866 echo $?/$^ERRNAME :$res:
1867 vput vexpr res substring 'bananarama' 9
1868 echo $?/$^ERRNAME :$res:
1869 vput vexpr res substring 'bananarama' 10
1870 echo $?/$^ERRNAME :$res:
1871 vput vexpr res substring 'bananarama' 1 3
1872 echo $?/$^ERRNAME :$res:
1873 vput vexpr res substring 'bananarama' 3 3
1874 echo $?/$^ERRNAME :$res:
1875 vput vexpr res substring 'bananarama' 5 3
1876 echo $?/$^ERRNAME :$res:
1877 vput vexpr res substring 'bananarama' 7 3
1878 echo $?/$^ERRNAME :$res:
1879 vput vexpr res substring 'bananarama' 9 3
1880 echo $?/$^ERRNAME :$res:
1881 vput vexpr res substring 'bananarama' 10 3
1882 echo $?/$^ERRNAME :$res:
1883 echo ' #3'
1884 vput vexpr res substring 'bananarama' -1
1885 echo $?/$^ERRNAME :$res:
1886 vput vexpr res substring 'bananarama' -3
1887 echo $?/$^ERRNAME :$res:
1888 vput vexpr res substring 'bananarama' -5
1889 echo $?/$^ERRNAME :$res:
1890 vput vexpr res substring 'bananarama' -7
1891 echo $?/$^ERRNAME :$res:
1892 vput vexpr res substring 'bananarama' -9
1893 echo $?/$^ERRNAME :$res:
1894 vput vexpr res substring 'bananarama' -10
1895 echo $?/$^ERRNAME :$res:
1896 vput vexpr res substring 'bananarama' 1 -3
1897 echo $?/$^ERRNAME :$res:
1898 vput vexpr res substring 'bananarama' 3 -3
1899 echo $?/$^ERRNAME :$res:
1900 vput vexpr res substring 'bananarama' 5 -3
1901 echo $?/$^ERRNAME :$res:
1902 vput vexpr res substring 'bananarama' 7 -3
1903 echo $?/$^ERRNAME :$res:
1904 vput vexpr res substring 'bananarama' 9 -3
1905 echo $?/$^ERRNAME :$res:
1906 vput vexpr res substring 'bananarama' 10 -3
1907 echo $?/$^ERRNAME :$res:
1908 echo ' #4'
1909 vput vexpr res trim 'Cocoon Cocoon'
1910 echo $?/$^ERRNAME :$res:
1911 vput vexpr res trim ' Cocoon Cocoon '
1912 echo $?/$^ERRNAME :$res:
1913 vput vexpr res trim-front 'Cocoon Cocoon'
1914 echo $?/$^ERRNAME :$res:
1915 vput vexpr res trim-front ' Cocoon Cocoon '
1916 echo $?/$^ERRNAME :$res:
1917 vput vexpr res trim-end 'Cocoon Cocoon'
1918 echo $?/$^ERRNAME :$res:
1919 vput vexpr res trim-end ' Cocoon Cocoon '
1920 echo $?/$^ERRNAME :$res:
1921 __EOT
1923 check behave:vexpr-string 0 "${MBOX}" '3182004322 601'
1925 if have_feat regex; then
1926 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" #2>/dev/null
1927 vput vexpr res regex 'bananarama' 'nana'
1928 echo $?/$^ERRNAME :$res:
1929 vput vexpr res regex 'bananarama' 'bana'
1930 echo $?/$^ERRNAME :$res:
1931 vput vexpr res regex 'bananarama' 'Bana'
1932 echo $?/$^ERRNAME :$res:
1933 vput vexpr res regex 'bananarama' 'rama'
1934 echo $?/$^ERRNAME :$res:
1935 echo ' #1'
1936 vput vexpr res iregex 'bananarama' 'nana'
1937 echo $?/$^ERRNAME :$res:
1938 vput vexpr res iregex 'bananarama' 'bana'
1939 echo $?/$^ERRNAME :$res:
1940 vput vexpr res iregex 'bananarama' 'Bana'
1941 echo $?/$^ERRNAME :$res:
1942 vput vexpr res iregex 'bananarama' 'rama'
1943 echo $?/$^ERRNAME :$res:
1944 echo ' #2'
1945 vput vexpr res regex 'bananarama' '(.*)nana(.*)' '\${1}a\${0}u{\$2}'
1946 echo $?/$^ERRNAME :$res:
1947 vput vexpr res regex 'bananarama' '(.*)bana(.*)' '\${1}a\${0}u\$2'
1948 echo $?/$^ERRNAME :$res:
1949 vput vexpr res regex 'bananarama' 'Bana(.+)' '\$1\$0'
1950 echo $?/$^ERRNAME :$res:
1951 vput vexpr res regex 'bananarama' '(.+)rama' '\$1\$0'
1952 echo $?/$^ERRNAME :$res:
1953 echo ' #3'
1954 vput vexpr res iregex 'bananarama' '(.*)nana(.*)' '\${1}a\${0}u{\$2}'
1955 echo $?/$^ERRNAME :$res:
1956 vput vexpr res iregex 'bananarama' '(.*)bana(.*)' '\${1}a\${0}u\$2'
1957 echo $?/$^ERRNAME :$res:
1958 vput vexpr res iregex 'bananarama' 'Bana(.+)' '\$1\$0'
1959 echo $?/$^ERRNAME :$res:
1960 vput vexpr res iregex 'bananarama' '(.+)rama' '\$1\$0'
1961 echo $?/$^ERRNAME :$res:
1962 echo ' #4'
1963 __EOT
1965 check behave:vexpr-regex 0 "${MBOX}" '3270360157 311'
1966 else
1967 printf 'behave:vexpr-regex: unsupported, skipped\n'
1970 t_epilog
1973 t_behave_call_ret() {
1974 t_prolog t_behave_call_ret
1976 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Snomemdebug > "${MBOX}" 2>&1
1977 define w1 {
1978 echon ">$1 "
1979 vput vexpr i + $1 1
1980 if [ $i -le 42 ]
1981 vput vexpr j '&' $i 7
1982 if [ $j -eq 7 ]
1983 echo .
1985 call w1 $i
1986 wysh set i=$? k=$!
1987 vput vexpr j '&' $i 7
1988 echon "<$1/$i/$k "
1989 if [ $j -eq 7 ]
1990 echo .
1992 else
1993 echo ! The end for $1
1995 return $1
1997 # Transport $?/$! up the call chain
1998 define w2 {
1999 echon ">$1 "
2000 vput vexpr i + $1 1
2001 if [ $1 -lt 42 ]
2002 call w2 $i
2003 wysh set i=$? j=$! k=$^ERRNAME
2004 echon "<$1/$i/$k "
2005 return $i $j
2006 else
2007 echo ! The end for $1
2008 return $i $^ERR-BUSY
2010 echoerr au
2012 # Up and down it goes
2013 define w3 {
2014 echon ">$1/$2 "
2015 vput vexpr i + $1 1
2016 if [ $1 -lt 42 ]
2017 call w3 $i $2
2018 wysh set i=$? j=$!
2019 vput vexpr k - $1 $2
2020 if [ $k -eq 21 ]
2021 vput vexpr i + $1 1
2022 vput vexpr j + $2 1
2023 echo "# <$i/$j> .. "
2024 call w3 $i $j
2025 wysh set i=$? j=$!
2027 eval echon "<\$1=\$i/\$^ERRNAME-$j "
2028 return $i $j
2029 else
2030 echo ! The end for $1=$i/$2
2031 if [ "$2" != "" ]
2032 return $i $^ERR-DOM
2033 else
2034 return $i $^ERR-BUSY
2037 echoerr au
2040 call w1 0; echo ?=$? !=$!; echo -----;
2041 call w2 0; echo ?=$? !=$^ERRNAME; echo -----;
2042 call w3 0 1; echo ?=$? !=$^ERRNAME; echo -----;
2043 __EOT
2045 check behave:call_ret 0 "${MBOX}" '1572045517 5922'
2047 t_epilog
2050 t_behave_xcall() {
2051 t_prolog t_behave_xcall
2053 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Snomemdebug > "${MBOX}" 2>&1
2054 define work {
2055 echon "$1 "
2056 vput vexpr i + $1 1
2057 if [ $i -le 1111 ]
2058 vput vexpr j '&' $i 7
2059 if [ $j -eq 7 ]
2060 echo .
2062 \xcall work $i $2
2064 echo ! The end for $1/$2
2065 if [ "$2" != "" ]
2066 return $i $^ERR-BUSY
2069 define xwork {
2070 \xcall work 0 $2
2072 call work 0
2073 echo ?=$? !=$!
2074 call xwork
2075 echo ?=$? !=$!
2076 xcall xwork
2077 echo ?=$? !=$^ERRNAME
2079 call work 0 yes
2080 echo ?=$? !=$^ERRNAME
2081 call xwork 0 yes
2082 echo ?=$? !=$^ERRNAME
2083 __EOT
2085 check behave:xcall-1 0 "${MBOX}" '2401702082 23801'
2089 ${cat} <<- '__EOT' > "${BODY}"
2090 define __w {
2091 echon "$1 "
2092 vput vexpr i + $1 1
2093 if [ $i -le 111 ]
2094 vput vexpr j '&' $i 7
2095 if [ $j -eq 7 ]
2096 echo .
2098 \xcall __w $i $2
2100 echo ! The end for $1
2101 if [ $2 -eq 0 ]
2102 nonexistingcommand
2103 echo would be err with errexit
2104 return
2106 echo calling exit
2107 exit
2109 define work {
2110 echo eins
2111 call __w 0 0
2112 echo zwei, ?=$? !=$!
2113 localopts yes; set errexit
2114 ignerr call __w 0 0
2115 echo drei, ?=$? !=$^ERRNAME
2116 call __w 0 $1
2117 echo vier, ?=$? !=$^ERRNAME, this is an error
2119 ignerr call work 0
2120 echo outer 1, ?=$? !=$^ERRNAME
2121 xxxign call work 0
2122 echo outer 2, ?=$? !=$^ERRNAME, could be error if xxxign non-empty
2123 call work 1
2124 echo outer 3, ?=$? !=$^ERRNAME
2125 echo this is definitely an error
2126 __EOT
2128 < "${BODY}" ${MAILX} ${ARGS} -X'commandalias xxxign ignerr' -Snomemdebug \
2129 > "${MBOX}" 2>&1
2130 check behave:xcall-2 0 "${MBOX}" '3900716531 4200'
2132 < "${BODY}" ${MAILX} ${ARGS} -X'commandalias xxxign " "' -Snomemdebug \
2133 > "${MBOX}" 2>&1
2134 check behave:xcall-3 1 "${MBOX}" '1006776201 2799'
2136 t_epilog
2139 t_behave_vpospar() {
2140 t_prolog t_behave_vpospar
2142 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
2143 vpospar set hey, "'you ", world!
2144 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2145 vput vpospar x quote; echo x<$x>
2146 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2147 vput vpospar y quote;echo y<$y>
2148 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2149 eval vpospar set ${y};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2150 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2152 define infun2 {
2153 echo infun2:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2154 vput vpospar z quote;echo infun2:z<$z>
2157 define infun {
2158 echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2159 vput vpospar y quote;echo infun:y<$y>
2160 eval vpospar set ${x};echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2161 vpospar clear;echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2162 eval call infun2 $x
2163 echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2164 eval vpospar set ${y};echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
2167 call infun This "in a" fun
2168 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2169 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2170 __EOT
2171 check behave:vpospar-1 0 "${MBOX}" '155175639 866'
2174 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
2175 set ifs=\'
2176 echo ifs<$ifs> ifs-ws<$ifs-ws>
2177 vpospar set hey, "'you ", world!
2178 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2179 vput vpospar x quote; echo x<$x>
2180 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2181 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2183 set ifs=,
2184 echo ifs<$ifs> ifs-ws<$ifs-ws>
2185 vpospar set hey, "'you ", world!
2186 unset ifs;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2187 set ifs=,
2188 vput vpospar x quote; echo x<$x>
2189 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2190 eval vpospar set ${x};\
2191 unset ifs;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2193 wysh set ifs=$',\t'
2194 echo ifs<$ifs> ifs-ws<$ifs-ws>
2195 vpospar set hey, "'you ", world!
2196 unset ifs; echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2197 wysh set ifs=$',\t'
2198 vput vpospar x quote; echo x<$x>
2199 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2200 eval vpospar set ${x};\
2201 unset ifs;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2202 __EOT
2203 check behave:vpospar-ifs 0 "${MBOX}" '2015927702 706'
2205 t_epilog
2208 t_behave_atxplode() {
2209 t_prolog t_behave_atxplode
2210 TRAP_EXIT_ADDONS="./.t*"
2212 ${cat} > ./.t.sh <<- '___'; ${cat} > ./.t.rc <<- '___'
2213 x() { echo $#; }
2214 xxx() {
2215 printf " (1/$#: <$1>)"
2216 shift
2217 if [ $# -gt 0 ]; then
2218 xxx "$@"
2219 else
2220 echo
2223 yyy() {
2224 eval "$@ ' ball"
2226 set --
2227 x "$@"
2228 x "$@"''
2229 x " $@"
2230 x "$@ "
2231 printf yyy;yyy 'xxx' "b\$'\t'u ' "
2232 printf xxx;xxx arg ,b u.
2233 printf xxx;xxx arg , .
2234 printf xxx;xxx arg ,ball.
2236 define x {
2237 echo $#
2239 define xxx {
2240 echon " (1/$#: <$1>)"
2241 shift
2242 if [ $# -gt 0 ]
2243 \xcall xxx "$@"
2244 endif
2245 echo
2247 define yyy {
2248 eval "$@ ' ball"
2250 vpospar set
2251 call x "$@"
2252 call x "$@"''
2253 call x " $@"
2254 call x "$@ "
2255 echon yyy;call yyy '\call xxx' "b\$'\t'u ' "
2256 echon xxx;call xxx arg ,b u.
2257 echon xxx;call xxx arg , .
2258 echon xxx;call xxx arg ,ball.
2261 ${MAILX} ${ARGS} -X'source ./.t.rc' -Xx > "${MBOX}" 2>&1
2262 check behave:atxplode-1 0 "${MBOX}" '41566293 164'
2264 #${SHELL} ./.t.sh > ./.tshout 2>&1
2265 #check behave:atxplode:disproof-1 0 ./.tshout '41566293 164'
2267 t_epilog
2270 t_behave_read() {
2271 t_prolog t_behave_read
2272 TRAP_EXIT_ADDONS="./.t*"
2274 ${cat} <<- '__EOT' > .tin
2275 hey1, "'you ", world!
2276 hey2, "'you ", bugs bunny!
2277 hey3, "'you ",
2278 hey4, "'you "
2279 __EOT
2281 ${cat} <<- '__EOT' |\
2282 ${MAILX} ${ARGS} -X'readctl create ./.tin' > "${MBOX}" 2>&1
2283 read a b c
2284 echo $?/$^ERRNAME / <$a><$b><$c>
2285 read a b c
2286 echo $?/$^ERRNAME / <$a><$b><$c>
2287 read a b c
2288 echo $?/$^ERRNAME / <$a><$b><$c>
2289 read a b c
2290 echo $?/$^ERRNAME / <$a><$b><$c>
2291 unset a b c;read a b c
2292 echo $?/$^ERRNAME / <$a><$b><$c>
2293 readctl remove ./.tin;echo readctl remove:$?/$^ERRNAME
2294 __EOT
2295 check behave:read-1 0 "${MBOX}" '1527910147 173'
2297 ${cat} <<- '__EOT' > .tin2
2298 hey2.0,:"'you ",:world!:mars.:
2299 hey2.1,:"'you ",:world!
2300 hey2.2,:"'you ",:bugs bunny!
2301 hey2.3,:"'you ",:
2302 hey2.4,:"'you ":
2304 __EOT
2306 ${cat} <<- '__EOT' |\
2307 6< .tin2 ${MAILX} ${ARGS} -X 'readctl create 6' > "${MBOX}" 2>&1
2308 set ifs=:
2309 read a b c
2310 echo $?/$^ERRNAME / <$a><$b><$c>
2311 read a b c
2312 echo $?/$^ERRNAME / <$a><$b><$c>
2313 read a b c
2314 echo $?/$^ERRNAME / <$a><$b><$c>
2315 read a b c
2316 echo $?/$^ERRNAME / <$a><$b><$c>
2317 read a b c
2318 echo $?/$^ERRNAME / <$a><$b><$c>
2319 read a b c
2320 echo $?/$^ERRNAME / <$a><$b><$c>
2321 unset a b c;read a b c
2322 echo $?/$^ERRNAME / <$a><$b><$c>
2323 read a b c
2324 echo $?/$^ERRNAME / <$a><$b><$c>
2325 readctl remove 6;echo readctl remove:$?/$^ERRNAME
2326 __EOT
2327 check behave:read-ifs 0 "${MBOX}" '890153490 298'
2329 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
2330 readctl create .tin
2331 readall d; echo $?/$^ERRNAME / <$d>
2332 wysh set d;readall d;echo $?/$^ERRNAME / <$d>
2333 readctl create .tin2
2334 readall d; echo $?/$^ERRNAME / <$d>
2335 wysh set d;readall d;echo $?/$^ERRNAME / <$d>
2336 readctl remove .tin;echo $?/$^ERRNAME;\
2337 readctl remove .tin2;echo $?/$^ERRNAME
2338 __EOT
2339 check behave:readall 0 "${MBOX}" '860434889 333'
2341 t_epilog
2344 t_behave_mbox() {
2345 t_prolog t_behave_mbox
2346 TRAP_EXIT_ADDONS="./.t*"
2350 while [ ${i} -lt 112 ]; do
2351 printf 'm file://%s\n~s Subject %s\nHello %s!\n~.\n' \
2352 "${MBOX}" "${i}" "${i}"
2353 i=`add ${i} 1`
2354 done
2355 ) | ${MAILX} ${ARGS}
2356 check behave:mbox-1 0 "${MBOX}" '1140119864 13780'
2358 printf 'File "%s"\ncopy * "%s"\nFile "%s"\nfrom*' "${MBOX}" .tmbox1 .tmbox1 |
2359 ${MAILX} ${ARGS} > .tlst
2360 check behave:mbox-2 0 .tlst '2739893312 9103'
2362 printf 'File "%s"\ncopy * "file://%s"\nFile "file://%s"\nfrom*' \
2363 "${MBOX}" .tmbox2 .tmbox2 | ${MAILX} ${ARGS} > .tlst
2364 check behave:mbox-3 0 .tlst '1702194178 9110'
2366 # only the odd (even)
2368 printf 'File "file://%s"\ncopy ' .tmbox2
2370 while [ ${i} -lt 112 ]; do
2371 j=`modulo ${i} 2`
2372 [ ${j} -eq 1 ] && printf '%s ' "${i}"
2373 i=`add ${i} 1`
2374 done
2375 printf 'file://%s\nFile "file://%s"\nfrom*' .tmbox3 .tmbox3
2376 ) | ${MAILX} ${ARGS} > .tlst
2377 check behave:mbox-4 0 .tmbox3 '631132924 6890'
2378 check behave:mbox-5 - .tlst '2960975049 4573'
2379 # ...
2381 printf 'file "file://%s"\nmove ' .tmbox2
2383 while [ ${i} -lt 112 ]; do
2384 j=`modulo ${i} 2`
2385 [ ${j} -eq 0 ] && [ ${i} -ne 0 ] && printf '%s ' "${i}"
2386 i=`add ${i} 1`
2387 done
2388 printf 'file://%s\nFile "file://%s"\nfrom*\nFile "file://%s"\nfrom*' \
2389 .tmbox3 .tmbox3 .tmbox2
2390 ) | ${MAILX} ${ARGS} > .tlst
2391 check behave:mbox-6 0 .tmbox3 '1387070539 13655'
2392 ${sed} 2d < .tlst > .tlstx
2393 check behave:mbox-7 - .tlstx '2729940494 13645'
2395 t_epilog
2398 t_behave_alternates() {
2399 t_prolog t_behave_alternates
2400 TRAP_EXIT_ADDONS="./.t*"
2402 ${cat} <<-_EOT > ./.tsendmail.sh
2403 #!${SHELL} -
2404 (echo 'From Valeriana Sat Jul 08 15:54:03 2017' && ${cat} && echo
2405 ) >> "${MBOX}"
2406 _EOT
2407 chmod 0755 ./.tsendmail.sh
2409 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Smta=./.tsendmail.sh > ./.tall 2>&1
2410 echo --0
2411 alternates
2412 echo $?/$^ERRNAME
2413 alternates a1@b1 a2@b2 a3@b3
2414 echo $?/$^ERRNAME
2415 alternates
2416 echo $?/$^ERRNAME
2417 vput alternates rv
2418 echo $?/$^ERRNAME <$rv>
2420 echo --1
2421 unalternates a2@b2
2422 vput alternates rv
2423 echo $?/$^ERRNAME <$rv>
2424 unalternates a3@b3
2425 vput alternates rv
2426 echo $?/$^ERRNAME <$rv>
2427 unalternates a1@b1
2428 vput alternates rv
2429 echo $?/$^ERRNAME <$rv>
2431 echo --2
2432 unalternates *
2433 alternates a1@b1 a2@b2 a3@b3
2434 unalternates a3@b3
2435 vput alternates rv
2436 echo $?/$^ERRNAME <$rv>
2437 unalternates a2@b2
2438 vput alternates rv
2439 echo $?/$^ERRNAME <$rv>
2440 unalternates a1@b1
2441 vput alternates rv
2442 echo $?/$^ERRNAME <$rv>
2444 echo --3
2445 alternates a1@b1 a2@b2 a3@b3
2446 unalternates a1@b1
2447 vput alternates rv
2448 echo $?/$^ERRNAME <$rv>
2449 unalternates a2@b2
2450 vput alternates rv
2451 echo $?/$^ERRNAME <$rv>
2452 unalternates a3@b3
2453 vput alternates rv
2454 echo $?/$^ERRNAME <$rv>
2456 echo --4
2457 unalternates *
2458 alternates a1@b1 a2@b2 a3@b3
2459 unalternates *
2460 vput alternates rv
2461 echo $?/$^ERRNAME <$rv>
2463 echo --5
2464 unalternates *
2465 alternates a1@b1 a1@c1 a1@d1 a2@b2 a3@b3 a3@c3 a3@d3
2466 m a1@b1 a1@c1 a1@d1
2467 ~s all alternates, only a1@b1 remains
2468 ~c a2@b2
2469 ~b a3@b3 a3@c3 a3@d3
2470 ~r - '_EOT'
2471 This body is!
2472 This also body is!!
2473 _EOT
2476 echo --6
2477 unalternates *
2478 alternates a1@b1 a1@c1 a2@b2 a3@b3
2479 m a1@b1 a1@c1 a1@d1
2480 ~s a1@b1 a1@d1, and a3@c3 a3@d3 remain
2481 ~c a2@b2
2482 ~b a3@b3 a3@c3 a3@d3
2483 ~r - '_EOT'
2484 This body2 is!
2485 _EOT
2488 echo --7
2489 alternates a1@b1 a2@b2 a3; set allnet
2490 m a1@b1 a1@c1 a1@d1
2491 ~s all alternates via allnet, only a1@b1 remains
2492 ~c a2@b2
2493 ~b a3@b3 a3@c3 a3@d3
2494 ~r - '_EOT'
2495 This body3 is!
2496 _EOT
2499 echo --10
2500 unalternates *
2501 alternates a1@b1
2502 echo $?/$^ERRNAME
2503 vput alternates rv
2504 echo $?/$^ERRNAME <$rv>
2505 alternates a2@b2
2506 echo $?/$^ERRNAME
2507 vput alternates rv
2508 echo $?/$^ERRNAME <$rv>
2509 alternates a3@b3
2510 echo $?/$^ERRNAME
2511 vput alternates rv
2512 echo $?/$^ERRNAME <$rv>
2513 alternates a4@b4
2514 echo $?/$^ERRNAME
2515 vput alternates rv
2516 echo $?/$^ERRNAME <$rv>
2518 unalternates *
2519 vput alternates rv
2520 echo $?/$^ERRNAME <$rv>
2522 echo --11
2523 set posix
2524 alternates a1@b1 a2@b2
2525 echo $?/$^ERRNAME
2526 vput alternates rv
2527 echo $?/$^ERRNAME <$rv>
2528 alternates a3@b3 a4@b4
2529 echo $?/$^ERRNAME
2530 vput alternates rv
2531 echo $?/$^ERRNAME <$rv>
2532 __EOT
2533 check behave:alternates-1 0 "${MBOX}" '142184864 515'
2534 check behave:alternates-2 - .tall '1878598364 505'
2536 t_epilog
2539 t_behave_alias() {
2540 t_prolog t_behave_alias
2541 TRAP_EXIT_ADDONS="./.t*"
2543 ${cat} <<-_EOT > ./.tsendmail.sh
2544 #!${SHELL} -
2545 (echo 'From Hippocastanum Mon Jun 19 15:07:07 2017' && ${cat} && echo
2546 ) >> "${MBOX}"
2547 _EOT
2548 chmod 0755 ./.tsendmail.sh
2550 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Smta=./.tsendmail.sh > ./.tall 2>&1
2551 alias a1 ex1@a1.ple
2552 alias a1 ex2@a1.ple "EX3 <ex3@a1.ple>"
2553 alias a1 ex4@a1.ple
2554 alias a2 ex1@a2.ple ex2@a2.ple ex3@a2.ple ex4@a2.ple
2555 alias a3 a4
2556 alias a4 a5 ex1@a4.ple
2557 alias a5 a6
2558 alias a6 a7 ex1@a6.ple
2559 alias a7 a8
2560 alias a8 ex1@a8.ple
2561 alias a1
2562 alias a2
2563 alias a3
2564 m a1
2565 ~c a2
2566 ~b a3
2567 ~r - '_EOT'
2568 This body is!
2569 This also body is!!
2570 _EOT
2571 __EOT
2572 check behave:alias-1 0 "${MBOX}" '2496925843 272'
2573 check behave:alias-2 - .tall '3548953204 152'
2575 # TODO t_behave_alias: n_ALIAS_MAXEXP is compile-time constant,
2576 # TODO need to somehow provide its contents to the test, then test
2578 t_epilog
2581 t_behave_filetype() {
2582 t_prolog t_behave_filetype
2583 TRAP_EXIT_ADDONS="./.t*"
2585 ${cat} <<-_EOT > ./.tsendmail.sh
2586 #!${SHELL} -
2587 (echo 'From Alchemilla Wed Apr 25 15:12:13 2017' && ${cat} && echo
2588 ) >> "${MBOX}"
2589 _EOT
2590 chmod 0755 ./.tsendmail.sh
2592 printf 'm m1@e.t\nL1\nHy1\n~.\nm m2@e.t\nL2\nHy2\n~@ %s\n~.\n' \
2593 "${SRCDIR}snailmail.jpg" | ${MAILX} ${ARGS} -Smta=./.tsendmail.sh
2594 check behave:filetype-1 0 "${MBOX}" '1594682963 13520'
2596 if (echo | gzip -c) >/dev/null 2>&1; then
2597 ${rm} -f ./.t.mbox*
2599 printf 'File "%s"\ncopy 1 ./.t.mbox.gz\ncopy 2 ./.t.mbox.gz' \
2600 "${MBOX}" | ${MAILX} ${ARGS} \
2601 -X'filetype gz gzip\ -dc gzip\ -c'
2602 printf 'File ./.t.mbox.gz\ncopy * ./.t.mbox\n' |
2603 ${MAILX} ${ARGS} -X'filetype gz gzip\ -dc gzip\ -c'
2604 } > ./.t.out 2>&1
2605 check behave:filetype-2 - "./.t.mbox" '1594682963 13520'
2606 check behave:filetype-3 - "./.t.out" '2494681730 102'
2607 else
2608 echo 'behave:filetype-2: unsupported, skipped'
2609 echo 'behave:filetype-3: unsupported, skipped'
2613 ${rm} -f ./.t.mbox*
2614 printf 'File "%s"\ncopy 1 ./.t.mbox.gz
2615 copy 2 ./.t.mbox.gz
2616 copy 1 ./.t.mbox.gz
2617 copy 2 ./.t.mbox.gz
2618 ' "${MBOX}" |
2619 ${MAILX} ${ARGS} \
2620 -X'filetype gz gzip\ -dc gzip\ -c' \
2621 -X'filetype mbox.gz "${sed} 1,3d|${cat}" \
2622 "echo eins;echo zwei;echo und mit ${sed} bist Du dabei;${cat}"'
2623 printf 'File ./.t.mbox.gz\ncopy * ./.t.mbox\n' |
2624 ${MAILX} ${ARGS} \
2625 -X'filetype gz gzip\ -dc gzip\ -c' \
2626 -X'filetype mbox.gz "${sed} 1,3d|${cat}" kill\ 0'
2627 } > ./.t.out 2>&1
2628 check behave:filetype-4 - "./.t.mbox" '2886541147 27060'
2629 check behave:filetype-5 - "./.t.out" '838452520 172'
2631 t_epilog
2634 t_behave_record_a_resend() {
2635 t_prolog t_behave_record_a_resend
2636 TRAP_EXIT_ADDONS="./.t.record ./.t.resent"
2638 printf '
2639 set record=%s
2640 m %s\n~s Subject 1.\nHello.\n~.
2641 set record-files add-file-recipients
2642 m %s\n~s Subject 2.\nHello.\n~.
2643 File %s
2644 resend 2 ./.t.resent
2645 Resend 1 ./.t.resent
2646 set record-resent
2647 resend 2 ./.t.resent
2648 Resend 1 ./.t.resent
2649 ' ./.t.record "${MBOX}" "${MBOX}" "${MBOX}" |
2650 ${MAILX} ${ARGS}
2652 check behave:record_a_resend-1 0 "${MBOX}" '3057873538 256'
2653 check behave:record_a_resend-2 - .t.record '391356429 460'
2654 check behave:record_a_resend-3 - .t.resent '2685231691 648'
2656 t_epilog
2659 t_behave_e_H_L_opts() {
2660 t_prolog t_behave_e_H_L_opts
2661 TRAP_EXIT_ADDONS="./.tsendmail.sh ./.t.mbox"
2663 touch ./.t.mbox
2664 ${MAILX} ${ARGS} -ef ./.t.mbox
2665 echo ${?} > "${MBOX}"
2667 ${cat} <<-_EOT > ./.tsendmail.sh
2668 #!${SHELL} -
2669 (echo 'From Alchemilla Wed Apr 07 17:03:33 2017' && ${cat} && echo
2670 ) >> "./.t.mbox"
2671 _EOT
2672 chmod 0755 ./.tsendmail.sh
2673 printf 'm me@exam.ple\nLine 1.\nHello.\n~.\n' |
2674 ${MAILX} ${ARGS} -Smta=./.tsendmail.sh
2675 printf 'm you@exam.ple\nLine 1.\nBye.\n~.\n' |
2676 ${MAILX} ${ARGS} -Smta=./.tsendmail.sh
2678 ${MAILX} ${ARGS} -ef ./.t.mbox
2679 echo ${?} >> "${MBOX}"
2680 ${MAILX} ${ARGS} -efL @t@me ./.t.mbox
2681 echo ${?} >> "${MBOX}"
2682 ${MAILX} ${ARGS} -efL @t@you ./.t.mbox
2683 echo ${?} >> "${MBOX}"
2684 ${MAILX} ${ARGS} -efL '@>@Line 1' ./.t.mbox
2685 echo ${?} >> "${MBOX}"
2686 ${MAILX} ${ARGS} -efL '@>@Hello.' ./.t.mbox
2687 echo ${?} >> "${MBOX}"
2688 ${MAILX} ${ARGS} -efL '@>@Bye.' ./.t.mbox
2689 echo ${?} >> "${MBOX}"
2690 ${MAILX} ${ARGS} -efL '@>@Good bye.' ./.t.mbox
2691 echo ${?} >> "${MBOX}"
2693 ${MAILX} ${ARGS} -fH ./.t.mbox >> "${MBOX}"
2694 echo ${?} >> "${MBOX}"
2695 ${MAILX} ${ARGS} -fL @t@me ./.t.mbox >> "${MBOX}"
2696 echo ${?} >> "${MBOX}"
2697 ${MAILX} ${ARGS} -fL @t@you ./.t.mbox >> "${MBOX}"
2698 echo ${?} >> "${MBOX}"
2699 ${MAILX} ${ARGS} -fL '@>@Line 1' ./.t.mbox >> "${MBOX}"
2700 echo ${?} >> "${MBOX}"
2701 ${MAILX} ${ARGS} -fL '@>@Hello.' ./.t.mbox >> "${MBOX}"
2702 echo ${?} >> "${MBOX}"
2703 ${MAILX} ${ARGS} -fL '@>@Bye.' ./.t.mbox >> "${MBOX}"
2704 echo ${?} >> "${MBOX}"
2705 ${MAILX} ${ARGS} -fL '@>@Good bye.' ./.t.mbox >> "${MBOX}" 2>/dev/null
2706 echo ${?} >> "${MBOX}"
2708 check behave:e_H_L_opts - "${MBOX}" '1708955574 678'
2710 t_epilog
2713 t_behave_compose_hooks() { # TODO monster
2714 t_prolog t_behave_compose_hooks
2715 TRAP_EXIT_ADDONS="./.t*"
2717 (echo line one&&echo line two&&echo line three) > ./.treadctl
2718 (echo echo four&&echo echo five&&echo echo six) > ./.tattach
2720 ${cat} <<-_EOT > ./.tsendmail.sh
2721 #!${SHELL} -
2722 (echo 'From PrimulaVeris Wed Apr 10 22:59:00 2017' && ${cat} && echo
2723 ) >> "${MBOX}"
2724 _EOT
2725 chmod 0755 ./.tsendmail.sh
2727 ${cat} <<'__EOT__' > ./.trc
2728 define bail {
2729 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
2731 define xerr {
2732 vput vexpr es substr "$1" 0 1
2733 if [ "$es" != 2 ]
2734 xcall bail "$2"
2737 define read_mline_res {
2738 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
2739 echo $len/$es/$^ERRNAME: $hl
2740 if [ $es -ne $^ERR-NONE ]
2741 xcall bail read_mline_res
2742 elif [ $len -ne 0 ]
2743 \xcall read_mline_res
2746 define ins_addr {
2747 wysh set xh=$1
2748 echo "~^header list"; read hl; echo $hl;\
2749 call xerr "$hl" "in_addr ($xh) 0-1"
2751 echo "~^header insert $xh diet <$xh@exam.ple> spliced";\
2752 read es; echo $es; call xerr "$es" "ins_addr $xh 1-1"
2753 echo "~^header insert $xh <${xh}2@exam.ple>";\
2754 read es; echo $es; call xerr "$es" "ins_addr $xh 1-2"
2755 echo "~^header insert $xh ${xh}3@exam.ple";\
2756 read es; echo $es; call xerr "$es" "ins_addr $xh 1-3"
2757 echo "~^header list $xh"; read hl; echo $hl;\
2758 call xerr "$hl" "ins_addr $xh 1-4"
2759 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 1-5"
2760 call read_mline_res
2762 if [ "$t_remove" == "" ]
2763 return
2766 echo "~^header remove $xh"; read es; call xerr $es "ins_addr $xh 2-1"
2767 echo "~^header remove $xh"; read es; vput vexpr es substr $es 0 3
2768 if [ $es != 501 ]
2769 xcall bail "ins_addr $xh 2-2"
2771 echo "~^header list $xh"; read es; vput vexpr es substr $es 0 3
2772 if [ $es != 501 ]
2773 xcall bail "ins_addr $xh 2-3"
2775 echo "~^header show $xh"; read es; vput vexpr es substr $es 0 3
2776 if [ $es != 501 ]
2777 xcall bail "ins_addr $xh 2-4"
2781 echo "~^header insert $xh diet <$xh@exam.ple> spliced";\
2782 read es; echo $es; call xerr "$es" "ins_addr $xh 3-1"
2783 echo "~^header insert $xh <${xh}2@exam.ple>";\
2784 read es; echo $es; call xerr "$es" "ins_addr $xh 3-2"
2785 echo "~^header insert $xh ${xh}3@exam.ple";\
2786 read es; echo $es; call xerr "$es" "ins_addr $xh 3-3"
2787 echo "~^header list $xh"; read hl; echo $hl;\
2788 call xerr "$hl" "ins_addr $xh 3-4"
2789 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 3-5"
2790 call read_mline_res
2792 echo "~^header remove-at $xh 1"; read es;\
2793 call xerr $es "ins_addr $xh 3-6"
2794 echo "~^header remove-at $xh 1"; read es;\
2795 call xerr $es "ins_addr $xh 3-7"
2796 echo "~^header remove-at $xh 1"; read es;\
2797 call xerr $es "ins_addr $xh 3-8"
2798 echo "~^header remove-at $xh 1"; read es;\
2799 vput vexpr es substr $es 0 3
2800 if [ $es != 501 ]
2801 xcall bail "ins_addr $xh 3-9"
2803 echo "~^header remove-at $xh T"; read es;\
2804 vput vexpr es substr $es 0 3
2805 if [ $es != 505 ]
2806 xcall bail "ins_addr $xh 3-10"
2808 echo "~^header list $xh"; read es;\
2809 vput vexpr es substr $es 0 3
2810 if [ $es != 501 ]
2811 xcall bail "ins_addr $xh 3-11"
2813 echo "~^header show $xh"; read es;\
2814 vput vexpr es substr $es 0 3
2815 if [ $es != 501 ]
2816 xcall bail "ins_addr $xh 3-12"
2820 echo "~^header insert $xh diet <$xh@exam.ple> spliced";\
2821 read es; echo $es; call xerr "$es" "ins_addr $xh 4-1"
2822 echo "~^header insert $xh <${xh}2@exam.ple> (comment) \"Quot(e)d\"";\
2823 read es; echo $es; call xerr "$es" "ins_addr $xh 4-2"
2824 echo "~^header insert $xh ${xh}3@exam.ple";\
2825 read es; echo $es; call xerr "$es" "ins_addr $xh 4-3"
2826 echo "~^header list $xh"; read hl; echo $hl;\
2827 call xerr "$hl" "header list $xh 3-4"
2828 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 4-5"
2829 call read_mline_res
2831 echo "~^header remove-at $xh 3"; read es;\
2832 call xerr $es "ins_addr $xh 4-6"
2833 echo "~^header remove-at $xh 2"; read es;\
2834 call xerr $es "ins_addr $xh 4-7"
2835 echo "~^header remove-at $xh 1"; read es;\
2836 call xerr $es "ins_addr $xh 4-8"
2837 echo "~^header remove-at $xh 1"; read es;\
2838 vput vexpr es substr $es 0 3
2839 if [ $es != 501 ]
2840 xcall bail "ins_addr $xh 4-9"
2842 echo "~^header remove-at $xh T"; read es;\
2843 vput vexpr es substr $es 0 3
2844 if [ $es != 505 ]
2845 xcall bail "ins_addr $xh 4-10"
2847 echo "~^header list $xh"; read es;\
2848 vput vexpr es substr $es 0 3
2849 if [ $es != 501 ]
2850 xcall bail "ins_addr $xh 4-11"
2852 echo "~^header show $xh"; read es;\
2853 vput vexpr es substr $es 0 3
2854 if [ $es != 501 ]
2855 xcall bail "ins_addr $xh 4-12"
2858 define ins_ref {
2859 wysh set xh=$1 mult=$2
2860 echo "~^header list"; read hl; echo $hl;\
2861 call xerr "$hl" "ins_ref ($xh) 0-1"
2863 echo "~^header insert $xh <$xh@exam.ple>";\
2864 read es; echo $es; call xerr "$es" "ins_ref $xh 1-1"
2865 if [ $mult -ne 0 ]
2866 echo "~^header insert $xh <${xh}2@exam.ple>";\
2867 read es; echo $es; call xerr "$es" "ins_ref $xh 1-2"
2868 echo "~^header insert $xh ${xh}3@exam.ple";\
2869 read es; echo $es; call xerr "$es" "ins_ref $xh 1-3"
2870 else
2871 echo "~^header insert $xh <${xh}2@exam.ple>"; read es;\
2872 vput vexpr es substr $es 0 3
2873 if [ $es != 506 ]
2874 xcall bail "ins_ref $xh 1-4"
2878 echo "~^header list $xh"; read hl; echo $hl;\
2879 call xerr "$hl" "ins_ref $xh 1-5"
2880 echo "~^header show $xh"; read es; call xerr $es "ins_ref $xh 1-6"
2881 call read_mline_res
2883 if [ "$t_remove" == "" ]
2884 return
2887 echo "~^header remove $xh"; read es;\
2888 call xerr $es "ins_ref $xh 2-1"
2889 echo "~^header remove $xh"; read es;\
2890 vput vexpr es substr $es 0 3
2891 if [ $es != 501 ]
2892 xcall bail "ins_ref $xh 2-2"
2894 echo "~^header list $xh"; read es;\
2895 vput vexpr es substr $es 0 3
2896 if [ $es != 501 ]
2897 xcall bail "$es ins_ref $xh 2-3"
2899 echo "~^header show $xh"; read es;\
2900 vput vexpr es substr $es 0 3
2901 if [ $es != 501 ]
2902 xcall bail "ins_ref $xh 2-4"
2906 echo "~^header insert $xh <$xh@exam.ple>";\
2907 read es; echo $es; call xerr "$es" "ins_ref $xh 3-1"
2908 if [ $mult -ne 0 ]
2909 echo "~^header insert $xh <${xh}2@exam.ple>";\
2910 read es; echo $es; call xerr "$es" "ins_ref $xh 3-2"
2911 echo "~^header insert $xh ${xh}3@exam.ple";\
2912 read es; echo $es; call xerr "$es" "ins_ref $xh 3-3"
2914 echo "~^header list $xh";\
2915 read hl; echo $hl; call xerr "$hl" "ins_ref $xh 3-4"
2916 echo "~^header show $xh";\
2917 read es; call xerr $es "ins_ref $xh 3-5"
2918 call read_mline_res
2920 echo "~^header remove-at $xh 1"; read es;\
2921 call xerr $es "ins_ref $xh 3-6"
2922 if [ $mult -ne 0 ] && [ $xh != subject ]
2923 echo "~^header remove-at $xh 1"; read es;\
2924 call xerr $es "ins_ref $xh 3-7"
2925 echo "~^header remove-at $xh 1"; read es;\
2926 call xerr $es "ins_ref $xh 3-8"
2928 echo "~^header remove-at $xh 1"; read es;\
2929 vput vexpr es substr $es 0 3
2930 if [ $es != 501 ]
2931 xcall bail "ins_ref $xh 3-9"
2933 echo "~^header remove-at $xh T"; read es;\
2934 vput vexpr es substr $es 0 3
2935 if [ $es != 505 ]
2936 xcall bail "ins_ref $xh 3-10"
2938 echo "~^header show $xh"; read es;\
2939 vput vexpr es substr $es 0 3
2940 if [ $es != 501 ]
2941 xcall bail "ins_ref $xh 3-11"
2945 echo "~^header insert $xh <$xh@exam.ple> ";\
2946 read es; echo $es; call xerr "$es" "ins_ref $xh 4-1"
2947 if [ $mult -ne 0 ]
2948 echo "~^header insert $xh <${xh}2@exam.ple> ";\
2949 read es; echo $es; call xerr "$es" "ins_ref $xh 4-2"
2950 echo "~^header insert $xh ${xh}3@exam.ple";\
2951 read es; echo $es; call xerr "$es" "ins_ref $xh 4-3"
2953 echo "~^header list $xh"; read hl; echo $hl;\
2954 call xerr "$hl" "ins_ref $xh 4-4"
2955 echo "~^header show $xh"; read es; call xerr $es "ins_ref $xh 4-5"
2956 call read_mline_res
2958 if [ $mult -ne 0 ] && [ $xh != subject ]
2959 echo "~^header remove-at $xh 3"; read es;\
2960 call xerr $es "ins_ref $xh 4-6"
2961 echo "~^header remove-at $xh 2"; read es;\
2962 call xerr $es "ins_ref $xh 4-7"
2964 echo "~^header remove-at $xh 1"; read es;\
2965 call xerr $es "ins_ref $xh 4-8"
2966 echo "~^header remove-at $xh 1"; read es;\
2967 vput vexpr es substr $es 0 3
2968 if [ $es != 501 ]
2969 xcall bail "ins_ref $xh 4-9"
2971 echo "~^header remove-at $xh T"; read es;\
2972 vput vexpr es substr $es 0 3
2973 if [ $es != 505 ]
2974 xcall bail "ins_ref $xh 4-10"
2976 echo "~^header show $xh"; read es;\
2977 vput vexpr es substr $es 0 3
2978 if [ $es != 501 ]
2979 xcall bail "ins_ref $xh 4-11"
2982 define t_header {
2983 echo t_header ENTER
2984 # In collect.c order
2985 call ins_addr from
2986 call ins_ref sender 0 # Not a "ref", but works
2987 call ins_addr To
2988 call ins_addr cC
2989 call ins_addr bCc
2990 call ins_addr reply-To
2991 call ins_addr mail-Followup-to
2992 call ins_ref messAge-id 0
2993 call ins_ref rEfErEncEs 1
2994 call ins_ref in-Reply-to 1
2995 call ins_ref subject 1 # Not a "ref", but works (with tweaks)
2996 call ins_addr freeForm1
2997 call ins_addr freeform2
2999 echo "~^header show MAILX-Command"; read es; call xerr $es "t_header 1000"
3000 call read_mline_res
3001 echo "~^header show MAILX-raw-TO"; read es; call xerr $es "t_header 1001"
3002 call read_mline_res
3004 echo t_header LEAVE
3006 define t_attach {
3007 echo t_attach ENTER
3009 echo "~^attachment";\
3010 read hl; echo $hl; vput vexpr es substr "$hl" 0 3
3011 if [ "$es" != 501 ]
3012 xcall bail "attach 0-1"
3015 echo "~^attach attribute ./.treadctl";\
3016 read hl; echo $hl; vput vexpr es substr "$hl" 0 3
3017 if [ "$es" != 501 ]
3018 xcall bail "attach 0-2"
3020 echo "~^attachment attribute-at 1";\
3021 read hl; echo $hl; vput vexpr es substr "$hl" 0 3
3022 if [ "$es" != 501 ]
3023 xcall bail "attach 0-3"
3026 echo "~^attachment insert ./.treadctl=ascii";\
3027 read hl; echo $hl; call xerr "$hl" "attach 1-1"
3028 echo "~^attachment list";\
3029 read es; echo $es;call xerr "$es" "attach 1-2"
3030 call read_mline_res
3031 echo "~^attachment attribute ./.treadctl";\
3032 read es; echo $es;call xerr "$es" "attach 1-3"
3033 call read_mline_res
3034 echo "~^attachment attribute .treadctl";\
3035 read es; echo $es;call xerr "$es" "attach 1-4"
3036 call read_mline_res
3037 echo "~^attachment attribute-at 1";\
3038 read es; echo $es;call xerr "$es" "attach 1-5"
3039 call read_mline_res
3041 echo "~^attachment attribute-set ./.treadctl filename rctl";\
3042 read es; echo $es;call xerr "$es" "attach 1-6"
3043 echo "~^attachment attribute-set .treadctl content-description Au";\
3044 read es; echo $es;call xerr "$es" "attach 1-7"
3045 echo "~^attachment attribute-set-at 1 content-id <10.du@ich>";\
3046 read es; echo $es;call xerr "$es" "attach 1-8"
3048 echo "~^attachment attribute ./.treadctl";\
3049 read es; echo $es;call xerr "$es" "attach 1-9"
3050 call read_mline_res
3051 echo "~^attachment attribute .treadctl";\
3052 read es; echo $es;call xerr "$es" "attach 1-10"
3053 call read_mline_res
3054 echo "~^attachment attribute rctl";\
3055 read es; echo $es;call xerr "$es" "attach 1-11"
3056 call read_mline_res
3057 echo "~^attachment attribute-at 1";\
3058 read es; echo $es;call xerr "$es" "attach 1-12"
3059 call read_mline_res
3062 echo "~^attachment insert ./.tattach=latin1";\
3063 read hl; echo $hl; call xerr "$hl" "attach 2-1"
3064 echo "~^attachment list";\
3065 read es; echo $es;call xerr "$es" "attach 2-2"
3066 call read_mline_res
3067 echo "~^attachment attribute ./.tattach";\
3068 read es; echo $es;call xerr "$es" "attach 2-3"
3069 call read_mline_res
3070 echo "~^attachment attribute .tattach";\
3071 read es; echo $es;call xerr "$es" "attach 2-4"
3072 call read_mline_res
3073 echo "~^attachment attribute-at 2";\
3074 read es; echo $es;call xerr "$es" "attach 2-5"
3075 call read_mline_res
3077 echo "~^attachment attribute-set ./.tattach filename tat";\
3078 read es; echo $es;call xerr "$es" "attach 2-6"
3079 echo \
3080 "~^attachment attribute-set .tattach content-description Au2";\
3081 read es; echo $es;call xerr "$es" "attach 2-7"
3082 echo "~^attachment attribute-set-at 2 content-id <20.du@wir>";\
3083 read es; echo $es;call xerr "$es" "attach 2-8"
3084 echo \
3085 "~^attachment attribute-set-at 2 content-type application/x-sh";\
3086 read es; echo $es;call xerr "$es" "attach 2-9"
3088 echo "~^attachment attribute ./.tattach";\
3089 read es; echo $es;call xerr "$es" "attach 2-10"
3090 call read_mline_res
3091 echo "~^attachment attribute .tattach";\
3092 read es; echo $es;call xerr "$es" "attach 2-11"
3093 call read_mline_res
3094 echo "~^attachment attribute tat";\
3095 read es; echo $es;call xerr "$es" "attach 2-12"
3096 call read_mline_res
3097 echo "~^attachment attribute-at 2";\
3098 read es; echo $es;call xerr "$es" "attach 2-13"
3099 call read_mline_res
3102 if [ "$t_remove" == "" ]
3103 return
3106 echo "~^attachment remove ./.treadctl"; read es;\
3107 call xerr $es "attach 3-1"
3108 echo "~^attachment remove ./.tattach"; read es;\
3109 call xerr $es "attach 3-2"
3110 echo "~^ attachment remove ./.treadctl"; read es;\
3111 vput vexpr es substr $es 0 3
3112 if [ $es != 501 ]
3113 xcall bail "attach 3-3"
3115 echo "~^ attachment remove ./.tattach"; read es;\
3116 vput vexpr es substr $es 0 3
3117 if [ $es != 501 ]
3118 xcall bail "attach 3-4"
3120 echo "~^attachment list"; read es;\
3121 vput vexpr es substr $es 0 3
3122 if [ $es != 501 ]
3123 xcall bail "attach 3-5"
3127 echo "~^attachment insert ./.tattach=latin1";\
3128 read hl; echo $hl; call xerr "$hl" "attach 4-1"
3129 echo "~^attachment insert ./.tattach=latin1";\
3130 read hl; echo $hl; call xerr "$hl" "attach 4-2"
3131 echo "~^attachment list";\
3132 read es; echo $es;call xerr "$es" "attach 4-3"
3133 call read_mline_res
3134 echo "~^ attachment remove .tattach"; read es;\
3135 vput vexpr es substr $es 0 3
3136 if [ $es != 506 ]
3137 xcall bail "attach 4-4 $es"
3139 echo "~^attachment remove-at T"; read es;\
3140 vput vexpr es substr $es 0 3
3141 if [ $es != 505 ]
3142 xcall bail "attach 4-5"
3144 echo "~^attachment remove ./.tattach"; read es;\
3145 call xerr $es "attach 4-6"
3146 echo "~^attachment remove ./.tattach"; read es;\
3147 call xerr $es "attach 4-7"
3148 echo "~^ attachment remove ./.tattach"; read es;\
3149 vput vexpr es substr $es 0 3
3150 if [ $es != 501 ]
3151 xcall bail "attach 4-8 $es"
3153 echo "~^attachment list"; read es;\
3154 vput vexpr es substr $es 0 3
3155 if [ $es != 501 ]
3156 xcall bail "attach 4-9"
3160 echo "~^attachment insert ./.tattach=latin1";\
3161 read hl; echo $hl; call xerr "$hl" "attach 5-1"
3162 echo "~^attachment insert ./.tattach=latin1";\
3163 read hl; echo $hl; call xerr "$hl" "attach 5-2"
3164 echo "~^attachment insert ./.tattach=latin1";\
3165 read hl; echo $hl; call xerr "$hl" "attach 5-3"
3166 echo "~^attachment list";\
3167 read es; echo $es;call xerr "$es" "attach 5-4"
3168 call read_mline_res
3170 echo "~^attachment remove-at 3"; read es;\
3171 call xerr $es "attach 5-5"
3172 echo "~^attachment remove-at 3"; read es;\
3173 vput vexpr es substr $es 0 3
3174 if [ $es != 501 ]
3175 xcall bail "attach 5-6"
3177 echo "~^attachment remove-at 2"; read es;\
3178 call xerr $es "attach 5-7"
3179 echo "~^attachment remove-at 2"; read es;\
3180 vput vexpr es substr $es 0 3
3181 if [ $es != 501 ]
3182 xcall bail "attach 5-8"
3184 echo "~^attachment remove-at 1"; read es;\
3185 call xerr $es "attach 5-9"
3186 echo "~^attachment remove-at 1"; read es;\
3187 vput vexpr es substr $es 0 3
3188 if [ $es != 501 ]
3189 xcall bail "attach 5-10"
3192 echo "~^attachment list"; read es;\
3193 vput vexpr es substr $es 0 3
3194 if [ $es != 501 ]
3195 xcall bail "attach 5-11"
3199 echo "~^attachment insert ./.tattach=latin1";\
3200 read hl; echo $hl; call xerr "$hl" "attach 6-1"
3201 echo "~^attachment insert ./.tattach=latin1";\
3202 read hl; echo $hl; call xerr "$hl" "attach 6-2"
3203 echo "~^attachment insert ./.tattach=latin1";\
3204 read hl; echo $hl; call xerr "$hl" "attach 6-3"
3205 echo "~^attachment list";\
3206 read es; echo $es;call xerr "$es" "attach 6-4"
3207 call read_mline_res
3209 echo "~^attachment remove-at 1"; read es;\
3210 call xerr $es "attach 6-5"
3211 echo "~^attachment remove-at 1"; read es;\
3212 call xerr $es "attach 6-6"
3213 echo "~^attachment remove-at 1"; read es;\
3214 call xerr $es "attach 6-7"
3215 echo "~^attachment remove-at 1"; read es;\
3216 vput vexpr es substr $es 0 3
3217 if [ $es != 501 ]
3218 xcall bail "attach 6-8"
3221 echo "~^attachment list"; read es;\
3222 vput vexpr es substr $es 0 3
3223 if [ $es != 501 ]
3224 xcall bail "attach 6-9"
3227 echo t_attach LEAVE
3229 define t_ocs {
3230 read ver
3231 echo t_ocs
3232 call t_header
3233 call t_attach
3235 define t_oce {
3236 echo on-compose-enter, mailx-command<$mailx-command>
3237 alternates alter1@exam.ple alter2@exam.ple
3238 alternates
3239 set autocc='alter1@exam.ple alter2@exam.ple'
3240 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3241 echo mailx-subject<$mailx-subject>
3242 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3243 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3244 mailx-raw-bcc<$mailx-raw-bcc>
3245 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
3246 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3248 define t_ocl {
3249 echo on-compose-leave, mailx-command<$mailx-command>
3250 vput alternates al
3251 eval alternates $al alter3@exam.ple alter4@exam.ple
3252 alternates
3253 set autobcc='alter3@exam.ple alter4@exam.ple'
3254 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3255 echo mailx-subject<$mailx-subject>
3256 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3257 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3258 mailx-raw-bcc<$mailx-raw-bcc>
3259 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
3260 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3262 define t_occ {
3263 echo on-compose-cleanup, mailx-command<$mailx-command>
3264 unalternates *
3265 alternates
3266 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3267 echo mailx-subject<$mailx-subject>
3268 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3269 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3270 mailx-raw-bcc<$mailx-raw-bcc>
3271 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
3272 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3274 wysh set on-compose-splice=t_ocs \
3275 on-compose-enter=t_oce on-compose-leave=t_ocl \
3276 on-compose-cleanup=t_occ
3277 __EOT__
3279 ${rm} -f "${MBOX}"
3280 printf 'm this-goes@nowhere\nbody\n!.\n' |
3281 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
3282 -X'source ./.trc' -Smta=./.tsendmail.sh \
3283 >./.tall 2>&1
3284 ${cat} ./.tall >> "${MBOX}"
3285 check behave:compose_hooks-1 0 "${MBOX}" '522535560 10101'
3287 ${rm} -f "${MBOX}"
3288 printf 'm this-goes@nowhere\nbody\n!.\n' |
3289 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
3290 -St_remove=1 -X'source ./.trc' -Smta=./.tsendmail.sh \
3291 >./.tall 2>&1
3292 ${cat} ./.tall >> "${MBOX}"
3293 check behave:compose_hooks-2 0 "${MBOX}" '3654000499 12535'
3297 # Some state machine stress, shell compose hook, localopts for hook, etc.
3298 # readctl in child. ~r as HERE document
3299 ${rm} -f "${MBOX}"
3300 printf 'm ex@am.ple\nbody\n!.
3301 echon ${mailx-command}${mailx-subject}
3302 echon ${mailx-from}${mailx-sender}
3303 echon ${mailx-to}${mailx-cc}${mailx-bcc}
3304 echon ${mailx-raw-to}${mailx-raw-cc}${mailx-raw-bcc}
3305 echon ${mailx-orig-from}${mailx-orig-to}${mailx-orig-gcc}${mailx-orig-bcc}
3306 var t_oce t_ocs t_ocs_sh t_ocl t_occ autocc
3307 ' | ${MAILX} ${ARGS} -Snomemdebug -Sescape=! \
3308 -Smta=./.tsendmail.sh \
3310 define bail {
3311 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
3313 define xerr {
3314 vput vexpr es substr "$1" 0 1
3315 if [ "$es" != 2 ]
3316 xcall bail "$2"
3319 define read_mline_res {
3320 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
3321 echo $len/$es/$^ERRNAME: $hl
3322 if [ $es -ne $^ERR-NONE ]
3323 xcall bail read_mline_res
3324 elif [ $len -ne 0 ]
3325 \xcall read_mline_res
3328 define _work {
3329 vput vexpr i + 1 "$2"
3330 if [ $i -lt 111 ]
3331 vput vexpr j % $i 10
3332 if [ $j -ne 0 ]
3333 set j=xcall
3334 else
3335 echon "$i.. "
3336 set j=call
3338 eval \\$j _work $1 $i
3339 return $?
3341 vput vexpr i + $i "$1"
3342 return $i
3344 define _read {
3345 wysh set line; read line;wysh set es=$? en=$^ERRNAME ;\
3346 echo read:$es/$en: $line
3347 if [ "${es}" -ne -1 ]
3348 xcall _read
3350 readctl remove $cwd/.treadctl; echo readctl remove:$?/$^ERRNAME
3352 define t_ocs {
3353 read ver
3354 echo t_ocs
3355 echo "~^header list"; read hl; echo $hl;\
3356 vput vexpr es substr "$hl" 0 1
3357 if [ "$es" != 2 ]
3358 xcall bail "header list"
3359 endif
3361 call _work 1; echo $?
3362 echo "~^header insert cc splicy diet <splice@exam.ple> spliced";\
3363 read es; echo $es; vput vexpr es substr "$es" 0 1
3364 if [ "$es" != 2 ]
3365 xcall bail "be diet"
3366 endif
3367 echo "~^header insert cc <splice2@exam.ple>";\
3368 read es; echo $es; vput vexpr es substr "$es" 0 1
3369 if [ "$es" != 2 ]
3370 xcall bail "be diet2"
3371 endif
3373 call _work 2; echo $?
3374 echo "~^header insert bcc juicy juice <juice@exam.ple> spliced";\
3375 read es; echo $es;vput vexpr es substr "$es" 0 1
3376 if [ "$es" != 2 ]
3377 xcall bail "be juicy"
3378 endif
3379 echo "~^header insert bcc juice2@exam.ple";\
3380 read es; echo $es;vput vexpr es substr "$es" 0 1
3381 if [ "$es" != 2 ]
3382 xcall bail "be juicy2"
3383 endif
3384 echo "~^header insert bcc juice3 <juice3@exam.ple>";\
3385 read es; echo $es;vput vexpr es substr "$es" 0 1
3386 if [ "$es" != 2 ]
3387 xcall bail "be juicy3"
3388 endif
3389 echo "~^header insert bcc juice4@exam.ple";\
3390 read es; echo $es;vput vexpr es substr "$es" 0 1
3391 if [ "$es" != 2 ]
3392 xcall bail "be juicy4"
3393 endif
3395 echo "~^header remove-at bcc 3";\
3396 read es; echo $es;vput vexpr es substr "$es" 0 1
3397 if [ "$es" != 2 ]
3398 xcall bail "remove juicy5"
3399 endif
3400 echo "~^header remove-at bcc 2";\
3401 read es; echo $es;vput vexpr es substr "$es" 0 1
3402 if [ "$es" != 2 ]
3403 xcall bail "remove juicy6"
3404 endif
3405 echo "~^header remove-at bcc 3";\
3406 read es; echo $es;vput vexpr es substr "$es" 0 3
3407 if [ "$es" != 501 ]
3408 xcall bail "failed to remove-at"
3409 endif
3410 # Add duplicates which ought to be removed!
3411 echo "~^header insert bcc juice4@exam.ple";\
3412 read es; echo $es;vput vexpr es substr "$es" 0 1
3413 if [ "$es" != 2 ]
3414 xcall bail "be juicy4-1"
3415 endif
3416 echo "~^header insert bcc juice4@exam.ple";\
3417 read es; echo $es;vput vexpr es substr "$es" 0 1
3418 if [ "$es" != 2 ]
3419 xcall bail "be juicy4-2"
3420 endif
3421 echo "~^header insert bcc juice4@exam.ple";\
3422 read es; echo $es;vput vexpr es substr "$es" 0 1
3423 if [ "$es" != 2 ]
3424 xcall bail "be juicy4-3"
3425 endif
3426 echo "~:set t_ocs"
3429 call _work 3; echo $?
3430 echo "~r - '__EOT'"
3431 vput ! i echo just knock if you can hear me;\
3432 i=0;\
3433 while [ $i -lt 24 ]; do printf "%s " $i; i=`expr $i + 1`; done;\
3434 echo relax
3435 echon shell-cmd says $?/$^ERRNAME: $i
3436 echo "~x will not become interpreted, we are reading until __EOT"
3437 echo "__EOT"
3438 read r_status; echo "~~r status output: $r_status"
3439 echo "~:echo $? $! $^ERRNAME"
3440 read r_status
3441 echo "~~r status from parent: $r_status"
3444 call _work 4; echo $?
3445 vput cwd cwd;echo cwd:$?
3446 readctl create $cwd/.treadctl ;echo readctl:$?/$^ERRNAME;\
3447 call _read
3450 call _work 5; echo $?
3451 echo "~^header show MAILX-Command"; read es;\
3452 call xerr $es "t_header 1000"; call read_mline_res
3453 echo "~^header show MAILX-raw-TO"; read es;\
3454 call xerr $es "t_header 1001"; xcall read_mline_res
3456 echoerr IT IS WRONG IF YOU SEE THIS
3458 define t_oce {
3459 echo on-compose-enter, mailx-command<$mailx-command>
3460 set t_oce autobcc=oce@exam.ple
3461 alternates alter1@exam.ple alter2@exam.ple
3462 alternates
3463 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3464 echo mailx-subject<$mailx-subject>
3465 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3466 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3467 mailx-raw-bcc<$mailx-raw-bcc>
3468 echo mailx-orig-from<$mailx-orig-from> \
3469 mailx-orig-to<$mailx-orig-to> \
3470 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3472 define t_ocl {
3473 echo on-compose-leave, mailx-command<$mailx-command>
3474 set t_ocl autocc=ocl@exam.ple
3475 unalternates *
3476 alternates alter3@exam.ple alter4@exam.ple
3477 alternates
3478 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3479 echo mailx-subject<$mailx-subject>
3480 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3481 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3482 mailx-raw-bcc<$mailx-raw-bcc>
3483 echo mailx-orig-from<$mailx-orig-from> \
3484 mailx-orig-to<$mailx-orig-to> \
3485 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3487 define t_occ {
3488 echo on-compose-cleanup, mailx-command<$mailx-command>
3489 set t_occ autocc=occ@exam.ple
3490 unalternates *
3491 alternates
3492 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3493 echo mailx-subject<$mailx-subject>
3494 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3495 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3496 mailx-raw-bcc<$mailx-raw-bcc>
3497 echo mailx-orig-from<$mailx-orig-from> \
3498 mailx-orig-to<$mailx-orig-to> \
3499 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3501 wysh set on-compose-splice=t_ocs \
3502 on-compose-splice-shell="read ver;printf \"t_ocs-shell\\n\
3503 ~t shell@exam.ple\\n~:set t_ocs_sh\\n\"" \
3504 on-compose-enter=t_oce on-compose-leave=t_ocl \
3505 on-compose-cleanup=t_occ
3506 ' > ./.tnotes 2>&1
3507 ex0_test behave:compose_hooks-3-estat
3508 ${cat} ./.tnotes >> "${MBOX}"
3510 check behave:compose_hooks-3 - "${MBOX}" '679526364 2431'
3512 # Reply, forward, resend, Resend
3514 ${rm} -f "${MBOX}"
3515 printf 'set from=f1@z\nm t1@z\nb1\n!.\nset from=f2@z\nm t2@z\nb2\n!.\n' |
3516 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! \
3517 -Smta=./.tsendmail.sh
3519 printf '
3520 echo start: $? $! $^ERRNAME
3521 File %s
3522 echo File: $? $! $^ERRNAME;echo;echo
3523 reply 1
3524 this is content of reply 1
3526 echo reply 1: $? $! $^ERRNAME;echo;echo
3527 Reply 1 2
3528 this is content of Reply 1 2
3530 echo Reply 1 2: $? $! $^ERRNAME;echo;echo
3531 forward 1 fwdex@am.ple
3532 this is content of forward 1
3534 echo forward 1: $? $! $^ERRNAME;echo;echo
3535 resend 1 2 resendex@am.ple
3536 echo resend 1 2: $? $! $^ERRNAME;echo;echo
3537 Resend 1 2 Resendex@am.ple
3538 echo Resend 1 2: $? $! $^ERRNAME;echo;echo
3539 ' "${MBOX}" |
3540 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! \
3541 -Smta=./.tsendmail.sh \
3543 define bail {
3544 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
3546 define xerr {
3547 vput vexpr es substr "$1" 0 1
3548 if [ "$es" != 2 ]
3549 xcall bail "$2"
3552 define read_mline_res {
3553 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
3554 echo mline_res:$len/$es/$^ERRNAME: $hl
3555 if [ $es -ne $^ERR-NONE ]
3556 xcall bail read_mline_res
3557 elif [ $len -ne 0 ]
3558 \xcall read_mline_res
3561 define work_hl {
3562 echo "~^header show $1"; read es;\
3563 call xerr $es "work_hl $1"; echo $1; call read_mline_res
3564 if [ $# -gt 1 ]
3565 shift
3566 xcall work_hl "$@"
3569 define t_ocs {
3570 read ver
3571 echo t_ocs version $ver
3572 echo "~^header list"; read hl; echo $hl;\
3573 echoerr the header list is $hl;\
3574 call xerr "$hl" "header list"
3575 eval vpospar set $hl
3576 shift
3577 xcall work_hl "$@"
3578 echoerr IT IS WRONG IF YOU SEE THIS
3580 define t_oce {
3581 echo on-XY-enter, mailx-command<$mailx-command>
3582 set t_oce autobcc=oce@exam.ple
3583 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3584 echo mailx-subject<$mailx-subject>
3585 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3586 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3587 mailx-raw-bcc<$mailx-raw-bcc>
3588 echo mailx-orig-from<$mailx-orig-from> \
3589 mailx-orig-to<$mailx-orig-to> \
3590 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3592 define t_ocl {
3593 echo on-XY-leave, mailx-command<$mailx-command>
3594 set t_ocl autocc=ocl@exam.ple
3595 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3596 echo mailx-subject<$mailx-subject>
3597 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3598 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3599 mailx-raw-bcc<$mailx-raw-bcc>
3600 echo mailx-orig-from<$mailx-orig-from> \
3601 mailx-orig-to<$mailx-orig-to> \
3602 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3604 define t_occ {
3605 echo on-XY-cleanup, mailx-command<$mailx-command>
3606 set t_occ autocc=occ@exam.ple
3607 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3608 echo mailx-subject<$mailx-subject>
3609 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3610 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3611 mailx-raw-bcc<$mailx-raw-bcc>
3612 echo mailx-orig-from<$mailx-orig-from> \
3613 mailx-orig-to<$mailx-orig-to> \
3614 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3616 wysh set on-compose-splice=t_ocs \
3617 on-compose-enter=t_oce on-compose-leave=t_ocl \
3618 on-compose-cleanup=t_occ \
3619 on-resend-enter=t_oce on-resend-cleanup=t_occ
3620 ' > ./.tnotes 2>&1
3621 ex0_test behave:compose_hooks-4-estat
3622 ${cat} ./.tnotes >> "${MBOX}"
3624 check behave:compose_hooks-4 - "${MBOX}" '3038884027 7516'
3626 t_epilog
3629 t_behave_message_injections() {
3630 t_prolog t_behave_message_injections
3631 TRAP_EXIT_ADDONS="./.t*"
3633 ${cat} <<-_EOT > ./.tsendmail.sh
3634 #!${SHELL} -
3635 (echo 'From Echinacea Tue Jun 20 15:54:02 2017' && ${cat} && echo
3636 ) > "${MBOX}"
3637 _EOT
3638 chmod 0755 ./.tsendmail.sh
3640 echo mysig > ./.tmysig
3642 echo some-body | ${MAILX} ${ARGS} -Smta=./.tsendmail.sh \
3643 -Smessage-inject-head=head-inject \
3644 -Smessage-inject-tail=tail-inject \
3645 -Ssignature=./.tmysig \
3646 ex@am.ple > ./.tall 2>&1
3647 check behave:message_injections-1 0 "${MBOX}" '2434746382 134'
3648 check behave:message_injections-2 - .tall '4294967295 0' # empty file
3650 ${cat} <<-_EOT > ./.template
3651 From: me
3652 To: ex1@am.ple
3653 Cc: ex2@am.ple
3654 Subject: This subject is
3656 Body, body, body me.
3657 _EOT
3658 < ./.template ${MAILX} ${ARGS} -t -Smta=./.tsendmail.sh \
3659 -Smessage-inject-head=head-inject \
3660 -Smessage-inject-tail=tail-inject \
3661 -Ssignature=./.tmysig \
3662 > ./.tall 2>&1
3663 check behave:message_injections-3 0 "${MBOX}" '3114203412 198'
3664 check behave:message_injections-4 - .tall '4294967295 0' # empty file
3666 t_epilog
3669 t_behave_mime_types_load_control() {
3670 t_prolog t_behave_mime_types_load_control
3671 TRAP_EXIT_ADDONS="./.t*"
3673 ${cat} <<-_EOT > ./.tmts1
3674 @ application/mathml+xml mathml
3675 _EOT
3676 ${cat} <<-_EOT > ./.tmts2
3677 @ x-conference/x-cooltalk ice
3678 @ aga-aga aga
3679 @ application/aga-aga aga
3680 _EOT
3682 ${cat} <<-_EOT > ./.tmts1.mathml
3683 <head>nonsense ML</head>
3684 _EOT
3685 ${cat} <<-_EOT > ./.tmts2.ice
3686 Icy, icy road.
3687 _EOT
3688 printf 'of which the c\x01rack is coming soon' > ./.tmtsx.doom
3689 printf 'of which the c\x01rack is coming soon' > ./.tmtsx.aga
3691 printf '
3692 m %s
3693 Schub-di-du
3694 ~@ ./.tmts1.mathml
3695 ~@ ./.tmts2.ice
3696 ~@ ./.tmtsx.doom
3697 ~@ ./.tmtsx.aga
3699 File %s
3700 from*
3701 type
3703 ' "${MBOX}" "${MBOX}" |
3704 ${MAILX} ${ARGS} \
3705 -Smimetypes-load-control=f=./.tmts1,f=./.tmts2 \
3706 > ./.tout 2>&1
3707 ex0_test behave:mime_types_load_control
3709 ${cat} "${MBOX}" >> ./.tout
3710 check behave:mime_types_load_control-1 - ./.tout '1441260727 2449'
3712 echo type | ${MAILX} ${ARGS} -R \
3713 -Smimetypes-load-control=f=./.tmts1,f=./.tmts3 \
3714 -f "${MBOX}" >> ./.tout 2>&1
3715 check behave:mime_types_load_control-2 0 ./.tout '1441391438 3646'
3717 t_epilog
3720 t_behave_s_mime() {
3721 have_feat smime || {
3722 echo 'behave:s/mime: unsupported, skipped'
3723 return
3726 t_prolog t_behave_s_mime
3727 TRAP_EXIT_ADDONS="./.t.conf ./.tkey.pem ./.tcert.pem ./.tpair.pem"
3728 TRAP_EXIT_ADDONS="${TRAP_EXIT_ADDONS} ./.VERIFY ./.DECRYPT ./.ENCRYPT"
3729 TRAP_EXIT_ADDONS="${TRAP_EXIT_ADDONS} ./.tsendmail.sh"
3731 printf 'behave:s/mime: .. generating test key and certificate ..\n'
3732 ${cat} <<-_EOT > ./.t.conf
3733 [ req ]
3734 default_bits = 1024
3735 default_keyfile = keyfile.pem
3736 distinguished_name = req_distinguished_name
3737 attributes = req_attributes
3738 prompt = no
3739 output_password =
3741 [ req_distinguished_name ]
3742 C = GB
3743 ST = Over the
3744 L = rainbow
3745 O = S-nail
3746 OU = S-nail.smime
3747 CN = S-nail.test
3748 emailAddress = test@localhost
3750 [ req_attributes ]
3751 challengePassword =
3752 _EOT
3753 openssl req -x509 -nodes -days 3650 -config ./.t.conf \
3754 -newkey rsa:1024 -keyout ./.tkey.pem -out ./.tcert.pem >/dev/null 2>&1
3755 ${cat} ./.tkey.pem ./.tcert.pem > ./.tpair.pem
3757 # Sign/verify
3758 printf 'behave:s/mime:sign/verify: '
3759 echo bla | ${MAILX} ${ARGS} \
3760 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
3761 -Ssmime-sign -Sfrom=test@localhost \
3762 -s 'S/MIME test' ./.VERIFY
3763 if [ $? -eq 0 ]; then
3764 printf 'ok\n'
3765 else
3766 printf 'failed\n'
3767 ESTAT=1
3768 t_epilog
3769 return
3772 ${awk} '
3773 BEGIN{ skip=0 }
3774 /^Content-Description: /{ skip = 2; print; next }
3775 /^$/{ if(skip) --skip }
3776 { if(!skip) print }
3778 < ./.VERIFY > "${MBOX}"
3779 check behave:s/mime:sign/verify:checksum - "${MBOX}" '2900817158 648'
3781 printf 'behave:s/mime:sign/verify:verify '
3782 printf 'verify\nx\n' |
3783 ${MAILX} ${ARGS} \
3784 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
3785 -Ssmime-sign -Sfrom=test@localhost \
3786 -Serrexit -R \
3787 -f ./.VERIFY >/dev/null 2>&1
3788 if [ $? -eq 0 ]; then
3789 printf 'ok\n'
3790 else
3791 printf 'failed\n'
3792 ESTAT=1
3793 t_epilog
3794 return
3797 printf 'behave:s/mime:sign/verify:disproof-1 '
3798 if openssl smime -verify -CAfile ./.tcert.pem \
3799 -in ./.VERIFY >/dev/null 2>&1; then
3800 printf 'ok\n'
3801 else
3802 printf 'failed\n'
3803 ESTAT=1
3804 t_epilog
3805 return
3808 # (signing +) encryption / decryption
3809 ${cat} <<-_EOT > ./.tsendmail.sh
3810 #!${SHELL} -
3811 (echo 'From Euphrasia Thu Apr 27 17:56:23 2017' && ${cat}) > ./.ENCRYPT
3812 _EOT
3813 chmod 0755 ./.tsendmail.sh
3815 printf 'behave:s/mime:encrypt+sign: '
3816 echo bla |
3817 ${MAILX} ${ARGS} \
3818 -Ssmime-force-encryption \
3819 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
3820 -Smta=./.tsendmail.sh \
3821 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
3822 -Ssmime-sign -Sfrom=test@localhost \
3823 -s 'S/MIME test' recei@ver.com
3824 if [ $? -eq 0 ]; then
3825 printf 'ok\n'
3826 else
3827 ESTAT=1
3828 printf 'error: encrypt+sign failed\n'
3831 ${sed} -e '/^$/,$d' < ./.ENCRYPT > "${MBOX}"
3832 check behave:s/mime:encrypt+sign:checksum - "${MBOX}" '1937410597 327'
3834 printf 'behave:s/mime:decrypt+verify: '
3835 printf 'decrypt ./.DECRYPT\nfi ./.DECRYPT\nverify\nx\n' |
3836 ${MAILX} ${ARGS} \
3837 -Ssmime-force-encryption \
3838 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
3839 -Smta=./.tsendmail.sh \
3840 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
3841 -Ssmime-sign -Sfrom=test@localhost \
3842 -Serrexit -R \
3843 -f ./.ENCRYPT >/dev/null 2>&1
3844 if [ $? -eq 0 ]; then
3845 printf 'ok\n'
3846 else
3847 ESTAT=1
3848 printf 'failed\n'
3851 ${awk} '
3852 BEGIN{ skip=0 }
3853 /^Content-Description: /{ skip = 2; print; next }
3854 /^$/{ if(skip) --skip }
3855 { if(!skip) print }
3857 < ./.DECRYPT > "${MBOX}"
3858 check behave:s/mime:decrypt+verify:checksum - "${MBOX}" '1720739247 931'
3860 printf 'behave:s/mime:decrypt+verify:disproof-1: '
3861 if (openssl smime -decrypt -inkey ./.tkey.pem -in ./.ENCRYPT |
3862 openssl smime -verify -CAfile ./.tcert.pem) >/dev/null 2>&1; then
3863 printf 'ok\n'
3864 else
3865 printf 'failed\n'
3866 ESTAT=1
3869 printf "behave:s/mime:encrypt: "
3870 echo bla | ${MAILX} ${ARGS} \
3871 -Ssmime-force-encryption \
3872 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
3873 -Smta=./.tsendmail.sh \
3874 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
3875 -Sfrom=test@localhost \
3876 -s 'S/MIME test' recei@ver.com
3877 if [ $? -eq 0 ]; then
3878 printf 'ok\n'
3879 else
3880 ESTAT=1
3881 printf 'failed\n'
3884 # Same as behave:s/mime:encrypt+sign:checksum above
3885 ${sed} -e '/^$/,$d' < ./.ENCRYPT > "${MBOX}"
3886 check behave:s/mime:encrypt:checksum - "${MBOX}" '1937410597 327'
3888 ${rm} -f ./.DECRYPT
3889 printf 'decrypt ./.DECRYPT\nx\n' | ${MAILX} ${ARGS} \
3890 -Ssmime-force-encryption \
3891 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
3892 -Smta=./.tsendmail.sh \
3893 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
3894 -Sfrom=test@localhost \
3895 -Serrexit -R \
3896 -f ./.ENCRYPT >/dev/null 2>&1
3897 check behave:s/mime:decrypt 0 "./.DECRYPT" '2624716890 422'
3899 printf 'behave:s/mime:decrypt:disproof-1: '
3900 if openssl smime -decrypt -inkey ./.tkey.pem \
3901 -in ./.ENCRYPT >/dev/null 2>&1; then
3902 printf 'ok\n'
3903 else
3904 printf 'failed\n'
3905 ESTAT=1
3908 t_epilog
3911 t_behave_maildir() {
3912 t_prolog t_behave_maildir
3913 TRAP_EXIT_ADDONS="./.t*"
3917 while [ ${i} -lt 112 ]; do
3918 printf 'm file://%s\n~s Subject %s\nHello %s!\n~.\n' \
3919 "${MBOX}" "${i}" "${i}"
3920 i=`add ${i} 1`
3921 done
3922 ) | ${MAILX} ${ARGS}
3923 check behave:maildir-1 0 "${MBOX}" '1140119864 13780'
3925 printf 'File "%s"
3926 copy * "%s"
3927 File "%s"
3928 from*
3929 ' "${MBOX}" .tmdir1 .tmdir1 |
3930 ${MAILX} ${ARGS} -Snewfolders=maildir > .tlst
3931 check behave:maildir-2 0 .tlst '1797938753 9103'
3933 printf 'File "%s"
3934 copy * "maildir://%s"
3935 File "maildir://%s"
3936 from*
3937 ' "${MBOX}" .tmdir2 .tmdir2 |
3938 ${MAILX} ${ARGS} > .tlst
3939 check behave:maildir-3 0 .tlst '1155631089 9113'
3941 printf 'File "maildir://%s"
3942 copy * "file://%s"
3943 File "file://%s"
3944 from*
3945 ' .tmdir2 .tmbox1 .tmbox1 |
3946 ${MAILX} ${ARGS} > .tlst
3947 check behave:maildir-4 0 .tmbox1 '2646131190 13220'
3948 check behave:maildir-5 - .tlst '3701297796 9110'
3950 # only the odd (even)
3952 printf 'File "maildir://%s"
3953 copy ' .tmdir2
3955 while [ ${i} -lt 112 ]; do
3956 j=`modulo ${i} 2`
3957 [ ${j} -eq 1 ] && printf '%s ' "${i}"
3958 i=`add ${i} 1`
3959 done
3960 printf ' file://%s
3961 File "file://%s"
3962 from*
3963 ' .tmbox2 .tmbox2
3964 ) | ${MAILX} ${ARGS} > .tlst
3965 check behave:maildir-6 0 .tmbox2 '142890131 6610'
3966 check behave:maildir-7 - .tlst '960096773 4573'
3967 # ...
3969 printf 'file "maildir://%s"
3970 move ' .tmdir2
3972 while [ ${i} -lt 112 ]; do
3973 j=`modulo ${i} 2`
3974 [ ${j} -eq 0 ] && [ ${i} -ne 0 ] && printf '%s ' "${i}"
3975 i=`add ${i} 1`
3976 done
3977 printf ' file://%s
3978 File "file://%s"
3979 from*
3980 File "maildir://%s"
3981 from*
3982 ' .tmbox2 .tmbox2 .tmdir2
3983 ) | ${MAILX} ${ARGS} > .tlst
3984 check behave:maildir-8 0 .tmbox2 '3806905791 13100'
3985 ${sed} 2d < .tlst > .tlstx
3986 check behave:maildir-9 - .tlstx '4216815295 13645'
3988 t_epilog
3991 t_behave_mass_recipients() {
3992 t_prolog t_behave_mass_recipients
3993 TRAP_EXIT_ADDONS="./.t*"
3995 ${cat} <<-_EOT > ./.tsendmail.sh
3996 #!${SHELL} -
3997 (echo 'From Eucalyptus Sat Jul 08 21:14:57 2017' && ${cat} && echo
3998 ) >> "${MBOX}"
3999 _EOT
4000 chmod 0755 ./.tsendmail.sh
4002 ${cat} <<'__EOT__' > ./.trc
4003 define bail {
4004 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
4006 define ins_addr {
4007 wysh set nr=$1 hn=$2
4008 echo "~$hn $hn$nr@$hn"; echo '~:echo $?'; read es
4009 if [ "$es" -ne 0 ]
4010 xcall bail "ins_addr $hn 1-$nr"
4012 vput vexpr nr + $nr 1
4013 if [ "$nr" -le "$maximum" ]
4014 xcall ins_addr $nr $hn
4017 define bld_alter {
4018 wysh set nr=$1 hn=$2
4019 alternates $hn$nr@$hn
4020 vput vexpr nr + $nr 2
4021 if [ "$nr" -le "$maximum" ]
4022 xcall bld_alter $nr $hn
4025 define t_ocs {
4026 read ver
4027 call ins_addr 1 t
4028 call ins_addr 1 c
4029 call ins_addr 1 b
4031 define t_ocl {
4032 if [ "$t_remove" != '' ]
4033 call bld_alter 1 t
4034 call bld_alter 2 c
4037 set on-compose-splice=t_ocs on-compose-leave=t_ocl
4038 __EOT__
4040 ${rm} -f "${MBOX}"
4041 printf 'm this-goes@nowhere\nbody\n!.\n' |
4042 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
4043 -X'source ./.trc' -Smta=./.tsendmail.sh -Smaximum=2001 \
4044 >./.tall 2>&1
4045 ${cat} ./.tall >> "${MBOX}"
4046 check behave:mass_recipients-1 0 "${MBOX}" '2912243346 51526'
4048 ${rm} -f "${MBOX}"
4049 printf 'm this-goes@nowhere\nbody\n!.\n' |
4050 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
4051 -St_remove=1 -X'source ./.trc' -Smta=./.tsendmail.sh -Smaximum=2001 \
4052 >./.tall 2>&1
4053 ${cat} ./.tall >> "${MBOX}"
4054 check behave:mass_recipients-2 0 "${MBOX}" '4097804632 34394'
4056 t_epilog
4059 t_behave_lreply_futh_rth_etc() {
4060 t_prolog t_behave_lreply_futh_rth_etc
4061 TRAP_EXIT_ADDONS="./.t*"
4063 ${cat} <<-_EOT > ./.tsendmail.sh
4064 #!${SHELL} -
4065 (echo 'From HumulusLupulus Thu Jul 27 14:41:20 2017' && ${cat} && echo
4066 ) >> "${MBOX}"
4067 _EOT
4068 chmod 0755 ./.tsendmail.sh
4070 ${cat} <<-_EOT > ./.tmbox
4071 From neverneverland Sun Jul 23 13:46:25 2017
4072 Subject: Bugstop: five miles out 1
4073 Reply-To: mister originator2 <mr2@originator>, bugstop@five.miles.out
4074 From: mister originator <mr@originator>
4075 To: bugstop-commit@five.miles.out, laber@backe.eu
4076 Cc: is@a.list
4077 Mail-Followup-To: bugstop@five.miles.out, laber@backe.eu, is@a.list
4078 In-reply-to: <20170719111113.bkcMz%laber@backe.eu>
4079 Date: Wed, 19 Jul 2017 09:22:57 -0400
4080 Message-Id: <20170719132257.766AF781267@originator>
4081 Status: RO
4083 > |Sorry, I think I misunderstand something. I would think that
4085 That's appalling.
4087 From neverneverland Fri Jul 7 22:39:11 2017
4088 Subject: Bugstop: five miles out 2
4089 Reply-To: mister originator2<mr2@originator>,bugstop@five.miles.out,is@a.list
4090 Content-Transfer-Encoding: 7bit
4091 From: mister originator <mr@originator>
4092 To: bugstop-commit@five.miles.out
4093 Cc: is@a.list
4094 Message-ID: <149945963975.28888.6950788126957753723.reportbug@five.miles.out>
4095 Date: Fri, 07 Jul 2017 16:33:59 -0400
4096 Status: R
4098 capable of changing back.
4100 From neverneverland Fri Jul 7 22:42:00 2017
4101 Subject: Bugstop: five miles out 3
4102 Reply-To: mister originator2 <mr2@originator>, bugstop@five.miles.out
4103 Content-Transfer-Encoding: 7bit
4104 From: mister originator <mr@originator>
4105 To: bugstop-commit@five.miles.out
4106 Cc: is@a.list
4107 Message-ID: <149945963975.28888.6950788126957753746.reportbug@five.miles.out>
4108 Date: Fri, 07 Jul 2017 16:33:59 -0400
4109 List-Post: <mailto:bugstop@five.miles.out>
4110 Status: R
4112 are you ready, boots?
4114 From neverneverland Sat Aug 19 23:15:00 2017
4115 Subject: Bugstop: five miles out 4
4116 Reply-To: mister originator2 <mr2@originator>, bugstop@five.miles.out
4117 Content-Transfer-Encoding: 7bit
4118 From: mister originator <mr@originator>
4119 To: bugstop@five.miles.out
4120 Cc: is@a.list
4121 Message-ID: <149945963975.28888.6950788126qtewrqwer.reportbug@five.miles.out>
4122 Date: Fri, 07 Jul 2017 16:33:59 -0400
4123 List-Post: <mailto:bugstop@five.miles.out>
4124 Status: R
4126 are you ready, boots?
4127 _EOT
4131 ${cat} <<-'_EOT' | ${MAILX} ${ARGS} -Sescape=! -Smta=./.tsendmail.sh \
4132 -Rf ./.tmbox >> "${MBOX}" 2>&1
4133 define r {
4134 wysh set m="This is text of \"reply ${1}."
4135 reply 1 2 3
4136 !I m
4139 !I m
4142 !I m
4145 echo -----After reply $1.1 - $1.3: $?/$^ERRNAME
4147 define R {
4148 wysh set m="This is text of \"Reply ${1}."
4149 eval Reply $2
4150 !I m
4151 !I 2
4154 echo -----After Reply $1.$2: $?/$^ERRNAME
4156 define _Lh {
4157 read protover
4158 echo '~I m'
4159 echo '~I n'
4160 echo '".'
4162 define _Ls {
4163 wysh set m="This is text of \"Lreply ${1}." on-compose-splice=_Lh n=$2
4164 eval Lreply $2
4166 define L {
4167 # We need two indirections for this test: one for the case that Lreply
4168 # fails because of missing recipients: we need to read EOF next, thus
4169 # place this in _Ls last; and second for the succeeding cases EOF is
4170 # not what these should read, so go over the backside and splice it in!
4171 call _Ls "$@"
4172 echo -----After Lreply $1.$2: $?/$^ERRNAME
4174 define x {
4175 localopts call-fixate yes
4176 call r $1
4177 call R $1 1; call R $1 2; call R $1 3; call R $1 4
4178 call L $1 1; call L $1 2; call L $1 3
4180 define tweak {
4181 echo;echo '===== CHANGING === '"$*"' =====';echo
4182 eval "$@"
4185 set from=laber@backe.eu
4186 mlist is@a.list
4187 call x 1
4188 call tweak set reply-to-honour
4189 call x 2
4190 call tweak set followup-to
4191 call x 3
4192 call tweak set followup-to-honour
4193 call x 4
4194 call tweak mlist bugstop@five.miles.out
4195 call x 5
4196 call tweak mlsubscribe bugstop@five.miles.out
4197 call x 6
4198 call tweak set recipients-in-cc
4199 call x 7
4200 _EOT
4202 check behave:lreply_futh_rth_etc-1 0 "${MBOX}" '940818845 29373'
4206 ${cat} <<-_EOT > ./.tmbox
4207 From tom@i-i.example Thu Oct 26 03:15:55 2017
4208 Date: Wed, 25 Oct 2017 21:15:46 -0400
4209 From: tom <tom@i-i.example>
4210 To: Steffen Nurpmeso <steffen@sdaoden.eu>
4211 Cc: tom <tom@i-i.example>
4212 Subject: Re: xxxx yyyyyyyy configure does not really like a missing zzzzz
4213 Message-ID: <20171026011546.GA11643@i-i.example>
4214 Reply-To: tom@i-i.example
4215 References: <20171025214601.T2pNd%steffen@sdaoden.eu>
4216 In-Reply-To: <20171025214601.T2pNd%steffen@sdaoden.eu>
4217 Status: R
4219 The report's useful :-)
4220 _EOT
4222 printf 'reply 1\nthank you\n!.\n' |
4223 ${MAILX} ${ARGS} -Sescape=! -Smta=./.tsendmail.sh -Sreply-to-honour \
4224 -Rf ./.tmbox > "${MBOX}" 2>&1
4225 check behave:lreply_futh_rth_etc-2 0 "${MBOX}" '1045866991 331'
4227 t_epilog
4230 t_behave_iconv_mbyte_base64() {
4231 t_prolog t_behave_iconv_mbyte_base64
4232 TRAP_EXIT_ADDONS="./.t*"
4234 if [ -n "${UTF8_LOCALE}" ] && have_feat iconv &&
4235 (</dev/null iconv -f ascii -t iso-2022-jp) >/dev/null 2>&1 ||
4236 (</dev/null iconv -f ascii -t euc-jp) >/dev/null 2>&1; then
4238 else
4239 echo 'behave:iconv_mbyte_base64: unsupported, skipped'
4240 return
4243 ${cat} <<-_EOT > ./.tsendmail.sh
4244 #!${SHELL} -
4245 (echo 'From DroseriaRotundifolia Thu Aug 03 17:26:25 2017' && ${cat} &&
4246 echo) >> "${MBOX}"
4247 _EOT
4248 chmod 0755 ./.tsendmail.sh
4250 if (</dev/null iconv -f ascii -t iso-2022-jp) >/dev/null 2>&1; then
4251 cat <<-'_EOT' | LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} \
4252 -Smta=./.tsendmail.sh \
4253 -Sescape=! -Smime-encoding=base64 2>./.terr
4254 set ttycharset=utf-8 sendcharsets=iso-2022-jp
4255 m t1@exam.ple
4256 !s Japanese from UTF-8 to ISO-2022-JP
4257 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
4259 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
4262 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
4264 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
4267 set ttycharset=iso-2022-jp charset-7bit=iso-2022-jp sendcharsets=utf-8
4268 m t2@exam.ple
4269 !s Japanese from ISO-2022-JP to UTF-8, eh, no, also ISO-2022-JP
4270 \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
4272 \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
4275 \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
4277 \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
4279 _EOT
4280 check behave:iconv_mbyte_base64-1 0 "${MBOX}" '3428985079 1976'
4281 check behave:iconv_mbyte_base64-2 - ./.terr '4294967295 0'
4283 printf 'eval f 1; write ./.twrite\n' |
4284 ${MAILX} ${ARGS} ${ADDARG_UNI} -Rf "${MBOX}" >./.tlog 2>&1
4285 check behave:iconv_mbyte_base64-3 0 ./.twrite '1259742080 686'
4286 check behave:iconv_mbyte_base64-4 - ./.tlog '3956097665 119'
4287 else
4288 echo 'behave:iconv_mbyte_base64: ISO-2022-JP unsupported, skipping 1-4'
4291 if (</dev/null iconv -f ascii -t euc-jp) >/dev/null 2>&1; then
4292 rm -f "${MBOX}" ./.twrite
4293 cat <<-'_EOT' | LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} \
4294 -Smta=./.tsendmail.sh \
4295 -Sescape=! -Smime-encoding=base64 2>./.terr
4296 set ttycharset=utf-8 sendcharsets=euc-jp
4297 m t1@exam.ple
4298 !s Japanese from UTF-8 to EUC-JP
4299 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
4301 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
4304 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
4306 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
4309 set ttycharset=EUC-JP sendcharsets=utf-8
4310 m t2@exam.ple
4311 !s Japanese from EUC-JP to UTF-8
4312 ¥·¥¸¥å¥¦¥«¥é²Ê¡Ê¥·¥¸¥å¥¦¥«¥é¤«¡¢³Ø̾ Paridae¡Ë¤Ï¡¢Ä»Îॹ¥º¥áÌܤβʤǤ¢¤ë¡£¥·¥¸¥å¥¦¥«¥é¡Ê»Í½½¿ý¡Ë¤ÈÁí¾Î¤µ¤ì¤ë¤¬¡¢¶¹µÁ¤Ë¤Ï¤³¤Î1¼ï¤ò¥·¥¸¥å¥¦¥«¥é¤È¸Æ¤Ö¡£
4314 ¥«¥ó¥à¥ê¥¬¥é¡Ê³Ø̾Parus cristatus¡Ë¤Ï¡¢¥¹¥º¥áÌÜ¥·¥¸¥å¥¦¥«¥é²Ê¤ËʬÎव¤ì¤ëÄ»Îà¤Î°ì¼ï¡£
4317 ¥«¥ó¥à¥ê¥¬¥é¡Ê³Ø̾Parus cristatus¡Ë¤Ï¡¢¥¹¥º¥áÌÜ¥·¥¸¥å¥¦¥«¥é²Ê¤ËʬÎव¤ì¤ëÄ»Îà¤Î°ì¼ï¡£
4319 ¥·¥¸¥å¥¦¥«¥é²Ê¡Ê¥·¥¸¥å¥¦¥«¥é¤«¡¢³Ø̾ Paridae¡Ë¤Ï¡¢Ä»Îॹ¥º¥áÌܤβʤǤ¢¤ë¡£¥·¥¸¥å¥¦¥«¥é¡Ê»Í½½¿ý¡Ë¤ÈÁí¾Î¤µ¤ì¤ë¤¬¡¢¶¹µÁ¤Ë¤Ï¤³¤Î1¼ï¤ò¥·¥¸¥å¥¦¥«¥é¤È¸Æ¤Ö¡£
4321 _EOT
4322 check behave:iconv_mbyte_base64-5 0 "${MBOX}" '1686827547 2051'
4323 check behave:iconv_mbyte_base64-6 - ./.terr '4294967295 0'
4325 printf 'eval f 1; write ./.twrite\n' |
4326 ${MAILX} ${ARGS} ${ADDARG_UNI} -Rf "${MBOX}" >./.tlog 2>&1
4327 check behave:iconv_mbyte_base64-7 0 ./.twrite '1259742080 686'
4328 check behave:iconv_mbyte_base64-8 - ./.tlog '500059195 119'
4329 else
4330 echo 'behave:iconv_mbyte_base64: EUC-JP unsupported, skipping 5-8'
4333 t_epilog
4336 t_behave_iconv_mainbody() {
4337 t_prolog t_behave_iconv_mainbody
4338 TRAP_EXIT_ADDONS="./.t*"
4341 if have_feat iconv &&
4342 (</dev/null iconv -f utf-8 -t ascii) >/dev/null 2>&1; then
4343 j="`printf '–' | iconv -f utf-8 -t ascii 2>/dev/null`"
4344 # This assumes iconv(1) behaves like iconv(3), but well
4345 if [ ${?} -ne 0 ]; then
4347 elif [ x"${j}" = 'x?' ]; then
4349 elif [ x"${j}" = 'x*' ]; then
4353 if [ -z "${i}" ]; then
4354 echo 'behave:iconv_mainbody: unsupported, skipped'
4355 return
4358 ${cat} <<-_EOT > ./.tsendmail.sh
4359 #!${SHELL} -
4360 (echo 'From HamamelisVirginiana Fri Oct 20 16:23:21 2017' && ${cat} &&
4361 echo) >> "${MBOX}"
4362 _EOT
4363 chmod 0755 ./.tsendmail.sh
4365 printf '–' | ${MAILX} ${ARGS} ${ADDARG_UNI} -Smta=./.tsendmail.sh \
4366 -S charset-7bit=us-ascii -S charset-8bit=utf-8 \
4367 -s '–' over-the@rain.bow 2>./.terr
4368 check behave:iconv_mainbody-1 0 "${MBOX}" '3634015017 251'
4369 check behave:iconv_mainbody-2 - ./.terr '4294967295 0'
4371 printf '–' | ${MAILX} ${ARGS} ${ADDARG_UNI} -Smta=./.tsendmail.sh \
4372 -S charset-7bit=us-ascii -S charset-8bit=us-ascii \
4373 -s '–' over-the@rain.bow 2>./.terr
4374 exn0_test behave:iconv_mainbody-3
4375 check behave:iconv_mainbody-3 - "${MBOX}" '3634015017 251'
4376 check behave:iconv_mainbody-4 - ./.terr '1960148192 128'
4378 printf 'p\nx\n' | ${MAILX} ${ARGS} -Rf "${MBOX}" >./.tout 2>./.terr
4379 j=${?}
4380 if [ ${i} -eq 1 ]; then
4381 # yuck, just assume ???, we need a test program for that one!
4382 ex0_test behave:iconv_mainbody-5-1 ${j}
4383 check behave:iconv_mainbody-6-1 - ./.tout '1959197095 283'
4384 check behave:iconv_mainbody-7-1 - ./.terr '4294967295 0'
4385 elif [ ${i} -eq 2 ]; then
4386 ex0_test behave:iconv_mainbody-5-2 ${j}
4387 check behave:iconv_mainbody-6-2 - ./.tout '1959197095 283'
4388 check behave:iconv_mainbody-7-2 - ./.terr '4294967295 0'
4389 else
4390 ex0_test behave:iconv_mainbody-5-3 ${j}
4391 check behave:iconv_mainbody-6-3 - ./.tout '3196380198 279'
4392 check behave:iconv_mainbody-7-3 - ./.terr '4294967295 0'
4395 t_epilog
4398 # t_content()
4399 # Some basic tests regarding correct sending of mails, via STDIN / -t / -q,
4400 # including basic MIME Content-Transfer-Encoding correctness (quoted-printable)
4401 # Note we unfortunately need to place some statements without proper
4402 # indentation because of continuation problems
4403 t_content() {
4404 t_prolog t_content
4406 # MIME encoding (QP) stress message body
4407 printf \
4408 'Ich bin eine DÖS-Datäi mit sehr langen Zeilen und auch '\
4409 'sonst bin ich ganz schön am Schleudern, da kannste denke '\
4410 "wasde willst, gelle, gelle, gelle, gelle, gelle.\r\n"\
4411 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst \r\n"\
4412 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1\r\n"\
4413 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12\r\n"\
4414 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123\r\n"\
4415 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1234\r\n"\
4416 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12345\r\n"\
4417 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123456\r\n"\
4418 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1234567\r\n"\
4419 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12345678\r\n"\
4420 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123456789\r\n"\
4421 "Unn ausserdem habe ich trailing SP/HT/SP/HT whitespace \r\n"\
4422 "Unn ausserdem habe ich trailing HT/SP/HT/SP whitespace \r\n"\
4423 "auf den zeilen vorher.\r\n"\
4424 "From am Zeilenbeginn und From der Mitte gibt es auch.\r\n"\
4425 ".\r\n"\
4426 "Die letzte Zeile war nur ein Punkt.\r\n"\
4427 "..\r\n"\
4428 "Das waren deren zwei.\r\n"\
4429 " \r\n"\
4430 "Die letzte Zeile war ein Leerschritt.\n"\
4431 "=VIER = EQUAL SIGNS=ON A LINE=\r\n"\
4432 "Prösterchen.\r\n"\
4433 ".\n"\
4434 "Die letzte Zeile war nur ein Punkt, mit Unix Zeilenende.\n"\
4435 "..\n"\
4436 "Das waren deren zwei. ditto.\n"\
4437 "Prösterchen.\n"\
4438 "Unn ausseerdem habe ich trailing SP/HT/SP/HT whitespace \n"\
4439 "Unn ausseerdem habe ich trailing HT/SP/HT/SP whitespace \n"\
4440 "auf den zeilen vorher.\n"\
4441 "ditto.\n"\
4442 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.\n"\
4443 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.1"\
4444 "\n"\
4445 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
4446 "\n"\
4447 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
4448 "3\n"\
4449 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
4450 "34\n"\
4451 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
4452 "345\n"\
4453 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
4454 "3456\n"\
4455 "QP am Zeilenende über soft-nl hinweg\n"\
4456 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
4457 "ö123\n"\
4458 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
4459 "1ö23\n"\
4460 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
4461 "12ö3\n"\
4462 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
4463 "123ö\n"\
4464 "=VIER = EQUAL SIGNS=ON A LINE=\n"\
4465 " \n"\
4466 "Die letzte Zeile war ein Leerschritt.\n"\
4467 ' '\
4468 > "${BODY}"
4470 # MIME encoding (QP) stress message subject
4471 SUB="Äbrä Kä?dä=brö Fü?di=bus? \
4472 adadaddsssssssddddddddddddddddddddd\
4473 ddddddddddddddddddddddddddddddddddd\
4474 ddddddddddddddddddddddddddddddddddd\
4475 dddddddddddddddddddd Hallelulja? Od\
4476 er?? eeeeeeeeeeeeeeeeeeeeeeeeeeeeee\
4477 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\
4478 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee f\
4479 fffffffffffffffffffffffffffffffffff\
4480 fffffffffffffffffffff ggggggggggggg\
4481 ggggggggggggggggggggggggggggggggggg\
4482 ggggggggggggggggggggggggggggggggggg\
4483 ggggggggggggggggggggggggggggggggggg\
4484 gggggggggggggggg"
4486 # Three tests for MIME encoding and (a bit) content classification.
4487 # At the same time testing -q FILE, < FILE and -t FILE
4489 ${rm} -f "${MBOX}"
4490 < "${BODY}" ${MAILX} ${ARGS} ${ADDARG_UNI} \
4491 -a "${BODY}" -s "${SUB}" "${MBOX}"
4492 check content:001 0 "${MBOX}" '1145066634 6654'
4494 ${rm} -f "${MBOX}"
4495 < /dev/null ${MAILX} ${ARGS} ${ADDARG_UNI} \
4496 -a "${BODY}" -s "${SUB}" -q "${BODY}" "${MBOX}"
4497 check content:002 0 "${MBOX}" '1145066634 6654'
4499 ${rm} -f "${MBOX}"
4500 ( echo "To: ${MBOX}" && echo "Subject: ${SUB}" && echo &&
4501 ${cat} "${BODY}"
4502 ) | ${MAILX} ${ARGS} ${ADDARG_UNI} -Snodot -a "${BODY}" -t
4503 check content:003 0 "${MBOX}" '1145066634 6654'
4505 # Test for [260e19d] (Juergen Daubert)
4506 ${rm} -f "${MBOX}"
4507 echo body | ${MAILX} ${ARGS} "${MBOX}"
4508 check content:004 0 "${MBOX}" '2917662811 98'
4510 # Sending of multiple mails in a single invocation
4511 ${rm} -f "${MBOX}"
4512 ( printf "m ${MBOX}\n~s subject1\nE-Mail Körper 1\n~.\n" &&
4513 printf "m ${MBOX}\n~s subject2\nEmail body 2\n~.\n" &&
4514 echo x
4515 ) | ${MAILX} ${ARGS} ${ADDARG_UNI}
4516 check content:005 0 "${MBOX}" '2098659767 358'
4518 ## $BODY CHANGED
4520 # "Test for" [d6f316a] (Gavin Troy)
4521 ${rm} -f "${MBOX}"
4522 printf "m ${MBOX}\n~s subject1\nEmail body\n~.\nfi ${MBOX}\np\nx\n" |
4523 ${MAILX} ${ARGS} ${ADDARG_UNI} -Spipe-text/plain="@* ${cat}" > "${BODY}"
4524 check content:006 0 "${MBOX}" '2099098650 122'
4525 check content:006-1 - "${BODY}" '794542938 174'
4527 # "Test for" [c299c45] (Peter Hofmann) TODO shouldn't end up QP-encoded?
4528 ${rm} -f "${MBOX}"
4529 ${awk} 'BEGIN{
4530 for(i = 0; i < 10000; ++i)
4531 printf "\xC3\xBC"
4532 #printf "\xF0\x90\x87\x90"
4533 }' | ${MAILX} ${ARGS} ${ADDARG_UNI} -s TestSubject "${MBOX}"
4534 check content:007 0 "${MBOX}" '534262374 61816'
4536 ## Test some more corner cases for header bodies (as good as we can today) ##
4539 ${rm} -f "${MBOX}"
4540 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
4541 -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̲' \
4542 "${MBOX}"
4543 check content:008 0 "${MBOX}" '3370931614 375'
4545 # Single word (overlong line split -- bad standard! Requires injection of
4546 # artificial data!! But can be prevented by using RFC 2047 encoding)
4547 ${rm} -f "${MBOX}"
4548 i=`${awk} 'BEGIN{for(i=0; i<92; ++i) printf "0123456789_"}'`
4549 echo | ${MAILX} ${ARGS} -s "${i}" "${MBOX}"
4550 check content:009 0 "${MBOX}" '489922370 1718'
4552 # Combination of encoded words, space and tabs of varying sort
4553 ${rm} -f "${MBOX}"
4554 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
4555 -s "1Abrä Kaspas1 2Abra Katä b_kaspas2 \
4556 3Abrä Kaspas3 4Abrä Kaspas4 5Abrä Kaspas5 \
4557 6Abra Kaspas6 7Abrä Kaspas7 8Abra Kaspas8 \
4558 9Abra Kaspastäb4-3 10Abra Kaspas1 _ 11Abra Katäb1 \
4559 12Abra Kadabrä1 After Tab after Täb this is NUTS" \
4560 "${MBOX}"
4561 check content:010 0 "${MBOX}" '1676887734 591'
4563 # Overlong multibyte sequence that must be forcefully split
4564 # todo This works even before v15.0, but only by accident
4565 ${rm} -f "${MBOX}"
4566 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
4567 -s "✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
4568 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
4569 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄" \
4570 "${MBOX}"
4571 check content:011 0 "${MBOX}" '3029301775 659'
4573 # Trailing WS
4574 ${rm} -f "${MBOX}"
4575 echo | ${MAILX} ${ARGS} \
4576 -s "1-1 B2 B3 B4 B5 B6 B\
4577 1-2 B2 B3 B4 B5 B6 B\
4578 1-3 B2 B3 B4 B5 B6 B\
4579 1-4 B2 B3 B4 B5 B6 B\
4580 1-5 B2 B3 B4 B5 B6 B\
4581 1-6 B2 B3 B4 B5 B6 " \
4582 "${MBOX}"
4583 check content:012 0 "${MBOX}" '4126167195 297'
4585 # Leading and trailing WS
4586 ${rm} -f "${MBOX}"
4587 echo | ${MAILX} ${ARGS} \
4588 -s " 2-1 B2 B3 B4 B5 B6 B\
4589 1-2 B2 B3 B4 B5 B6 B\
4590 1-3 B2 B3 B4 B5 B6 B\
4591 1-4 B2 B3 B4 B5 B6 " \
4592 "${MBOX}"
4593 check content:013 0 "${MBOX}" '3600624479 236'
4595 # Quick'n dirty RFC 2231 test; i had more when implementing it, but until we
4596 # have a (better) test framework materialize a quick shot
4597 ${rm} -f "${MBOX}"
4598 TRAP_EXIT_ADDONS=./.ttt
4600 mkdir ./.ttt || exit 1
4601 cd ./.ttt || exit 2
4602 : > "ma'ger.txt"
4603 : > "mä'ger.txt"
4604 : > 'diet\ is \curd.txt'
4605 : > 'diet "is" curd.txt'
4606 : > höde-tröge.txt
4607 : > 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
4608 : > höde__tröge__müde__dätte__hätte__vuelle__guelle__aese__aesse__sauerliche__kräuter__österliche__grüße__mäh.txt
4609 : > hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt
4610 : > ✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt
4612 echo bla | ${MAILX} ${ARGS} ${ADDARG_UNI} \
4613 -a "./.ttt/ma'ger.txt" -a "./.ttt/mä'ger.txt" \
4614 -a './.ttt/diet\ is \curd.txt' -a './.ttt/diet "is" curd.txt' \
4615 -a ./.ttt/höde-tröge.txt \
4616 -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 \
4617 -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 \
4618 -a ./.ttt/hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt \
4619 -a ./.ttt/✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt \
4620 "${MBOX}"
4621 check content:014-1 0 "${MBOX}" '684985954 3092'
4623 # `resend' test, reusing $MBOX
4624 ${rm} -f "${BODY}"
4625 printf "Resend ${BODY}\nx\n" | ${MAILX} ${ARGS} -Rf "${MBOX}"
4626 check content:014-2 0 "${BODY}" '684985954 3092'
4628 ${rm} -f "${BODY}"
4629 printf "resend ${BODY}\nx\n" | ${MAILX} ${ARGS} -Rf "${MBOX}"
4630 check content:014-3 0 "${BODY}" '3130352658 3148'
4632 t_epilog
4635 t_all() {
4636 # if have_feat devel; then
4637 # ARGS="${ARGS} -Smemdebug"
4638 # export ARGS
4639 # fi
4641 if [ -n "${UTF8_LOCALE}" ]; then
4642 printf 'Using Unicode locale %s\n' "${UTF8_LOCALE}"
4643 else
4644 printf 'No Unicode locale found, disabling Unicode tests\n'
4647 t_behave
4648 t_content
4651 if [ -z "${CHECK_ONLY}${MAE_TEST}" ]; then
4652 cc_all_configs
4653 elif [ -z "${MAE_TEST}" ] || [ ${#} -eq 0 ]; then
4654 t_all
4655 else
4656 while [ ${#} -gt 0 ]; do
4657 ${1}
4658 shift
4659 done
4662 [ ${ESTAT} -eq 0 ] && echo Ok || echo >&2 'Errors occurred'
4664 exit ${ESTAT}
4665 # s-sh-mode