rp

simple email tools
git clone https://git.parazyd.org/rp
Log | Files | Refs | README | LICENSE

commit 611044199ff9528142f4f9bc1f7be6b71e0f58ae
parent 0369264948bf87d176300b4080150cfd1ca7dfc7
Author: parazyd <parazyd@dyne.org>
Date:   Wed, 19 Dec 2018 08:51:55 -0500

Change message style.

Diffstat:
Mbin/rpabook | 10++++++----
Mbin/rppeek | 6+++---
Mbin/rpsend | 24+++++++++++++-----------
Mbin/rpsieve | 24+++++++++++++-----------
Mind.c | 6+++---
Mutil.c | 12++++++------
6 files changed, 44 insertions(+), 38 deletions(-)

diff --git a/bin/rpabook b/bin/rpabook @@ -9,9 +9,11 @@ profile="${RPPROFILE:-$HOME/.rp/default}" ab="$profile/whitelist.abook" usage() { - printf " * usage: %s [-a < email] [-c pattern]\\n" "$(basename "$0")" - printf "\\t-a: add to abook\\n" - printf "\\t-c: completion (used from mutt)\\n" + cat <<EOF +* usage: $(basename $0) [-a < email] [-c pattern] + -a: add to abook + -c: completion (used with mutt) +EOF exit 1 } @@ -23,7 +25,7 @@ for i in "$@"; do name="$(echo "$email" | rpheaders From | cut -d'<' -f1 | sed 's/ $//')" echo "$addr" grep -q "^email=$addr" "$ab" && { - echo " * address already in abook" + echo "* address already in abook" exit 0 } diff --git a/bin/rppeek b/bin/rppeek @@ -7,18 +7,18 @@ profile="${RPPROFILE:-$HOME/.rp/default}" usage() { - printf " * usage: %s [folder]\\n" "$(basename "$0")" + echo "* usage: $(basename $0) [folder]" exit 1 } for i in "$@"; do case "$i" in - -h) + -*) usage ;; *) folder="-f =${i}" - echo " * requested folder '$i'" + echo "* requested folder: '$i'" ;; esac done diff --git a/bin/rpsend b/bin/rpsend @@ -7,11 +7,13 @@ profile="${RPPROFILE:-$HOME/.rp/default}" usage() { - printf " * usage: %s [-n] [-v] [-l] [-a] < email\\n" "$(basename "$0")" - printf "\\t-n: dry run\\n" - printf "\\t-v: verbose list output\\n" - printf "\\t-l: list outbox\\n" - printf "\\t-a: send all\\n" + cat <<EOF +* usage: $(basename $0) [-n] [-v] [-l] [-a] < email + -n: dry run + -l: list outbox + -v: verbose list output + -a: send all +EOF exit 1 } @@ -64,7 +66,7 @@ ruser="$(rpheaders ruser < "$profile"/config)" printf "\\n\\n * smtp send via %s\\n" "$rimap" if ! [ -f "$profile/smtp-fingerprint" ]; then - echo " * no saved tls certificate fingerprint found. going with tofu." + echo "* no saved tls certificate fingerprint found. going with tofu." rputil -e getfpr "$rnet" > "$profile"/smtp-fingerprint fi @@ -85,7 +87,7 @@ fi msmtpcfg="$(mktemp)" -cat <<EOF > "$msmtpcfg" +cat > "$msmtpcfg" << EOF account default from $ruser user $ruser @@ -109,7 +111,7 @@ cat <<EOF * sending $(rputil -e humansize "${#email}") over the network EOF -cat <<EOF | msmtp $dryrun -C "$msmtpcfg" -t -X "$profile/tmp/msmtp.log" +cat | msmtp "$dryrun" -C "$msmtpcfg" -t -X "$profile/tmp/msmtp.log" << EOF $email EOF @@ -119,15 +121,15 @@ rm -f "$msmtpcfg" case "$_e" in 0) - echo " * email sent successfully" + echo "* email sent successfully" ;; *) - echo " * msmtp failed" + echo "* msmtp failed" exit $_e ;; esac # if successful, place into Sent -cat <<EOF | /usr/libexec/dovecot/deliver -m Sent +cat | /usr/libexec/dovecot/deliver -m Sent << EOF $email EOF diff --git a/bin/rpsieve b/bin/rpsieve @@ -7,10 +7,12 @@ profile="${RPPROFILE:-$HOME/.rp/default}" usage() { - printf " * usage: %s [-e] [-u] [-v]\\n" "$(basename "$0")" - printf "\\t-e: edit filters.txt before continuing\\n" - printf "\\t-u: upload filters.sieve when done\\n" - printf "\\t-v: be verbose\\n" + cat <<EOF +* usage: $(basename $0) [-e] [-u] [-v] + -e: edit filters.txt before continuing + -u: upload filters.sieve when done + -v; be verbose +EOF exit 1 } @@ -38,16 +40,16 @@ ab="$profile/whitelist.abook" [ -n "$ed" ] && vim "$ft" [ -f "$ft" ] || { - echo " * no filters.txt file" + echo "* no filters.txt file" exit 1 } [ -f "$ab" ] || { - echo " * no whitelist.abook file" + echo "* no whitelist.abook file" exit 1 } -echo " * generating sieve rules" -cat <<EOF > "$fs" +echo "* generating sieve rules" +cat > "$fs" << EOF # mailbox supports fileinto :create require ["fileinto","mailbox","variables"]; @@ -65,7 +67,7 @@ EOF rohrpost rpsieve $verbose < "$ab" } >> "$fs" -cat <<EOF >> "$fs" +cat >> "$fs" << EOF # spam if header :is "X-Spam-Flag" "YES" { fileinto :create "zz.spam"; stop; } @@ -74,11 +76,11 @@ fileinto :create "unsorted"; EOF if [ -n "$upload" ]; then - echo " * uploading filters.sieve" + echo "* uploading filters.sieve" host=t3.dyne.org path=/var/vmail/sieve-scripts/"$(readlink "$profile")" scp "$fs" "$host:$path" || { - echo " * upload failed" + echo "* upload failed" exit 1 } fi diff --git a/ind.c b/ind.c @@ -12,7 +12,7 @@ void edie(char *fmt, ...) { va_list fmtargs; va_start(fmtargs, fmt); - fprintf(stderr, " \033[31m*\033[0m "); + fprintf(stderr, "\033[31m*\033[0m "); vfprintf(stderr, fmt, fmtargs); va_end(fmtargs); fprintf(stderr, ": "); @@ -26,7 +26,7 @@ void die(char *fmt, ...) { va_list fmtargs; va_start(fmtargs, fmt); - fprintf(stderr, " \033[31m*\033[0m "); + fprintf(stderr, "\033[31m*\033[0m "); vfprintf(stderr, fmt, fmtargs); va_end(fmtargs); @@ -37,7 +37,7 @@ void info(char *fmt, ...) { va_list fmtargs; va_start(fmtargs, fmt); - fprintf(stderr, " \033[32m*\033[0m "); + fprintf(stderr, "\033[32m*\033[0m "); vfprintf(stderr, fmt, fmtargs); va_end(fmtargs); } diff --git a/util.c b/util.c @@ -19,12 +19,12 @@ char be[] = void utilusage(void) { die("usage: %s [-e cmd [args]]\n" - "\t-e: run util\n\n" - " available utils:\n" - "\t * genmsgid: generates a Message-ID header\n" - "\t * genmimeb: generates a semi-random MIME boundary\n" - "\t * humansize: calculates byte size into human readable\n" - "\t * getfpr: get tls fingerprint of $netspec\n", argv0); + " -e: run util\n\n" + "available utils:\n" + " * genmsgid: generates a Message-ID header\n" + " * genmimeb: generates a semi-random MIME boundary\n" + " * humansize: calculates byte size into human readable\n" + " * getfpr: get tls fingerprint of $netspec\n", argv0); } int randint(int max) {