2013-08-27 15:14:44 +04:00
|
|
|
#!/bin/bash
|
|
|
|
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
|
2014-07-07 22:06:38 +04:00
|
|
|
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
|
|
|
|
urequire DEFAULTS
|
2013-08-27 15:14:44 +04:00
|
|
|
|
|
|
|
function display_help() {
|
|
|
|
uecho "$scriptname: Télécharger un fichier avec wget ou curl
|
|
|
|
|
|
|
|
USAGE
|
|
|
|
$scriptname <file.url|file.desktop|URL> [wget options]"
|
|
|
|
}
|
|
|
|
|
|
|
|
parse_opts + "${PRETTYOPTS[@]}" \
|
|
|
|
--help '$exit_with display_help' \
|
|
|
|
@ args -- "$@" && set -- "${args[@]}" || die "$args"
|
|
|
|
|
|
|
|
url="$("$scriptdir/caturl" "$1")" || die
|
|
|
|
shift
|
|
|
|
|
|
|
|
filename="$(basename "$url")"
|
|
|
|
if progexists wget; then
|
|
|
|
if [ -f "$filename" ]; then
|
|
|
|
wget -c "$@" "$url"
|
|
|
|
else
|
|
|
|
wget "$@" "$url"
|
|
|
|
fi
|
|
|
|
elif progexists curl; then
|
|
|
|
if [ -f "$filename" ]; then
|
|
|
|
curl -C - -o "$filename" "$@" "$url"
|
|
|
|
else
|
|
|
|
curl -o "$filename" "$@" "$url"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
die "Aucune méthode de téléchargement n'a été détectée"
|
|
|
|
fi
|