From 0bd70d0d0f378f30d9effc49b9ff68baa3fa3066 Mon Sep 17 00:00:00 2001 From: Lucien Cartier-Tilet Date: Fri, 19 Nov 2021 18:38:24 +0100 Subject: [PATCH] Fix df-related code --- eshell-info-banner.el | 45 ++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/eshell-info-banner.el b/eshell-info-banner.el index 8b96617..12ff6de 100644 --- a/eshell-info-banner.el +++ b/eshell-info-banner.el @@ -301,28 +301,29 @@ Common function between otherwise differ solely on the position of the mount point in the partition list. Its position is given by the argument MOUNT-POSITION." - (let ((partitions (split-string (eshell-info-banner--shell-command-to-string "df -lH") - (regexp-quote "\n") - t))) - (seq-filter (lambda (partition) - (let* ((partition (split-string partition " " t)) - (filesystem (nth 0 partition)) - (size (nth 1 partition)) - (used (nth 2 partition)) - (percent (nth 4 partition)) - (mount (nth mount-position partition))) - (unless (seq-some (lambda (prefix) - (string-prefix-p prefix filesystem t)) - eshell-info-banner-partition-prefixes) - (make-eshell-info-banner--mounted-partitions - :path (if (> (length mount) eshell-info-banner-shorten-path-from) - (eshell-info-banner--abbr-path mount t) - mount) - :size size - :used used - :percent (string-to-number - (string-trim-left percent (regexp-quote "%"))))))) - partitions))) + (let ((partitions (cdr (split-string (eshell-info-banner--shell-command-to-string "df -lH") + (regexp-quote "\n") + t)))) + (cl-remove-if #'null + (mapcar (lambda (partition) + (let* ((partition (split-string partition " " t)) + (filesystem (nth 0 partition)) + (size (nth 1 partition)) + (used (nth 2 partition)) + (percent (nth 4 partition)) + (mount (nth mount-position partition))) + (when (seq-some (lambda (prefix) + (string-prefix-p prefix filesystem t)) + eshell-info-banner-partition-prefixes) + (make-eshell-info-banner--mounted-partitions + :path (if (> (length mount) eshell-info-banner-shorten-path-from) + (eshell-info-banner--abbr-path mount t) + mount) + :size size + :used used + :percent (string-to-number + (string-trim-left percent (regexp-quote "%"))))))) + partitions)))) (defun eshell-info-banner--get-mounted-partitions-gnu () "Detect mounted partitions on a Linux system.