comparison lisp/net/tramp.el @ 107498:40467a8dcd6c

* net/tramp.el (tramp-find-executable): Use `tramp-get-connection-buffer'. Make the regexp for checking output of "wc -l" more robust. (tramp-find-shell): Use another shell but /bin/sh on OpenSolaris. (tramp-open-connection-setup-interactive-shell): Remove workaround for OpenSolaris bug, it is not needed anymore.
author Michael Albinus <albinus@detlef>
date Sat, 13 Mar 2010 20:11:01 +0100
parents d2bfe26756ed
children 75e87467a0db 5a6b4fafaa52
comparison
equal deleted inserted replaced
107497:b09401cc9d96 107498:40467a8dcd6c
6292 only in DIRLIST. 6292 only in DIRLIST.
6293 6293
6294 Returns the absolute file name of PROGNAME, if found, and nil otherwise. 6294 Returns the absolute file name of PROGNAME, if found, and nil otherwise.
6295 6295
6296 This function expects to be in the right *tramp* buffer." 6296 This function expects to be in the right *tramp* buffer."
6297 (with-current-buffer (tramp-get-buffer vec) 6297 (with-current-buffer (tramp-get-connection-buffer vec)
6298 (let (result) 6298 (let (result)
6299 ;; Check whether the executable is in $PATH. "which(1)" does not 6299 ;; Check whether the executable is in $PATH. "which(1)" does not
6300 ;; report always a correct error code; therefore we check the 6300 ;; report always a correct error code; therefore we check the
6301 ;; number of words it returns. 6301 ;; number of words it returns.
6302 (unless ignore-path 6302 (unless ignore-path
6303 (tramp-send-command vec (format "which \\%s | wc -w" progname)) 6303 (tramp-send-command vec (format "which \\%s | wc -w" progname))
6304 (goto-char (point-min)) 6304 (goto-char (point-min))
6305 (if (looking-at "^1$") 6305 (if (looking-at "^\\s-*1$")
6306 (setq result (concat "\\" progname)))) 6306 (setq result (concat "\\" progname))))
6307 (unless result 6307 (unless result
6308 (when ignore-tilde 6308 (when ignore-tilde
6309 ;; Remove all ~/foo directories from dirlist. In Emacs 20, 6309 ;; Remove all ~/foo directories from dirlist. In Emacs 20,
6310 ;; `remove' is in CL, and we want to avoid CL dependencies. 6310 ;; `remove' is in CL, and we want to avoid CL dependencies.
6401 (unless (tramp-get-connection-property vec "remote-shell" nil) 6401 (unless (tramp-get-connection-property vec "remote-shell" nil)
6402 (let (shell) 6402 (let (shell)
6403 (with-current-buffer (tramp-get-buffer vec) 6403 (with-current-buffer (tramp-get-buffer vec)
6404 (tramp-send-command vec "echo ~root" t) 6404 (tramp-send-command vec "echo ~root" t)
6405 (cond 6405 (cond
6406 ((string-match "^~root$" (buffer-string)) 6406 ((or (string-match "^~root$" (buffer-string))
6407 ;; The default shell (ksh93) of OpenSolaris is buggy.
6408 (string-equal (tramp-get-connection-property vec "uname" "")
6409 "SunOS 5.11"))
6407 (setq shell 6410 (setq shell
6408 (or (tramp-find-executable 6411 (or (tramp-find-executable
6409 vec "bash" (tramp-get-remote-path vec) t) 6412 vec "bash" (tramp-get-remote-path vec) t t)
6410 (tramp-find-executable 6413 (tramp-find-executable
6411 vec "ksh" (tramp-get-remote-path vec) t))) 6414 vec "ksh" (tramp-get-remote-path vec) t t)))
6412 (unless shell 6415 (unless shell
6413 (tramp-error 6416 (tramp-error
6414 vec 'file-error 6417 vec 'file-error
6415 "Couldn't find a shell which groks tilde expansion")) 6418 "Couldn't find a shell which groks tilde expansion"))
6416 ;; Find arguments for this shell. 6419 ;; Find arguments for this shell.
6835 ;; Search for a good shell before searching for a command which 6838 ;; Search for a good shell before searching for a command which
6836 ;; checks if a file exists. This is done because Tramp wants to use 6839 ;; checks if a file exists. This is done because Tramp wants to use
6837 ;; "test foo; echo $?" to check if various conditions hold, and 6840 ;; "test foo; echo $?" to check if various conditions hold, and
6838 ;; there are buggy /bin/sh implementations which don't execute the 6841 ;; there are buggy /bin/sh implementations which don't execute the
6839 ;; "echo $?" part if the "test" part has an error. In particular, 6842 ;; "echo $?" part if the "test" part has an error. In particular,
6840 ;; the Solaris /bin/sh is a problem. I'm betting that all systems 6843 ;; the OpenSolaris /bin/sh is a problem. There are also other
6841 ;; with buggy /bin/sh implementations will have a working bash or 6844 ;; problems with /bin/sh of OpenSolaris, like redirection of stderr
6842 ;; ksh. Whee... 6845 ;; in in function declarations, or changing HISTFILE in place.
6846 ;; Therefore, OpenSolaris' /bin/sh is replaced by bash, when
6847 ;; detected.
6843 (tramp-find-shell vec) 6848 (tramp-find-shell vec)
6844 6849
6845 ;; Disable unexpected output. 6850 ;; Disable unexpected output.
6846 (tramp-send-command vec "mesg n; biff n" t) 6851 (tramp-send-command vec "mesg n; biff n" t)
6847 6852
6848 ;; Set the environment. 6853 ;; Set the environment.
6849 (tramp-message vec 5 "Setting default environment") 6854 (tramp-message vec 5 "Setting default environment")
6850
6851 ;; On OpenSolaris, there is a bug when HISTFILE is changed in place
6852 ;; <http://bugs.opensolaris.org/view_bug.do?bug_id=6834184>. We
6853 ;; apply the workaround.
6854 (if (string-equal (tramp-get-connection-property vec "uname" "") "SunOS 5.11")
6855 (tramp-send-command vec "unset HISTFILE" t))
6856 6855
6857 (let ((env (copy-sequence tramp-remote-process-environment)) 6856 (let ((env (copy-sequence tramp-remote-process-environment))
6858 unset item) 6857 unset item)
6859 (while env 6858 (while env
6860 (setq item (tramp-compat-split-string (car env) "=")) 6859 (setq item (tramp-compat-split-string (car env) "="))