+}
+
+function reopen_tty () {
+ # Close message-stdin and open terminal-stdin instead.
+ # mutt behaves different if STDIN is no terminal
+ # TODO: Find cleaner solution (e.g. mutt command-line argument?)
+ exec 0<&-
+ term="/dev/$(ps -p$$ -otty=)"
+ exec < $term
+}
+
+
+# Check command-line arguments and STDIN
+search_header="Message-ID"
+if tty -s ; then
+ [ $# -ne 1 ] && usage
+else
+ [ $# -gt 1 ] && usage
+ if [ $# -eq 1 ] ; then
+ [ "$1" != "-R" ] && usage
+ search_header="In-Reply-To"
+ shift
+ fi