@@ -165,9 +165,9 @@ shutdown() {
165165 # If we are exiting normally, jump back to the beginning of the line
166166 # and clear it. Otherwise, print a newline.
167167 if [ " $status " -eq 0 ]; then
168- printf " \x1B[0G\x1B[0K" >&4
168+ printf ' %b ' " \x1B[0G\x1B[0K" >&4
169169 else
170- printf ' \n ' >&4
170+ printf ' %s\n ' ' ' >&4
171171 fi
172172
173173 # stat="$(stcat "$statusfile")"
@@ -240,7 +240,7 @@ print_progress() {
240240 if [ " $percent_last " = " $percent " ]; then
241241 true " $BASH_SOURCE INFO: percentage number unchanged. Not re-drawing progress bar to avoid flicker."
242242 else
243- draw_progress_bar " $percent "
243+ draw_progress_bar " $percent " >&4
244244 if [ " $CURL_PRGRS_EXEC " = " " ]; then
245245 true " $BASH_SOURCE INFO: CURL_PRGRS_EXEC is empty. Not executing CURL_PRGRS_EXEC."
246246 else
@@ -262,7 +262,7 @@ curl_exit() {
262262 return 0
263263 fi
264264 : " ${curl_pid:= " " } "
265- if [ " $curl_pid " = " " ]; then
265+ if [ " $curl_pid " ! = " " ]; then
266266 if kill -0 -- " $curl_pid " 2> /dev/null; then
267267 kill -s SIGKILL -- " $curl_pid " & > /dev/null || true
268268 fi
@@ -276,19 +276,20 @@ curl_download() {
276276 $CURL --no-progress-meter " $@ " &
277277 curl_pid=" $! "
278278
279+ # # Additional validation.
280+ # # Already validated earlier, but:
281+ # # /usr/libexec/helper-scripts/curl-prgrs: line 266: [: : integer expression expected
282+ if ! is_whole_number " $curl_prgrs_content_length " ; then
283+ curl_exit 116
284+ fi
285+
279286 while true ; do
280287 if [ -f " $CURL_OUT_FILE " ]; then
281288 size_file_downloaded_bytes=" $( stat -c " %s" " $CURL_OUT_FILE " ) "
282289
283290 if ! is_whole_number " $size_file_downloaded_bytes " ; then
284291 curl_exit 113
285292 fi
286- # # Additional validation.
287- # # Already validated earlier, but:
288- # # /usr/libexec/helper-scripts/curl-prgrs: line 266: [: : integer expression expected
289- if ! is_whole_number " $curl_prgrs_content_length " ; then
290- curl_exit 116
291- fi
292293
293294 true " size_file_downloaded_bytes: $size_file_downloaded_bytes "
294295 true " CURL_PRGRS_MAX_FILE_SIZE_BYTES: $CURL_PRGRS_MAX_FILE_SIZE_BYTES "
@@ -305,7 +306,7 @@ curl_download() {
305306 if [ " $curl_prgrs_print_progress " = " yes" ]; then
306307 # # Need to print to stderr to avoid confusing the stdout output of this command.
307308 # stecho "$BASH_SOURCE INFO: print_progress '$size_file_downloaded_bytes' '$curl_prgrs_content_length'" >&2
308- print_progress " $size_file_downloaded_bytes " " $curl_prgrs_content_length " >&4
309+ print_progress " $size_file_downloaded_bytes " " $curl_prgrs_content_length "
309310 fi
310311 fi
311312
@@ -400,7 +401,7 @@ main() {
400401 # # Reset from previews invocation of curl_download, which calls print_progress.
401402 percent_last=" "
402403
403- true " $BASH_SOURCE INFO: Header downloaded done."
404+ true " $BASH_SOURCE INFO: Header download done."
404405
405406 if ! is_whole_number " $curl_prgrs_content_length " ; then
406407 curl_exit 116
@@ -412,10 +413,9 @@ main() {
412413 # # If attempting to refactor this, make sure signal sigterm stops downloads.
413414 header_download=" false" curl_download " $@ " &
414415
415- true " $BASH_SOURCE INFO: File download done."
416-
417416 wait_exit_code=0
418417 wait " $! " & > /dev/null || { wait_exit_code=$? ; true ; };
418+ true " $BASH_SOURCE INFO: File download done."
419419 true " $BASH_SOURCE INFO: END."
420420 exit " $wait_exit_code "
421421}
0 commit comments