scp 684 B

1234567891011121314151617181920212223242526272829303132
  1. #!/usr/bin/env bash
  2. # We want to catch any unexpected failure, and exit immediately
  3. set -e
  4. # Download helper for scp, to be called from the download wrapper script
  5. #
  6. # Call it as:
  7. # .../scp [-q] OUT_FILE SRC_URL
  8. #
  9. # Environment:
  10. # SCP : the scp command to call
  11. verbose=
  12. while getopts :q OPT; do
  13. case "${OPT}" in
  14. q) verbose=-q;;
  15. \?) printf "unknown option '%s'\n" "${OPTARG}" >&2; exit 1;;
  16. esac
  17. done
  18. shift $((OPTIND-1))
  19. output="${1}"
  20. url="${2}"
  21. # Caller needs to single-quote its arguments to prevent them from
  22. # being expanded a second time (in case there are spaces in them)
  23. _scp() {
  24. eval ${SCP} "${@}"
  25. }
  26. _scp ${verbose} "'${url}'" "'${output}'"