From 0862609ee92c855b7e516c03dada6945d32c9583 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Sun, 12 Mar 2023 10:22:33 -0300 Subject: bin/email: Make ADDRESS optional --- bin/email | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'bin/email') 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 -- cgit v1.2.3