diff options
author | Erich Eckner <git@eckner.net> | 2018-09-05 12:51:34 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2018-09-05 12:51:34 +0200 |
commit | 80e575c391e81ad389da36e50a3612b887c98a6a (patch) | |
tree | 9784d8a3694daafc9e89da11ced21f295a303137 | |
parent | 550ec57c321aca0b664afc41ba453fcbcbe156e9 (diff) | |
download | buff-di-wuff-80e575c391e81ad389da36e50a3612b887c98a6a.tar.xz |
buff-di-wuff: better url matching
-rwxr-xr-x | buff-di-wuff | 18 |
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 |