Skip to content

Commit

Permalink
avoids -I with multiple inputs on index/reindex
Browse files Browse the repository at this point in the history
  • Loading branch information
vasudeva8 committed Sep 12, 2023
1 parent 08a0f9a commit 504c532
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 1 addition & 3 deletions bgzip.1
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ bgzip \- Block compression/decompression utility
.IR size ]
.RB [ -@
.IR threads ]
.RI [ file1 ]
.RI [ file2 ]
.RI [ ... ]
.RI [[ file1 ][...]]
.PP
.SH DESCRIPTION
.PP
Expand Down
8 changes: 7 additions & 1 deletion bgzip.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,12 @@ int main(int argc, char **argv)
fprintf(stderr, "[bgzip] Index file name expected with rebgzip. See -I option.\n");
return 1;
}
/* avoid -I / indexfile with multiple inputs while index/reindex. these wont be set during
read/decompress and are not considered even if set */
if ( (index || reindex) && index_fname && argc - optind > 1) {
fprintf(stderr, "[bgzip] Cannot specify index filename with multiple data file on index, reindex.\n");
return 1;
}

do {
isstdin = optind >= argc ? 1 : !strcmp("-", argv[optind]); //using stdin or not?
Expand All @@ -224,7 +230,7 @@ int main(int argc, char **argv)
return 1;
}

if ( argc>optind && !isstdin )
if ( argc>optind && !isstdin ) //named input file that isn't an explicit "-"
{
if (pstdout)
fp = bgzf_open("-", out_mode);
Expand Down

0 comments on commit 504c532

Please sign in to comment.