2
1

cp 977 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/usr/bin/env bash
  2. # We want to catch any unexpected failure, and exit immediately
  3. set -e
  4. # Download helper for cp, to be called from the download wrapper script
  5. #
  6. # Call it as:
  7. # .../cp [-q] OUT_FILE SRC_FILE
  8. #
  9. # Environment:
  10. # LOCALFILES: the cp command to call
  11. # 'cp' usually does not print anything on its stdout, whereas the
  12. # other download backends, even if not verbose, at least print some
  13. # progress information.
  14. # Make 'cp' verbose by default, so it behaves a bit like the others.
  15. verbose=-v
  16. while getopts :q OPT; do
  17. case "${OPT}" in
  18. q) verbose=;;
  19. \?) printf "unknown option '%s'\n" "${OPTARG}" >&2; exit 1;;
  20. esac
  21. done
  22. shift $((OPTIND-1))
  23. output="${1}"
  24. source="${2}"
  25. shift 2 # Get rid of our options
  26. # Caller needs to single-quote its arguments to prevent them from
  27. # being expanded a second time (in case there are spaces in them)
  28. _localfiles() {
  29. eval ${LOCALFILES} "${@}"
  30. }
  31. _localfiles ${verbose} "${@}""'${source}'" "'${output}'"