Skip to content

Enhance help and option handling #191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions scripts/termux-api-start.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
#!@TERMUX_PREFIX@/bin/sh
# shellcheck shell=bash

am startservice -n com.termux.api/.KeepAliveService
2 changes: 2 additions & 0 deletions scripts/termux-api-stop.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
#!@TERMUX_PREFIX@/bin/sh
# shellcheck shell=bash

am stopservice -n com.termux.api/.KeepAliveService
2 changes: 2 additions & 0 deletions scripts/termux-audio-info.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!@TERMUX_PREFIX@/bin/sh
# shellcheck shell=bash

set -e -u

SCRIPTNAME=termux-audio-info
Expand Down
15 changes: 12 additions & 3 deletions scripts/termux-battery-status.in
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
#!@TERMUX_PREFIX@/bin/sh
# shellcheck shell=bash

set -e -u

SCRIPTNAME=termux-battery-status
show_usage () {
echo "Usage: $SCRIPTNAME"
echo "Get the status of the device battery."
RESET='\e[0m'
LABEL='\e[96m'

echo -e "${LABEL}Usage${RESET}: $SCRIPTNAME
Get the status of the device battery."
exit 0
}

specification=:h
option_names_as_string="$(echo "$specification" | sed 's/://g' | sed -r 's/(.)/ -\1/g')"
read -r -a option_names_as_array <<< "$option_names_as_string"

while getopts :h option
do
case "$option" in
h) show_usage;;
?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1;
?) echo "$SCRIPTNAME: illegal option -$OPTARG, expected one of ${option_names_as_array[*]}"; exit 1;
esac
done
shift $((OPTIND-1))
Expand Down
2 changes: 2 additions & 0 deletions scripts/termux-camera-info.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!@TERMUX_PREFIX@/bin/sh
# shellcheck shell=bash

set -e -u

SCRIPTNAME=termux-camera-info
Expand Down
2 changes: 2 additions & 0 deletions scripts/termux-camera-photo.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!@TERMUX_PREFIX@/bin/sh
# shellcheck shell=bash

set -e -u

SCRIPTNAME=termux-camera-photo
Expand Down
2 changes: 2 additions & 0 deletions scripts/termux-clipboard-get.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!@TERMUX_PREFIX@/bin/sh
# shellcheck shell=bash

set -e -u

SCRIPTNAME=termux-clipboard-get
Expand Down
2 changes: 2 additions & 0 deletions scripts/termux-clipboard-set.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!@TERMUX_PREFIX@/bin/sh
# shellcheck shell=bash

set -e -u

SCRIPTNAME=termux-clipboard-set
Expand Down
2 changes: 2 additions & 0 deletions scripts/termux-contact-list.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!@TERMUX_PREFIX@/bin/sh
# shellcheck shell=bash

set -e -u

SCRIPTNAME=termux-contact-list
Expand Down
2 changes: 2 additions & 0 deletions scripts/termux-download.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!@TERMUX_PREFIX@/bin/sh
# shellcheck shell=bash

set -e -u

SCRIPTNAME=termux-download
Expand Down
2 changes: 2 additions & 0 deletions scripts/termux-fingerprint.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!@TERMUX_PREFIX@/bin/sh
# shellcheck shell=bash

set -e -u

SCRIPTNAME=termux-fingerprint
Expand Down
2 changes: 2 additions & 0 deletions scripts/termux-infrared-frequencies.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!@TERMUX_PREFIX@/bin/sh
# shellcheck shell=bash

set -e -u

SCRIPTNAME=termux-infrared-frequencies
Expand Down
2 changes: 2 additions & 0 deletions scripts/termux-infrared-transmit.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!@TERMUX_PREFIX@/bin/sh
# shellcheck shell=bash

set -e -u

SCRIPTNAME=termux-infrared-transmit
Expand Down
2 changes: 2 additions & 0 deletions scripts/termux-job-scheduler.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!@TERMUX_PREFIX@/bin/bash
# shellcheck shell=bash

set -e -u -f

SCRIPTNAME=termux-job-scheduler
Expand Down
2 changes: 2 additions & 0 deletions scripts/termux-keystore.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!@TERMUX_PREFIX@/bin/sh
# shellcheck shell=bash

set -e -u

readonly CMD_BASE="@TERMUX_PREFIX@/libexec/termux-api Keystore"
Expand Down
2 changes: 2 additions & 0 deletions scripts/termux-location.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!@TERMUX_PREFIX@/bin/sh
# shellcheck shell=bash

set -e -u

SCRIPTNAME=termux-location
Expand Down
2 changes: 2 additions & 0 deletions scripts/termux-notification-list.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!@TERMUX_PREFIX@/bin/sh
# shellcheck shell=bash

set -e -u

SCRIPTNAME=termux-notification-list
Expand Down
2 changes: 2 additions & 0 deletions scripts/termux-notification-remove.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!@TERMUX_PREFIX@/bin/sh
# shellcheck shell=bash

set -e -u

SCRIPTNAME=termux-notification-remove
Expand Down
2 changes: 2 additions & 0 deletions scripts/termux-saf-create.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!@TERMUX_PREFIX@/bin/sh
# shellcheck shell=bash

set -e -u

SCRIPTNAME=termux-saf-create
Expand Down
2 changes: 2 additions & 0 deletions scripts/termux-saf-dirs.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!@TERMUX_PREFIX@/bin/sh
# shellcheck shell=bash

set -e -u

SCRIPTNAME=termux-saf-dirs
Expand Down
2 changes: 2 additions & 0 deletions scripts/termux-saf-ls.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!@TERMUX_PREFIX@/bin/sh
# shellcheck shell=bash

set -e -u

SCRIPTNAME=termux-saf-ls
Expand Down
2 changes: 2 additions & 0 deletions scripts/termux-saf-managedir.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!@TERMUX_PREFIX@/bin/sh
# shellcheck shell=bash

set -e -u

SCRIPTNAME=termux-saf-managedir
Expand Down
2 changes: 2 additions & 0 deletions scripts/termux-saf-mkdir.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!@TERMUX_PREFIX@/bin/sh
# shellcheck shell=bash

set -e -u

SCRIPTNAME=termux-saf-mkdir
Expand Down
2 changes: 2 additions & 0 deletions scripts/termux-saf-read.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!@TERMUX_PREFIX@/bin/sh
# shellcheck shell=bash

set -e -u

SCRIPTNAME=termux-saf-read
Expand Down
2 changes: 2 additions & 0 deletions scripts/termux-saf-rm.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!@TERMUX_PREFIX@/bin/sh
# shellcheck shell=bash

set -e -u

SCRIPTNAME=termux-saf-rm
Expand Down
2 changes: 2 additions & 0 deletions scripts/termux-saf-stat.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!@TERMUX_PREFIX@/bin/sh
# shellcheck shell=bash

set -e -u

SCRIPTNAME=termux-saf-stat
Expand Down
2 changes: 2 additions & 0 deletions scripts/termux-saf-write.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!@TERMUX_PREFIX@/bin/sh
# shellcheck shell=bash

set -e -u

SCRIPTNAME=termux-saf-write
Expand Down
2 changes: 2 additions & 0 deletions scripts/termux-share.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!@TERMUX_PREFIX@/bin/sh
# shellcheck shell=bash

set -e -u

SCRIPTNAME=termux-share
Expand Down
2 changes: 2 additions & 0 deletions scripts/termux-sms-inbox.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!@TERMUX_PREFIX@/bin/sh
# shellcheck shell=bash


echo "termux-sms-inbox: This script has been replaced by termux-sms-list."
exit 1
2 changes: 2 additions & 0 deletions scripts/termux-sms-list.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!@TERMUX_PREFIX@/bin/sh
# shellcheck shell=bash

set -u

PARAM_LIMIT=10
Expand Down
2 changes: 2 additions & 0 deletions scripts/termux-sms-send.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!@TERMUX_PREFIX@/bin/sh
# shellcheck shell=bash

set -e -u

SCRIPTNAME=termux-sms-send
Expand Down
2 changes: 2 additions & 0 deletions scripts/termux-speech-to-text.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!@TERMUX_PREFIX@/bin/sh
# shellcheck shell=bash

set -e -u

SCRIPTNAME=termux-speech-to-text
Expand Down
2 changes: 2 additions & 0 deletions scripts/termux-storage-get.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!@TERMUX_PREFIX@/bin/sh
# shellcheck shell=bash

set -e -u

SCRIPTNAME=termux-storage-get
Expand Down
2 changes: 2 additions & 0 deletions scripts/termux-telephony-call.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!@TERMUX_PREFIX@/bin/sh
# shellcheck shell=bash

set -e -u

SCRIPTNAME=termux-telephony-call
Expand Down
2 changes: 2 additions & 0 deletions scripts/termux-telephony-cellinfo.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!@TERMUX_PREFIX@/bin/sh
# shellcheck shell=bash

set -e -u

SCRIPTNAME=termux-telephony-cellinfo
Expand Down
2 changes: 2 additions & 0 deletions scripts/termux-telephony-deviceinfo.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!@TERMUX_PREFIX@/bin/sh
# shellcheck shell=bash

set -e -u

SCRIPTNAME=termux-telephony-deviceinfo
Expand Down
2 changes: 2 additions & 0 deletions scripts/termux-torch.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!@TERMUX_PREFIX@/bin/sh
# shellcheck shell=bash

set -e -u

SCRIPTNAME=termux-torch
Expand Down
2 changes: 2 additions & 0 deletions scripts/termux-tts-engines.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!@TERMUX_PREFIX@/bin/sh
# shellcheck shell=bash

set -e -u

SCRIPTNAME=termux-tts-engines
Expand Down
2 changes: 2 additions & 0 deletions scripts/termux-tts-speak.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!@TERMUX_PREFIX@/bin/sh
# shellcheck shell=bash

set -e -u

SCRIPTNAME=termux-tts-speak
Expand Down
2 changes: 2 additions & 0 deletions scripts/termux-vibrate.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!@TERMUX_PREFIX@/bin/sh
# shellcheck shell=bash

set -e -u

SCRIPTNAME=termux-vibrate
Expand Down
2 changes: 2 additions & 0 deletions scripts/termux-wifi-connectioninfo.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!@TERMUX_PREFIX@/bin/sh
# shellcheck shell=bash

set -e -u

SCRIPTNAME=termux-wifi-connectioninfo
Expand Down
2 changes: 2 additions & 0 deletions scripts/termux-wifi-enable.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!@TERMUX_PREFIX@/bin/sh
# shellcheck shell=bash

set -e -u

SCRIPTNAME=termux-wifi-enable
Expand Down
2 changes: 2 additions & 0 deletions scripts/termux-wifi-scaninfo.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!@TERMUX_PREFIX@/bin/sh
# shellcheck shell=bash

set -e -u

SCRIPTNAME=termux-wifi-scaninfo
Expand Down