X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=notmuch-emacs-mua;h=79714305b3e2a0a6104b84215710004efc157fe0;hp=13f67bee4417f78569916e147e4610ffa39899c4;hb=dc840338b21cb041cb781d34b6b7f20f7e8fecb0;hpb=5240c438f5f6212fbce811ea4fd55ae964c97d99 diff --git a/notmuch-emacs-mua b/notmuch-emacs-mua index 13f67bee..79714305 100755 --- a/notmuch-emacs-mua +++ b/notmuch-emacs-mua @@ -22,9 +22,12 @@ set -eu +# escape: "expand" '\' as '\\' and '"' as '\"' +# calling convention: escape -v var "$arg" (like in bash printf). escape () { - echo "${1//\"/\\\"}" + local __escape_arg__=${3//\\/\\\\} + printf -v $2 '%s' "${__escape_arg__//\"/\\\"}" } EMACS=${EMACS-emacs} @@ -72,9 +75,7 @@ while getopts :s:c:b:i:h opt; do ;; esac - - OPTARG="${OPTARG-none}" - OPTARG="$(escape "${OPTARG}")" + escape -v OPTARG "${OPTARG-none}" case "${opt}" in --help|h) @@ -117,7 +118,7 @@ done # Positional parameters. for arg; do - arg="$(escape "${arg}")" + escape -v arg "${arg}" ELISP="${ELISP} (message-goto-to) (insert \"${arg}, \")" done