From b32cf97e95ba1b897379ae65515fad5ba51a6fd1 Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Thu, 29 Aug 2024 14:26:28 -0400 Subject: [PATCH] Add require function to copy.sh Add requirements for jq and gron - used by mirror.sh --- copy.sh | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/copy.sh b/copy.sh index 7f40597..5f0d8ab 100755 --- a/copy.sh +++ b/copy.sh @@ -6,15 +6,21 @@ SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) FAKE_HOME="$SCRIPT_DIR/fake_home" export f="$FAKE_HOME" -if ! command -v wget &> /dev/null; then - echo "wget must be installed!" - exit 1 -fi +function require { + local success=true + for comm in "$@"; do + if ! command -v "$comm" &> /dev/null; then + echo "$comm must be installed!" + success=false + fi + done + if ! $success; then + echo "Missing copy.sh dependencies! Exiting!" + exit 1 + fi +} -if ! command -v curl &> /dev/null; then - echo "curl must be installed!" - exit 1 -fi +require git wget curl find jq gron mkdir -p "$HOME/.tmp" || exit 1