From e69a7ad311e94c29a1e4b7e593a8630b09573ea2 Mon Sep 17 00:00:00 2001
From: alps2006 <guoxiangxun@gmail.com>
Date: Wed, 27 May 2020 10:02:20 +0800
Subject: Fix head: illegal line count -- -1 (#443)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* Fix head: illegal line count -- -1

* Fix `osascript: display notification with title "📧 xxxx" subtitle "xxxx" : No such file or directory`
---
 bin/mailsync | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'bin/mailsync')

diff --git a/bin/mailsync b/bin/mailsync
index 3104c65..6aeb946 100755
--- a/bin/mailsync
+++ b/bin/mailsync
@@ -21,7 +21,7 @@ export DISPLAY=:0.0
 # Settings are different for MacOS (Darwin) systems.
 if [ "$(uname)" = "Darwin" ]; then
     notify() { osascript -e "display notification \"$2 in $1\" with title \"You've got Mail\" subtitle \"Account: $account\"" && sleep 2 ;}
-    messageinfo() { osascript "display notification with title \"📧 $from\" subtitle \"$subject\"" ;}
+    messageinfo() { osascript -e "display notification with title \"📧 $from\" subtitle \"$subject\"" ;}
 else
     notify() { notify-send --app-name="mutt-wizard" "mutt-wizard" "📬 $2 new mail(s) in \`$1\` account." ;}
     messageinfo() { notify-send --app-name="mutt-wizard" "📧$from:" "$subject" ;}
@@ -38,7 +38,7 @@ syncandnotify() {
         for file in $new; do
             # Extract subject and sender from mail.
             from=$(awk '/^From: / && ++n ==1,/^\<.*\>:/' "$file" | perl -CS -MEncode -ne 'print decode("MIME-Header", $_)' | awk '{ $1=""; if (NF>=3)$NF=""; print $0 }' | sed 's/^[[:blank:]]*[\"'\''\<]*//;s/[\"'\''\>]*[[:blank:]]*$//')
-            subject=$(awk '/^Subject: / && ++n == 1,/^\<.*\>: / && ++i == 2' "$file" | head -n-1 | perl -CS -MEncode -ne 'print decode("MIME-Header", $_)' | sed 's/^Subject: //' | sed 's/^{[[:blank:]]*[\"'\''\<]*//;s/[\"'\''\>]*[[:blank:]]*$//' | tr -d '\n')
+            subject=$(awk '/^Subject: / && ++n == 1,/^\<.*\>: / && ++i == 2' "$file" | head -n 1 | perl -CS -MEncode -ne 'print decode("MIME-Header", $_)' | sed 's/^Subject: //' | sed 's/^{[[:blank:]]*[\"'\''\<]*//;s/[\"'\''\>]*[[:blank:]]*$//' | tr -d '\n')
 	    messageinfo &
         done
     fi
-- 
cgit v1.2.3


From bb72cf5a71418a3d8eaa3cc731a2b8a8627e9c1c Mon Sep 17 00:00:00 2001
From: JameyBear <WhispersofJ@gmail.com>
Date: Sun, 31 May 2020 12:10:35 -0400
Subject: Cleanup (#450)

* Simple Fixes

* Tweak wording

* Update openfile

* ShellChecked

* Little Fixes
---
 bin/mailsync | 4 ++--
 bin/mw       | 8 ++++----
 bin/openfile | 2 +-
 mw.1         | 2 +-
 4 files changed, 8 insertions(+), 8 deletions(-)

(limited to 'bin/mailsync')

diff --git a/bin/mailsync b/bin/mailsync
index 6aeb946..6128f41 100755
--- a/bin/mailsync
+++ b/bin/mailsync
@@ -12,7 +12,7 @@ ping -q -c 1 1.1.1.1 > /dev/null || { echo "No internet connection detected."; e
 command -v notify-send >/dev/null || echo "Note that \`libnotify\` or \`libnotify-send\` should be installed for pop-up mail notifications with this script."
 
 # Required to display notifications if run as a cronjob:
-DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus
+export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus
 export DISPLAY=:0.0
 
 # For individual configurations:
@@ -30,7 +30,7 @@ fi
 # Check account for new mail. Notify if there is new content.
 syncandnotify() {
     acc="$(echo "$account" | sed "s/.*\///")"
-    mbsync $opts "$acc"
+    mbsync "$opts" "$acc"
     new=$(find "$HOME/.local/share/mail/$acc/INBOX/new/" "$HOME/.local/share/mail/$acc/Inbox/new/" "$HOME/.local/share/mail/$acc/inbox/new/" -type f -newer "$HOME/.config/mutt/.mailsynclastrun" 2> /dev/null)
     newcount=$(echo "$new" | sed '/^\s*$/d' | wc -l)
     if [ "$newcount" -gt "0" ]; then
diff --git a/bin/mw b/bin/mw
index e62be2a..0862f30 100755
--- a/bin/mw
+++ b/bin/mw
@@ -3,7 +3,7 @@
 command -V gpg >/dev/null 2>&1 && GPG="gpg" || GPG="gpg2"
 [ -z ${PASSWORD_STORE_DIR+x} ] && PASSWORD_STORE_DIR="$HOME/.password-store"
 [ -r "$PASSWORD_STORE_DIR/.gpg-id" ] &&
-    "$GPG" --list-secret-keys $(cat "$PASSWORD_STORE_DIR/.gpg-id") >/dev/null 2>&1 || {
+    "$GPG" --list-secret-keys "$(cat "$PASSWORD_STORE_DIR/.gpg-id")" >/dev/null 2>&1 || {
         printf "\`pass\` must be installed and initialized to encrypt passwords.\\nBe sure it is installed and run \`pass init <yourgpgemail>\`.\\nIf you don't have a GPG public private key pair, run \`%s --full-gen-key\` first.\\n" "$GPG"
         exit
     }
@@ -134,7 +134,7 @@ fi
 askinfo() { \
 	printf "Insert the \033[31memail address\033[0m that you want to autoconfigure for mutt/mbsync\\n\tEmail: \033[36m"
 	read -r fulladdr
-	keyid=$( gpg --list-keys --with-colons $fulladdr | awk -F: '/^pub:/ { print $5 }')
+	keyid=$( gpg --list-keys --with-colons "$fulladdr" | awk -F: '/^pub:/ { print $5 }')
 	printf "\033[0m"
 	while ! echo "$fulladdr" | grep "$emailre" >/dev/null; do
 		printf "That is not a valid \033[31memail address\033[0m, please retype the desired email.\\n\\nEmail: \033[36m\t"
@@ -145,7 +145,7 @@ askinfo() { \
   search_query=$domain
   case "$domain" in
     protonmail.com|protonmail.ch|pm.me)
-      search_query='protonmail.com' && break;;
+      search_query='protonmail.com' && return 1;;
     *)
       while : ; do
         printf "\nIs your email hosted with Protonmail? [yes/no] "
@@ -339,7 +339,7 @@ synchronize_flags=true
 gpg_path=$GPG"
 	echo "$nmbasic" > "$NOTMUCH_CONFIG" ;}
 
-trap 'echo -e "\033[0m\n"; exit' STOP INT ABRT KILL
+trap 'echo -e "\033[0m\n"; exit' INT ABRT
 
 case "$1" in
 	ls) list ;;
diff --git a/bin/openfile b/bin/openfile
index c0e2e9c..f6668dc 100755
--- a/bin/openfile
+++ b/bin/openfile
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 # Helps open a file with xdg-open from mutt in a external program without weird side effects.
-[ $(uname) = "Darwin" ] && opener="open" || opener="setsid xdg-open"
+[ "$(uname)" = "Darwin" ] && opener="open" || opener="setsid xdg-open"
 mkdir -p "/tmp/$USER-mutt-tmp"
 file="/tmp/$USER-mutt-tmp/$(basename "$1")"
 rm -f "$file"
diff --git a/mw.1 b/mw.1
index c866c83..217ae2b 100644
--- a/mw.1
+++ b/mw.1
@@ -6,7 +6,7 @@ mw \- mutt-wizard \- autoconfigure email accounts for neomutt and isync
 <command>
 .SH DESCRIPTION
 .B mw
-takes a user email account and sets up a terminal-based email interface with it for
+takes a user email account and sets up a terminal-based email interface for it with
 .B neomutt.
 This can include offline email with
 .B isync/mbsync
-- 
cgit v1.2.3