From 253cfd4e49d48ae00f88458034404d3e827563cc Mon Sep 17 00:00:00 2001 From: Alec Goncharow Date: Fri, 27 Oct 2023 17:48:41 -0400 Subject: sync --- script_template.sh | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 script_template.sh (limited to 'script_template.sh') diff --git a/script_template.sh b/script_template.sh new file mode 100755 index 0000000..854ddfa --- /dev/null +++ b/script_template.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash + +set -o errexit +set -o nounset +set -o pipefail +if [[ "${TRACE-0}" == "1" ]]; then + set -o xtrace +fi + +prompt_confirm() { + while true; do + read -r -n 1 -p "${1:-Continue?} [y/n]: " REPLY + case $REPLY in + [yY]) echo ; return 0 ;; + [nN]) echo ; return 1 ;; + *) printf " \033[31m %s \n\033[0m" "invalid input" + esac + done +} + + +help() { + echo 'Usage: ./script.sh arg-one arg-two + +This is an awesome bash script to make your life better. + +' + exit +} + +if [[ "${1-}" =~ ^-*h(elp)?$ ]]; then + help +fi + +cd "$(dirname "$0")" + +main() { + prompt_confirm "print help?" || exit 0 + help +} + +main "$@" -- cgit v1.2.3-70-g09d2