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

Trying to capture exit code when set -e is active #31

Open
dgholz opened this issue Dec 9, 2021 · 1 comment
Open

Trying to capture exit code when set -e is active #31

dgholz opened this issue Dec 9, 2021 · 1 comment

Comments

@dgholz
Copy link
Contributor

dgholz commented Dec 9, 2021

I see in the new composite action, we try to capture the exit code from running & reporting the Brakeman findings:

brakeman [...] | reviewdog [...]

exit_code=$?
echo '::endgroup::'

exit $exit_code

exit_code=$?

I think this is so the ::endgroup:: can be printed to close the group, but because we're running with -e, the script will exit as soon as the first command fails.

The way to capture exit codes under set -e is like:

if ! cmd
then
  exit_code=$?
fi
cleanup
exit $exit_code

or using traps

@dgholz
Copy link
Contributor Author

dgholz commented Dec 9, 2021

In my opinion, this isn't a bug and doesn't need a fix. It's just code that doesn't do anything and might confuse or mislead future maintainers into thinking it serves a purpose.

@mgrachev mgrachev added the help wanted Extra attention is needed label Jan 8, 2022
@mgrachev mgrachev removed the help wanted Extra attention is needed label Apr 20, 2022
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

No branches or pull requests

2 participants