Function: mh-quote-for-shell

mh-quote-for-shell is a byte-compiled function defined in mh-e.el.gz.

Signature

(mh-quote-for-shell STRING)

Documentation

Quote STRING for /bin/sh.

Adds double-quotes around entire string and quotes the characters
\, `, and $ with a backslash.

Source Code

;; Defined in /usr/src/emacs/lisp/mh-e/mh-e.el.gz
;; XXX This should be applied anywhere MH-E calls out to /bin/sh.
(defun mh-quote-for-shell (string)
  "Quote STRING for /bin/sh.
Adds double-quotes around entire string and quotes the characters
\\, `, and $ with a backslash."
  (concat "\""
          (cl-loop for x across string
                   concat (format (if (memq x '(?\\ ?` ?$)) "\\%c" "%c") x))
          "\""))