summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbuff-di-wuff18
1 files changed, 13 insertions, 5 deletions
diff --git a/buff-di-wuff b/buff-di-wuff
index 7cbe7cc..822a15d 100755
--- a/buff-di-wuff
+++ b/buff-di-wuff
@@ -21,20 +21,28 @@ grep '^[^#]' "$(dirname "$0")/downloads.list" | \
sed 's|/[^/]*$|/|'
)
urlPrefix="${urlDir}"
+ urlFile="${url##*/}"
+ spacer='/'
else
- urlPrefix="${url%/*}/"
+ urlPrefix=$(
+ printf '%s\n' "${url}" | \
+ sed '
+ s,\([^/]/\)[^/].*$,\1,
+ '
+ )
+ urlFile="/${url#*//*/}"
+ spacer=''
fi
urlFile=$(
- printf '%s\n' "${url}" | \
+ printf '%s\n' "${urlFile}" | \
sed '
- s|^.*/||
s|\.|\\.|g
s|*|.*|g
'
)
wget --no-check-certificate -O - "${urlDir}" 2> /dev/null | \
- tr '"<>/' '\n' | \
- grep "^${urlFile}\$" | \
+ tr '"<>'"${spacer}" '\n' | \
+ grep '\(^\|/\)'"${urlFile}\$" | \
sort -u | \
xargs -r printf "${urlPrefix}%s\n"
else