🐛 Fix curl broken-pipe error in battery update version check

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.
This commit is contained in:
Sir Claudius
2026-02-25 11:02:23 +00:00
parent d3bbb1814f
commit 0c2ca3a9e4

View File

@@ -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"
}
## ###############