From 0c2ca3a9e4ed3f27bdd73bbb61c82418bce257a4 Mon Sep 17 00:00:00 2001 From: Sir Claudius Date: Wed, 25 Feb 2026 11:02:23 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20curl=20broken-pipe=20error?= =?UTF-8?q?=20in=20battery=20update=20version=20check?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Piping curl directly into grep -q caused curl error 56 (failure writing output) because grep exits on first match while curl is still streaming. Download the remote script into a variable first, then grep it. Bump version to v1.3.3. --- battery.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/battery.sh b/battery.sh index 2bbc109..1bed17a 100755 --- a/battery.sh +++ b/battery.sh @@ -4,7 +4,7 @@ ## Update management ## variables are used by this binary as well at the update script ## ############### -BATTERY_CLI_VERSION="v1.3.2" +BATTERY_CLI_VERSION="v1.3.3" # If a script may run as root: # - Reset PATH to safe defaults at the very beginning of the script. @@ -536,8 +536,13 @@ function fixup_installation_owner_mode() { function is_latest_version_installed() { # Check if content is reachable first with HEAD request curl -sSI "$github_url_battery_sh" &>/dev/null || return 0 - # Start downloading and check version - curl -sS "$github_url_battery_sh" 2>/dev/null | grep -q "$BATTERY_CLI_VERSION" + + # Download the remote script then check if our version string is present. + # Note: piping curl directly into grep -q causes a broken-pipe error (curl error 56) + # because grep -q exits on first match while curl is still writing. + local remote_script + remote_script="$(curl -sS "$github_url_battery_sh" 2>/dev/null)" + echo "$remote_script" | grep -q "$BATTERY_CLI_VERSION" } ## ###############