cat > "${TMPFILE}" || exit 1
# Now that we've read in the mailbox file, reopen stdin for mutt/user
-# interaction. We're not technically in a tty, so use a little hack
-# from "greno" at
+# interaction. When in a pipe we're not technically in a tty, so use
+# a little hack from "greno" at
# http://www.linuxforums.org/forum/linux-programming-scripting/98607-bash-stdin-problem.html
-tty="/dev/$(ps -p$$ --no-heading | awk '{print $2}')"
+tty="/dev/`ps -p$$ --no-heading | awk '{print $2}'`"
exec < ${tty}
if [ `wc -c "${TMPFILE}" | awk '{print $1}'` -gt 0 ]; then
- echo 1>&2 "Calling mutt on mailbox file (${TMPFILE})."
+ echo 1>&2 "Calling mutt on temporary mailbox file (${TMPFILE})."
mutt -R -f "${TMPFILE}" "$@"
else
echo 1>&2 "Empty mailbox input."
fi
-rm -f "${TMPFILE}" && echo 1>&2 "Deleted results file (${TMPFILE})."
+rm -f "${TMPFILE}" && echo 1>&2 "Deleted temporary mailbox file (${TMPFILE})."