diff options
author | Francis Rowe <info@gluglug.org.uk> | 2015-06-26 23:03:12 (EDT) |
---|---|---|
committer | Francis Rowe <info@gluglug.org.uk> | 2015-06-26 23:03:12 (EDT) |
commit | d7718287d29e1d96c382a0ce262bc725de85628f (patch) | |
tree | e44ef72cd7caf904c29c997493381793c5d4c132 | |
parent | 2f72e90c475f8e3ceeeb1c4ea067798d39c522ce (diff) | |
download | libreboot-d7718287d29e1d96c382a0ce262bc725de85628f.zip libreboot-d7718287d29e1d96c382a0ce262bc725de85628f.tar.gz libreboot-d7718287d29e1d96c382a0ce262bc725de85628f.tar.bz2 |
download script: support specifying more than one option
Also, invalid options now generate a warning, instead of
producting an error.
-rwxr-xr-x | download | 27 |
1 files changed, 16 insertions, 11 deletions
@@ -23,30 +23,35 @@ set -u -e download="./resources/scripts/helpers/download" -programme="unknown" +programmes="unknown" -usage="./download programme" +usage="./download programme(s) # programmes are space separated, if specifing multiple programmes" availableprogrammes="$(ls ${download}/)" # User specified no or too few/many parameters -if (( $# != 1 )); then +if [ $# -lt 1 ]; then printf "%s\n\n" "${usage}" - printf "possible values for 'programme':\nall:\n%s\n\n" "${availableprogrammes}" + printf "possible values for 'programmes':\nall:\n%s\n\n" "${availableprogrammes}" printf "Example (download everything): ./download all\n" - printf "Example (download coreboot): ./download coreboot\n\n" + printf "Example (download flashrom): ./download flashrom\n" + printf "Example (download coreboot): ./download coreboot\n" + printf "Example (download coreboot and flashrom): ./download coreboot flashrom\n" exit 1 fi -programme="${1}" +programmes="$@" -if [ "${programme}" = "all" ]; then +if [ "${programmes}" = "all" ]; then for programme in ${availableprogrammes}; do ${download}/${programme} done -elif [ -f "${download}/${programme}" ]; then - ${download}/${programme} else - printf "Invalid programme. Available programmes are:\nall\n%s\n" "${availableprogrammes}" - exit 1 + for programme in programmes; do + if [ -f "${download}/${programme}" ]; then + ${download}/${programme} + else + printf "download: WARNING: Invalid programme '%s'. Available programmes are:\nall\n%s\n" "${programme}" "${availableprogrammes}" + fi + done fi # ------------------- DONE ---------------------- |