summaryrefslogtreecommitdiffstats
path: root/usr.bin/patch/patch.c
diff options
context:
space:
mode:
authorstsp <stsp@openbsd.org>2009-04-05 13:36:00 +0000
committerstsp <stsp@openbsd.org>2009-04-05 13:36:00 +0000
commit79be82bf7e5f686c69395ce499378dc189f83a5c (patch)
tree23357e35df22241ab41cdf3995b8bae905cef6ba /usr.bin/patch/patch.c
parentRework the vblank subsystem so that instead of having various bits in (diff)
downloadwireguard-openbsd-79be82bf7e5f686c69395ce499378dc189f83a5c.tar.xz
wireguard-openbsd-79be82bf7e5f686c69395ce499378dc189f83a5c.zip
If no patch can be found in input, in addition to complaining on stderr,
have the exit code indicate failure, not success. Discrepancy with GNU patch pointed out by Arfrever Frehtes Taifersar Arahesis. Help from and ok djm@, "sounds good to me" millert@
Diffstat (limited to 'usr.bin/patch/patch.c')
-rw-r--r--usr.bin/patch/patch.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/usr.bin/patch/patch.c b/usr.bin/patch/patch.c
index 6bef90a337c..33f1441fbbe 100644
--- a/usr.bin/patch/patch.c
+++ b/usr.bin/patch/patch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: patch.c,v 1.46 2008/08/20 18:28:46 otto Exp $ */
+/* $OpenBSD: patch.c,v 1.47 2009/04/05 13:36:00 stsp Exp $ */
/*
* patch - a program to apply diffs to original files
@@ -27,7 +27,7 @@
*/
#ifndef lint
-static const char rcsid[] = "$OpenBSD: patch.c,v 1.46 2008/08/20 18:28:46 otto Exp $";
+static const char rcsid[] = "$OpenBSD: patch.c,v 1.47 2009/04/05 13:36:00 stsp Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -149,6 +149,7 @@ int
main(int argc, char *argv[])
{
int error = 0, hunk, failed, i, fd;
+ bool patch_seen;
LINENUM where = 0, newwhere, fuzz, mymaxfuzz;
const char *tmpdir;
char *v;
@@ -208,9 +209,12 @@ main(int argc, char *argv[])
/* make sure we clean up /tmp in case of disaster */
set_signals(0);
+ patch_seen = false;
for (open_patch_file(filearg[1]); there_is_another_patch();
reinitialize_almost_everything()) {
/* for each patch in patch file */
+
+ patch_seen = true;
warn_on_invalid_line = true;
@@ -397,6 +401,10 @@ main(int argc, char *argv[])
}
set_signals(1);
}
+
+ if (!patch_seen)
+ error = 2;
+
my_exit(error);
/* NOTREACHED */
}