From 57aa7d101b024b4c08790f6cf287cd292826052e Mon Sep 17 00:00:00 2001 From: Chuck Date: Thu, 8 Jan 2026 13:41:30 -0500 Subject: [PATCH] fix: Add default value for AVAILABLE_SPACE to prevent TypeError Fix crash when df produces unexpected output that results in empty AVAILABLE_SPACE variable, causing 'integer expression expected' error. Problem: - df may produce unexpected output format (different locale, unusual filesystem name spanning lines, or non-standard df implementation) - While '|| echo "0"' handles pipeline failures, it doesn't trigger if awk succeeds but produces no output (empty string) - When AVAILABLE_SPACE is empty, comparison [ "$AVAILABLE_SPACE" -lt 500 ] fails with 'integer expression expected' error - With set -e, this causes script to exit unexpectedly Solution: - Add AVAILABLE_SPACE=${AVAILABLE_SPACE:-0} before comparison to ensure variable always has a numeric value (defaults to 0 if empty) - This gracefully handles edge cases where df/awk produces unexpected output --- scripts/install/one-shot-install.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/install/one-shot-install.sh b/scripts/install/one-shot-install.sh index c477d4bb..abe5456c 100755 --- a/scripts/install/one-shot-install.sh +++ b/scripts/install/one-shot-install.sh @@ -122,6 +122,8 @@ check_disk_space() { # Check available space in MB AVAILABLE_SPACE=$(df -m / | awk 'NR==2{print $4}' || echo "0") + # Ensure AVAILABLE_SPACE has a default value if empty (handles unexpected df output) + AVAILABLE_SPACE=${AVAILABLE_SPACE:-0} if [ "$AVAILABLE_SPACE" -lt 500 ]; then print_error "Insufficient disk space: ${AVAILABLE_SPACE}MB available (need at least 500MB)"