Open
Conversation
jesperpedersen
requested changes
Oct 17, 2022
| There are, however, times when a commands exit code provides important information. In those cases, we have two ways to work with exit codes. | ||
|
|
||
| == Stop on errors | ||
| The first option is to enable exit code checking with either the `-x` ro `--exitCode` command line argument or adding `check-exit-code` to the `settings`. |
|
|
||
| == Specific exit values | ||
|
|
||
| qDup has built in support for zero and non-zero exit codes but a command can return any valid integer as an exit code and some commands provide error information based on the exit number. qDup does not have native support for filtering the exit code but we can add `echo $?` to our scripts the same way we would check the exit code if we were manually runnin commands in an ssh terminal. |
rvansa
requested changes
Oct 17, 2022
| settings: | ||
| check-exit-code: true | ||
| ``` | ||
| Exit code checking will automatically check the exit code of all `sh` commands that end with the default qDup prompt. We don't check the exit code of commands that end with a prompt from `add-prompt` because those commands are typically in a sub-shell that may not support exit codes. qDup will then abort if the exit code is non-zero. This is a very strict way to enforce exit codes and most scripts probably are not written to consider exit codes. |
Member
There was a problem hiding this comment.
Could you also do
- sh:
command: maybe_fail
check-exit-code: true
or do you have to do this?
- sh: maybe_fail || echo "__command_failed__"
then:
- regex: "__command_failed__"
then:
- abort: command failed
Collaborator
Author
There was a problem hiding this comment.
both should work to end the run if maybe_fail had a non-zero exit code
| #> echo $? | ||
| 127 | ||
| ``` | ||
| There are, however, times when a commands exit code provides important information. In those cases, we have two ways to work with exit codes. |
Member
There was a problem hiding this comment.
I wouldn't say "two ways to work with exit codes" because these are not really 'generic' ways. Rather sum it up as "abort on non-zero" and "process exit code as text" or something similar.
Member
|
Bump, is this going to be improved any further? |
Member
|
@willr3 is there any more to add to this doc? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.