aboutsummaryrefslogtreecommitdiff
path: root/script_template.sh
diff options
context:
space:
mode:
Diffstat (limited to 'script_template.sh')
-rwxr-xr-xscript_template.sh42
1 files changed, 42 insertions, 0 deletions
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 "$@"