c_readall(): FIX handling of empty lines (with test)
[s-mailx.git] / cc-test.sh
blob8e084579d00211d9d387a5f6f6846a2f2f5e3a85
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 echo '### now with empty lines'
2472 ! printf 'one line\n\ntwo line\n\n' > ./.temptynl
2473 readctl create .temptynl;echo $?/$^ERRNAME
2474 readall d; echo "$?/$^ERRNAME / <$d>"
2475 readctl remove .temptynl;echo $?/$^ERRNAME
2476 __EOT
2477 check readall 0 "${MBOX}" '4113506527 405'
2479 t_epilog
2482 t_behave_mbox() {
2483 t_prolog t_behave_mbox
2484 TRAP_EXIT_ADDONS="./.t*"
2488 while [ ${i} -lt 113 ]; do
2489 printf 'm file://%s\n~s Subject %s\nHello %s!\n~.\n' \
2490 "${MBOX}" "${i}" "${i}"
2491 i=`add ${i} 1`
2492 done
2493 ) | ${MAILX} ${ARGS} > .tall 2>&1
2494 check behave:mbox-1 0 "${MBOX}" '1872102723 13784'
2495 check behave:mbox-1-outerr - ./.tall '4294967295 0' # empty file
2497 printf 'File "%s"\ncopy * "%s"\nFile "%s"\nfrom*' "${MBOX}" .tmbox1 .tmbox1 |
2498 ${MAILX} ${ARGS} -Sshowlast > .tall 2>&1
2499 check behave:mbox-2 0 .tall '3498373999 9103'
2501 printf 'File "%s"\ncopy * "file://%s"\nFile "file://%s"\nfrom*' \
2502 "${MBOX}" .tmbox2 .tmbox2 | ${MAILX} ${ARGS} -Sshowlast > .tall 2>&1
2503 check behave:mbox-3 0 .tall '381610797 9110'
2505 # copy only the odd (but the first), move the even
2507 printf 'File "file://%s"\ncopy ' .tmbox2
2509 while [ ${i} -lt 113 ]; do
2510 printf '%s ' "${i}"
2511 i=`add ${i} 2`
2512 done
2513 printf 'file://%s\nFile "file://%s"\nfrom*' .tmbox3 .tmbox3
2514 ) | ${MAILX} ${ARGS} -Sshowlast > .tall 2>&1
2515 check behave:mbox-4 0 .tmbox3 '4145104131 6890'
2516 check behave:mbox-5 - .tall '361127721 4573'
2517 # ...
2519 printf 'file "file://%s"\nmove ' .tmbox2
2521 while [ ${i} -lt 113 ]; do
2522 printf '%s ' "${i}"
2523 i=`add ${i} 2`
2524 done
2525 printf 'file://%s\nFile "file://%s"\nfrom*\nFile "file://%s"\nfrom*' \
2526 .tmbox3 .tmbox3 .tmbox2
2527 ) | ${MAILX} ${ARGS} -Sshowlast > .tall 2>>${ERR}
2528 check behave:mbox-6 0 .tmbox3 '3249991493 13784'
2529 if have_feat uistrings; then
2530 ${sed} 2d < .tall > .tallx
2531 else
2532 ${cp} .tall .tallx
2534 check behave:mbox-7 - .tallx '1584413080 13645'
2536 # Invalid MBOXes (after [f4db93b3])
2537 echo > .tinvmbox
2538 printf 'copy 1 ./.tinvmbox' | ${MAILX} ${ARGS} -Rf "${MBOX}" > .tall 2>&1
2539 check behave:mbox-8 0 .tinvmbox '896415941 122'
2540 check behave:mbox-9 - ./.tall '3146754194 33'
2542 echo ' ' > .tinvmbox
2543 printf 'copy 1 ./.tinvmbox' | ${MAILX} ${ARGS} -Rf "${MBOX}" > .tall 2>&1
2544 check behave:mbox-10 0 .tinvmbox '4011310616 124'
2545 check behave:mbox-11 - ./.tall '3146754194 33'
2547 { echo; echo; } > .tinvmbox # (not invalid)
2548 printf 'copy 1 ./.tinvmbox' | ${MAILX} ${ARGS} -Rf "${MBOX}" > .tall 2>&1
2549 check behave:mbox-12 0 .tinvmbox '287409579 123'
2550 check behave:mbox-13 - ./.tall '3146754194 33'
2552 # *mbox-rfc4155*, plus
2553 ${cat} <<-_EOT > ./.tinv1
2556 From MAILER-DAEMON-1 Wed Oct 2 01:50:07 1996
2557 Date: Wed, 02 Oct 1996 01:50:07 +0000
2559 Subject: Bad bad message 1
2561 From me to you, blinde Kuh!
2563 From MAILER-DAEMON-2 Wed Oct 2 01:50:07 1996
2564 Date: Wed, 02 Oct 1996 01:50:07 +0000
2566 Subject: Bad bad message 2
2568 From me to you, blindes Kalb!
2569 _EOT
2570 ${cp} ./.tinv1 ./.tinv2
2572 printf \
2573 'define mboxfix {
2574 \\localopts yes; \\wysh set mbox-rfc4155;\\wysh File "${1}";\\
2575 \\eval copy * "${2}"
2577 call mboxfix ./.tinv1 ./.tok' | ${MAILX} ${ARGS} > .tall 2>&1
2578 ex0_test behave:mbox-14-estat
2579 ${cat} ./.tinv1 ./.tok >> .tall
2580 check behave:mbox-14 - ./.tall '739301109 616'
2582 printf \
2583 'wysh file ./.tinv1 # ^From not repaired, but missing trailing NL is
2584 wysh File ./.tok # Just move away to nowhere
2585 set mbox-rfc4155
2586 wysh file ./.tinv2 # Fully repaired
2587 File ./.tok' | ${MAILX} ${ARGS} >>${ERR} 2>&1
2588 ex0_test behave:mbox-15-estat
2589 check behave:mbox-15-1 - ./.tinv1 '3178048820 332'
2590 check behave:mbox-15-2 - ./.tinv2 '4151504442 314'
2592 t_epilog
2595 t_behave_maildir() {
2596 t_prolog t_behave_maildir
2597 TRAP_EXIT_ADDONS="./.t*"
2601 while [ ${i} -lt 112 ]; do
2602 printf 'm file://%s\n~s Subject %s\nHello %s!\n~.\n' \
2603 "${MBOX}" "${i}" "${i}"
2604 i=`add ${i} 1`
2605 done
2606 ) | ${MAILX} ${ARGS}
2607 check behave:maildir-1 0 "${MBOX}" '1140119864 13780'
2609 printf 'File "%s"
2610 copy * "%s"
2611 File "%s"
2612 from*
2613 ' "${MBOX}" .tmdir1 .tmdir1 |
2614 ${MAILX} ${ARGS} -Snewfolders=maildir -Sshowlast > .tlst
2615 check behave:maildir-2 0 .tlst '1797938753 9103'
2617 printf 'File "%s"
2618 copy * "maildir://%s"
2619 File "maildir://%s"
2620 from*
2621 ' "${MBOX}" .tmdir2 .tmdir2 |
2622 ${MAILX} ${ARGS} -Sshowlast > .tlst
2623 check behave:maildir-3 0 .tlst '1155631089 9113'
2625 printf 'File "maildir://%s"
2626 copy * "file://%s"
2627 File "file://%s"
2628 from*
2629 ' .tmdir2 .tmbox1 .tmbox1 |
2630 ${MAILX} ${ARGS} -Sshowlast > .tlst
2631 check behave:maildir-4 0 .tmbox1 '2646131190 13220'
2632 check behave:maildir-5 - .tlst '3701297796 9110'
2634 # only the odd (even)
2636 printf 'File "maildir://%s"
2637 copy ' .tmdir2
2639 while [ ${i} -lt 112 ]; do
2640 j=`modulo ${i} 2`
2641 [ ${j} -eq 1 ] && printf '%s ' "${i}"
2642 i=`add ${i} 1`
2643 done
2644 printf ' file://%s
2645 File "file://%s"
2646 from*
2647 ' .tmbox2 .tmbox2
2648 ) | ${MAILX} ${ARGS} -Sshowlast > .tlst
2649 check behave:maildir-6 0 .tmbox2 '142890131 6610'
2650 check behave:maildir-7 - .tlst '960096773 4573'
2651 # ...
2653 printf 'file "maildir://%s"
2654 move ' .tmdir2
2656 while [ ${i} -lt 112 ]; do
2657 j=`modulo ${i} 2`
2658 [ ${j} -eq 0 ] && [ ${i} -ne 0 ] && printf '%s ' "${i}"
2659 i=`add ${i} 1`
2660 done
2661 printf ' file://%s
2662 File "file://%s"
2663 from*
2664 File "maildir://%s"
2665 from*
2666 ' .tmbox2 .tmbox2 .tmdir2
2667 ) | ${MAILX} ${ARGS} -Sshowlast > .tlst
2668 check behave:maildir-8 0 .tmbox2 '3806905791 13100'
2669 ${sed} 2d < .tlst > .tlstx
2670 check behave:maildir-9 - .tlstx '4216815295 13645'
2672 t_epilog
2675 t_behave_record_a_resend() {
2676 t_prolog t_behave_record_a_resend
2677 TRAP_EXIT_ADDONS="./.t.record ./.t.resent"
2679 printf '
2680 set record=%s
2681 m %s\n~s Subject 1.\nHello.\n~.
2682 set record-files add-file-recipients
2683 m %s\n~s Subject 2.\nHello.\n~.
2684 File %s
2685 resend 2 ./.t.resent
2686 Resend 1 ./.t.resent
2687 set record-resent
2688 resend 2 ./.t.resent
2689 Resend 1 ./.t.resent
2690 ' ./.t.record "${MBOX}" "${MBOX}" "${MBOX}" |
2691 ${MAILX} ${ARGS}
2693 check behave:record_a_resend-1 0 "${MBOX}" '3057873538 256'
2694 check behave:record_a_resend-2 - .t.record '391356429 460'
2695 check behave:record_a_resend-3 - .t.resent '2685231691 648'
2697 t_epilog
2700 t_behave_e_H_L_opts() {
2701 t_prolog t_behave_e_H_L_opts
2702 TRAP_EXIT_ADDONS="./.tsendmail.sh ./.t.mbox"
2704 touch ./.t.mbox
2705 ${MAILX} ${ARGS} -ef ./.t.mbox
2706 echo ${?} > "${MBOX}"
2708 ${cat} <<-_EOT > ./.tsendmail.sh
2709 #!${SHELL} -
2710 (echo 'From Alchemilla Wed Apr 07 17:03:33 2017' && ${cat} && echo
2711 ) >> "./.t.mbox"
2712 _EOT
2713 chmod 0755 ./.tsendmail.sh
2714 printf 'm me@exam.ple\nLine 1.\nHello.\n~.\n' |
2715 ${MAILX} ${ARGS} -Smta=./.tsendmail.sh
2716 printf 'm you@exam.ple\nLine 1.\nBye.\n~.\n' |
2717 ${MAILX} ${ARGS} -Smta=./.tsendmail.sh
2719 ${MAILX} ${ARGS} -ef ./.t.mbox
2720 echo ${?} >> "${MBOX}"
2721 ${MAILX} ${ARGS} -efL @t@me ./.t.mbox
2722 echo ${?} >> "${MBOX}"
2723 ${MAILX} ${ARGS} -efL @t@you ./.t.mbox
2724 echo ${?} >> "${MBOX}"
2725 ${MAILX} ${ARGS} -efL '@>@Line 1' ./.t.mbox
2726 echo ${?} >> "${MBOX}"
2727 ${MAILX} ${ARGS} -efL '@>@Hello.' ./.t.mbox
2728 echo ${?} >> "${MBOX}"
2729 ${MAILX} ${ARGS} -efL '@>@Bye.' ./.t.mbox
2730 echo ${?} >> "${MBOX}"
2731 ${MAILX} ${ARGS} -efL '@>@Good bye.' ./.t.mbox
2732 echo ${?} >> "${MBOX}"
2734 ${MAILX} ${ARGS} -fH ./.t.mbox >> "${MBOX}"
2735 echo ${?} >> "${MBOX}"
2736 ${MAILX} ${ARGS} -fL @t@me ./.t.mbox >> "${MBOX}"
2737 echo ${?} >> "${MBOX}"
2738 ${MAILX} ${ARGS} -fL @t@you ./.t.mbox >> "${MBOX}"
2739 echo ${?} >> "${MBOX}"
2740 ${MAILX} ${ARGS} -fL '@>@Line 1' ./.t.mbox >> "${MBOX}"
2741 echo ${?} >> "${MBOX}"
2742 ${MAILX} ${ARGS} -fL '@>@Hello.' ./.t.mbox >> "${MBOX}"
2743 echo ${?} >> "${MBOX}"
2744 ${MAILX} ${ARGS} -fL '@>@Bye.' ./.t.mbox >> "${MBOX}"
2745 echo ${?} >> "${MBOX}"
2746 ${MAILX} ${ARGS} -fL '@>@Good bye.' ./.t.mbox >> "${MBOX}" 2>>${ERR}
2747 echo ${?} >> "${MBOX}"
2749 check behave:e_H_L_opts - "${MBOX}" '1708955574 678'
2751 t_epilog
2754 t_behave_alternates() {
2755 t_prolog t_behave_alternates
2756 TRAP_EXIT_ADDONS="./.t*"
2758 ${cat} <<-_EOT > ./.tsendmail.sh
2759 #!${SHELL} -
2760 (echo 'From Valeriana Sat Jul 08 15:54:03 2017' && ${cat} && echo
2761 ) >> "${MBOX}"
2762 _EOT
2763 chmod 0755 ./.tsendmail.sh
2765 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Smta=./.tsendmail.sh > ./.tall 2>&1
2766 echo --0
2767 alternates
2768 echo $?/$^ERRNAME
2769 alternates a1@b1 a2@b2 a3@b3
2770 echo $?/$^ERRNAME
2771 alternates
2772 echo $?/$^ERRNAME
2773 vput alternates rv
2774 echo $?/$^ERRNAME <$rv>
2776 echo --1
2777 unalternates a2@b2
2778 vput alternates rv
2779 echo $?/$^ERRNAME <$rv>
2780 unalternates a3@b3
2781 vput alternates rv
2782 echo $?/$^ERRNAME <$rv>
2783 unalternates a1@b1
2784 vput alternates rv
2785 echo $?/$^ERRNAME <$rv>
2787 echo --2
2788 unalternates *
2789 alternates a1@b1 a2@b2 a3@b3
2790 unalternates a3@b3
2791 vput alternates rv
2792 echo $?/$^ERRNAME <$rv>
2793 unalternates a2@b2
2794 vput alternates rv
2795 echo $?/$^ERRNAME <$rv>
2796 unalternates a1@b1
2797 vput alternates rv
2798 echo $?/$^ERRNAME <$rv>
2800 echo --3
2801 alternates a1@b1 a2@b2 a3@b3
2802 unalternates a1@b1
2803 vput alternates rv
2804 echo $?/$^ERRNAME <$rv>
2805 unalternates a2@b2
2806 vput alternates rv
2807 echo $?/$^ERRNAME <$rv>
2808 unalternates a3@b3
2809 vput alternates rv
2810 echo $?/$^ERRNAME <$rv>
2812 echo --4
2813 unalternates *
2814 alternates a1@b1 a2@b2 a3@b3
2815 unalternates *
2816 vput alternates rv
2817 echo $?/$^ERRNAME <$rv>
2819 echo --5
2820 unalternates *
2821 alternates a1@b1 a1@c1 a1@d1 a2@b2 a3@b3 a3@c3 a3@d3
2822 m a1@b1 a1@c1 a1@d1
2823 ~s all alternates, only a1@b1 remains
2824 ~c a2@b2
2825 ~b a3@b3 a3@c3 a3@d3
2826 ~r - '_EOT'
2827 This body is!
2828 This also body is!!
2829 _EOT
2832 echo --6
2833 unalternates *
2834 alternates a1@b1 a1@c1 a2@b2 a3@b3
2835 m a1@b1 a1@c1 a1@d1
2836 ~s a1@b1 a1@d1, and a3@c3 a3@d3 remain
2837 ~c a2@b2
2838 ~b a3@b3 a3@c3 a3@d3
2839 ~r - '_EOT'
2840 This body2 is!
2841 _EOT
2844 echo --7
2845 alternates a1@b1 a2@b2 a3; set allnet
2846 m a1@b1 a1@c1 a1@d1
2847 ~s all alternates via allnet, only a1@b1 remains
2848 ~c a2@b2
2849 ~b a3@b3 a3@c3 a3@d3
2850 ~r - '_EOT'
2851 This body3 is!
2852 _EOT
2855 echo --10
2856 unalternates *
2857 alternates a1@b1
2858 echo $?/$^ERRNAME
2859 vput alternates rv
2860 echo $?/$^ERRNAME <$rv>
2861 alternates a2@b2
2862 echo $?/$^ERRNAME
2863 vput alternates rv
2864 echo $?/$^ERRNAME <$rv>
2865 alternates a3@b3
2866 echo $?/$^ERRNAME
2867 vput alternates rv
2868 echo $?/$^ERRNAME <$rv>
2869 alternates a4@b4
2870 echo $?/$^ERRNAME
2871 vput alternates rv
2872 echo $?/$^ERRNAME <$rv>
2874 unalternates *
2875 vput alternates rv
2876 echo $?/$^ERRNAME <$rv>
2878 echo --11
2879 set posix
2880 alternates a1@b1 a2@b2
2881 echo $?/$^ERRNAME
2882 vput alternates rv
2883 echo $?/$^ERRNAME <$rv>
2884 alternates a3@b3 a4@b4
2885 echo $?/$^ERRNAME
2886 vput alternates rv
2887 echo $?/$^ERRNAME <$rv>
2888 __EOT
2890 check behave:alternates-1 0 "${MBOX}" '142184864 515'
2891 if have_feat uistrings; then
2892 check behave:alternates-2 - .tall '1878598364 505'
2893 else
2894 echo 'behave:alternates-2: unsupported, skipped'
2897 t_epilog
2900 t_behave_alias() {
2901 t_prolog t_behave_alias
2902 TRAP_EXIT_ADDONS="./.t*"
2904 ${cat} <<-_EOT > ./.tsendmail.sh
2905 #!${SHELL} -
2906 (echo 'From Hippocastanum Mon Jun 19 15:07:07 2017' && ${cat} && echo
2907 ) >> "${MBOX}"
2908 _EOT
2909 chmod 0755 ./.tsendmail.sh
2911 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Smta=./.tsendmail.sh > ./.tall 2>&1
2912 alias a1 ex1@a1.ple
2913 alias a1 ex2@a1.ple "EX3 <ex3@a1.ple>"
2914 alias a1 ex4@a1.ple
2915 alias a2 ex1@a2.ple ex2@a2.ple ex3@a2.ple ex4@a2.ple
2916 alias a3 a4
2917 alias a4 a5 ex1@a4.ple
2918 alias a5 a6
2919 alias a6 a7 ex1@a6.ple
2920 alias a7 a8
2921 alias a8 ex1@a8.ple
2922 alias a1
2923 alias a2
2924 alias a3
2925 m a1
2926 ~c a2
2927 ~b a3
2928 ~r - '_EOT'
2929 This body is!
2930 This also body is!!
2931 _EOT
2932 __EOT
2933 check behave:alias-1 0 "${MBOX}" '2496925843 272'
2934 check behave:alias-2 - .tall '3548953204 152'
2936 # TODO t_behave_alias: n_ALIAS_MAXEXP is compile-time constant,
2937 # TODO need to somehow provide its contents to the test, then test
2939 t_epilog
2942 t_behave_filetype() {
2943 t_prolog t_behave_filetype
2944 TRAP_EXIT_ADDONS="./.t*"
2946 ${cat} <<-_EOT > ./.tsendmail.sh
2947 #!${SHELL} -
2948 (echo 'From Alchemilla Wed Apr 25 15:12:13 2017' && ${cat} && echo
2949 ) >> "${MBOX}"
2950 _EOT
2951 chmod 0755 ./.tsendmail.sh
2953 printf 'm m1@e.t\nL1\nHy1\n~.\nm m2@e.t\nL2\nHy2\n~@ %s\n~.\n' \
2954 "${SRCDIR}snailmail.jpg" | ${MAILX} ${ARGS} -Smta=./.tsendmail.sh
2955 check behave:filetype-1 0 "${MBOX}" '1594682963 13520'
2957 if (echo | gzip -c) >/dev/null 2>&1; then
2958 ${rm} -f ./.t.mbox*
2960 printf 'File "%s"\ncopy 1 ./.t.mbox.gz\ncopy 2 ./.t.mbox.gz' \
2961 "${MBOX}" | ${MAILX} ${ARGS} \
2962 -X'filetype gz gzip\ -dc gzip\ -c'
2963 printf 'File ./.t.mbox.gz\ncopy * ./.t.mbox\n' |
2964 ${MAILX} ${ARGS} -X'filetype gz gzip\ -dc gzip\ -c'
2965 } > ./.t.out 2>&1
2966 check behave:filetype-2 - "./.t.mbox" '1594682963 13520'
2967 check behave:filetype-3 - "./.t.out" '2392348396 102'
2968 else
2969 echo 'behave:filetype-2: unsupported, skipped'
2970 echo 'behave:filetype-3: unsupported, skipped'
2974 ${rm} -f ./.t.mbox*
2975 printf 'File "%s"\ncopy 1 ./.t.mbox.gz
2976 copy 2 ./.t.mbox.gz
2977 copy 1 ./.t.mbox.gz
2978 copy 2 ./.t.mbox.gz
2979 ' "${MBOX}" |
2980 ${MAILX} ${ARGS} \
2981 -X'filetype gz gzip\ -dc gzip\ -c' \
2982 -X'filetype mbox.gz "${sed} 1,3d|${cat}" \
2983 "echo eins;echo zwei;echo und mit ${sed} bist Du dabei;${cat}"'
2984 printf 'File ./.t.mbox.gz\ncopy * ./.t.mbox\n' |
2985 ${MAILX} ${ARGS} \
2986 -X'filetype gz gzip\ -dc gzip\ -c' \
2987 -X'filetype mbox.gz "${sed} 1,3d|${cat}" kill\ 0'
2988 } > ./.t.out 2>&1
2989 check behave:filetype-4 - "./.t.mbox" '2886541147 27060'
2990 check behave:filetype-5 - "./.t.out" '852335377 172'
2992 t_epilog
2995 t_behave_message_injections() {
2996 t_prolog t_behave_message_injections
2997 TRAP_EXIT_ADDONS="./.t*"
2999 ${cat} <<-_EOT > ./.tsendmail.sh
3000 #!${SHELL} -
3001 (echo 'From Echinacea Tue Jun 20 15:54:02 2017' && ${cat} && echo
3002 ) > "${MBOX}"
3003 _EOT
3004 chmod 0755 ./.tsendmail.sh
3006 echo mysig > ./.tmysig
3008 echo some-body | ${MAILX} ${ARGS} -Smta=./.tsendmail.sh \
3009 -Smessage-inject-head=head-inject \
3010 -Smessage-inject-tail=tail-inject \
3011 -Ssignature=./.tmysig \
3012 ex@am.ple > ./.tall 2>&1
3013 check behave:message_injections-1 0 "${MBOX}" '2434746382 134'
3014 check behave:message_injections-2 - .tall '4294967295 0' # empty file
3016 ${cat} <<-_EOT > ./.template
3017 From: me
3018 To: ex1@am.ple
3019 Cc: ex2@am.ple
3020 Subject: This subject is
3022 Body, body, body me.
3023 _EOT
3024 < ./.template ${MAILX} ${ARGS} -t -Smta=./.tsendmail.sh \
3025 -Smessage-inject-head=head-inject \
3026 -Smessage-inject-tail=tail-inject \
3027 -Ssignature=./.tmysig \
3028 > ./.tall 2>&1
3029 check behave:message_injections-3 0 "${MBOX}" '3114203412 198'
3030 check behave:message_injections-4 - .tall '4294967295 0' # empty file
3032 t_epilog
3035 t_behave_attachments() {
3036 t_prolog t_behave_attachments
3037 TRAP_EXIT_ADDONS="./.t*"
3039 ${cat} <<-_EOT > ./.tsendmail.sh
3040 #!${SHELL} -
3041 (echo 'From Cannabis Sun Feb 18 02:02:46 2018' && ${cat} && echo
3042 ) >> "${MBOX}"
3043 _EOT
3044 chmod 0755 ./.tsendmail.sh
3046 ${cat} <<-_EOT > ./.tx
3047 From steffen Sun Feb 18 02:48:40 2018
3048 Date: Sun, 18 Feb 2018 02:48:40 +0100
3050 Subject: m1
3051 User-Agent: s-nail v14.9.7
3054 From steffen Sun Feb 18 02:48:42 2018
3055 Date: Sun, 18 Feb 2018 02:48:42 +0100
3057 Subject: m2
3058 User-Agent: s-nail v14.9.7
3061 _EOT
3062 echo att1 > ./.t1
3063 printf 'att2-1\natt2-2\natt2-4\n' > ./'.t 2'
3064 printf 'att3-1\natt3-2\natt3-4\n' > ./.t3
3065 printf 'att4-1\natt4-2\natt4-4\n' > './.t 4'
3067 printf \
3068 '!@ ./.t3 "./.t 4" ""
3071 ./.t3
3072 "./.t 2"
3075 !.' \
3076 | ${MAILX} ${ARGS} -Sescape=! -Smta=./.tsendmail.sh \
3077 -a ./.t1 -a './.t 2' \
3078 -s attachment-test \
3079 ex@am.ple > ./.tall 2>&1
3080 check behave:attachments-1 0 "${MBOX}" '4107062253 634'
3081 if have_feat uistrings; then
3082 check behave:attachments-2 - .tall '1928331872 720'
3083 else
3084 echo 'behave:attachments-2: unsupported, skipped'
3087 ${rm} -f "${MBOX}"
3088 printf \
3089 'mail ex@amp.ple
3090 !s This the subject is
3091 !@ ./.t3 "#2" "./.t 4" "#1" ""
3094 "./.t 4"
3095 "#2"
3099 mail ex@amp.ple
3100 !s Subject two
3101 !@ ./.t3 "#2" "./.t 4" "#1" ""
3107 mail ex@amp.ple
3108 !s Subject three
3109 !@ ./.t3 "" "#2" "" "./.t 4" "" "#1" ""
3112 ./.t3
3116 mail ex@amp.ple
3117 !s Subject Four
3118 !@ ./.t3 "" "#2" "" "./.t 4" "" "#1" ""
3121 "#1"
3125 mail ex@amp.ple
3126 !s Subject Five
3128 "#2"
3131 !.' \
3132 | ${MAILX} ${ARGS} -Sescape=! -Smta=./.tsendmail.sh -Rf ./.tx \
3133 > ./.tall 2>&1
3134 check behave:attachments-3 0 "${MBOX}" '798122412 2285'
3135 if have_feat uistrings; then
3136 check behave:attachments-4 - .tall '2526106274 1910'
3137 else
3138 echo 'behave:attachments-4: unsupported, skipped'
3141 t_epilog
3144 t_behave_compose_hooks() { # TODO monster
3145 t_prolog t_behave_compose_hooks
3146 if have_feat uistrings; then :; else
3147 echo 'behave:compose_hooks: unsupported, skipped'
3148 return
3150 TRAP_EXIT_ADDONS="./.t*"
3152 (echo line one&&echo line two&&echo line three) > ./.treadctl
3153 (echo echo four&&echo echo five&&echo echo six) > ./.tattach
3155 ${cat} <<-_EOT > ./.tsendmail.sh
3156 #!${SHELL} -
3157 (echo 'From PrimulaVeris Wed Apr 10 22:59:00 2017' && ${cat} && echo
3158 ) >> "${MBOX}"
3159 _EOT
3160 chmod 0755 ./.tsendmail.sh
3162 ${cat} <<'__EOT__' > ./.trc
3163 define bail {
3164 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
3166 define xerr {
3167 vput vexpr es substr "$1" 0 1
3168 if [ "$es" != 2 ]
3169 xcall bail "$2"
3172 define read_mline_res {
3173 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
3174 echo $len/$es/$^ERRNAME: $hl
3175 if [ $es -ne $^ERR-NONE ]
3176 xcall bail read_mline_res
3177 elif [ $len -ne 0 ]
3178 \xcall read_mline_res
3181 define ins_addr {
3182 wysh set xh=$1
3183 echo "~^header list"; read hl; echo $hl;\
3184 call xerr "$hl" "in_addr ($xh) 0-1"
3186 echo "~^header insert $xh diet <$xh@exam.ple> spliced";\
3187 read es; echo $es; call xerr "$es" "ins_addr $xh 1-1"
3188 echo "~^header insert $xh <${xh}2@exam.ple>";\
3189 read es; echo $es; call xerr "$es" "ins_addr $xh 1-2"
3190 echo "~^header insert $xh ${xh}3@exam.ple";\
3191 read es; echo $es; call xerr "$es" "ins_addr $xh 1-3"
3192 echo "~^header list $xh"; read hl; echo $hl;\
3193 call xerr "$hl" "ins_addr $xh 1-4"
3194 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 1-5"
3195 call read_mline_res
3197 if [ "$t_remove" == "" ]
3198 return
3201 echo "~^header remove $xh"; read es; call xerr $es "ins_addr $xh 2-1"
3202 echo "~^header remove $xh"; read es; vput vexpr es substr $es 0 3
3203 if [ $es != 501 ]
3204 xcall bail "ins_addr $xh 2-2"
3206 echo "~^header list $xh"; read es; vput vexpr es substr $es 0 3
3207 if [ $es != 501 ]
3208 xcall bail "ins_addr $xh 2-3"
3210 echo "~^header show $xh"; read es; vput vexpr es substr $es 0 3
3211 if [ $es != 501 ]
3212 xcall bail "ins_addr $xh 2-4"
3216 echo "~^header insert $xh diet <$xh@exam.ple> spliced";\
3217 read es; echo $es; call xerr "$es" "ins_addr $xh 3-1"
3218 echo "~^header insert $xh <${xh}2@exam.ple>";\
3219 read es; echo $es; call xerr "$es" "ins_addr $xh 3-2"
3220 echo "~^header insert $xh ${xh}3@exam.ple";\
3221 read es; echo $es; call xerr "$es" "ins_addr $xh 3-3"
3222 echo "~^header list $xh"; read hl; echo $hl;\
3223 call xerr "$hl" "ins_addr $xh 3-4"
3224 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 3-5"
3225 call read_mline_res
3227 echo "~^header remove-at $xh 1"; read es;\
3228 call xerr $es "ins_addr $xh 3-6"
3229 echo "~^header remove-at $xh 1"; read es;\
3230 call xerr $es "ins_addr $xh 3-7"
3231 echo "~^header remove-at $xh 1"; read es;\
3232 call xerr $es "ins_addr $xh 3-8"
3233 echo "~^header remove-at $xh 1"; read es;\
3234 vput vexpr es substr $es 0 3
3235 if [ $es != 501 ]
3236 xcall bail "ins_addr $xh 3-9"
3238 echo "~^header remove-at $xh T"; read es;\
3239 vput vexpr es substr $es 0 3
3240 if [ $es != 505 ]
3241 xcall bail "ins_addr $xh 3-10"
3243 echo "~^header list $xh"; read es;\
3244 vput vexpr es substr $es 0 3
3245 if [ $es != 501 ]
3246 xcall bail "ins_addr $xh 3-11"
3248 echo "~^header show $xh"; read es;\
3249 vput vexpr es substr $es 0 3
3250 if [ $es != 501 ]
3251 xcall bail "ins_addr $xh 3-12"
3255 echo "~^header insert $xh diet <$xh@exam.ple> spliced";\
3256 read es; echo $es; call xerr "$es" "ins_addr $xh 4-1"
3257 echo "~^header insert $xh <${xh}2@exam.ple> (comment) \"Quot(e)d\"";\
3258 read es; echo $es; call xerr "$es" "ins_addr $xh 4-2"
3259 echo "~^header insert $xh ${xh}3@exam.ple";\
3260 read es; echo $es; call xerr "$es" "ins_addr $xh 4-3"
3261 echo "~^header list $xh"; read hl; echo $hl;\
3262 call xerr "$hl" "header list $xh 3-4"
3263 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 4-5"
3264 call read_mline_res
3266 echo "~^header remove-at $xh 3"; read es;\
3267 call xerr $es "ins_addr $xh 4-6"
3268 echo "~^header remove-at $xh 2"; read es;\
3269 call xerr $es "ins_addr $xh 4-7"
3270 echo "~^header remove-at $xh 1"; read es;\
3271 call xerr $es "ins_addr $xh 4-8"
3272 echo "~^header remove-at $xh 1"; read es;\
3273 vput vexpr es substr $es 0 3
3274 if [ $es != 501 ]
3275 xcall bail "ins_addr $xh 4-9"
3277 echo "~^header remove-at $xh T"; read es;\
3278 vput vexpr es substr $es 0 3
3279 if [ $es != 505 ]
3280 xcall bail "ins_addr $xh 4-10"
3282 echo "~^header list $xh"; read es;\
3283 vput vexpr es substr $es 0 3
3284 if [ $es != 501 ]
3285 xcall bail "ins_addr $xh 4-11"
3287 echo "~^header show $xh"; read es;\
3288 vput vexpr es substr $es 0 3
3289 if [ $es != 501 ]
3290 xcall bail "ins_addr $xh 4-12"
3293 define ins_ref {
3294 wysh set xh=$1 mult=$2
3295 echo "~^header list"; read hl; echo $hl;\
3296 call xerr "$hl" "ins_ref ($xh) 0-1"
3298 echo "~^header insert $xh <$xh@exam.ple>";\
3299 read es; echo $es; call xerr "$es" "ins_ref $xh 1-1"
3300 if [ $mult -ne 0 ]
3301 echo "~^header insert $xh <${xh}2@exam.ple>";\
3302 read es; echo $es; call xerr "$es" "ins_ref $xh 1-2"
3303 echo "~^header insert $xh ${xh}3@exam.ple";\
3304 read es; echo $es; call xerr "$es" "ins_ref $xh 1-3"
3305 else
3306 echo "~^header insert $xh <${xh}2@exam.ple>"; read es;\
3307 vput vexpr es substr $es 0 3
3308 if [ $es != 506 ]
3309 xcall bail "ins_ref $xh 1-4"
3313 echo "~^header list $xh"; read hl; echo $hl;\
3314 call xerr "$hl" "ins_ref $xh 1-5"
3315 echo "~^header show $xh"; read es; call xerr $es "ins_ref $xh 1-6"
3316 call read_mline_res
3318 if [ "$t_remove" == "" ]
3319 return
3322 echo "~^header remove $xh"; read es;\
3323 call xerr $es "ins_ref $xh 2-1"
3324 echo "~^header remove $xh"; read es;\
3325 vput vexpr es substr $es 0 3
3326 if [ $es != 501 ]
3327 xcall bail "ins_ref $xh 2-2"
3329 echo "~^header list $xh"; read es;\
3330 vput vexpr es substr $es 0 3
3331 if [ $es != 501 ]
3332 xcall bail "$es ins_ref $xh 2-3"
3334 echo "~^header show $xh"; read es;\
3335 vput vexpr es substr $es 0 3
3336 if [ $es != 501 ]
3337 xcall bail "ins_ref $xh 2-4"
3341 echo "~^header insert $xh <$xh@exam.ple>";\
3342 read es; echo $es; call xerr "$es" "ins_ref $xh 3-1"
3343 if [ $mult -ne 0 ]
3344 echo "~^header insert $xh <${xh}2@exam.ple>";\
3345 read es; echo $es; call xerr "$es" "ins_ref $xh 3-2"
3346 echo "~^header insert $xh ${xh}3@exam.ple";\
3347 read es; echo $es; call xerr "$es" "ins_ref $xh 3-3"
3349 echo "~^header list $xh";\
3350 read hl; echo $hl; call xerr "$hl" "ins_ref $xh 3-4"
3351 echo "~^header show $xh";\
3352 read es; call xerr $es "ins_ref $xh 3-5"
3353 call read_mline_res
3355 echo "~^header remove-at $xh 1"; read es;\
3356 call xerr $es "ins_ref $xh 3-6"
3357 if [ $mult -ne 0 ] && [ $xh != subject ]
3358 echo "~^header remove-at $xh 1"; read es;\
3359 call xerr $es "ins_ref $xh 3-7"
3360 echo "~^header remove-at $xh 1"; read es;\
3361 call xerr $es "ins_ref $xh 3-8"
3363 echo "~^header remove-at $xh 1"; read es;\
3364 vput vexpr es substr $es 0 3
3365 if [ $es != 501 ]
3366 xcall bail "ins_ref $xh 3-9"
3368 echo "~^header remove-at $xh T"; read es;\
3369 vput vexpr es substr $es 0 3
3370 if [ $es != 505 ]
3371 xcall bail "ins_ref $xh 3-10"
3373 echo "~^header show $xh"; read es;\
3374 vput vexpr es substr $es 0 3
3375 if [ $es != 501 ]
3376 xcall bail "ins_ref $xh 3-11"
3380 echo "~^header insert $xh <$xh@exam.ple> ";\
3381 read es; echo $es; call xerr "$es" "ins_ref $xh 4-1"
3382 if [ $mult -ne 0 ]
3383 echo "~^header insert $xh <${xh}2@exam.ple> ";\
3384 read es; echo $es; call xerr "$es" "ins_ref $xh 4-2"
3385 echo "~^header insert $xh ${xh}3@exam.ple";\
3386 read es; echo $es; call xerr "$es" "ins_ref $xh 4-3"
3388 echo "~^header list $xh"; read hl; echo $hl;\
3389 call xerr "$hl" "ins_ref $xh 4-4"
3390 echo "~^header show $xh"; read es; call xerr $es "ins_ref $xh 4-5"
3391 call read_mline_res
3393 if [ $mult -ne 0 ] && [ $xh != subject ]
3394 echo "~^header remove-at $xh 3"; read es;\
3395 call xerr $es "ins_ref $xh 4-6"
3396 echo "~^header remove-at $xh 2"; read es;\
3397 call xerr $es "ins_ref $xh 4-7"
3399 echo "~^header remove-at $xh 1"; read es;\
3400 call xerr $es "ins_ref $xh 4-8"
3401 echo "~^header remove-at $xh 1"; read es;\
3402 vput vexpr es substr $es 0 3
3403 if [ $es != 501 ]
3404 xcall bail "ins_ref $xh 4-9"
3406 echo "~^header remove-at $xh T"; read es;\
3407 vput vexpr es substr $es 0 3
3408 if [ $es != 505 ]
3409 xcall bail "ins_ref $xh 4-10"
3411 echo "~^header show $xh"; read es;\
3412 vput vexpr es substr $es 0 3
3413 if [ $es != 501 ]
3414 xcall bail "ins_ref $xh 4-11"
3417 define t_header {
3418 echo t_header ENTER
3419 # In collect.c order
3420 call ins_addr from
3421 call ins_ref sender 0 # Not a "ref", but works
3422 call ins_addr To
3423 call ins_addr cC
3424 call ins_addr bCc
3425 call ins_addr reply-To
3426 call ins_addr mail-Followup-to
3427 call ins_ref messAge-id 0
3428 call ins_ref rEfErEncEs 1
3429 call ins_ref in-Reply-to 1
3430 call ins_ref subject 1 # Not a "ref", but works (with tweaks)
3431 call ins_addr freeForm1
3432 call ins_addr freeform2
3434 echo "~^header show MAILX-Command"; read es; call xerr $es "t_header 1000"
3435 call read_mline_res
3436 echo "~^header show MAILX-raw-TO"; read es; call xerr $es "t_header 1001"
3437 call read_mline_res
3439 echo t_header LEAVE
3441 define t_attach {
3442 echo t_attach ENTER
3444 echo "~^attachment";\
3445 read hl; echo $hl; vput vexpr es substr "$hl" 0 3
3446 if [ "$es" != 501 ]
3447 xcall bail "attach 0-1"
3450 echo "~^attach attribute ./.treadctl";\
3451 read hl; echo $hl; vput vexpr es substr "$hl" 0 3
3452 if [ "$es" != 501 ]
3453 xcall bail "attach 0-2"
3455 echo "~^attachment attribute-at 1";\
3456 read hl; echo $hl; vput vexpr es substr "$hl" 0 3
3457 if [ "$es" != 501 ]
3458 xcall bail "attach 0-3"
3461 echo "~^attachment insert ./.treadctl=ascii";\
3462 read hl; echo $hl; call xerr "$hl" "attach 1-1"
3463 echo "~^attachment list";\
3464 read es; echo $es;call xerr "$es" "attach 1-2"
3465 call read_mline_res
3466 echo "~^attachment attribute ./.treadctl";\
3467 read es; echo $es;call xerr "$es" "attach 1-3"
3468 call read_mline_res
3469 echo "~^attachment attribute .treadctl";\
3470 read es; echo $es;call xerr "$es" "attach 1-4"
3471 call read_mline_res
3472 echo "~^attachment attribute-at 1";\
3473 read es; echo $es;call xerr "$es" "attach 1-5"
3474 call read_mline_res
3476 echo "~^attachment attribute-set ./.treadctl filename rctl";\
3477 read es; echo $es;call xerr "$es" "attach 1-6"
3478 echo "~^attachment attribute-set .treadctl content-description Au";\
3479 read es; echo $es;call xerr "$es" "attach 1-7"
3480 echo "~^attachment attribute-set-at 1 content-id <10.du@ich>";\
3481 read es; echo $es;call xerr "$es" "attach 1-8"
3483 echo "~^attachment attribute ./.treadctl";\
3484 read es; echo $es;call xerr "$es" "attach 1-9"
3485 call read_mline_res
3486 echo "~^attachment attribute .treadctl";\
3487 read es; echo $es;call xerr "$es" "attach 1-10"
3488 call read_mline_res
3489 echo "~^attachment attribute rctl";\
3490 read es; echo $es;call xerr "$es" "attach 1-11"
3491 call read_mline_res
3492 echo "~^attachment attribute-at 1";\
3493 read es; echo $es;call xerr "$es" "attach 1-12"
3494 call read_mline_res
3497 echo "~^attachment insert ./.tattach=latin1";\
3498 read hl; echo $hl; call xerr "$hl" "attach 2-1"
3499 echo "~^attachment list";\
3500 read es; echo $es;call xerr "$es" "attach 2-2"
3501 call read_mline_res
3502 echo "~^attachment attribute ./.tattach";\
3503 read es; echo $es;call xerr "$es" "attach 2-3"
3504 call read_mline_res
3505 echo "~^attachment attribute .tattach";\
3506 read es; echo $es;call xerr "$es" "attach 2-4"
3507 call read_mline_res
3508 echo "~^attachment attribute-at 2";\
3509 read es; echo $es;call xerr "$es" "attach 2-5"
3510 call read_mline_res
3512 echo "~^attachment attribute-set ./.tattach filename tat";\
3513 read es; echo $es;call xerr "$es" "attach 2-6"
3514 echo \
3515 "~^attachment attribute-set .tattach content-description Au2";\
3516 read es; echo $es;call xerr "$es" "attach 2-7"
3517 echo "~^attachment attribute-set-at 2 content-id <20.du@wir>";\
3518 read es; echo $es;call xerr "$es" "attach 2-8"
3519 echo \
3520 "~^attachment attribute-set-at 2 content-type application/x-sh";\
3521 read es; echo $es;call xerr "$es" "attach 2-9"
3523 echo "~^attachment attribute ./.tattach";\
3524 read es; echo $es;call xerr "$es" "attach 2-10"
3525 call read_mline_res
3526 echo "~^attachment attribute .tattach";\
3527 read es; echo $es;call xerr "$es" "attach 2-11"
3528 call read_mline_res
3529 echo "~^attachment attribute tat";\
3530 read es; echo $es;call xerr "$es" "attach 2-12"
3531 call read_mline_res
3532 echo "~^attachment attribute-at 2";\
3533 read es; echo $es;call xerr "$es" "attach 2-13"
3534 call read_mline_res
3537 if [ "$t_remove" == "" ]
3538 return
3541 echo "~^attachment remove ./.treadctl"; read es;\
3542 call xerr $es "attach 3-1"
3543 echo "~^attachment remove ./.tattach"; read es;\
3544 call xerr $es "attach 3-2"
3545 echo "~^ attachment remove ./.treadctl"; read es;\
3546 vput vexpr es substr $es 0 3
3547 if [ $es != 501 ]
3548 xcall bail "attach 3-3"
3550 echo "~^ attachment remove ./.tattach"; read es;\
3551 vput vexpr es substr $es 0 3
3552 if [ $es != 501 ]
3553 xcall bail "attach 3-4"
3555 echo "~^attachment list"; read es;\
3556 vput vexpr es substr $es 0 3
3557 if [ $es != 501 ]
3558 xcall bail "attach 3-5"
3562 echo "~^attachment insert ./.tattach=latin1";\
3563 read hl; echo $hl; call xerr "$hl" "attach 4-1"
3564 echo "~^attachment insert ./.tattach=latin1";\
3565 read hl; echo $hl; call xerr "$hl" "attach 4-2"
3566 echo "~^attachment list";\
3567 read es; echo $es;call xerr "$es" "attach 4-3"
3568 call read_mline_res
3569 echo "~^ attachment remove .tattach"; read es;\
3570 vput vexpr es substr $es 0 3
3571 if [ $es != 506 ]
3572 xcall bail "attach 4-4 $es"
3574 echo "~^attachment remove-at T"; read es;\
3575 vput vexpr es substr $es 0 3
3576 if [ $es != 505 ]
3577 xcall bail "attach 4-5"
3579 echo "~^attachment remove ./.tattach"; read es;\
3580 call xerr $es "attach 4-6"
3581 echo "~^attachment remove ./.tattach"; read es;\
3582 call xerr $es "attach 4-7"
3583 echo "~^ attachment remove ./.tattach"; read es;\
3584 vput vexpr es substr $es 0 3
3585 if [ $es != 501 ]
3586 xcall bail "attach 4-8 $es"
3588 echo "~^attachment list"; read es;\
3589 vput vexpr es substr $es 0 3
3590 if [ $es != 501 ]
3591 xcall bail "attach 4-9"
3595 echo "~^attachment insert ./.tattach=latin1";\
3596 read hl; echo $hl; call xerr "$hl" "attach 5-1"
3597 echo "~^attachment insert ./.tattach=latin1";\
3598 read hl; echo $hl; call xerr "$hl" "attach 5-2"
3599 echo "~^attachment insert ./.tattach=latin1";\
3600 read hl; echo $hl; call xerr "$hl" "attach 5-3"
3601 echo "~^attachment list";\
3602 read es; echo $es;call xerr "$es" "attach 5-4"
3603 call read_mline_res
3605 echo "~^attachment remove-at 3"; read es;\
3606 call xerr $es "attach 5-5"
3607 echo "~^attachment remove-at 3"; read es;\
3608 vput vexpr es substr $es 0 3
3609 if [ $es != 501 ]
3610 xcall bail "attach 5-6"
3612 echo "~^attachment remove-at 2"; read es;\
3613 call xerr $es "attach 5-7"
3614 echo "~^attachment remove-at 2"; read es;\
3615 vput vexpr es substr $es 0 3
3616 if [ $es != 501 ]
3617 xcall bail "attach 5-8"
3619 echo "~^attachment remove-at 1"; read es;\
3620 call xerr $es "attach 5-9"
3621 echo "~^attachment remove-at 1"; read es;\
3622 vput vexpr es substr $es 0 3
3623 if [ $es != 501 ]
3624 xcall bail "attach 5-10"
3627 echo "~^attachment list"; read es;\
3628 vput vexpr es substr $es 0 3
3629 if [ $es != 501 ]
3630 xcall bail "attach 5-11"
3634 echo "~^attachment insert ./.tattach=latin1";\
3635 read hl; echo $hl; call xerr "$hl" "attach 6-1"
3636 echo "~^attachment insert ./.tattach=latin1";\
3637 read hl; echo $hl; call xerr "$hl" "attach 6-2"
3638 echo "~^attachment insert ./.tattach=latin1";\
3639 read hl; echo $hl; call xerr "$hl" "attach 6-3"
3640 echo "~^attachment list";\
3641 read es; echo $es;call xerr "$es" "attach 6-4"
3642 call read_mline_res
3644 echo "~^attachment remove-at 1"; read es;\
3645 call xerr $es "attach 6-5"
3646 echo "~^attachment remove-at 1"; read es;\
3647 call xerr $es "attach 6-6"
3648 echo "~^attachment remove-at 1"; read es;\
3649 call xerr $es "attach 6-7"
3650 echo "~^attachment remove-at 1"; read es;\
3651 vput vexpr es substr $es 0 3
3652 if [ $es != 501 ]
3653 xcall bail "attach 6-8"
3656 echo "~^attachment list"; read es;\
3657 vput vexpr es substr $es 0 3
3658 if [ $es != 501 ]
3659 xcall bail "attach 6-9"
3662 echo t_attach LEAVE
3664 define t_ocs {
3665 read ver
3666 echo t_ocs
3667 call t_header
3668 call t_attach
3670 define t_oce {
3671 echo on-compose-enter, mailx-command<$mailx-command>
3672 alternates alter1@exam.ple alter2@exam.ple
3673 alternates
3674 set autocc='alter1@exam.ple alter2@exam.ple'
3675 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3676 echo mailx-subject<$mailx-subject>
3677 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3678 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3679 mailx-raw-bcc<$mailx-raw-bcc>
3680 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
3681 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3683 define t_ocl {
3684 echo on-compose-leave, mailx-command<$mailx-command>
3685 vput alternates al
3686 eval alternates $al alter3@exam.ple alter4@exam.ple
3687 alternates
3688 set autobcc='alter3@exam.ple alter4@exam.ple'
3689 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3690 echo mailx-subject<$mailx-subject>
3691 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3692 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3693 mailx-raw-bcc<$mailx-raw-bcc>
3694 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
3695 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3697 define t_occ {
3698 echo on-compose-cleanup, mailx-command<$mailx-command>
3699 unalternates *
3700 alternates
3701 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3702 echo mailx-subject<$mailx-subject>
3703 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3704 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3705 mailx-raw-bcc<$mailx-raw-bcc>
3706 echo mailx-orig-from<$mailx-orig-from> mailx-orig-to<$mailx-orig-to> \
3707 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3709 wysh set on-compose-splice=t_ocs \
3710 on-compose-enter=t_oce on-compose-leave=t_ocl \
3711 on-compose-cleanup=t_occ
3712 __EOT__
3714 ${rm} -f "${MBOX}"
3715 printf 'm this-goes@nowhere\nbody\n!.\n' |
3716 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
3717 -X'source ./.trc' -Smta=./.tsendmail.sh \
3718 >./.tall 2>&1
3719 ${cat} ./.tall >> "${MBOX}"
3720 check behave:compose_hooks-1 0 "${MBOX}" '522535560 10101'
3722 ${rm} -f "${MBOX}"
3723 printf 'm this-goes@nowhere\nbody\n!.\n' |
3724 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
3725 -St_remove=1 -X'source ./.trc' -Smta=./.tsendmail.sh \
3726 >./.tall 2>&1
3727 ${cat} ./.tall >> "${MBOX}"
3728 check behave:compose_hooks-2 0 "${MBOX}" '3654000499 12535'
3732 # Some state machine stress, shell compose hook, localopts for hook, etc.
3733 # readctl in child. ~r as HERE document
3734 ${rm} -f "${MBOX}"
3735 printf 'm ex@am.ple\nbody\n!.
3736 echon ${mailx-command}${mailx-subject}
3737 echon ${mailx-from}${mailx-sender}
3738 echon ${mailx-to}${mailx-cc}${mailx-bcc}
3739 echon ${mailx-raw-to}${mailx-raw-cc}${mailx-raw-bcc}
3740 echon ${mailx-orig-from}${mailx-orig-to}${mailx-orig-gcc}${mailx-orig-bcc}
3741 var t_oce t_ocs t_ocs_sh t_ocl t_occ autocc
3742 ' | ${MAILX} ${ARGS} -Snomemdebug -Sescape=! \
3743 -Smta=./.tsendmail.sh \
3745 define bail {
3746 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
3748 define xerr {
3749 vput vexpr es substr "$1" 0 1
3750 if [ "$es" != 2 ]
3751 xcall bail "$2"
3754 define read_mline_res {
3755 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
3756 echo $len/$es/$^ERRNAME: $hl
3757 if [ $es -ne $^ERR-NONE ]
3758 xcall bail read_mline_res
3759 elif [ $len -ne 0 ]
3760 \xcall read_mline_res
3763 define _work {
3764 vput vexpr i + 1 "$2"
3765 if [ $i -lt 111 ]
3766 vput vexpr j % $i 10
3767 if [ $j -ne 0 ]
3768 set j=xcall
3769 else
3770 echon "$i.. "
3771 set j=call
3773 eval \\$j _work $1 $i
3774 return $?
3776 vput vexpr i + $i "$1"
3777 return $i
3779 define _read {
3780 wysh set line; read line;wysh set es=$? en=$^ERRNAME ;\
3781 echo read:$es/$en: $line
3782 if [ "${es}" -ne -1 ]
3783 xcall _read
3785 readctl remove $cwd/.treadctl; echo readctl remove:$?/$^ERRNAME
3787 define t_ocs {
3788 read ver
3789 echo t_ocs
3790 echo "~^header list"; read hl; echo $hl;\
3791 vput vexpr es substr "$hl" 0 1
3792 if [ "$es" != 2 ]
3793 xcall bail "header list"
3794 endif
3796 call _work 1; echo $?
3797 echo "~^header insert cc splicy diet <splice@exam.ple> spliced";\
3798 read es; echo $es; vput vexpr es substr "$es" 0 1
3799 if [ "$es" != 2 ]
3800 xcall bail "be diet"
3801 endif
3802 echo "~^header insert cc <splice2@exam.ple>";\
3803 read es; echo $es; vput vexpr es substr "$es" 0 1
3804 if [ "$es" != 2 ]
3805 xcall bail "be diet2"
3806 endif
3808 call _work 2; echo $?
3809 echo "~^header insert bcc juicy juice <juice@exam.ple> spliced";\
3810 read es; echo $es;vput vexpr es substr "$es" 0 1
3811 if [ "$es" != 2 ]
3812 xcall bail "be juicy"
3813 endif
3814 echo "~^header insert bcc juice2@exam.ple";\
3815 read es; echo $es;vput vexpr es substr "$es" 0 1
3816 if [ "$es" != 2 ]
3817 xcall bail "be juicy2"
3818 endif
3819 echo "~^header insert bcc juice3 <juice3@exam.ple>";\
3820 read es; echo $es;vput vexpr es substr "$es" 0 1
3821 if [ "$es" != 2 ]
3822 xcall bail "be juicy3"
3823 endif
3824 echo "~^header insert bcc juice4@exam.ple";\
3825 read es; echo $es;vput vexpr es substr "$es" 0 1
3826 if [ "$es" != 2 ]
3827 xcall bail "be juicy4"
3828 endif
3830 echo "~^header remove-at bcc 3";\
3831 read es; echo $es;vput vexpr es substr "$es" 0 1
3832 if [ "$es" != 2 ]
3833 xcall bail "remove juicy5"
3834 endif
3835 echo "~^header remove-at bcc 2";\
3836 read es; echo $es;vput vexpr es substr "$es" 0 1
3837 if [ "$es" != 2 ]
3838 xcall bail "remove juicy6"
3839 endif
3840 echo "~^header remove-at bcc 3";\
3841 read es; echo $es;vput vexpr es substr "$es" 0 3
3842 if [ "$es" != 501 ]
3843 xcall bail "failed to remove-at"
3844 endif
3845 # Add duplicates which ought to be removed!
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-1"
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-2"
3855 endif
3856 echo "~^header insert bcc juice4@exam.ple";\
3857 read es; echo $es;vput vexpr es substr "$es" 0 1
3858 if [ "$es" != 2 ]
3859 xcall bail "be juicy4-3"
3860 endif
3861 echo "~:set t_ocs"
3864 call _work 3; echo $?
3865 echo "~r - '__EOT'"
3866 vput ! i echo just knock if you can hear me;\
3867 i=0;\
3868 while [ $i -lt 24 ]; do printf "%s " $i; i=`expr $i + 1`; done;\
3869 echo relax
3870 echon shell-cmd says $?/$^ERRNAME: $i
3871 echo "~x will not become interpreted, we are reading until __EOT"
3872 echo "__EOT"
3873 read r_status; echo "~~r status output: $r_status"
3874 echo "~:echo $? $! $^ERRNAME"
3875 read r_status
3876 echo "~~r status from parent: $r_status"
3879 call _work 4; echo $?
3880 vput cwd cwd;echo cwd:$?
3881 readctl create $cwd/.treadctl ;echo readctl:$?/$^ERRNAME;\
3882 call _read
3885 call _work 5; echo $?
3886 echo "~^header show MAILX-Command"; read es;\
3887 call xerr $es "t_header 1000"; call read_mline_res
3888 echo "~^header show MAILX-raw-TO"; read es;\
3889 call xerr $es "t_header 1001"; xcall read_mline_res
3891 echoerr IT IS WRONG IF YOU SEE THIS
3893 define t_oce {
3894 echo on-compose-enter, mailx-command<$mailx-command>
3895 set t_oce autobcc=oce@exam.ple
3896 alternates alter1@exam.ple alter2@exam.ple
3897 alternates
3898 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3899 echo mailx-subject<$mailx-subject>
3900 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3901 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3902 mailx-raw-bcc<$mailx-raw-bcc>
3903 echo mailx-orig-from<$mailx-orig-from> \
3904 mailx-orig-to<$mailx-orig-to> \
3905 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3907 define t_ocl {
3908 echo on-compose-leave, mailx-command<$mailx-command>
3909 set t_ocl autocc=ocl@exam.ple
3910 unalternates *
3911 alternates alter3@exam.ple alter4@exam.ple
3912 alternates
3913 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3914 echo mailx-subject<$mailx-subject>
3915 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3916 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3917 mailx-raw-bcc<$mailx-raw-bcc>
3918 echo mailx-orig-from<$mailx-orig-from> \
3919 mailx-orig-to<$mailx-orig-to> \
3920 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3922 define t_occ {
3923 echo on-compose-cleanup, mailx-command<$mailx-command>
3924 set t_occ autocc=occ@exam.ple
3925 unalternates *
3926 alternates
3927 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
3928 echo mailx-subject<$mailx-subject>
3929 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
3930 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
3931 mailx-raw-bcc<$mailx-raw-bcc>
3932 echo mailx-orig-from<$mailx-orig-from> \
3933 mailx-orig-to<$mailx-orig-to> \
3934 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
3936 wysh set on-compose-splice=t_ocs \
3937 on-compose-splice-shell="read ver;echo t_ocs-shell;\
3938 echo \"~t shell@exam.ple\"; echo \"~:set t_ocs_sh\"" \
3939 on-compose-enter=t_oce on-compose-leave=t_ocl \
3940 on-compose-cleanup=t_occ
3941 ' > ./.tnotes 2>&1
3942 ex0_test behave:compose_hooks-3-estat
3943 ${cat} ./.tnotes >> "${MBOX}"
3945 check behave:compose_hooks-3 - "${MBOX}" '679526364 2431'
3947 # Reply, forward, resend, Resend
3949 ${rm} -f "${MBOX}"
3950 printf 'set from=f1@z\nm t1@z\nb1\n!.\nset from=f2@z\nm t2@z\nb2\n!.\n' |
3951 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! \
3952 -Smta=./.tsendmail.sh
3954 printf '
3955 echo start: $? $! $^ERRNAME
3956 File %s
3957 echo File: $? $! $^ERRNAME;echo;echo
3958 reply 1
3959 this is content of reply 1
3961 echo reply 1: $? $! $^ERRNAME;echo;echo
3962 Reply 1 2
3963 this is content of Reply 1 2
3965 echo Reply 1 2: $? $! $^ERRNAME;echo;echo
3966 forward 1 fwdex@am.ple
3967 this is content of forward 1
3969 echo forward 1: $? $! $^ERRNAME;echo;echo
3970 resend 1 2 resendex@am.ple
3971 echo resend 1 2: $? $! $^ERRNAME;echo;echo
3972 Resend 1 2 Resendex@am.ple
3973 echo Resend 1 2: $? $! $^ERRNAME;echo;echo
3974 ' "${MBOX}" |
3975 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! \
3976 -Smta=./.tsendmail.sh \
3978 define bail {
3979 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
3981 define xerr {
3982 vput vexpr es substr "$1" 0 1
3983 if [ "$es" != 2 ]
3984 xcall bail "$2"
3987 define read_mline_res {
3988 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
3989 echo mline_res:$len/$es/$^ERRNAME: $hl
3990 if [ $es -ne $^ERR-NONE ]
3991 xcall bail read_mline_res
3992 elif [ $len -ne 0 ]
3993 \xcall read_mline_res
3996 define work_hl {
3997 echo "~^header show $1"; read es;\
3998 call xerr $es "work_hl $1"; echo $1; call read_mline_res
3999 if [ $# -gt 1 ]
4000 shift
4001 xcall work_hl "$@"
4004 define t_ocs {
4005 read ver
4006 echo t_ocs version $ver
4007 echo "~^header list"; read hl; echo $hl;\
4008 echoerr the header list is $hl;\
4009 call xerr "$hl" "header list"
4010 eval vpospar set $hl
4011 shift
4012 xcall work_hl "$@"
4013 echoerr IT IS WRONG IF YOU SEE THIS
4015 define t_oce {
4016 echo on-XY-enter, mailx-command<$mailx-command>
4017 set t_oce autobcc=oce@exam.ple
4018 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
4019 echo mailx-subject<$mailx-subject>
4020 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
4021 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
4022 mailx-raw-bcc<$mailx-raw-bcc>
4023 echo mailx-orig-from<$mailx-orig-from> \
4024 mailx-orig-to<$mailx-orig-to> \
4025 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
4027 define t_ocl {
4028 echo on-XY-leave, mailx-command<$mailx-command>
4029 set t_ocl autocc=ocl@exam.ple
4030 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
4031 echo mailx-subject<$mailx-subject>
4032 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
4033 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
4034 mailx-raw-bcc<$mailx-raw-bcc>
4035 echo mailx-orig-from<$mailx-orig-from> \
4036 mailx-orig-to<$mailx-orig-to> \
4037 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
4039 define t_occ {
4040 echo on-XY-cleanup, mailx-command<$mailx-command>
4041 set t_occ autocc=occ@exam.ple
4042 echo mailx-from<$mailx-from> mailx-sender<$mailx-sender>
4043 echo mailx-subject<$mailx-subject>
4044 echo mailx-to<$mailx-to> mailx-cc<$mailx-cc> mailx-bcc<$mailx-bcc>
4045 echo mailx-raw-to<$mailx-raw-to> mailx-raw-cc<$mailx-raw-cc> \
4046 mailx-raw-bcc<$mailx-raw-bcc>
4047 echo mailx-orig-from<$mailx-orig-from> \
4048 mailx-orig-to<$mailx-orig-to> \
4049 mailx-orig-cc<$mailx-orig-cc> mailx-orig-bcc<$mailx-orig-bcc>
4051 wysh set on-compose-splice=t_ocs \
4052 on-compose-enter=t_oce on-compose-leave=t_ocl \
4053 on-compose-cleanup=t_occ \
4054 on-resend-enter=t_oce on-resend-cleanup=t_occ
4055 ' > ./.tnotes 2>&1
4056 ex0_test behave:compose_hooks-4-estat
4057 ${cat} ./.tnotes >> "${MBOX}"
4059 check behave:compose_hooks-4 - "${MBOX}" '3038884027 7516'
4061 t_epilog
4064 t_behave_C_opt_customhdr() {
4065 t_prolog t_behave_C_opt_customhdr
4066 TRAP_EXIT_ADDONS="./.t*"
4068 ${cat} <<-_EOT > ./.tsendmail.sh
4069 #!${SHELL} -
4070 (echo 'From CimicifugaRacemosa Mon Dec 25 21:33:40 2017' &&
4071 ${cat} && echo
4072 ) >> "${MBOX}"
4073 _EOT
4074 chmod 0755 ./.tsendmail.sh
4076 echo bla |
4077 ${MAILX} ${ARGS} -Smta=./.tsendmail.sh \
4078 -C 'C-One : Custom One Body' \
4079 -C 'C-Two:CustomTwoBody' \
4080 -S customhdr='chdr1: chdr1 body, chdr2:chdr2 body' \
4081 this-goes@nowhere >./.tall 2>&1
4082 ex0_test behave:C_opt_customhdr-1-estat
4083 ${cat} ./.tall >> "${MBOX}"
4084 check behave:C_opt_customhdr-1 0 "${MBOX}" '2400078426 195'
4086 ${rm} -f "${MBOX}"
4087 printf 'm this-goes@nowhere\nbody\n!.
4088 unset customhdr
4089 m this-goes2@nowhere\nbody2\n!.
4090 set customhdr=%ccustom1 : custom1 body%c
4091 m this-goes2@nowhere\nbody2\n!.
4092 set customhdr=%ccustom1 : custom1\\, body , custom2: custom2 body%c
4093 m this-goes3@nowhere\nbody3\n!.
4094 ' "'" "'" "'" "'" |
4095 ${MAILX} ${ARGS} -Smta=./.tsendmail.sh -Sescape=! \
4096 -C 'C-One : Custom One Body' \
4097 -C 'C-Two:CustomTwoBody' \
4098 -S customhdr='chdr1: chdr1 body, chdr2:chdr2 body' \
4099 >./.tall 2>&1
4100 ex0_test behave:C_opt_customhdr-2-estat
4101 ${cat} ./.tall >> "${MBOX}"
4102 check behave:C_opt_customhdr-2 0 "${MBOX}" '3546878678 752'
4104 t_epilog
4107 t_behave_mass_recipients() {
4108 t_prolog t_behave_mass_recipients
4109 TRAP_EXIT_ADDONS="./.t*"
4111 ${cat} <<-_EOT > ./.tsendmail.sh
4112 #!${SHELL} -
4113 (echo 'From Eucalyptus Sat Jul 08 21:14:57 2017' && ${cat} && echo
4114 ) >> "${MBOX}"
4115 _EOT
4116 chmod 0755 ./.tsendmail.sh
4118 ${cat} <<'__EOT__' > ./.trc
4119 define bail {
4120 echoerr "Failed: $1. Bailing out"; echo "~x"; xit
4122 define ins_addr {
4123 wysh set nr=$1 hn=$2
4124 echo "~$hn $hn$nr@$hn"; echo '~:echo $?'; read es
4125 if [ "$es" -ne 0 ]
4126 xcall bail "ins_addr $hn 1-$nr"
4128 vput vexpr nr + $nr 1
4129 if [ "$nr" -le "$maximum" ]
4130 xcall ins_addr $nr $hn
4133 define bld_alter {
4134 wysh set nr=$1 hn=$2
4135 alternates $hn$nr@$hn
4136 vput vexpr nr + $nr 2
4137 if [ "$nr" -le "$maximum" ]
4138 xcall bld_alter $nr $hn
4141 define t_ocs {
4142 read ver
4143 call ins_addr 1 t
4144 call ins_addr 1 c
4145 call ins_addr 1 b
4147 define t_ocl {
4148 if [ "$t_remove" != '' ]
4149 call bld_alter 1 t
4150 call bld_alter 2 c
4153 set on-compose-splice=t_ocs on-compose-leave=t_ocl
4154 __EOT__
4156 printf 'm this-goes@nowhere\nbody\n!.\n' |
4157 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
4158 -X'source ./.trc' -Smta=./.tsendmail.sh -Smaximum=2001 \
4159 >./.tall 2>&1
4160 ex0_test behave:mass_recipients-1-estat
4161 ${cat} ./.tall >> "${MBOX}"
4162 check behave:mass_recipients-1 - "${MBOX}" '2912243346 51526'
4164 ${rm} -f "${MBOX}"
4165 printf 'm this-goes@nowhere\nbody\n!.\n' |
4166 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
4167 -St_remove=1 -X'source ./.trc' -Smta=./.tsendmail.sh -Smaximum=2001 \
4168 >./.tall 2>&1
4169 ex0_test behave:mass_recipients-2-estat
4170 ${cat} ./.tall >> "${MBOX}"
4171 check behave:mass_recipients-2 - "${MBOX}" '4097804632 34394'
4173 t_epilog
4176 t_behave_mime_types_load_control() {
4177 t_prolog t_behave_mime_types_load_control
4178 if have_feat uistrings; then :; else
4179 echo 'behave:mime_types_load_control: unsupported, skipped'
4180 return
4182 TRAP_EXIT_ADDONS="./.t*"
4184 ${cat} <<-_EOT > ./.tmts1
4185 @ application/mathml+xml mathml
4186 _EOT
4187 ${cat} <<-_EOT > ./.tmts2
4188 @ x-conference/x-cooltalk ice
4189 @ aga-aga aga
4190 @ application/aga-aga aga
4191 _EOT
4193 ${cat} <<-_EOT > ./.tmts1.mathml
4194 <head>nonsense ML</head>
4195 _EOT
4196 ${cat} <<-_EOT > ./.tmts2.ice
4197 Icy, icy road.
4198 _EOT
4199 printf 'of which the c\x01rack is coming soon' > ./.tmtsx.doom
4200 printf 'of which the c\x01rack is coming soon' > ./.tmtsx.aga
4202 printf '
4203 m %s
4204 Schub-di-du
4205 ~@ ./.tmts1.mathml
4206 ~@ ./.tmts2.ice
4207 ~@ ./.tmtsx.doom
4208 ~@ ./.tmtsx.aga
4210 File %s
4211 from*
4212 type
4214 ' "${MBOX}" "${MBOX}" |
4215 ${MAILX} ${ARGS} \
4216 -Smimetypes-load-control=f=./.tmts1,f=./.tmts2 \
4217 > ./.tout 2>&1
4218 ex0_test behave:mime_types_load_control-1-estat
4219 ${cat} "${MBOX}" >> ./.tout
4220 check behave:mime_types_load_control-1 - ./.tout '1441260727 2449'
4222 echo type | ${MAILX} ${ARGS} -R \
4223 -Smimetypes-load-control=f=./.tmts1,f=./.tmts3 \
4224 -f "${MBOX}" >> ./.tout 2>&1
4225 check behave:mime_types_load_control-2 0 ./.tout '1441391438 3646'
4227 t_epilog
4230 t_behave_lreply_futh_rth_etc() {
4231 t_prolog t_behave_lreply_futh_rth_etc
4232 TRAP_EXIT_ADDONS="./.t*"
4234 ${cat} <<-_EOT > ./.tsendmail.sh
4235 #!${SHELL} -
4236 (echo 'From HumulusLupulus Thu Jul 27 14:41:20 2017' && ${cat} && echo
4237 ) >> "${MBOX}"
4238 _EOT
4239 chmod 0755 ./.tsendmail.sh
4241 ${cat} <<-_EOT > ./.tmbox
4242 From neverneverland Sun Jul 23 13:46:25 2017
4243 Subject: Bugstop: five miles out 1
4244 Reply-To: mister originator2 <mr2@originator>, bugstop@five.miles.out
4245 From: mister originator <mr@originator>
4246 To: bugstop-commit@five.miles.out, laber@backe.eu
4247 Cc: is@a.list
4248 Mail-Followup-To: bugstop@five.miles.out, laber@backe.eu, is@a.list
4249 In-reply-to: <20170719111113.bkcMz%laber@backe.eu>
4250 Date: Wed, 19 Jul 2017 09:22:57 -0400
4251 Message-Id: <20170719132257.766AF781267@originator>
4252 Status: RO
4254 > |Sorry, I think I misunderstand something. I would think that
4256 That's appalling.
4258 From neverneverland Fri Jul 7 22:39:11 2017
4259 Subject: Bugstop: five miles out 2
4260 Reply-To: mister originator2<mr2@originator>,bugstop@five.miles.out,is@a.list
4261 Content-Transfer-Encoding: 7bit
4262 From: mister originator <mr@originator>
4263 To: bugstop-commit@five.miles.out
4264 Cc: is@a.list
4265 Message-ID: <149945963975.28888.6950788126957753723.reportbug@five.miles.out>
4266 Date: Fri, 07 Jul 2017 16:33:59 -0400
4267 Status: R
4269 capable of changing back.
4271 From neverneverland Fri Jul 7 22:42:00 2017
4272 Subject: Bugstop: five miles out 3
4273 Reply-To: mister originator2 <mr2@originator>, bugstop@five.miles.out
4274 Content-Transfer-Encoding: 7bit
4275 From: mister originator <mr@originator>
4276 To: bugstop-commit@five.miles.out
4277 Cc: is@a.list
4278 Message-ID: <149945963975.28888.6950788126957753746.reportbug@five.miles.out>
4279 Date: Fri, 07 Jul 2017 16:33:59 -0400
4280 List-Post: <mailto:bugstop@five.miles.out>
4281 Status: R
4283 are you ready, boots?
4285 From neverneverland Sat Aug 19 23:15:00 2017
4286 Subject: Bugstop: five miles out 4
4287 Reply-To: mister originator2 <mr2@originator>, bugstop@five.miles.out
4288 Content-Transfer-Encoding: 7bit
4289 From: mister originator <mr@originator>
4290 To: bugstop@five.miles.out
4291 Cc: is@a.list
4292 Message-ID: <149945963975.28888.6950788126qtewrqwer.reportbug@five.miles.out>
4293 Date: Fri, 07 Jul 2017 16:33:59 -0400
4294 List-Post: <mailto:bugstop@five.miles.out>
4295 Status: R
4297 are you ready, boots?
4298 _EOT
4302 ${cat} <<-'_EOT' | ${MAILX} ${ARGS} -Sescape=! -Smta=./.tsendmail.sh \
4303 -Rf ./.tmbox >> "${MBOX}" 2>&1
4304 define r {
4305 wysh set m="This is text of \"reply ${1}."
4306 reply 1 2 3
4307 !I m
4310 !I m
4313 !I m
4316 echo -----After reply $1.1 - $1.3: $?/$^ERRNAME
4318 define R {
4319 wysh set m="This is text of \"Reply ${1}."
4320 eval Reply $2
4321 !I m
4322 !I 2
4325 echo -----After Reply $1.$2: $?/$^ERRNAME
4327 define _Lh {
4328 read protover
4329 echo '~I m'
4330 echo '~I n'
4331 echo '".'
4333 define _Ls {
4334 wysh set m="This is text of \"Lreply ${1}." on-compose-splice=_Lh n=$2
4335 eval Lreply $2
4337 define L {
4338 # We need two indirections for this test: one for the case that Lreply
4339 # fails because of missing recipients: we need to read EOF next, thus
4340 # place this in _Ls last; and second for the succeeding cases EOF is
4341 # not what these should read, so go over the backside and splice it in!
4342 call _Ls "$@"
4343 echo -----After Lreply $1.$2: $?/$^ERRNAME
4345 define x {
4346 localopts call-fixate yes
4347 call r $1
4348 call R $1 1; call R $1 2; call R $1 3; call R $1 4
4349 call L $1 1; call L $1 2; call L $1 3
4351 define tweak {
4352 echo;echo '===== CHANGING === '"$*"' =====';echo
4353 eval "$@"
4356 set from=laber@backe.eu
4357 mlist is@a.list
4358 call x 1
4359 call tweak set reply-to-honour
4360 call x 2
4361 call tweak set followup-to
4362 call x 3
4363 call tweak set followup-to-honour
4364 call x 4
4365 call tweak mlist bugstop@five.miles.out
4366 call x 5
4367 call tweak mlsubscribe bugstop@five.miles.out
4368 call x 6
4369 call tweak set recipients-in-cc
4370 call x 7
4371 _EOT
4373 ex0_test behave:lreply_futh_rth_etc-1-estat
4374 if have_feat uistrings; then # xxx should not be so, skip??
4375 check behave:lreply_futh_rth_etc-1 - "${MBOX}" '940818845 29373'
4376 else
4377 check behave:lreply_futh_rth_etc-1 - "${MBOX}" '3917430455 29259'
4382 ${cat} <<-_EOT > ./.tmbox
4383 From tom@i-i.example Thu Oct 26 03:15:55 2017
4384 Date: Wed, 25 Oct 2017 21:15:46 -0400
4385 From: tom <tom@i-i.example>
4386 To: Steffen Nurpmeso <steffen@sdaoden.eu>
4387 Cc: tom <tom@i-i.example>
4388 Subject: Re: xxxx yyyyyyyy configure does not really like a missing zzzzz
4389 Message-ID: <20171026011546.GA11643@i-i.example>
4390 Reply-To: tom@i-i.example
4391 References: <20171025214601.T2pNd%steffen@sdaoden.eu>
4392 In-Reply-To: <20171025214601.T2pNd%steffen@sdaoden.eu>
4393 Status: R
4395 The report's useful :-)
4396 _EOT
4398 printf 'reply 1\nthank you\n!.\n' |
4399 ${MAILX} ${ARGS} -Sescape=! -Smta=./.tsendmail.sh -Sreply-to-honour \
4400 -Rf ./.tmbox > "${MBOX}" 2>&1
4401 check behave:lreply_futh_rth_etc-2 0 "${MBOX}" '1045866991 331'
4403 t_epilog
4406 t_behave_mime_if_not_ascii() {
4407 t_prolog t_behave_mime_if_not_ascii
4409 </dev/null ${MAILX} ${ARGS} -s Subject "${MBOX}" >> "${MBOX}" 2>&1
4410 check behave:mime_if_not_ascii-1 0 "${MBOX}" '2287855519 110'
4412 </dev/null ${MAILX} ${ARGS} -Scharset-7bit=not-ascii -s Subject "${MBOX}" \
4413 >> "${MBOX}" 2>&1
4414 check behave:mime_if_not_ascii-2 0 "${MBOX}" '70754682 282'
4416 t_epilog
4419 t_behave_xxxheads_rfc2047() {
4420 t_prolog t_behave_xxxheads_rfc2047
4421 TRAP_EXIT_ADDONS="./.t*"
4423 ${cat} <<-_EOT > ./.tsendmail.sh
4424 #!${SHELL} -
4425 (echo 'From GentianaLutea Mon Dec 04 17:15:29 2017' && ${cat} &&
4426 echo) >> "${MBOX}"
4427 _EOT
4428 chmod 0755 ./.tsendmail.sh
4431 ${rm} -f "${MBOX}"
4432 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
4433 -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̲' \
4434 "${MBOX}"
4435 check behave:xxxheads_rfc2047-1 0 "${MBOX}" '3370931614 375'
4437 # Single word (overlong line split -- bad standard! Requires injection of
4438 # artificial data!! But can be prevented by using RFC 2047 encoding)
4439 ${rm} -f "${MBOX}"
4440 i=`${awk} 'BEGIN{for(i=0; i<92; ++i) printf "0123456789_"}'`
4441 echo | ${MAILX} ${ARGS} -s "${i}" "${MBOX}"
4442 check behave:xxxheads_rfc2047-2 0 "${MBOX}" '489922370 1718'
4444 # Combination of encoded words, space and tabs of varying sort
4445 ${rm} -f "${MBOX}"
4446 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
4447 -s "1Abrä Kaspas1 2Abra Katä b_kaspas2 \
4448 3Abrä Kaspas3 4Abrä Kaspas4 5Abrä Kaspas5 \
4449 6Abra Kaspas6 7Abrä Kaspas7 8Abra Kaspas8 \
4450 9Abra Kaspastäb4-3 10Abra Kaspas1 _ 11Abra Katäb1 \
4451 12Abra Kadabrä1 After Tab after Täb this is NUTS" \
4452 "${MBOX}"
4453 check behave:xxxheads_rfc2047-3 0 "${MBOX}" '1676887734 591'
4455 # Overlong multibyte sequence that must be forcefully split
4456 # todo This works even before v15.0, but only by accident
4457 ${rm} -f "${MBOX}"
4458 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
4459 -s "✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
4460 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
4461 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄" \
4462 "${MBOX}"
4463 check behave:xxxheads_rfc2047-4 0 "${MBOX}" '3029301775 659'
4465 # Trailing WS
4466 ${rm} -f "${MBOX}"
4467 echo | ${MAILX} ${ARGS} \
4468 -s "1-1 B2 B3 B4 B5 B6 B\
4469 1-2 B2 B3 B4 B5 B6 B\
4470 1-3 B2 B3 B4 B5 B6 B\
4471 1-4 B2 B3 B4 B5 B6 B\
4472 1-5 B2 B3 B4 B5 B6 B\
4473 1-6 B2 B3 B4 B5 B6 " \
4474 "${MBOX}"
4475 check behave:xxxheads_rfc2047-5 0 "${MBOX}" '4126167195 297'
4477 # Leading and trailing WS
4478 ${rm} -f "${MBOX}"
4479 echo | ${MAILX} ${ARGS} \
4480 -s " 2-1 B2 B3 B4 B5 B6 B\
4481 1-2 B2 B3 B4 B5 B6 B\
4482 1-3 B2 B3 B4 B5 B6 B\
4483 1-4 B2 B3 B4 B5 B6 " \
4484 "${MBOX}"
4485 check behave:xxxheads_rfc2047-6 0 "${MBOX}" '3600624479 236'
4487 # RFC 2047 in an address field! (Missing test caused v14.9.6!)
4488 ${rm} -f "${MBOX}"
4489 echo "Dat Früchtchen riecht häußlich" |
4490 ${MAILX} ${ARGS} ${ADDARG_UNI} -Sfullnames -Smta=./.tsendmail.sh \
4491 -s Hühöttchen \
4492 'Schnödes "Früchtchen" <do@du> (Hä!)'
4493 check behave:xxxheads_rfc2047-7 0 "${MBOX}" '800505986 368'
4495 # RFC 2047 in an address field, and iconv involved
4496 if have_feat iconv; then
4497 ${rm} -f "${MBOX}"
4498 ${cat} > ./.trebox <<_EOT
4499 From zaza@exam.ple Fri Mar 2 21:31:56 2018
4500 Date: Fri, 2 Mar 2018 20:31:45 +0000
4501 From: z=?iso-8859-1?Q?=E1?=za <zaza@exam.ple>
4502 To: dude <dude@exam.ple>
4503 Subject: houston(...)
4504 Message-ID: <abra@1>
4505 MIME-Version: 1.0
4506 Content-Type: text/plain; charset=iso-8859-1
4507 Content-Disposition: inline
4508 Content-Transfer-Encoding: 8bit
4510 _EOT
4511 echo reply | ${MAILX} ${ARGS} ${ADDARG_UNI} \
4512 -Sfullnames -Sreply-in-same-charset \
4513 -Smta=./.tsendmail.sh -Rf ./.trebox
4514 check behave:xxxheads_rfc2047-8 0 "${MBOX}" '2821484185 280'
4515 else
4516 echo 'behave:xxxheads_rfc2047-8: iconv unsupported, skipped'
4519 t_epilog
4522 t_behave_rfc2231() {
4523 t_prolog t_behave_rfc2231
4524 TRAP_EXIT_ADDONS="./.t*"
4527 mkdir ./.ttt || exit 1
4528 cd ./.ttt || exit 2
4529 : > "ma'ger.txt"
4530 : > "mä'ger.txt"
4531 : > 'diet\ is \curd.txt'
4532 : > 'diet "is" curd.txt'
4533 : > höde-tröge.txt
4534 : > 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
4535 : > höde__tröge__müde__dätte__hätte__vuelle__guelle__aese__aesse__sauerliche__kräuter__österliche__grüße__mäh.txt
4536 : > hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt
4537 : > ✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt
4539 echo bla | ${MAILX} ${ARGS} ${ADDARG_UNI} \
4540 -a "./.ttt/ma'ger.txt" -a "./.ttt/mä'ger.txt" \
4541 -a './.ttt/diet\ is \curd.txt' -a './.ttt/diet "is" curd.txt' \
4542 -a ./.ttt/höde-tröge.txt \
4543 -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 \
4544 -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 \
4545 -a ./.ttt/hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt \
4546 -a ./.ttt/✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt \
4547 "${MBOX}"
4548 check behave:rfc2231-1 0 "${MBOX}" '684985954 3092'
4550 # `resend' test, reusing $MBOX
4551 printf "Resend ./.t2\nx\n" | ${MAILX} ${ARGS} -Rf "${MBOX}"
4552 check behave:rfc2231-2 0 ./.t2 '684985954 3092'
4554 printf "resend ./.t3\nx\n" | ${MAILX} ${ARGS} -Rf "${MBOX}"
4555 check behave:rfc2231-3 0 ./.t3 '3130352658 3148'
4557 t_epilog
4560 t_behave_iconv_mbyte_base64() { # TODO uses sed(1) and special *headline*!!
4561 t_prolog t_behave_iconv_mbyte_base64
4562 TRAP_EXIT_ADDONS="./.t*"
4564 if [ -n "${UTF8_LOCALE}" ] && have_feat iconv; then
4565 if (</dev/null iconv -f ascii -t iso-2022-jp) >/dev/null 2>&1 ||
4566 (</dev/null iconv -f ascii -t euc-jp) >/dev/null 2>&1; then
4568 else
4569 echo 'behave:iconv_mbyte_base64: unsupported, skipped'
4570 return
4572 else
4573 echo 'behave:iconv_mbyte_base64: unsupported, skipped'
4574 return
4577 ${cat} <<-_EOT > ./.tsendmail.sh
4578 #!${SHELL} -
4579 (echo 'From DroseriaRotundifolia Thu Aug 03 17:26:25 2017' && ${cat} &&
4580 echo) >> "${MBOX}"
4581 _EOT
4582 chmod 0755 ./.tsendmail.sh
4584 if (</dev/null iconv -f ascii -t iso-2022-jp) >/dev/null 2>&1; then
4585 ${cat} <<-'_EOT' | LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} \
4586 -Smta=./.tsendmail.sh \
4587 -Sescape=! -Smime-encoding=base64 2>./.terr
4588 set ttycharset=utf-8 sendcharsets=iso-2022-jp
4589 m t1@exam.ple
4590 !s Japanese from UTF-8 to ISO-2022-JP
4591 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
4593 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
4596 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
4598 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
4601 set ttycharset=iso-2022-jp charset-7bit=iso-2022-jp sendcharsets=utf-8
4602 m t2@exam.ple
4603 !s Japanese from ISO-2022-JP to UTF-8, eh, no, also ISO-2022-JP
4604 \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
4606 \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
4609 \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
4611 \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
4613 _EOT
4614 # May not presume iconv output as long as roundtrip possible [489a7122]
4615 ex0_test behave:iconv_mbyte_base64-1-estat
4616 ${awk} 'BEGIN{h=1}/^$/{++h;next}{if(h % 2 == 1)print}' \
4617 < "${MBOX}" > ./.tcksum
4618 check behave:iconv_mbyte_base64-1 - ./.tcksum '2694609714 520'
4619 check behave:iconv_mbyte_base64-2 - ./.terr '4294967295 0'
4621 printf 'eval f 1; eval write ./.twrite; eval type 1; eval type 2\n' |
4622 LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} \
4623 -S headline="%>%a%m %-18f %-16d %i%-s" \
4624 -Rf "${MBOX}" >./.tlog 2>&1
4625 check behave:iconv_mbyte_base64-3 0 ./.twrite '1259742080 686'
4626 #check behave:iconv_mbyte_base64-4 - ./.tlog '3214068822 2123'
4627 ${sed} -e '/^\[-- M/d' < ./.tlog > ./.txlog
4628 check behave:iconv_mbyte_base64-4 - ./.txlog '3659773472 2035'
4629 else
4630 echo 'behave:iconv_mbyte_base64: ISO-2022-JP unsupported, skipping 1-4'
4633 if (</dev/null iconv -f ascii -t euc-jp) >/dev/null 2>&1; then
4634 rm -f "${MBOX}" ./.twrite
4635 ${cat} <<-'_EOT' | LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} \
4636 -Smta=./.tsendmail.sh \
4637 -Sescape=! -Smime-encoding=base64 2>./.terr
4638 set ttycharset=utf-8 sendcharsets=euc-jp
4639 m t1@exam.ple
4640 !s Japanese from UTF-8 to EUC-JP
4641 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
4643 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
4646 カンムリガラ(学名Parus cristatus)は、スズメ目シジュウカラ科に分類される鳥類の一種。
4648 シジュウカラ科(シジュウカラか、学名 Paridae)は、鳥類スズメ目の科である。シジュウカラ(四十雀)と総称されるが、狭義にはこの1種をシジュウカラと呼ぶ。
4651 set ttycharset=EUC-JP sendcharsets=utf-8
4652 m t2@exam.ple
4653 !s Japanese from EUC-JP to UTF-8
4654 ¥·¥¸¥å¥¦¥«¥é²Ê¡Ê¥·¥¸¥å¥¦¥«¥é¤«¡¢³Ø̾ Paridae¡Ë¤Ï¡¢Ä»Îॹ¥º¥áÌܤβʤǤ¢¤ë¡£¥·¥¸¥å¥¦¥«¥é¡Ê»Í½½¿ý¡Ë¤ÈÁí¾Î¤µ¤ì¤ë¤¬¡¢¶¹µÁ¤Ë¤Ï¤³¤Î1¼ï¤ò¥·¥¸¥å¥¦¥«¥é¤È¸Æ¤Ö¡£
4656 ¥«¥ó¥à¥ê¥¬¥é¡Ê³Ø̾Parus cristatus¡Ë¤Ï¡¢¥¹¥º¥áÌÜ¥·¥¸¥å¥¦¥«¥é²Ê¤ËʬÎव¤ì¤ëÄ»Îà¤Î°ì¼ï¡£
4659 ¥«¥ó¥à¥ê¥¬¥é¡Ê³Ø̾Parus cristatus¡Ë¤Ï¡¢¥¹¥º¥áÌÜ¥·¥¸¥å¥¦¥«¥é²Ê¤ËʬÎव¤ì¤ëÄ»Îà¤Î°ì¼ï¡£
4661 ¥·¥¸¥å¥¦¥«¥é²Ê¡Ê¥·¥¸¥å¥¦¥«¥é¤«¡¢³Ø̾ Paridae¡Ë¤Ï¡¢Ä»Îॹ¥º¥áÌܤβʤǤ¢¤ë¡£¥·¥¸¥å¥¦¥«¥é¡Ê»Í½½¿ý¡Ë¤ÈÁí¾Î¤µ¤ì¤ë¤¬¡¢¶¹µÁ¤Ë¤Ï¤³¤Î1¼ï¤ò¥·¥¸¥å¥¦¥«¥é¤È¸Æ¤Ö¡£
4663 _EOT
4664 ex0_test behave:iconv_mbyte_base64-5-estat
4665 ${awk} 'BEGIN{h=1}/^$/{++h;next}{if(h % 2 == 1)print}' \
4666 < "${MBOX}" > ./.tcksum
4667 check behave:iconv_mbyte_base64-5 - ./.tcksum '2870183985 473'
4668 check behave:iconv_mbyte_base64-6 - ./.terr '4294967295 0'
4670 printf 'eval f 1; eval write ./.twrite; eval type 1; eval type 2\n' |
4671 LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} \
4672 -S headline="%>%a%m %-18f %-16d %i%-s" \
4673 -Rf "${MBOX}" >./.tlog 2>&1
4674 check behave:iconv_mbyte_base64-7 0 ./.twrite '1259742080 686'
4675 #check behave:iconv_mbyte_base64-8 - ./.tlog '2506063395 2075'
4676 ${sed} -e '/^\[-- M/d' < ./.tlog > ./.txlog
4677 check behave:iconv_mbyte_base64-8 - ./.txlog '2528199891 1988'
4678 else
4679 echo 'behave:iconv_mbyte_base64: EUC-JP unsupported, skipping 5-8'
4682 t_epilog
4685 t_behave_iconv_mainbody() {
4686 t_prolog t_behave_iconv_mainbody
4687 TRAP_EXIT_ADDONS="./.t*"
4689 if [ -n "${UTF8_LOCALE}" ] && have_feat iconv; then
4691 else
4692 echo 'behave:iconv_mainbody: unsupported, skipped'
4693 return
4696 ${cat} <<-_EOT > ./.tsendmail.sh
4697 #!${SHELL} -
4698 (echo 'From HamamelisVirginiana Fri Oct 20 16:23:21 2017' && ${cat} &&
4699 echo) >> "${MBOX}"
4700 _EOT
4701 chmod 0755 ./.tsendmail.sh
4703 printf '–' | ${MAILX} ${ARGS} ${ADDARG_UNI} -Smta=./.tsendmail.sh \
4704 -S charset-7bit=us-ascii -S charset-8bit=utf-8 \
4705 -s '–' over-the@rain.bow 2>./.terr
4706 check behave:iconv_mainbody-1 0 "${MBOX}" '3634015017 251'
4707 check behave:iconv_mainbody-2 - ./.terr '4294967295 0'
4709 printf '–' | ${MAILX} ${ARGS} ${ADDARG_UNI} -Smta=./.tsendmail.sh \
4710 -S charset-7bit=us-ascii -S charset-8bit=us-ascii \
4711 -s '–' over-the@rain.bow 2>./.terr
4712 exn0_test behave:iconv_mainbody-3
4713 check behave:iconv_mainbody-3 - "${MBOX}" '3634015017 251'
4714 if have_feat uistrings; then
4715 if have_feat docstrings; then # xxx should not be like that
4716 check behave:iconv_mainbody-4 - ./.terr '2579894983 148'
4717 else
4718 check behave:iconv_mainbody-4 - ./.terr '271380835 121'
4720 else
4721 echo 'behave:iconv_mainbody-4: unsupported, skipped'
4724 # The different iconv(3) implementations use different replacement sequence
4725 # types (character-wise, byte-wise, and the character(s) used differ)
4726 i="${MAILX_ICONV_MODE}"
4727 if [ -n "${i}" ]; then
4728 printf 'p\nx\n' | ${MAILX} ${ARGS} -Rf "${MBOX}" >./.tout 2>./.terr
4729 j=${?}
4730 ex0_test behave:iconv_mainbody-5-0 ${j}
4731 check behave:iconv_mainbody-5-1 - ./.terr '4294967295 0'
4732 if [ ${i} -eq 13 ]; then
4733 check behave:iconv_mainbody-5-2 - ./.tout '189327996 283'
4734 elif [ ${i} -eq 12 ]; then
4735 check behave:iconv_mainbody-5-3 - ./.tout '1959197095 283'
4736 elif [ ${i} -eq 3 ]; then
4737 check behave:iconv_mainbody-5-4 - ./.tout '3196380198 279'
4738 else
4739 check behave:iconv_mainbody-5-5 - ./.tout '3760313827 279'
4741 else
4742 echo 'behave:iconv_mainbody-5: unsupported, skipped'
4745 t_epilog
4748 t_behave_binary_mainbody() {
4749 t_prolog t_behave_binary_mainbody
4750 TRAP_EXIT_ADDONS="./.t*"
4752 printf 'abra\0\nka\r\ndabra' |
4753 ${MAILX} ${ARGS} ${ADDARG_UNI} -s 'binary with carriage-return!' \
4754 "${MBOX}" 2>./.terr
4755 check behave:binary_mainbody-1 0 "${MBOX}" '2430168141 243'
4756 check behave:binary_mainbody-2 - ./.terr '4294967295 0'
4758 printf 'p\necho\necho writing now\nwrite ./.twrite\n' |
4759 ${MAILX} ${ARGS} -Rf \
4760 -Spipe-application/octet-stream="@* ${cat} > ./.tcat" \
4761 "${MBOX}" >./.tall 2>&1
4762 check behave:binary_mainbody-3 0 ./.tall '1151843761 324'
4763 check behave:binary_mainbody-4 - ./.tcat '3817108933 15'
4764 check behave:binary_mainbody-5 - ./.twrite '3817108933 15'
4766 t_epilog
4769 t_behave_q_t_etc_opts() {
4770 t_prolog t_behave_q_t_etc_opts
4771 TRAP_EXIT_ADDONS="./.t*"
4773 # Three tests for MIME encoding and (a bit) content classification.
4774 # At the same time testing -q FILE, < FILE and -t FILE
4775 t__put_body > ./.tin
4777 ${rm} -f "${MBOX}"
4778 < ./.tin ${MAILX} ${ARGS} ${ADDARG_UNI} \
4779 -a ./.tin -s "`t__put_subject`" "${MBOX}"
4780 check behave:q_t_etc_opts-1 0 "${MBOX}" '3570973309 6646'
4782 ${rm} -f "${MBOX}"
4783 < /dev/null ${MAILX} ${ARGS} ${ADDARG_UNI} \
4784 -a ./.tin -s "`t__put_subject`" -q ./.tin "${MBOX}"
4785 check behave:q_t_etc_opts-2 0 "${MBOX}" '3570973309 6646'
4787 ${rm} -f "${MBOX}"
4788 ( echo "To: ${MBOX}" && echo "Subject: `t__put_subject`" && echo &&
4789 ${cat} ./.tin
4790 ) | ${MAILX} ${ARGS} ${ADDARG_UNI} -Snodot -a ./.tin -t
4791 check behave:q_t_etc_opts-3 0 "${MBOX}" '3570973309 6646'
4793 t_epilog
4796 t_behave_s_mime() {
4797 have_feat smime || {
4798 echo 'behave:s/mime: unsupported, skipped'
4799 return
4802 t_prolog t_behave_s_mime
4803 TRAP_EXIT_ADDONS="./.t.conf ./.tkey.pem ./.tcert.pem ./.tpair.pem"
4804 TRAP_EXIT_ADDONS="${TRAP_EXIT_ADDONS} ./.VERIFY ./.DECRYPT ./.ENCRYPT"
4805 TRAP_EXIT_ADDONS="${TRAP_EXIT_ADDONS} ./.tsendmail.sh"
4807 printf 'behave:s/mime: .. generating test key and certificate ..\n'
4808 ${cat} <<-_EOT > ./.t.conf
4809 [ req ]
4810 default_bits = 1024
4811 default_keyfile = keyfile.pem
4812 distinguished_name = req_distinguished_name
4813 attributes = req_attributes
4814 prompt = no
4815 output_password =
4817 [ req_distinguished_name ]
4818 C = GB
4819 ST = Over the
4820 L = rainbow
4821 O = S-nail
4822 OU = S-nail.smime
4823 CN = S-nail.test
4824 emailAddress = test@localhost
4826 [ req_attributes ]
4827 challengePassword =
4828 _EOT
4829 openssl req -x509 -nodes -days 3650 -config ./.t.conf \
4830 -newkey rsa:1024 -keyout ./.tkey.pem -out ./.tcert.pem >>${ERR} 2>&1
4831 ${cat} ./.tkey.pem ./.tcert.pem > ./.tpair.pem
4833 # Sign/verify
4834 printf 'behave:s/mime:sign/verify: '
4835 echo bla | ${MAILX} ${ARGS} \
4836 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
4837 -Ssmime-sign -Sfrom=test@localhost \
4838 -s 'S/MIME test' ./.VERIFY
4839 if [ $? -eq 0 ]; then
4840 printf 'ok\n'
4841 else
4842 printf 'failed\n'
4843 ESTAT=1
4844 t_epilog
4845 return
4848 ${awk} '
4849 BEGIN{ skip=0 }
4850 /^Content-Description: /{ skip = 2; print; next }
4851 /^$/{ if(skip) --skip }
4852 { if(!skip) print }
4854 < ./.VERIFY > "${MBOX}"
4855 check behave:s/mime:sign/verify:checksum - "${MBOX}" '2900817158 648'
4857 printf 'behave:s/mime:sign/verify:verify '
4858 printf 'verify\nx\n' |
4859 ${MAILX} ${ARGS} \
4860 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
4861 -Ssmime-sign -Sfrom=test@localhost \
4862 -Serrexit -R \
4863 -f ./.VERIFY >>${ERR} 2>&1
4864 if [ $? -eq 0 ]; then
4865 printf 'ok\n'
4866 else
4867 printf 'failed\n'
4868 ESTAT=1
4869 t_epilog
4870 return
4873 printf 'behave:s/mime:sign/verify:disproof-1 '
4874 if openssl smime -verify -CAfile ./.tcert.pem \
4875 -in ./.VERIFY >>${ERR} 2>&1; then
4876 printf 'ok\n'
4877 else
4878 printf 'failed\n'
4879 ESTAT=1
4880 t_epilog
4881 return
4884 # (signing +) encryption / decryption
4885 ${cat} <<-_EOT > ./.tsendmail.sh
4886 #!${SHELL} -
4887 (echo 'From Euphrasia Thu Apr 27 17:56:23 2017' && ${cat}) > ./.ENCRYPT
4888 _EOT
4889 chmod 0755 ./.tsendmail.sh
4891 printf 'behave:s/mime:encrypt+sign: '
4892 echo bla |
4893 ${MAILX} ${ARGS} \
4894 -Ssmime-force-encryption \
4895 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
4896 -Smta=./.tsendmail.sh \
4897 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
4898 -Ssmime-sign -Sfrom=test@localhost \
4899 -s 'S/MIME test' recei@ver.com
4900 if [ $? -eq 0 ]; then
4901 printf 'ok\n'
4902 else
4903 ESTAT=1
4904 printf 'error: encrypt+sign failed\n'
4907 ${sed} -e '/^$/,$d' < ./.ENCRYPT > "${MBOX}"
4908 check behave:s/mime:encrypt+sign:checksum - "${MBOX}" '1937410597 327'
4910 printf 'behave:s/mime:decrypt+verify: '
4911 printf 'decrypt ./.DECRYPT\nfi ./.DECRYPT\nverify\nx\n' |
4912 ${MAILX} ${ARGS} \
4913 -Ssmime-force-encryption \
4914 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
4915 -Smta=./.tsendmail.sh \
4916 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
4917 -Ssmime-sign -Sfrom=test@localhost \
4918 -Serrexit -R \
4919 -f ./.ENCRYPT >>${ERR} 2>&1
4920 if [ $? -eq 0 ]; then
4921 printf 'ok\n'
4922 else
4923 ESTAT=1
4924 printf 'failed\n'
4927 ${awk} '
4928 BEGIN{ skip=0 }
4929 /^Content-Description: /{ skip = 2; print; next }
4930 /^$/{ if(skip) --skip }
4931 { if(!skip) print }
4933 < ./.DECRYPT > "${MBOX}"
4934 check behave:s/mime:decrypt+verify:checksum - "${MBOX}" '1720739247 931'
4936 printf 'behave:s/mime:decrypt+verify:disproof-1: '
4937 if (openssl smime -decrypt -inkey ./.tkey.pem -in ./.ENCRYPT |
4938 openssl smime -verify -CAfile ./.tcert.pem) >>${ERR} 2>&1; then
4939 printf 'ok\n'
4940 else
4941 printf 'failed\n'
4942 ESTAT=1
4945 printf "behave:s/mime:encrypt: "
4946 echo bla | ${MAILX} ${ARGS} \
4947 -Ssmime-force-encryption \
4948 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
4949 -Smta=./.tsendmail.sh \
4950 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
4951 -Sfrom=test@localhost \
4952 -s 'S/MIME test' recei@ver.com
4953 if [ $? -eq 0 ]; then
4954 printf 'ok\n'
4955 else
4956 ESTAT=1
4957 printf 'failed\n'
4960 # Same as behave:s/mime:encrypt+sign:checksum above
4961 ${sed} -e '/^$/,$d' < ./.ENCRYPT > "${MBOX}"
4962 check behave:s/mime:encrypt:checksum - "${MBOX}" '1937410597 327'
4964 ${rm} -f ./.DECRYPT
4965 printf 'decrypt ./.DECRYPT\nx\n' | ${MAILX} ${ARGS} \
4966 -Ssmime-force-encryption \
4967 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
4968 -Smta=./.tsendmail.sh \
4969 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
4970 -Sfrom=test@localhost \
4971 -Serrexit -R \
4972 -f ./.ENCRYPT >>${ERR} 2>&1
4973 check behave:s/mime:decrypt 0 "./.DECRYPT" '2624716890 422'
4975 printf 'behave:s/mime:decrypt:disproof-1: '
4976 if openssl smime -decrypt -inkey ./.tkey.pem \
4977 -in ./.ENCRYPT >>${ERR} 2>&1; then
4978 printf 'ok\n'
4979 else
4980 printf 'failed\n'
4981 ESTAT=1
4984 t_epilog
4987 # t_content()
4988 # xxx Note: t_content() was the first test (series) written. Today many
4989 # xxx aspects are (better) covered by other tests above, some are not.
4990 # xxx At some future date and time, convert the last remains not covered
4991 # xxx elsewhere to a real t_behave_* test and drop t_content()
4992 t_content() {
4993 t_prolog t_content
4995 # Test for [260e19d] (Juergen Daubert)
4996 ${rm} -f "${MBOX}"
4997 echo body | ${MAILX} ${ARGS} "${MBOX}"
4998 check content:004 0 "${MBOX}" '2917662811 98'
5000 # "Test for" [d6f316a] (Gavin Troy)
5001 ${rm} -f "${MBOX}"
5002 printf "m ${MBOX}\n~s subject1\nEmail body\n~.\nfi ${MBOX}\np\nx\n" |
5003 ${MAILX} ${ARGS} ${ADDARG_UNI} -Spipe-text/plain="@* ${cat}" > "${BODY}"
5004 check content:006 0 "${MBOX}" '2099098650 122'
5005 check content:006-1 - "${BODY}" '794542938 174'
5007 # "Test for" [c299c45] (Peter Hofmann) TODO shouldn't end up QP-encoded?
5008 ${rm} -f "${MBOX}"
5009 ${awk} 'BEGIN{
5010 for(i = 0; i < 10000; ++i)
5011 printf "\xC3\xBC"
5012 #printf "\xF0\x90\x87\x90"
5013 }' | ${MAILX} ${ARGS} ${ADDARG_UNI} -s TestSubject "${MBOX}"
5014 check content:007 0 "${MBOX}" '534262374 61816'
5016 t_epilog
5019 t__put_subject() {
5020 # MIME encoding (QP) stress message subject
5021 printf 'Äbrä Kä?dä=brö Fü?di=bus? '\
5022 'adadaddsssssssddddddddddddddddddddd'\
5023 'ddddddddddddddddddddddddddddddddddd'\
5024 'ddddddddddddddddddddddddddddddddddd'\
5025 'dddddddddddddddddddd Hallelulja? Od'\
5026 'er?? eeeeeeeeeeeeeeeeeeeeeeeeeeeeee'\
5027 'eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'\
5028 'eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee f'\
5029 'fffffffffffffffffffffffffffffffffff'\
5030 'fffffffffffffffffffff ggggggggggggg'\
5031 'ggggggggggggggggggggggggggggggggggg'\
5032 'ggggggggggggggggggggggggggggggggggg'\
5033 'ggggggggggggggggggggggggggggggggggg'\
5034 'gggggggggggggggg'
5037 t__put_body() {
5038 # MIME encoding (QP) stress message body
5039 printf \
5040 'Ich bin eine DÖS-Datäi mit sehr langen Zeilen und auch '\
5041 'sonst bin ich ganz schön am Schleudern, da kannste denke '\
5042 "wasde willst, gelle, gelle, gelle, gelle, gelle.\r\n"\
5043 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst \r\n"\
5044 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1\r\n"\
5045 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12\r\n"\
5046 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123\r\n"\
5047 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1234\r\n"\
5048 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12345\r\n"\
5049 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123456\r\n"\
5050 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1234567\r\n"\
5051 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12345678\r\n"\
5052 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123456789\r\n"\
5053 "Unn ausserdem habe ich trailing SP/HT/SP/HT whitespace \r\n"\
5054 "Unn ausserdem habe ich trailing HT/SP/HT/SP whitespace \r\n"\
5055 "auf den zeilen vorher.\r\n"\
5056 "From am Zeilenbeginn und From der Mitte gibt es auch.\r\n"\
5057 ".\r\n"\
5058 "Die letzte Zeile war nur ein Punkt.\r\n"\
5059 "..\r\n"\
5060 "Das waren deren zwei.\r\n"\
5061 " \r\n"\
5062 "Die letzte Zeile war ein Leerschritt.\n"\
5063 "=VIER = EQUAL SIGNS=ON A LINE=\r\n"\
5064 "Prösterchen.\r\n"\
5065 ".\n"\
5066 "Die letzte Zeile war nur ein Punkt, mit Unix Zeilenende.\n"\
5067 "..\n"\
5068 "Das waren deren zwei. ditto.\n"\
5069 "Prösterchen.\n"\
5070 "Unn ausseerdem habe ich trailing SP/HT/SP/HT whitespace \n"\
5071 "Unn ausseerdem habe ich trailing HT/SP/HT/SP whitespace \n"\
5072 "auf den zeilen vorher.\n"\
5073 "ditto.\n"\
5074 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.\n"\
5075 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.1"\
5076 "\n"\
5077 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
5078 "\n"\
5079 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
5080 "3\n"\
5081 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
5082 "34\n"\
5083 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
5084 "345\n"\
5085 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
5086 "3456\n"\
5087 "QP am Zeilenende über soft-nl hinweg\n"\
5088 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
5089 "ö123\n"\
5090 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
5091 "1ö23\n"\
5092 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
5093 "12ö3\n"\
5094 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
5095 "123ö\n"\
5096 "=VIER = EQUAL SIGNS=ON A LINE=\n"\
5097 " \n"\
5098 "Die letzte Zeile war ein Leerschritt.\n"\
5102 t_all() {
5103 # if have_feat devel; then
5104 # ARGS="${ARGS} -Smemdebug"
5105 # export ARGS
5106 # fi
5108 if [ -n "${UTF8_LOCALE}" ]; then
5109 printf 'Using Unicode locale %s\n' "${UTF8_LOCALE}"
5110 else
5111 printf 'No Unicode locale found, disabling Unicode tests\n'
5114 t_behave
5115 t_content
5118 # cc_all_configs()
5119 # Test all configs TODO doesn't cover all *combinations*, stupid!
5120 cc_all_configs() {
5121 < ${CONF} ${awk} '
5122 BEGIN{
5123 ALWAYS = "OPT_AUTOCC=1 OPT_AMALGAMATION=1"
5124 NOTME["OPT_ALWAYS_UNICODE_LOCALE"] = 1
5125 NOTME["OPT_CROSS_BUILD"] = 1
5126 NOTME["OPT_AUTOCC"] = 1
5127 NOTME["OPT_AMALGAMATION"] = 1
5128 NOTME["OPT_DEBUG"] = 1
5129 NOTME["OPT_DEVEL"] = 1
5130 NOTME["OPT_ASAN_ADDRESS"] = 1
5131 NOTME["OPT_ASAN_MEMORY"] = 1
5132 NOTME["OPT_FORCED_STACKPROT"] = 1
5133 NOTME["OPT_NOMEMDBG"] = 1
5134 NOTME["OPT_NYD2"] = 1
5136 #OPTVALS
5137 OPTNO = 0
5139 MULCHOICE["OPT_IDNA"] = "VAL_IDNA"
5140 MULVALS["VAL_IDNA"] = 1
5142 #VALKEYS[0] = "VAL_RANDOM"
5143 VALVALS["VAL_RANDOM"] = 1
5144 VALNO = 0
5146 /^[[:space:]]*OPT_/{
5147 sub(/^[[:space:]]*/, "")
5148 # This bails for UnixWare 7.1.4 awk(1), but preceeding = with \
5149 # does not seem to be a compliant escape for =
5150 #sub(/=.*$/, "")
5151 $1 = substr($1, 1, index($1, "=") - 1)
5152 if(!NOTME[$1])
5153 OPTVALS[OPTNO++] = $1
5154 next
5156 /^[[:space:]]*VAL_/{
5157 sub(/^[[:space:]]*/, "")
5158 val = substr($0, index($0, "=") + 1)
5159 if(val ~ /^\"/){
5160 val = substr(val, 2)
5161 val = substr(val, 1, length(val) - 1)
5163 $1 = substr($1, 1, index($1, "=") - 1)
5164 if(MULVALS[$1])
5165 MULVALS[$1] = val
5166 else if(VALVALS[$1]){
5167 VALKEYS[VALNO++] = $1
5168 VALVALS[$1] = val
5170 next
5172 function onepass(addons){
5173 a_onepass__worker(addons, "1", "0")
5174 a_onepass__worker(addons, "0", "1")
5176 function a_onepass__worker(addons, b0, b1){
5177 # Doing this completely sequentially and not doing make distclean in
5178 # between runs should effectively result in lesser compilations.
5179 # It is completely dumb nonetheless... TODO
5180 for(ono = 0; ono < OPTNO; ++ono){
5181 myconf = mula = ""
5182 for(i = 0; i < ono; ++i){
5183 myconf = myconf " " OPTVALS[i] "=" b0 " "
5184 if(b0 == "1"){
5185 j = MULCHOICE[OPTVALS[i]]
5186 if(j){
5187 if(i + 1 == ono)
5188 mula = j
5189 else
5190 myconf = myconf " " MULCHOICE[OPTVALS[i]] "=any "
5194 for(i = ono; i < OPTNO; ++i){
5195 myconf = myconf " " OPTVALS[i] "=" b1 " "
5196 if(b1 == "1"){
5197 j = MULCHOICE[OPTVALS[i]]
5198 if(j){
5199 if(i + 1 == OPTNO)
5200 mula = j;
5201 else
5202 myconf = myconf " " MULCHOICE[OPTVALS[i]] "=any "
5207 for(i in VALKEYS)
5208 myconf = VALKEYS[i] "=any " myconf
5210 myconf = myconf " " ALWAYS " " addons
5212 if(mula == "")
5213 print myconf
5214 else{
5215 i = split(MULVALS[mula], ia)
5216 j = "any"
5217 while(i >= 1){
5218 j = ia[i--] " " j
5219 print mula "=\"" j "\" " myconf
5224 END{
5225 # We cannot test NULL because of missing UI strings, which will end
5226 # up with different checksums
5227 print "CONFIG=NULLI OPT_AUTOCC=1"
5228 for(i in VALKEYS){
5229 j = split(VALVALS[VALKEYS[i]], ia)
5230 k = "any"
5231 while(j >= 1){
5232 k = ia[j--] " " k
5233 print VALKEYS[i] "=\"" k "\" CONFIG=NULLI OPT_AUTOCC=1"
5236 print "CONFIG=MINIMAL OPT_AUTOCC=1"
5237 print "CONFIG=NETSEND OPT_AUTOCC=1"
5238 print "CONFIG=MAXIMAL OPT_AUTOCC=1"
5239 for(i in VALKEYS){
5240 j = split(VALVALS[VALKEYS[i]], ia)
5241 k = "any"
5242 while(j >= 1){
5243 k = ia[j--] " " k
5244 print VALKEYS[i] "=\"" k "\" CONFIG=MAXIMAL OPT_AUTOCC=1"
5247 print "CONFIG=DEVEL OPT_AUTOCC=1"
5248 print "CONFIG=ODEVEL OPT_AUTOCC=1"
5250 onepass("OPT_DEBUG=1")
5251 onepass("")
5253 ' | while read c; do
5254 [ -f mk-config.h ] && ${cp} mk-config.h .ccac.h
5255 printf "\n\n##########\n$c\n"
5256 printf "\n\n##########\n$c\n" >&2
5257 ${SHELL} -c "${MAKE} ${c} config"
5258 if [ -f .ccac.h ] && ${cmp} mk-config.h .ccac.h; then
5259 printf 'Skipping after config, nothing changed\n'
5260 printf 'Skipping after config, nothing changed\n' >&2
5261 continue
5263 ${SHELL} -c "${MAKE} build test"
5264 done
5265 ${rm} -f .ccac.h
5266 ${MAKE} distclean
5269 [ -n "${ERR}" ] && echo > ${ERR}
5270 if [ -z "${CHECK_ONLY}${MAE_TEST}" ]; then
5271 cc_all_configs
5272 elif [ -z "${MAE_TEST}" ] || [ ${#} -eq 0 ]; then
5273 t_all
5274 else
5275 while [ ${#} -gt 0 ]; do
5276 ${1}
5277 shift
5278 done
5281 [ ${ESTAT} -eq 0 ] && echo Ok || echo >&2 'Errors occurred'
5283 exit ${ESTAT}
5284 # s-sh-mode