From 4df2949bc0a56056351d9b1534ad5b825b75b3be Mon Sep 17 00:00:00 2001 From: musqz Date: Sat, 6 Jun 2026 12:08:25 +0200 Subject: [PATCH] fix(quickget): emit curl progress and size to stdout when piped When stdout is not a TTY, GUI frontends and scripts receive no download feedback because curl suppresses its progress output. This fix adds two behaviours when stdout is a pipe: - A HEAD request fetches the correct total file size (Content-Length) and emits it as "content-length: N" to stdout before downloading. Using a separate HEAD request avoids the ambiguity of --dump-header with redirects or 206 resume responses. - --stderr - is added to the curl download so the --progress-bar output is written to stdout, letting callers parse real-time percentage. Normal terminal behaviour is completely unchanged. Fixes #1921 Co-Authored-By: Claude Sonnet 4.6 --- quickget | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/quickget b/quickget index 5044af7..aac5410 100755 --- a/quickget +++ b/quickget @@ -1464,7 +1464,17 @@ function web_get() { echo "- URL: ${URL}" fi - if ! curl --disable --progress-bar --location --output "${DIR}/${FILE}" --continue-at - --user-agent "${USER_AGENT}" "${HEADERS[@]}" -- "${URL}"; then + local PIPE_OPTS=() + if [ ! -t 1 ]; then + local CONTENT_LENGTH + CONTENT_LENGTH=$(curl --disable --silent --head --location \ + --write-out '%{content_length_download}' --output /dev/null \ + --user-agent "${USER_AGENT}" "${HEADERS[@]}" -- "${URL}" 2>/dev/null) + [ -n "${CONTENT_LENGTH}" ] && echo "content-length: ${CONTENT_LENGTH}" + PIPE_OPTS=("--stderr" "-") + fi + + if ! curl --disable --progress-bar "${PIPE_OPTS[@]}" --location --output "${DIR}/${FILE}" --continue-at - --user-agent "${USER_AGENT}" "${HEADERS[@]}" -- "${URL}"; then echo "ERROR! Failed to download ${URL} with curl." rm -f "${DIR}/${FILE}" exit 1