summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2023-03-15 19:09:52 +0200
committerPaul Buetow <paul@buetow.org>2023-03-15 19:09:52 +0200
commitd839e9159851934ed6cfb35f557c8313b88aa27c (patch)
treea863be5fc962dcc8890e9930cf4f0a95e33864b0
parent4082179769e6ed50936db43ab674691dce4d9f7a (diff)
use safer bash options
-rwxr-xr-xgemtexter8
-rw-r--r--lib/generate.source.sh4
2 files changed, 9 insertions, 3 deletions
diff --git a/gemtexter b/gemtexter
index a76e219..9959c1e 100755
--- a/gemtexter
+++ b/gemtexter
@@ -19,7 +19,13 @@ readonly DATE
readonly SED
readonly GREP
-set -e
+# Set unset variables to make 'set -u' work, they can optionally be passed as
+# enviroments to Gemtexter
+test -z "$CONFIG_FILE_PATH" && CONFIG_FILE_PATH=''
+test -z "$GIT_COMMIT_MESSAGE" && GIT_COMMIT_MESSAGE=''
+test -z "$LOG_VERBOSE" && LOG_VERBOSE=''
+
+set -euf -o pipefail
if [[ -n "$CONFIG_FILE_PATH" ]]; then
source "$CONFIG_FILE_PATH"
diff --git a/lib/generate.source.sh b/lib/generate.source.sh
index 848e7fd..1c0a823 100644
--- a/lib/generate.source.sh
+++ b/lib/generate.source.sh
@@ -2,8 +2,8 @@
generate::make_link () {
local -r what="$1"; shift
local -r line="${1/=> }"; shift
- local link
- local descr
+ local link=''
+ local descr=''
while read -r token; do
if [ -z "$link" ]; then