Function: erc--split-string-shell-cmd

erc--split-string-shell-cmd is a byte-compiled function defined in erc.el.gz.

Signature

(erc--split-string-shell-cmd STRING)

Documentation

Parse whitespace-separated arguments in STRING.

Source Code

;; Defined in /usr/src/emacs/lisp/erc/erc.el.gz
(defun erc--split-string-shell-cmd (string)
  "Parse whitespace-separated arguments in STRING."
  ;; From `shell--parse-pcomplete-arguments' and friends.  Quirk:
  ;; backslash-escaped characters appearing within spans of double
  ;; quotes are unescaped.
  (with-temp-buffer
    (insert string)
    (let ((end (point))
          args)
      (goto-char (point-min))
      (while (and (skip-chars-forward " \t") (< (point) end))
        (let (arg)
          (while (looking-at erc--shell-parse-regexp)
            (goto-char (match-end 0))
            (cond ((match-beginning 3) ; backslash escape
                   (push (if (= (match-beginning 3) (match-end 3))
                             "\\"
                           (match-string 3))
                         arg))
                  ((match-beginning 2) ; double quote
                   (push (replace-regexp-in-string (rx ?\\ (group nonl))
                                                   "\\1" (match-string 2))
                         arg))
                  ((match-beginning 1) ; single quote
                   (push (match-string 1) arg))
                  (t (push (match-string 0) arg))))
          (push (string-join (nreverse arg)) args)))
      (nreverse args))))