modernisation-platform
modernisation-platform copied to clipboard
Use 'set -Eeuo pipefail' in bash scripts
User Story
The issue https://github.com/ministryofjustice/modernisation-platform/issues/1166 highlighted the fact that some scripts continue to run instead of exiting with error code. This means that the GitHub job reports success while there are fatal errors during the execution. To fix this issue we need to set set -Eeuo pipefail
in the beginning of the script, as documented in https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
Unfortunately, a lot of our bash scripts under the scripts directory in the modernisation-platform repository have the same issue. Perhaps it would make sense to proactively update all/most of them to use set -Eeuo pipefail
, unless some of them require otherwise due to their logic. Talk to @davidkelliott as there are some scripts which might need to continue upon failure, or might need to be refactored to deal with "expected" error codes.
Value
Questions / Assumptions
Definition of done
- [ ] readme has been updated
- [ ] user docs have been updated
- [ ] another team member has reviewed
- [ ] tests are green