From d9ac29388750327d72674951f11085d4e3578fc7 Mon Sep 17 00:00:00 2001 From: z3rOR0ne Date: Wed, 27 Jul 2022 12:45:36 -0700 Subject: [PATCH] :recycle: Refactgored where dependency check for curl is --- scripts/bgit | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/scripts/bgit b/scripts/bgit index b4a6aa6e..f3e232d1 100755 --- a/scripts/bgit +++ b/scripts/bgit @@ -16,28 +16,13 @@ txtyellow=${txtbld}$(tput setaf 3) txtwhite=${txtbld}$(tput setaf 7) # Dependency check -dependencies=("git" "curl") -numdependencies=2 -missingdependencies=0 -for ((i = 0; i < numdependencies; i++)) ; -do - if ! command -v "${dependencies[$i]}" &> /dev/null - then - echo "${txtred}dependency not met: ${dependencies[$i]}${txtwhite}" - missingdependencies=$((missingdependencies+1)) - fi -done - -if [ $missingdependencies -gt 0 ] ; +if ! command -v git &> /dev/null then - echo "${txtred}Please install needed dependencies${txtwhite}" + echo "${txtred}dependency not met: git" + echo "Please install needed depndencies${txtwhite}" exit 1 fi -# Time to rewrite new version: -# Features to include: -# setopts/getopts flags for init,delete repos ( see git_create...txt file in notes) - # Intro Prompt echo "${txtblue}bgit: a handy shell script for automating simple git inits/commits" @@ -212,10 +197,21 @@ if [ $numrepos -eq 0 ] ; then if [[ $crepo == 'y' || $crepo == 'yes' ]] ; then # Dependency check - if ! command -v xclip &> /dev/null + dependencies=("xclip" "curl") + numdependencies=2 + missingdependencies=0 + for ((i = 0; i < numdependencies; i++)) ; + do + if ! command -v "${dependencies[$i]}" &> /dev/null + then + echo "${txtred}dependency not met: ${dependencies[$i]}${txtwhite}" + missingdependencies=$((missingdependencies+1)) + fi + done + + if [ $missingdependencies -gt 0 ] ; then - echo "${txtred}dependency not met: xclip" - echo "Please install needed depndencies${txtwhite}" + echo "${txtred}Please install needed dependencies${txtwhite}" exit 1 fi