Skip to content

Add custom exit codes #234

Open
Open
@nkakouros

Description

@nkakouros

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions