emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r109511: * net/tramp-sh.el (tramp-fin


From: Michael Albinus
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r109511: * net/tramp-sh.el (tramp-find-file-exists-command): Protect the
Date: Wed, 08 Aug 2012 15:40:45 +0200
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 109511
committer: Michael Albinus <address@hidden
branch nick: trunk
timestamp: Wed 2012-08-08 15:40:45 +0200
message:
  * net/tramp-sh.el (tramp-find-file-exists-command): Protect the
  tests by `ignore-error'.
  (tramp-find-shell): Open also a new shell, when cache is already
  set.  Reported by Carsten Bormann <address@hidden>.  (Bug#12148)
modified:
  lisp/ChangeLog
  lisp/net/tramp-sh.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2012-08-08 08:48:57 +0000
+++ b/lisp/ChangeLog    2012-08-08 13:40:45 +0000
@@ -1,3 +1,10 @@
+2012-08-08  Michael Albinus  <address@hidden>
+
+       * net/tramp-sh.el (tramp-find-file-exists-command): Protect the
+       tests by `ignore-error'.
+       (tramp-find-shell): Open also a new shell, when cache is already
+       set.  Reported by Carsten Bormann <address@hidden>.  (Bug#12148)
+
 2012-08-08  Juri Linkov  <address@hidden>
 
        * bookmark.el: Add `defaults' property to the bookmark record.

=== modified file 'lisp/net/tramp-sh.el'
--- a/lisp/net/tramp-sh.el      2012-07-06 13:16:13 +0000
+++ b/lisp/net/tramp-sh.el      2012-08-08 13:40:45 +0000
@@ -3559,26 +3559,30 @@
     ;;                    `/usr/bin/test'.
     ;; `/usr/bin/test -e' In case `/bin/test' does not exist.
     (unless (or
-             (and (setq result (format "%s -e" (tramp-get-test-command vec)))
-                 (tramp-send-command-and-check
-                  vec (format "%s %s" result existing))
-                  (not (tramp-send-command-and-check
-                       vec (format "%s %s" result nonexistent))))
-             (and (setq result "/bin/test -e")
-                 (tramp-send-command-and-check
-                  vec (format "%s %s" result existing))
-                  (not (tramp-send-command-and-check
-                       vec (format "%s %s" result nonexistent))))
-             (and (setq result "/usr/bin/test -e")
-                 (tramp-send-command-and-check
-                  vec (format "%s %s" result existing))
-                  (not (tramp-send-command-and-check
-                       vec (format "%s %s" result nonexistent))))
-             (and (setq result (format "%s -d" (tramp-get-ls-command vec)))
-                 (tramp-send-command-and-check
-                  vec (format "%s %s" result existing))
-                  (not (tramp-send-command-and-check
-                       vec (format "%s %s" result nonexistent)))))
+            (ignore-errors
+              (and (setq result (format "%s -e" (tramp-get-test-command vec)))
+                   (tramp-send-command-and-check
+                    vec (format "%s %s" result existing))
+                   (not (tramp-send-command-and-check
+                         vec (format "%s %s" result nonexistent)))))
+            (ignore-errors
+              (and (setq result "/bin/test -e")
+                   (tramp-send-command-and-check
+                    vec (format "%s %s" result existing))
+                   (not (tramp-send-command-and-check
+                         vec (format "%s %s" result nonexistent)))))
+            (ignore-errors
+              (and (setq result "/usr/bin/test -e")
+                   (tramp-send-command-and-check
+                    vec (format "%s %s" result existing))
+                   (not (tramp-send-command-and-check
+                         vec (format "%s %s" result nonexistent)))))
+            (ignore-errors
+              (and (setq result (format "%s -d" (tramp-get-ls-command vec)))
+                   (tramp-send-command-and-check
+                    vec (format "%s %s" result existing))
+                   (not (tramp-send-command-and-check
+                         vec (format "%s %s" result nonexistent))))))
       (tramp-error
        vec 'file-error "Couldn't find command to check if file exists"))
     result))
@@ -3609,48 +3613,50 @@
 
 (defun tramp-find-shell (vec)
   "Opens a shell on the remote host which groks tilde expansion."
-  (with-connection-property vec "remote-shell"
-    (let ((shell (tramp-get-method-parameter
-                 (tramp-file-name-method vec) 'tramp-remote-shell)))
-      (with-current-buffer (tramp-get-buffer vec)
-       ;; CCC: "root" does not exist always, see QNAP 459.  Which
-       ;; check could we apply instead?
-       (tramp-send-command vec "echo ~root" t)
-       (when (or (string-match "^~root$" (buffer-string))
-                 ;; The default shell (ksh93) of OpenSolaris and
-                 ;; Solaris is buggy.  We've got reports for "SunOS
-                 ;; 5.10" and "SunOS 5.11" so far.
-                 (string-match (regexp-opt '("SunOS 5.10" "SunOS 5.11"))
-                               (tramp-get-connection-property vec "uname" "")))
-         (if (setq shell
-                   (or (tramp-find-executable
-                        vec "bash" (tramp-get-remote-path vec) t t)
-                       (tramp-find-executable
-                        vec "ksh" (tramp-get-remote-path vec) t t)))
-             (progn
-               (tramp-message
-                vec 5 "Starting remote shell `%s' for tilde expansion" shell)
-               (tramp-open-shell vec shell))
-
-           ;; Maybe it works at least for some other commands.
-           (setq shell
-                 (tramp-get-method-parameter
-                  (tramp-file-name-method vec) 'tramp-remote-shell))
-           (tramp-message
-            vec 2
-            (concat
-             "Couldn't find a remote shell which groks tilde expansion, "
-             "using `%s'")
-            shell)))
-
-       ;; Busyboxes tend to behave strange.  We check for the existence.
-       (with-connection-property vec "busybox"
-         (tramp-send-command vec (format "%s --version" shell) t)
-         (let ((case-fold-search t))
-           (and (string-match "busybox" (buffer-string)) t)))
-
-       ;; Return the shell.
-       shell))))
+  (with-current-buffer (tramp-get-buffer vec)
+    (let ((default-shell (tramp-get-method-parameter
+                         (tramp-file-name-method vec) 'tramp-remote-shell))
+         shell)
+      (setq shell
+           (with-connection-property vec "remote-shell"
+             ;; CCC: "root" does not exist always, see QNAP 459.
+             ;; Which check could we apply instead?
+             (tramp-send-command vec "echo ~root" t)
+             (if (or (string-match "^~root$" (buffer-string))
+                     ;; The default shell (ksh93) of OpenSolaris and
+                     ;; Solaris is buggy.  We've got reports for
+                     ;; "SunOS 5.10" and "SunOS 5.11" so far.
+                     (string-match (regexp-opt '("SunOS 5.10" "SunOS 5.11"))
+                                   (tramp-get-connection-property
+                                    vec "uname" "")))
+
+                 (or (tramp-find-executable
+                      vec "bash" (tramp-get-remote-path vec) t t)
+                     (tramp-find-executable
+                      vec "ksh" (tramp-get-remote-path vec) t t)
+                     ;; Maybe it works at least for some other commands.
+                     (prog1
+                         default-shell
+                       (tramp-message
+                        vec 2
+                        (concat
+                         "Couldn't find a remote shell which groks tilde "
+                         "expansion, using `%s'")
+                        default-shell)))
+
+               default-shell)))
+
+      ;; Open a new shell if needed.
+      (unless (string-equal shell default-shell)
+       (tramp-message
+        vec 5 "Starting remote shell `%s' for tilde expansion" shell)
+       (tramp-open-shell vec shell))
+
+      ;; Busyboxes tend to behave strange.  We check for the existence.
+      (with-connection-property vec "busybox"
+       (tramp-send-command vec (format "%s --version" shell) t)
+       (let ((case-fold-search t))
+         (and (string-match "busybox" (buffer-string)) t))))))
 
 ;; Utility functions.
 
@@ -3786,7 +3792,7 @@
   (tramp-set-remote-path vec)
 
   ;; Search for a good shell before searching for a command which
-  ;; checks if a file exists. This is done because Tramp wants to use
+  ;; checks if a file exists.  This is done because Tramp wants to use
   ;; "test foo; echo $?" to check if various conditions hold, and
   ;; there are buggy /bin/sh implementations which don't execute the
   ;; "echo $?"  part if the "test" part has an error.  In particular,


reply via email to

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