GNU and Darwin df shows space in 1K blocks by default

Als use the "-k" parameter to enforce this block size, so that the
command does not depend on environment variables (POSIXLY_CORRECT and
BLOCKSIZE).

Fixes #21
This commit is contained in:
Juergen Hoetzel 2022-05-14 15:17:40 +02:00 committed by Lucien Cartier-Tilet
parent 53fc69b871
commit 8c6e37cc61

View File

@ -365,15 +365,15 @@ Common function between
otherwise differ solely on the position of the mount point in the otherwise differ solely on the position of the mount point in the
partition list. Its position is given by the argument partition list. Its position is given by the argument
MOUNT-POSITION." MOUNT-POSITION."
(let ((partitions (cdr (split-string (eshell-info-banner--shell-command-to-string "df -l") (let ((partitions (cdr (split-string (eshell-info-banner--shell-command-to-string "df -l -k")
(regexp-quote "\n") (regexp-quote "\n")
t)))) t))))
(cl-remove-if #'null (cl-remove-if #'null
(mapcar (lambda (partition) (mapcar (lambda (partition)
(let* ((partition (split-string partition " " t)) (let* ((partition (split-string partition " " t))
(filesystem (nth 0 partition)) (filesystem (nth 0 partition))
(size (string-to-number (nth 1 partition))) (size (* (string-to-number (nth 1 partition)) 1024))
(used (string-to-number (nth 2 partition))) (used (* (string-to-number (nth 2 partition)) 1024))
(percent (nth 4 partition)) (percent (nth 4 partition))
(mount (nth mount-position partition))) (mount (nth mount-position partition)))
(when (seq-some (lambda (prefix) (when (seq-some (lambda (prefix)