comparison lisp/net/tramp.el @ 109443:9e514d1076b4

* net/tramp.el (tramp-handle-shell-command): Don't use hard-wired "/bin/sh" but `tramp-remote-sh' from `tramp-methods'. (tramp-find-shell): Simplify setting connection property. (tramp-get-ls-command): Make test for "--color=never" stronger.
author Michael Albinus <michael.albinus@gmx.de>
date Fri, 16 Jul 2010 14:09:55 +0200
parents c4552014bea2
children 333d4b14e6cb
comparison
equal deleted inserted replaced
109442:6c14b478b70f 109443:9e514d1076b4
4681 (command &optional output-buffer error-buffer) 4681 (command &optional output-buffer error-buffer)
4682 "Like `shell-command' for Tramp files." 4682 "Like `shell-command' for Tramp files."
4683 (let* ((asynchronous (string-match "[ \t]*&[ \t]*\\'" command)) 4683 (let* ((asynchronous (string-match "[ \t]*&[ \t]*\\'" command))
4684 ;; We cannot use `shell-file-name' and `shell-command-switch', 4684 ;; We cannot use `shell-file-name' and `shell-command-switch',
4685 ;; they are variables of the local host. 4685 ;; they are variables of the local host.
4686 (args (list "/bin/sh" "-c" (substring command 0 asynchronous))) 4686 (args (list
4687 (tramp-get-method-parameter
4688 (tramp-file-name-method
4689 (tramp-dissect-file-name default-directory))
4690 'tramp-remote-sh)
4691 "-c" (substring command 0 asynchronous)))
4687 current-buffer-p 4692 current-buffer-p
4688 (output-buffer 4693 (output-buffer
4689 (cond 4694 (cond
4690 ((bufferp output-buffer) output-buffer) 4695 ((bufferp output-buffer) output-buffer)
4691 ((stringp output-buffer) (get-buffer-create output-buffer)) 4696 ((stringp output-buffer) (get-buffer-create output-buffer))
6617 (tramp-send-command vec "PS3=''" t) 6622 (tramp-send-command vec "PS3=''" t)
6618 (tramp-send-command vec "PROMPT_COMMAND=''" t))) 6623 (tramp-send-command vec "PROMPT_COMMAND=''" t)))
6619 6624
6620 (t (tramp-message 6625 (t (tramp-message
6621 vec 5 "Remote `%s' groks tilde expansion, good" 6626 vec 5 "Remote `%s' groks tilde expansion, good"
6622 (tramp-get-method-parameter 6627 (tramp-set-connection-property
6623 (tramp-file-name-method vec) 'tramp-remote-sh)) 6628 vec "remote-shell"
6624 (tramp-set-connection-property 6629 (tramp-get-method-parameter
6625 vec "remote-shell" 6630 (tramp-file-name-method vec) 'tramp-remote-sh)))))))))
6626 (tramp-get-method-parameter
6627 (tramp-file-name-method vec) 'tramp-remote-sh))))))))
6628 6631
6629 ;; ------------------------------------------------------------ 6632 ;; ------------------------------------------------------------
6630 ;; -- Functions for establishing connection -- 6633 ;; -- Functions for establishing connection --
6631 ;; ------------------------------------------------------------ 6634 ;; ------------------------------------------------------------
6632 6635
8314 result) 8317 result)
8315 (while (and dl (setq result (tramp-find-executable vec cmd dl t t))) 8318 (while (and dl (setq result (tramp-find-executable vec cmd dl t t)))
8316 ;; Check parameters. On busybox, "ls" output coloring is 8319 ;; Check parameters. On busybox, "ls" output coloring is
8317 ;; enabled by default sometimes. So we try to disable it 8320 ;; enabled by default sometimes. So we try to disable it
8318 ;; when possible. $LS_COLORING is not supported there. 8321 ;; when possible. $LS_COLORING is not supported there.
8322 ;; Some "ls" versions are sensible wrt the order of
8323 ;; arguments, they fail when "-al" is after the
8324 ;; "--color=never" argument (for example on FreeBSD).
8319 (when (zerop (tramp-send-command-and-check 8325 (when (zerop (tramp-send-command-and-check
8320 vec (format "%s -lnd /" result))) 8326 vec (format "%s -lnd /" result)))
8321 (when (zerop (tramp-send-command-and-check 8327 (when (zerop (tramp-send-command-and-check
8322 vec (format "%s --color=never /" result))) 8328 vec (format "%s --color=never -al /" result)))
8323 (setq result (concat result " --color=never"))) 8329 (setq result (concat result " --color=never")))
8324 (throw 'ls-found result)) 8330 (throw 'ls-found result))
8325 (setq dl (cdr dl)))))) 8331 (setq dl (cdr dl))))))
8326 (tramp-error vec 'file-error "Couldn't find a proper `ls' command")))) 8332 (tramp-error vec 'file-error "Couldn't find a proper `ls' command"))))
8327 8333