X-Git-Url: https://git.distorted.org.uk/~mdw/termux-packages/blobdiff_plain/0ae97c5e985892744202a4d264b268f887eb3c0d..0ec2b70462bf2052dd2080460112c3a8fc87f62e:/packages/termux-api/termux-dialog diff --git a/packages/termux-api/termux-dialog b/packages/termux-api/termux-dialog index f827b2e0..d9684533 100755 --- a/packages/termux-api/termux-dialog +++ b/packages/termux-api/termux-dialog @@ -1,34 +1,40 @@ #!/bin/sh - set -e -u -SCRIPTNAME=$0 +SCRIPTNAME=termux-dialog show_usage () { - echo "usage: $SCRIPTNAME [OPTIONS]" - echo " Show a text entry dialog." - echo " -i, --input-hint The input hint to show when the input is empty" - echo " -m, --multiple-lines Use a textarea with multiple lines instead of a single" - echo " -p, --password Enter the input as a password" - echo " -t, --title The title to show for the input prompt" + echo "Usage: $SCRIPTNAME [OPTIONS]" + echo "Show a text entry dialog." + echo "" + echo " -i <hint> The input hint to show when the input is empty" + echo " -m Use a textarea with multiple lines instead of a single" + echo " -p Enter the input as a password" + echo " -t <title> The title to show for the input prompt" + exit 0 } PARAMS="" -O=`busybox getopt -q -l help -l input-hint: -l multiple-lines -l password -l title: -- hi:mpt: "$@"` -if [ $? != 0 ] ; then show_usage; exit 1 ; fi -eval set -- "$O" -while true; do -case "$1" in - -h|--help) show_usage; exit 0;; - -i|--input-hint) PARAMS="$PARAMS --es input_hint '$2'"; shift 2;; - -m|--multiple-lines) PARAMS="$PARAMS --ez multiple_lines true"; shift 1;; - -p|--password) PARAMS="$PARAMS --es input_type password"; shift 1;; - -t|--title) PARAMS="$PARAMS --es input_title '$2'"; shift 2;; - --) shift; break;; - *) echo Error; exit 1;; -esac + +ARG_I="" +OPT_I="" +ARG_M="" +ARG_P="" +ARG_T="" +OPT_T="" + +while getopts :hi:mpt: option +do + case "$option" in + h) show_usage;; + i) ARG_I="--es input_hint"; OPT_I="$OPTARG";; + m) ARG_M="--ez multiple_lines true";; + p) ARG_P="--es input_type password";; + t) ARG_T="--es input_title"; OPT_T="$OPTARG";; + ?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1; + esac done +shift $(($OPTIND-1)) -# Too many arguments: -if [ $# != 0 ]; then show_usage; exit 1; fi +if [ $# != 0 ]; then echo "$SCRIPTNAME: too many arguments"; exit 1; fi -eval @TERMUX_API@ Dialog $PARAMS +@TERMUX_API@ Dialog $ARG_I "$OPT_I" $ARG_M $ARG_P $ARG_T "$OPT_T"