Abort on non-zero blastcmd exit code #213
Open
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.
Currently, Abricate will exit successfully regardless of the exit code of the BLAST command. This is misleading as failures in the BLAST command (eg. if it is killed by the OOM killer) will emit the message "Found 0 genes in $file", rather than indicating an error has ocurred.
This change checks the exit code of the executed command after
close
is called. If it is non-zero, Abricate will terminate with a brief message and the same exit code; allowing the calling shell to decide what to do with the error.This change uses a bash subshell instead of sh to make use of pipefail. For anyone who wants to continue using sh I wave my hands in the air and leave it as an exercise to anyone who wishes to inspect the exit code of each piped command instead.
I leave this around in the hope it may be useful for someone!