resend_msg(): CID 1379029
[s-mailx.git] / cc-test.sh
blob680453f721b258ea03af88aabcb9a438e3884098
1 #!/bin/sh -
2 #@ Usage: ./cc-test.sh [--check-only s-mailx-binary]
3 #@ TODO _All_ the tests should happen in a temporary subdir.
4 # Public Domain
6 # We need *stealthmua* regardless of $SOURCE_DATE_EPOCH, the program name as
7 # such is a compile-time variable
8 ARGS='-:/ -# -Sdotlock-ignore-error -Sexpandaddr=restrict'
9 ARGS="${ARGS}"' -Smime-encoding=quoted-printable -Snosave -Sstealthmua'
10 ADDARG_UNI=-Sttycharset=UTF-8
11 CONF=./make.rc
12 BODY=./.cc-body.txt
13 MBOX=./.cc-test.mbox
14 MAIL=/dev/null
15 #UTF8_LOCALE= autodetected unless set
17 # Note valgrind has problems with FDs in forked childs, which causes some tests
18 # to fail (the FD is rewound and thus will be dumped twice)
19 MEMTESTER=
20 #MEMTESTER='valgrind --leak-check=full --log-file=.vl-%p '
22 if ( command -v command ) >/dev/null 2>&1; then :; else
23 command() {
24 shift
25 which "${@}"
29 MAKE="${MAKE:-`command -v make`}"
30 awk=${awk:-`command -v awk`}
31 cat=${cat:-`command -v cat`}
32 cksum=${cksum:-`command -v cksum`}
33 rm=${rm:-`command -v rm`}
34 sed=${sed:-`command -v sed`}
35 grep=${grep:-`command -v grep`}
37 # Problem: force $SHELL to be a real shell. It seems some testing environments
38 # use nologin(?), but we need a real shell for command execution
39 if { echo ${SHELL} | ${grep} nologin; } >/dev/null 2>&1; then
40 echo >&2 '$SHELL seems to be nologin, overwriting to /bin/sh!'
41 SHELL=/bin/sh
42 export SHELL
45 # We sometimes "fake" sendmail(1) a.k.a. *mta* with a shell wrapper, and it
46 # happens that /bin/sh is often terribly slow
47 if command -v dash >/dev/null 2>&1; then
48 MYSHELL="`command -v dash`"
49 elif command -v mksh >/dev/null 2>&1; then
50 MYSHELL="`command -v mksh`"
51 else
52 MYSHELL="${SHELL}"
55 ## -- >8 -- 8< -- ##
57 export ARGS ADDARG_UNI CONF BODY MBOX MAIL MAKE awk cat cksum rm sed grep
59 LC_ALL=C LANG=C
60 TZ=UTC
61 # Wed Oct 2 01:50:07 UTC 1996
62 SOURCE_DATE_EPOCH=844221007
64 export LC_ALL LANG TZ SOURCE_DATE_EPOCH
65 unset POSIXLY_CORRECT
67 usage() {
68 echo >&2 "Usage: ./cc-test.sh [--check-only s-mailx-binary]"
69 exit 1
72 CHECK_ONLY= MAILX=
73 if [ "${1}" = --check-only ]; then
74 CHECK_ONLY=1
75 MAILX=${2}
76 [ -x "${MAILX}" ] || usage
78 RAWMAILX=${MAILX}
79 MAILX="${MEMTESTER}${MAILX}"
80 export RAWMAILX MAILX
82 if [ -n "${CHECK_ONLY}" ] && [ -z "${UTF8_LOCALE}" ]; then
83 # Try ourselfs for nl_langinfo(CODESET) output first (requires a new version)
84 i=`LC_ALL=C.utf8 "${RAWMAILX}" ${ARGS} -X '
85 \define cset_test {
86 \if [ "${ttycharset}" @i=% utf ]
87 \echo $LC_ALL
88 \xit 0
89 \end
90 \if [ "${#}" -gt 0 ]
91 \wysh set LC_ALL=${1}
92 \shift
93 \eval xcall cset_test "${@}"
94 \end
95 \xit 1
97 \call cset_test C.UTF-8 POSIX.utf8 POSIX.UTF-8 en_EN.utf8 en_EN.UTF-8 \
98 en_US.utf8 en_US.UTF-8
100 [ $? -eq 0 ] && UTF8_LOCALE=$i
102 if [ -z "${UTF8_LOCALE}" ] && command -v locale >/dev/null 2>&1; then
103 UTF8_LOCALE=`locale -a | { m=
104 while read n; do
105 if { echo ${n} | ${grep} -i 'utf-\{0,1\}8'; } >/dev/null 2>&1; then
106 m=${n}
107 if { echo ${n} | ${grep} -e POSIX -e en_EN -e en_US; }; then
108 exit 0
111 m=${n}
112 done
113 echo ${m}
118 ESTAT=0
120 TRAP_EXIT_ADDONS=
121 trap "${rm} -rf \"${BODY}\" \"${MBOX}\" \${TRAP_EXIT_ADDONS}" EXIT
122 trap "exit 1" HUP INT TERM
124 # cc_all_configs()
125 # Test all configs TODO doesn't cover all *combinations*, stupid!
126 cc_all_configs() {
127 < ${CONF} ${awk} '
128 BEGIN {
129 NOTME["OPT_AUTOCC"] = 1
130 NOTME["OPT_DEBUG"] = 1
131 NOTME["OPT_DEVEL"] = 1
132 NOTME["OPT_NOEXTMD5"] = 1
133 NOTME["OPT_ASAN_ADDRESS"] = 1
134 NOTME["OPT_ASAN_MEMORY"] = 1
135 NOTME["OPT_FORCED_STACKPROT"] = 1
136 NOTME["OPT_NOMEMDBG"] = 1
137 NOTME["OPT_NYD2"] = 1
138 i = 0
140 /^[[:space:]]*OPT_/ {
141 sub(/^[[:space:]]*/, "")
142 # This bails for UnixWare 7.1.4 awk(1), but preceeding = with \
143 # does not seem to be a compliant escape for =
144 #sub(/=.*$/, "")
145 $1 = substr($1, 1, index($1, "=") - 1)
146 if (NOTME[$1])
147 next
148 data[i++] = $1
150 END {
151 # Doing this completely sequentially and not doing make distclean in
152 # between runs should effectively result in lesser compilations.
153 # It is completely dumb nonetheless... TODO
154 for (j = 1; j < i; ++j) {
155 for (k = 1; k < j; ++k)
156 printf data[k] "=1 "
157 for (k = j; k < i; ++k)
158 printf data[k] "=0 "
159 printf "OPT_AUTOCC=1\n"
161 for (j = 1; j < i; ++j) {
162 for (k = 1; k < j; ++k)
163 printf data[k] "=0 "
164 for (k = j; k < i; ++k)
165 printf data[k] "=1 "
166 printf "OPT_AUTOCC=1\n"
168 # With debug
169 for (j = 1; j < i; ++j) {
170 for (k = 1; k < j; ++k)
171 printf data[k] "=1 "
172 for (k = j; k < i; ++k)
173 printf data[k] "=0 "
174 printf "OPT_AUTOCC=1\n"
175 printf "OPT_DEBUG=1\n"
177 for (j = 1; j < i; ++j) {
178 for (k = 1; k < j; ++k)
179 printf data[k] "=0 "
180 for (k = j; k < i; ++k)
181 printf data[k] "=1 "
182 printf "OPT_AUTOCC=1\n"
183 printf "OPT_DEBUG=1\n"
186 printf "CONFIG=NULL OPT_AUTOCC=0\n"
187 printf "CONFIG=NULL OPT_AUTOCC=1\n"
188 printf "CONFIG=NULLI OPT_AUTOCC=0\n"
189 printf "CONFIG=NULLI OPT_AUTOCC=1\n"
190 printf "CONFIG=MINIMAL OPT_AUTOCC=0\n"
191 printf "CONFIG=MINIMAL OPT_AUTOCC=1\n"
192 printf "CONFIG=MEDIUM OPT_AUTOCC=0\n"
193 printf "CONFIG=MEDIUM OPT_AUTOCC=1\n"
194 printf "CONFIG=NETSEND OPT_AUTOCC=0\n"
195 printf "CONFIG=NETSEND OPT_AUTOCC=1\n"
196 printf "CONFIG=MAXIMAL OPT_AUTOCC=0\n"
197 printf "CONFIG=MAXIMAL OPT_AUTOCC=1\n"
198 printf "CONFIG=DEVEL OPT_AUTOCC=0\n"
199 printf "CONFIG=DEVEL OPT_AUTOCC=1\n"
200 printf "CONFIG=ODEVEL OPT_AUTOCC=0\n"
201 printf "CONFIG=ODEVEL OPT_AUTOCC=1\n"
203 ' | while read c; do
204 printf "\n\n##########\n$c\n"
205 printf "\n\n##########\n$c\n" >&2
206 sh -c "${MAKE} ${c} all test"
207 done
208 ${MAKE} distclean
211 have_feat() {
212 ( "${RAWMAILX}" ${ARGS} -X'echo $features' -Xx |
213 ${grep} +${1} ) >/dev/null 2>&1
216 t_prolog() {
217 ${rm} -rf "${BODY}" "${MBOX}" ${TRAP_EXIT_ADDONS}
218 TRAP_EXIT_ADDONS=
220 t_epilog() {
221 t_prolog
224 check() {
225 restat=${?} tid=${1} eestat=${2} f=${3} s=${4}
226 #x=`echo ${tid} | tr "/:=" "__-"`
227 #cp -f "${f}" "${TMPDIR}/${x}"
228 [ "${eestat}" != - ] && [ "${restat}" != "${eestat}" ] &&
229 err "${tid}" 'unexpected exit status: '"${restat} != ${eestat}"
230 csum="`${cksum} < ${f}`"
231 if [ "${csum}" = "${s}" ]; then
232 printf '%s: ok\n' "${tid}"
233 else
234 ESTAT=1
235 printf '%s: error: checksum mismatch (got %s)\n' "${tid}" "${csum}"
239 err() {
240 ESTAT=1
241 printf '%s: error: %s\n' ${1} "${2}"
244 ex0_test() {
245 [ $? -ne 0 ] && err $1 'unexpected non-0 exit status'
248 exn0_test() {
249 [ $? -eq 0 ] && err $1 'unexpected 0 exit status'
252 if ( [ "$((1 + 1))" = 2 ] ) >/dev/null 2>&1; then
253 add() {
254 echo "$((${1} + ${2}))"
256 elif command -v expr >/dev/null 2>&1; then
257 add() {
258 echo `expr ${1} + ${2}`
260 else
261 add() {
262 echo `${awk} 'BEGIN{print '${1}' + '${2}'}'`
266 if ( [ "$((2 % 3))" = 2 ] ) >/dev/null 2>&1; then
267 modulo() {
268 echo "$((${1} % ${2}))"
270 elif command -v expr >/dev/null 2>&1; then
271 modulo() {
272 echo `expr ${1} % ${2}`
274 else
275 modulo() {
276 echo `${awk} 'BEGIN{print '${1}' % '${2}'}'`
280 # t_behave()
281 # Basic (easily testable) behaviour tests
282 t_behave() {
283 t_behave_X_opt_input_command_stack
284 t_behave_X_errexit
285 t_behave_wysh
286 t_behave_input_inject_semicolon_seq
287 t_behave_commandalias
288 t_behave_ifelse
289 t_behave_localopts
290 t_behave_macro_param_shift
291 t_behave_addrcodec
292 t_behave_vexpr
293 t_behave_call_ret
294 t_behave_xcall
295 t_behave_vpospar
296 t_behave_atxplode
298 t_behave_mbox
300 t_behave_alternates
301 t_behave_alias
302 # FIXME t_behave_mlist
303 t_behave_filetype
305 t_behave_record_a_resend
307 t_behave_e_H_L_opts
308 t_behave_compose_hooks
309 t_behave_message_injections
310 t_behave_mime_types_load_control
312 t_behave_smime
314 t_behave_maildir
315 t_behave_mass_recipients
316 t_behave_lreply_futh_rth_etc
317 t_behave_iconv_mbyte_base64
320 t_behave_X_opt_input_command_stack() {
321 t_prolog
323 ${cat} <<- '__EOT' > "${BODY}"
324 echo 1
325 define mac0 {
326 echo mac0-1 via1 $0
328 call mac0
329 echo 2
330 source '\
331 echo "define mac1 {";\
332 echo " echo mac1-1 via1 \$0";\
333 echo " call mac0";\
334 echo " echo mac1-2";\
335 echo " call mac2";\
336 echo " echo mac1-3";\
337 echo "}";\
338 echo "echo 1-1";\
339 echo "define mac2 {";\
340 echo " echo mac2-1 via1 \$0";\
341 echo " call mac0";\
342 echo " echo mac2-2";\
343 echo "}";\
344 echo "echo 1-2";\
345 echo "call mac1";\
346 echo "echo 1-3";\
347 echo "source \"\
348 echo echo 1-1-1 via1 \$0;\
349 echo call mac0;\
350 echo echo 1-1-2;\
351 | \"";\
352 echo "echo 1-4";\
354 echo 3
355 call mac2
356 echo 4
357 undefine *
358 __EOT
360 # The -X option supports multiline arguments, and those can internally use
361 # reverse solidus newline escaping. And all -X options are joined...
362 APO=\'
363 < "${BODY}" ${MAILX} ${ARGS} \
364 -X 'e\' \
365 -X ' c\' \
366 -X ' h\' \
367 -X ' o \' \
368 -X 1 \
370 define mac0 {
371 echo mac0-1 via2 $0
373 call mac0
374 echo 2
377 source '${APO}'\
378 echo "define mac1 {";\
379 echo " echo mac1-1 via2 \$0";\
380 echo " call mac0";\
381 echo " echo mac1-2";\
382 echo " call mac2";\
383 echo " echo mac1-3";\
384 echo "}";\
385 echo "echo 1-1";\
386 echo "define mac2 {";\
387 echo " echo mac2-1 via2 \$0";\
388 echo " call mac0";\
389 echo " echo mac2-2";\
390 echo "}";\
391 echo "echo 1-2";\
392 echo "call mac1";\
393 echo "echo 1-3";\
394 echo "source \"\
395 echo echo 1-1-1 via2 \$0;\
396 echo call mac0;\
397 echo echo 1-1-2;\
398 | \"";\
399 echo "echo 1-4";\
400 | '${APO}'
401 echo 3
404 call mac2
405 echo 4
406 undefine *
407 ' > "${MBOX}"
409 check behave:x_opt_input_command_stack 0 "${MBOX}" '1786542668 416'
411 t_epilog
414 t_behave_X_errexit() {
415 t_prolog
417 ${cat} <<- '__EOT' > "${BODY}"
418 echo one
419 echos nono
420 echo two
421 __EOT
423 </dev/null ${MAILX} ${ARGS} -Snomemdebug \
424 -X'echo one' -X' echos nono ' -X'echo two' \
425 > "${MBOX}" 2>&1
426 check behave:x_errexit-1 0 "${MBOX}" '916157812 53'
428 </dev/null ${MAILX} ${ARGS} -X'source '"${BODY}" -Snomemdebug \
429 > "${MBOX}" 2>&1
430 check behave:x_errexit-2 0 "${MBOX}" '916157812 53'
432 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Snomemdebug \
433 > "${MBOX}" 2>&1
434 check behave:x_errexit-3 0 "${MBOX}" '916157812 53'
438 </dev/null ${MAILX} ${ARGS} -Serrexit -Snomemdebug \
439 -X'echo one' -X' echos nono ' -X'echo two' \
440 > "${MBOX}" 2>&1
441 check behave:x_errexit-4 1 "${MBOX}" '2118430867 49'
443 </dev/null ${MAILX} ${ARGS} -X'source '"${BODY}" -Serrexit -Snomemdebug \
444 > "${MBOX}" 2>&1
445 check behave:x_errexit-5 1 "${MBOX}" '2118430867 49'
447 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Serrexit -Snomemdebug \
448 > "${MBOX}" 2>&1
449 check behave:x_errexit-6 1 "${MBOX}" '12955965 172'
451 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Sposix -Snomemdebug \
452 > "${MBOX}" 2>&1
453 check behave:x_errexit-7 1 "${MBOX}" '12955965 172'
455 ## Repeat 4-7 with ignerr set
457 ${sed} -e 's/^echos /ignerr echos /' < "${BODY}" > "${MBOX}"
459 </dev/null ${MAILX} ${ARGS} -Serrexit -Snomemdebug \
460 -X'echo one' -X'ignerr echos nono ' -X'echo two' \
461 > "${BODY}" 2>&1
462 check behave:x_errexit-8 0 "${BODY}" '916157812 53'
464 </dev/null ${MAILX} ${ARGS} -X'source '"${MBOX}" -Serrexit -Snomemdebug \
465 > "${BODY}" 2>&1
466 check behave:x_errexit-9 0 "${BODY}" '916157812 53'
468 </dev/null MAILRC="${MBOX}" ${MAILX} ${ARGS} -:u -Serrexit -Snomemdebug \
469 > "${BODY}" 2>&1
470 check behave:x_errexit-10 0 "${BODY}" '916157812 53'
472 </dev/null MAILRC="${MBOX}" ${MAILX} ${ARGS} -:u -Sposix -Snomemdebug \
473 > "${BODY}" 2>&1
474 check behave:x_errexit-11 0 "${BODY}" '916157812 53'
476 t_epilog
479 t_behave_wysh() {
480 t_prolog
482 ${cat} <<- '__EOT' > "${BODY}"
484 echo abcd
485 echo a'b'c'd'
486 echo a"b"c"d"
487 echo a$'b'c$'d'
488 echo 'abcd'
489 echo "abcd"
490 echo $'abcd'
491 echo a\ b\ c\ d
492 echo a 'b c' d
493 echo a "b c" d
494 echo a $'b c' d
496 echo 'a$`"\'
497 echo "a\$\`'\"\\"
498 echo $'a\$`\'\"\\'
499 echo $'a\$`\'"\\'
500 # DIET=CURD TIED=
501 echo 'a${DIET}b${TIED}c\${DIET}d\${TIED}e' # COMMENT
502 echo "a${DIET}b${TIED}c\${DIET}d\${TIED}e"
503 echo $'a${DIET}b${TIED}c\${DIET}d\${TIED}e'
505 echo a$'\101\0101\x41\u0041\u41\U00000041\U41'c
506 echo a$'\u0041\u41\u0C1\U00000041\U41'c
507 echo a$'\377'c
508 echo a$'\0377'c
509 echo a$'\400'c
510 echo a$'\0400'c
511 echo a$'\U1100001'c
513 echo a$'b\0c'd
514 echo a$'b\00c'de
515 echo a$'b\000c'df
516 echo a$'b\0000c'dg
517 echo a$'b\x0c'dh
518 echo a$'b\x00c'di
519 echo a$'b\u0'dj
520 echo a$'b\u00'dk
521 echo a$'b\u000'dl
522 echo a$'b\u0000'dm
523 echo a$'b\U0'dn
524 echo a$'b\U00'do
525 echo a$'b\U000'dp
526 echo a$'b\U0000'dq
527 echo a$'b\U00000'dr
528 echo a$'b\U000000'ds
529 echo a$'b\U0000000'dt
530 echo a$'b\U00000000'du
532 echo a$'\cI'b
533 echo a$'\011'b
534 echo a$'\x9'b
535 echo a$'\u9'b
536 echo a$'\U9'b
537 echo a$'\c@'b c d
538 __EOT
540 if [ -z "${UTF8_LOCALE}" ]; then
541 echo 'Skip behave:wysh_unicode, no UTF8_LOCALE'
542 else
543 < "${BODY}" DIET=CURD TIED= \
544 LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} 2>/dev/null > "${MBOX}"
545 check behave:wysh_unicode 0 "${MBOX}" '475805847 317'
548 < "${BODY}" DIET=CURD TIED= ${MAILX} ${ARGS} > "${MBOX}" 2>/dev/null
549 check behave:wysh_c 0 "${MBOX}" '1473887148 321'
551 t_epilog
554 t_behave_input_inject_semicolon_seq() {
555 t_prolog
557 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
558 define mydeepmac {
559 echon '(mydeepmac)';
561 define mymac {
562 echon this_is_mymac;call mydeepmac;echon ';';
564 echon one';';call mymac;echon two";";call mymac;echo three$';';
565 define mymac {
566 echon this_is_mymac;call mydeepmac;echon ,TOO'!;';
568 echon one';';call mymac;echon two";";call mymac;echo three$';';
569 __EOT
571 check behave:input_inject_semicolon_seq 0 "${MBOX}" '512117110 140'
573 t_epilog
576 t_behave_commandalias() {
577 t_prolog
579 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
580 commandalias echo echo hoho
581 echo stop.
582 commandalias X Xx
583 commandalias Xx XxX
584 commandalias XxX XxXx
585 commandalias XxXx XxXxX
586 commandalias XxXxX XxXxXx
587 commandalias XxXxXx echo huhu
588 commandalias XxXxXxX echo huhu
590 commandalias XxXxXx XxXxXxX
592 uncommandalias echo
593 commandalias XxXxXx echo huhu
595 __EOT
597 check behave:commandalias 0 "${MBOX}" '3694143612 31'
599 t_epilog
602 t_behave_ifelse() {
603 t_prolog
605 # Nestable conditions test
606 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
607 if 0
608 echo 1.err
609 else
610 echo 1.ok
611 endif
612 if 1
613 echo 2.ok
614 else
615 echo 2.err
616 endif
617 if $dietcurd
618 echo 3.err
619 else
620 echo 3.ok
621 endif
622 set dietcurd=yoho
623 if $dietcurd
624 echo 4.ok
625 else
626 echo 4.err
627 endif
628 if $dietcurd == 'yoho'
629 echo 5.ok
630 else
631 echo 5.err
632 endif
633 if $dietcurd @== 'Yoho'
634 echo 5-1.ok
635 else
636 echo 5-1.err
637 endif
638 if $dietcurd == 'Yoho'
639 echo 5-2.err
640 else
641 echo 5-2.ok
642 endif
643 if $dietcurd != 'yoho'
644 echo 6.err
645 else
646 echo 6.ok
647 endif
648 if $dietcurd @!= 'Yoho'
649 echo 6-1.err
650 else
651 echo 6-1.ok
652 endif
653 if $dietcurd != 'Yoho'
654 echo 6-2.ok
655 else
656 echo 6-2.err
657 endif
658 # Nesting
659 if faLse
660 echo 7.err1
661 if tRue
662 echo 7.err2
663 if yEs
664 echo 7.err3
665 else
666 echo 7.err4
667 endif
668 echo 7.err5
669 endif
670 echo 7.err6
671 else
672 echo 7.ok7
673 if YeS
674 echo 7.ok8
675 if No
676 echo 7.err9
677 else
678 echo 7.ok9
679 endif
680 echo 7.ok10
681 else
682 echo 7.err11
683 if yeS
684 echo 7.err12
685 else
686 echo 7.err13
687 endif
688 endif
689 echo 7.ok14
690 endif
691 if r
692 echo 8.ok1
693 if R
694 echo 8.ok2
695 else
696 echo 8.err2
697 endif
698 echo 8.ok3
699 else
700 echo 8.err1
701 endif
702 if s
703 echo 9.err1
704 else
705 echo 9.ok1
706 if S
707 echo 9.err2
708 else
709 echo 9.ok2
710 endif
711 echo 9.ok3
712 endif
713 # `elif'
714 if $dietcurd == 'yohu'
715 echo 10.err1
716 elif $dietcurd == 'yoha'
717 echo 10.err2
718 elif $dietcurd == 'yohe'
719 echo 10.err3
720 elif $dietcurd == 'yoho'
721 echo 10.ok1
722 if $dietcurd == 'yohu'
723 echo 10.err4
724 elif $dietcurd == 'yoha'
725 echo 10.err5
726 elif $dietcurd == 'yohe'
727 echo 10.err6
728 elif $dietcurd == 'yoho'
729 echo 10.ok2
730 if $dietcurd == 'yohu'
731 echo 10.err7
732 elif $dietcurd == 'yoha'
733 echo 10.err8
734 elif $dietcurd == 'yohe'
735 echo 10.err9
736 elif $dietcurd == 'yoho'
737 echo 10.ok3
738 else
739 echo 10.err10
740 endif
741 else
742 echo 10.err11
743 endif
744 else
745 echo 10.err12
746 endif
747 # integer
748 set dietcurd=10
749 if $dietcurd -lt 11
750 echo 11.ok1
751 if $dietcurd -gt 9
752 echo 11.ok2
753 else
754 echo 11.err2
755 endif
756 if $dietcurd -eq 10
757 echo 11.ok3
758 else
759 echo 11.err3
760 endif
761 if $dietcurd -ge 10
762 echo 11.ok4
763 else
764 echo 11.err4
765 endif
766 if $dietcurd -le 10
767 echo 11.ok5
768 else
769 echo 11.err5
770 endif
771 if $dietcurd -ge 11
772 echo 11.err6
773 else
774 echo 11.ok6
775 endif
776 if $dietcurd -le 9
777 echo 11.err7
778 else
779 echo 11.ok7
780 endif
781 else
782 echo 11.err1
783 endif
784 set dietcurd=Abc
785 if $dietcurd < aBd
786 echo 12.ok1
787 if $dietcurd @> abB
788 echo 12.ok2
789 else
790 echo 12.err2
791 endif
792 if $dietcurd @== aBC
793 echo 12.ok3
794 else
795 echo 12.err3
796 endif
797 if $dietcurd @>= AbC
798 echo 12.ok4
799 else
800 echo 12.err4
801 endif
802 if $dietcurd @<= ABc
803 echo 12.ok5
804 else
805 echo 12.err5
806 endif
807 if $dietcurd @>= abd
808 echo 12.err6
809 else
810 echo 12.ok6
811 endif
812 if $dietcurd @<= abb
813 echo 12.err7
814 else
815 echo 12.ok7
816 endif
817 else
818 echo 12.err1
819 endif
820 if $dietcurd < aBc
821 echo 12-1.ok
822 else
823 echo 12-1.err
824 endif
825 if $dietcurd @< aBc
826 echo 12-2.err
827 else
828 echo 12-2.ok
829 endif
830 if $dietcurd > ABc
831 echo 12-3.ok
832 else
833 echo 12-3.err
834 endif
835 if $dietcurd @> ABc
836 echo 12-3.err
837 else
838 echo 12-3.ok
839 endif
840 if $dietcurd @i=% aB
841 echo 13.ok
842 else
843 echo 13.err
844 endif
845 if $dietcurd =% aB
846 echo 13-1.err
847 else
848 echo 13-1.ok
849 endif
850 if $dietcurd @=% bC
851 echo 14.ok
852 else
853 echo 14.err
854 endif
855 if $dietcurd !% aB
856 echo 15-1.ok
857 else
858 echo 15-1.err
859 endif
860 if $dietcurd @!% aB
861 echo 15-2.err
862 else
863 echo 15-2.ok
864 endif
865 if $dietcurd !% bC
866 echo 15-3.ok
867 else
868 echo 15-3.err
869 endif
870 if $dietcurd @!% bC
871 echo 15-4.err
872 else
873 echo 15-4.ok
874 endif
875 if $dietcurd =% Cd
876 echo 16.err
877 else
878 echo 16.ok
879 endif
880 if $dietcurd !% Cd
881 echo 17.ok
882 else
883 echo 17.err
884 endif
885 set diet=abc curd=abc
886 if $diet == $curd
887 echo 18.ok
888 else
889 echo 18.err
890 endif
891 set diet=abc curd=abcd
892 if $diet != $curd
893 echo 19.ok
894 else
895 echo 19.err
896 endif
897 # 1. Shitty grouping capabilities as of today
898 unset diet curd ndefined
899 if [ [ false ] || [ false ] || [ true ] ] && [ [ false ] || [ true ] ] && \
900 [ yes ]
901 echo 20.ok
902 else
903 echo 20.err
904 endif
905 if [ [ [ [ 0 ] || [ 1 ] ] && [ [ 1 ] || [ 0 ] ] ] && [ 1 ] ] && [ yes ]
906 echo 21.ok
907 else
908 echo 21.err
909 endif
910 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] ]
911 echo 22.ok
912 else
913 echo 22.err
914 endif
915 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] ]
916 echo 23.ok
917 else
918 echo 23.err
919 endif
920 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] && [ no ]
921 echo 24.err
922 else
923 echo 24.ok
924 endif
925 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] \
926 && [ no ] || [ yes ]
927 echo 25.ok
928 else
929 echo 25.err
930 endif
931 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
932 echo 26.ok
933 else
934 echo 26.err
935 endif
936 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 0 ] ]
937 echo 27.err
938 else
939 echo 27.ok
940 endif
941 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 0 ] ] && [ 1 ] ] ] && [ 1 ] ]
942 echo 28.err
943 else
944 echo 28.ok
945 endif
946 if [ [ [ [ [ [ [ 0 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
947 echo 29.err
948 else
949 echo 29.ok
950 endif
951 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 0 ]
952 echo 30.err
953 else
954 echo 30.ok
955 endif
956 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 1 ]
957 echo 31.ok
958 else
959 echo 31.err
960 endif
961 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ]
962 echo 32.err
963 else
964 echo 32.ok
965 endif
966 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 1 ]
967 echo 33.ok
968 else
969 echo 33.err
970 endif
971 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 0 ]
972 echo 34.err
973 else
974 echo 34.ok
975 endif
976 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 1 ]
977 echo 35.ok
978 else
979 echo 35.err
980 endif
981 set diet=yo curd=ho
982 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
983 echo 36.err
984 else
985 echo 36.ok
986 endif
987 set ndefined
988 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
989 echo 37.ok
990 else
991 echo 37.err
992 endif
993 # 2. Shitty grouping capabilities as of today
994 unset diet curd ndefined
995 if [ false || false || true ] && [ false || true ] && yes
996 echo 40.ok
997 else
998 echo 40.err
999 endif
1000 if [ [ [ 0 || 1 ] && [ 1 || 0 ] ] && 1 ] && [ yes ]
1001 echo 41.ok
1002 else
1003 echo 41.err
1004 endif
1005 if [ 1 || 0 || 0 || 0 ]
1006 echo 42.ok
1007 else
1008 echo 42.err
1009 endif
1010 if [ 1 || 0 || 0 || 0 || [ 1 ] ]
1011 echo 43.ok
1012 else
1013 echo 43.err
1014 endif
1015 if [ 1 || 0 || 0 || 0 || [ 1 ] || 1 ] && no
1016 echo 44.err
1017 else
1018 echo 44.ok
1019 endif
1020 if [ 1 || 0 || 0 || 0 || 1 || [ 1 ] ] && no || [ yes ]
1021 echo 45.ok
1022 else
1023 echo 45.err
1024 endif
1025 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && 1 ] ] && [ 1 ] ]
1026 echo 46.ok
1027 else
1028 echo 46.err
1029 endif
1030 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && [ 1 ] ] ] && 0 ]
1031 echo 47.err
1032 else
1033 echo 47.ok
1034 endif
1035 if [ [ [ [ [ [ [ 1 ] ] && 1 ] && 0 ] && [ 1 ] ] ] && 1 ]
1036 echo 48.err
1037 else
1038 echo 48.ok
1039 endif
1040 if [ [ [ [ [ [ 0 ] && 1 ] && 1 ] && 1 ] ] && 1 ]
1041 echo 49.err
1042 else
1043 echo 49.ok
1044 endif
1045 if 1 || 0 || 0 || 0 && 0
1046 echo 50.err
1047 else
1048 echo 50.ok
1049 endif
1050 if 1 || 0 || 0 || 0 && 1
1051 echo 51.ok
1052 else
1053 echo 51.err
1054 endif
1055 if 0 || 0 || 0 || 1 && 0
1056 echo 52.err
1057 else
1058 echo 52.ok
1059 endif
1060 if 0 || 0 || 0 || 1 && 1
1061 echo 53.ok
1062 else
1063 echo 53.err
1064 endif
1065 if 0 || 0 || 0 || 1 && 0 || 1 && 0
1066 echo 54.err
1067 else
1068 echo 54.ok
1069 endif
1070 if 0 || 0 || 0 || 1 && 0 || 1 && 1
1071 echo 55.ok
1072 else
1073 echo 55.err
1074 endif
1075 set diet=yo curd=ho
1076 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
1077 echo 56.err
1078 else
1079 echo 56.ok
1080 endif
1081 if $diet == 'yo' && $curd == 'ho' && $ndefined
1082 echo 57.err
1083 else
1084 echo 57.ok
1085 endif
1086 set ndefined
1087 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
1088 echo 57.ok
1089 else
1090 echo 57.err
1091 endif
1092 if $diet == 'yo' && $curd == 'ho' && $ndefined
1093 echo 58.ok
1094 else
1095 echo 58.err
1096 endif
1097 if [ [ [ [ [ [ $diet == 'yo' && $curd == 'ho' && $ndefined ] ] ] ] ] ]
1098 echo 59.ok
1099 else
1100 echo 59.err
1101 endif
1102 # Some more en-braced variables
1103 set diet=yo curd=ho
1104 if ${diet} == ${curd}
1105 echo 70.err
1106 else
1107 echo 70.ok
1108 endif
1109 if ${diet} != ${curd}
1110 echo 71.ok
1111 else
1112 echo 71.err
1113 endif
1114 if $diet == ${curd}
1115 echo 72.err
1116 else
1117 echo 72.ok
1118 endif
1119 if ${diet} == $curd
1120 echo 73.err
1121 else
1122 echo 73.ok
1123 endif
1124 # Unary !
1125 if ! 0 && ! ! 1 && ! ! ! ! 2 && 3
1126 echo 80.ok
1127 else
1128 echo 80.err
1129 endif
1130 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ ! 2 ] ] ] && 3
1131 echo 81.ok
1132 else
1133 echo 81.err
1134 endif
1135 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1136 echo 82.ok
1137 else
1138 echo 82.err
1139 endif
1140 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
1141 echo 83.err
1142 else
1143 echo 83.ok
1144 endif
1145 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
1146 echo 84.err
1147 else
1148 echo 84.ok
1149 endif
1150 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1151 echo 85.err
1152 else
1153 echo 85.ok
1154 endif
1155 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1156 echo 86.err
1157 else
1158 echo 86.ok
1159 endif
1160 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] || 3
1161 echo 87.ok
1162 else
1163 echo 87.err
1164 endif
1165 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! ! [ 2 ] ] ] ] ]
1166 echo 88.ok
1167 else
1168 echo 88.err
1169 endif
1170 # Unary !, odd
1171 if ! 0 && ! ! 1 && ! ! ! 0 && 3
1172 echo 90.ok
1173 else
1174 echo 90.err
1175 endif
1176 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ 0 ] ] ] && 3
1177 echo 91.ok
1178 else
1179 echo 91.err
1180 endif
1181 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ [ 0 ] ] ] ] ] && 3
1182 echo 92.ok
1183 else
1184 echo 92.err
1185 endif
1186 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! ! [ ! [ ! 0 ] ] ] ] && ! 3
1187 echo 93.err
1188 else
1189 echo 93.ok
1190 endif
1191 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ ! [ ! [ ! [ ! 0 ] ] ] ] && 3
1192 echo 94.ok
1193 else
1194 echo 94.err
1195 endif
1196 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! ! [ ! [ ! [ ! [ 0 ] ] ] ] ] && 3
1197 echo 95.err
1198 else
1199 echo 95.ok
1200 endif
1201 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! ! 0 ] ] ] ] && 3
1202 echo 96.err
1203 else
1204 echo 96.ok
1205 endif
1206 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ ! 0 ] ] ] ] ] || 3
1207 echo 97.ok
1208 else
1209 echo 97.err
1210 endif
1211 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! [ 0 ] ] ] ] ]
1212 echo 98.ok
1213 else
1214 echo 98.err
1215 endif
1216 __EOT
1218 check behave:if-normal 0 "${MBOX}" '1688759742 719'
1220 if have_feat regex; then
1221 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
1222 set dietcurd=yoho
1223 if $dietcurd =~ '^yo.*'
1224 echo 1.ok
1225 else
1226 echo 1.err
1227 endif
1228 if $dietcurd =~ '^Yo.*'
1229 echo 1-1.err
1230 else
1231 echo 1-1.ok
1232 endif
1233 if $dietcurd @=~ '^Yo.*'
1234 echo 1-2.ok
1235 else
1236 echo 1-2.err
1237 endif
1238 if $dietcurd =~ '^yOho.+'
1239 echo 2.err
1240 else
1241 echo 2.ok
1242 endif
1243 if $dietcurd @!~ '.*Ho$'
1244 echo 3.err
1245 else
1246 echo 3.ok
1247 endif
1248 if $dietcurd !~ '.+yohO$'
1249 echo 4.ok
1250 else
1251 echo 4.err
1252 endif
1253 if [ $dietcurd @i!~ '.+yoho$' ]
1254 echo 5.ok
1255 else
1256 echo 5.err
1257 endif
1258 if ! [ $dietcurd @i=~ '.+yoho$' ]
1259 echo 6.ok
1260 else
1261 echo 6.err
1262 endif
1263 if ! ! [ $dietcurd @i!~ '.+yoho$' ]
1264 echo 7.ok
1265 else
1266 echo 7.err
1267 endif
1268 if ! [ ! [ $dietcurd @i!~ '.+yoho$' ] ]
1269 echo 8.ok
1270 else
1271 echo 8.err
1272 endif
1273 if [ ! [ ! [ $dietcurd @i!~ '.+yoho$' ] ] ]
1274 echo 9.ok
1275 else
1276 echo 9.err
1277 endif
1278 if ! [ ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
1279 echo 10.err
1280 else
1281 echo 10.ok
1282 endif
1283 if ! ! ! $dietcurd !~ '.+yoho$'
1284 echo 11.err
1285 else
1286 echo 11.ok
1287 endif
1288 if ! ! ! $dietcurd =~ '.+yoho$'
1289 echo 12.ok
1290 else
1291 echo 12.err
1292 endif
1293 if ! [ ! ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
1294 echo 13.ok
1295 else
1296 echo 13.err
1297 endif
1298 set diet=abc curd='^abc$'
1299 if $diet =~ $curd
1300 echo 14.ok
1301 else
1302 echo 14.err
1303 endif
1304 set diet=abc curd='^abcd$'
1305 if $diet !~ $curd
1306 echo 15.ok
1307 else
1308 echo 15.err
1309 endif
1310 __EOT
1312 check behave:if-regex 0 "${MBOX}" '1115671789 95'
1313 else
1314 printf 'behave:if-regex: unsupported, skipped\n'
1317 t_epilog
1320 t_behave_localopts() {
1321 t_prolog
1323 # Nestable conditions test
1324 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
1325 define t2 {
1326 echo in: t2
1327 set t2=t2
1328 echo $t2
1330 define t1 {
1331 echo in: t1
1332 set gv1=gv1
1333 localopts on
1334 set lv1=lv1 lv2=lv2
1335 set lv3=lv3
1336 call t2
1337 localopts off
1338 set gv2=gv2
1339 echo $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2
1341 define t0 {
1342 echo in: t0
1343 call t1
1344 echo $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2
1345 echo "$gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2"
1347 account trouble {
1348 echo in: trouble
1349 call t0
1351 call t0
1352 unset gv1 gv2
1353 account trouble
1354 echo active trouble: $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t3
1355 account null
1356 echo active null: $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t3
1359 define ll2 {
1360 localopts $1
1361 set x=2
1362 echo ll2=$x
1364 define ll1 {
1365 wysh set y=$1; shift; eval localopts $y; localopts $1; shift
1366 set x=1
1367 echo ll1.1=$x
1368 call ll2 $1
1369 echo ll1.2=$x
1371 define ll0 {
1372 wysh set y=$1; shift; eval localopts $y; localopts $1; shift
1373 set x=0
1374 echo ll0.1=$x
1375 call ll1 $y "$@"
1376 echo ll0.2=$x
1378 define llx {
1379 echo ----- $1: $2 -> $3 -> $4
1380 echo ll-1.1=$x
1381 eval localopts $1
1382 call ll0 "$@"
1383 echo ll-1.2=$x
1384 unset x
1386 define lly {
1387 call llx 'call off' on on on
1388 call llx 'call off' off on on
1389 call llx 'call off' on off on
1390 call llx 'call off' on off off
1391 localopts call-fixate on
1392 call llx 'call-fixate on' on on on
1393 call llx 'call-fixate on' off on on
1394 call llx 'call-fixate on' on off on
1395 call llx 'call-fixate on' on off off
1396 unset x;localopts call on
1397 call llx 'call on' on on on
1398 call llx 'call on' off on on
1399 call llx 'call on' on off on
1400 call llx 'call on' on off off
1402 call lly
1403 __EOT
1405 check behave:localopts 0 "${MBOX}" '4016155249 1246'
1407 t_epilog
1410 t_behave_macro_param_shift() {
1411 t_prolog
1413 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>/dev/null
1414 define t2 {
1415 echo in: t2
1416 echo t2.0 has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1417 localopts on
1418 wysh set ignerr=$1
1419 shift
1420 localopts off
1421 echo t2.1 has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1422 if [ $# > 1 ] || [ $ignerr == '' ]
1423 shift 2
1424 else
1425 ignerr shift 2
1426 endif
1427 echo t2.2:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1428 shift 0
1429 echo t2.3:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1430 if [ $# > 0 ]
1431 shift
1432 endif
1433 echo t2.4:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1435 define t1 {
1436 set errexit
1437 echo in: t1
1438 call t2 1 you get four args
1439 echo t1.1: $?';' ignerr ($ignerr) should not exist
1440 call t2 1 you get 'three args'
1441 echo t1.2: $?';' ignerr ($ignerr) should not exist
1442 call t2 1 you 'get two args'
1443 echo t1.3: $?';' ignerr ($ignerr) should not exist
1444 call t2 1 'you get one arg'
1445 echo t1.4: $?';' ignerr ($ignerr) should not exist
1446 ignerr call t2 '' 'you get one arg'
1447 echo t1.5: $?';' ignerr ($ignerr) should not exist
1449 call t1
1450 __EOT
1452 check behave:macro_param_shift 0 "${MBOX}" '1402489146 1682'
1454 t_epilog
1457 t_behave_addrcodec() {
1458 t_prolog
1460 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
1461 vput addrcodec res e 1 <doog@def>
1462 echo $?/$^ERRNAME $res
1463 eval vput addrcodec res d $res
1464 echo $?/$^ERRNAME $res
1465 vput addrcodec res e 2 . <doog@def>
1466 echo $?/$^ERRNAME $res
1467 eval vput addrcodec res d $res
1468 echo $?/$^ERRNAME $res
1469 vput addrcodec res e 3 Sauer Dr. <doog@def>
1470 echo $?/$^ERRNAME $res
1471 eval vput addrcodec res d $res
1472 echo $?/$^ERRNAME $res
1473 vput addrcodec res e 3.50 Sauer (Ma) Dr. <doog@def>
1474 echo $?/$^ERRNAME $res
1475 eval vput addrcodec res d $res
1476 echo $?/$^ERRNAME $res
1477 vput addrcodec res e 3.51 Sauer (Ma) "Dr." <doog@def>
1478 echo $?/$^ERRNAME $res
1479 eval vput addrcodec res d $res
1480 echo $?/$^ERRNAME $res
1482 vput addrcodec res +e 4 Sauer (Ma) Dr. <doog@def>
1483 echo $?/$^ERRNAME $res
1484 eval vput addrcodec res d $res
1485 echo $?/$^ERRNAME $res
1486 vput addrcodec res +e 5 Sauer (Ma) Braten Dr. <doog@def>
1487 echo $?/$^ERRNAME $res
1488 eval vput addrcodec res d $res
1489 echo $?/$^ERRNAME $res
1490 vput addrcodec res +e 6 Sauer (Ma) Braten Dr. (Heu) <doog@def>
1491 echo $?/$^ERRNAME $res
1492 eval vput addrcodec res d $res
1493 echo $?/$^ERRNAME $res
1494 vput addrcodec res +e 7 Sauer (Ma) Braten Dr. (Heu) <doog@def> (bu)
1495 echo $?/$^ERRNAME $res
1496 eval vput addrcodec res d $res
1497 echo $?/$^ERRNAME $res
1498 vput addrcodec res +e 8 \
1499 Dr. Sauer (Ma) Braten Dr. (Heu) <doog@def> (bu) Boom. Boom
1500 echo $?/$^ERRNAME $res
1501 eval vput addrcodec res d $res
1502 echo $?/$^ERRNAME $res
1503 vput addrcodec res +e 9 Dr.Sauer(Ma)Braten Dr. (Heu) <doog@def>
1504 echo $?/$^ERRNAME $res
1505 eval vput addrcodec res d $res
1506 echo $?/$^ERRNAME $res
1507 vput addrcodec res +e 10 (Ma)Braten Dr. (Heu) <doog@def>
1508 echo $?/$^ERRNAME $res
1509 eval vput addrcodec res d $res
1510 echo $?/$^ERRNAME $res
1511 vput addrcodec res +e 11 (Ma)Braten Dr"." (Heu) <doog@def>
1512 echo $?/$^ERRNAME $res
1513 eval vput addrcodec res d $res
1514 echo $?/$^ERRNAME $res
1515 vput addrcodec res +e 12 Dr. Sauer (Ma) Braten Dr. (u) <doog@def>
1516 echo $?/$^ERRNAME $res
1517 eval vput addrcodec res d $res
1518 echo $?/$^ERRNAME $res
1519 vput addrcodec res +e 13(Ma)Braten Dr. (Heu) <doog@def>
1520 echo $?/$^ERRNAME $res
1521 eval vput addrcodec res d $res
1522 echo $?/$^ERRNAME $res
1523 vput addrcodec res +e 14 Hey, Du <doog@def> Wie() findet Dr. das? ()
1524 echo $?/$^ERRNAME $res
1525 eval vput addrcodec res d $res
1526 echo $?/$^ERRNAME $res
1527 vput addrcodec res +e 15 \
1528 Hey, Du <doog@def> Wie() findet "" Dr. "" das? ()
1529 echo $?/$^ERRNAME $res
1530 eval vput addrcodec res d $res
1531 echo $?/$^ERRNAME $res
1532 vput addrcodec res +e 16 \
1533 "Hey," "Du" <doog@def> "Wie()" findet "" Dr. "" das? ()
1534 echo $?/$^ERRNAME $res
1535 eval vput addrcodec res d $res
1536 echo $?/$^ERRNAME $res
1537 vput addrcodec res +e 17 \
1538 "Hey" Du <doog@def> "Wie() findet " " Dr. """ das? ()
1539 echo $?/$^ERRNAME $res
1540 eval vput addrcodec res d $res
1541 echo $?/$^ERRNAME $res
1542 vput addrcodec res +e 18 \
1543 <doog@def> "Hey" Du "Wie() findet " " Dr. """ das? ()
1544 echo $?/$^ERRNAME $res
1545 eval vput addrcodec res d $res
1546 echo $?/$^ERRNAME $res
1547 vput addrcodec res +e 19 Hey\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1548 echo $?/$^ERRNAME $res
1549 eval vput addrcodec res d $res
1550 echo $?/$^ERRNAME $res
1552 vput addrcodec res ++e 20 Hey\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1553 echo $?/$^ERRNAME $res
1554 vput addrcodec res ++e 21 Hey\,\"" <doog@def> "Wie()" findet \" Dr. \" das?
1555 echo $?/$^ERRNAME $res
1556 eval vput addrcodec res d $res
1557 echo $?/$^ERRNAME $res
1559 vput addrcodec res +++e 22 Hey\\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1560 echo $?/$^ERRNAME $res
1561 eval vput addrcodec res d $res
1562 echo $?/$^ERRNAME $res
1564 vput addrcodec res s \
1565 "23 Hey\\,\\\" \"Wie" () "\" findet \\\" Dr. \\\" das?" <doog@def>
1566 echo $?/$^ERRNAME $res
1567 __EOT
1569 check behave:addrcodec 0 "${MBOX}" '429099645 2414'
1571 t_epilog
1574 t_behave_vexpr() {
1575 t_prolog
1577 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>/dev/null
1578 vput vexpr res = 9223372036854775807
1579 echo $?/$^ERRNAME $res
1580 vput vexpr res = 9223372036854775808
1581 echo $?/$^ERRNAME $res
1582 vput vexpr res =@ 9223372036854775808
1583 echo $?/$^ERRNAME $res
1584 vput vexpr res = -9223372036854775808
1585 echo $?/$^ERRNAME $res
1586 vput vexpr res = -9223372036854775809
1587 echo $?/$^ERRNAME $res
1588 vput vexpr res =@ -9223372036854775809
1589 echo $?/$^ERRNAME $res
1590 echo ' #1'
1591 vput vexpr res ~ 0
1592 echo $?/$^ERRNAME $res
1593 vput vexpr res ~ 1
1594 echo $?/$^ERRNAME $res
1595 vput vexpr res ~ -1
1596 echo $?/$^ERRNAME $res
1597 echo ' #2'
1598 vput vexpr res + 0 0
1599 echo $?/$^ERRNAME $res
1600 vput vexpr res + 0 1
1601 echo $?/$^ERRNAME $res
1602 vput vexpr res + 1 1
1603 echo $?/$^ERRNAME $res
1604 echo ' #3'
1605 vput vexpr res + 9223372036854775807 0
1606 echo $?/$^ERRNAME $res
1607 vput vexpr res + 9223372036854775807 1
1608 echo $?/$^ERRNAME $res
1609 vput vexpr res +@ 9223372036854775807 1
1610 echo $?/$^ERRNAME $res
1611 vput vexpr res + 0 9223372036854775807
1612 echo $?/$^ERRNAME $res
1613 vput vexpr res + 1 9223372036854775807
1614 echo $?/$^ERRNAME $res
1615 vput vexpr res +@ 1 9223372036854775807
1616 echo $?/$^ERRNAME $res
1617 echo ' #4'
1618 vput vexpr res + -9223372036854775808 0
1619 echo $?/$^ERRNAME $res
1620 vput vexpr res + -9223372036854775808 -1
1621 echo $?/$^ERRNAME $res
1622 vput vexpr res +@ -9223372036854775808 -1
1623 echo $?/$^ERRNAME $res
1624 vput vexpr res + 0 -9223372036854775808
1625 echo $?/$^ERRNAME $res
1626 vput vexpr res + -1 -9223372036854775808
1627 echo $?/$^ERRNAME $res
1628 vput vexpr res +@ -1 -9223372036854775808
1629 echo $?/$^ERRNAME $res
1630 echo ' #5'
1631 vput vexpr res - 0 0
1632 echo $?/$^ERRNAME $res
1633 vput vexpr res - 0 1
1634 echo $?/$^ERRNAME $res
1635 vput vexpr res - 1 1
1636 echo $?/$^ERRNAME $res
1637 echo ' #6'
1638 vput vexpr res - 9223372036854775807 0
1639 echo $?/$^ERRNAME $res
1640 vput vexpr res - 9223372036854775807 -1
1641 echo $?/$^ERRNAME $res
1642 vput vexpr res -@ 9223372036854775807 -1
1643 echo $?/$^ERRNAME $res
1644 vput vexpr res - 0 9223372036854775807
1645 echo $?/$^ERRNAME $res
1646 vput vexpr res - -1 9223372036854775807
1647 echo $?/$^ERRNAME $res
1648 vput vexpr res - -2 9223372036854775807
1649 echo $?/$^ERRNAME $res
1650 vput vexpr res -@ -2 9223372036854775807
1651 echo $?/$^ERRNAME $res
1652 echo ' #7'
1653 vput vexpr res - -9223372036854775808 +0
1654 echo $?/$^ERRNAME $res
1655 vput vexpr res - -9223372036854775808 +1
1656 echo $?/$^ERRNAME $res
1657 vput vexpr res -@ -9223372036854775808 +1
1658 echo $?/$^ERRNAME $res
1659 vput vexpr res - 0 -9223372036854775808
1660 echo $?/$^ERRNAME $res
1661 vput vexpr res - +1 -9223372036854775808
1662 echo $?/$^ERRNAME $res
1663 vput vexpr res -@ +1 -9223372036854775808
1664 echo $?/$^ERRNAME $res
1665 echo ' #8'
1666 vput vexpr res + -13 -2
1667 echo $?/$^ERRNAME $res
1668 vput vexpr res - 0 0
1669 echo $?/$^ERRNAME $res
1670 vput vexpr res - 0 1
1671 echo $?/$^ERRNAME $res
1672 vput vexpr res - 1 1
1673 echo $?/$^ERRNAME $res
1674 vput vexpr res - -13 -2
1675 echo $?/$^ERRNAME $res
1676 echo ' #9'
1677 vput vexpr res * 0 0
1678 echo $?/$^ERRNAME $res
1679 vput vexpr res * 0 1
1680 echo $?/$^ERRNAME $res
1681 vput vexpr res * 1 1
1682 echo $?/$^ERRNAME $res
1683 vput vexpr res * -13 -2
1684 echo $?/$^ERRNAME $res
1685 echo ' #10'
1686 vput vexpr res / 0 0
1687 echo $?/$^ERRNAME $res
1688 vput vexpr res / 0 1
1689 echo $?/$^ERRNAME $res
1690 vput vexpr res / 1 1
1691 echo $?/$^ERRNAME $res
1692 vput vexpr res / -13 -2
1693 echo $?/$^ERRNAME $res
1694 echo ' #11'
1695 vput vexpr res % 0 0
1696 echo $?/$^ERRNAME $res
1697 vput vexpr res % 0 1
1698 echo $?/$^ERRNAME $res
1699 vput vexpr res % 1 1
1700 echo $?/$^ERRNAME $res
1701 vput vexpr res % -13 -2
1702 echo $?/$^ERRNAME $res
1703 __EOT
1705 check behave:vexpr-numeric 0 "${MBOX}" '1723609217 1048'
1707 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" #2>/dev/null
1708 vput vexpr res find 'bananarama' 'nana'
1709 echo $?/$^ERRNAME :$res:
1710 vput vexpr res find 'bananarama' 'bana'
1711 echo $?/$^ERRNAME :$res:
1712 vput vexpr res find 'bananarama' 'Bana'
1713 echo $?/$^ERRNAME :$res:
1714 vput vexpr res find 'bananarama' 'rama'
1715 echo $?/$^ERRNAME :$res:
1716 echo ' #1'
1717 vput vexpr res ifind 'bananarama' 'nana'
1718 echo $?/$^ERRNAME :$res:
1719 vput vexpr res ifind 'bananarama' 'bana'
1720 echo $?/$^ERRNAME :$res:
1721 vput vexpr res ifind 'bananarama' 'Bana'
1722 echo $?/$^ERRNAME :$res:
1723 vput vexpr res ifind 'bananarama' 'rama'
1724 echo $?/$^ERRNAME :$res:
1725 echo ' #2'
1726 vput vexpr res substring 'bananarama' 1
1727 echo $?/$^ERRNAME :$res:
1728 vput vexpr res substring 'bananarama' 3
1729 echo $?/$^ERRNAME :$res:
1730 vput vexpr res substring 'bananarama' 5
1731 echo $?/$^ERRNAME :$res:
1732 vput vexpr res substring 'bananarama' 7
1733 echo $?/$^ERRNAME :$res:
1734 vput vexpr res substring 'bananarama' 9
1735 echo $?/$^ERRNAME :$res:
1736 vput vexpr res substring 'bananarama' 10
1737 echo $?/$^ERRNAME :$res:
1738 vput vexpr res substring 'bananarama' 1 3
1739 echo $?/$^ERRNAME :$res:
1740 vput vexpr res substring 'bananarama' 3 3
1741 echo $?/$^ERRNAME :$res:
1742 vput vexpr res substring 'bananarama' 5 3
1743 echo $?/$^ERRNAME :$res:
1744 vput vexpr res substring 'bananarama' 7 3
1745 echo $?/$^ERRNAME :$res:
1746 vput vexpr res substring 'bananarama' 9 3
1747 echo $?/$^ERRNAME :$res:
1748 vput vexpr res substring 'bananarama' 10 3
1749 echo $?/$^ERRNAME :$res:
1750 echo ' #3'
1751 __EOT
1753 check behave:vexpr-string 0 "${MBOX}" '265398700 267'
1755 if have_feat regex; then
1756 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" #2>/dev/null
1757 vput vexpr res regex 'bananarama' 'nana'
1758 echo $?/$^ERRNAME :$res:
1759 vput vexpr res regex 'bananarama' 'bana'
1760 echo $?/$^ERRNAME :$res:
1761 vput vexpr res regex 'bananarama' 'Bana'
1762 echo $?/$^ERRNAME :$res:
1763 vput vexpr res regex 'bananarama' 'rama'
1764 echo $?/$^ERRNAME :$res:
1765 echo ' #1'
1766 vput vexpr res iregex 'bananarama' 'nana'
1767 echo $?/$^ERRNAME :$res:
1768 vput vexpr res iregex 'bananarama' 'bana'
1769 echo $?/$^ERRNAME :$res:
1770 vput vexpr res iregex 'bananarama' 'Bana'
1771 echo $?/$^ERRNAME :$res:
1772 vput vexpr res iregex 'bananarama' 'rama'
1773 echo $?/$^ERRNAME :$res:
1774 echo ' #2'
1775 vput vexpr res regex 'bananarama' '(.*)nana(.*)' '\${1}a\${0}u{\$2}'
1776 echo $?/$^ERRNAME :$res:
1777 vput vexpr res regex 'bananarama' '(.*)bana(.*)' '\${1}a\${0}u\$2'
1778 echo $?/$^ERRNAME :$res:
1779 vput vexpr res regex 'bananarama' 'Bana(.+)' '\$1\$0'
1780 echo $?/$^ERRNAME :$res:
1781 vput vexpr res regex 'bananarama' '(.+)rama' '\$1\$0'
1782 echo $?/$^ERRNAME :$res:
1783 echo ' #3'
1784 vput vexpr res iregex 'bananarama' '(.*)nana(.*)' '\${1}a\${0}u{\$2}'
1785 echo $?/$^ERRNAME :$res:
1786 vput vexpr res iregex 'bananarama' '(.*)bana(.*)' '\${1}a\${0}u\$2'
1787 echo $?/$^ERRNAME :$res:
1788 vput vexpr res iregex 'bananarama' 'Bana(.+)' '\$1\$0'
1789 echo $?/$^ERRNAME :$res:
1790 vput vexpr res iregex 'bananarama' '(.+)rama' '\$1\$0'
1791 echo $?/$^ERRNAME :$res:
1792 echo ' #4'
1793 __EOT
1795 check behave:vexpr-regex 0 "${MBOX}" '3270360157 311'
1796 else
1797 printf 'behave:vexpr-regex: unsupported, skipped\n'
1800 t_epilog
1803 t_behave_call_ret() {
1804 t_prolog
1806 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Snomemdebug > "${MBOX}" 2>&1
1807 define w1 {
1808 echon ">$1 "
1809 vput vexpr i + $1 1
1810 if [ $i -le 42 ]
1811 vput vexpr j '&' $i 7
1812 if [ $j -eq 7 ]
1813 echo .
1815 call w1 $i
1816 wysh set i=$? k=$!
1817 vput vexpr j '&' $i 7
1818 echon "<$1/$i/$k "
1819 if [ $j -eq 7 ]
1820 echo .
1822 else
1823 echo ! The end for $1
1825 return $1
1827 # Transport $?/$! up the call chain
1828 define w2 {
1829 echon ">$1 "
1830 vput vexpr i + $1 1
1831 if [ $1 -lt 42 ]
1832 call w2 $i
1833 wysh set i=$? j=$! k=$^ERRNAME
1834 echon "<$1/$i/$k "
1835 return $i $j
1836 else
1837 echo ! The end for $1
1838 return $i $^ERR-BUSY
1840 echoerr au
1842 # Up and down it goes
1843 define w3 {
1844 echon ">$1/$2 "
1845 vput vexpr i + $1 1
1846 if [ $1 -lt 42 ]
1847 call w3 $i $2
1848 wysh set i=$? j=$!
1849 vput vexpr k - $1 $2
1850 if [ $k -eq 21 ]
1851 vput vexpr i + $1 1
1852 vput vexpr j + $2 1
1853 echo "# <$i/$j> .. "
1854 call w3 $i $j
1855 wysh set i=$? j=$!
1857 eval echon "<\$1=\$i/\$^ERRNAME-$j "
1858 return $i $j
1859 else
1860 echo ! The end for $1=$i/$2
1861 if [ "$2" != "" ]
1862 return $i $^ERR-DOM
1863 else
1864 return $i $^ERR-BUSY
1867 echoerr au
1870 call w1 0; echo ?=$? !=$!; echo -----;
1871 call w2 0; echo ?=$? !=$^ERRNAME; echo -----;
1872 call w3 0 1; echo ?=$? !=$^ERRNAME; echo -----;
1873 __EOT
1875 check behave:call_ret 0 "${MBOX}" '1572045517 5922'
1877 t_epilog
1880 t_behave_xcall() {
1881 t_prolog
1883 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Snomemdebug > "${MBOX}" 2>&1
1884 define work {
1885 echon "$1 "
1886 vput vexpr i + $1 1
1887 if [ $i -le 1111 ]
1888 vput vexpr j '&' $i 7
1889 if [ $j -eq 7 ]
1890 echo .
1892 \xcall work $i $2
1894 echo ! The end for $1/$2
1895 if [ "$2" != "" ]
1896 return $i $^ERR-BUSY
1899 define xwork {
1900 \xcall work 0 $2
1902 call work 0
1903 echo ?=$? !=$!
1904 call xwork
1905 echo ?=$? !=$!
1906 xcall xwork
1907 echo ?=$? !=$^ERRNAME
1909 call work 0 yes
1910 echo ?=$? !=$^ERRNAME
1911 call xwork 0 yes
1912 echo ?=$? !=$^ERRNAME
1913 __EOT
1915 check behave:xcall-1 0 "${MBOX}" '2401702082 23801'
1919 ${cat} <<- '__EOT' > "${BODY}"
1920 define __w {
1921 echon "$1 "
1922 vput vexpr i + $1 1
1923 if [ $i -le 111 ]
1924 vput vexpr j '&' $i 7
1925 if [ $j -eq 7 ]
1926 echo .
1928 \xcall __w $i $2
1930 echo ! The end for $1
1931 if [ $2 -eq 0 ]
1932 nonexistingcommand
1933 echo would be err with errexit
1934 return
1936 echo calling exit
1937 exit
1939 define work {
1940 echo eins
1941 call __w 0 0
1942 echo zwei, ?=$? !=$!
1943 localopts yes; set errexit
1944 ignerr call __w 0 0
1945 echo drei, ?=$? !=$^ERRNAME
1946 call __w 0 $1
1947 echo vier, ?=$? !=$^ERRNAME, this is an error
1949 ignerr call work 0
1950 echo outer 1, ?=$? !=$^ERRNAME
1951 xxxign call work 0
1952 echo outer 2, ?=$? !=$^ERRNAME, could be error if xxxign non-empty
1953 call work 1
1954 echo outer 3, ?=$? !=$^ERRNAME
1955 echo this is definitely an error
1956 __EOT
1958 < "${BODY}" ${MAILX} ${ARGS} -X'commandalias xxxign ignerr' -Snomemdebug \
1959 > "${MBOX}" 2>&1
1960 check behave:xcall-2 0 "${MBOX}" '3900716531 4200'
1962 < "${BODY}" ${MAILX} ${ARGS} -X'commandalias xxxign " "' -Snomemdebug \
1963 > "${MBOX}" 2>&1
1964 check behave:xcall-3 1 "${MBOX}" '1006776201 2799'
1966 t_epilog
1969 t_behave_vpospar() {
1970 t_prolog
1972 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
1973 vpospar set hey, "'you ", world!
1974 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1975 vput vpospar x quote; echo x<$x>
1976 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1977 vput vpospar y quote;echo y<$y>
1978 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1979 eval vpospar set ${y};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1980 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1982 define infun2 {
1983 echo infun2:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
1984 vput vpospar z quote;echo infun2:z<$z>
1987 define infun {
1988 echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
1989 vput vpospar y quote;echo infun:y<$y>
1990 eval vpospar set ${x};echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
1991 vpospar clear;echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
1992 eval call infun2 $x
1993 echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
1994 eval vpospar set ${y};echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
1997 call infun This "in a" fun
1998 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1999 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2000 __EOT
2001 check behave:vpospar-1 0 "${MBOX}" '155175639 866'
2004 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
2005 set ifs=\'
2006 echo ifs<$ifs> ifs-ws<$ifs-ws>
2007 vpospar set hey, "'you ", world!
2008 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2009 vput vpospar x quote; echo x<$x>
2010 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2011 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2013 set ifs=,
2014 echo ifs<$ifs> ifs-ws<$ifs-ws>
2015 vpospar set hey, "'you ", world!
2016 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2017 vput vpospar x quote; echo x<$x>
2018 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2019 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2021 wysh set ifs=$',\t'
2022 echo ifs<$ifs> ifs-ws<$ifs-ws>
2023 vpospar set hey, "'you ", world!
2024 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2025 vput vpospar x quote; echo x<$x>
2026 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2027 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
2028 __EOT
2029 check behave:vpospar-ifs 0 "${MBOX}" '2015927702 706'
2031 t_epilog
2034 t_behave_atxplode() {
2035 t_prolog
2036 TRAP_EXIT_ADDONS="./.t*"
2038 ${cat} > ./.t.sh <<- '___'; ${cat} > ./.t.rc <<- '___'
2039 x() { echo $#; }
2040 xxx() {
2041 printf " (1/$#: <$1>)"
2042 shift
2043 if [ $# -gt 0 ]; then
2044 xxx "$@"
2045 else
2046 echo
2049 yyy() {
2050 eval "$@ ' ball"
2052 set --
2053 x "$@"
2054 x "$@"''
2055 x " $@"
2056 x "$@ "
2057 printf yyy;yyy 'xxx' "b\$'\t'u ' "
2058 printf xxx;xxx arg ,b u.
2059 printf xxx;xxx arg , .
2060 printf xxx;xxx arg ,ball.
2062 define x {
2063 echo $#
2065 define xxx {
2066 echon " (1/$#: <$1>)"
2067 shift
2068 if [ $# -gt 0 ]
2069 \xcall xxx "$@"
2070 endif
2071 echo
2073 define yyy {
2074 eval "$@ ' ball"
2076 vpospar set
2077 call x "$@"
2078 call x "$@"''
2079 call x " $@"
2080 call x "$@ "
2081 echon yyy;call yyy '\call xxx' "b\$'\t'u ' "
2082 echon xxx;call xxx arg ,b u.
2083 echon xxx;call xxx arg , .
2084 echon xxx;call xxx arg ,ball.
2087 ${MAILX} ${ARGS} -X'source ./.t.rc' -Xx > "${MBOX}" 2>&1
2088 check behave:atxplode-1 0 "${MBOX}" '41566293 164'
2090 #${SHELL} ./.t.sh > ./.tshout 2>&1
2091 #check behave:atxplode:disproof-1 0 ./.tshout '41566293 164'
2093 t_epilog
2096 t_behave_read() {
2097 t_prolog
2098 TRAP_EXIT_ADDONS="./.t*"
2100 ${cat} <<- '__EOT' > .tin
2101 hey1, "'you ", world!
2102 hey2, "'you ", bugs bunny!
2103 hey3, "'you ",
2104 hey4, "'you "
2105 __EOT
2107 ${cat} <<- '__EOT' |\
2108 ${MAILX} ${ARGS} -X'readctl create ./.tin' > "${MBOX}" 2>&1
2109 read a b c
2110 echo $?/$^ERRNAME / <$a><$b><$c>
2111 read a b c
2112 echo $?/$^ERRNAME / <$a><$b><$c>
2113 read a b c
2114 echo $?/$^ERRNAME / <$a><$b><$c>
2115 read a b c
2116 echo $?/$^ERRNAME / <$a><$b><$c>
2117 read a b c
2118 echo $?/$^ERRNAME / <$a><$b><$c>
2119 readctl remove ./.tin;echo readctl remove:$?/$^ERRNAME
2120 __EOT
2121 check behave:read-1 0 "${MBOX}" '1527910147 173'
2123 ${cat} <<- '__EOT' > .tin2
2124 hey2.0,:"'you ",:world!:mars.:
2125 hey2.1,:"'you ",:world!
2126 hey2.2,:"'you ",:bugs bunny!
2127 hey2.3,:"'you ",:
2128 hey2.4,:"'you ":
2130 __EOT
2132 ${cat} <<- '__EOT' |\
2133 6< .tin2 ${MAILX} ${ARGS} -X 'readctl create 6' > "${MBOX}" 2>&1
2134 set ifs=:
2135 read a b c
2136 echo $?/$^ERRNAME / <$a><$b><$c>
2137 read a b c
2138 echo $?/$^ERRNAME / <$a><$b><$c>
2139 read a b c
2140 echo $?/$^ERRNAME / <$a><$b><$c>
2141 read a b c
2142 echo $?/$^ERRNAME / <$a><$b><$c>
2143 read a b c
2144 echo $?/$^ERRNAME / <$a><$b><$c>
2145 read a b c
2146 echo $?/$^ERRNAME / <$a><$b><$c>
2147 read a b c
2148 echo $?/$^ERRNAME / <$a><$b><$c>
2149 read a b c
2150 echo $?/$^ERRNAME / <$a><$b><$c>
2151 readctl remove 6;echo readctl remove:$?/$^ERRNAME
2152 __EOT
2153 check behave:read-ifs 0 "${MBOX}" '890153490 298'
2155 t_epilog
2158 t_behave_mbox() {
2159 t_prolog
2160 TRAP_EXIT_ADDONS="./.t*"
2164 while [ ${i} -lt 112 ]; do
2165 printf 'm file://%s\n~s Subject %s\nHello %s!\n~.\n' \
2166 "${MBOX}" "${i}" "${i}"
2167 i=`add ${i} 1`
2168 done
2169 ) | ${MAILX} ${ARGS}
2170 check behave:mbox-1 0 "${MBOX}" '1140119864 13780'
2172 printf 'File "%s"
2173 copy * "%s"
2174 File "%s"
2175 from*
2176 ' "${MBOX}" .tmbox1 .tmbox1 |
2177 ${MAILX} ${ARGS} > .tlst
2178 check behave:mbox-2 0 .tlst '2739893312 9103'
2180 printf 'File "%s"
2181 copy * "file://%s"
2182 File "file://%s"
2183 from*
2184 ' "${MBOX}" .tmbox2 .tmbox2 |
2185 ${MAILX} ${ARGS} > .tlst
2186 check behave:mbox-3 0 .tlst '1702194178 9110'
2188 # only the odd (even)
2190 printf 'File "file://%s"
2191 copy ' .tmbox2
2193 while [ ${i} -lt 112 ]; do
2194 j=`modulo ${i} 2`
2195 [ ${j} -eq 1 ] && printf '%s ' "${i}"
2196 i=`add ${i} 1`
2197 done
2198 printf ' file://%s
2199 File "file://%s"
2200 from*
2201 ' .tmbox3 .tmbox3
2202 ) | ${MAILX} ${ARGS} > .tlst
2203 check behave:mbox-4 0 .tmbox3 '631132924 6890'
2204 check behave:mbox-5 - .tlst '2960975049 4573'
2205 # ...
2207 printf 'file "file://%s"
2208 move ' .tmbox2
2210 while [ ${i} -lt 112 ]; do
2211 j=`modulo ${i} 2`
2212 [ ${j} -eq 0 ] && [ ${i} -ne 0 ] && printf '%s ' "${i}"
2213 i=`add ${i} 1`
2214 done
2215 printf ' file://%s
2216 File "file://%s"
2217 from*
2218 File "file://%s"
2219 from*
2220 ' .tmbox3 .tmbox3 .tmbox2
2221 ) | ${MAILX} ${ARGS} > .tlst
2222 check behave:mbox-6 0 .tmbox3 '1387070539 13655'
2223 ${sed} 2d < .tlst > .tlstx
2224 check behave:mbox-7 - .tlstx '2729940494 13645'
2226 t_epilog
2229 t_behave_alternates() {
2230 t_prolog
2231 TRAP_EXIT_ADDONS="./.t*"
2233 ${cat} <<-_EOT > ./.tsendmail.sh
2234 #!${MYSHELL} -
2235 (echo 'From Valeriana Sat Jul 08 15:54:03 2017' && ${cat} && echo
2236 ) >> "${MBOX}"
2237 _EOT
2238 chmod 0755 ./.tsendmail.sh
2240 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Smta=./.tsendmail.sh > ./.tall 2>&1
2241 echo --0
2242 alternates
2243 echo $?/$^ERRNAME
2244 alternates a1@b1 a2@b2 a3@b3
2245 echo $?/$^ERRNAME
2246 alternates
2247 echo $?/$^ERRNAME
2248 vput alternates rv
2249 echo $?/$^ERRNAME <$rv>
2251 echo --1
2252 unalternates a2@b2
2253 vput alternates rv
2254 echo $?/$^ERRNAME <$rv>
2255 unalternates a3@b3
2256 vput alternates rv
2257 echo $?/$^ERRNAME <$rv>
2258 unalternates a1@b1
2259 vput alternates rv
2260 echo $?/$^ERRNAME <$rv>
2262 echo --2
2263 unalternates *
2264 alternates a1@b1 a2@b2 a3@b3
2265 unalternates a3@b3
2266 vput alternates rv
2267 echo $?/$^ERRNAME <$rv>
2268 unalternates a2@b2
2269 vput alternates rv
2270 echo $?/$^ERRNAME <$rv>
2271 unalternates a1@b1
2272 vput alternates rv
2273 echo $?/$^ERRNAME <$rv>
2275 echo --3
2276 alternates a1@b1 a2@b2 a3@b3
2277 unalternates a1@b1
2278 vput alternates rv
2279 echo $?/$^ERRNAME <$rv>
2280 unalternates a2@b2
2281 vput alternates rv
2282 echo $?/$^ERRNAME <$rv>
2283 unalternates a3@b3
2284 vput alternates rv
2285 echo $?/$^ERRNAME <$rv>
2287 echo --4
2288 unalternates *
2289 alternates a1@b1 a2@b2 a3@b3
2290 unalternates *
2291 vput alternates rv
2292 echo $?/$^ERRNAME <$rv>
2294 echo --5
2295 unalternates *
2296 alternates a1@b1 a1@c1 a1@d1 a2@b2 a3@b3 a3@c3 a3@d3
2297 m a1@b1 a1@c1 a1@d1
2298 ~s all alternates, only a1@b1 remains
2299 ~c a2@b2
2300 ~b a3@b3 a3@c3 a3@d3
2301 ~r - '_EOT'
2302 This body is!
2303 This also body is!!
2304 _EOT
2307 echo --6
2308 unalternates *
2309 alternates a1@b1 a1@c1 a2@b2 a3@b3
2310 m a1@b1 a1@c1 a1@d1
2311 ~s a1@b1 a1@d1, and a3@c3 a3@d3 remain
2312 ~c a2@b2
2313 ~b a3@b3 a3@c3 a3@d3
2314 ~r - '_EOT'
2315 This body2 is!
2316 _EOT
2319 echo --7
2320 alternates a1@b1 a2@b2 a3; set allnet
2321 m a1@b1 a1@c1 a1@d1
2322 ~s all alternates via allnet, only a1@b1 remains
2323 ~c a2@b2
2324 ~b a3@b3 a3@c3 a3@d3
2325 ~r - '_EOT'
2326 This body3 is!
2327 _EOT
2330 echo --10
2331 unalternates *
2332 alternates a1@b1
2333 echo $?/$^ERRNAME
2334 vput alternates rv
2335 echo $?/$^ERRNAME <$rv>
2336 alternates a2@b2
2337 echo $?/$^ERRNAME
2338 vput alternates rv
2339 echo $?/$^ERRNAME <$rv>
2340 alternates a3@b3
2341 echo $?/$^ERRNAME
2342 vput alternates rv
2343 echo $?/$^ERRNAME <$rv>
2344 alternates a4@b4
2345 echo $?/$^ERRNAME
2346 vput alternates rv
2347 echo $?/$^ERRNAME <$rv>
2349 unalternates *
2350 vput alternates rv
2351 echo $?/$^ERRNAME <$rv>
2353 echo --11
2354 set posix
2355 alternates a1@b1 a2@b2
2356 echo $?/$^ERRNAME
2357 vput alternates rv
2358 echo $?/$^ERRNAME <$rv>
2359 alternates a3@b3 a4@b4
2360 echo $?/$^ERRNAME
2361 vput alternates rv
2362 echo $?/$^ERRNAME <$rv>
2363 __EOT
2364 check behave:alternates-1 0 "${MBOX}" '142184864 515'
2365 check behave:alternates-2 - .tall '1878598364 505'
2367 t_epilog
2370 t_behave_alias() {
2371 t_prolog
2372 TRAP_EXIT_ADDONS="./.t*"
2374 ${cat} <<-_EOT > ./.tsendmail.sh
2375 #!${MYSHELL} -
2376 (echo 'From Hippocastanum Mon Jun 19 15:07:07 2017' && ${cat} && echo
2377 ) >> "${MBOX}"
2378 _EOT
2379 chmod 0755 ./.tsendmail.sh
2381 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Smta=./.tsendmail.sh > ./.tall 2>&1
2382 alias a1 ex1@a1.ple
2383 alias a1 ex2@a1.ple "EX3 <ex3@a1.ple>"
2384 alias a1 ex4@a1.ple
2385 alias a2 ex1@a2.ple ex2@a2.ple ex3@a2.ple ex4@a2.ple
2386 alias a3 a4
2387 alias a4 a5 ex1@a4.ple
2388 alias a5 a6
2389 alias a6 a7 ex1@a6.ple
2390 alias a7 a8
2391 alias a8 ex1@a8.ple
2392 alias a1
2393 alias a2
2394 alias a3
2395 m a1
2396 ~c a2
2397 ~b a3
2398 ~r - '_EOT'
2399 This body is!
2400 This also body is!!
2401 _EOT
2402 __EOT
2403 check behave:alias-1 0 "${MBOX}" '2496925843 272'
2404 check behave:alias-2 - .tall '3548953204 152'
2406 # TODO t_behave_alias: n_ALIAS_MAXEXP is compile-time constant,
2407 # TODO need to somehow provide its contents to the test, then test
2409 t_epilog
2412 t_behave_filetype() {
2413 t_prolog
2414 TRAP_EXIT_ADDONS="./.t*"
2416 ${cat} <<-_EOT > ./.tsendmail.sh
2417 #!${MYSHELL} -
2418 (echo 'From Alchemilla Wed Apr 25 15:12:13 2017' && ${cat} && echo
2419 ) >> "${MBOX}"
2420 _EOT
2421 chmod 0755 ./.tsendmail.sh
2423 printf 'm m1@e.t\nL1\nHy1\n~.\nm m2@e.t\nL2\nHy2\n~@ ./snailmail.jpg\n~.\n' |
2424 ${MAILX} ${ARGS} -Smta=./.tsendmail.sh
2425 check behave:filetype-1 0 "${MBOX}" '1645747150 13536'
2427 if command -v gzip >/dev/null 2>&1; then
2428 ${rm} -f ./.t.mbox*
2430 printf 'File "%s"\ncopy 1 ./.t.mbox.gz
2431 copy 2 ./.t.mbox.gz' "${MBOX}" |
2432 ${MAILX} ${ARGS} \
2433 -X'filetype gz gzip\ -dc gzip\ -c'
2434 printf 'File ./.t.mbox.gz\ncopy * ./.t.mbox\n' |
2435 ${MAILX} ${ARGS} \
2436 -X'filetype gz gzip\ -dc gzip\ -c'
2437 } >/dev/null 2>&1
2438 check behave:filetype-2 0 "./.t.mbox" '1645747150 13536'
2439 else
2440 echo 'behave:filetype-2: unsupported, skipped'
2444 ${rm} -f ./.t.mbox*
2445 printf 'File "%s"\ncopy 1 ./.t.mbox.gz
2446 copy 2 ./.t.mbox.gz
2447 copy 1 ./.t.mbox.gz
2448 copy 2 ./.t.mbox.gz
2449 ' "${MBOX}" |
2450 ${MAILX} ${ARGS} \
2451 -X'filetype gz gzip\ -dc gzip\ -c' \
2452 -X'filetype mbox.gz "${sed} 1,3d|${cat}" \
2453 "echo eins;echo zwei;echo und mit ${sed} bist Du dabei;${cat}"'
2454 printf 'File ./.t.mbox.gz\ncopy * ./.t.mbox\n' |
2455 ${MAILX} ${ARGS} \
2456 -X'filetype gz gzip\ -dc gzip\ -c' \
2457 -X'filetype mbox.gz "${sed} 1,3d|${cat}" kill\ 0'
2458 } >/dev/null 2>&1
2460 check behave:filetype-3 - "./.t.mbox" '238021003 27092'
2462 t_epilog
2465 t_behave_record_a_resend() {
2466 t_prolog
2467 TRAP_EXIT_ADDONS="./.t.record ./.t.resent"
2469 printf '
2470 set record=%s
2471 m %s\n~s Subject 1.\nHello.\n~.
2472 set record-files add-file-recipients
2473 m %s\n~s Subject 2.\nHello.\n~.
2474 File %s
2475 resend 2 ./.t.resent
2476 Resend 1 ./.t.resent
2477 set record-resent
2478 resend 2 ./.t.resent
2479 Resend 1 ./.t.resent
2480 ' ./.t.record "${MBOX}" "${MBOX}" "${MBOX}" |
2481 ${MAILX} ${ARGS}
2483 check behave:record_a_resend-1 0 "${MBOX}" '3057873538 256'
2484 check behave:record_a_resend-2 - .t.record '391356429 460'
2485 check behave:record_a_resend-3 - .t.resent '2685231691 648'
2487 t_epilog
2490 t_behave_e_H_L_opts() {
2491 t_prolog
2492 TRAP_EXIT_ADDONS="./.tsendmail.sh ./.t.mbox"
2494 touch ./.t.mbox
2495 ${MAILX} ${ARGS} -ef ./.t.mbox
2496 echo ${?} > "${MBOX}"
2498 ${cat} <<-_EOT > ./.tsendmail.sh
2499 #!${MYSHELL} -
2500 (echo 'From Alchemilla Wed Apr 07 17:03:33 2017' && ${cat} && echo
2501 ) >> "./.t.mbox"
2502 _EOT
2503 chmod 0755 ./.tsendmail.sh
2504 printf 'm me@exam.ple\nLine 1.\nHello.\n~.\n' |
2505 ${MAILX} ${ARGS} -Smta=./.tsendmail.sh
2506 printf 'm you@exam.ple\nLine 1.\nBye.\n~.\n' |
2507 ${MAILX} ${ARGS} -Smta=./.tsendmail.sh
2509 ${MAILX} ${ARGS} -ef ./.t.mbox
2510 echo ${?} >> "${MBOX}"
2511 ${MAILX} ${ARGS} -efL @t@me ./.t.mbox
2512 echo ${?} >> "${MBOX}"
2513 ${MAILX} ${ARGS} -efL @t@you ./.t.mbox
2514 echo ${?} >> "${MBOX}"
2515 ${MAILX} ${ARGS} -efL '@>@Line 1' ./.t.mbox
2516 echo ${?} >> "${MBOX}"
2517 ${MAILX} ${ARGS} -efL '@>@Hello.' ./.t.mbox
2518 echo ${?} >> "${MBOX}"
2519 ${MAILX} ${ARGS} -efL '@>@Bye.' ./.t.mbox
2520 echo ${?} >> "${MBOX}"
2521 ${MAILX} ${ARGS} -efL '@>@Good bye.' ./.t.mbox
2522 echo ${?} >> "${MBOX}"
2524 ${MAILX} ${ARGS} -fH ./.t.mbox >> "${MBOX}"
2525 echo ${?} >> "${MBOX}"
2526 ${MAILX} ${ARGS} -fL @t@me ./.t.mbox >> "${MBOX}"
2527 echo ${?} >> "${MBOX}"
2528 ${MAILX} ${ARGS} -fL @t@you ./.t.mbox >> "${MBOX}"
2529 echo ${?} >> "${MBOX}"
2530 ${MAILX} ${ARGS} -fL '@>@Line 1' ./.t.mbox >> "${MBOX}"
2531 echo ${?} >> "${MBOX}"
2532 ${MAILX} ${ARGS} -fL '@>@Hello.' ./.t.mbox >> "${MBOX}"
2533 echo ${?} >> "${MBOX}"
2534 ${MAILX} ${ARGS} -fL '@>@Bye.' ./.t.mbox >> "${MBOX}"
2535 echo ${?} >> "${MBOX}"
2536 ${MAILX} ${ARGS} -fL '@>@Good bye.' ./.t.mbox >> "${MBOX}" 2>/dev/null
2537 echo ${?} >> "${MBOX}"
2539 check behave:e_H_L_opts - "${MBOX}" '1708955574 678'
2541 t_epilog
2544 t_behave_compose_hooks() { # TODO monster
2545 t_prolog
2546 TRAP_EXIT_ADDONS="./.t*"
2548 (echo line one&&echo line two&&echo line three) > ./.treadctl
2549 (echo echo four&&echo echo five&&echo echo six) > ./.tattach
2551 ${cat} <<-_EOT > ./.tsendmail.sh
2552 #!${MYSHELL} -
2553 (echo 'From PrimulaVeris Wed Apr 10 22:59:00 2017' && ${cat} && echo
2554 ) >> "${MBOX}"
2555 _EOT
2556 chmod 0755 ./.tsendmail.sh
2558 ${cat} <<'__EOT__' > ./.trc
2559 define bail {
2560 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
2562 define xerr {
2563 vput vexpr es substr "$1" 0 1
2564 if [ "$es" != 2 ]
2565 xcall bail "$2"
2568 define read_mline_res {
2569 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
2570 echo $len/$es/$^ERRNAME: $hl
2571 if [ $es -ne $^ERR-NONE ]
2572 xcall bail read_mline_res
2573 elif [ $len -ne 0 ]
2574 \xcall read_mline_res
2577 define ins_addr {
2578 wysh set xh=$1
2579 echo "~^header list"; read hl; echo $hl;\
2580 call xerr "$hl" "in_addr ($xh) 0-1"
2582 echo "~^header insert $xh diet <$xh@exam.ple> spliced";\
2583 read es; echo $es; call xerr "$es" "ins_addr $xh 1-1"
2584 echo "~^header insert $xh <${xh}2@exam.ple>";\
2585 read es; echo $es; call xerr "$es" "ins_addr $xh 1-2"
2586 echo "~^header insert $xh ${xh}3@exam.ple";\
2587 read es; echo $es; call xerr "$es" "ins_addr $xh 1-3"
2588 echo "~^header list $xh"; read hl; echo $hl;\
2589 call xerr "$hl" "ins_addr $xh 1-4"
2590 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 1-5"
2591 call read_mline_res
2593 if [ "$t_remove" == "" ]
2594 return
2597 echo "~^header remove $xh"; read es; call xerr $es "ins_addr $xh 2-1"
2598 echo "~^header remove $xh"; read es; vput vexpr es substr $es 0 3
2599 if [ $es != 501 ]
2600 xcall bail "ins_addr $xh 2-2"
2602 echo "~^header list $xh"; read es; vput vexpr es substr $es 0 3
2603 if [ $es != 501 ]
2604 xcall bail "ins_addr $xh 2-3"
2606 echo "~^header show $xh"; read es; vput vexpr es substr $es 0 3
2607 if [ $es != 501 ]
2608 xcall bail "ins_addr $xh 2-4"
2612 echo "~^header insert $xh diet <$xh@exam.ple> spliced";\
2613 read es; echo $es; call xerr "$es" "ins_addr $xh 3-1"
2614 echo "~^header insert $xh <${xh}2@exam.ple>";\
2615 read es; echo $es; call xerr "$es" "ins_addr $xh 3-2"
2616 echo "~^header insert $xh ${xh}3@exam.ple";\
2617 read es; echo $es; call xerr "$es" "ins_addr $xh 3-3"
2618 echo "~^header list $xh"; read hl; echo $hl;\
2619 call xerr "$hl" "ins_addr $xh 3-4"
2620 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 3-5"
2621 call read_mline_res
2623 echo "~^header remove-at $xh 1"; read es;\
2624 call xerr $es "ins_addr $xh 3-6"
2625 echo "~^header remove-at $xh 1"; read es;\
2626 call xerr $es "ins_addr $xh 3-7"
2627 echo "~^header remove-at $xh 1"; read es;\
2628 call xerr $es "ins_addr $xh 3-8"
2629 echo "~^header remove-at $xh 1"; read es;\
2630 vput vexpr es substr $es 0 3
2631 if [ $es != 501 ]
2632 xcall bail "ins_addr $xh 3-9"
2634 echo "~^header remove-at $xh T"; read es;\
2635 vput vexpr es substr $es 0 3
2636 if [ $es != 505 ]
2637 xcall bail "ins_addr $xh 3-10"
2639 echo "~^header list $xh"; read es;\
2640 vput vexpr es substr $es 0 3
2641 if [ $es != 501 ]
2642 xcall bail "ins_addr $xh 3-11"
2644 echo "~^header show $xh"; read es;\
2645 vput vexpr es substr $es 0 3
2646 if [ $es != 501 ]
2647 xcall bail "ins_addr $xh 3-12"
2651 echo "~^header insert $xh diet <$xh@exam.ple> spliced";\
2652 read es; echo $es; call xerr "$es" "ins_addr $xh 4-1"
2653 echo "~^header insert $xh <${xh}2@exam.ple> (comment) \"Quot(e)d\"";\
2654 read es; echo $es; call xerr "$es" "ins_addr $xh 4-2"
2655 echo "~^header insert $xh ${xh}3@exam.ple";\
2656 read es; echo $es; call xerr "$es" "ins_addr $xh 4-3"
2657 echo "~^header list $xh"; read hl; echo $hl;\
2658 call xerr "$hl" "header list $xh 3-4"
2659 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 4-5"
2660 call read_mline_res
2662 echo "~^header remove-at $xh 3"; read es;\
2663 call xerr $es "ins_addr $xh 4-6"
2664 echo "~^header remove-at $xh 2"; read es;\
2665 call xerr $es "ins_addr $xh 4-7"
2666 echo "~^header remove-at $xh 1"; read es;\
2667 call xerr $es "ins_addr $xh 4-8"
2668 echo "~^header remove-at $xh 1"; read es;\
2669 vput vexpr es substr $es 0 3
2670 if [ $es != 501 ]
2671 xcall bail "ins_addr $xh 4-9"
2673 echo "~^header remove-at $xh T"; read es;\
2674 vput vexpr es substr $es 0 3
2675 if [ $es != 505 ]
2676 xcall bail "ins_addr $xh 4-10"
2678 echo "~^header list $xh"; read es;\
2679 vput vexpr es substr $es 0 3
2680 if [ $es != 501 ]
2681 xcall bail "ins_addr $xh 4-11"
2683 echo "~^header show $xh"; read es;\
2684 vput vexpr es substr $es 0 3
2685 if [ $es != 501 ]
2686 xcall bail "ins_addr $xh 4-12"
2689 define ins_ref {
2690 wysh set xh=$1 mult=$2
2691 echo "~^header list"; read hl; echo $hl;\
2692 call xerr "$hl" "ins_ref ($xh) 0-1"
2694 echo "~^header insert $xh <$xh@exam.ple>";\
2695 read es; echo $es; call xerr "$es" "ins_ref $xh 1-1"
2696 if [ $mult -ne 0 ]
2697 echo "~^header insert $xh <${xh}2@exam.ple>";\
2698 read es; echo $es; call xerr "$es" "ins_ref $xh 1-2"
2699 echo "~^header insert $xh ${xh}3@exam.ple";\
2700 read es; echo $es; call xerr "$es" "ins_ref $xh 1-3"
2701 else
2702 echo "~^header insert $xh <${xh}2@exam.ple>"; read es;\
2703 vput vexpr es substr $es 0 3
2704 if [ $es != 506 ]
2705 xcall bail "ins_ref $xh 1-4"
2709 echo "~^header list $xh"; read hl; echo $hl;\
2710 call xerr "$hl" "ins_ref $xh 1-5"
2711 echo "~^header show $xh"; read es; call xerr $es "ins_ref $xh 1-6"
2712 call read_mline_res
2714 if [ "$t_remove" == "" ]
2715 return
2718 echo "~^header remove $xh"; read es;\
2719 call xerr $es "ins_ref $xh 2-1"
2720 echo "~^header remove $xh"; read es;\
2721 vput vexpr es substr $es 0 3
2722 if [ $es != 501 ]
2723 xcall bail "ins_ref $xh 2-2"
2725 echo "~^header list $xh"; read es;\
2726 vput vexpr es substr $es 0 3
2727 if [ $es != 501 ]
2728 xcall bail "$es ins_ref $xh 2-3"
2730 echo "~^header show $xh"; read es;\
2731 vput vexpr es substr $es 0 3
2732 if [ $es != 501 ]
2733 xcall bail "ins_ref $xh 2-4"
2737 echo "~^header insert $xh <$xh@exam.ple>";\
2738 read es; echo $es; call xerr "$es" "ins_ref $xh 3-1"
2739 if [ $mult -ne 0 ]
2740 echo "~^header insert $xh <${xh}2@exam.ple>";\
2741 read es; echo $es; call xerr "$es" "ins_ref $xh 3-2"
2742 echo "~^header insert $xh ${xh}3@exam.ple";\
2743 read es; echo $es; call xerr "$es" "ins_ref $xh 3-3"
2745 echo "~^header list $xh";\
2746 read hl; echo $hl; call xerr "$hl" "ins_ref $xh 3-4"
2747 echo "~^header show $xh";\
2748 read es; call xerr $es "ins_ref $xh 3-5"
2749 call read_mline_res
2751 echo "~^header remove-at $xh 1"; read es;\
2752 call xerr $es "ins_ref $xh 3-6"
2753 if [ $mult -ne 0 ] && [ $xh != subject ]
2754 echo "~^header remove-at $xh 1"; read es;\
2755 call xerr $es "ins_ref $xh 3-7"
2756 echo "~^header remove-at $xh 1"; read es;\
2757 call xerr $es "ins_ref $xh 3-8"
2759 echo "~^header remove-at $xh 1"; read es;\
2760 vput vexpr es substr $es 0 3
2761 if [ $es != 501 ]
2762 xcall bail "ins_ref $xh 3-9"
2764 echo "~^header remove-at $xh T"; read es;\
2765 vput vexpr es substr $es 0 3
2766 if [ $es != 505 ]
2767 xcall bail "ins_ref $xh 3-10"
2769 echo "~^header show $xh"; read es;\
2770 vput vexpr es substr $es 0 3
2771 if [ $es != 501 ]
2772 xcall bail "ins_ref $xh 3-11"
2776 echo "~^header insert $xh <$xh@exam.ple> ";\
2777 read es; echo $es; call xerr "$es" "ins_ref $xh 4-1"
2778 if [ $mult -ne 0 ]
2779 echo "~^header insert $xh <${xh}2@exam.ple> ";\
2780 read es; echo $es; call xerr "$es" "ins_ref $xh 4-2"
2781 echo "~^header insert $xh ${xh}3@exam.ple";\
2782 read es; echo $es; call xerr "$es" "ins_ref $xh 4-3"
2784 echo "~^header list $xh"; read hl; echo $hl;\
2785 call xerr "$hl" "ins_ref $xh 4-4"
2786 echo "~^header show $xh"; read es; call xerr $es "ins_ref $xh 4-5"
2787 call read_mline_res
2789 if [ $mult -ne 0 ] && [ $xh != subject ]
2790 echo "~^header remove-at $xh 3"; read es;\
2791 call xerr $es "ins_ref $xh 4-6"
2792 echo "~^header remove-at $xh 2"; read es;\
2793 call xerr $es "ins_ref $xh 4-7"
2795 echo "~^header remove-at $xh 1"; read es;\
2796 call xerr $es "ins_ref $xh 4-8"
2797 echo "~^header remove-at $xh 1"; read es;\
2798 vput vexpr es substr $es 0 3
2799 if [ $es != 501 ]
2800 xcall bail "ins_ref $xh 4-9"
2802 echo "~^header remove-at $xh T"; read es;\
2803 vput vexpr es substr $es 0 3
2804 if [ $es != 505 ]
2805 xcall bail "ins_ref $xh 4-10"
2807 echo "~^header show $xh"; read es;\
2808 vput vexpr es substr $es 0 3
2809 if [ $es != 501 ]
2810 xcall bail "ins_ref $xh 4-11"
2813 define t_header {
2814 echo t_header ENTER
2815 # In collect.c order
2816 call ins_addr from
2817 call ins_ref sender 0 # Not a "ref", but works
2818 call ins_addr To
2819 call ins_addr cC
2820 call ins_addr bCc
2821 call ins_addr reply-To
2822 call ins_addr mail-Followup-to
2823 call ins_ref messAge-id 0
2824 call ins_ref rEfErEncEs 1
2825 call ins_ref in-Reply-to 1
2826 call ins_ref subject 1 # Not a "ref", but works (with tweaks)
2827 call ins_addr freeForm1
2828 call ins_addr freeform2
2830 echo "~^header show MAILX-Command"; read es; call xerr $es "t_header 1000"
2831 call read_mline_res
2832 echo "~^header show MAILX-raw-TO"; read es; call xerr $es "t_header 1001"
2833 call read_mline_res
2835 echo t_header LEAVE
2837 define t_attach {
2838 echo t_attach ENTER
2840 echo "~^attachment";\
2841 read hl; echo $hl; vput vexpr es substr "$hl" 0 3
2842 if [ "$es" != 501 ]
2843 xcall bail "attach 0-1"
2846 echo "~^attach attribute ./.treadctl";\
2847 read hl; echo $hl; vput vexpr es substr "$hl" 0 3
2848 if [ "$es" != 501 ]
2849 xcall bail "attach 0-2"
2851 echo "~^attachment attribute-at 1";\
2852 read hl; echo $hl; vput vexpr es substr "$hl" 0 3
2853 if [ "$es" != 501 ]
2854 xcall bail "attach 0-3"
2857 echo "~^attachment insert ./.treadctl=ascii";\
2858 read hl; echo $hl; call xerr "$hl" "attach 1-1"
2859 echo "~^attachment list";\
2860 read es; echo $es;call xerr "$es" "attach 1-2"
2861 call read_mline_res
2862 echo "~^attachment attribute ./.treadctl";\
2863 read es; echo $es;call xerr "$es" "attach 1-3"
2864 call read_mline_res
2865 echo "~^attachment attribute .treadctl";\
2866 read es; echo $es;call xerr "$es" "attach 1-4"
2867 call read_mline_res
2868 echo "~^attachment attribute-at 1";\
2869 read es; echo $es;call xerr "$es" "attach 1-5"
2870 call read_mline_res
2872 echo "~^attachment attribute-set ./.treadctl filename rctl";\
2873 read es; echo $es;call xerr "$es" "attach 1-6"
2874 echo "~^attachment attribute-set .treadctl content-description Au";\
2875 read es; echo $es;call xerr "$es" "attach 1-7"
2876 echo "~^attachment attribute-set-at 1 content-id <10.du@ich>";\
2877 read es; echo $es;call xerr "$es" "attach 1-8"
2879 echo "~^attachment attribute ./.treadctl";\
2880 read es; echo $es;call xerr "$es" "attach 1-9"
2881 call read_mline_res
2882 echo "~^attachment attribute .treadctl";\
2883 read es; echo $es;call xerr "$es" "attach 1-10"
2884 call read_mline_res
2885 echo "~^attachment attribute rctl";\
2886 read es; echo $es;call xerr "$es" "attach 1-11"
2887 call read_mline_res
2888 echo "~^attachment attribute-at 1";\
2889 read es; echo $es;call xerr "$es" "attach 1-12"
2890 call read_mline_res
2893 echo "~^attachment insert ./.tattach=latin1";\
2894 read hl; echo $hl; call xerr "$hl" "attach 2-1"
2895 echo "~^attachment list";\
2896 read es; echo $es;call xerr "$es" "attach 2-2"
2897 call read_mline_res
2898 echo "~^attachment attribute ./.tattach";\
2899 read es; echo $es;call xerr "$es" "attach 2-3"
2900 call read_mline_res
2901 echo "~^attachment attribute .tattach";\
2902 read es; echo $es;call xerr "$es" "attach 2-4"
2903 call read_mline_res
2904 echo "~^attachment attribute-at 2";\
2905 read es; echo $es;call xerr "$es" "attach 2-5"
2906 call read_mline_res
2908 echo "~^attachment attribute-set ./.tattach filename tat";\
2909 read es; echo $es;call xerr "$es" "attach 2-6"
2910 echo \
2911 "~^attachment attribute-set .tattach content-description Au2";\
2912 read es; echo $es;call xerr "$es" "attach 2-7"
2913 echo "~^attachment attribute-set-at 2 content-id <20.du@wir>";\
2914 read es; echo $es;call xerr "$es" "attach 2-8"
2915 echo \
2916 "~^attachment attribute-set-at 2 content-type application/x-sh";\
2917 read es; echo $es;call xerr "$es" "attach 2-9"
2919 echo "~^attachment attribute ./.tattach";\
2920 read es; echo $es;call xerr "$es" "attach 2-10"
2921 call read_mline_res
2922 echo "~^attachment attribute .tattach";\
2923 read es; echo $es;call xerr "$es" "attach 2-11"
2924 call read_mline_res
2925 echo "~^attachment attribute tat";\
2926 read es; echo $es;call xerr "$es" "attach 2-12"
2927 call read_mline_res
2928 echo "~^attachment attribute-at 2";\
2929 read es; echo $es;call xerr "$es" "attach 2-13"
2930 call read_mline_res
2933 if [ "$t_remove" == "" ]
2934 return
2937 echo "~^attachment remove ./.treadctl"; read es;\
2938 call xerr $es "attach 3-1"
2939 echo "~^attachment remove ./.tattach"; read es;\
2940 call xerr $es "attach 3-2"
2941 echo "~^ attachment remove ./.treadctl"; read es;\
2942 vput vexpr es substr $es 0 3
2943 if [ $es != 501 ]
2944 xcall bail "attach 3-3"
2946 echo "~^ attachment remove ./.tattach"; read es;\
2947 vput vexpr es substr $es 0 3
2948 if [ $es != 501 ]
2949 xcall bail "attach 3-4"
2951 echo "~^attachment list"; read es;\
2952 vput vexpr es substr $es 0 3
2953 if [ $es != 501 ]
2954 xcall bail "attach 3-5"
2958 echo "~^attachment insert ./.tattach=latin1";\
2959 read hl; echo $hl; call xerr "$hl" "attach 4-1"
2960 echo "~^attachment insert ./.tattach=latin1";\
2961 read hl; echo $hl; call xerr "$hl" "attach 4-2"
2962 echo "~^attachment list";\
2963 read es; echo $es;call xerr "$es" "attach 4-3"
2964 call read_mline_res
2965 echo "~^ attachment remove .tattach"; read es;\
2966 vput vexpr es substr $es 0 3
2967 if [ $es != 506 ]
2968 xcall bail "attach 4-4 $es"
2970 echo "~^attachment remove-at T"; read es;\
2971 vput vexpr es substr $es 0 3
2972 if [ $es != 505 ]
2973 xcall bail "attach 4-5"
2975 echo "~^attachment remove ./.tattach"; read es;\
2976 call xerr $es "attach 4-6"
2977 echo "~^attachment remove ./.tattach"; read es;\
2978 call xerr $es "attach 4-7"
2979 echo "~^ attachment remove ./.tattach"; read es;\
2980 vput vexpr es substr $es 0 3
2981 if [ $es != 501 ]
2982 xcall bail "attach 4-8 $es"
2984 echo "~^attachment list"; read es;\
2985 vput vexpr es substr $es 0 3
2986 if [ $es != 501 ]
2987 xcall bail "attach 4-9"
2991 echo "~^attachment insert ./.tattach=latin1";\
2992 read hl; echo $hl; call xerr "$hl" "attach 5-1"
2993 echo "~^attachment insert ./.tattach=latin1";\
2994 read hl; echo $hl; call xerr "$hl" "attach 5-2"
2995 echo "~^attachment insert ./.tattach=latin1";\
2996 read hl; echo $hl; call xerr "$hl" "attach 5-3"
2997 echo "~^attachment list";\
2998 read es; echo $es;call xerr "$es" "attach 5-4"
2999 call read_mline_res
3001 echo "~^attachment remove-at 3"; read es;\
3002 call xerr $es "attach 5-5"
3003 echo "~^attachment remove-at 3"; read es;\
3004 vput vexpr es substr $es 0 3
3005 if [ $es != 501 ]
3006 xcall bail "attach 5-6"
3008 echo "~^attachment remove-at 2"; read es;\
3009 call xerr $es "attach 5-7"
3010 echo "~^attachment remove-at 2"; read es;\
3011 vput vexpr es substr $es 0 3
3012 if [ $es != 501 ]
3013 xcall bail "attach 5-8"
3015 echo "~^attachment remove-at 1"; read es;\
3016 call xerr $es "attach 5-9"
3017 echo "~^attachment remove-at 1"; read es;\
3018 vput vexpr es substr $es 0 3
3019 if [ $es != 501 ]
3020 xcall bail "attach 5-10"
3023 echo "~^attachment list"; read es;\
3024 vput vexpr es substr $es 0 3
3025 if [ $es != 501 ]
3026 xcall bail "attach 5-11"
3030 echo "~^attachment insert ./.tattach=latin1";\
3031 read hl; echo $hl; call xerr "$hl" "attach 6-1"
3032 echo "~^attachment insert ./.tattach=latin1";\
3033 read hl; echo $hl; call xerr "$hl" "attach 6-2"
3034 echo "~^attachment insert ./.tattach=latin1";\
3035 read hl; echo $hl; call xerr "$hl" "attach 6-3"
3036 echo "~^attachment list";\
3037 read es; echo $es;call xerr "$es" "attach 6-4"
3038 call read_mline_res
3040 echo "~^attachment remove-at 1"; read es;\
3041 call xerr $es "attach 6-5"
3042 echo "~^attachment remove-at 1"; read es;\
3043 call xerr $es "attach 6-6"
3044 echo "~^attachment remove-at 1"; read es;\
3045 call xerr $es "attach 6-7"
3046 echo "~^attachment remove-at 1"; read es;\
3047 vput vexpr es substr $es 0 3
3048 if [ $es != 501 ]
3049 xcall bail "attach 6-8"
3052 echo "~^attachment list"; read es;\
3053 vput vexpr es substr $es 0 3
3054 if [ $es != 501 ]
3055 xcall bail "attach 6-9"
3058 echo t_attach LEAVE
3060 define t_ocs {
3061 read ver
3062 echo t_ocs
3063 call t_header
3064 call t_attach
3066 define t_oce {
3067 echo on-compose-enter, mailx-command<$mailx-command>
3068 alternates alter1@exam.ple alter2@exam.ple
3069 alternates
3070 set autocc='alter1@exam.ple alter2@exam.ple'
3071 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3072 echo mailx-subject<$mailx-subject>
3073 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3074 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3075 mailx-raw-bcc<$mailx-raw-bcc>
3076 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
3077 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3079 define t_ocl {
3080 echo on-compose-leave, mailx-command<$mailx-command>
3081 vput alternates al
3082 eval alternates $al alter3@exam.ple alter4@exam.ple
3083 alternates
3084 set autobcc='alter3@exam.ple alter4@exam.ple'
3085 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3086 echo mailx-subject<$mailx-subject>
3087 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3088 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3089 mailx-raw-bcc<$mailx-raw-bcc>
3090 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
3091 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3093 define t_occ {
3094 echo on-compose-cleanup, mailx-command<$mailx-command>
3095 unalternates *
3096 alternates
3097 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3098 echo mailx-subject<$mailx-subject>
3099 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3100 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3101 mailx-raw-bcc<$mailx-raw-bcc>
3102 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
3103 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3105 wysh set on-compose-splice=t_ocs \
3106 on-compose-enter=t_oce on-compose-leave=t_ocl \
3107 on-compose-cleanup=t_occ
3108 __EOT__
3112 ${rm} -f "${MBOX}"
3113 printf 'm this-goes@nowhere\nbody\n!.\n' |
3114 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
3115 -X'source ./.trc' -Smta=./.tsendmail.sh \
3116 >./.tall 2>&1
3117 ${cat} ./.tall >> "${MBOX}"
3118 check behave:compose_hooks-1 0 "${MBOX}" '3667291468 10101'
3120 ${rm} -f "${MBOX}"
3121 printf 'm this-goes@nowhere\nbody\n!.\n' |
3122 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
3123 -St_remove=1 -X'source ./.trc' -Smta=./.tsendmail.sh \
3124 >./.tall 2>&1
3125 ${cat} ./.tall >> "${MBOX}"
3126 check behave:compose_hooks-2 0 "${MBOX}" '1746765053 12535'
3128 # Some state machine stress, shell compose hook, localopts for hook, etc.
3129 # readctl in child. ~r as HERE document
3130 ${rm} -f "${MBOX}"
3131 printf 'm ex@am.ple\nbody\n!.\nvar t_oce t_ocs t_ocs_sh t_ocl t_occ autocc' |
3132 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! \
3133 -Smta=./.tsendmail.sh \
3135 define bail {
3136 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
3138 define xerr {
3139 vput vexpr es substr "$1" 0 1
3140 if [ "$es" != 2 ]
3141 xcall bail "$2"
3144 define read_mline_res {
3145 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
3146 echo $len/$es/$^ERRNAME: $hl
3147 if [ $es -ne $^ERR-NONE ]
3148 xcall bail read_mline_res
3149 elif [ $len -ne 0 ]
3150 \xcall read_mline_res
3153 define _work {
3154 vput vexpr i + 1 "$2"
3155 if [ $i -lt 111 ]
3156 vput vexpr j % $i 10
3157 if [ $j -ne 0 ]
3158 set j=xcall
3159 else
3160 echon "$i.. "
3161 set j=call
3163 eval \\$j _work $1 $i
3164 return $?
3166 vput vexpr i + $i "$1"
3167 return $i
3169 define _read {
3170 read line;wysh set es=$? en=$^ERRNAME ; echo read:$es/$en: $line
3171 if [ "${es}" -ne -1 ]
3172 xcall _read
3174 readctl remove $cwd/.treadctl; echo readctl remove:$?/$^ERRNAME
3176 define t_ocs {
3177 read ver
3178 echo t_ocs
3179 echo "~^header list"; read hl; echo $hl;\
3180 vput vexpr es substr "$hl" 0 1
3181 if [ "$es" != 2 ]
3182 xcall bail "header list"
3183 endif
3185 call _work 1; echo $?
3186 echo "~^header insert cc splicy diet <splice@exam.ple> spliced";\
3187 read es; echo $es; vput vexpr es substr "$es" 0 1
3188 if [ "$es" != 2 ]
3189 xcall bail "be diet"
3190 endif
3191 echo "~^header insert cc <splice2@exam.ple>";\
3192 read es; echo $es; vput vexpr es substr "$es" 0 1
3193 if [ "$es" != 2 ]
3194 xcall bail "be diet2"
3195 endif
3197 call _work 2; echo $?
3198 echo "~^header insert bcc juicy juice <juice@exam.ple> spliced";\
3199 read es; echo $es;vput vexpr es substr "$es" 0 1
3200 if [ "$es" != 2 ]
3201 xcall bail "be juicy"
3202 endif
3203 echo "~^header insert bcc juice2@exam.ple";\
3204 read es; echo $es;vput vexpr es substr "$es" 0 1
3205 if [ "$es" != 2 ]
3206 xcall bail "be juicy2"
3207 endif
3208 echo "~^header insert bcc juice3 <juice3@exam.ple>";\
3209 read es; echo $es;vput vexpr es substr "$es" 0 1
3210 if [ "$es" != 2 ]
3211 xcall bail "be juicy3"
3212 endif
3213 echo "~^header insert bcc juice4@exam.ple";\
3214 read es; echo $es;vput vexpr es substr "$es" 0 1
3215 if [ "$es" != 2 ]
3216 xcall bail "be juicy4"
3217 endif
3219 echo "~^header remove-at bcc 3";\
3220 read es; echo $es;vput vexpr es substr "$es" 0 1
3221 if [ "$es" != 2 ]
3222 xcall bail "remove juicy5"
3223 endif
3224 echo "~^header remove-at bcc 2";\
3225 read es; echo $es;vput vexpr es substr "$es" 0 1
3226 if [ "$es" != 2 ]
3227 xcall bail "remove juicy6"
3228 endif
3229 echo "~^header remove-at bcc 3";\
3230 read es; echo $es;vput vexpr es substr "$es" 0 3
3231 if [ "$es" != 501 ]
3232 xcall bail "failed to remove-at"
3233 endif
3234 # Add duplicates which ought to be removed!
3235 echo "~^header insert bcc juice4@exam.ple";\
3236 read es; echo $es;vput vexpr es substr "$es" 0 1
3237 if [ "$es" != 2 ]
3238 xcall bail "be juicy4-1"
3239 endif
3240 echo "~^header insert bcc juice4@exam.ple";\
3241 read es; echo $es;vput vexpr es substr "$es" 0 1
3242 if [ "$es" != 2 ]
3243 xcall bail "be juicy4-2"
3244 endif
3245 echo "~^header insert bcc juice4@exam.ple";\
3246 read es; echo $es;vput vexpr es substr "$es" 0 1
3247 if [ "$es" != 2 ]
3248 xcall bail "be juicy4-3"
3249 endif
3250 echo "~:set t_ocs"
3253 call _work 3; echo $?
3254 echo "~r - '__EOT'"
3255 vput ! i echo just knock if you can hear me;\
3256 i=0;\
3257 while [ $i -lt 24 ]; do printf "%s " $i; i=`expr $i + 1`; done;\
3258 echo relax
3259 echon shell-cmd says $?/$^ERRNAME: $i
3260 echo "~x will not become interpreted, we are reading until __EOT"
3261 echo "__EOT"
3262 read r_status; echo "~~r status output: $r_status"
3263 echo "~:echo $? $! $^ERRNAME"
3264 read r_status
3265 echo "~~r status from parent: $r_status"
3268 call _work 4; echo $?
3269 vput cwd cwd;echo cwd:$?
3270 readctl create $cwd/.treadctl ;echo readctl:$?/$^ERRNAME;\
3271 call _read
3274 call _work 5; echo $?
3275 echo "~^header show MAILX-Command"; read es;\
3276 call xerr $es "t_header 1000"; call read_mline_res
3277 echo "~^header show MAILX-raw-TO"; read es;\
3278 call xerr $es "t_header 1001"; xcall read_mline_res
3280 echoerr IT IS WRONG IF YOU SEE THIS
3282 define t_oce {
3283 echo on-compose-enter, mailx-command<$mailx-command>
3284 set t_oce autobcc=oce@exam.ple
3285 alternates alter1@exam.ple alter2@exam.ple
3286 alternates
3287 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3288 echo mailx-subject<$mailx-subject>
3289 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3290 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3291 mailx-raw-bcc<$mailx-raw-bcc>
3292 echo mailx-orig-from<$mailx-orig-from> \
3293 mailx-orig-to<$mailx-orig-to> \
3294 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3296 define t_ocl {
3297 echo on-compose-leave, mailx-command<$mailx-command>
3298 set t_ocl autocc=ocl@exam.ple
3299 unalternates *
3300 alternates alter3@exam.ple alter4@exam.ple
3301 alternates
3302 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3303 echo mailx-subject<$mailx-subject>
3304 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3305 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3306 mailx-raw-bcc<$mailx-raw-bcc>
3307 echo mailx-orig-from<$mailx-orig-from> \
3308 mailx-orig-to<$mailx-orig-to> \
3309 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3311 define t_occ {
3312 echo on-compose-cleanup, mailx-command<$mailx-command>
3313 set t_occ autocc=occ@exam.ple
3314 unalternates *
3315 alternates
3316 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3317 echo mailx-subject<$mailx-subject>
3318 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3319 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3320 mailx-raw-bcc<$mailx-raw-bcc>
3321 echo mailx-orig-from<$mailx-orig-from> \
3322 mailx-orig-to<$mailx-orig-to> \
3323 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3325 wysh set on-compose-splice=t_ocs \
3326 on-compose-splice-shell="read ver;printf \"t_ocs-shell\\n\
3327 ~t shell@exam.ple\\n~:set t_ocs_sh\\n\"" \
3328 on-compose-enter=t_oce on-compose-leave=t_ocl \
3329 on-compose-cleanup=t_occ
3330 ' > ./.tnotes 2>&1
3331 ex0_test behave:compose_hooks-3
3332 ${cat} ./.tnotes >> "${MBOX}"
3334 check behave:compose_hooks-3 - "${MBOX}" '679526364 2431'
3336 # Reply, forward, resend, Resend
3338 ${rm} -f "${MBOX}"
3339 printf 'set from=f1@z\nm t1@z\nb1\n!.\nset from=f2@z\nm t2@z\nb2\n!.\n' |
3340 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! \
3341 -Smta=./.tsendmail.sh
3343 printf '
3344 echo start: $? $! $^ERRNAME
3345 File %s
3346 echo File: $? $! $^ERRNAME;echo;echo
3347 reply 1
3348 this is content of reply 1
3350 echo reply 1: $? $! $^ERRNAME;echo;echo
3351 Reply 1 2
3352 this is content of Reply 1 2
3354 echo Reply 1 2: $? $! $^ERRNAME;echo;echo
3355 forward 1 fwdex@am.ple
3356 this is content of forward 1
3358 echo forward 1: $? $! $^ERRNAME;echo;echo
3359 resend 1 2 resendex@am.ple
3360 echo resend 1 2: $? $! $^ERRNAME;echo;echo
3361 Resend 1 2 Resendex@am.ple
3362 echo Resend 1 2: $? $! $^ERRNAME;echo;echo
3363 ' "${MBOX}" |
3364 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! \
3365 -Smta=./.tsendmail.sh \
3367 define bail {
3368 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
3370 define xerr {
3371 vput vexpr es substr "$1" 0 1
3372 if [ "$es" != 2 ]
3373 xcall bail "$2"
3376 define read_mline_res {
3377 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
3378 echo mline_res:$len/$es/$^ERRNAME: $hl
3379 if [ $es -ne $^ERR-NONE ]
3380 xcall bail read_mline_res
3381 elif [ $len -ne 0 ]
3382 \xcall read_mline_res
3385 define work_hl {
3386 echo "~^header show $1"; read es;\
3387 call xerr $es "work_hl $1"; echo $1; call read_mline_res
3388 if [ $# -gt 1 ]
3389 shift
3390 xcall work_hl "$@"
3393 define t_ocs {
3394 read ver
3395 echo t_ocs version $ver
3396 echo "~^header list"; read hl; echo $hl;\
3397 echoerr the header list is $hl;\
3398 call xerr "$hl" "header list"
3399 eval vpospar set $hl
3400 shift
3401 xcall work_hl "$@"
3402 echoerr IT IS WRONG IF YOU SEE THIS
3404 define t_oce {
3405 echo on-XY-enter, mailx-command<$mailx-command>
3406 set t_oce autobcc=oce@exam.ple
3407 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3408 echo mailx-subject<$mailx-subject>
3409 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3410 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3411 mailx-raw-bcc<$mailx-raw-bcc>
3412 echo mailx-orig-from<$mailx-orig-from> \
3413 mailx-orig-to<$mailx-orig-to> \
3414 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3416 define t_ocl {
3417 echo on-XY-leave, mailx-command<$mailx-command>
3418 set t_ocl autocc=ocl@exam.ple
3419 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3420 echo mailx-subject<$mailx-subject>
3421 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3422 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3423 mailx-raw-bcc<$mailx-raw-bcc>
3424 echo mailx-orig-from<$mailx-orig-from> \
3425 mailx-orig-to<$mailx-orig-to> \
3426 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3428 define t_occ {
3429 echo on-XY-cleanup, mailx-command<$mailx-command>
3430 set t_occ autocc=occ@exam.ple
3431 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3432 echo mailx-subject<$mailx-subject>
3433 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3434 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3435 mailx-raw-bcc<$mailx-raw-bcc>
3436 echo mailx-orig-from<$mailx-orig-from> \
3437 mailx-orig-to<$mailx-orig-to> \
3438 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3440 wysh set on-compose-splice=t_ocs \
3441 on-compose-enter=t_oce on-compose-leave=t_ocl \
3442 on-compose-cleanup=t_occ \
3443 on-resend-enter=t_oce on-resend-cleanup=t_occ
3444 ' > ./.tnotes 2>&1
3445 ex0_test behave:compose_hooks-4
3446 ${cat} ./.tnotes >> "${MBOX}"
3448 check behave:compose_hooks-4 - "${MBOX}" '3038884027 7516'
3450 t_epilog
3453 t_behave_message_injections() {
3454 t_prolog
3455 TRAP_EXIT_ADDONS="./.t*"
3457 ${cat} <<-_EOT > ./.tsendmail.sh
3458 #!${MYSHELL} -
3459 (echo 'From Echinacea Tue Jun 20 15:54:02 2017' && ${cat} && echo
3460 ) > "${MBOX}"
3461 _EOT
3462 chmod 0755 ./.tsendmail.sh
3464 echo mysig > ./.tmysig
3466 echo some-body | ${MAILX} ${ARGS} -Smta=./.tsendmail.sh \
3467 -Smessage-inject-head=head-inject \
3468 -Smessage-inject-tail=tail-inject \
3469 -Ssignature=./.tmysig \
3470 ex@am.ple > ./.tall 2>&1
3471 check behave:message_injections-1 0 "${MBOX}" '2434746382 134'
3472 check behave:message_injections-2 - .tall '4294967295 0' # empty file
3474 ${cat} <<-_EOT > ./.template
3475 From: me
3476 To: ex1@am.ple
3477 Cc: ex2@am.ple
3478 Subject: This subject is
3480 Body, body, body me.
3481 _EOT
3482 < ./.template ${MAILX} ${ARGS} -t -Smta=./.tsendmail.sh \
3483 -Smessage-inject-head=head-inject \
3484 -Smessage-inject-tail=tail-inject \
3485 -Ssignature=./.tmysig \
3486 > ./.tall 2>&1
3487 check behave:message_injections-3 0 "${MBOX}" '3114203412 198'
3488 check behave:message_injections-4 - .tall '4294967295 0' # empty file
3490 t_epilog
3493 t_behave_mime_types_load_control() {
3494 t_prolog
3495 TRAP_EXIT_ADDONS="./.t*"
3497 ${cat} <<-_EOT > ./.tmts1
3498 @ application/mathml+xml mathml
3499 _EOT
3500 ${cat} <<-_EOT > ./.tmts2
3501 @ x-conference/x-cooltalk ice
3502 @ aga-aga aga
3503 @ application/aga-aga aga
3504 _EOT
3506 ${cat} <<-_EOT > ./.tmts1.mathml
3507 <head>nonsense ML</head>
3508 _EOT
3509 ${cat} <<-_EOT > ./.tmts2.ice
3510 Icy, icy road.
3511 _EOT
3512 printf 'of which the c\x01rack is coming soon' > ./.tmtsx.doom
3513 printf 'of which the c\x01rack is coming soon' > ./.tmtsx.aga
3515 printf '
3516 m %s
3517 Schub-di-du
3518 ~@ ./.tmts1.mathml
3519 ~@ ./.tmts2.ice
3520 ~@ ./.tmtsx.doom
3521 ~@ ./.tmtsx.aga
3523 File %s
3524 from*
3525 type
3527 ' "${MBOX}" "${MBOX}" |
3528 ${MAILX} ${ARGS} \
3529 -Smimetypes-load-control=f=./.tmts1,f=./.tmts2 \
3530 > ./.tout 2>&1
3531 ex0_test behave:mime_types_load_control
3533 ${cat} "${MBOX}" >> ./.tout
3534 check behave:mime_types_load_control-1 - ./.tout '3270459399 2460'
3536 echo type | ${MAILX} ${ARGS} -R \
3537 -Smimetypes-load-control=f=./.tmts1,f=./.tmts3 \
3538 -f "${MBOX}" >> ./.tout 2>&1
3539 check behave:mime_types_load_control-2 0 ./.tout '2258163974 3530'
3541 t_epilog
3544 t_behave_smime() {
3545 have_feat smime || {
3546 echo 'behave:s/mime: unsupported, skipped'
3547 return
3550 t_prolog
3551 TRAP_EXIT_ADDONS="./.t.conf ./.tkey.pem ./.tcert.pem ./.tpair.pem"
3552 TRAP_EXIT_ADDONS="${TRAP_EXIT_ADDONS} ./.VERIFY ./.DECRYPT ./.ENCRYPT"
3553 TRAP_EXIT_ADDONS="${TRAP_EXIT_ADDONS} ./.tsendmail.sh"
3555 printf 'behave:s/mime: .. generating test key and certificate ..\n'
3556 ${cat} <<-_EOT > ./.t.conf
3557 [ req ]
3558 default_bits = 1024
3559 default_keyfile = keyfile.pem
3560 distinguished_name = req_distinguished_name
3561 attributes = req_attributes
3562 prompt = no
3563 output_password =
3565 [ req_distinguished_name ]
3566 C = GB
3567 ST = Over the
3568 L = rainbow
3569 O = S-nail
3570 OU = S-nail.smime
3571 CN = S-nail.test
3572 emailAddress = test@localhost
3574 [ req_attributes ]
3575 challengePassword =
3576 _EOT
3577 openssl req -x509 -nodes -days 3650 -config ./.t.conf \
3578 -newkey rsa:1024 -keyout ./.tkey.pem -out ./.tcert.pem >/dev/null 2>&1
3579 ${cat} ./.tkey.pem ./.tcert.pem > ./.tpair.pem
3581 # Sign/verify
3582 printf 'behave:s/mime:sign/verify: '
3583 echo bla | ${MAILX} ${ARGS} \
3584 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
3585 -Ssmime-sign -Sfrom=test@localhost \
3586 -s 'S/MIME test' ./.VERIFY
3587 if [ $? -eq 0 ]; then
3588 printf 'ok\n'
3589 else
3590 printf 'failed\n'
3591 ESTAT=1
3592 t_epilog
3593 return
3596 ${awk} '
3597 BEGIN{ skip=0 }
3598 /^Content-Description: /{ skip = 2; print; next }
3599 /^$/{ if(skip) --skip }
3600 { if(!skip) print }
3602 < ./.VERIFY > "${MBOX}"
3603 check behave:s/mime:sign/verify:checksum - "${MBOX}" '2900817158 648'
3605 printf 'behave:s/mime:sign/verify:verify '
3606 printf 'verify\nx\n' |
3607 ${MAILX} ${ARGS} \
3608 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
3609 -Ssmime-sign -Sfrom=test@localhost \
3610 -Serrexit -R \
3611 -f ./.VERIFY >/dev/null 2>&1
3612 if [ $? -eq 0 ]; then
3613 printf 'ok\n'
3614 else
3615 printf 'failed\n'
3616 ESTAT=1
3617 t_epilog
3618 return
3621 printf 'behave:s/mime:sign/verify:disproof-1 '
3622 if openssl smime -verify -CAfile ./.tcert.pem \
3623 -in ./.VERIFY >/dev/null 2>&1; then
3624 printf 'ok\n'
3625 else
3626 printf 'failed\n'
3627 ESTAT=1
3628 t_epilog
3629 return
3632 # (signing +) encryption / decryption
3633 ${cat} <<-_EOT > ./.tsendmail.sh
3634 #!${MYSHELL} -
3635 (echo 'From Euphrasia Thu Apr 27 17:56:23 2017' && ${cat}) > ./.ENCRYPT
3636 _EOT
3637 chmod 0755 ./.tsendmail.sh
3639 printf 'behave:s/mime:encrypt+sign: '
3640 echo bla |
3641 ${MAILX} ${ARGS} \
3642 -Ssmime-force-encryption \
3643 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
3644 -Smta=./.tsendmail.sh \
3645 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
3646 -Ssmime-sign -Sfrom=test@localhost \
3647 -s 'S/MIME test' recei@ver.com
3648 if [ $? -eq 0 ]; then
3649 printf 'ok\n'
3650 else
3651 ESTAT=1
3652 printf 'error: encrypt+sign failed\n'
3655 ${sed} -e '/^$/,$d' < ./.ENCRYPT > "${MBOX}"
3656 check behave:s/mime:encrypt+sign:checksum - "${MBOX}" '1937410597 327'
3658 printf 'behave:s/mime:decrypt+verify: '
3659 printf 'decrypt ./.DECRYPT\nfi ./.DECRYPT\nverify\nx\n' |
3660 ${MAILX} ${ARGS} \
3661 -Ssmime-force-encryption \
3662 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
3663 -Smta=./.tsendmail.sh \
3664 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
3665 -Ssmime-sign -Sfrom=test@localhost \
3666 -Serrexit -R \
3667 -f ./.ENCRYPT >/dev/null 2>&1
3668 if [ $? -eq 0 ]; then
3669 printf 'ok\n'
3670 else
3671 ESTAT=1
3672 printf 'failed\n'
3675 ${awk} '
3676 BEGIN{ skip=0 }
3677 /^Content-Description: /{ skip = 2; print; next }
3678 /^$/{ if(skip) --skip }
3679 { if(!skip) print }
3681 < ./.DECRYPT > "${MBOX}"
3682 check behave:s/mime:decrypt+verify:checksum - "${MBOX}" '1720739247 931'
3684 printf 'behave:s/mime:decrypt+verify:disproof-1: '
3685 if (openssl smime -decrypt -inkey ./.tkey.pem -in ./.ENCRYPT |
3686 openssl smime -verify -CAfile ./.tcert.pem) >/dev/null 2>&1; then
3687 printf 'ok\n'
3688 else
3689 printf 'failed\n'
3690 ESTAT=1
3693 printf "behave:s/mime:encrypt: "
3694 echo bla | ${MAILX} ${ARGS} \
3695 -Ssmime-force-encryption \
3696 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
3697 -Smta=./.tsendmail.sh \
3698 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
3699 -Sfrom=test@localhost \
3700 -s 'S/MIME test' recei@ver.com
3701 if [ $? -eq 0 ]; then
3702 printf 'ok\n'
3703 else
3704 ESTAT=1
3705 printf 'failed\n'
3708 # Same as behave:s/mime:encrypt+sign:checksum above
3709 ${sed} -e '/^$/,$d' < ./.ENCRYPT > "${MBOX}"
3710 check behave:s/mime:encrypt:checksum - "${MBOX}" '1937410597 327'
3712 ${rm} -f ./.DECRYPT
3713 printf 'decrypt ./.DECRYPT\nx\n' | ${MAILX} ${ARGS} \
3714 -Ssmime-force-encryption \
3715 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
3716 -Smta=./.tsendmail.sh \
3717 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
3718 -Sfrom=test@localhost \
3719 -Serrexit -R \
3720 -f ./.ENCRYPT >/dev/null 2>&1
3721 check behave:s/mime:decrypt 0 "./.DECRYPT" '2624716890 422'
3723 printf 'behave:s/mime:decrypt:disproof-1: '
3724 if openssl smime -decrypt -inkey ./.tkey.pem \
3725 -in ./.ENCRYPT >/dev/null 2>&1; then
3726 printf 'ok\n'
3727 else
3728 printf 'failed\n'
3729 ESTAT=1
3732 t_epilog
3735 t_behave_maildir() {
3736 t_prolog
3737 TRAP_EXIT_ADDONS="./.t*"
3741 while [ ${i} -lt 112 ]; do
3742 printf 'm file://%s\n~s Subject %s\nHello %s!\n~.\n' \
3743 "${MBOX}" "${i}" "${i}"
3744 i=`add ${i} 1`
3745 done
3746 ) | ${MAILX} ${ARGS}
3747 check behave:maildir-1 0 "${MBOX}" '1140119864 13780'
3749 printf 'File "%s"
3750 copy * "%s"
3751 File "%s"
3752 from*
3753 ' "${MBOX}" .tmdir1 .tmdir1 |
3754 ${MAILX} ${ARGS} -Snewfolders=maildir > .tlst
3755 check behave:maildir-2 0 .tlst '1797938753 9103'
3757 printf 'File "%s"
3758 copy * "maildir://%s"
3759 File "maildir://%s"
3760 from*
3761 ' "${MBOX}" .tmdir2 .tmdir2 |
3762 ${MAILX} ${ARGS} > .tlst
3763 check behave:maildir-3 0 .tlst '1155631089 9113'
3765 printf 'File "maildir://%s"
3766 copy * "file://%s"
3767 File "file://%s"
3768 from*
3769 ' .tmdir2 .tmbox1 .tmbox1 |
3770 ${MAILX} ${ARGS} > .tlst
3771 check behave:maildir-4 0 .tmbox1 '2646131190 13220'
3772 check behave:maildir-5 - .tlst '3701297796 9110'
3774 # only the odd (even)
3776 printf 'File "maildir://%s"
3777 copy ' .tmdir2
3779 while [ ${i} -lt 112 ]; do
3780 j=`modulo ${i} 2`
3781 [ ${j} -eq 1 ] && printf '%s ' "${i}"
3782 i=`add ${i} 1`
3783 done
3784 printf ' file://%s
3785 File "file://%s"
3786 from*
3787 ' .tmbox2 .tmbox2
3788 ) | ${MAILX} ${ARGS} > .tlst
3789 check behave:maildir-6 0 .tmbox2 '142890131 6610'
3790 check behave:maildir-7 - .tlst '960096773 4573'
3791 # ...
3793 printf 'file "maildir://%s"
3794 move ' .tmdir2
3796 while [ ${i} -lt 112 ]; do
3797 j=`modulo ${i} 2`
3798 [ ${j} -eq 0 ] && [ ${i} -ne 0 ] && printf '%s ' "${i}"
3799 i=`add ${i} 1`
3800 done
3801 printf ' file://%s
3802 File "file://%s"
3803 from*
3804 File "maildir://%s"
3805 from*
3806 ' .tmbox2 .tmbox2 .tmdir2
3807 ) | ${MAILX} ${ARGS} > .tlst
3808 check behave:maildir-8 0 .tmbox2 '3806905791 13100'
3809 ${sed} 2d < .tlst > .tlstx
3810 check behave:maildir-9 - .tlstx '4216815295 13645'
3812 t_epilog
3815 t_behave_mass_recipients() {
3816 t_prolog
3817 TRAP_EXIT_ADDONS="./.t*"
3819 ${cat} <<-_EOT > ./.tsendmail.sh
3820 #!${MYSHELL} -
3821 (echo 'From Eucalyptus Sat Jul 08 21:14:57 2017' && ${cat} && echo
3822 ) >> "${MBOX}"
3823 _EOT
3824 chmod 0755 ./.tsendmail.sh
3826 ${cat} <<'__EOT__' > ./.trc
3827 define bail {
3828 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
3830 define ins_addr {
3831 wysh set nr=$1 hn=$2
3832 echo "~$hn $hn$nr@$hn"; echo '~:echo $?'; read es
3833 if [ "$es" -ne 0 ]
3834 xcall bail "ins_addr $hn 1-$nr"
3836 vput vexpr nr + $nr 1
3837 if [ "$nr" -le "$maximum" ]
3838 xcall ins_addr $nr $hn
3841 define bld_alter {
3842 wysh set nr=$1 hn=$2
3843 alternates $hn$nr@$hn
3844 vput vexpr nr + $nr 2
3845 if [ "$nr" -le "$maximum" ]
3846 xcall bld_alter $nr $hn
3849 define t_ocs {
3850 read ver
3851 call ins_addr 1 t
3852 call ins_addr 1 c
3853 call ins_addr 1 b
3855 define t_ocl {
3856 if [ "$t_remove" != '' ]
3857 call bld_alter 1 t
3858 call bld_alter 2 c
3861 set on-compose-splice=t_ocs on-compose-leave=t_ocl
3862 __EOT__
3864 ${rm} -f "${MBOX}"
3865 printf 'm this-goes@nowhere\nbody\n!.\n' |
3866 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
3867 -X'source ./.trc' -Smta=./.tsendmail.sh -Smaximum=2001 \
3868 >./.tall 2>&1
3869 ${cat} ./.tall >> "${MBOX}"
3870 check behave:mass_recipients-1 0 "${MBOX}" '2912243346 51526'
3872 ${rm} -f "${MBOX}"
3873 printf 'm this-goes@nowhere\nbody\n!.\n' |
3874 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
3875 -St_remove=1 -X'source ./.trc' -Smta=./.tsendmail.sh -Smaximum=2001 \
3876 >./.tall 2>&1
3877 ${cat} ./.tall >> "${MBOX}"
3878 check behave:mass_recipients-2 0 "${MBOX}" '4097804632 34394'
3880 t_epilog
3883 t_behave_lreply_futh_rth_etc() {
3884 t_prolog
3885 TRAP_EXIT_ADDONS="./.t*"
3887 ${cat} <<-_EOT > ./.tsendmail.sh
3888 #!${MYSHELL} -
3889 (echo 'From HumulusLupulus Thu Jul 27 14:41:20 2017' && ${cat} && echo
3890 ) >> "${MBOX}"
3891 _EOT
3892 chmod 0755 ./.tsendmail.sh
3894 ${cat} <<-_EOT > ./.tmbox
3895 From neverneverland Sun Jul 23 13:46:25 2017
3896 Subject: Bugstop: five miles out 1
3897 Reply-To: mister originator2 <mr2@originator>, bugstop@five.miles.out
3898 From: mister originator <mr@originator>
3899 To: bugstop-commit@five.miles.out, laber@backe.eu
3900 Cc: is@a.list
3901 Mail-Followup-To: bugstop@five.miles.out, laber@backe.eu, is@a.list
3902 In-reply-to: <20170719111113.bkcMz%laber@backe.eu>
3903 Date: Wed, 19 Jul 2017 09:22:57 -0400
3904 Message-Id: <20170719132257.766AF781267@originator>
3905 Status: RO
3907 > |Sorry, I think I misunderstand something. I would think that
3909 That's appalling.
3911 From neverneverland Fri Jul 7 22:39:11 2017
3912 Subject: Bugstop: five miles out 2
3913 Reply-To: mister originator2<mr2@originator>,bugstop@five.miles.out,is@a.list
3914 Content-Transfer-Encoding: 7bit
3915 From: mister originator <mr@originator>
3916 To: bugstop-commit@five.miles.out
3917 Cc: is@a.list
3918 Message-ID: <149945963975.28888.6950788126957753723.reportbug@five.miles.out>
3919 Date: Fri, 07 Jul 2017 16:33:59 -0400
3920 Status: R
3922 capable of changing back.
3924 From neverneverland Fri Jul 7 22:42:00 2017
3925 Subject: Bugstop: five miles out 3
3926 Reply-To: mister originator2 <mr2@originator>, bugstop@five.miles.out
3927 Content-Transfer-Encoding: 7bit
3928 From: mister originator <mr@originator>
3929 To: bugstop-commit@five.miles.out
3930 Cc: is@a.list
3931 Message-ID: <149945963975.28888.6950788126957753746.reportbug@five.miles.out>
3932 Date: Fri, 07 Jul 2017 16:33:59 -0400
3933 List-Post: <mailto:bugstop@five.miles.out>
3934 Status: R
3936 are you ready, boots?
3938 _EOT
3942 printf '
3943 define r {
3944 wysh set m="This is text of \\\"reply ${1}."
3945 reply 1 2 3
3946 !I m
3949 !I m
3952 !I m
3955 echo -----After reply $1.1 - $1.3: $?/$^ERRNAME
3957 define R {
3958 wysh set m="This is text of \\\"Reply ${1}."
3959 eval Reply $2
3960 !I m
3961 !I 2
3964 echo -----After Reply $1.$2: $?/$^ERRNAME
3966 define _Lh {
3967 read protover
3968 echo '"'"'~I m'"'"'
3969 echo '"'"'~I n'"'"'
3970 echo '"'"'".'"'"'
3972 define _Ls {
3973 wysh set m="This is text of \\\"Lreply ${1}." \\
3974 on-compose-splice=_Lh n=$2
3975 eval Lreply $2
3977 define L {
3978 # We need two indirections for this test: one for the case that Lreply
3979 # fails because if missing recipients, we need to read EOF next, thus
3980 # place this in _Ls last, and second for the succeeding cases EOF is
3981 # not what these should read, so go over the backside and splice it in!
3982 call _Ls "$@"
3983 echo -----After Lreply $1.$2: $?/$^ERRNAME
3985 define x {
3986 localopts call-fixate yes
3987 call r $1
3988 call R $1 1; call R $1 2; call R $1 3
3989 call L $1 1; call L $1 2; call L $1 3
3991 define tweak {
3992 echo;echo '"'"'===== CHANGING === '"'"'"$*"'"'"' ====='"'"';echo
3993 eval "$@"
3996 set from=laber@backe.eu
3997 mlist is@a.list
3998 call x 1
3999 call tweak set reply-to-honour
4000 call x 2
4001 call tweak set followup-to
4002 call x 3
4003 call tweak set followup-to-honour
4004 call x 4
4005 call tweak mlist bugstop@five.miles.out
4006 call x 5
4007 call tweak mlsubscribe bugstop@five.miles.out
4008 call x 6
4009 call tweak set recipients-in-cc
4010 call x 7
4011 ' | ${MAILX} ${ARGS} -Sescape=! -Smta=./.tsendmail.sh \
4012 -Rf ./.tmbox >> "${MBOX}" 2>&1
4014 check behave:lreply_futh_rth_etc 0 "${MBOX}" '2491739775 22062'
4016 t_epilog
4019 t_behave_iconv_mbyte_base64() {
4020 t_prolog
4021 TRAP_EXIT_ADDONS="./.t*"
4023 if [ -n "${UTF8_LOCALE}" ] && have_feat iconv &&
4024 command -v iconv >/dev/null 2>&1 &&
4025 ( iconv -l | ${grep} -i -e iso-2022-jp -e euc-jp) >/dev/null 2>&1; then
4027 else
4028 echo 'behave:iconv_mbyte_base64: unsupported, skipped'
4029 return
4032 ${cat} <<-_EOT > ./.tsendmail.sh
4033 #!${MYSHELL} -
4034 (echo 'From DroseriaRotundifolia Thu Aug 03 17:26:25 2017' && ${cat} &&
4035 echo) >> "${MBOX}"
4036 _EOT
4037 chmod 0755 ./.tsendmail.sh
4039 if ( iconv -l | ${grep} -i iso-2022-jp ) >/dev/null 2>&1; then
4040 printf '
4041 set ttycharset=utf-8 sendcharsets=iso-2022-jp
4042 m t1@exam.ple
4043 !s Japanese from UTF-8 to ISO-2022-JP
4044 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
4046 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
4049 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
4051 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
4054 set ttycharset=iso-2022-jp charset-7bit=iso-2022-jp sendcharsets=utf-8
4055 m t2@exam.ple
4056 !s Japanese from ISO-2022-JP to UTF-8, eh, no, also ISO-2022-JP
4057 \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
4059 \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
4062 \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
4064 \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
4066 ' | LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} -Smta=./.tsendmail.sh \
4067 -Sescape=! -Smime-encoding=base64 2>./.terr
4068 check behave:iconv_mbyte_base64-1 0 "${MBOX}" '3428985079 1976'
4069 check behave:iconv_mbyte_base64-2 - ./.terr '4294967295 0'
4071 printf 'eval f 1; write ./.twrite\n' |
4072 ${MAILX} ${ARGS} ${ADDARG_UNI} -Rf "${MBOX}" >./.tlog 2>&1
4073 check behave:iconv_mbyte_base64-3 0 ./.twrite '1259742080 686'
4074 check behave:iconv_mbyte_base64-4 - ./.tlog '3956097665 119'
4075 else
4076 echo 'behave:iconv_mbyte_base64: ISO-2022-JP unsupported, skipping 1-4'
4079 if ( iconv -l | ${grep} -i euc-jp ) >/dev/null 2>&1; then
4080 rm -f "${MBOX}" ./.twrite
4081 printf '
4082 set ttycharset=utf-8 sendcharsets=euc-jp
4083 m t1@exam.ple
4084 !s Japanese from UTF-8 to EUC-JP
4085 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
4087 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
4090 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
4092 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
4095 set ttycharset=EUC-JP sendcharsets=utf-8
4096 m t2@exam.ple
4097 !s Japanese from EUC-JP to UTF-8
4098 ¥·¥¸¥å¥¦¥«¥é²Ê¡Ê¥·¥¸¥å¥¦¥«¥é¤«¡¢³Ø̾ Paridae¡Ë¤Ï¡¢Ä»Îॹ¥º¥áÌܤβʤǤ¢¤ë¡£¥·¥¸¥å¥¦¥«¥é¡Ê»Í½½¿ý¡Ë¤ÈÁí¾Î¤µ¤ì¤ë¤¬¡¢¶¹µÁ¤Ë¤Ï¤³¤Î1¼ï¤ò¥·¥¸¥å¥¦¥«¥é¤È¸Æ¤Ö¡£
4100 ¥«¥ó¥à¥ê¥¬¥é¡Ê³Ø̾Parus cristatus¡Ë¤Ï¡¢¥¹¥º¥áÌÜ¥·¥¸¥å¥¦¥«¥é²Ê¤ËʬÎव¤ì¤ëÄ»Îà¤Î°ì¼ï¡£
4103 ¥«¥ó¥à¥ê¥¬¥é¡Ê³Ø̾Parus cristatus¡Ë¤Ï¡¢¥¹¥º¥áÌÜ¥·¥¸¥å¥¦¥«¥é²Ê¤ËʬÎव¤ì¤ëÄ»Îà¤Î°ì¼ï¡£
4105 ¥·¥¸¥å¥¦¥«¥é²Ê¡Ê¥·¥¸¥å¥¦¥«¥é¤«¡¢³Ø̾ Paridae¡Ë¤Ï¡¢Ä»Îॹ¥º¥áÌܤβʤǤ¢¤ë¡£¥·¥¸¥å¥¦¥«¥é¡Ê»Í½½¿ý¡Ë¤ÈÁí¾Î¤µ¤ì¤ë¤¬¡¢¶¹µÁ¤Ë¤Ï¤³¤Î1¼ï¤ò¥·¥¸¥å¥¦¥«¥é¤È¸Æ¤Ö¡£
4107 ' | LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} -Smta=./.tsendmail.sh \
4108 -Sescape=! -Smime-encoding=base64 2>./.terr
4109 check behave:iconv_mbyte_base64-5 0 "${MBOX}" '1686827547 2051'
4110 check behave:iconv_mbyte_base64-6 - ./.terr '4294967295 0'
4112 printf 'eval f 1; write ./.twrite\n' |
4113 ${MAILX} ${ARGS} ${ADDARG_UNI} -Rf "${MBOX}" >./.tlog 2>&1
4114 check behave:iconv_mbyte_base64-7 0 ./.twrite '1259742080 686'
4115 check behave:iconv_mbyte_base64-8 - ./.tlog '500059195 119'
4116 else
4117 echo 'behave:iconv_mbyte_base64: EUC-JP unsupported, skipping 5-8'
4120 t_epilog
4123 # t_content()
4124 # Some basic tests regarding correct sending of mails, via STDIN / -t / -q,
4125 # including basic MIME Content-Transfer-Encoding correctness (quoted-printable)
4126 # Note we unfortunately need to place some statements without proper
4127 # indentation because of continuation problems
4128 t_content() {
4129 t_prolog
4131 # MIME encoding (QP) stress message body
4132 printf \
4133 'Ich bin eine DÖS-Datäi mit sehr langen Zeilen und auch '\
4134 'sonst bin ich ganz schön am Schleudern, da kannste denke '\
4135 "wasde willst, gelle, gelle, gelle, gelle, gelle.\r\n"\
4136 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst \r\n"\
4137 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1\r\n"\
4138 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12\r\n"\
4139 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123\r\n"\
4140 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1234\r\n"\
4141 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12345\r\n"\
4142 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123456\r\n"\
4143 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1234567\r\n"\
4144 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12345678\r\n"\
4145 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123456789\r\n"\
4146 "Unn ausserdem habe ich trailing SP/HT/SP/HT whitespace \r\n"\
4147 "Unn ausserdem habe ich trailing HT/SP/HT/SP whitespace \r\n"\
4148 "auf den zeilen vorher.\r\n"\
4149 "From am Zeilenbeginn und From der Mitte gibt es auch.\r\n"\
4150 ".\r\n"\
4151 "Die letzte Zeile war nur ein Punkt.\r\n"\
4152 "..\r\n"\
4153 "Das waren deren zwei.\r\n"\
4154 " \r\n"\
4155 "Die letzte Zeile war ein Leerschritt.\n"\
4156 "=VIER = EQUAL SIGNS=ON A LINE=\r\n"\
4157 "Prösterchen.\r\n"\
4158 ".\n"\
4159 "Die letzte Zeile war nur ein Punkt, mit Unix Zeilenende.\n"\
4160 "..\n"\
4161 "Das waren deren zwei. ditto.\n"\
4162 "Prösterchen.\n"\
4163 "Unn ausseerdem habe ich trailing SP/HT/SP/HT whitespace \n"\
4164 "Unn ausseerdem habe ich trailing HT/SP/HT/SP whitespace \n"\
4165 "auf den zeilen vorher.\n"\
4166 "ditto.\n"\
4167 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.\n"\
4168 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.1"\
4169 "\n"\
4170 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
4171 "\n"\
4172 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
4173 "3\n"\
4174 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
4175 "34\n"\
4176 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
4177 "345\n"\
4178 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
4179 "3456\n"\
4180 "QP am Zeilenende über soft-nl hinweg\n"\
4181 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
4182 "ö123\n"\
4183 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
4184 "1ö23\n"\
4185 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
4186 "12ö3\n"\
4187 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
4188 "123ö\n"\
4189 "=VIER = EQUAL SIGNS=ON A LINE=\n"\
4190 " \n"\
4191 "Die letzte Zeile war ein Leerschritt.\n"\
4192 ' '\
4193 > "${BODY}"
4195 # MIME encoding (QP) stress message subject
4196 SUB="Äbrä Kä?dä=brö Fü?di=bus? \
4197 adadaddsssssssddddddddddddddddddddd\
4198 ddddddddddddddddddddddddddddddddddd\
4199 ddddddddddddddddddddddddddddddddddd\
4200 dddddddddddddddddddd Hallelulja? Od\
4201 er?? eeeeeeeeeeeeeeeeeeeeeeeeeeeeee\
4202 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\
4203 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee f\
4204 fffffffffffffffffffffffffffffffffff\
4205 fffffffffffffffffffff ggggggggggggg\
4206 ggggggggggggggggggggggggggggggggggg\
4207 ggggggggggggggggggggggggggggggggggg\
4208 ggggggggggggggggggggggggggggggggggg\
4209 gggggggggggggggg"
4211 # Three tests for MIME encoding and (a bit) content classification.
4212 # At the same time testing -q FILE, < FILE and -t FILE
4214 ${rm} -f "${MBOX}"
4215 < "${BODY}" ${MAILX} ${ARGS} ${ADDARG_UNI} \
4216 -a "${BODY}" -s "${SUB}" "${MBOX}"
4217 check content:001 0 "${MBOX}" '1145066634 6654'
4219 ${rm} -f "${MBOX}"
4220 < /dev/null ${MAILX} ${ARGS} ${ADDARG_UNI} \
4221 -a "${BODY}" -s "${SUB}" -q "${BODY}" "${MBOX}"
4222 check content:002 0 "${MBOX}" '1145066634 6654'
4224 ${rm} -f "${MBOX}"
4225 ( echo "To: ${MBOX}" && echo "Subject: ${SUB}" && echo &&
4226 ${cat} "${BODY}"
4227 ) | ${MAILX} ${ARGS} ${ADDARG_UNI} -Snodot -a "${BODY}" -t
4228 check content:003 0 "${MBOX}" '1145066634 6654'
4230 # Test for [260e19d] (Juergen Daubert)
4231 ${rm} -f "${MBOX}"
4232 echo body | ${MAILX} ${ARGS} "${MBOX}"
4233 check content:004 0 "${MBOX}" '2917662811 98'
4235 # Sending of multiple mails in a single invocation
4236 ${rm} -f "${MBOX}"
4237 ( printf "m ${MBOX}\n~s subject1\nE-Mail Körper 1\n~.\n" &&
4238 printf "m ${MBOX}\n~s subject2\nEmail body 2\n~.\n" &&
4239 echo x
4240 ) | ${MAILX} ${ARGS} ${ADDARG_UNI}
4241 check content:005 0 "${MBOX}" '2098659767 358'
4243 ## $BODY CHANGED
4245 # "Test for" [d6f316a] (Gavin Troy)
4246 ${rm} -f "${MBOX}"
4247 printf "m ${MBOX}\n~s subject1\nEmail body\n~.\nfi ${MBOX}\np\nx\n" |
4248 ${MAILX} ${ARGS} ${ADDARG_UNI} -Spipe-text/plain="@* ${cat}" > "${BODY}"
4249 check content:006 0 "${MBOX}" '2099098650 122'
4250 check content:006-1 - "${BODY}" '794542938 174'
4252 # "Test for" [c299c45] (Peter Hofmann) TODO shouldn't end up QP-encoded?
4253 ${rm} -f "${MBOX}"
4254 ${awk} 'BEGIN{
4255 for(i = 0; i < 10000; ++i)
4256 printf "\xC3\xBC"
4257 #printf "\xF0\x90\x87\x90"
4258 }' | ${MAILX} ${ARGS} ${ADDARG_UNI} -s TestSubject "${MBOX}"
4259 check content:007 0 "${MBOX}" '534262374 61816'
4261 ## Test some more corner cases for header bodies (as good as we can today) ##
4264 ${rm} -f "${MBOX}"
4265 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
4266 -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̲' \
4267 "${MBOX}"
4268 check content:008 0 "${MBOX}" '3370931614 375'
4270 # Single word (overlong line split -- bad standard! Requires injection of
4271 # artificial data!! But can be prevented by using RFC 2047 encoding)
4272 ${rm} -f "${MBOX}"
4273 i=`${awk} 'BEGIN{for(i=0; i<92; ++i) printf "0123456789_"}'`
4274 echo | ${MAILX} ${ARGS} -s "${i}" "${MBOX}"
4275 check content:009 0 "${MBOX}" '489922370 1718'
4277 # Combination of encoded words, space and tabs of varying sort
4278 ${rm} -f "${MBOX}"
4279 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
4280 -s "1Abrä Kaspas1 2Abra Katä b_kaspas2 \
4281 3Abrä Kaspas3 4Abrä Kaspas4 5Abrä Kaspas5 \
4282 6Abra Kaspas6 7Abrä Kaspas7 8Abra Kaspas8 \
4283 9Abra Kaspastäb4-3 10Abra Kaspas1 _ 11Abra Katäb1 \
4284 12Abra Kadabrä1 After Tab after Täb this is NUTS" \
4285 "${MBOX}"
4286 check content:010 0 "${MBOX}" '1676887734 591'
4288 # Overlong multibyte sequence that must be forcefully split
4289 # todo This works even before v15.0, but only by accident
4290 ${rm} -f "${MBOX}"
4291 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
4292 -s "✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
4293 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
4294 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄" \
4295 "${MBOX}"
4296 check content:011 0 "${MBOX}" '3029301775 659'
4298 # Trailing WS
4299 ${rm} -f "${MBOX}"
4300 echo | ${MAILX} ${ARGS} \
4301 -s "1-1 B2 B3 B4 B5 B6 B\
4302 1-2 B2 B3 B4 B5 B6 B\
4303 1-3 B2 B3 B4 B5 B6 B\
4304 1-4 B2 B3 B4 B5 B6 B\
4305 1-5 B2 B3 B4 B5 B6 B\
4306 1-6 B2 B3 B4 B5 B6 " \
4307 "${MBOX}"
4308 check content:012 0 "${MBOX}" '4126167195 297'
4310 # Leading and trailing WS
4311 ${rm} -f "${MBOX}"
4312 echo | ${MAILX} ${ARGS} \
4313 -s " 2-1 B2 B3 B4 B5 B6 B\
4314 1-2 B2 B3 B4 B5 B6 B\
4315 1-3 B2 B3 B4 B5 B6 B\
4316 1-4 B2 B3 B4 B5 B6 " \
4317 "${MBOX}"
4318 check content:013 0 "${MBOX}" '3600624479 236'
4320 # Quick'n dirty RFC 2231 test; i had more when implementing it, but until we
4321 # have a (better) test framework materialize a quick shot
4322 ${rm} -f "${MBOX}"
4323 TRAP_EXIT_ADDONS=./.ttt
4325 mkdir ./.ttt || exit 1
4326 cd ./.ttt || exit 2
4327 : > "ma'ger.txt"
4328 : > "mä'ger.txt"
4329 : > 'diet\ is \curd.txt'
4330 : > 'diet "is" curd.txt'
4331 : > höde-tröge.txt
4332 : > 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
4333 : > höde__tröge__müde__dätte__hätte__vuelle__guelle__aese__aesse__sauerliche__kräuter__österliche__grüße__mäh.txt
4334 : > hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt
4335 : > ✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt
4337 echo bla | ${MAILX} ${ARGS} ${ADDARG_UNI} \
4338 -a "./.ttt/ma'ger.txt" -a "./.ttt/mä'ger.txt" \
4339 -a './.ttt/diet\ is \curd.txt' -a './.ttt/diet "is" curd.txt' \
4340 -a ./.ttt/höde-tröge.txt \
4341 -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 \
4342 -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 \
4343 -a ./.ttt/hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt \
4344 -a ./.ttt/✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt \
4345 "${MBOX}"
4346 check content:014-1 0 "${MBOX}" '684985954 3092'
4348 # `resend' test, reusing $MBOX
4349 ${rm} -f "${BODY}"
4350 printf "Resend ${BODY}\nx\n" | ${MAILX} ${ARGS} -Rf "${MBOX}"
4351 check content:014-2 0 "${BODY}" '684985954 3092'
4353 ${rm} -f "${BODY}"
4354 printf "resend ${BODY}\nx\n" | ${MAILX} ${ARGS} -Rf "${MBOX}"
4355 check content:014-3 0 "${BODY}" '3130352658 3148'
4357 t_epilog
4360 t_all() {
4361 # if have_feat devel; then
4362 # ARGS="${ARGS} -Smemdebug"
4363 # export ARGS
4364 # fi
4366 if [ -n "${UTF8_LOCALE}" ]; then
4367 printf 'Using Unicode locale %s\n' "${UTF8_LOCALE}"
4368 else
4369 printf 'No Unicode locale found, disabling Unicode tests\n'
4372 t_behave
4373 t_content
4376 if [ -z "${CHECK_ONLY}" ]; then
4377 cc_all_configs
4378 else
4379 t_all
4382 [ ${ESTAT} -eq 0 ] && echo Ok || echo >&2 'Errors occurred'
4384 exit ${ESTAT}
4385 # s-sh-mode