how to fail on first error when using bash as a template tool
0
votes
2
answers
218
views
I am looking for a better version of
set -e
. That better version should just work™. I briefly read [BashFaq/105](http://mywiki.wooledge.org/BashFAQ/105) and tried [this insane approach](https://fvue.nl/wiki/Bash:_Error_handling#Solutions_revisited:_Combining_the_tools) , but I still do not know how to fail on error.
My use case is that I would like to generate a text file from a template like this:
#!/usr/bin/env bash
# none of these options helped to get the behavior I want: stop on first error
# set -euo pipefail
# shopt -s inherit_errexit
# set -o errexit
# trap ERR
cat
MYAPP_DATABASE_PASSWORD=
MYAPP_USER_PASSWORD=
MYAPP_CONFIGURATION_DATE=
if there is a typo in SecureRandom
then erb
immediately exits with a failure.
**How to achieve this crash-on-failure behavior with bash?**
Asked by Julius
(101 rep)
Jan 2, 2021, 06:21 PM
Last activity: Jan 4, 2021, 01:11 AM
Last activity: Jan 4, 2021, 01:11 AM