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(install): return error codes from install script #2664

Merged
merged 1 commit into from Feb 23, 2024

Conversation

hacst
Copy link
Contributor

@hacst hacst commented Feb 22, 2024

Previously exit was called with the stdout content of the main function. This did not make sense and
resulted in the script not returning the expected exit codes when main returned a non-zero code.

Strangely enough this broken code was introduced in response to #1566 but I do not see how it ever worked unless the script used to echo its intended exit code.

Previously exit was called with the stdout content of
the main function. This did not make sense and
resulted in the script not returning the expected
exit codes when main returned a non-zero code.

Strangely enough this broken code was introduced in
response to anchore#1566 but I do not see how it ever worked
unless the script used to echo its intended exit code.

Signed-off-by: Stefan Hacker <mail@hacst.net>
Copy link
Contributor

@kzantow kzantow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @hacst -- I can confirm this version works on sh in alpine:latest and macOS. For what it's worth: the version written as exit $(main "$@") did work properly on macOS, but not alpine, and this seems to be the right way to do it. 👍

@kzantow kzantow merged commit 170ac07 into anchore:main Feb 23, 2024
11 checks passed
hacst added a commit to hacst/grype that referenced this pull request Feb 23, 2024
As the main function was not the last command, it did always
return a zero status code. Exiting right after main allows us to
return the actual return code instead.

Analogous to anchore/syft#2664 .

Signed-off-by: Stefan Hacker <mail@hacst.net>
@hacst hacst deleted the patch-1 branch February 23, 2024 08:46
@kzantow kzantow added the bug Something isn't working label Feb 26, 2024
@kzantow kzantow changed the title fix(install): actually return right error codes fix(install): return error codes from install script Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants