summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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