diff options
| author | Richard M. Stallman | 1993-12-31 09:25:12 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1993-12-31 09:25:12 +0000 |
| commit | 8af7df607d2e0cdf57791cfe107626918b028ed4 (patch) | |
| tree | e095c1f5002147589ea1baf3ed9e1328da2baffe | |
| parent | 06811c2dd3bab6d97bef9e24c3f836c9178eebfa (diff) | |
| download | emacs-8af7df607d2e0cdf57791cfe107626918b028ed4.tar.gz emacs-8af7df607d2e0cdf57791cfe107626918b028ed4.zip | |
(shell-quote-argument): New function.
| -rw-r--r-- | lisp/subr.el | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lisp/subr.el b/lisp/subr.el index 9d6e4ac3228..fce4a56e79b 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -643,6 +643,18 @@ Wildcards and redirection are handle as usual in the shell." | |||
| 643 | (cons 'progn body) | 643 | (cons 'progn body) |
| 644 | (list 'store-match-data original))))) | 644 | (list 'store-match-data original))))) |
| 645 | 645 | ||
| 646 | (defun shell-quote-argument (argument) | ||
| 647 | "Quote an argument for passing as argument to an inferior shell." | ||
| 648 | ;; Quote everything except POSIX filename characters. | ||
| 649 | ;; This should be safe enough even for really weird shells. | ||
| 650 | (let ((result "") (start 0) end) | ||
| 651 | (while (string-match "[^---0-9a-zA-Z_./]" argument start) | ||
| 652 | (setq end (match-beginning 0) | ||
| 653 | result (concat result (substring argument start end) | ||
| 654 | "\\" (substring argument end (1+ end))) | ||
| 655 | start (1+ end))) | ||
| 656 | (concat result (substring argument start)))) | ||
| 657 | |||
| 646 | ;; now in fns.c | 658 | ;; now in fns.c |
| 647 | ;(defun nth (n list) | 659 | ;(defun nth (n list) |
| 648 | ; "Returns the Nth element of LIST. | 660 | ; "Returns the Nth element of LIST. |