From 3b91eda6db03e373be4a1fae0af30553465fba03 Mon Sep 17 00:00:00 2001 From: Yorick Barbanneau Date: Wed, 12 Feb 2020 15:44:39 +0100 Subject: [PATCH] Error in download() bug resolved --- init.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/init.sh b/init.sh index c12304b..bcdcfab 100755 --- a/init.sh +++ b/init.sh @@ -124,11 +124,14 @@ download (){ # $2 : url # $3 : 1 if abort download if file exist printf "Downloading %s : " "$1" -http_response=$(wget --spider --server-response $2/$1 2>&1 | grep HTTP/ | tail -1 | awk ' { printf $2 }') -if [ $http_response -eq 200 ] +local url +local http_response +url="$2/$1" +http_response=$(wget --spider --server-response "$url" 2>&1 | grep HTTP/ | tail -1 | awk ' { printf $2 }') +if [ "$http_response" -eq 200 ] then - wget -c --progress=dot $2/$1 2>&1 | grep --line-buffered "[0-9]\{1,3\}%" -o | awk '{printf ("\b\b\b\b%4s", $1)}' - if [ $? -eq 0 ] + wget -c --progress=dot "$url" 2>&1 | grep --line-buffered "[0-9]\{1,3\}%" -o | awk '{printf ("\b\b\b\b%4s", $1)}' + if [ "$?" -eq 0 ] then printf " \b\b\b\b\b done\n " else