Compare commits

...

4 Commits

Author SHA1 Message Date
Justin
62f68959c7 Remove inline comment in misc/tools.func
Co-authored-by: Michel Roegl-Brunner <73236783+michelroegl-brunner@users.noreply.github.com>
2026-01-29 10:24:13 +01:00
Justin
f2a847ac81 Remove inline comment in misc/alpine-tools.func
Co-authored-by: Michel Roegl-Brunner <73236783+michelroegl-brunner@users.noreply.github.com>
2026-01-29 10:24:13 +01:00
justin
75898f4986 Add tail -1 before tr to use only the last value 2026-01-29 10:24:13 +01:00
justin
622fda4b32 Fix download_with_progress() content_length calc 2026-01-29 10:24:13 +01:00
2 changed files with 15 additions and 6 deletions

View File

@ -196,11 +196,17 @@ ensure_usr_local_bin_persist() {
download_with_progress() {
# $1 url, $2 dest
local url="$1" out="$2" cl
local url="$1" out="$2" content_length
need_tool curl pv || return 1
cl=$(curl -fsSLI "$url" 2>/dev/null | awk 'tolower($0) ~ /^content-length:/ {print $2}' | tr -d '\r')
if [ -n "$cl" ]; then
curl -fsSL "$url" | pv -s "$cl" >"$out" || {
content_length=$(
curl -fsSLI "$url" 2>/dev/null |
awk '(tolower($1) ~ /^content-length:/) && ($2 + 0 > 0) {print $2+0}' |
tail -1 | tr -cd '[:digit:]' || true
)
if [ -n "$content_length" ]; then
curl -fsSL "$url" | pv -s "$content_length" >"$out" || {
msg_error "Download failed: $url"
return 1
}

View File

@ -1692,7 +1692,11 @@ function download_with_progress() {
# Content-Length aus HTTP-Header holen
local content_length
content_length=$(curl -fsSLI "$url" | awk '/Content-Length/ {print $2}' | tr -d '\r' || true)
content_length=$(
curl -fsSLI "$url" 2>/dev/null |
awk '(tolower($1) ~ /^content-length:/) && ($2 + 0 > 0) {print $2+0}' |
tail -1 | tr -cd '[:digit:]' || true
)
if [[ -z "$content_length" ]]; then
if ! curl -fL# -o "$output" "$url"; then
@ -6205,4 +6209,3 @@ function fetch_and_deploy_archive() {
msg_ok "Successfully deployed archive to $directory"
return 0
}