Skip to content

Instantly share code, notes, and snippets.

@rawiriblundell
Created December 19, 2020 22:07
Show Gist options
  • Select an option

  • Save rawiriblundell/d7be2fca8f7036aa680fa184ebcf80af to your computer and use it in GitHub Desktop.

Select an option

Save rawiriblundell/d7be2fca8f7036aa680fa184ebcf80af to your computer and use it in GitHub Desktop.
Fetch a download from a redirected URL
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