summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaromil <jaromil@dyne.org>2017-03-14 07:02:09 (GMT)
committer Jaromil <jaromil@dyne.org>2017-03-14 07:02:09 (GMT)
commit16a454b77e5b0e23899e7d499cebe2b598c02f31 (patch)
tree8f68f17c241cd0015bba124cf5330c4389855a88
parent5902ddf2e37fb1cf572f8d55c771a41444569610 (diff)
add checks to cli send oneliners
-rwxr-xr-xsrc/zlibs/email27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/zlibs/email b/src/zlibs/email
index 620f058..a373e6f 100755
--- a/src/zlibs/email
+++ b/src/zlibs/email
@@ -39,16 +39,23 @@ compose() {
fi
done
- # take as subject the first line of body
- ztmp
- cat > $ztmpfile
- local subject=`head -n1 $ztmpfile`
- local nbsp=$'\255'
- notice "Sending mail from commandline"
- act "recipients: ${_addrs}"
- [[ "$_files" = "" ]] || act "attachments: ${_files}"
- act "subject: $subject"
- cat <<EOF | x_mutt -s "${subject// /_}" -i $ztmpfile ${=_files} -- ${=_addrs}
+ # take as subject the first line of body
+ ztmp; body=$ztmpfile
+ if command -v rlwrap >/dev/null; then
+ rlwrap -c --multi-line -D2 -b '<>' -I -e '' cat > $body
+ else
+ cat > $body
+ fi
+ local subject=`head -n1 $body`
+
+ [[ "$subject" = "" ]] && {
+ error "Nothing read from input, not even the subject"
+ return 1 }
+ notice "Sending mail from commandline"
+ act "recipients: ${_addrs}"
+ [[ "$_files" = "" ]] || act "attachments: ${_files}"
+ act "subject: $subject"
+ cat <<EOF | x_mutt -s "${subject// /_}" -i $ztmpfile ${=_files} -- ${=_addrs}
EOF
# _mutt -H <(print "To: ${PARAM[@]}")
return $?