sed portable?

This commit is contained in:
Luke Smith 2019-04-26 11:36:14 -04:00
parent b53babb00c
commit e81e2c450d
No known key found for this signature in database
GPG Key ID: 4C50B54A911F6252

14
bin/mw
View File

@ -182,7 +182,7 @@ formatShortcut() { \
tryconnect() { mkdir -p "$maildir/$title"
if mailboxes="$(mbsync -l "$title" | sed 's/\//./')" >/dev/null 2>&1 && [ -n "$mailboxes" ]; then
[ "$accounttype" = "online" ] && sed -i "/IMAPStore $title-remote$/,/# End profile/d" "$mbsyncrc"
[ "$accounttype" = "online" ] && sed -ibu "/IMAPStore $title-remote$/,/# End profile/d" "$mbsyncrc" ; rm -f "$mbsync"bu
printf "\033[32mMailboxes detected.\033[0m\\n"
echo "$mailboxes" | xargs -I {} mkdir -p "$maildir/$title/{}"
return 0
@ -199,11 +199,11 @@ finalize() { \
record=$(echo "$boxes" | grep -i -m 1 sent | sed 's/=/+/g')
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" "$accdir/$idnum-$title.muttrc"
sed -ibu "/^mailboxes\|^set record\|^set postponed\|^set trash\|^set spoolfile/d" "$accdir/$idnum-$title.muttrc" ; rm -f "$accdir/$idnum-$title.muttrcbu"
{ echo "set spoolfile = \"$spoolfile\""; echo "set record = \"$record\""; echo "set postponed = \"$postponed\""; echo "set trash = \"$trash\""; } >> "$accdir/$idnum-$title.muttrc"
echo "mailboxes =$title ===================== $(echo "$boxes" | sed -e "s/^\|$/\"/g" | tr "\n" " ")" >> "$accdir/$idnum-$title.muttrc"
printf "Setting up your keyboard shortcuts for jumping between mailboxes...\\n"
sed -i "/# mw-autogenerated/d" "$accdir/$idnum-$title.muttrc"
sed -ibu "/# mw-autogenerated/d" "$accdir/$idnum-$title.muttrc" ; rm -f "$accdir/$idnum-$title.muttrcbu"
echo "$boxes" | grep -i inbox | head -n 1 | formatShortcut i inbox
echo "$boxes" | grep -i sent | head -n 1 | formatShortcut s sent
echo "$boxes" | grep -i draft | head -n 1 | formatShortcut d drafts
@ -227,10 +227,10 @@ pick() { printf "Select an accounts to %s:\\n" "$1"
[ -z "$title" ] && printf "Invalid response." && return 1
return 0 ;}
delete() { sed -i "/IMAPStore $title-remote$/,/# End profile/d" "$mbsyncrc"
delete() { sed -ibu "/IMAPStore $title-remote$/,/# End profile/d" "$mbsyncrc" ; rm -rf "$mbsyncrc"bu
rm -rf "${cachedir:?}/${title:?}" "$accdir/"[1-9]"-$title.muttrc"
sed -i "/[0-9]-$title.muttrc/d" "$muttrc"
sed -i "/account $title/,/^\(\s*$\|account\)/d" "$HOME/.config/msmtp/config"
sed -ibu "/[0-9]-$title.muttrc/d" "$muttrc" ; rm -f "$muttrc"bu
sed -ibu "/account $title/,/^\(\s*$\|account\)/d" "$HOME/.config/msmtp/config"; rm -f "$HOME/.config/msmtp/configbu"
}
choosecron() { ! pgrep -x cron\|crond >/dev/null && echo "No cron manager running. Install/enable one and then select this option again." && return 1
@ -266,7 +266,7 @@ asktype() { while : ; do
purge() { confirm "delete all account data" || exit
rm -rf "$mbsyncrc" "$accdir" "$HOME/.config/msmtp" "$cachedir"
echo "All configs and account settings have been purged."
sed -i "/\# mw-autogenerated/d" "$muttrc"
sed -ibu "/\# mw-autogenerated/d" "$muttrc" ; rm -f "$muttrc"bu
}
notmuchauto() { \