Commit 90e424c9 authored by Vitaly Lipatov's avatar Vitaly Lipatov

tools_eget: improve getting of url list

parent ad7ba835
...@@ -195,7 +195,7 @@ if echo "$1" | grep -q "^ftp://" ; then ...@@ -195,7 +195,7 @@ if echo "$1" | grep -q "^ftp://" ; then
fi fi
# drop mask part # drop mask part
URL="$(dirname "$1")/" URL="$(dirname "$1")"
if echo "$URL" | grep -q "[*?]" ; then if echo "$URL" | grep -q "[*?]" ; then
fatal "Error: there are globbing symbols (*?) in $URL" fatal "Error: there are globbing symbols (*?) in $URL"
...@@ -209,15 +209,15 @@ fi ...@@ -209,15 +209,15 @@ fi
get_urls() get_urls()
{ {
scat $URL | \ scat $URL/ | \
grep -i -o -E 'href="([^\*/"#]+)"' | cut -d'"' -f2 grep -i -o -P 'href="(.*?)"' | cut -d'"' -f2 | sed -e "s|^./||"
} }
if [ -n "$LISTONLY" ] ; then if [ -n "$LISTONLY" ] ; then
fn='' fn=''
for fn in $(get_urls | filter_glob "$MASK" | filter_order) ; do for fn in $(get_urls | filter_glob "$MASK" | filter_order) ; do
# TODO: return full url? someone use old behaviour? # TODO: return full url? someone use old behaviour?
echo "$(basename "$fn")" echo "$fn" | sed -e "s|$URL/||"
done done
test -n "$fn" test -n "$fn"
exit exit
...@@ -226,7 +226,8 @@ fi ...@@ -226,7 +226,8 @@ fi
ERROR=0 ERROR=0
fn='' fn=''
for fn in $(get_urls | filter_glob "$MASK" | filter_order) ; do for fn in $(get_urls | filter_glob "$MASK" | filter_order) ; do
sget "$URL/$(basename "$fn")" || ERROR=1 echo "$fn" | grep -q "://" && furl=$fn || furl="$URL/$fn"
sget "$furl" || ERROR=1
done done
test -n "$fn" || ERROR=1 test -n "$fn" || ERROR=1
exit $ERROR exit $ERROR
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment