From 56791c1b1cee584c26fb6b68537e8b5143774753 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Fri, 13 Jul 2018 15:10:17 +0200 Subject: buff-di-wuff: really parse github :-) --- buff-di-wuff | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/buff-di-wuff b/buff-di-wuff index bcd1526..c86965f 100755 --- a/buff-di-wuff +++ b/buff-di-wuff @@ -12,34 +12,25 @@ mkdir -p \ grep '^[^#]' "$(dirname "$0")/downloads.list" | \ while read -r url urlDir; do - if [ -n "${urlDir}" ]; then - urlFile=$( - printf '%s\n' "${url}" | \ - sed ' - s|\.|\.|g - s|*|.*|g - ' - ) - wget --no-check-certificate -O - "${urlDir}" 2> /dev/null | \ - tr '"<>' '\n' | \ - grep "^${urlFile}\$" | \ - sort -u - elif echo "${url}" | \ - grep -q '\*[^/]*$'; then - urlDir=$( - printf '%s\n' "${url}" | \ - sed 's|/[^/]*$|/|' - ) + if [ -n "${urlDir}" ] || \ + echo "${url}" | \ + grep -q '\*[^/]*$'; then + if [ -z "${urlDir}" ]; then + urlDir=$( + printf '%s\n' "${url}" | \ + sed 's|/[^/]*$|/|' + ) + fi urlFile=$( printf '%s\n' "${url}" | \ sed ' s|^.*/|| - s|\.|\.|g + s|\.|\\.|g s|*|.*|g ' ) wget --no-check-certificate -O - "${urlDir}" 2> /dev/null | \ - tr '"<>' '\n' | \ + tr '"<>/' '\n' | \ grep "^${urlFile}\$" | \ sort -u | \ xargs -r printf "${urlDir}%s\n" -- cgit v1.2.3-70-g09d2