From 610711747339162004801b28a08cf81c33d65e48 Mon Sep 17 00:00:00 2001 From: Francis Rowe Date: Sat, 29 Aug 2015 21:44:02 +0100 Subject: download script: re-factor. only have 1 loop for downloading --- download | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'download') diff --git a/download b/download index 4860a583..bed0b647 100755 --- a/download +++ b/download @@ -24,20 +24,18 @@ set -u -e download=./resources/scripts/helpers/download -availableprogrammes=$(ls ${download}/) +programmes="none" case ${@} in all) - for programme in ${availableprogrammes}; do - ${download}/${programme} - done + programmes=$(ls ${download}/) ;; list) - printf "possible values for 'programmes':\nall:\n%s\n\n" "${availableprogrammes}" + printf "possible values for 'programmes':\nall:\n%s\n\n" "${programmes}" ;; help) printf "%s\n\n" "./download programme(s) # programmes are space separated, if specifing multiple programmes" - printf "possible values for 'programmes':\nall:\n%s\n\n" "${availableprogrammes}" + printf "possible values for 'programmes':\nall:\n%s\n\n" "${programmes}" printf "Example (download everything): ./download all\n" printf "Example (download flashrom): ./download flashrom\n" printf "Example (download coreboot): ./download coreboot\n" @@ -46,11 +44,12 @@ case ${@} in ;; *) for programme in ${@}; do - echo ${availableprogrammes} | grep -wq ${programme} || (printf "ERROR: Invalid programme '${programme}'. See ./download help.\n"; exit 1) - done - for programme in ${@}; do - ${download}/${programme} + echo ${programmes} | grep -wq ${programme} || (printf "ERROR: Invalid programme '${programme}'. See ./download help.\n"; exit 1) done + programmes=${@} ;; esac -# ------------------- DONE ---------------------- + +for programme in ${programmes}; do + ${download}/${programme} +done -- cgit v1.2.3-70-g09d2