aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2023-03-12 10:22:33 -0300
committerEuAndreh <eu@euandre.org>2023-03-12 10:22:33 -0300
commit0862609ee92c855b7e516c03dada6945d32c9583 (patch)
treea6c6b25af6a5e938407d98b63e8a542e0621c0de /bin
parentbin/reconfigure: Add -U option to call update(1) (diff)
downloaddotfiles-0862609ee92c855b7e516c03dada6945d32c9583.tar.gz
dotfiles-0862609ee92c855b7e516c03dada6945d32c9583.tar.xz
bin/email: Make ADDRESS optional
Diffstat (limited to 'bin')
-rwxr-xr-xbin/email15
1 files changed, 9 insertions, 6 deletions
diff --git a/bin/email b/bin/email
index 2cce7f0..e6b055c 100755
--- a/bin/email
+++ b/bin/email
@@ -4,7 +4,7 @@ set -eu
usage() {
cat <<-'EOF'
Usage:
- email [-s SUBJECT] [-f FROM] ADDRESS... < BODY
+ email [-s SUBJECT] [-f FROM] [ADDRESS...] < BODY
email -h
EOF
}
@@ -17,7 +17,7 @@ help() {
-f FROM the addr to send from (default: "eu@euandre.org")
-h, --help show this message
- ADDRESS the email addresses to send the email to
+ ADDRESS the email addresses to send the email to (default: "eu@euandre.org")
BODY the text to be sent as the body
@@ -29,6 +29,11 @@ help() {
Send 10 numbers to mail@example.com:
$ seq 10 | email -s number mail@email.com
+
+
+ Send a UUID using all defaults:
+
+ $ uuid | email
EOF
}
@@ -70,17 +75,15 @@ while getopts 'f:s:h' flag; do
done
shift $((OPTIND - 1))
-ADDRESS="${1:-}"
+ADDRESS="$(printf '%s\n' "$@" | tr '\n' ',' | sed 's|,|, |g;s|, $||')"
-eval "$(assert-arg -- "${SUBJECT:-}" '-s SUBJECT')"
-eval "$(assert-arg -- "$ADDRESS" 'ADDRESS')"
{
cat <<-EOF
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
From: $FROM
- To: $ADDRESS
+ To: ${ADDRESS:-eu@euandre.org}
Subject: $(printf '%s' "$SUBJECT" | tr -d '\n')
EOF