Skip to content

Commit

Permalink
Merge pull request #361 from mknos/diff-stdindir
Browse files Browse the repository at this point in the history
diff: comparing stdin with directory
  • Loading branch information
briandfoy authored Dec 2, 2023
2 parents a95471c + cb6b76b commit 7c6bf13
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions bin/diff
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,10 @@ my ($fh1, $fh2);

if ($file1 eq '-') {
exit 0 if ($file2 eq '-');
bag("cannot compare '-' to a directory") if (-d $file2);
$fh1 = *STDIN;
} elsif (-d $file1) {
bag("cannot compare '-' to a directory") if ($file2 eq '-');
bag("'$file2': is a directory") if (-d $file2);
my $path = join('/', $file1, basename($file2));
open($fh1, '<', $path) or bag("Couldn't open '$path': $!");
Expand Down

0 comments on commit 7c6bf13

Please sign in to comment.