diff options
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/net/tramp-sh.el | 130 |
2 files changed, 75 insertions, 62 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index f199102295a..69451ce5349 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2012-08-08 Michael Albinus <michael.albinus@gmx.de> | ||
| 2 | |||
| 3 | * net/tramp-sh.el (tramp-find-file-exists-command): Protect the | ||
| 4 | tests by `ignore-error'. | ||
| 5 | (tramp-find-shell): Open also a new shell, when cache is already | ||
| 6 | set. Reported by Carsten Bormann <cabo@tzi.org>. (Bug#12148) | ||
| 7 | |||
| 1 | 2012-08-08 Juri Linkov <juri@jurta.org> | 8 | 2012-08-08 Juri Linkov <juri@jurta.org> |
| 2 | 9 | ||
| 3 | * bookmark.el: Add `defaults' property to the bookmark record. | 10 | * bookmark.el: Add `defaults' property to the bookmark record. |
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index afb25509e4f..a92f4231700 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el | |||
| @@ -3559,26 +3559,30 @@ file exists and nonzero exit status otherwise." | |||
| 3559 | ;; `/usr/bin/test'. | 3559 | ;; `/usr/bin/test'. |
| 3560 | ;; `/usr/bin/test -e' In case `/bin/test' does not exist. | 3560 | ;; `/usr/bin/test -e' In case `/bin/test' does not exist. |
| 3561 | (unless (or | 3561 | (unless (or |
| 3562 | (and (setq result (format "%s -e" (tramp-get-test-command vec))) | 3562 | (ignore-errors |
| 3563 | (tramp-send-command-and-check | 3563 | (and (setq result (format "%s -e" (tramp-get-test-command vec))) |
| 3564 | vec (format "%s %s" result existing)) | 3564 | (tramp-send-command-and-check |
| 3565 | (not (tramp-send-command-and-check | 3565 | vec (format "%s %s" result existing)) |
| 3566 | vec (format "%s %s" result nonexistent)))) | 3566 | (not (tramp-send-command-and-check |
| 3567 | (and (setq result "/bin/test -e") | 3567 | vec (format "%s %s" result nonexistent))))) |
| 3568 | (tramp-send-command-and-check | 3568 | (ignore-errors |
| 3569 | vec (format "%s %s" result existing)) | 3569 | (and (setq result "/bin/test -e") |
| 3570 | (not (tramp-send-command-and-check | 3570 | (tramp-send-command-and-check |
| 3571 | vec (format "%s %s" result nonexistent)))) | 3571 | vec (format "%s %s" result existing)) |
| 3572 | (and (setq result "/usr/bin/test -e") | 3572 | (not (tramp-send-command-and-check |
| 3573 | (tramp-send-command-and-check | 3573 | vec (format "%s %s" result nonexistent))))) |
| 3574 | vec (format "%s %s" result existing)) | 3574 | (ignore-errors |
| 3575 | (not (tramp-send-command-and-check | 3575 | (and (setq result "/usr/bin/test -e") |
| 3576 | vec (format "%s %s" result nonexistent)))) | 3576 | (tramp-send-command-and-check |
| 3577 | (and (setq result (format "%s -d" (tramp-get-ls-command vec))) | 3577 | vec (format "%s %s" result existing)) |
| 3578 | (tramp-send-command-and-check | 3578 | (not (tramp-send-command-and-check |
| 3579 | vec (format "%s %s" result existing)) | 3579 | vec (format "%s %s" result nonexistent))))) |
| 3580 | (not (tramp-send-command-and-check | 3580 | (ignore-errors |
| 3581 | vec (format "%s %s" result nonexistent))))) | 3581 | (and (setq result (format "%s -d" (tramp-get-ls-command vec))) |
| 3582 | (tramp-send-command-and-check | ||
| 3583 | vec (format "%s %s" result existing)) | ||
| 3584 | (not (tramp-send-command-and-check | ||
| 3585 | vec (format "%s %s" result nonexistent)))))) | ||
| 3582 | (tramp-error | 3586 | (tramp-error |
| 3583 | vec 'file-error "Couldn't find command to check if file exists")) | 3587 | vec 'file-error "Couldn't find command to check if file exists")) |
| 3584 | result)) | 3588 | result)) |
| @@ -3609,48 +3613,50 @@ file exists and nonzero exit status otherwise." | |||
| 3609 | 3613 | ||
| 3610 | (defun tramp-find-shell (vec) | 3614 | (defun tramp-find-shell (vec) |
| 3611 | "Opens a shell on the remote host which groks tilde expansion." | 3615 | "Opens a shell on the remote host which groks tilde expansion." |
| 3612 | (with-connection-property vec "remote-shell" | 3616 | (with-current-buffer (tramp-get-buffer vec) |
| 3613 | (let ((shell (tramp-get-method-parameter | 3617 | (let ((default-shell (tramp-get-method-parameter |
| 3614 | (tramp-file-name-method vec) 'tramp-remote-shell))) | 3618 | (tramp-file-name-method vec) 'tramp-remote-shell)) |
| 3615 | (with-current-buffer (tramp-get-buffer vec) | 3619 | shell) |
| 3616 | ;; CCC: "root" does not exist always, see QNAP 459. Which | 3620 | (setq shell |
| 3617 | ;; check could we apply instead? | 3621 | (with-connection-property vec "remote-shell" |
| 3618 | (tramp-send-command vec "echo ~root" t) | 3622 | ;; CCC: "root" does not exist always, see QNAP 459. |
| 3619 | (when (or (string-match "^~root$" (buffer-string)) | 3623 | ;; Which check could we apply instead? |
| 3620 | ;; The default shell (ksh93) of OpenSolaris and | 3624 | (tramp-send-command vec "echo ~root" t) |
| 3621 | ;; Solaris is buggy. We've got reports for "SunOS | 3625 | (if (or (string-match "^~root$" (buffer-string)) |
| 3622 | ;; 5.10" and "SunOS 5.11" so far. | 3626 | ;; The default shell (ksh93) of OpenSolaris and |
| 3623 | (string-match (regexp-opt '("SunOS 5.10" "SunOS 5.11")) | 3627 | ;; Solaris is buggy. We've got reports for |
| 3624 | (tramp-get-connection-property vec "uname" ""))) | 3628 | ;; "SunOS 5.10" and "SunOS 5.11" so far. |
| 3625 | (if (setq shell | 3629 | (string-match (regexp-opt '("SunOS 5.10" "SunOS 5.11")) |
| 3626 | (or (tramp-find-executable | 3630 | (tramp-get-connection-property |
| 3627 | vec "bash" (tramp-get-remote-path vec) t t) | 3631 | vec "uname" ""))) |
| 3628 | (tramp-find-executable | 3632 | |
| 3629 | vec "ksh" (tramp-get-remote-path vec) t t))) | 3633 | (or (tramp-find-executable |
| 3630 | (progn | 3634 | vec "bash" (tramp-get-remote-path vec) t t) |
| 3631 | (tramp-message | 3635 | (tramp-find-executable |
| 3632 | vec 5 "Starting remote shell `%s' for tilde expansion" shell) | 3636 | vec "ksh" (tramp-get-remote-path vec) t t) |
| 3633 | (tramp-open-shell vec shell)) | 3637 | ;; Maybe it works at least for some other commands. |
| 3634 | 3638 | (prog1 | |
| 3635 | ;; Maybe it works at least for some other commands. | 3639 | default-shell |
| 3636 | (setq shell | 3640 | (tramp-message |
| 3637 | (tramp-get-method-parameter | 3641 | vec 2 |
| 3638 | (tramp-file-name-method vec) 'tramp-remote-shell)) | 3642 | (concat |
| 3639 | (tramp-message | 3643 | "Couldn't find a remote shell which groks tilde " |
| 3640 | vec 2 | 3644 | "expansion, using `%s'") |
| 3641 | (concat | 3645 | default-shell))) |
| 3642 | "Couldn't find a remote shell which groks tilde expansion, " | 3646 | |
| 3643 | "using `%s'") | 3647 | default-shell))) |
| 3644 | shell))) | 3648 | |
| 3645 | 3649 | ;; Open a new shell if needed. | |
| 3646 | ;; Busyboxes tend to behave strange. We check for the existence. | 3650 | (unless (string-equal shell default-shell) |
| 3647 | (with-connection-property vec "busybox" | 3651 | (tramp-message |
| 3648 | (tramp-send-command vec (format "%s --version" shell) t) | 3652 | vec 5 "Starting remote shell `%s' for tilde expansion" shell) |
| 3649 | (let ((case-fold-search t)) | 3653 | (tramp-open-shell vec shell)) |
| 3650 | (and (string-match "busybox" (buffer-string)) t))) | ||
| 3651 | 3654 | ||
| 3652 | ;; Return the shell. | 3655 | ;; Busyboxes tend to behave strange. We check for the existence. |
| 3653 | shell)))) | 3656 | (with-connection-property vec "busybox" |
| 3657 | (tramp-send-command vec (format "%s --version" shell) t) | ||
| 3658 | (let ((case-fold-search t)) | ||
| 3659 | (and (string-match "busybox" (buffer-string)) t)))))) | ||
| 3654 | 3660 | ||
| 3655 | ;; Utility functions. | 3661 | ;; Utility functions. |
| 3656 | 3662 | ||
| @@ -3786,7 +3792,7 @@ process to set up. VEC specifies the connection." | |||
| 3786 | (tramp-set-remote-path vec) | 3792 | (tramp-set-remote-path vec) |
| 3787 | 3793 | ||
| 3788 | ;; Search for a good shell before searching for a command which | 3794 | ;; Search for a good shell before searching for a command which |
| 3789 | ;; checks if a file exists. This is done because Tramp wants to use | 3795 | ;; checks if a file exists. This is done because Tramp wants to use |
| 3790 | ;; "test foo; echo $?" to check if various conditions hold, and | 3796 | ;; "test foo; echo $?" to check if various conditions hold, and |
| 3791 | ;; there are buggy /bin/sh implementations which don't execute the | 3797 | ;; there are buggy /bin/sh implementations which don't execute the |
| 3792 | ;; "echo $?" part if the "test" part has an error. In particular, | 3798 | ;; "echo $?" part if the "test" part has an error. In particular, |