diff options
author | Luke Shumaker <LukeShu@sbcglobal.net> | 2014-01-03 23:06:17 -0500 |
---|---|---|
committer | Luke Shumaker <LukeShu@sbcglobal.net> | 2014-01-04 19:39:07 -0500 |
commit | f1487a80edac9e8f651f7bf2970e8fa4d2a9e971 (patch) | |
tree | 03d9c85fba57723eff0c8822cd23d88b85d47bf3 /src | |
parent | 8698eb5f1dff6d046fb708d1e4f529d83e88cb4c (diff) |
librefetch: defer canonicalizing $src until we've validated $MIRROR
Diffstat (limited to 'src')
-rwxr-xr-x | src/librefetch/librefetch | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/librefetch/librefetch b/src/librefetch/librefetch index 6268d75..3d7f667 100755 --- a/src/librefetch/librefetch +++ b/src/librefetch/librefetch @@ -119,18 +119,11 @@ main() { local src="${extra_opts[0]}" local dst="${extra_opts[1]:-${src##*/}}" - # canonicalize $src - if [[ "$src" == libre://* ]]; then - src="${MIRROR}/${src#libre://}" - fi - # canonicalize $dst - dst="$(readlink -m -- "$dst")" + # Don't canonicalize $src unless mode =~ download, and we've validated + # that $MIRROR is configured. - # check to see if $src is a candidate for create mode - if [[ "$src" != "$MIRROR"* ]]; then - # inhibit create - mode=download - fi + # Canonicalize $dst + dst="$(readlink -m -- "$dst")" # Mode: download ####################################################### @@ -138,6 +131,17 @@ main() { load_files librefetch check_vars librefetch MIRROR DOWNLOADER || return 1 + # Canonicalize $src + if [[ "$src" == libre://* ]]; then + src="${MIRROR}/${src#libre://}" + fi + + # check to see if $src is a candidate for create mode + if [[ "$src" != "$MIRROR"* ]]; then + # inhibit create + mode=download + fi + local dlcmd="${DOWNLOADER}" dlcmd="${dlcmd//\%o/\"$dst\"}" dlcmd="${dlcmd//\%u/\"$src\"}" |