changeset 112418:106bf56d370e

* lisp/subr.el (shell-quote-argument): Properly quote \n. Suggested by Flo <sensorflo@gmail.com>.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Fri, 21 Jan 2011 13:07:41 -0500
parents a2432c16dc9f
children a651b7492a78
files lisp/ChangeLog lisp/subr.el
diffstat 2 files changed, 7 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Thu Jan 20 21:04:45 2011 -0800
+++ b/lisp/ChangeLog	Fri Jan 21 13:07:41 2011 -0500
@@ -1,3 +1,8 @@
+2011-01-21  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* subr.el (shell-quote-argument): Properly quote \n (bug#7687).
+	Suggested by Flo <sensorflo@gmail.com>.
+
 2011-01-21  Glenn Morris  <rgm@gnu.org>
 
 	* progmodes/compile.el (compilation-error-regexp-alist):
--- a/lisp/subr.el	Thu Jan 20 21:04:45 2011 -0800
+++ b/lisp/subr.el	Fri Jan 21 13:07:41 2011 -0500
@@ -2426,13 +2426,8 @@
         "''"
       ;; 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))))))
+      (replace-regexp-in-string "\n" "'\n'"
+       (replace-regexp-in-string "[^-0-9a-zA-Z_./\n]" "\\\\\\&" argument)))))
 
 (defun string-or-null-p (object)
   "Return t if OBJECT is a string or nil.