1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-28 08:11:05 -08:00

Adapt Tramp's make-process for macOS.

* lisp/net/tramp-sh.el (tramp-check-remote-uname): New defun.
(tramp-sh-handle-file-ownership-preserved-p)
(tramp-sh-handle-make-process, tramp-find-executable)
(tramp-find-shell, tramp-get-remote-stat): Use it.  (Bug#50748)

* test/lisp/net/tramp-tests.el (tramp-check-remote-uname): Declare.
(tramp-test29-start-file-process, tramp-test30-make-process):
Instrument for macOS.
(tramp--test-hpux-p): Adapt function.
(tramp--test-macos-p): New defun.
This commit is contained in:
Michael Albinus 2021-09-26 10:32:15 +02:00
parent 50798267f2
commit 27d8726ae2
2 changed files with 31 additions and 18 deletions

View file

@ -1628,9 +1628,7 @@ ID-FORMAT valid values are `string' and `integer'."
;; On BSD-derived systems files always inherit the
;; parent directory's group, so skip the group-gid
;; test.
(string-match-p
"BSD\\|DragonFly\\|Darwin"
(tramp-get-connection-property v "uname" ""))
(tramp-check-remote-uname v "BSD\\|DragonFly\\|Darwin")
(= (tramp-compat-file-attribute-group-id attributes)
(tramp-get-remote-gid v 'integer)))))))))
@ -2937,8 +2935,11 @@ implementation will be used."
(setq p (tramp-get-connection-process v))
(process-put p 'remote-pid pid)
(tramp-set-connection-property p "remote-pid" pid))
;; Disable carriage return to newline translation.
(when (memq connection-type '(nil pipe))
;; Disable carriage return to newline
;; translation. This does not work on
;; macOS, see Bug#50748.
(when (and (memq connection-type '(nil pipe))
(not (tramp-check-remote-uname v "Darwin")))
(tramp-send-command v "stty -icrnl"))
;; `tramp-maybe-open-connection' and
;; `tramp-send-command-and-read' could have
@ -4008,10 +4009,7 @@ This function expects to be in the right *tramp* buffer."
;; number of words it returns. "SunOS 5.10" (and maybe "SunOS
;; 5.11") have problems with this command, we disable the call
;; therefore.
(unless (or ignore-path
(string-match-p
tramp-sunos-unames
(tramp-get-connection-property vec "uname" "")))
(unless (or ignore-path (tramp-check-remote-uname vec tramp-sunos-unames))
(tramp-send-command vec (format "which \\%s | wc -w" progname))
(goto-char (point-min))
(if (looking-at-p "^\\s-*1$")
@ -4221,9 +4219,7 @@ file exists and nonzero exit status otherwise."
;; 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-p
tramp-sunos-unames
(tramp-get-connection-property vec "uname" "")))
(tramp-check-remote-uname vec tramp-sunos-unames))
(or (tramp-find-executable
vec "bash" (tramp-get-remote-path vec) t t)
@ -5340,6 +5336,10 @@ Return ATTR."
;; Variables local to connection.
(defun tramp-check-remote-uname (vec regexp)
"Check whether REGEXP matches the connection property \"uname\"."
(string-match-p regexp (tramp-get-connection-property vec "uname" "")))
(defun tramp-get-remote-path (vec)
"Compile list of remote directories for PATH.
Nonexistent directories are removed from spec."
@ -5564,8 +5564,7 @@ Nonexistent directories are removed from spec."
(with-tramp-connection-property vec "stat"
;; stat on Solaris is buggy. We've got reports for "SunOS 5.10"
;; and "SunOS 5.11" so far.
(unless (string-match-p
tramp-sunos-unames (tramp-get-connection-property vec "uname" ""))
(unless (tramp-check-remote-uname vec tramp-sunos-unames)
(tramp-message vec 5 "Finding a suitable `stat' command")
(let ((result (tramp-find-executable
vec "stat" (tramp-get-remote-path vec)))

View file

@ -52,6 +52,7 @@
(require 'vc-git)
(require 'vc-hg)
(declare-function tramp-check-remote-uname "tramp-sh")
(declare-function tramp-find-executable "tramp-sh")
(declare-function tramp-get-remote-chmod-h "tramp-sh")
(declare-function tramp-get-remote-gid "tramp-sh")
@ -4585,6 +4586,10 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
(while (< (- (point-max) (point-min))
(length "66\n6F\n6F\n0D\n0A\n"))
(while (accept-process-output proc 0 nil t))))
(if (tramp--test-macos-p)
(tramp--test-message
"process-connection-type %s\n%s"
process-connection-type (pp-to-string (buffer-string)))
(should
(string-match-p
(if (memq process-connection-type '(nil pipe))
@ -4592,7 +4597,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
;; flag is FALSE. See telnet(1) man page.
"66\n6F\n6F\n0D\\(\n00\\)?\n0A\n"
"66\n6F\n6F\n0A\\(\n00\\)?\n0A\n")
(buffer-string))))
(buffer-string)))))
;; Cleanup.
(ignore-errors (delete-process proc)))))
@ -4850,6 +4855,10 @@ If UNSTABLE is non-nil, the test is tagged as `:unstable'."
(while (< (- (point-max) (point-min))
(length "66\n6F\n6F\n0D\n0A\n"))
(while (accept-process-output proc 0 nil t))))
(if (tramp--test-macos-p)
(tramp--test-message
"process-connection-type %s\n%s"
process-connection-type (pp-to-string (buffer-string)))
(should
(string-match-p
(if (memq (or connection-type process-connection-type)
@ -4858,7 +4867,7 @@ If UNSTABLE is non-nil, the test is tagged as `:unstable'."
;; flag is FALSE. See telnet(1) man page.
"66\n6F\n6F\n0D\\(\n00\\)?\n0A\n"
"66\n6F\n6F\n0A\\(\n00\\)?\n0A\n")
(buffer-string))))
(buffer-string)))))
;; Cleanup.
(ignore-errors (delete-process proc)))))))))
@ -6099,8 +6108,7 @@ If optional METHOD is given, it is checked first."
Several special characters do not work properly there."
;; We must refill the cache. `file-truename' does it.
(file-truename tramp-test-temporary-file-directory)
(string-match-p
"^HP-UX" (tramp-get-connection-property tramp-test-vec "uname" "")))
(tramp-check-remote-uname tramp-test-vec "^HP-UX"))
(defun tramp--test-ksh-p ()
"Check, whether the remote shell is ksh.
@ -6111,6 +6119,12 @@ a $'' syntax."
(string-match-p
"ksh$" (tramp-get-connection-property tramp-test-vec "remote-shell" "")))
(defun tramp--test-macos-p ()
"Check, whether the remote host runs macOS."
;; We must refill the cache. `file-truename' does it.
(file-truename tramp-test-temporary-file-directory)
(tramp-check-remote-uname tramp-test-vec "Darwin"))
(defun tramp--test-mock-p ()
"Check, whether the mock method is used.
This does not support external Emacs calls."