1PATCH(1) General Commands Manual PATCH(1)
2
3
4
6 patch - apply a diff file to an original
7
9 patch [options] [originalfile [patchfile]]
10
11 but usually just
12
13 patch -pnum <patchfile
14
16 patch takes a patch file patchfile containing a difference listing pro‐
17 duced by the diff program and applies those differences to one or more
18 original files, producing patched versions. Normally the patched ver‐
19 sions are put in place of the originals. Backups can be made; see the
20 -b or --backup option. The names of the files to be patched are usu‐
21 ally taken from the patch file, but if there's just one file to be
22 patched it can be specified on the command line as originalfile.
23
24 Upon startup, patch attempts to determine the type of the diff listing,
25 unless overruled by a -c (--context), -e (--ed), -n (--normal), or -u
26 (--unified) option. Context diffs (old-style, new-style, and unified)
27 and normal diffs are applied by the patch program itself, while ed
28 diffs are simply fed to the ed(1) editor via a pipe.
29
30 patch tries to skip any leading garbage, apply the diff, and then skip
31 any trailing garbage. Thus you could feed an article or message con‐
32 taining a diff listing to patch, and it should work. If the entire
33 diff is indented by a consistent amount, or if a context diff contains
34 lines ending in CRLF or is encapsulated one or more times by prepending
35 "- " to lines starting with "-" as specified by Internet RFC 934, this
36 is taken into account. After removing indenting or encapsulation,
37 lines beginning with # are ignored, as they are considered to be com‐
38 ments.
39
40 With context diffs, and to a lesser extent with normal diffs, patch can
41 detect when the line numbers mentioned in the patch are incorrect, and
42 attempts to find the correct place to apply each hunk of the patch. As
43 a first guess, it takes the line number mentioned for the hunk, plus or
44 minus any offset used in applying the previous hunk. If that is not
45 the correct place, patch scans both forwards and backwards for a set of
46 lines matching the context given in the hunk. First patch looks for a
47 place where all lines of the context match. If no such place is found,
48 and it's a context diff, and the maximum fuzz factor is set to 1 or
49 more, then another scan takes place ignoring the first and last line of
50 context. If that fails, and the maximum fuzz factor is set to 2 or
51 more, the first two and last two lines of context are ignored, and
52 another scan is made. (The default maximum fuzz factor is 2.)
53
54 Hunks with less prefix context than suffix context (after applying
55 fuzz) must apply at the start of the file if their first line number
56 is 1. Hunks with more prefix context than suffix context (after apply‐
57 ing fuzz) must apply at the end of the file.
58
59 If patch cannot find a place to install that hunk of the patch, it puts
60 the hunk out to a reject file, which normally is the name of the output
61 file plus a .rej suffix, or # if .rej would generate a file name that
62 is too long (if even appending the single character # makes the file
63 name too long, then # replaces the file name's last character).
64
65 The rejected hunk comes out in unified or context diff format. If the
66 input was a normal diff, many of the contexts are simply null. The
67 line numbers on the hunks in the reject file may be different than in
68 the patch file: they reflect the approximate location patch thinks the
69 failed hunks belong in the new file rather than the old one.
70
71 As each hunk is completed, you are told if the hunk failed, and if so
72 which line (in the new file) patch thought the hunk should go on. If
73 the hunk is installed at a different line from the line number speci‐
74 fied in the diff, you are told the offset. A single large offset may
75 indicate that a hunk was installed in the wrong place. You are also
76 told if a fuzz factor was used to make the match, in which case you
77 should also be slightly suspicious. If the --verbose option is given,
78 you are also told about hunks that match exactly.
79
80 If no original file origfile is specified on the command line, patch
81 tries to figure out from the leading garbage what the name of the file
82 to edit is, using the following rules.
83
84 First, patch takes an ordered list of candidate file names as follows:
85
86 · If the header is that of a context diff, patch takes the old and new
87 file names in the header. A name is ignored if it does not have
88 enough slashes to satisfy the -pnum or --strip=num option. The name
89 /dev/null is also ignored.
90
91 · If there is an Index: line in the leading garbage and if either the
92 old and new names are both absent or if patch is conforming to
93 POSIX, patch takes the name in the Index: line.
94
95 · For the purpose of the following rules, the candidate file names are
96 considered to be in the order (old, new, index), regardless of the
97 order that they appear in the header.
98
99 Then patch selects a file name from the candidate list as follows:
100
101 · If some of the named files exist, patch selects the first name if
102 conforming to POSIX, and the best name otherwise.
103
104 · If patch is not ignoring RCS, ClearCase, Perforce, and SCCS (see the
105 -g num or --get=num option), and no named files exist but an RCS,
106 ClearCase, Perforce, or SCCS master is found, patch selects the
107 first named file with an RCS, ClearCase, Perforce, or SCCS master.
108
109 · If no named files exist, no RCS, ClearCase, Perforce, or SCCS master
110 was found, some names are given, patch is not conforming to POSIX,
111 and the patch appears to create a file, patch selects the best name
112 requiring the creation of the fewest directories.
113
114 · If no file name results from the above heuristics, you are asked for
115 the name of the file to patch, and patch selects that name.
116
117 To determine the best of a nonempty list of file names, patch first
118 takes all the names with the fewest path name components; of those, it
119 then takes all the names with the shortest basename; of those, it then
120 takes all the shortest names; finally, it takes the first remaining
121 name.
122
123 Additionally, if the leading garbage contains a Prereq: line, patch
124 takes the first word from the prerequisites line (normally a version
125 number) and checks the original file to see if that word can be found.
126 If not, patch asks for confirmation before proceeding.
127
128 The upshot of all this is that you should be able to say, while in a
129 news interface, something like the following:
130
131 | patch -d /usr/src/local/blurfl
132
133 and patch a file in the blurfl directory directly from the article con‐
134 taining the patch.
135
136 If the patch file contains more than one patch, patch tries to apply
137 each of them as if they came from separate patch files. This means,
138 among other things, that it is assumed that the name of the file to
139 patch must be determined for each diff listing, and that the garbage
140 before each diff listing contains interesting things such as file names
141 and revision level, as mentioned previously.
142
144 -b or --backup
145 Make backup files. That is, when patching a file, rename or copy
146 the original instead of removing it. When backing up a file that
147 does not exist, an empty, unreadable backup file is created as a
148 placeholder to represent the nonexistent file. See the -V or --ver‐
149 sion-control option for details about how backup file names are
150 determined.
151
152 --backup-if-mismatch
153 Back up a file if the patch does not match the file exactly and if
154 backups are not otherwise requested. This is the default unless
155 patch is conforming to POSIX.
156
157 --no-backup-if-mismatch
158 Do not back up a file if the patch does not match the file exactly
159 and if backups are not otherwise requested. This is the default if
160 patch is conforming to POSIX.
161
162 -B pref or --prefix=pref
163 Use the simple method to determine backup file names (see the -V
164 method or --version-control method option), and append pref to a
165 file name when generating its backup file name. For example, with
166 -B /junk/ the simple backup file name for src/patch/util.c is
167 /junk/src/patch/util.c.
168
169 --binary
170 Write all files in binary mode, except for standard output and
171 /dev/tty. When reading, disable the heuristic for transforming CRLF
172 line endings into LF line endings. (On POSIX-conforming systems,
173 reads and writes never transform line endings. On Windows, reads and
174 writes do transform line endings by default, and patches should be
175 generated by diff --binary when line endings are significant.)
176
177 -c or --context
178 Interpret the patch file as a ordinary context diff.
179
180 -d dir or --directory=dir
181 Change to the directory dir immediately, before doing anything else.
182
183 -D define or --ifdef=define
184 Use the #ifdef ... #endif construct to mark changes, with define as
185 the differentiating symbol.
186
187 --dry-run
188 Print the results of applying the patches without actually changing
189 any files.
190
191 -e or --ed
192 Interpret the patch file as an ed script.
193
194 -E or --remove-empty-files
195 Remove output files that are empty after the patches have been
196 applied. Normally this option is unnecessary, since patch can exam‐
197 ine the time stamps on the header to determine whether a file should
198 exist after patching. However, if the input is not a context diff
199 or if patch is conforming to POSIX, patch does not remove empty
200 patched files unless this option is given. When patch removes a
201 file, it also attempts to remove any empty ancestor directories.
202
203 -f or --force
204 Assume that the user knows exactly what he or she is doing, and do
205 not ask any questions. Skip patches whose headers do not say which
206 file is to be patched; patch files even though they have the wrong
207 version for the Prereq: line in the patch; and assume that patches
208 are not reversed even if they look like they are. This option does
209 not suppress commentary; use -s for that.
210
211 -F num or --fuzz=num
212 Set the maximum fuzz factor. This option only applies to diffs that
213 have context, and causes patch to ignore up to that many lines in
214 looking for places to install a hunk. Note that a larger fuzz fac‐
215 tor increases the odds of a faulty patch. The default fuzz factor
216 is 2, and it may not be set to more than the number of lines of con‐
217 text in the context diff, ordinarily 3.
218
219 -g num or --get=num
220 This option controls patch's actions when a file is under RCS or
221 SCCS control, and does not exist or is read-only and matches the
222 default version, or when a file is under ClearCase or Perforce con‐
223 trol and does not exist. If num is positive, patch gets (or checks
224 out) the file from the revision control system; if zero, patch
225 ignores RCS, ClearCase, Perforce, and SCCS and does not get the
226 file; and if negative, patch asks the user whether to get the file.
227 The default value of this option is given by the value of the
228 PATCH_GET environment variable if it is set; if not, the default
229 value is zero.
230
231 --help
232 Print a summary of options and exit.
233
234 -i patchfile or --input=patchfile
235 Read the patch from patchfile. If patchfile is -, read from stan‐
236 dard input, the default.
237
238 -l or --ignore-whitespace
239 Match patterns loosely, in case tabs or spaces have been munged in
240 your files. Any sequence of one or more blanks in the patch file
241 matches any sequence in the original file, and sequences of blanks
242 at the ends of lines are ignored. Normal characters must still
243 match exactly. Each line of the context must still match a line in
244 the original file.
245
246 --merge
247 Merge a patch file into the original files similar to merge(1). If a
248 conflict is found, patch outputs a warning and brackets the conflict
249 with <<<<<<< and >>>>>>> lines. A typical conflict will look like
250 this:
251
252 <<<<<<<
253 lines from the original file
254 =======
255 lines from the patch
256 >>>>>>>
257
258 If there are conflicts, the user should edit the result and delete
259 one of the alternatives. This option implies --forward and does not
260 take the --fuzz=num option into account.
261
262 -n or --normal
263 Interpret the patch file as a normal diff.
264
265 -N or --forward
266 Ignore patches that seem to be reversed or already applied. See
267 also -R.
268
269 -o outfile or --output=outfile
270 Send output to outfile instead of patching files in place. Do not
271 use this option if outfile is one of the files to be patched. When
272 outfile is -, send output to standard output, and send any messages
273 that would usually go to standard output to standard error.
274
275 -pnum or --strip=num
276 Strip the smallest prefix containing num leading slashes from each
277 file name found in the patch file. A sequence of one or more adja‐
278 cent slashes is counted as a single slash. This controls how file
279 names found in the patch file are treated, in case you keep your
280 files in a different directory than the person who sent out the
281 patch. For example, supposing the file name in the patch file was
282
283 /u/howard/src/blurfl/blurfl.c
284
285 setting -p0 gives the entire file name unmodified, -p1 gives
286
287 u/howard/src/blurfl/blurfl.c
288
289 without the leading slash, -p4 gives
290
291 blurfl/blurfl.c
292
293 and not specifying -p at all just gives you blurfl.c. Whatever you
294 end up with is looked for either in the current directory, or the
295 directory specified by the -d option.
296
297 --posix
298 Conform more strictly to the POSIX standard, as follows.
299
300 · Take the first existing file from the list (old, new, index) when
301 intuiting file names from diff headers.
302
303 · Do not remove files that are empty after patching.
304
305 · Do not ask whether to get files from RCS, ClearCase, Perforce, or
306 SCCS.
307
308 · Require that all options precede the files in the command line.
309
310 · Do not backup files when there is a mismatch.
311
312 --quoting-style=word
313 Use style word to quote output names. The word should be one of the
314 following:
315
316 literal
317 Output names as-is.
318
319 shell Quote names for the shell if they contain shell metacharac‐
320 ters or would cause ambiguous output.
321
322 shell-always
323 Quote names for the shell, even if they would normally not
324 require quoting.
325
326 c Quote names as for a C language string.
327
328 escape Quote as with c except omit the surrounding double-quote
329 characters.
330
331 You can specify the default value of the --quoting-style option with
332 the environment variable QUOTING_STYLE. If that environment vari‐
333 able is not set, the default value is shell.
334
335 -r rejectfile or --reject-file=rejectfile
336 Put rejects into rejectfile instead of the default .rej file. When
337 rejectfile is -, discard rejects.
338
339 -R or --reverse
340 Assume that this patch was created with the old and new files
341 swapped. (Yes, I'm afraid that does happen occasionally, human
342 nature being what it is.) patch attempts to swap each hunk around
343 before applying it. Rejects come out in the swapped format. The -R
344 option does not work with ed diff scripts because there is too lit‐
345 tle information to reconstruct the reverse operation.
346
347 If the first hunk of a patch fails, patch reverses the hunk to see
348 if it can be applied that way. If it can, you are asked if you want
349 to have the -R option set. If it can't, the patch continues to be
350 applied normally. (Note: this method cannot detect a reversed patch
351 if it is a normal diff and if the first command is an append (i.e.
352 it should have been a delete) since appends always succeed, due to
353 the fact that a null context matches anywhere. Luckily, most
354 patches add or change lines rather than delete them, so most
355 reversed normal diffs begin with a delete, which fails, triggering
356 the heuristic.)
357
358 --reject-format=format
359 Produce reject files in the specified format (either context or uni‐
360 fied). Without this option, rejected hunks come out in unified diff
361 format if the input patch was of that format, otherwise in ordinary
362 context diff form.
363
364 -s or --silent or --quiet
365 Work silently, unless an error occurs.
366
367 -t or --batch
368 Suppress questions like -f, but make some different assumptions:
369 skip patches whose headers do not contain file names (the same as
370 -f); skip patches for which the file has the wrong version for the
371 Prereq: line in the patch; and assume that patches are reversed if
372 they look like they are.
373
374 -T or --set-time
375 Set the modification and access times of patched files from time
376 stamps given in context diff headers, assuming that the context diff
377 headers use local time. This option is not recommended, because
378 patches using local time cannot easily be used by people in other
379 time zones, and because local time stamps are ambiguous when local
380 clocks move backwards during daylight-saving time adjustments.
381 Instead of using this option, generate patches with UTC and use the
382 -Z or --set-utc option instead.
383
384 -u or --unified
385 Interpret the patch file as a unified context diff.
386
387 -v or --version
388 Print out patch's revision header and patch level, and exit.
389
390 -V method or --version-control=method
391 Use method to determine backup file names. The method can also be
392 given by the PATCH_VERSION_CONTROL (or, if that's not set, the VER‐
393 SION_CONTROL) environment variable, which is overridden by this
394 option. The method does not affect whether backup files are made;
395 it affects only the names of any backup files that are made.
396
397 The value of method is like the GNU Emacs `version-control' vari‐
398 able; patch also recognizes synonyms that are more descriptive. The
399 valid values for method are (unique abbreviations are accepted):
400
401 existing or nil
402 Make numbered backups of files that already have them, otherwise
403 simple backups. This is the default.
404
405 numbered or t
406 Make numbered backups. The numbered backup file name for F is
407 F.~N~ where N is the version number.
408
409 simple or never
410 Make simple backups. The -B or --prefix, -Y or --basename-pre‐
411 fix, and -z or --suffix options specify the simple backup file
412 name. If none of these options are given, then a simple backup
413 suffix is used; it is the value of the SIMPLE_BACKUP_SUFFIX envi‐
414 ronment variable if set, and is .orig otherwise.
415
416 With numbered or simple backups, if the backup file name is too
417 long, the backup suffix ~ is used instead; if even appending ~ would
418 make the name too long, then ~ replaces the last character of the
419 file name.
420
421 --verbose
422 Output extra information about the work being done.
423
424 -x num or --debug=num
425 Set internal debugging flags of interest only to patch patchers.
426
427 -Y pref or --basename-prefix=pref
428 Use the simple method to determine backup file names (see the -V
429 method or --version-control method option), and prefix pref to the
430 basename of a file name when generating its backup file name. For
431 example, with -Y .del/ the simple backup file name for
432 src/patch/util.c is src/patch/.del/util.c.
433
434 -z suffix or --suffix=suffix
435 Use the simple method to determine backup file names (see the -V
436 method or --version-control method option), and use suffix as the
437 suffix. For example, with -z - the backup file name for
438 src/patch/util.c is src/patch/util.c-.
439
440 -Z or --set-utc
441 Set the modification and access times of patched files from time
442 stamps given in context diff headers, assuming that the context diff
443 headers use Coordinated Universal Time (UTC, often known as GMT).
444 Also see the -T or --set-time option.
445
446 The -Z or --set-utc and -T or --set-time options normally refrain
447 from setting a file's time if the file's original time does not
448 match the time given in the patch header, or if its contents do not
449 match the patch exactly. However, if the -f or --force option is
450 given, the file time is set regardless.
451
452 Due to the limitations of diff output format, these options cannot
453 update the times of files whose contents have not changed. Also, if
454 you use these options, you should remove (e.g. with make clean) all
455 files that depend on the patched files, so that later invocations of
456 make do not get confused by the patched files' times.
457
459 PATCH_GET
460 This specifies whether patch gets missing or read-only files from
461 RCS, ClearCase, Perforce, or SCCS by default; see the -g or --get
462 option.
463
464 POSIXLY_CORRECT
465 If set, patch conforms more strictly to the POSIX standard by
466 default: see the --posix option.
467
468 QUOTING_STYLE
469 Default value of the --quoting-style option.
470
471 SIMPLE_BACKUP_SUFFIX
472 Extension to use for simple backup file names instead of .orig.
473
474 TMPDIR, TMP, TEMP
475 Directory to put temporary files in; patch uses the first environ‐
476 ment variable in this list that is set. If none are set, the
477 default is system-dependent; it is normally /tmp on Unix hosts.
478
479 VERSION_CONTROL or PATCH_VERSION_CONTROL
480 Selects version control style; see the -v or --version-control
481 option.
482
484 $TMPDIR/p*
485 temporary files
486
487 /dev/tty
488 controlling terminal; used to get answers to questions asked of the
489 user
490
492 diff(1), ed(1), merge(1).
493
494 Marshall T. Rose and Einar A. Stefferud, Proposed Standard for Message
495 Encapsulation, Internet RFC 934 <URL:ftp://ftp.isi.edu/in-
496 notes/rfc934.txt> (1985-01).
497
499 There are several things you should bear in mind if you are going to be
500 sending out patches.
501
502 Create your patch systematically. A good method is the command
503 diff -Naur old new where old and new identify the old and new directo‐
504 ries. The names old and new should not contain any slashes. The diff
505 command's headers should have dates and times in Universal Time using
506 traditional Unix format, so that patch recipients can use the -Z or
507 --set-utc option. Here is an example command, using Bourne shell syn‐
508 tax:
509
510 LC_ALL=C TZ=UTC0 diff -Naur gcc-2.7 gcc-2.8
511
512 Tell your recipients how to apply the patch by telling them which
513 directory to cd to, and which patch options to use. The option string
514 -Np1 is recommended. Test your procedure by pretending to be a recipi‐
515 ent and applying your patch to a copy of the original files.
516
517 You can save people a lot of grief by keeping a patchlevel.h file which
518 is patched to increment the patch level as the first diff in the patch
519 file you send out. If you put a Prereq: line in with the patch, it
520 won't let them apply patches out of order without some warning.
521
522 You can create a file by sending out a diff that compares /dev/null or
523 an empty file dated the Epoch (1970-01-01 00:00:00 UTC) to the file you
524 want to create. This only works if the file you want to create doesn't
525 exist already in the target directory. Conversely, you can remove a
526 file by sending out a context diff that compares the file to be deleted
527 with an empty file dated the Epoch. The file will be removed unless
528 patch is conforming to POSIX and the -E or --remove-empty-files option
529 is not given. An easy way to generate patches that create and remove
530 files is to use GNU diff's -N or --new-file option.
531
532 If the recipient is supposed to use the -pN option, do not send output
533 that looks like this:
534
535 diff -Naur v2.0.29/prog/README prog/README
536 --- v2.0.29/prog/README Mon Mar 10 15:13:12 1997
537 +++ prog/README Mon Mar 17 14:58:22 1997
538
539 because the two file names have different numbers of slashes, and dif‐
540 ferent versions of patch interpret the file names differently. To
541 avoid confusion, send output that looks like this instead:
542
543 diff -Naur v2.0.29/prog/README v2.0.30/prog/README
544 --- v2.0.29/prog/README Mon Mar 10 15:13:12 1997
545 +++ v2.0.30/prog/README Mon Mar 17 14:58:22 1997
546
547
548 Avoid sending patches that compare backup file names like README.orig,
549 since this might confuse patch into patching a backup file instead of
550 the real file. Instead, send patches that compare the same base file
551 names in different directories, e.g. old/README and new/README.
552
553 Take care not to send out reversed patches, since it makes people won‐
554 der whether they already applied the patch.
555
556 Try not to have your patch modify derived files (e.g. the file config‐
557 ure where there is a line configure: configure.in in your makefile),
558 since the recipient should be able to regenerate the derived files any‐
559 way. If you must send diffs of derived files, generate the diffs using
560 UTC, have the recipients apply the patch with the -Z or --set-utc
561 option, and have them remove any unpatched files that depend on patched
562 files (e.g. with make clean).
563
564 While you may be able to get away with putting 582 diff listings into
565 one file, it may be wiser to group related patches into separate files
566 in case something goes haywire.
567
569 Diagnostics generally indicate that patch couldn't parse your patch
570 file.
571
572 If the --verbose option is given, the message Hmm... indicates that
573 there is unprocessed text in the patch file and that patch is attempt‐
574 ing to intuit whether there is a patch in that text and, if so, what
575 kind of patch it is.
576
577 patch's exit status is 0 if all hunks are applied successfully, 1 if
578 some hunks cannot be applied or there were merge conflicts, and 2 if
579 there is more serious trouble. When applying a set of patches in a
580 loop it behooves you to check this exit status so you don't apply a
581 later patch to a partially patched file.
582
584 Context diffs cannot reliably represent the creation or deletion of
585 empty files, empty directories, or special files such as symbolic
586 links. Nor can they represent changes to file metadata like ownership,
587 permissions, or whether one file is a hard link to another. If changes
588 like these are also required, separate instructions (e.g. a shell
589 script) to accomplish them should accompany the patch.
590
591 patch cannot tell if the line numbers are off in an ed script, and can
592 detect bad line numbers in a normal diff only when it finds a change or
593 deletion. A context diff using fuzz factor 3 may have the same prob‐
594 lem. You should probably do a context diff in these cases to see if
595 the changes made sense. Of course, compiling without errors is a
596 pretty good indication that the patch worked, but not always.
597
598 patch usually produces the correct results, even when it has to do a
599 lot of guessing. However, the results are guaranteed to be correct
600 only when the patch is applied to exactly the same version of the file
601 that the patch was generated from.
602
604 The POSIX standard specifies behavior that differs from patch's tradi‐
605 tional behavior. You should be aware of these differences if you must
606 interoperate with patch versions 2.1 and earlier, which do not conform
607 to POSIX.
608
609 · In traditional patch, the -p option's operand was optional, and a
610 bare -p was equivalent to -p0. The -p option now requires an oper‐
611 and, and -p 0 is now equivalent to -p0. For maximum compatibility,
612 use options like -p0 and -p1.
613
614 Also, traditional patch simply counted slashes when stripping path
615 prefixes; patch now counts pathname components. That is, a sequence
616 of one or more adjacent slashes now counts as a single slash. For
617 maximum portability, avoid sending patches containing // in file
618 names.
619
620 · In traditional patch, backups were enabled by default. This behav‐
621 ior is now enabled with the -b or --backup option.
622
623 Conversely, in POSIX patch, backups are never made, even when there
624 is a mismatch. In GNU patch, this behavior is enabled with the
625 --no-backup-if-mismatch option, or by conforming to POSIX with the
626 --posix option or by setting the POSIXLY_CORRECT environment vari‐
627 able.
628
629 The -b suffix option of traditional patch is equivalent to the
630 -b -z suffix options of GNU patch.
631
632 · Traditional patch used a complicated (and incompletely documented)
633 method to intuit the name of the file to be patched from the patch
634 header. This method did not conform to POSIX, and had a few
635 gotchas. Now patch uses a different, equally complicated (but bet‐
636 ter documented) method that is optionally POSIX-conforming; we hope
637 it has fewer gotchas. The two methods are compatible if the file
638 names in the context diff header and the Index: line are all identi‐
639 cal after prefix-stripping. Your patch is normally compatible if
640 each header's file names all contain the same number of slashes.
641
642 · When traditional patch asked the user a question, it sent the ques‐
643 tion to standard error and looked for an answer from the first file
644 in the following list that was a terminal: standard error, standard
645 output, /dev/tty, and standard input. Now patch sends questions to
646 standard output and gets answers from /dev/tty. Defaults for some
647 answers have been changed so that patch never goes into an infinite
648 loop when using default answers.
649
650 · Traditional patch exited with a status value that counted the number
651 of bad hunks, or with status 1 if there was real trouble. Now patch
652 exits with status 1 if some hunks failed, or with 2 if there was
653 real trouble.
654
655 · Limit yourself to the following options when sending instructions
656 meant to be executed by anyone running GNU patch, traditional patch,
657 or a patch that conforms to POSIX. Spaces are significant in the
658 following list, and operands are required.
659
660 -c
661 -d dir
662 -D define
663 -e
664 -l
665 -n
666 -N
667 -o outfile
668 -pnum
669 -R
670 -r rejectfile
671
673 Please report bugs via email to <bug-patch@gnu.org>.
674
675 If code has been duplicated (for instance with #ifdef OLDCODE ... #else
676 ... #endif), patch is incapable of patching both versions, and, if it
677 works at all, will likely patch the wrong one, and tell you that it
678 succeeded to boot.
679
680 If you apply a patch you've already applied, patch thinks it is a
681 reversed patch, and offers to un-apply the patch. This could be con‐
682 strued as a feature.
683
684 Computing how to merge a hunk is significantly harder than using the
685 standard fuzzy algorithm. Bigger hunks, more context, a bigger offset
686 from the original location, and a worse match all slow the algorithm
687 down.
688
690 Copyright (C) 1984, 1985, 1986, 1988 Larry Wall.
691 Copyright (C) 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
692 1998, 1999, 2000, 2001, 2002, 2009 Free Software Foundation, Inc.
693
694 Permission is granted to make and distribute verbatim copies of this
695 manual provided the copyright notice and this permission notice are
696 preserved on all copies.
697
698 Permission is granted to copy and distribute modified versions of this
699 manual under the conditions for verbatim copying, provided that the
700 entire resulting derived work is distributed under the terms of a per‐
701 mission notice identical to this one.
702
703 Permission is granted to copy and distribute translations of this man‐
704 ual into another language, under the above conditions for modified ver‐
705 sions, except that this permission notice may be included in transla‐
706 tions approved by the copyright holders instead of in the original Eng‐
707 lish.
708
710 Larry Wall wrote the original version of patch. Paul Eggert removed
711 patch's arbitrary limits; added support for binary files, setting file
712 times, and deleting files; and made it conform better to POSIX. Other
713 contributors include Wayne Davison, who added unidiff support, and
714 David MacKenzie, who added configuration and backup support. Andreas
715 Grünbacher added support for merging.
716
717
718
719 GNU PATCH(1)