Skip to content

Commit db0ce31

Browse files
authored
Merge pull request #213 from SamStudio8/check_blastcmd_exitcode
Abort on non-zero blastcmd exit
2 parents 2ae68c0 + 03afa8f commit db0ce31

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

bin/abricate

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,13 @@ for my $file (@ARGV) {
121121
: "blastx -task blastx-fast -seg no"
122122
;
123123

124-
my $cmd = "(any2fasta -q -u \Q$file\E |"
125-
. " $blastcmd -db \Q$db_path\E -outfmt '$format' -num_threads $threads"
124+
my $cmd = "bash -c 'set -euo pipefail;"
125+
. " any2fasta -q -u \Q$file\E |"
126+
. " $blastcmd -db \Q$db_path\E -outfmt \"$format\" -num_threads $threads"
126127
. " -evalue 1E-20 -culling_limit $CULL"
127128
. " -max_target_seqs 10000" # https://github.com/tseemann/abricate/issues/135
128129
# . " -max_target_seqs ".$dbinfo->{SEQUENCES} # Issue #76
129-
. ")"
130+
. "'"
130131
;
131132

132133
msg("Running: $cmd") if $debug;
@@ -183,6 +184,12 @@ for my $file (@ARGV) {
183184
];
184185
}
185186
close BLAST;
187+
# Check the exit status of BLAST handle and abort
188+
my $exitcode = $? >> 8;
189+
if ($exitcode != 0) {
190+
msg("Command exited with non-zero exit code $exitcode. Aborting Abricate.");
191+
exit($exitcode);
192+
}
186193

187194
msg("Found", scalar(@hit), "genes in $file");
188195

0 commit comments

Comments
 (0)