curl: Update from 7.48 to 7.49
[termux-packages] / packages / termux-api / termux-vibrate
index 78187e0..ed973bf 100755 (executable)
@@ -1,23 +1,30 @@
-#!/system/bin/sh
-
+#!/bin/sh
 set -e -u
 
+SCRIPTNAME=termux-vibrate
 show_usage () {
-       echo 'usage: termux-vibrate [<duration_ms>]'
-       echo 'Vibrate the device for the specified duration (default:1000 ms).'
-       exit 1
+    echo "Usage: $SCRIPTNAME [-d duration] [-f]"
+    echo "Vibrate the device."
+    echo ""
+    echo "  -d duration  the duration to vibrate in ms (default:1000)"
+    echo "  -f           force vibration even in silent mode"
+    echo ""
+    exit 0
 }
 
-PARAM_DURATION=""
-O=`getopt -l duration: -l help -- d:h "$@"`
-eval set -- "$O"
-while true; do
-case "$1" in
-       -d|--duration) PARAM_DURATION="--ei duration_ms $2";  shift 2;;
-       -h|--help) show_usage;;
-       --)     shift; break;;
-       *)      echo Error; exit 1;;
-esac
+PARAMS=""
+
+while getopts :hfd: option
+do
+    case "$option" in
+       h) show_usage;;
+       d) PARAMS="$PARAMS --ei duration_ms $OPTARG";;
+       f) PARAMS="$PARAMS --ez force true";;
+       ?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1;
+    esac
 done
+shift $(($OPTIND-1))
+
+if [ $# != 0 ]; then echo "$SCRIPTNAME: too many arguments"; exit 1; fi
 
-termux-api Vibrate $PARAM_DURATION
+@TERMUX_API@ Vibrate $PARAMS