Skip to content

Commit

Permalink
Merge pull request #351 from mknos/pr-stdin
Browse files Browse the repository at this point in the history
pr: support stdin
  • Loading branch information
briandfoy authored Nov 27, 2023
2 parents 2c87271 + adc487c commit 353a290
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions bin/pr
Original file line number Diff line number Diff line change
Expand Up @@ -154,18 +154,26 @@ my $pageno=$startpageno;
foreach(1..$columns) {
push(@COLINFO, &create_col);
}
foreach(@ARGV) {
if (-d $_) {
warn "$Program: '$_' is a directory\n";
exit EX_FAILURE;
}
my $fh= FileHandle->new("$_", "r");
if (! $fh) {
next if ($quietskip);
warn "$Program: Can't open '$_': $!\n";
exit EX_FAILURE;
if (scalar(@ARGV) == 0) {
@ARGV = ('-');
}
foreach my $file (@ARGV) {
my $fh;
if ($file eq '-') {
$fh = *STDIN;
} else {
if (-d $file) {
warn "$Program: '$file' is a directory\n";
exit EX_FAILURE;
}
$fh = FileHandle->new($file, 'r');
if (! $fh) {
next if ($quietskip);
warn "$Program: Can't open '$file': $!\n";
exit EX_FAILURE;
}
}
push(@FINFO, { name => $_,
push(@FINFO, { name => $file,
handle=> $fh,
lineno=> 0,
});
Expand Down

0 comments on commit 353a290

Please sign in to comment.