X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=send_email;h=b2b1b54cb92927973c1d01bc67fbb1cd2f9a7ea4;hb=HEAD;hp=37e5c349d39eb475f24f84be031ad46f5e3584fa;hpb=3b12961b47780d32c77479e662fd342eff8f750a;p=next-scripts diff --git a/send_email b/send_email index 37e5c34..b2b1b54 100755 --- a/send_email +++ b/send_email @@ -1,26 +1,33 @@ #!/bin/bash -TARGET="$(dirname $0)/../mails"/$(date +"%Y-%m-%d+%s").email +mail_dir=$(realpath --relative-to=. "$(dirname "$0")/../mails") +printf -v TARGET '%s/%(%Y-%m-%d+%s)T.email' "$mail_dir" -1 +subject="$1" +shift to="$1" -cc="$2" -subject="$3" - -( - cat <*} + if grep -q -F "<$e>" <<<"$to"; then + unset "cc[$i]" + fi +done + +{ + printf 'To: %s\n' "$to" + if [ "${#cc[@]}" -gt 0 ]; then + printf 'Cc: %s\n' "${cc[@]}" + fi + printf 'Subject: %s\n\n' "$subject" cat -) > $TARGET +} > "$TARGET" -gvim $TARGET +gvim "$TARGET" -echo "When you're finished editing you need to send $TARGET" +printf 'When you are finished editing you need to send %s\n' "$TARGET" exit 0