diff options
Diffstat (limited to 'usr.bin/patch')
-rw-r--r-- | usr.bin/patch/backupfile.c | 6 | ||||
-rw-r--r-- | usr.bin/patch/patch.1 | 17 | ||||
-rw-r--r-- | usr.bin/patch/patch.c | 16 | ||||
-rw-r--r-- | usr.bin/patch/util.c | 10 |
4 files changed, 29 insertions, 20 deletions
diff --git a/usr.bin/patch/backupfile.c b/usr.bin/patch/backupfile.c index 5614de91cb9..d4d81a5ddbc 100644 --- a/usr.bin/patch/backupfile.c +++ b/usr.bin/patch/backupfile.c @@ -1,4 +1,4 @@ -/* $OpenBSD: backupfile.c,v 1.14 2003/07/22 17:52:20 deraadt Exp $ */ +/* $OpenBSD: backupfile.c,v 1.15 2003/07/28 16:13:53 millert Exp $ */ /* * backupfile.c -- make Emacs style backup file names Copyright (C) 1990 Free @@ -17,7 +17,7 @@ */ #ifndef lint -static const char rcsid[] = "$OpenBSD: backupfile.c,v 1.14 2003/07/22 17:52:20 deraadt Exp $"; +static const char rcsid[] = "$OpenBSD: backupfile.c,v 1.15 2003/07/28 16:13:53 millert Exp $"; #endif /* not lint */ #include <ctype.h> @@ -260,5 +260,5 @@ get_version(char *version) if (i >= 0) return backup_types[i]; invalid_arg("version control type", version, i); - exit(1); + exit(2); } diff --git a/usr.bin/patch/patch.1 b/usr.bin/patch/patch.1 index 8e4cd81571d..fd0a176cc05 100644 --- a/usr.bin/patch/patch.1 +++ b/usr.bin/patch/patch.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: patch.1,v 1.12 2003/07/25 02:12:45 millert Exp $ +.\" $OpenBSD: patch.1,v 1.13 2003/07/28 16:13:53 millert Exp $ .\" Copyright 1986, Larry Wall .\" .\" Redistribution and use in source and binary forms, with or without @@ -481,14 +481,25 @@ indicates that there is unprocessed text in the patch file and that is attempting to intuit whether there is a patch in that text and, if so, what kind of patch it is. .Pp +The .Nm -will exit with a non-zero status if any reject files were created. +utility exits with one of the following values: +.Pp +.Bl -tag -width Ds -compact -offset indent +.It \&0 +Successful completion. +.It \&1 +One or more lines were written to a reject file. +.It \*[Gt]\&1 +An error occurred. +.El +.Pp When applying a set of patches in a loop it behooves you to check this exit status so you don't apply a later patch to a partially patched file. .Sh SEE ALSO .Xr diff 1 .Sh AUTHORS -.An Larry Wall Aq larry@wall.org +.An Larry Wall with many other contributors. .Sh CAVEATS .Nm diff --git a/usr.bin/patch/patch.c b/usr.bin/patch/patch.c index 55ea6ce6c14..1da4a9e90fa 100644 --- a/usr.bin/patch/patch.c +++ b/usr.bin/patch/patch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: patch.c,v 1.27 2003/07/25 02:12:45 millert Exp $ */ +/* $OpenBSD: patch.c,v 1.28 2003/07/28 16:13:53 millert 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.27 2003/07/25 02:12:45 millert Exp $"; +static const char rcsid[] = "$OpenBSD: patch.c,v 1.28 2003/07/28 16:13:53 millert Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -82,7 +82,7 @@ static char serrbuf[BUFSIZ]; int main(int argc, char *argv[]) { - int hunk = 0, failed = 0, failtotal = 0, patch_seen = 0, i; + int error = 0, hunk, failed, patch_seen = 0, i; LINENUM where, newwhere, fuzz, mymaxfuzz; char *tmpdir, *v; @@ -310,7 +310,7 @@ main(int argc, char *argv[]) fclose(rejfp); rejfp = NULL; if (failed) { - failtotal += failed; + error = 1; if (!*rejname) { if (strlcpy(rejname, outname, sizeof(rejname)) >= sizeof(rejname)) @@ -331,9 +331,7 @@ main(int argc, char *argv[]) } set_signals(1); } - if (!patch_seen) - failtotal++; - my_exit(failtotal); + my_exit(error); /* NOTREACHED */ } @@ -534,7 +532,7 @@ usage(void) " [-Fmax-fuzz] [-o out-file] [-p[strip-count]] [-r rej-name]\n" " [-V {numbered,existing,simple}] [-z backup-ext]\n" " [origfile [patchfile]]\n"); - my_exit(1); + my_exit(EXIT_SUCCESS); } /* @@ -692,7 +690,7 @@ apply_hunk(LINENUM where) say("oldchar = '%c', newchar = '%c'\n", pch_char(old), pch_char(new)); #endif - my_exit(1); + my_exit(2); } else if (pch_char(new) == '!') { copy_till(where + old - 1); if (R_do_defines) { diff --git a/usr.bin/patch/util.c b/usr.bin/patch/util.c index 0874dac002f..885ac4109fe 100644 --- a/usr.bin/patch/util.c +++ b/usr.bin/patch/util.c @@ -1,7 +1,7 @@ -/* $OpenBSD: util.c,v 1.18 2003/07/25 02:12:45 millert Exp $ */ +/* $OpenBSD: util.c,v 1.19 2003/07/28 16:13:53 millert Exp $ */ #ifndef lint -static const char rcsid[] = "$OpenBSD: util.c,v 1.18 2003/07/25 02:12:45 millert Exp $"; +static const char rcsid[] = "$OpenBSD: util.c,v 1.19 2003/07/28 16:13:53 millert Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -199,7 +199,7 @@ fatal(char *fmt, ...) fprintf(stderr, "patch: **** "); vfprintf(stderr, fmt, ap); va_end(ap); - my_exit(1); + my_exit(2); } /* @@ -216,7 +216,7 @@ pfatal(char *fmt, ...) vfprintf(stderr, fmt, ap); va_end(ap); fprintf(stderr, ": %s\n", strerror(errnum)); - my_exit(1); + my_exit(2); } /* @@ -385,7 +385,7 @@ void version(void) { fprintf(stderr, "Patch version 2.0-12u8-OpenBSD\n"); - my_exit(0); + my_exit(EXIT_SUCCESS); } /* |