mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-15 18:40:39 -08:00
Use the Lisp implemention of "du" in Eshell when querying remote dirs
* lisp/eshell/em-unix.el (eshell/du): If all directories are local, use the external "du" instead.
This commit is contained in:
parent
f6a63e4b44
commit
f26fb25ec8
1 changed files with 57 additions and 60 deletions
|
|
@ -910,17 +910,7 @@ external command."
|
|||
|
||||
(defun eshell/du (&rest args)
|
||||
"Implementation of \"du\" in Lisp, passing ARGS."
|
||||
(setq args (if args
|
||||
(eshell-stringify-list (flatten-tree args))
|
||||
'(".")))
|
||||
(let ((ext-du (eshell-search-path "du")))
|
||||
(if (and ext-du
|
||||
(not (catch 'have-ange-path
|
||||
(dolist (arg args)
|
||||
(if (string-equal
|
||||
(file-remote-p (expand-file-name arg) 'method) "ftp")
|
||||
(throw 'have-ange-path t))))))
|
||||
(throw 'eshell-external (eshell-external-command ext-du args))
|
||||
(let ((original-args args))
|
||||
(eshell-eval-using-options
|
||||
"du" args
|
||||
'((?a "all" nil show-all
|
||||
|
|
@ -952,25 +942,32 @@ external command."
|
|||
:external "du"
|
||||
:usage "[OPTION]... FILE...
|
||||
Summarize disk usage of each FILE, recursively for directories.")
|
||||
;; If possible, use the external "du" command.
|
||||
(when-let* (((not (seq-some
|
||||
(lambda (i) (and (stringp i) (file-remote-p i)))
|
||||
args)))
|
||||
(ext-du (eshell-search-path "du")))
|
||||
(throw 'eshell-external (eshell-external-command ext-du original-args)))
|
||||
(unless by-bytes
|
||||
(setq block-size (or block-size 1024)))
|
||||
(if (and max-depth (stringp max-depth))
|
||||
(when (stringp block-size)
|
||||
(setq block-size (string-to-number block-size)))
|
||||
(when (stringp max-depth)
|
||||
(setq max-depth (string-to-number max-depth)))
|
||||
;; filesystem support means nothing under Windows
|
||||
(if (eshell-under-windows-p)
|
||||
;; Filesystem support means nothing under MS-Windows.
|
||||
(when (eshell-under-windows-p)
|
||||
(setq only-one-filesystem nil))
|
||||
(let ((size 0.0))
|
||||
(while args
|
||||
(if only-one-filesystem
|
||||
(dolist (arg (or args '(".")))
|
||||
(when only-one-filesystem
|
||||
(setq only-one-filesystem
|
||||
(file-attribute-device-number (eshell-file-attributes
|
||||
(file-name-as-directory (car args))))))
|
||||
(file-attribute-device-number
|
||||
(eshell-file-attributes (file-name-as-directory arg)))))
|
||||
(setq size (+ size (eshell-du-sum-directory
|
||||
(directory-file-name (car args)) 0)))
|
||||
(setq args (cdr args)))
|
||||
(directory-file-name arg) 0))))
|
||||
(if grand-total
|
||||
(eshell-print (concat (eshell-du-size-string size)
|
||||
"total\n"))))))))
|
||||
"total\n")))))))
|
||||
|
||||
(put 'eshell/du 'eshell-filename-arguments t)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue