termux-api.c: rand() -> arc4random()
[termux-packages] / packages / termux-api / termux-sms-send
CommitLineData
59f0d218
FF
1#!/bin/sh
2set -e -u
3
0ec2b704
FF
4SCRIPTNAME=termux-sms-send
5show_usage () {
6 echo "Usage: $SCRIPTNAME [-t <text>] <recipient-number>"
7 echo "Send a SMS."
8 echo ""
8d6e165f 9 echo " -t <text> text to send (optional - else from stdin)"
0ec2b704
FF
10 echo ""
11 echo "If no text is specified with the -t option the text to send is read from stdin."
12 exit 0
13}
14
15TEXT_TO_SEND=""
16while getopts :ht: option
17do
18 case "$option" in
19 h) show_usage;;
20 t) TEXT_TO_SEND="$OPTARG";;
21 ?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1;
22 esac
23done
24shift $(($OPTIND-1))
25
26if [ $# = 0 ]; then echo "$SCRIPTNAME: too few arguments"; exit 1; fi
27if [ $# -gt 1 ]; then echo "$SCRIPTNAME: too many arguments"; exit 1; fi
28
29CMD="@TERMUX_API@ SmsSend --es recipient $1"
30if [ -z "$TEXT_TO_SEND" ]; then
31 $CMD
32else
33 echo $TEXT_TO_SEND | $CMD
59f0d218
FF
34fi
35