From f1487a80edac9e8f651f7bf2970e8fa4d2a9e971 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Fri, 3 Jan 2014 23:06:17 -0500 Subject: librefetch: defer canonicalizing $src until we've validated $MIRROR --- src/librefetch/librefetch | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'src') 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\"}" -- cgit v1.2.2