Skip to content

Commit deba4d8

Browse files
jkbonfieldpd3
authored andcommitted
Fix a regression with -Ou format being the same as -Ob.
Commit 30dbc3c broke the -Ou option when a filename is given. So `bcftools sort -Ou -o out.bcf in.vcf` is treated as -Ob instead. Hence this was a regression in functionality that arrived with bcftools 1.12. The fix is simply to honour Ou vs Ob even when filenames are specified, and only use the filename suffix when it's incompatible with the data type specified. Fixes #2263
1 parent 37f1600 commit deba4d8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

version.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ void set_wmode(char dst[8], int file_type, const char *fname, int clevel)
8888
const char *end = fname ? strstr(fname, HTS_IDX_DELIM) : NULL;
8989
if ( !end ) end = fname ? fname + strlen(fname) : fname;
9090
int len = end - fname;
91-
if ( len >= 4 && !strncasecmp(".bcf",fname+len-4,4) ) ret = hts_bcf_wmode(FT_BCF|FT_GZ);
91+
if ( len >= 4 && !strncasecmp(".bcf",fname+len-4,4) )
92+
ret = hts_bcf_wmode(file_type & FT_BCF ? file_type : FT_BCF|FT_GZ);
9293
else if ( len >= 4 && !strncasecmp(".vcf",fname+len-4,4) ) ret = hts_bcf_wmode(FT_VCF);
9394
else if ( len >= 7 && !strncasecmp(".vcf.gz",fname+len-7,7) ) ret = hts_bcf_wmode(FT_VCF|FT_GZ);
9495
else if ( len >= 8 && !strncasecmp(".vcf.bgz",fname+len-8,8) ) ret = hts_bcf_wmode(FT_VCF|FT_GZ);

0 commit comments

Comments
 (0)