summaryrefslogtreecommitdiff
path: root/vidoas
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2022-11-15 11:00:42 +0100
committerThomas Voss <mail@thomasvoss.com> 2022-11-15 11:00:42 +0100
commitaed6e88edb43878e98620cf7c938a74040174f2b (patch)
tree5a6f4beb505b6b62b9542c77599bc63d0b433f9d /vidoas
parent17616c16865b14c51e3d9efdf3154d03b7c2a3d1 (diff)
Add the usage() function
Diffstat (limited to 'vidoas')
-rwxr-xr-xvidoas24
1 files changed, 10 insertions, 14 deletions
diff --git a/vidoas b/vidoas
index 96789ff..ac12728 100755
--- a/vidoas
+++ b/vidoas
@@ -33,8 +33,9 @@ doas_conf_mode="0600"
[ $(id -u) -eq 0 ] && EDIT="${VISUAL:-${EDITOR:-vi}}" || EDIT=doasedit
-warn() { echo "$PROG: $@" >&2; }
-die() { rv=$1; shift; warn "$@"; exit $rv; }
+warn() { echo "$PROG: $@" >&2; }
+die() { rv=$1; shift; warn "$@"; exit $rv; }
+usage() { die 1 "Usage: $PROG [-n] [file]"; }
get_intr() {
stty -a | sed -En '
@@ -56,26 +57,21 @@ set_trap_rm() {
noop=0
-while getopts hn c; do
+while getopts n c; do
case "$c" in
- n)
- noop=$(($noop + 1))
- ;;
- *)
- echo "Usage: $PROG [-n] [file]" >&2;
- exit 1
- ;;
+ n) noop=$(($noop + 1)) ;;
+ *) usage ;;
esac
done
shift $(($OPTIND - 1))
case $# in
-0) ;;
-1) DOAS_CONF="$1" ;;
-*) usage 1>&2; exit 1 ;;
+0) ;;
+1) DOAS_CONF="$1" ;;
+*) usage ;;
esac
-case ${noop} in
+case $noop in
0) noop=false ;;
1) noop=true ;;
*) noop=true; exec >/dev/null 2>&1 ;;