From 75898f498697d40e1ff4b90db3f9a3098758fd70 Mon Sep 17 00:00:00 2001 From: justin Date: Tue, 27 Jan 2026 11:30:26 -0500 Subject: [PATCH] Add tail -1 before tr to use only the last value --- misc/alpine-tools.func | 4 ++-- misc/tools.func | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/misc/alpine-tools.func b/misc/alpine-tools.func index a830c220c..035565194 100644 --- a/misc/alpine-tools.func +++ b/misc/alpine-tools.func @@ -201,10 +201,10 @@ download_with_progress() { content_length=$( curl -fsSLI "$url" 2>/dev/null | - # May return multiple values on redirect. i.e., 0 and content-length + # May return multiple values on redirect. i.e., 0 and actual content-length value # Cast $2 to int by adding 0 to it awk '(tolower($1) ~ /^content-length:/) && ($2 + 0 > 0) {print $2+0}' | - tr -cd '[:digit:]' || true + tail -1 | tr -cd '[:digit:]' || true ) if [ -n "$content_length" ]; then diff --git a/misc/tools.func b/misc/tools.func index 44484ae5b..18602dc85 100644 --- a/misc/tools.func +++ b/misc/tools.func @@ -1694,10 +1694,10 @@ function download_with_progress() { local content_length content_length=$( curl -fsSLI "$url" 2>/dev/null | - # May return multiple values on redirect. i.e., 0 and content_length + # May return multiple values on redirect. i.e., 0 and actual content-length value # Add 0 to $2 to cast it to int awk '(tolower($1) ~ /^content-length:/) && ($2 + 0 > 0) {print $2+0}' | - tr -cd '[:digit:]' || true + tail -1 | tr -cd '[:digit:]' || true ) if [[ -z "$content_length" ]]; then