Annotation of src/usr.bin/patch/patch.1, Revision 1.34
1.34 ! schwarze 1: .\" $OpenBSD: patch.1,v 1.33 2021/11/09 16:13:40 jmc Exp $
1.6 jmc 2: .\" Copyright 1986, Larry Wall
3: .\"
4: .\" Redistribution and use in source and binary forms, with or without
5: .\" modification, are permitted provided that the following condition
6: .\" is met:
7: .\" 1. Redistributions of source code must retain the above copyright
8: .\" notice, this condition and the following disclaimer.
1.7 deraadt 9: .\"
1.6 jmc 10: .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
11: .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
12: .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
13: .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
14: .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
15: .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
16: .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
17: .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
18: .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
19: .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
20: .\" SUCH DAMAGE.
21: .\"
1.34 ! schwarze 22: .Dd $Mdocdate: November 9 2021 $
1.9 jmc 23: .Dt PATCH 1
24: .Os
25: .Sh NAME
26: .Nm patch
27: .Nd apply a diff file to an original
28: .Sh SYNOPSIS
29: .Nm patch
1.18 sobrado 30: .Bk -words
31: .Op Fl bCcEeflNnRstuv
32: .Op Fl B Ar backup-prefix
33: .Op Fl D Ar symbol
34: .Op Fl d Ar directory
35: .Op Fl F Ar max-fuzz
36: .Op Fl i Ar patchfile
37: .Op Fl o Ar out-file
38: .Op Fl p Ar strip-count
39: .Op Fl r Ar rej-name
40: .Op Fl V Cm t | nil | never
41: .Op Fl x Ar number
42: .Op Fl z Ar backup-ext
43: .Op Fl Fl posix
1.9 jmc 44: .Op Ar origfile Op Ar patchfile
1.18 sobrado 45: .Ek
1.9 jmc 46: .Nm patch
47: .Pf \*(Lt Ar patchfile
48: .Sh DESCRIPTION
49: .Nm
1.34 ! schwarze 50: takes the text file
! 51: .Ar patchfile
! 52: containing any of the four forms of difference
1.1 deraadt 53: listing produced by the
1.9 jmc 54: .Xr diff 1
1.34 ! schwarze 55: program and applies those differences to an original text file,
1.9 jmc 56: producing a patched version.
1.1 deraadt 57: If
1.9 jmc 58: .Ar patchfile
1.17 millert 59: is omitted, or is a hyphen, the patch will be read from the standard input.
1.9 jmc 60: .Pp
61: .Nm
1.23 jmc 62: will attempt to determine the type of the diff listing, unless overruled by a
1.9 jmc 63: .Fl c ,
64: .Fl e ,
65: .Fl n ,
1.1 deraadt 66: or
1.9 jmc 67: .Fl u
1.11 millert 68: option.
1.9 jmc 69: .Pp
1.17 millert 70: If the
71: .Ar patchfile
72: contains more than one patch,
1.9 jmc 73: .Nm
1.1 deraadt 74: will try to apply each of them as if they came from separate patch files.
75: This means, among other things, that it is assumed that the name of the file
1.17 millert 76: to patch must be determined for each diff listing, and that the garbage before
77: each diff listing will be examined for interesting things such as file names
78: and revision level (see the section on
79: .Sx Filename Determination
80: below).
1.9 jmc 81: .Pp
1.11 millert 82: The options are as follows:
1.9 jmc 83: .Bl -tag -width Ds
1.18 sobrado 84: .It Xo
85: .Fl B Ar backup-prefix ,
86: .Fl Fl prefix Ar backup-prefix
87: .Xc
88: Causes the next argument to be interpreted as a prefix to the backup file
89: name.
90: If this argument is specified, any argument to
91: .Fl z
92: will be ignored.
1.12 millert 93: .It Fl b , Fl Fl backup
94: Save a backup copy of the file before it is modified.
95: By default the original file is saved with a backup extension of
96: .Qq .orig
97: unless the file already has a numbered backup, in which case a numbered
98: backup is made.
99: This is equivalent to specifying
1.18 sobrado 100: .Qo Fl V Cm existing Qc .
1.22 jmc 101: This option is currently the default, unless
102: .Fl -posix
103: is specified.
1.32 zhuk 104: .It Fl C , Fl Fl check , Fl Fl dry-run
1.18 sobrado 105: Checks that the patch would apply cleanly, but does not modify anything.
1.9 jmc 106: .It Fl c , Fl Fl context
107: Forces
108: .Nm
1.1 deraadt 109: to interpret the patch file as a context diff.
1.18 sobrado 110: .It Xo
111: .Fl D Ar symbol ,
112: .Fl Fl ifdef Ar symbol
113: .Xc
1.9 jmc 114: Causes
115: .Nm
116: to use the
117: .Qq #ifdef...#endif
118: construct to mark changes.
1.1 deraadt 119: The argument following will be used as the differentiating symbol.
120: Note that, unlike the C compiler, there must be a space between the
1.9 jmc 121: .Fl D
1.1 deraadt 122: and the argument.
1.18 sobrado 123: .It Xo
124: .Fl d Ar directory ,
125: .Fl Fl directory Ar directory
126: .Xc
127: Causes
128: .Nm
1.21 jmc 129: to interpret the next argument as a directory,
130: and change working directory to it before doing anything else.
1.18 sobrado 131: .It Fl E , Fl Fl remove-empty-files
132: Causes
133: .Nm
134: to remove output files that are empty after the patches have been applied.
135: This option is useful when applying patches that create or remove files.
1.9 jmc 136: .It Fl e , Fl Fl ed
137: Forces
138: .Nm
139: to interpret the patch file as an
140: .Xr ed 1
141: script.
1.18 sobrado 142: .It Xo
143: .Fl F Ar max-fuzz ,
144: .Fl Fl fuzz Ar max-fuzz
145: .Xc
146: Sets the maximum fuzz factor.
147: This option only applies to context diffs, and causes
1.9 jmc 148: .Nm
1.18 sobrado 149: to ignore up to that many lines in looking for places to install a hunk.
150: Note that a larger fuzz factor increases the odds of a faulty patch.
151: The default fuzz factor is 2, and it may not be set to more than
152: the number of lines of context in the context diff, ordinarily 3.
1.9 jmc 153: .It Fl f , Fl Fl force
154: Forces
155: .Nm
1.1 deraadt 156: to assume that the user knows exactly what he or she is doing, and to not
1.9 jmc 157: ask any questions.
158: It assumes the following:
159: skip patches for which a file to patch can't be found;
160: patch files even though they have the wrong version for the
161: .Qq Prereq:
162: line in the patch;
163: and assume that patches are not reversed even if they look like they are.
1.1 deraadt 164: This option does not suppress commentary; use
1.9 jmc 165: .Fl s
1.1 deraadt 166: for that.
1.9 jmc 167: .It Xo
1.18 sobrado 168: .Fl i Ar patchfile ,
169: .Fl Fl input Ar patchfile
1.9 jmc 170: .Xc
1.15 millert 171: Causes the next argument to be interpreted as the input file name
172: (i.e. a patchfile).
1.9 jmc 173: .It Fl l , Fl Fl ignore-whitespace
174: Causes the pattern matching to be done loosely, in case the tabs and
1.1 deraadt 175: spaces have been munged in your input file.
176: Any sequence of whitespace in the pattern line will match any sequence
177: in the input file.
178: Normal characters must still match exactly.
179: Each line of the context must still match a line in the input file.
1.9 jmc 180: .It Fl N , Fl Fl forward
181: Causes
182: .Nm
1.1 deraadt 183: to ignore patches that it thinks are reversed or already applied.
184: See also
1.9 jmc 185: .Fl R .
1.18 sobrado 186: .It Fl n , Fl Fl normal
187: Forces
188: .Nm
189: to interpret the patch file as a normal diff.
190: .It Xo
191: .Fl o Ar out-file ,
192: .Fl Fl output Ar out-file
193: .Xc
1.9 jmc 194: Causes the next argument to be interpreted as the output file name.
195: .It Xo
1.18 sobrado 196: .Fl p Ar strip-count ,
197: .Fl Fl strip Ar strip-count
1.9 jmc 198: .Xc
199: Sets the pathname strip count,
200: which controls how pathnames found in the patch file are treated,
201: in case you keep your files in a different directory than the person who sent
1.1 deraadt 202: out the patch.
203: The strip count specifies how many slashes are to be stripped from
204: the front of the pathname.
205: (Any intervening directory names also go away.)
1.17 millert 206: For example, supposing the file name in the patch file was
1.9 jmc 207: .Pa /u/howard/src/blurfl/blurfl.c :
208: .Pp
209: Setting
210: .Fl p Ns Ar 0
211: gives the entire pathname unmodified.
212: .Pp
213: .Fl p Ns Ar 1
1.1 deraadt 214: gives
1.9 jmc 215: .Pp
216: .D1 Pa u/howard/src/blurfl/blurfl.c
217: .Pp
218: without the leading slash.
219: .Pp
220: .Fl p Ns Ar 4
1.1 deraadt 221: gives
1.9 jmc 222: .Pp
223: .D1 Pa blurfl/blurfl.c
224: .Pp
225: Not specifying
226: .Fl p
227: at all just gives you
228: .Pa blurfl.c ,
229: unless all of the directories in the leading path
230: .Pq Pa u/howard/src/blurfl
231: exist and that path is relative,
1.1 deraadt 232: in which case you get the entire pathname unmodified.
233: Whatever you end up with is looked for either in the current directory,
234: or the directory specified by the
1.9 jmc 235: .Fl d
1.11 millert 236: option.
1.9 jmc 237: .It Fl R , Fl Fl reverse
238: Tells
239: .Nm
1.1 deraadt 240: that this patch was created with the old and new files swapped.
241: (Yes, I'm afraid that does happen occasionally, human nature being what it
242: is.)
1.9 jmc 243: .Nm
1.1 deraadt 244: will attempt to swap each hunk around before applying it.
245: Rejects will come out in the swapped format.
246: The
1.9 jmc 247: .Fl R
1.11 millert 248: option will not work with ed diff scripts because there is too little
1.1 deraadt 249: information to reconstruct the reverse operation.
1.9 jmc 250: .Pp
1.1 deraadt 251: If the first hunk of a patch fails,
1.9 jmc 252: .Nm
1.1 deraadt 253: will reverse the hunk to see if it can be applied that way.
254: If it can, you will be asked if you want to have the
1.9 jmc 255: .Fl R
1.11 millert 256: option set.
1.1 deraadt 257: If it can't, the patch will continue to be applied normally.
258: (Note: this method cannot detect a reversed patch if it is a normal diff
259: and if the first command is an append (i.e. it should have been a delete)
260: since appends always succeed, due to the fact that a null context will match
261: anywhere.
262: Luckily, most patches add or change lines rather than delete them, so most
263: reversed normal diffs will begin with a delete, which will fail, triggering
264: the heuristic.)
1.9 jmc 265: .It Xo
1.18 sobrado 266: .Fl r Ar rej-name ,
267: .Fl Fl reject-file Ar rej-name
268: .Xc
269: Causes the next argument to be interpreted as the reject file name.
270: .It Xo
1.9 jmc 271: .Fl s , Fl Fl quiet ,
272: .Fl Fl silent
273: .Xc
274: Makes
275: .Nm
1.1 deraadt 276: do its work silently, unless an error occurs.
1.17 millert 277: .It Fl t , Fl Fl batch
278: Similar to
279: .Fl f ,
280: in that it suppresses questions, but makes some different assumptions:
281: skip patches for which a file to patch can't be found (the same as
282: .Fl f ) ;
283: skip patches for which the file has the wrong version for the
284: .Qq Prereq:
285: line in the patch;
286: and assume that patches are reversed if they look like they are.
1.9 jmc 287: .It Fl u , Fl Fl unified
288: Forces
289: .Nm
1.1 deraadt 290: to interpret the patch file as a unified context diff (a unidiff).
1.18 sobrado 291: .It Xo
292: .Fl V Cm t | nil | never ,
293: .Fl Fl version-control Cm t | nil | never
294: .Xc
1.9 jmc 295: Causes the next argument to be interpreted as a method for creating
296: backup file names.
297: The type of backups made can also be given in the
1.17 millert 298: .Ev PATCH_VERSION_CONTROL
299: or
1.9 jmc 300: .Ev VERSION_CONTROL
1.17 millert 301: environment variables, which are overridden by this option.
1.1 deraadt 302: The
1.9 jmc 303: .Fl B
1.1 deraadt 304: option overrides this option, causing the prefix to always be used for
305: making backup file names.
1.17 millert 306: The values of the
307: .Ev PATCH_VERSION_CONTROL
308: and
1.9 jmc 309: .Ev VERSION_CONTROL
1.17 millert 310: environment variables and the argument to the
1.9 jmc 311: .Fl V
312: option are like the GNU Emacs
313: .Dq version-control
314: variable; they also recognize synonyms that are more descriptive.
315: The valid values are (unique abbreviations are accepted):
316: .Bl -tag -width Ds -offset indent
1.18 sobrado 317: .It Cm t , numbered
1.1 deraadt 318: Always make numbered backups.
1.18 sobrado 319: .It Cm nil , existing
1.9 jmc 320: Make numbered backups of files that already have them,
321: simple backups of the others.
1.18 sobrado 322: .It Cm never , simple
1.1 deraadt 323: Always make simple backups.
1.9 jmc 324: .El
1.18 sobrado 325: .It Fl v , Fl Fl version
326: Causes
327: .Nm
328: to print out its revision header and patch level.
1.9 jmc 329: .It Xo
1.18 sobrado 330: .Fl x Ar number ,
331: .Fl Fl debug Ar number
1.9 jmc 332: .Xc
333: Sets internal debugging flags, and is of interest only to
334: .Nm
1.1 deraadt 335: patchers.
1.18 sobrado 336: .It Xo
337: .Fl z Ar backup-ext ,
338: .Fl Fl suffix Ar backup-ext
339: .Xc
1.12 millert 340: Causes the next argument to be interpreted as the backup extension, to be
341: used in place of
342: .Qq .orig .
1.17 millert 343: .It Fl Fl posix
344: Enables strict
1.24 jmc 345: .St -p1003.1-2008
1.17 millert 346: conformance, specifically:
347: .Bl -enum
348: .It
349: Backup files are not created unless the
350: .Fl b
351: option is specified.
352: .It
353: If unspecified, the file name used is the first of the old, new and
354: index files that exists.
355: .El
356: .El
357: .Ss Patch Application
358: .Nm
359: will try to skip any leading garbage, apply the diff,
360: and then skip any trailing garbage.
361: Thus you could feed an article or message containing a
362: diff listing to
363: .Nm patch ,
364: and it should work.
365: If the entire diff is indented by a consistent amount,
366: this will be taken into account.
367: .Pp
368: With context diffs, and to a lesser extent with normal diffs,
369: .Nm
370: can detect when the line numbers mentioned in the patch are incorrect,
371: and will attempt to find the correct place to apply each hunk of the patch.
372: As a first guess, it takes the line number mentioned for the hunk, plus or
373: minus any offset used in applying the previous hunk.
374: If that is not the correct place,
375: .Nm
376: will scan both forwards and backwards for a set of lines matching the context
377: given in the hunk.
378: First
379: .Nm
380: looks for a place where all lines of the context match.
381: If no such place is found, and it's a context diff, and the maximum fuzz factor
382: is set to 1 or more, then another scan takes place ignoring the first and last
383: line of context.
384: If that fails, and the maximum fuzz factor is set to 2 or more,
385: the first two and last two lines of context are ignored,
386: and another scan is made.
387: .Pq The default maximum fuzz factor is 2.
388: .Pp
389: If
390: .Nm
391: cannot find a place to install that hunk of the patch, it will put the hunk
392: out to a reject file, which normally is the name of the output file plus
393: .Qq .rej .
394: (Note that the rejected hunk will come out in context diff form whether the
395: input patch was a context diff or a normal diff.
396: If the input was a normal diff, many of the contexts will simply be null.)
397: The line numbers on the hunks in the reject file may be different than
398: in the patch file: they reflect the approximate location patch thinks the
399: failed hunks belong in the new file rather than the old one.
400: .Pp
401: As each hunk is completed, you will be told whether the hunk succeeded or
402: failed, and which line (in the new file)
403: .Nm
404: thought the hunk should go on.
405: If this is different from the line number specified in the diff,
406: you will be told the offset.
407: A single large offset MAY be an indication that a hunk was installed in the
408: wrong place.
409: You will also be told if a fuzz factor was used to make the match, in which
410: case you should also be slightly suspicious.
411: .Ss Filename Determination
412: If no original file is specified on the command line,
413: .Nm
414: will try to figure out from the leading garbage what the name of the file
415: to edit is.
416: When checking a prospective file name, pathname components are stripped
417: as specified by the
418: .Fl p
419: option and the file's existence and writability are checked relative
420: to the current working directory (or the directory specified by the
421: .Fl d
422: option).
423: .Pp
424: If the diff is a context or unified diff,
425: .Nm
426: is able to determine the old and new file names from the diff header.
427: For context diffs, the
428: .Dq old
429: file is specified in the line beginning with
430: .Qq ***
431: and the
432: .Dq new
433: file is specified in the line beginning with
434: .Qq --- .
435: For a unified diff, the
436: .Dq old
437: file is specified in the line beginning with
438: .Qq ---
439: and the
440: .Dq new
441: file is specified in the line beginning with
442: .Qq +++ .
443: If there is an
444: .Qq Index:
445: line in the leading garbage (regardless of the diff type),
446: .Nm
447: will use the file name from that line as the
448: .Dq index
449: file.
450: .Pp
451: .Nm
452: will choose the file name by performing the following steps, with the first
453: match used:
454: .Bl -enum
455: .It
456: If
457: .Nm
458: is operating in strict
1.24 jmc 459: .St -p1003.1-2008
1.17 millert 460: mode, the first of the
461: .Dq old ,
462: .Dq new
463: and
464: .Dq index
465: file names that exist is used.
466: Otherwise,
467: .Nm
468: will examine either the
469: .Dq old
470: and
471: .Dq new
472: file names or, for a non-context diff, the
473: .Dq index
474: file name, and choose the file name with the fewest path components,
475: the shortest basename, and the shortest total file name length (in that order).
476: .It
477: If no suitable file was found to patch, the patch file is a context or
478: unified diff, and the old file was zero length, the new file name is
479: created and used.
480: .It
481: If the file name still cannot be determined,
482: .Nm
483: will prompt the user for the file name to use.
1.9 jmc 484: .El
1.17 millert 485: .Pp
486: Additionally, if the leading garbage contains a
487: .Qq Prereq:\ \&
488: line,
489: .Nm
490: will take the first word from the prerequisites line (normally a version
491: number) and check the input file to see if that word can be found.
492: If not,
493: .Nm
494: will ask for confirmation before proceeding.
495: .Pp
496: The upshot of all this is that you should be able to say, while in a news
497: interface, the following:
498: .Pp
499: .Dl | patch -d /usr/src/local/blurfl
500: .Pp
501: and patch a file in the blurfl directory directly from the article containing
502: the patch.
503: .Ss Backup Files
504: By default, the patched version is put in place of the original, with
505: the original file backed up to the same name with the extension
506: .Qq .orig ,
507: or as specified by the
508: .Fl B ,
509: .Fl V ,
510: or
511: .Fl z
512: options.
513: The extension used for making backup files may also be specified in the
514: .Ev SIMPLE_BACKUP_SUFFIX
515: environment variable, which is overridden by the options above.
516: .Pp
517: If the backup file is a symbolic or hard link to the original file,
518: .Nm
519: creates a new backup file name by changing the first lowercase letter
520: in the last component of the file's name into uppercase.
521: If there are no more lowercase letters in the name,
522: it removes the first character from the name.
523: It repeats this process until it comes up with a
524: backup file that does not already exist or is not linked to the original file.
525: .Pp
526: You may also specify where you want the output to go with the
527: .Fl o
528: option; if that file already exists, it is backed up first.
529: .Ss Notes For Patch Senders
1.1 deraadt 530: There are several things you should bear in mind if you are going to
1.9 jmc 531: be sending out patches:
532: .Pp
533: First, you can save people a lot of grief by keeping a
534: .Pa patchlevel.h
535: file which is patched to increment the patch level as the first diff in the
1.1 deraadt 536: patch file you send out.
1.9 jmc 537: If you put a
538: .Qq Prereq:
539: line in with the patch, it won't let them apply
1.1 deraadt 540: patches out of order without some warning.
1.9 jmc 541: .Pp
1.17 millert 542: Second, make sure you've specified the file names right, either in a
1.9 jmc 543: context diff header, or with an
544: .Qq Index:
545: line.
1.1 deraadt 546: If you are patching something in a subdirectory, be sure to tell the patch
1.4 aaron 547: user to specify a
1.9 jmc 548: .Fl p
1.11 millert 549: option as needed.
1.9 jmc 550: .Pp
1.1 deraadt 551: Third, you can create a file by sending out a diff that compares a
552: null file to the file you want to create.
553: This will only work if the file you want to create doesn't exist already in
554: the target directory.
1.9 jmc 555: .Pp
1.1 deraadt 556: Fourth, take care not to send out reversed patches, since it makes people wonder
557: whether they already applied the patch.
1.9 jmc 558: .Pp
1.1 deraadt 559: Fifth, while you may be able to get away with putting 582 diff listings into
560: one file, it is probably wiser to group related patches into separate files in
561: case something goes haywire.
1.9 jmc 562: .Sh ENVIRONMENT
1.17 millert 563: .Bl -tag -width "PATCH_VERSION_CONTROL" -compact
564: .It Ev POSIXLY_CORRECT
565: When set,
566: .Nm
567: behaves as if the
568: .Fl Fl posix
569: option has been specified.
570: .It Ev SIMPLE_BACKUP_SUFFIX
571: Extension to use for backup file names instead of
572: .Qq .orig .
1.9 jmc 573: .It Ev TMPDIR
574: Directory to put temporary files in; default is
575: .Pa /tmp .
1.17 millert 576: .It Ev PATCH_VERSION_CONTROL
577: Selects when numbered backup files are made.
1.9 jmc 578: .It Ev VERSION_CONTROL
1.17 millert 579: Same as
580: .Ev PATCH_VERSION_CONTROL .
1.9 jmc 581: .El
582: .Sh FILES
1.17 millert 583: .Bl -tag -width "$TMPDIR/patch*" -compact
1.9 jmc 584: .It Pa $TMPDIR/patch*
1.17 millert 585: .Nm
586: temporary files
587: .It Pa /dev/tty
588: used to read input when
589: .Nm
590: prompts the user
1.9 jmc 591: .El
1.26 jmc 592: .Sh EXIT STATUS
593: The
594: .Nm
595: utility exits with one of the following values:
596: .Pp
597: .Bl -tag -width Ds -offset indent -compact
598: .It 0
599: Successful completion.
600: .It 1
601: One or more lines were written to a reject file.
602: .It \*(Gt1
603: An error occurred.
604: .El
605: .Pp
606: When applying a set of patches in a loop it behooves you to check this
607: exit status so you don't apply a later patch to a partially patched file.
1.9 jmc 608: .Sh DIAGNOSTICS
1.1 deraadt 609: Too many to list here, but generally indicative that
1.9 jmc 610: .Nm
1.1 deraadt 611: couldn't parse your patch file.
1.9 jmc 612: .Pp
613: The message
614: .Qq Hmm...
615: indicates that there is unprocessed text in the patch file and that
616: .Nm
1.1 deraadt 617: is attempting to intuit whether there is a patch in that text and, if so,
618: what kind of patch it is.
1.9 jmc 619: .Sh SEE ALSO
620: .Xr diff 1
1.19 jmc 621: .Sh STANDARDS
622: The
623: .Nm
624: utility is compliant with the
1.24 jmc 625: .St -p1003.1-2008
1.27 jmc 626: specification,
627: except as detailed above for the
1.22 jmc 628: .Fl -posix
1.27 jmc 629: option.
1.19 jmc 630: .Pp
631: The flags
1.25 jmc 632: .Op Fl BCEFfstVvxz
1.19 jmc 633: and
634: .Op Fl -posix
635: are extensions to that specification.
1.9 jmc 636: .Sh AUTHORS
1.13 millert 637: .An Larry Wall
1.9 jmc 638: with many other contributors.
639: .Sh CAVEATS
640: .Nm
1.1 deraadt 641: cannot tell if the line numbers are off in an ed script, and can only detect
1.9 jmc 642: bad line numbers in a normal diff when it finds a
643: .Qq change
644: or a
645: .Qq delete
646: command.
1.1 deraadt 647: A context diff using fuzz factor 3 may have the same problem.
648: Until a suitable interactive interface is added, you should probably do
649: a context diff in these cases to see if the changes made sense.
650: Of course, compiling without errors is a pretty good indication that the patch
651: worked, but not always.
1.9 jmc 652: .Pp
653: .Nm
1.1 deraadt 654: usually produces the correct results, even when it has to do a lot of
655: guessing.
656: However, the results are guaranteed to be correct only when the patch is
657: applied to exactly the same version of the file that the patch was
658: generated from.
1.9 jmc 659: .Sh BUGS
660: Could be smarter about partial matches, excessively deviant offsets and
1.1 deraadt 661: swapped code, but that would take an extra pass.
1.9 jmc 662: .Pp
663: Check patch mode
664: .Pq Fl C
1.3 espie 665: will fail if you try to check several patches in succession that build on
1.9 jmc 666: each other.
1.17 millert 667: The entire
1.9 jmc 668: .Nm
1.17 millert 669: code would have to be restructured to keep temporary files around so that it
670: can handle this situation.
1.9 jmc 671: .Pp
1.1 deraadt 672: If code has been duplicated (for instance with #ifdef OLDCODE ... #else ...
673: #endif),
1.9 jmc 674: .Nm
1.29 jmc 675: is incapable of patching both versions and, if it works at all, will likely
1.1 deraadt 676: patch the wrong one, and tell you that it succeeded to boot.
1.9 jmc 677: .Pp
1.1 deraadt 678: If you apply a patch you've already applied,
1.9 jmc 679: .Nm
1.1 deraadt 680: will think it is a reversed patch, and offer to un-apply the patch.
681: This could be construed as a feature.