From: martin f. krafft Date: Fri, 25 Apr 2014 07:19:10 +0000 (+0200) Subject: Escape sed delimiter when doing subject replacing X-Git-Url: https://git.madduck.net/etc/mutt.git/commitdiff_plain/4e16114bb66323111c8d5bfffa8911629a117c42?ds=sidebyside Escape sed delimiter when doing subject replacing --- diff --git a/.mutt/batch-subject-editor b/.mutt/batch-subject-editor index e5bb596..0649ac5 100755 --- a/.mutt/batch-subject-editor +++ b/.mutt/batch-subject-editor @@ -21,9 +21,12 @@ if [ -z "${subj:-}" ]; then exit 1 fi +SED_DELIM=, +subj=$(echo "$subj" | sed -re "s${SED_DELIM}\\\&g") + RE_REPLY='((re|aw|antwort)([[(]?[[:digit:]]+[)]]?)?):[[:space:]]*' RE_SUBJ_PREFIX="^Subject:[[:space:]]*(${RE_REPLY})*" RE_SUBJ='.*' -EDITOR="sed -i -re \"s,(${RE_SUBJ_PREFIX})${RE_SUBJ},\\\1$subj,i\"" +EDITOR="sed -i -re \"s${SED_DELIM}(${RE_SUBJ_PREFIX})${RE_SUBJ}${SED_DELIM}\\\1$subj${SED_DELIM}i\"" printf "set editor='${EDITOR} %s'"