From ccae8451c36c7b2c596a586520a48f750c4a1709 Mon Sep 17 00:00:00 2001 From: shuki Date: Fri, 6 Mar 2026 07:13:46 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20remote=5Fdisk=5Finfo=5Fshort=20=E2=80=94?= =?UTF-8?q?=20parse=20df=20on=20remote=20side?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move awk parsing to the remote to avoid SSH output encoding issues that caused empty fields when parsing locally. Co-Authored-By: Claude Opus 4.6 --- lib/remotes.sh | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/lib/remotes.sh b/lib/remotes.sh index f3d67d1..75749fc 100644 --- a/lib/remotes.sh +++ b/lib/remotes.sh @@ -330,28 +330,24 @@ check_remote_disk_space() { return 0 } -# Compact one-line disk info: "USED/TOTAL (FREE free)" +# Compact one-line disk info: "USED/TOTAL (FREE free) PCT" +# Parsing is done on the remote/local side to avoid SSH output issues. remote_disk_info_short() { local base="${REMOTE_BASE:-/}" - local df_out="" + local cmd="df -h '$base' 2>/dev/null | awk 'NR>1{printf \"%s/%s (%s free) %s\", \$3, \$2, \$4, \$5}'" + local result="" case "${REMOTE_TYPE:-ssh}" in ssh) - df_out=$(remote_exec "df -h '$base' 2>/dev/null | tail -1") || return 1 + result=$(remote_exec "$cmd") || return 1 ;; local) - df_out=$(df -h "$base" 2>/dev/null | tail -1) || return 1 + result=$(eval "$cmd") || return 1 ;; *) echo "N/A" return 0 ;; esac - # df output: Filesystem Size Used Avail Use% Mount - local size used avail pct - size=$(echo "$df_out" | awk '{print $2}') - used=$(echo "$df_out" | awk '{print $3}') - avail=$(echo "$df_out" | awk '{print $4}') - pct=$(echo "$df_out" | awk '{print $5}') - echo "${used}/${size} (${avail} free) ${pct}" + echo "${result:-N/A}" }