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

Add custom exit codes #234

Open
3 tasks done
nkakouros opened this issue Jan 16, 2018 · 0 comments
Open
3 tasks done

Add custom exit codes #234

nkakouros opened this issue Jan 16, 2018 · 0 comments

Comments

@nkakouros
Copy link

nkakouros commented Jan 16, 2018

Due diligence

Description

It would be useful if the go-script framework used custom, clearly defined exit codes to signify the type of error that occurred.

The main reason I am proposing this is that when a user wants to handle errors in their application via traps or set -eu, the several cases that go-script returns 1 become problematic. For instance, I have a set a error trap in my scripts that outputs a nice stack trace on error. But even bash completion failure triggers the trap (as mentioned here), as do bad flags (eg go-template commands --bad which has its own nice error output), etc. To handle this situation one has to perform ugly checks, like checking if a file exists in the BASH_SOURCE array or if a function exists in the FUNCNAME array. Having custom error codes other than 1 would make handling this situation much easier, as the user can filter out go-script-bash codes and handle only the rest in their custom error trap.

Custom error codes could be based for instance on sysexits.h and new ones introduced in the cases sysexit.h doesn't cover.

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

1 participant