Commit 4803595d authored by Michael Albinus's avatar Michael Albinus
Browse files

Bug#16045

* progmodes/compile.el (compilation-start):
* progmodes/grep.el (rgrep): Revert change of 2012-12-20T11:15:38Z!michael.albinus@gmx.de.

* net/tramp-sh.el (tramp-sh-handle-start-file-process):
Handle long command lines, lasting from "sh -c ...".  (Bug#16045)
parent a59d76e0
2013-12-06 Michael Albinus <michael.albinus@gmx.de>
* progmodes/compile.el (compilation-start):
* progmodes/grep.el (rgrep): Revert change 2012-12-20T11:15:38Z!michael.albinus@gmx.de.
* 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 <dgutov@yandex.ru> 2013-12-06 Dmitry Gutov <dgutov@yandex.ru>
* progmodes/ruby-mode.el (ruby-syntax-propertize-function): Touch * progmodes/ruby-mode.el (ruby-syntax-propertize-function): Touch
......
...@@ -2686,27 +2686,46 @@ the result will be a local, non-Tramp, filename." ...@@ -2686,27 +2686,46 @@ the result will be a local, non-Tramp, filename."
(defun tramp-sh-handle-start-file-process (name buffer program &rest args) (defun tramp-sh-handle-start-file-process (name buffer program &rest args)
"Like `start-file-process' for Tramp files." "Like `start-file-process' for Tramp files."
(with-parsed-tramp-file-name default-directory nil (with-parsed-tramp-file-name default-directory nil
;; When PROGRAM is nil, we just provide a tty. (let* (;; When PROGRAM matches "*sh", and the first arg is "-c",
(let ((command ;; it might be that the arguments exceed the command line
(when (stringp program) ;; length. Therefore, we modify the command.
(format "cd %s; exec env PS1=%s %s" (heredoc (and (stringp program)
(tramp-shell-quote-argument localname) (string-match "sh$" program)
;; Use a human-friendly prompt, for example for `shell'. (string-equal "-c" (car args))
(tramp-shell-quote-argument (= (length args) 2)))
(format "%s %s" ;; When PROGRAM is nil, we just provide a tty.
(file-remote-p default-directory) (args (if (not heredoc) args
tramp-initial-end-of-output)) (let ((i 250))
(mapconcat 'tramp-shell-quote-argument (while (and (< i (length (cadr args)))
(cons program args) " ")))) (string-match " " (cadr args) i))
(tramp-process-connection-type (setcdr
(or (null program) tramp-process-connection-type)) args
(bmp (and (buffer-live-p buffer) (buffer-modified-p buffer))) (list (replace-match " \\\\\n" nil nil (cadr args))))
(name1 name) (setq i (+ i 250))))
(i 0) (cdr args)))
;; We do not want to raise an error when (command
;; `start-file-process' has been started several time in (when (stringp program)
;; `eshell' and friends. (format "cd %s; exec %s env PS1=%s %s"
(tramp-current-connection nil)) (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 (unless buffer
;; BUFFER can be nil. We use a temporary buffer. ;; BUFFER can be nil. We use a temporary buffer.
......
...@@ -1623,11 +1623,7 @@ Returns the compilation buffer created." ...@@ -1623,11 +1623,7 @@ Returns the compilation buffer created."
(format "%s started at %s\n\n" (format "%s started at %s\n\n"
mode-name mode-name
(substring (current-time-string) 0 19)) (substring (current-time-string) 0 19))
;; The command could be split into several lines, see command "\n")
;; `rgrep' for example. We want to display it as one
;; line.
(apply 'concat (split-string command (regexp-quote "\\\n") t))
"\n")
(setq thisdir default-directory)) (setq thisdir default-directory))
(set-buffer-modified-p nil)) (set-buffer-modified-p nil))
;; Pop up the compilation buffer. ;; Pop up the compilation buffer.
......
...@@ -995,8 +995,6 @@ to specify a command to run." ...@@ -995,8 +995,6 @@ to specify a command to run."
(compilation-start regexp 'grep-mode)) (compilation-start regexp 'grep-mode))
(setq dir (file-name-as-directory (expand-file-name dir))) (setq dir (file-name-as-directory (expand-file-name dir)))
(require 'find-dired) ; for `find-name-arg' (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 (let ((command (grep-expand-template
grep-find-template grep-find-template
regexp regexp
...@@ -1005,7 +1003,7 @@ to specify a command to run." ...@@ -1005,7 +1003,7 @@ to specify a command to run."
(mapconcat (mapconcat
#'shell-quote-argument #'shell-quote-argument
(split-string files) (split-string files)
(concat "\\\n" " -o " find-name-arg " ")) (concat " -o " find-name-arg " "))
" " " "
(shell-quote-argument ")")) (shell-quote-argument ")"))
dir dir
...@@ -1026,7 +1024,7 @@ to specify a command to run." ...@@ -1026,7 +1024,7 @@ to specify a command to run."
(concat "*/" (concat "*/"
(cdr ignore))))))) (cdr ignore)))))))
grep-find-ignored-directories grep-find-ignored-directories
"\\\n -o -path ") " -o -path ")
" " " "
(shell-quote-argument ")") (shell-quote-argument ")")
" -prune -o ")) " -prune -o "))
...@@ -1044,7 +1042,7 @@ to specify a command to run." ...@@ -1044,7 +1042,7 @@ to specify a command to run."
(shell-quote-argument (shell-quote-argument
(cdr ignore)))))) (cdr ignore))))))
grep-find-ignored-files grep-find-ignored-files
"\\\n -o -name ") " -o -name ")
" " " "
(shell-quote-argument ")") (shell-quote-argument ")")
" -prune -o ")))))) " -prune -o "))))))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment