Function: tramp-get-remote-stat

tramp-get-remote-stat is a byte-compiled function defined in tramp-sh.el.gz.

Signature

(tramp-get-remote-stat VEC)

Documentation

Determine remote stat command.

Source Code

;; Defined in /usr/src/emacs/lisp/net/tramp-sh.el.gz
(defun tramp-get-remote-stat (vec)
  "Determine remote `stat' command."
  (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 (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)))
	    tmp)
	;; Check whether stat(1) returns usable syntax.  "%s" does not
	;; work on older AIX systems.  Recent GNU stat versions
	;; (8.24?)  use shell quoted format for "%N", we check the
	;; boundaries "`" and "'" and their localized variants,
	;; therefore.  See Bug#23422 in coreutils.  Since GNU stat
	;; 8.26, environment variable QUOTING_STYLE is supported.
	(when result
	  (setq result (concat "env QUOTING_STYLE=locale " result)
		tmp (tramp-send-command-and-read
		     vec (format "%s -c '(\"%%N\" %%s)' /" result) 'noerror))
	  (unless (and (listp tmp) (stringp (car tmp))
		       (string-match-p
			(rx bol (any "\"`'‘„”«「") "/" (any "\"'’“”»」") eol)
			(car tmp))
		       (integerp (cadr tmp)))
	    (setq result nil)))
	result))))