summaryrefslogtreecommitdiff
path: root/src/librefetch
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2014-01-03 23:06:17 -0500
committerLuke Shumaker <LukeShu@sbcglobal.net>2014-01-04 19:39:07 -0500
commitf1487a80edac9e8f651f7bf2970e8fa4d2a9e971 (patch)
tree03d9c85fba57723eff0c8822cd23d88b85d47bf3 /src/librefetch
parent8698eb5f1dff6d046fb708d1e4f529d83e88cb4c (diff)
librefetch: defer canonicalizing $src until we've validated $MIRROR
Diffstat (limited to 'src/librefetch')
-rwxr-xr-xsrc/librefetch/librefetch26
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\"}"