Merge from emacs-23; up to 2010-06-08T03:06:47Z!dann@ics.uci.edu.
[bpt/emacs.git] / lisp / net / tramp-sh.el
index 151758b..ec5c46b 100644 (file)
@@ -66,7 +66,7 @@ files conditionalize this setup based on the TERM environment variable."
   :group 'tramp
   :type 'string)
 
-;; ksh on OpenBSD 4.5 requires, that $PS1 contains a `#' character for
+;; ksh on OpenBSD 4.5 requires that $PS1 contains a `#' character for
 ;; root users.  It uses the `$' character for other users.  In order
 ;; to guarantee a proper prompt, we use "#$ " for the prompt.
 
@@ -90,7 +90,7 @@ detected as prompt when being sent on echoing hosts, therefore.")
     (tramp-login-args           (("%h") ("-l" "%u")))
     (tramp-remote-sh            "/bin/sh")
     (tramp-copy-program         "rcp")
-    (tramp-copy-args            (("%k" "-p") ("-r")))
+    (tramp-copy-args            (("-p" "%k") ("-r")))
     (tramp-copy-keep-date       t)
     (tramp-copy-recursive       t)))
 ;;;###tramp-autoload
@@ -100,7 +100,7 @@ detected as prompt when being sent on echoing hosts, therefore.")
     (tramp-login-args           (("%h") ("-l" "%u")))
     (tramp-remote-sh            "/bin/sh")
     (tramp-copy-program         "rcp")
-    (tramp-copy-args            (("%k" "-p")))
+    (tramp-copy-args            (("-p" "%k")))
     (tramp-copy-keep-date       t)))
 ;;;###tramp-autoload
 (add-to-list 'tramp-methods
@@ -110,7 +110,7 @@ detected as prompt when being sent on echoing hosts, therefore.")
    (tramp-async-args           (("-q")))
    (tramp-remote-sh            "/bin/sh")
    (tramp-copy-program         "scp")
-   (tramp-copy-args            (("-P" "%p") ("%k" "-p")        ("-q") ("-r")))
+   (tramp-copy-args            (("-P" "%p") ("-p" "%k")        ("-q") ("-r")))
    (tramp-copy-keep-date       t)
    (tramp-copy-recursive       t)
    (tramp-gw-args              (("-o" "GlobalKnownHostsFile=/dev/null")
@@ -126,7 +126,7 @@ detected as prompt when being sent on echoing hosts, therefore.")
     (tramp-async-args           (("-q")))
     (tramp-remote-sh            "/bin/sh")
     (tramp-copy-program         "scp")
-    (tramp-copy-args            (("-1") ("-P" "%p") ("%k" "-p") ("-q") ("-r")))
+    (tramp-copy-args            (("-1") ("-P" "%p") ("-p" "%k") ("-q") ("-r")))
     (tramp-copy-keep-date       t)
     (tramp-copy-recursive       t)
     (tramp-gw-args              (("-o" "GlobalKnownHostsFile=/dev/null")
@@ -142,7 +142,7 @@ detected as prompt when being sent on echoing hosts, therefore.")
     (tramp-async-args           (("-q")))
     (tramp-remote-sh            "/bin/sh")
     (tramp-copy-program         "scp")
-    (tramp-copy-args            (("-2") ("-P" "%p") ("%k" "-p") ("-q") ("-r")))
+    (tramp-copy-args            (("-2") ("-P" "%p") ("-p" "%k") ("-q") ("-r")))
     (tramp-copy-keep-date       t)
     (tramp-copy-recursive       t)
     (tramp-gw-args              (("-o" "GlobalKnownHostsFile=/dev/null")
@@ -160,7 +160,7 @@ detected as prompt when being sent on echoing hosts, therefore.")
     (tramp-async-args           (("-q")))
     (tramp-remote-sh            "/bin/sh")
     (tramp-copy-program         "scp")
-    (tramp-copy-args            (("-P" "%p") ("%k" "-p") ("-q") ("-r")
+    (tramp-copy-args            (("-P" "%p") ("-p" "%k") ("-q") ("-r")
                                 ("-o" "ControlPath=%t.%%r@%%h:%%p")
                                 ("-o" "ControlMaster=auto")))
     (tramp-copy-keep-date       t)
@@ -179,7 +179,7 @@ detected as prompt when being sent on echoing hosts, therefore.")
     (tramp-async-args           (("-q")))
     (tramp-remote-sh            "/bin/sh")
     (tramp-copy-program         "scp")
-    (tramp-copy-args            (("-P" "%p") ("%k" "-p") ("-q") ("-r")))
+    (tramp-copy-args            (("-P" "%p") ("-p" "%k") ("-q") ("-r")))
     (tramp-copy-keep-date       t)
     (tramp-copy-recursive       t)
     (tramp-gw-args              (("-o" "GlobalKnownHostsFile=/dev/null")
@@ -202,7 +202,7 @@ detected as prompt when being sent on echoing hosts, therefore.")
     (tramp-async-args           (("-q")))
     (tramp-remote-sh            "/bin/sh")
     (tramp-copy-program         "rsync")
-    (tramp-copy-args            (("-e" "ssh") ("%k" "-t") ("-r")))
+    (tramp-copy-args            (("-e" "ssh") ("-t" "%k") ("-r")))
     (tramp-copy-keep-date       t)
     (tramp-copy-keep-tmpfile    t)
     (tramp-copy-recursive       t)))
@@ -217,7 +217,7 @@ detected as prompt when being sent on echoing hosts, therefore.")
     (tramp-async-args           (("-q")))
     (tramp-remote-sh            "/bin/sh")
     (tramp-copy-program         "rsync")
-    (tramp-copy-args            (("%k" "-t") ("-r")))
+    (tramp-copy-args            (("-t" "%k") ("-r")))
     (tramp-copy-env             (("RSYNC_RSH")
                                 (,(concat
                                    "ssh"
@@ -353,7 +353,7 @@ detected as prompt when being sent on echoing hosts, therefore.")
     (tramp-login-args           (("-l" "%u") ("-P" "%p") ("-ssh") ("%h")))
     (tramp-remote-sh            "/bin/sh")
     (tramp-copy-program         "pscp")
-    (tramp-copy-args            (("-P" "%p") ("-scp") ("%k" "-p")
+    (tramp-copy-args            (("-P" "%p") ("-scp") ("-p" "%k")
                                 ("-q") ("-r")))
     (tramp-copy-keep-date       t)
     (tramp-copy-recursive       t)
@@ -366,7 +366,7 @@ detected as prompt when being sent on echoing hosts, therefore.")
     (tramp-login-args           (("-l" "%u") ("-P" "%p") ("-ssh") ("%h")))
     (tramp-remote-sh            "/bin/sh")
     (tramp-copy-program         "pscp")
-    (tramp-copy-args            (("-P" "%p") ("-sftp") ("%k" "-p")
+    (tramp-copy-args            (("-P" "%p") ("-sftp") ("-p" "%k")
                                 ("-q") ("-r")))
     (tramp-copy-keep-date       t)
     (tramp-copy-recursive       t)
@@ -378,7 +378,7 @@ detected as prompt when being sent on echoing hosts, therefore.")
     (tramp-login-args           (("%h") ("-l" "%u") ("sh" "-i")))
     (tramp-remote-sh            "/bin/sh -i")
     (tramp-copy-program         "fcp")
-    (tramp-copy-args            (("%k" "-p")))
+    (tramp-copy-args            (("-p" "%k")))
     (tramp-copy-keep-date       t)))
 
 ;;;###tramp-autoload
@@ -509,7 +509,7 @@ entry ENVVARNAME= diables the corresponding environment variable,
 which might have been set in the init files like ~/.profile.
 
 Special handling is applied to the PATH environment, which should
-not be set here. Instead of, it should be set via `tramp-remote-path'."
+not be set here. Instead, it should be set via `tramp-remote-path'."
   :group 'tramp
   :type '(repeat string))
 
@@ -2209,7 +2209,7 @@ The method used must be an out-of-band method."
     (with-parsed-tramp-file-name (if t1 filename newname) nil
       (if (and t1 t2)
 
-         ;; Both are Tramp files.  We shall optimize it, when the
+         ;; Both are Tramp files.  We shall optimize it when the
          ;; methods for filename and newname are the same.
          (let* ((dir-flag (file-directory-p filename))
                 (tmpfile (tramp-compat-make-temp-file localname dir-flag)))
@@ -2251,11 +2251,15 @@ The method used must be an out-of-band method."
                        'identity)
                      (if t2 (tramp-make-copy-program-file-name v) newname)))
 
-       ;; Check for port number.  Until now, there's no need for handling
-       ;; like method, user, host.
-       (setq host (tramp-file-name-real-host v)
-             port (tramp-file-name-port v)
-             port (or (and port (number-to-string port)) ""))
+       ;; Check for host and port number.  We cannot use
+       ;; `tramp-file-name-port', because this returns also
+       ;; `tramp-default-port', which might clash with settings in
+       ;; "~/.ssh/config".
+       (setq host (tramp-file-name-host v)
+             port "")
+       (when (string-match tramp-host-with-port-regexp host)
+         (setq host (string-to-number (match-string 1 host))
+               port (string-to-number (match-string 2 host))))
 
        ;; Compose copy command.
        (setq spec (format-spec-make
@@ -2270,7 +2274,7 @@ The method used must be an out-of-band method."
              copy-args
              (delete
               ;; " " has either been a replacement of "%k" (when
-              ;; keep-date argument is non-nil), or a replacemtent
+              ;; keep-date argument is non-nil), or a replacement
               ;; for the whole keep-date sublist.
               " "
               (dolist
@@ -2281,7 +2285,7 @@ The method used must be an out-of-band method."
                       (append
                        copy-args
                        (let ((y (mapcar (lambda (z) (format-spec z spec)) x)))
-                         (if (zerop (length (car y))) '(" ") y))))))
+                         (if (member "" y) '(" ") y))))))
              copy-env
              (delq
               nil
@@ -2405,7 +2409,7 @@ This is like `dired-recursive-delete-directory' for Tramp files."
     (tramp-send-command
      v
      (format "rm -rf %s" (tramp-shell-quote-argument localname))
-     ;; Don't read the output, do it explicitely.
+     ;; Don't read the output, do it explicitly.
      nil t)
     ;; Wait for the remote system to return to us...
     ;; This might take a while, allow it plenty of time.
@@ -3150,7 +3154,7 @@ Returns a file name in `tramp-auto-save-directory' for autosaving this file."
          ;; filename does not exist (eq modes nil) it has been
          ;; renamed to the backup file.  This case `save-buffer'
          ;; handles permissions.
-         ;; Ensure, that it is still readable.
+         ;; Ensure that it is still readable.
          (when modes
            (set-file-modes
             tmpfile
@@ -3296,7 +3300,7 @@ Returns a file name in `tramp-auto-save-directory' for autosaving this file."
        (when (or (eq visit t) (stringp visit))
           (let ((file-attr (file-attributes filename)))
             (set-visited-file-modtime
-             ;; We must pass modtime explicitely, because filename can
+             ;; We must pass modtime explicitly, because filename can
              ;; be different from (buffer-file-name), f.e. if
              ;; `file-precious-flag' is set.
              (nth 5 file-attr))
@@ -3403,7 +3407,7 @@ Fall back to normal file name handler if no Tramp handler exists."
       (with-parsed-tramp-file-name filename nil
        (cond
         ;; That's what we want: file names, for which checks are
-        ;; applied.  We assume, that VC uses only `file-exists-p' and
+        ;; applied.  We assume that VC uses only `file-exists-p' and
         ;; `file-readable-p' checks; otherwise we must extend the
         ;; list.  We do not perform any action, but return nil, in
         ;; order to keep `vc-registered' running.
@@ -4303,7 +4307,7 @@ connection if a previous connection has died for some reason."
                     ;; it is just a prefix for the ControlPath option
                     ;; of ssh; the real temporary file has another
                     ;; name, and it is created and protected by ssh.
-                    ;; It is also removed by ssh, when the connection
+                    ;; It is also removed by ssh when the connection
                     ;; is closed.
                     (tmpfile
                      (tramp-set-connection-property
@@ -5074,7 +5078,7 @@ function cell is returned to be applied on a buffer."
 ;; * It makes me wonder if tramp couldn't fall back to ssh when scp
 ;;   isn't on the remote host.  (Mark A. Hershberger)
 ;; * Use lsh instead of ssh.  (Alfred M. Szmidt)
-;; * Optimize out-of-band copying, when both methods are scp-like (not
+;; * Optimize out-of-band copying when both methods are scp-like (not
 ;;   rsync).
 ;; * Keep a second connection open for out-of-band methods like scp or
 ;;   rsync.