Commit 6a39e446 authored by Vitaly Lipatov's avatar Vitaly Lipatov

eget: add --latest support

parent 4bd399cc
...@@ -29,11 +29,18 @@ if [ "$1" = "-q" ] ; then ...@@ -29,11 +29,18 @@ if [ "$1" = "-q" ] ; then
shift shift
fi fi
LISTONLY=''
if [ "$1" = "--list" ] ; then if [ "$1" = "--list" ] ; then
LISTONLY="$1" LISTONLY="$1"
shift shift
fi fi
LATEST=''
if [ "$1" = "--latest" ] ; then
LATEST="$1"
shift
fi
fatal() fatal()
{ {
echo "$*" >&2 echo "$*" >&2
...@@ -47,6 +54,11 @@ filter_glob() ...@@ -47,6 +54,11 @@ filter_glob()
grep "^$(echo "$1" | sed -e "s|\*|.*|g" -e "s|?|.|g")$" grep "^$(echo "$1" | sed -e "s|\*|.*|g" -e "s|?|.|g")$"
} }
filter_order()
{
[ -z "$LATEST" ] && cat && return
sort | tail -n1
}
# download to this file # download to this file
WGET_OPTION_TARGET= WGET_OPTION_TARGET=
...@@ -110,14 +122,14 @@ get_urls() ...@@ -110,14 +122,14 @@ get_urls()
if [ -n "$LISTONLY" ] ; then if [ -n "$LISTONLY" ] ; then
WGET="$WGET -q" WGET="$WGET -q"
for fn in $(get_urls | filter_glob "$MASK") ; do for fn in $(get_urls | filter_glob "$MASK" | filter_order) ; do
echo "$(basename "$fn")" echo "$(basename "$fn")"
done done
exit exit
fi fi
ERROR=0 ERROR=0
for fn in $(get_urls | filter_glob "$MASK") ; do for fn in $(get_urls | filter_glob "$MASK" | filter_order) ; do
$WGET "$URL/$(basename "$fn")" || ERROR=1 $WGET "$URL/$(basename "$fn")" || ERROR=1
done done
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