diff options
Diffstat (limited to 'lisp')
| -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. |