diff options
author | EuAndreh <eu@euandre.org> | 2023-03-12 10:22:33 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2023-03-12 10:22:33 -0300 |
commit | 0862609ee92c855b7e516c03dada6945d32c9583 (patch) | |
tree | a6c6b25af6a5e938407d98b63e8a542e0621c0de /bin/email | |
parent | bin/reconfigure: Add -U option to call update(1) (diff) | |
download | dotfiles-0862609ee92c855b7e516c03dada6945d32c9583.tar.gz dotfiles-0862609ee92c855b7e516c03dada6945d32c9583.tar.xz |
bin/email: Make ADDRESS optional
Diffstat (limited to 'bin/email')
-rwxr-xr-x | bin/email | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -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 |