Created
December 19, 2020 22:07
-
-
Save rawiriblundell/d7be2fca8f7036aa680fa184ebcf80af to your computer and use it in GitHub Desktop.
Fetch a download from a redirected URL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| software::fetch() { | |
| local local_target remote_target | |
| remote_target="${1:?No target specified}" | |
| remote_target="$(curl "${remote_target}" -s -L -I -o /dev/null -w '%{url_effective}')" | |
| local_target="${remote_target##*/}" | |
| printf -- '%s\n' "Attempting to fetch ${remote_target}..." | |
| curl "${remote_target}" > "${local_dir}"/"${local_target}" || return 1 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment