# HG changeset patch # User Richard M. Stallman # Date 757329912 0 # Node ID 53077bf7c7181a0c5470b66d073e7d0ee7e389dc # Parent ec02e2f72eae13971f288f2cd3dc2cab93deaaf8 (shell-quote-argument): New function. diff -r ec02e2f72eae -r 53077bf7c718 lisp/subr.el --- a/lisp/subr.el Fri Dec 31 06:59:31 1993 +0000 +++ b/lisp/subr.el Fri Dec 31 09:25:12 1993 +0000 @@ -643,6 +643,18 @@ (cons 'progn body) (list 'store-match-data original))))) +(defun shell-quote-argument (argument) + "Quote an argument for passing as argument to an inferior shell." + ;; Quote everything except POSIX filename characters. + ;; This should be safe enough even for really weird shells. + (let ((result "") (start 0) end) + (while (string-match "[^---0-9a-zA-Z_./]" argument start) + (setq end (match-beginning 0) + result (concat result (substring argument start end) + "\\" (substring argument end (1+ end))) + start (1+ end))) + (concat result (substring argument start)))) + ;; now in fns.c ;(defun nth (n list) ; "Returns the Nth element of LIST.