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