From f59a418c208a8ca6f5ed204164edb73c76896334 Mon Sep 17 00:00:00 2001 From: SgtBatten Date: Tue, 23 Apr 2019 08:03:47 +1000 Subject: [PATCH] Correctly display Latest Version Latest version displayed properly when user is updating to other than latest version --- update.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/update.sh b/update.sh index 12cecae..c587b7a 100644 --- a/update.sh +++ b/update.sh @@ -250,10 +250,13 @@ fi version=$(echo $1 | rev | cut -d'/' -f 1 | rev | sed 's/\(.*\).zip/\1/' | sed 's/\(.*\).jar/\1/' | rev | sed 's/\(.*\)-reliarTtiforP/\1/' | rev) download=$1 +### Get latest Version number +latest=$(curl -s https://api.github.com/repos/taniman/profit-trailer/releases | grep tag_name | cut -d '"' -f 4 | sed -n '1p') + ### If no variable is passed search on github ### if [[ ! $1 ]]; then ### Find Latest Version of PT and its download url ### -version=$(curl -s https://api.github.com/repos/taniman/profit-trailer/releases | grep tag_name | cut -d '"' -f 4 | sed -n '1p') +version=$latest download=$(curl -s https://api.github.com/repos/taniman/profit-trailer/releases | grep browser_download_url | cut -d '"' -f 4 | sed -n '1p') fi @@ -262,7 +265,9 @@ echo "##################################################" echo " Update" echo "##################################################" echo $(tput sgr0) -echo "Latest release is version $(tput setaf 6) $version $(tput sgr0)" +echo "Latest release is version $(tput setaf 6) $latest $(tput sgr0)" +if [[$version != $latest]] + echo "Updating to version $(tput setaf 6) $version $(tput sgr0)" echo read -p "Do you want to continue? (Y/N) " continue echo