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