emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r115401: Bug#16045


From: Michael Albinus
Subject: [Emacs-diffs] trunk r115401: Bug#16045
Date: Fri, 06 Dec 2013 15:34:12 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 115401
revision-id: address@hidden
parent: address@hidden
committer: Michael Albinus <address@hidden>
branch nick: trunk
timestamp: Fri 2013-12-06 16:34:06 +0100
message:
  Bug#16045
  
  * progmodes/compile.el (compilation-start):
  * progmodes/grep.el (rgrep): Revert change of 2012-12-20 (r111276).
  
  * net/tramp-sh.el (tramp-sh-handle-start-file-process):
  Handle long command lines, lasting from "sh -c ...".  (Bug#16045)
modified:
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/net/tramp-sh.el           trampsh.el-20100913133439-a1faifh29eqoi4nh-1
  lisp/progmodes/compile.el      compile.el-20091113204419-o5vbwnq5f7feedwu-126
  lisp/progmodes/grep.el         grep.el-20091113204419-o5vbwnq5f7feedwu-2948
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-12-06 14:24:10 +0000
+++ b/lisp/ChangeLog    2013-12-06 15:34:06 +0000
@@ -1,3 +1,11 @@
+2013-12-06  Michael Albinus  <address@hidden>
+
+       * progmodes/compile.el (compilation-start):
+       * progmodes/grep.el (rgrep): Revert change of 2012-12-20 (r111276).
+
+       * net/tramp-sh.el (tramp-sh-handle-start-file-process):
+       Handle long command lines, lasting from "sh -c ...".  (Bug#16045)
+
 2013-12-06  Dmitry Gutov  <address@hidden>
 
        * progmodes/ruby-mode.el (ruby-syntax-propertize-function): Touch

=== modified file 'lisp/net/tramp-sh.el'
--- a/lisp/net/tramp-sh.el      2013-12-02 13:52:23 +0000
+++ b/lisp/net/tramp-sh.el      2013-12-06 15:34:06 +0000
@@ -2686,27 +2686,46 @@
 (defun tramp-sh-handle-start-file-process (name buffer program &rest args)
   "Like `start-file-process' for Tramp files."
   (with-parsed-tramp-file-name default-directory nil
-    ;; When PROGRAM is nil, we just provide a tty.
-    (let ((command
-          (when (stringp program)
-            (format "cd %s; exec env PS1=%s %s"
-                    (tramp-shell-quote-argument localname)
-                    ;; Use a human-friendly prompt, for example for `shell'.
-                    (tramp-shell-quote-argument
-                     (format "%s %s"
-                             (file-remote-p default-directory)
-                             tramp-initial-end-of-output))
-                    (mapconcat 'tramp-shell-quote-argument
-                               (cons program args) " "))))
-         (tramp-process-connection-type
-          (or (null program) tramp-process-connection-type))
-         (bmp (and (buffer-live-p buffer) (buffer-modified-p buffer)))
-         (name1 name)
-         (i 0)
-         ;; We do not want to raise an error when
-         ;; `start-file-process' has been started several time in
-         ;; `eshell' and friends.
-         (tramp-current-connection nil))
+    (let* (;; When PROGRAM matches "*sh", and the first arg is "-c",
+          ;; it might be that the arguments exceed the command line
+          ;; length.  Therefore, we modify the command.
+          (heredoc (and (stringp program)
+                        (string-match "sh$" program)
+                        (string-equal "-c" (car args))
+                        (= (length args) 2)))
+          ;; When PROGRAM is nil, we just provide a tty.
+          (args (if (not heredoc) args
+                  (let ((i 250))
+                    (while (and (< i (length (cadr args)))
+                                (string-match " " (cadr args) i))
+                      (setcdr
+                       args
+                       (list (replace-match " \\\\\n" nil nil (cadr args))))
+                      (setq i (+ i 250))))
+                  (cdr args)))
+          (command
+           (when (stringp program)
+             (format "cd %s; exec %s env PS1=%s %s"
+                     (tramp-shell-quote-argument localname)
+                     (if heredoc "<<EOF" "")
+                     ;; Use a human-friendly prompt, for example for `shell'.
+                     (tramp-shell-quote-argument
+                      (format "%s %s"
+                              (file-remote-p default-directory)
+                              tramp-initial-end-of-output))
+                     (if heredoc
+                         (format "%s\n%s\nEOF" program (car args))
+                       (mapconcat 'tramp-shell-quote-argument
+                                  (cons program args) " ")))))
+          (tramp-process-connection-type
+           (or (null program) tramp-process-connection-type))
+          (bmp (and (buffer-live-p buffer) (buffer-modified-p buffer)))
+          (name1 name)
+          (i 0)
+          ;; We do not want to raise an error when
+          ;; `start-file-process' has been started several time in
+          ;; `eshell' and friends.
+          (tramp-current-connection nil))
 
       (unless buffer
        ;; BUFFER can be nil.  We use a temporary buffer.

=== modified file 'lisp/progmodes/compile.el'
--- a/lisp/progmodes/compile.el 2013-12-03 01:19:24 +0000
+++ b/lisp/progmodes/compile.el 2013-12-06 15:34:06 +0000
@@ -1623,11 +1623,7 @@
                (format "%s started at %s\n\n"
                        mode-name
                        (substring (current-time-string) 0 19))
-               ;; The command could be split into several lines, see
-               ;; `rgrep' for example.  We want to display it as one
-               ;; line.
-               (apply 'concat (split-string command (regexp-quote "\\\n") t))
-               "\n")
+               command "\n")
        (setq thisdir default-directory))
       (set-buffer-modified-p nil))
     ;; Pop up the compilation buffer.

=== modified file 'lisp/progmodes/grep.el'
--- a/lisp/progmodes/grep.el    2013-12-06 15:18:23 +0000
+++ b/lisp/progmodes/grep.el    2013-12-06 15:34:06 +0000
@@ -995,8 +995,6 @@
            (compilation-start regexp 'grep-mode))
       (setq dir (file-name-as-directory (expand-file-name dir)))
       (require 'find-dired)            ; for `find-name-arg'
-      ;; In Tramp, there could be problems if the command line is too
-      ;; long.  We escape it, therefore.
       (let ((command (grep-expand-template
                      grep-find-template
                      regexp
@@ -1005,7 +1003,7 @@
                              (mapconcat
                               #'shell-quote-argument
                               (split-string files)
-                              (concat "\\\n" " -o " find-name-arg " "))
+                              (concat " -o " find-name-arg " "))
                              " "
                              (shell-quote-argument ")"))
                      dir
@@ -1026,7 +1024,7 @@
                                                      (concat "*/"
                                                              (cdr ignore)))))))
                                     grep-find-ignored-directories
-                                    "\\\n -o -path ")
+                                    " -o -path ")
                                    " "
                                    (shell-quote-argument ")")
                                    " -prune -o "))
@@ -1044,7 +1042,7 @@
                                                     (shell-quote-argument
                                                      (cdr ignore))))))
                                     grep-find-ignored-files
-                                    "\\\n -o -name ")
+                                    " -o -name ")
                                    " "
                                    (shell-quote-argument ")")
                                    " -prune -o "))))))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]