mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-12-28 10:56:36 +00:00
Handle too long commands in Tramp
* lisp/net/tramp-sh.el (tramp-sh-handle-make-symbolic-link) (tramp-do-file-attributes-with-ls): Send sequence of commands, in order to not exceed shell command line limit. * test/automated/tramp-tests.el (tramp--test-darwin-p): Remove. (tramp--test-utf8): Include Arabic file name, again.
This commit is contained in:
parent
684eb58db9
commit
1089dc98b7
@ -1100,15 +1100,19 @@ target of the symlink differ."
|
|||||||
;; Right, they are on the same host, regardless of user, method,
|
;; Right, they are on the same host, regardless of user, method,
|
||||||
;; etc. We now make the link on the remote machine. This will
|
;; etc. We now make the link on the remote machine. This will
|
||||||
;; occur as the user that FILENAME belongs to.
|
;; occur as the user that FILENAME belongs to.
|
||||||
(tramp-send-command-and-check
|
(and (tramp-send-command-and-check
|
||||||
l
|
l (format "cd %s" (tramp-shell-quote-argument cwd)))
|
||||||
(format
|
(tramp-send-command-and-check
|
||||||
"cd %s && %s -sf %s %s"
|
l (format
|
||||||
(tramp-shell-quote-argument cwd)
|
"%s -sf %s %s"
|
||||||
ln
|
ln
|
||||||
(tramp-shell-quote-argument filename)
|
(tramp-shell-quote-argument filename)
|
||||||
(tramp-shell-quote-argument l-localname))
|
;; The command could exceed PATH_MAX, so we use
|
||||||
t))))
|
;; relative file names. However, relative file names
|
||||||
|
;; could start with "-". `tramp-shell-quote-argument'
|
||||||
|
;; does not handle this, we must do it ourselves.
|
||||||
|
(tramp-shell-quote-argument
|
||||||
|
(concat "./" (file-name-nondirectory l-localname)))))))))
|
||||||
|
|
||||||
(defun tramp-sh-handle-file-truename (filename)
|
(defun tramp-sh-handle-file-truename (filename)
|
||||||
"Like `file-truename' for Tramp files."
|
"Like `file-truename' for Tramp files."
|
||||||
@ -1266,100 +1270,108 @@ target of the symlink differ."
|
|||||||
res-inode res-filemodes res-numlinks
|
res-inode res-filemodes res-numlinks
|
||||||
res-uid res-gid res-size res-symlink-target)
|
res-uid res-gid res-size res-symlink-target)
|
||||||
(tramp-message vec 5 "file attributes with ls: %s" localname)
|
(tramp-message vec 5 "file attributes with ls: %s" localname)
|
||||||
(tramp-send-command
|
;; We cannot send all three commands combined, it could exceed
|
||||||
vec
|
;; NAME_MAX or PATH_MAX. Happened on Mac OS X, for example.
|
||||||
(format "(%s %s || %s -h %s) && %s %s %s %s"
|
(when (or (tramp-send-command-and-check
|
||||||
(tramp-get-file-exists-command vec)
|
vec
|
||||||
(tramp-shell-quote-argument localname)
|
(format "%s %s"
|
||||||
(tramp-get-test-command vec)
|
(tramp-get-file-exists-command vec)
|
||||||
(tramp-shell-quote-argument localname)
|
(tramp-shell-quote-argument localname)))
|
||||||
(tramp-get-ls-command vec)
|
(tramp-send-command-and-check
|
||||||
(if (eq id-format 'integer) "-ildn" "-ild")
|
vec
|
||||||
;; On systems which have no quoting style, file names
|
(format "%s -h %s"
|
||||||
;; with special characters could fail.
|
(tramp-get-test-command vec)
|
||||||
(cond
|
(tramp-shell-quote-argument localname))))
|
||||||
((tramp-get-ls-command-with-quoting-style vec)
|
(tramp-send-command
|
||||||
"--quoting-style=c")
|
vec
|
||||||
((tramp-get-ls-command-with-w-option vec)
|
(format "%s %s %s %s"
|
||||||
"-w")
|
(tramp-get-ls-command vec)
|
||||||
(t ""))
|
(if (eq id-format 'integer) "-ildn" "-ild")
|
||||||
(tramp-shell-quote-argument localname)))
|
;; On systems which have no quoting style, file names
|
||||||
;; Parse `ls -l' output ...
|
;; with special characters could fail.
|
||||||
(with-current-buffer (tramp-get-buffer vec)
|
(cond
|
||||||
(when (> (buffer-size) 0)
|
((tramp-get-ls-command-with-quoting-style vec)
|
||||||
(goto-char (point-min))
|
"--quoting-style=c")
|
||||||
;; ... inode
|
((tramp-get-ls-command-with-w-option vec)
|
||||||
(setq res-inode
|
"-w")
|
||||||
(condition-case err
|
(t ""))
|
||||||
(read (current-buffer))
|
(tramp-shell-quote-argument localname)))
|
||||||
(invalid-read-syntax
|
;; Parse `ls -l' output ...
|
||||||
(when (and (equal (cadr err)
|
(with-current-buffer (tramp-get-buffer vec)
|
||||||
"Integer constant overflow in reader")
|
(when (> (buffer-size) 0)
|
||||||
(string-match
|
(goto-char (point-min))
|
||||||
"^[0-9]+\\([0-9][0-9][0-9][0-9][0-9]\\)\\'"
|
;; ... inode
|
||||||
(car (cddr err))))
|
(setq res-inode
|
||||||
(let* ((big (read (substring (car (cddr err)) 0
|
(condition-case err
|
||||||
(match-beginning 1))))
|
(read (current-buffer))
|
||||||
(small (read (match-string 1 (car (cddr err)))))
|
(invalid-read-syntax
|
||||||
(twiddle (/ small 65536)))
|
(when (and (equal (cadr err)
|
||||||
(cons (+ big twiddle)
|
"Integer constant overflow in reader")
|
||||||
(- small (* twiddle 65536))))))))
|
(string-match
|
||||||
;; ... file mode flags
|
"^[0-9]+\\([0-9][0-9][0-9][0-9][0-9]\\)\\'"
|
||||||
(setq res-filemodes (symbol-name (read (current-buffer))))
|
(car (cddr err))))
|
||||||
;; ... number links
|
(let* ((big (read (substring (car (cddr err)) 0
|
||||||
(setq res-numlinks (read (current-buffer)))
|
(match-beginning 1))))
|
||||||
;; ... uid and gid
|
(small (read (match-string 1 (car (cddr err)))))
|
||||||
(setq res-uid (read (current-buffer)))
|
(twiddle (/ small 65536)))
|
||||||
(setq res-gid (read (current-buffer)))
|
(cons (+ big twiddle)
|
||||||
(if (eq id-format 'integer)
|
(- small (* twiddle 65536))))))))
|
||||||
|
;; ... file mode flags
|
||||||
|
(setq res-filemodes (symbol-name (read (current-buffer))))
|
||||||
|
;; ... number links
|
||||||
|
(setq res-numlinks (read (current-buffer)))
|
||||||
|
;; ... uid and gid
|
||||||
|
(setq res-uid (read (current-buffer)))
|
||||||
|
(setq res-gid (read (current-buffer)))
|
||||||
|
(if (eq id-format 'integer)
|
||||||
|
(progn
|
||||||
|
(unless (numberp res-uid) (setq res-uid -1))
|
||||||
|
(unless (numberp res-gid) (setq res-gid -1)))
|
||||||
(progn
|
(progn
|
||||||
(unless (numberp res-uid) (setq res-uid -1))
|
(unless (stringp res-uid) (setq res-uid (symbol-name res-uid)))
|
||||||
(unless (numberp res-gid) (setq res-gid -1)))
|
(unless (stringp res-gid) (setq res-gid (symbol-name res-gid)))))
|
||||||
(progn
|
;; ... size
|
||||||
(unless (stringp res-uid) (setq res-uid (symbol-name res-uid)))
|
(setq res-size (read (current-buffer)))
|
||||||
(unless (stringp res-gid) (setq res-gid (symbol-name res-gid)))))
|
;; From the file modes, figure out other stuff.
|
||||||
;; ... size
|
(setq symlinkp (eq ?l (aref res-filemodes 0)))
|
||||||
(setq res-size (read (current-buffer)))
|
(setq dirp (eq ?d (aref res-filemodes 0)))
|
||||||
;; From the file modes, figure out other stuff.
|
;; If symlink, find out file name pointed to.
|
||||||
(setq symlinkp (eq ?l (aref res-filemodes 0)))
|
(when symlinkp
|
||||||
(setq dirp (eq ?d (aref res-filemodes 0)))
|
(search-forward "-> ")
|
||||||
;; If symlink, find out file name pointed to.
|
(setq res-symlink-target
|
||||||
(when symlinkp
|
(if (tramp-get-ls-command-with-quoting-style vec)
|
||||||
(search-forward "-> ")
|
(read (current-buffer))
|
||||||
(setq res-symlink-target
|
(buffer-substring (point) (point-at-eol)))))
|
||||||
(if (tramp-get-ls-command-with-quoting-style vec)
|
;; Return data gathered.
|
||||||
(read (current-buffer))
|
(list
|
||||||
(buffer-substring (point) (point-at-eol)))))
|
;; 0. t for directory, string (name linked to) for symbolic
|
||||||
;; Return data gathered.
|
;; link, or nil.
|
||||||
(list
|
(or dirp res-symlink-target)
|
||||||
;; 0. t for directory, string (name linked to) for symbolic
|
;; 1. Number of links to file.
|
||||||
;; link, or nil.
|
res-numlinks
|
||||||
(or dirp res-symlink-target)
|
;; 2. File uid.
|
||||||
;; 1. Number of links to file.
|
res-uid
|
||||||
res-numlinks
|
;; 3. File gid.
|
||||||
;; 2. File uid.
|
res-gid
|
||||||
res-uid
|
;; 4. Last access time, as a list of integers. Normally
|
||||||
;; 3. File gid.
|
;; this would be in the same format as `current-time', but
|
||||||
res-gid
|
;; the subseconds part is not currently implemented, and (0
|
||||||
;; 4. Last access time, as a list of integers. Normally this
|
;; 0) denotes an unknown time.
|
||||||
;; would be in the same format as `current-time', but the
|
;; 5. Last modification time, likewise.
|
||||||
;; subseconds part is not currently implemented, and (0 0)
|
;; 6. Last status change time, likewise.
|
||||||
;; denotes an unknown time.
|
'(0 0) '(0 0) '(0 0) ;CCC how to find out?
|
||||||
;; 5. Last modification time, likewise.
|
;; 7. Size in bytes (-1, if number is out of range).
|
||||||
;; 6. Last status change time, likewise.
|
res-size
|
||||||
'(0 0) '(0 0) '(0 0) ;CCC how to find out?
|
;; 8. File modes, as a string of ten letters or dashes as in ls -l.
|
||||||
;; 7. Size in bytes (-1, if number is out of range).
|
res-filemodes
|
||||||
res-size
|
;; 9. t if file's gid would change if file were deleted and
|
||||||
;; 8. File modes, as a string of ten letters or dashes as in ls -l.
|
;; recreated. Will be set in `tramp-convert-file-attributes'.
|
||||||
res-filemodes
|
t
|
||||||
;; 9. t if file's gid would change if file were deleted and
|
;; 10. Inode number.
|
||||||
;; recreated. Will be set in `tramp-convert-file-attributes'.
|
res-inode
|
||||||
t
|
;; 11. Device number. Will be replaced by a virtual device number.
|
||||||
;; 10. Inode number.
|
-1
|
||||||
res-inode
|
))))))
|
||||||
;; 11. Device number. Will be replaced by a virtual device number.
|
|
||||||
-1
|
|
||||||
)))))
|
|
||||||
|
|
||||||
(defun tramp-do-file-attributes-with-perl
|
(defun tramp-do-file-attributes-with-perl
|
||||||
(vec localname &optional id-format)
|
(vec localname &optional id-format)
|
||||||
|
@ -1785,14 +1785,6 @@ Several special characters do not work properly there."
|
|||||||
(file-truename tramp-test-temporary-file-directory) nil
|
(file-truename tramp-test-temporary-file-directory) nil
|
||||||
(string-match "^HP-UX" (tramp-get-connection-property v "uname" ""))))
|
(string-match "^HP-UX" (tramp-get-connection-property v "uname" ""))))
|
||||||
|
|
||||||
(defun tramp--test-darwin-p ()
|
|
||||||
"Check, whether the remote host runs Mac OS X.
|
|
||||||
Several special characters do not work properly there."
|
|
||||||
;; We must refill the cache. `file-truename' does it.
|
|
||||||
(with-parsed-tramp-file-name
|
|
||||||
(file-truename tramp-test-temporary-file-directory) nil
|
|
||||||
(string-match "^Darwin" (tramp-get-connection-property v "uname" ""))))
|
|
||||||
|
|
||||||
(defun tramp--test-check-files (&rest files)
|
(defun tramp--test-check-files (&rest files)
|
||||||
"Run a simple but comprehensive test over every file in FILES."
|
"Run a simple but comprehensive test over every file in FILES."
|
||||||
;; We must use `file-truename' for the temporary directory, because
|
;; We must use `file-truename' for the temporary directory, because
|
||||||
@ -2046,7 +2038,7 @@ Use the `ls' command."
|
|||||||
(file-name-coding-system 'utf-8))
|
(file-name-coding-system 'utf-8))
|
||||||
(tramp--test-check-files
|
(tramp--test-check-files
|
||||||
(unless (tramp--test-hpux-p) "Γυρίστε το Γαλαξία με Ώτο Στοπ")
|
(unless (tramp--test-hpux-p) "Γυρίστε το Γαλαξία με Ώτο Στοπ")
|
||||||
(unless (or (tramp--test-hpux-p) (tramp--test-darwin-p))
|
(unless (tramp--test-hpux-p)
|
||||||
"أصبح بوسعك الآن تنزيل نسخة كاملة من موسوعة ويكيبيديا العربية لتصفحها بلا اتصال بالإنترنت")
|
"أصبح بوسعك الآن تنزيل نسخة كاملة من موسوعة ويكيبيديا العربية لتصفحها بلا اتصال بالإنترنت")
|
||||||
"银河系漫游指南系列"
|
"银河系漫游指南系列"
|
||||||
"Автостопом по гала́ктике")))
|
"Автостопом по гала́ктике")))
|
||||||
|
Loading…
Reference in New Issue
Block a user