Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: change log function to work with set -euo pipefail #6

Merged
merged 1 commit into from
Oct 20, 2022

Conversation

vmarora
Copy link

@vmarora vmarora commented Oct 18, 2022

When set -euo pipefail is used in a script, the script exits when there is a failure. There are side effects that one needs to be aware of like mentioned here https://gist.github.com/mohanpedala/1e2ff5661761d3abd0385e8223e16425?permalink_comment_id=4326440#gistcomment-4326440. The log function in the script checks for "[ "${lvl,,}" == error ]" and uses && operator to exit. However when the condition check does not succeed, this gets treated as error and the script exits. The fix is to use if check here which does not cause set -e to trigger exit.

When set -euo pipefail is used in a script, the script exits when there is a failure. There are side effects that one needs to be aware of like mentioned here https://gist.github.com/mohanpedala/1e2ff5661761d3abd0385e8223e16425?permalink_comment_id=4326440#gistcomment-4326440. The log function in the script checks for "[ "${lvl,,}" == error ]" and uses && operator to exit. However when the condition check does not succeed, this gets treated as error and the script exits. The fix is to use if check here which does not cause set -e to trigger exit.
@sentoz sentoz merged commit a0a4d83 into sentoz:main Oct 20, 2022
@sentoz
Copy link
Owner

sentoz commented Oct 20, 2022

@vmarora Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants