changeset 106204:075fc4ee6c41

* net/tramp.el (tramp-shell-prompt-pattern): Use \r for carriage return. (tramp-handle-make-symbolic-link) (tramp-handle-dired-compress-file, tramp-handle-expand-file-name): Quote file names. (tramp-send-command-and-check): New argument DONT-SUPPRESS-ERR. (tramp-handle-process-file): Use it.
author Michael Albinus <michael.albinus@gmx.de>
date Mon, 23 Nov 2009 15:58:49 +0000
parents d51db5b86079
children f573e64710b2
files lisp/net/tramp.el
diffstat 1 files changed, 31 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/net/tramp.el	Mon Nov 23 14:48:59 2009 +0000
+++ b/lisp/net/tramp.el	Mon Nov 23 15:58:49 2009 +0000
@@ -1030,7 +1030,7 @@
 (defcustom tramp-shell-prompt-pattern
   ;; Allow a prompt to start right after a ^M since it indeed would be
   ;; displayed at the beginning of the line (and Zsh uses it).
-  "\\(?:^\\|
\\)[^#$%>\n]*[#$%>] *\\(\e\\[[0-9;]*[a-zA-Z] *\\)*"
+  "\\(?:^\\|\r\\)[^#$%>\n]*[#$%>] *\\(\e\\[[0-9;]*[a-zA-Z] *\\)*"
   "Regexp to match prompts from remote shell.
 Normally, Tramp expects you to configure `shell-prompt-pattern'
 correctly, but sometimes it happens that you are connecting to a
@@ -2429,7 +2429,14 @@
       ;; that FILENAME belongs to.
       (zerop
        (tramp-send-command-and-check
-	l (format "cd %s && %s -sf %s %s" cwd ln filename l-localname) t)))))
+	l
+	(format
+	 "cd %s && %s -sf %s %s"
+	 (tramp-shell-quote-argument cwd)
+	 ln
+	 (tramp-shell-quote-argument filename)
+	 (tramp-shell-quote-argument l-localname))
+	t)))))
 
 (defun tramp-handle-load (file &optional noerror nomessage nosuffix must-suffix)
   "Like `load' for Tramp files."
@@ -3957,7 +3964,8 @@
 	       ;; We found an uncompression rule.
 	       (tramp-message v 0 "Uncompressing %s..." file)
 	       (when (zerop (tramp-send-command-and-check
-			     v (concat (nth 2 suffix) " " localname)))
+			     v (concat (nth 2 suffix) " "
+				       (tramp-shell-quote-argument localname))))
 		 (tramp-message v 0 "Uncompressing %s...done" file)
 		 ;; `dired-remove-file' is not defined in XEmacs
 		 (funcall (symbol-function 'dired-remove-file) file)
@@ -3968,7 +3976,8 @@
 	       ;; Try gzip.
 	       (tramp-message v 0 "Compressing %s..." file)
 	       (when (zerop (tramp-send-command-and-check
-			     v (concat "gzip -f " localname)))
+			     v (concat "gzip -f "
+				       (tramp-shell-quote-argument localname))))
 		 (tramp-message v 0 "Compressing %s...done" file)
 		 ;; `dired-remove-file' is not defined in XEmacs
 		 (funcall (symbol-function 'dired-remove-file) file)
@@ -4126,11 +4135,13 @@
 		     (string-match "\\`su\\(do\\)?\\'" method))
 	    (setq uname (concat uname user)))
 	  (setq uname
-	    (with-connection-property v uname
-	      (tramp-send-command v (format "cd %s; pwd" uname))
-	      (with-current-buffer (tramp-get-buffer v)
-		(goto-char (point-min))
-		(buffer-substring (point) (tramp-compat-line-end-position)))))
+		(with-connection-property v uname
+		  (tramp-send-command
+		   v (format "cd %s; pwd" (tramp-shell-quote-argument uname)))
+		  (with-current-buffer (tramp-get-buffer v)
+		    (goto-char (point-min))
+		    (buffer-substring
+		     (point) (tramp-compat-line-end-position)))))
 	  (setq localname (concat uname fname))))
       ;; There might be a double slash, for example when "~/"
       ;; expands to "/".  Remove this.
@@ -4357,7 +4368,8 @@
                     (tramp-send-command-and-check
                      v (format "\\cd %s; %s"
                                (tramp-shell-quote-argument localname)
-                               command)))
+                               command)
+		     nil t))
 	    ;; We should show the output anyway.
 	    (when outbuf
 	      (with-current-buffer outbuf
@@ -6892,7 +6904,8 @@
 		  (unless (zerop (tramp-send-command-and-check
 				  vec
 				  (format "echo %s | %s | %s"
-					  magic rem-enc rem-dec) t))
+					  magic rem-enc rem-dec)
+				  t))
 		    (throw 'wont-work-remote nil))
 
 		  (with-current-buffer (tramp-get-buffer vec)
@@ -7250,20 +7263,22 @@
       ;; Return value is whether end-of-output sentinel was found.
       found)))
 
-(defun tramp-send-command-and-check (vec command &optional subshell)
+(defun tramp-send-command-and-check
+  (vec command &optional subshell dont-suppress-err)
   "Run COMMAND and check its exit status.
 Sends `echo $?' along with the COMMAND for checking the exit status.  If
 COMMAND is nil, just sends `echo $?'.  Returns the exit status found.
 
-If the optional argument SUBSHELL is non-nil, the command is executed in
-a subshell, ie surrounded by parentheses."
+If the optional argument SUBSHELL is non-nil, the command is
+executed in a subshell, ie surrounded by parentheses.  If
+DONT-SUPPRESS-ERR is non-nil, stderr won't be sent to /dev/null."
   (tramp-send-command
    vec
    (concat (if subshell "( " "")
 	   command
-	   (if command " 2>/dev/null; " "")
+	   (if command (if dont-suppress-err "; " " 2>/dev/null; ") "")
 	   "echo tramp_exit_status $?"
-	   (if subshell " )" " ")))
+	   (if subshell " )" "")))
   (with-current-buffer (tramp-get-connection-buffer vec)
     (goto-char (point-max))
     (unless (re-search-backward "tramp_exit_status [0-9]+" nil t)