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