Skip to content

Commit

Permalink
properly read in from stdin, either by having no arguments or passing…
Browse files Browse the repository at this point in the history
… in "-"
  • Loading branch information
nh13 committed Oct 28, 2015
1 parent 63e974c commit 4354c9f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pbgzip.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,11 @@ main(int argc, char *argv[])
}
}

if ((f_src = open(argv[optind], O_RDONLY)) < 0) {
// read from stdin if no more arguments, or a "-", are/is supplied.
if (optind == argc || 0 == strcmp(argv[optind], "-")) {
f_src = fileno(stdin);
}
else if ((f_src = open(argv[optind], O_RDONLY)) < 0) {
fprintf(stderr, "[pbgzip] %s: %s\n", strerror(errno), argv[optind]);
return 1;
}
Expand Down

0 comments on commit 4354c9f

Please sign in to comment.