mosquitto: Update from 1.4.10 to 1.4.11
[termux-packages] / packages / termux-api / termux-download
CommitLineData
cc1ae02e 1#!/bin/sh
59f0d218
FF
2set -e -u
3
8d6e165f 4SCRIPTNAME=termux-download
59f0d218 5show_usage () {
bea93fbd
FF
6 echo "Usage: $SCRIPTNAME [-d description] [-t title] url-to-download"
7 echo "Download a resource using the system download manager."
bea93fbd
FF
8 echo " -d description description for the download request notification"
9 echo " -t title title for the download request notification"
bea93fbd 10 exit 0
59f0d218
FF
11}
12
8d6e165f
FF
13ARG_D=""
14OPT_D=""
15ARG_T=""
16OPT_T=""
17
18while getopts :hd:t: option
19do
20 case "$option" in
21 h) show_usage;;
22 d) ARG_D="--es description"; OPT_D="$OPTARG";;
23 t) ARG_T="--es title"; OPT_T="$OPTARG";;
24 ?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1;
25 esac
59f0d218 26done
8d6e165f
FF
27shift $(($OPTIND-1))
28
29if [ $# -lt 1 ]; then echo "$SCRIPTNAME: no url specified"; exit 1; fi
30if [ $# -gt 1 ]; then echo "$SCRIPTNAME: too many arguments"; exit 1; fi
31
32URL_TO_DOWNLOAD="$1"
59f0d218 33
8d6e165f
FF
34set --
35if [ -n "$ARG_D" ]; then set -- "$@" $ARG_D "$OPT_D"; fi
36if [ -n "$ARG_T" ]; then set -- "$@" $ARG_T "$OPT_T"; fi
37set -- "$@" $URL_TO_DOWNLOAD
59f0d218 38
8d6e165f 39@TERMUX_API@ Download "$@"