wget 923 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/usr/bin/env bash
  2. # We want to catch any unexpected failure, and exit immediately
  3. set -e
  4. # Download helper for wget, to be called from the download wrapper script
  5. #
  6. # Options:
  7. # -q Be quiet.
  8. # -o FILE Save into file FILE.
  9. # -u URL Download file at URL.
  10. #
  11. # Environment:
  12. # WGET : the wget command to call
  13. verbose=
  14. while getopts "${BR_BACKEND_DL_GETOPTS}" OPT; do
  15. case "${OPT}" in
  16. q) verbose=-q;;
  17. o) output="${OPTARG}";;
  18. u) url="${OPTARG}";;
  19. :) printf "option '%s' expects a mandatory argument\n" "${OPTARG}"; exit 1;;
  20. \?) printf "unknown option '%s'\n" "${OPTARG}" >&2; exit 1;;
  21. esac
  22. done
  23. shift $((OPTIND-1)) # Get rid of our options
  24. # Caller needs to single-quote its arguments to prevent them from
  25. # being expanded a second time (in case there are spaces in them)
  26. _wget() {
  27. eval ${WGET} "${@}"
  28. }
  29. _wget ${verbose} "${@}" -O "'${output}'" "'${url}'"