From b5ec9eda3bf47c9b5b79fbc3311372d27ef71a8c Mon Sep 17 00:00:00 2001 From: CaptainArk Date: Thu, 19 Apr 2018 23:16:51 +0200 Subject: [PATCH] check for dependencies before doing stuff --- github2email.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/github2email.sh b/github2email.sh index d9e1f4f..7ecccd8 100755 --- a/github2email.sh +++ b/github2email.sh @@ -13,6 +13,14 @@ GitHubApi="https://api.github.com/users/${UserName}/starred" LastPage="$(curl -I ${GitHubApi} | grep -Eo 'page=[[:digit:]]+' | tail -n1)" TempFile=$(mktemp -t github2email.sh.XXXXXXXXXX) +# Checking for dependencies +for Dependencies in curl jq r2e; do + if [[ ! -x $(which ${Dependencies}) ]]; then + echo "${Dependencies} is required to run to script. Exiting..." + exit 2 + fi +done + for StarPages in $(seq 1 ${LastPage#*=}); do curl -s "${GitHubApi}?page=${StarPages}" | jq -r '.[] | .name + "," + .html_url' | sed 's#$#/releases.atom#' >> ${TempFile} done @@ -23,14 +31,6 @@ if [[ ! -s ${TempFile} ]]; then exit 2 fi -# Checking for dependencies -for Dependencies in curl jq r2e; do - if [[ ! -x $(which ${Dependencies}) ]]; then - echo "${Dependencies} is required to run to script. Exiting..." - exit 2 - fi -done - # Doing our magic stuff that does cool shit for Star in $(cat ${TempFile}); do ProjectName=${Star%,*}