Skip to content

Commit

Permalink
patch: refuse to process a directory (#556)
Browse files Browse the repository at this point in the history
* When testing against GNU patch, the following usage is invalid: "patch . < some.diff"
* An error is displayed: "File . is not a regular file -- refusing to patch"
* Even with patch -f (force) option the usage is not allowed
* Add extra branch to condition where file-exists check happens to handle this
  • Loading branch information
mknos committed Apr 15, 2024
1 parent 0ea12dc commit acc9877
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion bin/patch
Expand Up @@ -382,7 +382,9 @@ sub bless {
}

# Make sure original file exists.
if ($self->{force} || $self->{batch}) {
if (-e $orig && ! -f $orig) {
$self->skip("File '$orig' is not a regular file\n");
} elsif ($self->{'force'} || $self->{'batch'}) {
-e $orig or $self->skip;
} else {
until (-e $orig) {
Expand Down

0 comments on commit acc9877

Please sign in to comment.