From 99a1b0b0d9372a41337361679d1fbb6aa0b1829b Mon Sep 17 00:00:00 2001 From: Patrick Spek Date: Thu, 20 Feb 2020 22:44:00 +0100 Subject: Update sh template --- .local/templates/sh | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/.local/templates/sh b/.local/templates/sh index 064986c..11af633 100644 --- a/.local/templates/sh +++ b/.local/templates/sh @@ -13,31 +13,19 @@ main() { # Handle opts - opts "$@" - shift "$OPTS" - unset OPTS - - # Show help - [ "$OPT_HELP_ONLY" ] && usage && exit 0 - - # TODO: Write actual program -} - -opts() -{ - OPTS=0 - while getopts ":h" opt do case "$opt" in - h) OPT_HELP_ONLY=1 ;; + h) usage && exit 0 ;; *) printf "Invalid option passed: %s\n" "$OPTARG" >&2 ;; esac done - unset opt + shift $(( OPTIND - 1 )) + + # TODO: Write actual program } usage() -- cgit v1.1