From 279b05b5e476ab8ec05567a00c7bbea5c52aaf47 Mon Sep 17 00:00:00 2001 From: shuki Date: Fri, 6 Mar 2026 07:12:18 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20disk=20usage=20parsing=20=E2=80=94=20use?= =?UTF-8?q?=20grep=20instead=20of=20df=20--output?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit df --output=pcent is not available on all systems. Use grep -oP to extract the percentage field from standard df output. Co-Authored-By: Claude Opus 4.6 --- lib/remotes.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/remotes.sh b/lib/remotes.sh index e0557ca..f3d67d1 100644 --- a/lib/remotes.sh +++ b/lib/remotes.sh @@ -294,22 +294,23 @@ get_target_remotes() { # Returns 0 (unknown) on unsupported remote types. remote_disk_usage_pct() { local base="${REMOTE_BASE:-/}" - local df_out="" + local df_line="" case "${REMOTE_TYPE:-ssh}" in ssh) - df_out=$(remote_exec "df --output=pcent '$base' 2>/dev/null | tail -1" 2>/dev/null) || return 1 + df_line=$(remote_exec "df '$base' 2>/dev/null | tail -1") || return 1 ;; local) - df_out=$(df --output=pcent "$base" 2>/dev/null | tail -1) || return 1 + df_line=$(df "$base" 2>/dev/null | tail -1) || return 1 ;; *) echo "0" return 0 ;; esac - # Strip whitespace and % sign - df_out="${df_out// /}" - echo "${df_out%%%}" + # Extract the percentage field (e.g. "73%") — grep for number followed by % + local pct_raw + pct_raw=$(echo "$df_line" | grep -oP '[0-9]+%' | head -1) || return 1 + echo "${pct_raw%%%}" } # Check remote disk space. Fail if usage >= threshold (default 95%).