- else
- rm -rf "$@"
- fi
-}
-
-
-tclock() {
- clear
- date +%l:%_M
- len=60
- # this goes to full width
- #len=${1:-$((COLUMNS -7))}
- x=1
- while true; do
- if (( x == len )); then
- end=true
- d="$(date +%l:%_M) "
- else
- end=false
- d=$(date +%l:%M:%_S)
- fi
- echo -en "\r"
- echo -n "$d"
- for ((i=0; i<x; i++)); do
- if (( i % 6 )); then
- echo -n _
- else
- echo -n .
- fi
- done
- if $end; then
- echo
- x=1
- else
- x=$((x+1))
- fi
- sleep 5
- done
-}
-
-
-te() {
- # test existence / exists
- local ret=0
- for x in "$@"; do
- [[ -e "$x" || -L "$x" ]] || ret=1
- done
- return $ret
-}
-
-testmail() {
- declare -gi _seq; _seq+=1
- echo "test body" | m mail -s "test mail from $HOSTNAME, $_seq" "${@:-root@localhost}"
- # for testing to send from an external address, you can do for example
- # -aFrom:ian@iank.bid web-6fnbs@mail-tester.com
- # note in exim, you can retry a deferred message
- # s exim -M MSG_ID
- # MSG_ID is in /var/log/exim4/mainlog, looks like 1ccdnD-0001nh-EN
-}
-
-# use -eW to actually modify mailbox
-testsievelist() {
- sieve-filter ~/sieve/main.sieve "$@" >/a/tmp/slog 2> >(tail) && sed -rn '/^Performed actions:/{n;n;p}' /a/tmp/slog | sort -u
-}
-
-
-testsieve() {
- sieve-filter ~/sieve/main.sieve "$@"
-}
-
-testexim() {
- # testmail above calls sendmail, which is a link to exim/postfix.
- # it's docs don't say a way of adding an argument
- # to sendmail to turn on debug output. We could make a wrapper, but
- # that is a pain. Exim debug args are documented here:
- # http://www.exim.org/exim-html-current/doc/html/spec_html/ch-the_exim_command_line.html
- #
- # http://www.exim.org/exim-html-current/doc/html/spec_html/ch-building_and_installing_exim.html
- # note, for exim daemon, you can turn on debug options by
- # adding -d, etc to COMMONOPTIONS in
- # /etc/default/exim4
- # for testing external mail, you need the to address as final cmdline arg
- exim -d+tls -t <<'EOF'
+ else
+ rm -rf "$@"
+ fi
+}
+
+
+ tclock() {
+ clear
+ date +%l:%_M
+ len=60
+ # this goes to full width
+ #len=${1:-$((COLUMNS -7))}
+ x=1
+ while true; do
+ if (( x == len )); then
+ end=true
+ d="$(date +%l:%_M) "
+ else
+ end=false
+ d=$(date +%l:%M:%_S)
+ fi
+ echo -en "\r"
+ echo -n "$d"
+ for ((i=0; i<x; i++)); do
+ if (( i % 6 )); then
+ echo -n _
+ else
+ echo -n .
+ fi
+ done
+ if $end; then
+ echo
+ x=1
+ else
+ x=$((x+1))
+ fi
+ sleep 5
+ done
+ }
+
+
+ te() {
+ # test existence / exists
+ local ret=0
+ for x in "$@"; do
+ [[ -e "$x" || -L "$x" ]] || ret=1
+ done
+ return $ret
+ }
+
+ # mail related
+ testmail() {
+ declare -gi _seq; _seq+=1
+ echo "test body" | m mail -s "test mail from $HOSTNAME, $_seq" "${@:-root@localhost}"
+ # for testing to send from an external address, you can do for example
+ # -fian@iank.bid -aFrom:ian@iank.bid web-6fnbs@mail-tester.com
+ # note in exim, you can retry a deferred message
+ # s exim -M MSG_ID
+ # MSG_ID is in /var/log/exim4/mainlog, looks like 1ccdnD-0001nh-EN
+ }
+
+ # to test sieve, use below command. for fsf mail, see fsf-get-mail script.
+ # make modifications, then copy to live file, use -eW to actually modify mailbox
+ # cp /p/c/subdir_files/sieve/personal{test,}.sieve; testsievelist -eW INBOX
+ #
+ # Another option is to use sieve-test SCRIPT MAIL_FILE. note,
+ # sieve-test doesn't know about envelopes, I'm not sure if sieve-filter does.
+
+ # sieve with output filter. arg is mailbox, like INBOX.
+ # This depends on dovecot conf, notably mail_location in /etc/dovecot/conf.d/10-mail.conf
+
+ testsievelist() {
+ sieve-filter ~/sieve/maintest.sieve "$@" >/tmp/testsieve.log 2> >(tail) && sed -rn '/^Performed actions:/{n;n;p}' /tmp/testsieve.log | sort -u
+ }
+
+
+ # mail related
+ # plain sieve
+ testsieve() {
+ sieve-filter ~/sieve/main.sieve "$@"
+ }
+
+ # mail related
+ testexim() {
+ # testmail above calls sendmail, which is a link to exim/postfix.
+ # it's docs don't say a way of adding an argument
+ # to sendmail to turn on debug output. We could make a wrapper, but
+ # that is a pain. Exim debug args are documented here:
+ # http://www.exim.org/exim-html-current/doc/html/spec_html/ch-the_exim_command_line.html
+ #
+ # http://www.exim.org/exim-html-current/doc/html/spec_html/ch-building_and_installing_exim.html
+ # note, for exim daemon, you can turn on debug options by
+ # adding -d, etc to COMMONOPTIONS in
+ # /etc/default/exim4
+ # for testing external mail, you need the to address as final cmdline arg
+ exim -d+tls -t <<'EOF'