From 649b5a0f445c97ac24f968cc9b3ae51c71ea148b Mon Sep 17 00:00:00 2001 From: Kevin van Zonneveld Date: Tue, 21 Jun 2016 13:36:48 +0200 Subject: [PATCH] Introduce `errtrace`, which is on by default (BREAKING) --- CHANGELOG.md | 1 + main.sh | 2 ++ 2 files changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ce3977a..89c3418 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ Released: Unreleased. [Commit log](https://github.com/kvz/bash3boilerplate/compare/v2.0.0...master) +- Introduce `errtrace`, which is on by default (BREAKING) - Add a configurable `helptext` that is left alone by the parses and allows you to have a richer help - Add a simple documentation website - Add best practice of using `__double_underscore_prefixed_vars` to indicate global variables that are solely controlled inside your script diff --git a/main.sh b/main.sh index 9c822d0..fe21843 100755 --- a/main.sh +++ b/main.sh @@ -37,6 +37,8 @@ # `set` is safer than relying on a shebang like `#!/bin/bash -e` because that is neutralized # when someone runs your script as `bash yourscript.sh` set -o errexit +# Exit on error inside any functions or subshells. +set -o errtrace set -o nounset # Bash will remember & return the highest exitcode in a chain of pipes.