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

exit with underlying exit code #98

Merged
merged 2 commits into from
Jan 11, 2017
Merged

Conversation

asobrien
Copy link

@asobrien asobrien commented Jan 10, 2017

fixes #37

@asobrien asobrien changed the title fixes #37 exit with underlying exit code exit with underlying exit code Jan 10, 2017
Copy link
Member

@brikis98 brikis98 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

@@ -32,7 +34,13 @@ func checkForErrorsAndExit(err error) {
} else {
logger.Println(err)
}
os.Exit(1)
// exit with the underlying error code
var retCode int
Copy link
Member

Choose a reason for hiding this comment

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

You should default this to 1. Otherwise, if the error is not an ExitError, this will exit with a 0.

Copy link
Author

Choose a reason for hiding this comment

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

Ah, of course! Done.

// exit with the underlying error code
var retCode int
if exiterr, ok := errors.Unwrap(err).(*exec.ExitError); ok {
status := exiterr.Sys().(syscall.WaitStatus)
Copy link
Member

Choose a reason for hiding this comment

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

Does this work on all OS's?

Copy link
Author

Choose a reason for hiding this comment

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

This will work on darwin, linux, and windows (all the terragrunt OS's).

It's not completely portable (plan9 prob won't work) but unfortunately there's no portable way to get the exit code. Fortunately, windows and *nix have the same method signatures.

Copy link
Member

Choose a reason for hiding this comment

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

Got it!

@brikis98
Copy link
Member

LGTM. Thank you!

@brikis98 brikis98 merged commit 29d4f93 into gruntwork-io:master Jan 11, 2017
@brikis98
Copy link
Member

Just created a new release here: https://github.com/gruntwork-io/terragrunt/releases/tag/v0.8.1. If the build passes, the new binaries should show up in a few minutes.

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.

terragrunt plan should respect -detailed-exitcode
2 participants