diff --git a/bin/autoreply/autoreply.sh b/bin/autoreply/autoreply.sh index 0f8644f..3dff41f 100755 --- a/bin/autoreply/autoreply.sh +++ b/bin/autoreply/autoreply.sh @@ -14,8 +14,7 @@ if [[ -z "$(notmuch search tag:misdirected)" ]] ; then exit 1 fi -# !!! Script just craps out here when invoked with no flag. Refactor to -# match https://www.man7.org/linux/man-pages/man1/getopts.1p.html#EXAMPLES +# Handle option(s) dry_run= while getopts n opt ; do printf "[debug] opt: %s\n\n" $opt @@ -64,8 +63,8 @@ while IFS= read -r -d '' thread ; do printf "[debug] Outgoing mail:\n%s\n" "$(cat $temporary_file)" if [[ -z "$dry_run" ]] ; then echo "[loop] Sending reply to $recipient ... " - cat "$temporary_file" | msmtp --read-envelope-from --read-recipients - cat "$temporary_file" | notmuch insert --folder=Sent -inbox -unread +sent +misdirected-reply + msmtp --read-envelope-from --read-recipients <"$temporary_file" + notmuch insert --folder=Sent -inbox -unread +sent +misdirected-reply <"$temporary_file" # Remove the misdirected tag notmuch tag -misdirected -- thread:"$thread_id"