summaryrefslogtreecommitdiff
path: root/src/librefetch
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2014-01-03 22:33:48 -0500
committerLuke Shumaker <LukeShu@sbcglobal.net>2014-01-03 22:36:19 -0500
commit0318548c81d95cc2483aaf44e63f487650a74f87 (patch)
tree78777a58235006a98e492dc58026102bced9ab75 /src/librefetch
parentfcddad60721db6dceb4858fc752f109c954e54e2 (diff)
librefetch: accept HTTP URLs, but don't create if they aren't in $MIRROR
But, don't update the documentation. I have a feeling things will change again in the next few commits.
Diffstat (limited to 'src/librefetch')
-rwxr-xr-xsrc/librefetch/librefetch22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/librefetch/librefetch b/src/librefetch/librefetch
index 93bcd1e..e963b96 100755
--- a/src/librefetch/librefetch
+++ b/src/librefetch/librefetch
@@ -127,12 +127,12 @@ main() {
local src dst
case ${#extra_opts[@]} in
1)
- src="${extra_opts[0]#*://}"
- dst="$(readlink -m -- "${src##*/}")"
+ src="${extra_opts[0]}"
+ dst="${src##*/}"
;;
2)
- src="${extra_opts[0]#*://}"
- dst="$(readlink -m -- "${extra_opts[1]}")"
+ src="${extra_opts[0]}"
+ dst="${extra_opts[1]}"
;;
*)
print "%s: %d non-flag arguments found, expected 1 or 2: %s" "$cmd" ${#extra_opts[@]} >> /dev/stderr
@@ -140,17 +140,25 @@ main() {
return 1
esac
+ if [[ "$src" == libre://* ]]; then
+ src="${MIRROR}/${src#libre://}"
+ fi
+
+ if [[ "$src" != "$MIRROR"* ]]; then
+ # inhibit create
+ mode=download
+ fi
+ dst="$(readlink -m -- "$dst")" # canonicalize $dst
+
# Mode: download #######################################################
if [[ $mode =~ download ]]; then
load_files librefetch
check_vars librefetch MIRROR DOWNLOADER || return 1
- local url="${MIRROR}/${src}"
-
local dlcmd="${DOWNLOADER}"
dlcmd="${dlcmd//\%o/\"$dst\"}"
- dlcmd="${dlcmd//\%u/\"$url\"}"
+ dlcmd="${dlcmd//\%u/\"$src\"}"
{ eval "$dlcmd"; } >> /dev/stderr && return 0
fi