Subject: bug#7711: Patch for bug #7687

From: Stefan Monnier <[email-masked]>
Date: Fri, 21 Jan 2011 13:07:30 -0500

forcemerge 7687 7711
close 7711
thanks

> the empty string. The new version of shell-quote-argument
> treats newlines specially. They are quoted with single
> quotes.

Thanks.  I've installed a slightly different patch (took the opportunity
to simplify the code by using replace-regexp-in-string) that implements
your idea.

        Stefan

=== modified file 'lisp/ChangeLog'
--- lisp/ChangeLog	2011-01-21 05:04:45 +0000
+++ lisp/ChangeLog	2011-01-21 18:04:16 +0000
@@ -1,3 +1,8 @@
+2011-01-21  Stefan Monnier  <[email-masked]>
+
+	* subr.el (shell-quote-argument): Properly quote \n (bug#7687).
+	Suggested by Flo <[email-masked]>.
+
 2011-01-21  Glenn Morris  <[email-masked]>
 
 	* progmodes/compile.el (compilation-error-regexp-alist):

=== modified file 'lisp/subr.el'
--- lisp/subr.el	2011-01-15 02:32:19 +0000
+++ lisp/subr.el	2011-01-21 18:04:45 +0000
@@ -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.