2015-08-14 21:27:47 +02:00
|
|
|
#!/bin/sh
|
2015-06-13 01:03:31 +02:00
|
|
|
set -e -u
|
|
|
|
|
2016-04-20 11:34:03 +02:00
|
|
|
SCRIPTNAME=termux-download
|
2015-06-13 01:03:31 +02:00
|
|
|
show_usage () {
|
2016-04-20 11:34:03 +02:00
|
|
|
echo "Usage: $SCRIPTNAME [OPTIONS] <url-to-download>"
|
|
|
|
echo "Download a resource using the system download manager."
|
|
|
|
echo ""
|
|
|
|
echo " -d <description> description for the download request notification"
|
|
|
|
echo " -t <title> title for the download request notification"
|
|
|
|
exit 0
|
2015-06-13 01:03:31 +02:00
|
|
|
}
|
|
|
|
|
2016-04-20 11:34:03 +02:00
|
|
|
ARG_D=""
|
|
|
|
OPT_D=""
|
|
|
|
ARG_T=""
|
|
|
|
OPT_T=""
|
|
|
|
|
|
|
|
while getopts :hd:t: option
|
|
|
|
do
|
|
|
|
case "$option" in
|
|
|
|
h) show_usage;;
|
|
|
|
d) ARG_D="--es description"; OPT_D="$OPTARG";;
|
|
|
|
t) ARG_T="--es title"; OPT_T="$OPTARG";;
|
|
|
|
?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1;
|
|
|
|
esac
|
2015-06-13 01:03:31 +02:00
|
|
|
done
|
2016-04-20 11:34:03 +02:00
|
|
|
shift $(($OPTIND-1))
|
|
|
|
|
|
|
|
if [ $# -lt 1 ]; then echo "$SCRIPTNAME: no url specified"; exit 1; fi
|
|
|
|
if [ $# -gt 1 ]; then echo "$SCRIPTNAME: too many arguments"; exit 1; fi
|
|
|
|
|
|
|
|
URL_TO_DOWNLOAD="$1"
|
2015-06-13 01:03:31 +02:00
|
|
|
|
2016-04-20 11:34:03 +02:00
|
|
|
set --
|
|
|
|
if [ -n "$ARG_D" ]; then set -- "$@" $ARG_D "$OPT_D"; fi
|
|
|
|
if [ -n "$ARG_T" ]; then set -- "$@" $ARG_T "$OPT_T"; fi
|
|
|
|
set -- "$@" $URL_TO_DOWNLOAD
|
2015-06-13 01:03:31 +02:00
|
|
|
|
2016-04-20 11:34:03 +02:00
|
|
|
@TERMUX_API@ Download "$@"
|