Subject: Re: bug#12148: 24.1.50; Tramp has problems with Solaris server (test -e)

From: Michael Albinus <[email-masked]>
Date: Wed, 08 Aug 2012 08:47:38 +0200

Carsten Bormann <[email-masked]> writes:

Hi Carsten,

> Again, the problem is that test -e suppresses the rest of the command
> line in /bin/sh on Solaris, so the first "test -e" fails right away,
> but is somehow recovered using another attempt that uses test -d. The
> attempt to find-file (open) .bash_history then completely fails on
> what seems to be the same kind of "test -e" (hmm, why didn't it do
> that in my previous tests before I wrote the tramp file).

I've hardened the test a little bit. Could you, please, check whether
this works (clean the cache first):

--8<---------------cut here---------------start------------->8---
*** ~/src/tramp/lisp/tramp-sh.el.~2.77~	2012-08-08 08:40:59.692792871 +0200
--- ~/src/tramp/lisp/tramp-sh.el	2012-08-08 08:40:33.696337454 +0200
***************
*** 3559,3584 ****
      ;;                    `/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)))))
        (tramp-error
         vec 'file-error "Couldn't find command to check if file exists"))
      result))
--- 3559,3588 ----
      ;;                    `/usr/bin/test'.
      ;; `/usr/bin/test -e' In case `/bin/test' does not exist.
      (unless (or
! 	     (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))
--8<---------------cut here---------------end--------------->8---

> Grüße, Carsten

Best regards, Michael.