From de51551caa223c2d070f9c11ce0e3624b8d965a6 Mon Sep 17 00:00:00 2001 From: FriendlyNeighborhoodShane Date: Sun, 27 Jun 2021 12:39:19 +0530 Subject: [PATCH] update.sh: user curl with -f for error handling --- res/util/func-resdl.sh | 2 +- update.sh | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/res/util/func-resdl.sh b/res/util/func-resdl.sh index c892689..3f24bd4 100755 --- a/res/util/func-resdl.sh +++ b/res/util/func-resdl.sh @@ -134,7 +134,7 @@ checkwhitelist() { echo " "; echo " - Getting priv-app permissions..."; - curl -L "$privpermurl" -o "$tmpdir/tmppage" || { echo "ERROR: Android permission docpage failed to download"; return 1; } + curl -fL "$privpermurl" -o "$tmpdir/tmppage" || { echo "ERROR: Android permission docpage failed to download"; return 1; } lines="$(grep -nE "" "$tmpdir/tmppage" | grep -A1 "ENUM CONSTANTS DETAIL" | sed "s|:| |g" | select_word 1)"; for line in $lines; do diff --git a/update.sh b/update.sh index c677bf2..34f1e66 100755 --- a/update.sh +++ b/update.sh @@ -98,7 +98,7 @@ for repo in $(echo "$stuff_repo" | select_word 1); do [ "$repourl" ] || { echo "ERROR: Repo $repo has no URL"; continue; } echo " -- REPO: Downloading repo $repo"; echo " ---- Downloading $repourl"; - curl -L "$repourl/index-v1.jar" -o "$tmpdir/repos/$repo.jar" || { echo "ERROR: Repo $repo failed to download"; continue; } + curl -fL "$repourl/index-v1.jar" -o "$tmpdir/repos/$repo.jar" || { echo "ERROR: Repo $repo failed to download"; continue; } unzip -oq "$tmpdir/repos/$repo.jar" "index-v1.json" -d "$tmpdir/repos/" || { echo "ERROR: Repo $repo failed to unzip"; continue; } mv -f "$tmpdir/repos/index-v1.json" "$tmpdir/repos/$repo.json" || { echo "ERROR: Repo $repo failed to rename"; continue; } done; @@ -126,13 +126,13 @@ for object in $(echo "$stuff_download" | select_word 1); do ;; github) echo " ---- Getting GitHub URL for $object"; - objecturl="$(curl -Ls "https://api.github.com/repos/$objectpath/releases" | jq -r '.[].assets[].browser_download_url' | grep "$objectarg$" | head -n1)"; + objecturl="$(curl -fLs "https://api.github.com/repos/$objectpath/releases" | jq -r '.[].assets[].browser_download_url' | grep "$objectarg$" | head -n1)"; ;; gitlab) objectid="$(echo "$objectpath" | jq -Rr "@uri")"; [ "$objectid" ] || { echo "ERROR: $object gitlab project ID not found"; continue; } echo " ---- Getting GitLab URL for $object"; - objectupload="$(curl -Ls "https://gitlab.com/api/v4/projects/$objectid/repository/tags" | jq -r '.[].release.description' | grep -oE "(/uploads/[^()]*$objectarg)" | head -n1 | tr -d "()")"; + objectupload="$(curl -fLs "https://gitlab.com/api/v4/projects/$objectid/repository/tags" | jq -r '.[].release.description' | grep -oE "(/uploads/[^()]*$objectarg)" | head -n1 | tr -d "()")"; [ "$objectupload" ] || { echo "ERROR: $object gitlab project upload not found"; continue; } objecturl="https://gitlab.com/$objectpath$objectupload"; ;; @@ -164,7 +164,7 @@ for object in $(echo "$stuff_download" | select_word 1); do objectname="$(basename "$objecturl")"; objectfile="$tmpdir/$objectname"; echo " ---- Downloading $objecturl"; - curl -L "$objecturl" -o "$objectfile" || { echo "ERROR: $object failed to download"; continue; } + curl -fL "$objecturl" -o "$objectfile" || { echo "ERROR: $object failed to download"; continue; } objectcksum="$(cksum "$objectfile" | select_word 1)"; echo "FILE: $object, URL: $objecturl, CKSUM: $objectcksum;" >> "$updatelog"; ;;