Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
contribution under the same terms as this project's license, and
that I have the right to license my contribution under those terms.
cc: @mbland
This PR is an approach to introducing custom exit codes. This is in relation to #234.
Some notes
return x
commands that are used by functions to signal either an error or one of two or more possible outcomes. There are alsoexit x
commands to stop script execution. I rewrite both of these.return
,exit
,return 0
orexit 0
commands are rewritten asreturn "$_GO_EC_OK"
, etc, where the return code will not be but 0. Although adding nothing in functionality, this is done to be consistent.@go()
may return with$_GO_EC_CONFIG
or$_GO_EC_USAGE
. If@go()
were to be called by another function, eg@go.for_lack_of_better_example()
then it would be called like this:return
will return with the return code of@go.another_func
. Assuming that, as a go function,@go.another_func
will return using the custom codes, no change is performed in the code.is rewritten to
Here,
printf
may exit with2
if there are wrong arguments used and1
for other errors._GO_EC_GENERR+1
corresponds to_GO_EC_EXT1
and_GO_EC_GENERR+2
to_GO_EC_EXT2
.But, for instance:
is left as is, since echo will fail only when a write error occurs, which would mean bigger problems anyway.
bats_restore_shell_options
are left as is. Should these be changed as well?