From 14c2572c7386b11f5328aeb868c751a59525c2d4 Mon Sep 17 00:00:00 2001 From: Roland Puntaier Date: Thu, 29 Aug 2019 12:16:15 +0200 Subject: [PATCH] fix mutt cache folder cannot have @ --- bin/mw | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/bin/mw b/bin/mw index 62c70ae..258febb 100755 --- a/bin/mw +++ b/bin/mw @@ -127,8 +127,8 @@ set from = \"$mwaddr\" set sendmail = \"$msmtpbin -a $mwaccount\" alias me $mwname <$mwaddr> set folder = \"imaps://$mwaddr@$mwimap:$mwiport\" -set header_cache = $mwcachedir/$mwaccount -set message_cachedir = $mwcachedir/$mwaccount +set header_cache = $mwcachedir/$mwaccount_ +set message_cachedir = $mwcachedir/$mwaccount_ set imap_user = \"$mwlogin\" set imap_pass = \"\`pass $mwpass\`\" account-hook \$folder 'set imap_user=\"$mwlogin\" imap_pass=\"\`pass $mwpass\`\"' @@ -184,6 +184,7 @@ EOF read -r mwname fi mwaccount=$mwaddr + mwaccount_="${mwaccount//[.@]/_}" if [ -z $mwlogin ]; then printf "Type your account username if different from your email address.\\n\033[34mFor most accounts you can probably leave this blank.\033[0m\\n\tLogin(?): \033[36m" read -r mwlogin @@ -195,7 +196,7 @@ EOF getpass fi getprofiles - mkdir -p "$mwmuttdir" "$mwaccdir" "$mwcachedir/$mwaccount" "$mwconfigdir/msmtp" + mkdir -p "$mwmuttdir" "$mwaccdir" "$mwcachedir/$mwaccount_" "$mwconfigdir/msmtp" [ ! -f "$mwmsmtprc" ] && echo "$msmtp_header" > "$mwmsmtprc" echo "$msmtp_profile" >> "$mwmsmtprc" case "$mwservice" in @@ -259,8 +260,12 @@ finalize() { postponed=$(echo "$boxes" | grep -i -m 1 draft | sed 's/=/+/g') trash=$(echo "$boxes" | grep -i -m 1 trash | sed 's/=/+/g') sed -i "/^mailboxes\|^set record\|^set postponed\|^set trash\|^set spoolfile/d" "$mwaccrc" - { echo "set spoolfile = \"$spoolfile\""; echo "set record = \"$record\""; echo "set postponed = \"$postponed\""; echo "set trash = \"$trash\""; } >> "$mwaccrc" - mwaccount_="${mwaccount//[.@]/_}" + cat >> "$mwaccrc" <> "$mwaccrc" printf "Setting up your keyboard shortcuts for jumping between mailboxes...\\n" sed -i "/# mw-autogenerated/d" "$mwaccrc" @@ -272,6 +277,7 @@ finalize() { echo "$boxes" | grep -i junk | head -n 1 | formatShortcut j junk echo "$boxes" | grep -i archive | head -n 1 | formatShortcut a archive idnum=${mwaccrc%%-*} + idnum=${idnum##*/} muttsync="source $mwaccrc\!;" echo "macro index,pager i$idnum '$muttsync' \"switch to $mwaddr\" # mw-autogenerated" >> "$mwaccrc" if [ "$mwtype" = "offline" ]; then @@ -294,13 +300,14 @@ mwpick() { [ -z "$input" ] && return 1 mwaddr="$(echo "$accounts" | grep "$input": | awk '{print $2}')" mwaccount=$mwaddr + mwaccount_="${mwaccount//[.@]/_}" [ -z "$mwaccount" ] && printf "Invalid response." && return 1 return 0 ; } mwdelete() { sed -i "/IMAPStore $mwaccount-remote$/,/# End profile/d" "$mwmbsyncrc" - rm -rf "$mwcachedir/$mwaccount" + rm -rf "$mwcachedir/$mwaccount_" rm -rf "$mwaccdir/"[1-9]"-$mwaccount.muttrc" sed -i "/[0-9]-$mwaccount.muttrc/d" "$mwmuttrc" sed -i "/account $mwaccount/,/^\(\s*$\|account\)/d" "$mwmsmtprc"