1PATCH(1)                    General Commands Manual                   PATCH(1)
2
3
4

NAME

6       patch - apply a diff file to an original
7

SYNOPSIS

9       patch [options] [originalfile [patchfile]]
10
11       but usually just
12
13       patch -pnum <patchfile
14

DESCRIPTION

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 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.
37
38       With context diffs, and to a lesser extent with normal diffs, patch can
39       detect when the line numbers mentioned in the patch are incorrect,  and
40       attempts to find the correct place to apply each hunk of the patch.  As
41       a first guess, it takes the line number mentioned for the hunk, plus or
42       minus  any  offset  used in applying the previous hunk.  If that is not
43       the correct place, patch scans both forwards and backwards for a set of
44       lines  matching the context given in the hunk.  First patch looks for a
45       place where all lines of the context match.  If no such place is found,
46       and  it's  a  context  diff, and the maximum fuzz factor is set to 1 or
47       more, then another scan takes place ignoring the first and last line of
48       context.   If  that  fails,  and the maximum fuzz factor is set to 2 or
49       more, the first two and last two lines  of  context  are  ignored,  and
50       another  scan  is  made.   (The  default maximum fuzz factor is 2.)  If
51       patch cannot find a place to install that hunk of the  patch,  it  puts
52       the hunk out to a reject file, which normally is the name of the output
53       file plus a .rej suffix, or # if .rej would generate a file  name  that
54       is  too  long  (if even appending the single character # makes the file
55       name too long, then # replaces the file name's last  character).   (The
56       rejected hunk comes out in ordinary context diff form regardless of the
57       input patch's form.  If the input was a normal diff, many of  the  con‐
58       texts  are  simply  null.)  The line numbers on the hunks in the reject
59       file may be different than in the patch file: they reflect the approxi‐
60       mate  location  patch  thinks  the  failed hunks belong in the new file
61       rather than the old one.
62
63       As each hunk is completed, you are told if the hunk failed, and  if  so
64       which  line  (in the new file) patch thought the hunk should go on.  If
65       the hunk is installed at a different line from the line  number  speci‐
66       fied  in  the  diff you are told the offset.  A single large offset may
67       indicate that a hunk was installed in the wrong place.   You  are  also
68       told  if  a  fuzz  factor was used to make the match, in which case you
69       should also be slightly suspicious.  If the --verbose option is  given,
70       you are also told about hunks that match exactly.
71
72       If  no  original  file origfile is specified on the command line, patch
73       tries to figure out from the leading garbage what the name of the  file
74       to edit is, using the following rules.
75
76       First, patch takes an ordered list of candidate file names as follows:
77
78        · If the header is that of a context diff, patch takes the old and new
79          file names in the header.  A name is ignored if  it  does  not  have
80          enough slashes to satisfy the -pnum or --strip=num option.  The name
81          /dev/null is also ignored.
82
83        · If there is an Index: line in the leading garbage and if either  the
84          old  and  new  names  are  both  absent or if patch is conforming to
85          POSIX, patch takes the name in the Index: line.
86
87        · For the purpose of the following rules, the candidate file names are
88          considered  to  be in the order (old, new, index), regardless of the
89          order that they appear in the header.
90
91       Then patch selects a file name from the candidate list as follows:
92
93        · If some of the named files exist, patch selects the  first  name  if
94          conforming to POSIX, and the best name otherwise.
95
96        · If patch is not ignoring RCS, ClearCase, and SCCS (see the -g num or
97          --get=num option), and no named files exist but an  RCS,  ClearCase,
98          or  SCCS master is found, patch selects the first named file with an
99          RCS, ClearCase, or SCCS master.
100
101        · If no named files exist, no  RCS,  ClearCase,  or  SCCS  master  was
102          found,  some  names are given, patch is not conforming to POSIX, and
103          the patch appears to create a file,  patch  selects  the  best  name
104          requiring the creation of the fewest directories.
105
106        · If no file name results from the above heuristics, you are asked for
107          the name of the file to patch, and patch selects that name.
108
109       To determine the best of a nonempty list of  file  names,  patch  first
110       takes  all the names with the fewest path name components; of those, it
111       then takes all the names with the shortest basename; of those, it  then
112       takes  all  the  shortest  names; finally, it takes the first remaining
113       name.
114
115       Additionally, if the leading garbage contains  a  Prereq:  line,  patch
116       takes  the  first  word from the prerequisites line (normally a version
117       number) and checks the original file to see if that word can be  found.
118       If not, patch asks for confirmation before proceeding.
119
120       The  upshot  of  all this is that you should be able to say, while in a
121       news interface, something like the following:
122
123          | patch -d /usr/src/local/blurfl
124
125       and patch a file in the blurfl directory directly from the article con‐
126       taining the patch.
127
128       If  the  patch  file contains more than one patch, patch tries to apply
129       each of them as if they came from separate patch  files.   This  means,
130       among  other  things,  that  it is assumed that the name of the file to
131       patch must be determined for each diff listing, and  that  the  garbage
132       before each diff listing contains interesting things such as file names
133       and revision level, as mentioned previously.
134

OPTIONS

136       -b  or  --backup
137          Make backup files.  That is, when patching a file,  rename  or  copy
138          the  original  instead  of removing it.  When backing up a file that
139          does not exist, an empty, unreadable backup file  is  created  as  a
140          placeholder to represent the nonexistent file.  See the -V or --ver‐
141          sion-control option for details about  how  backup  file  names  are
142          determined.
143
144       --backup-if-mismatch
145          Back  up  a file if the patch does not match the file exactly and if
146          backups are not otherwise requested.  This  is  the  default  unless
147          patch is conforming to POSIX.
148
149       --no-backup-if-mismatch
150          Do  not  back up a file if the patch does not match the file exactly
151          and if backups are not otherwise requested.  This is the default  if
152          patch is conforming to POSIX.
153
154       -B pref  or  --prefix=pref
155          Prefix  pref  to  a file name when generating its simple backup file
156          name.  For example, with -B /junk/ the simple backup file  name  for
157          src/patch/util.c is /junk/src/patch/util.c.
158
159       --binary
160          Read  and write all files in binary mode, except for standard output
161          and /dev/tty.  This option has no effect  on  POSIX-conforming  sys‐
162          tems.  On systems like DOS where this option makes a difference, the
163          patch should be generated by diff -a --binary.
164
165       -c  or  --context
166          Interpret the patch file as a ordinary context diff.
167
168       -d dir  or  --directory=dir
169          Change to the directory dir immediately, before doing anything else.
170
171       -D define  or  --ifdef=define
172          Use the #ifdef ... #endif construct to mark changes, with define  as
173          the differentiating symbol.
174
175       --dry-run
176          Print  the results of applying the patches without actually changing
177          any files.
178
179       -e  or  --ed
180          Interpret the patch file as an ed script.
181
182       -E  or  --remove-empty-files
183          Remove output files that are  empty  after  the  patches  have  been
184          applied.  Normally this option is unnecessary, since patch can exam‐
185          ine the time stamps on the header to determine whether a file should
186          exist  after  patching.  However, if the input is not a context diff
187          or if patch is conforming to POSIX,  patch  does  not  remove  empty
188          patched  files  unless  this  option is given.  When patch removes a
189          file, it also attempts to remove any empty ancestor directories.
190
191       -f  or  --force
192          Assume that the user knows exactly what he or she is doing,  and  do
193          not  ask any questions.  Skip patches whose headers do not say which
194          file is to be patched; patch files even though they have  the  wrong
195          version  for  the Prereq: line in the patch; and assume that patches
196          are not reversed even if they look like they are.  This option  does
197          not suppress commentary; use -s for that.
198
199       -F num  or  --fuzz=num
200          Set the maximum fuzz factor.  This option only applies to diffs that
201          have context, and causes patch to ignore up to that  many  lines  in
202          looking  for places to install a hunk.  Note that a larger fuzz fac‐
203          tor increases the odds of a faulty patch.  The default  fuzz  factor
204          is 2, and it may not be set to more than the number of lines of con‐
205          text in the context diff, ordinarily 3.
206
207       -g num  or  --get=num
208          This option controls patch's actions when a file  is  under  RCS  or
209          SCCS  control,  and  does  not exist or is read-only and matches the
210          default version, or when a file is under ClearCase control and  does
211          not  exist.  If num is positive, patch gets (or checks out) the file
212          from the revision  control  system;  if  zero,  patch  ignores  RCS,
213          ClearCase,  and  SCCS  and  does  not get the file; and if negative,
214          patch asks the user whether to get the file.  The default  value  of
215          this option is given by the value of the PATCH_GET environment vari‐
216          able if it is set; if not, the default value is  zero  if  patch  is
217          conforming to POSIX, negative otherwise.
218
219       --help
220          Print a summary of options and exit.
221
222       -i patchfile  or  --input=patchfile
223          Read  the  patch from patchfile.  If patchfile is -, read from stan‐
224          dard input, the default.
225
226       -l  or  --ignore-whitespace
227          Match patterns loosely, in case tabs or spaces have been  munged  in
228          your  files.   Any  sequence of one or more blanks in the patch file
229          matches any sequence in the original file, and sequences  of  blanks
230          at  the  ends  of  lines  are ignored.  Normal characters must still
231          match exactly.  Each line of the context must still match a line  in
232          the original file.
233
234       -n  or  --normal
235          Interpret the patch file as a normal diff.
236
237       -N  or  --forward
238          Ignore  patches  that  seem  to be reversed or already applied.  See
239          also -R.
240
241       -o outfile  or  --output=outfile
242          Send output to outfile instead of patching files in place.
243
244       -pnum  or  --strip=num
245          Strip the smallest prefix containing num leading slashes  from  each
246          file  name found in the patch file.  A sequence of one or more adja‐
247          cent slashes is counted as a single slash.  This controls  how  file
248          names  found  in  the  patch file are treated, in case you keep your
249          files in a different directory than the  person  who  sent  out  the
250          patch.  For example, supposing the file name in the patch file was
251
252             /u/howard/src/blurfl/blurfl.c
253
254          setting -p0 gives the entire file name unmodified, -p1 gives
255
256             u/howard/src/blurfl/blurfl.c
257
258          without the leading slash, -p4 gives
259
260             blurfl/blurfl.c
261
262          and  not specifying -p at all just gives you blurfl.c.  Whatever you
263          end up with is looked for either in the current  directory,  or  the
264          directory specified by the -d option.
265
266       --posix
267          Conform more strictly to the POSIX standard, as follows.
268
269           · Take the first existing file from the list (old, new, index) when
270             intuiting file names from diff headers.
271
272           · Do not remove files that are empty after patching.
273
274           · Do not ask whether to get files from RCS, ClearCase, or SCCS.
275
276           · Require that all options precede the files in the command line.
277
278           · Do not backup files when there is a mismatch.
279
280       --quoting-style=word
281          Use style word to quote output names.  The word should be one of the
282          following:
283
284          literal
285                 Output names as-is.
286
287          shell  Quote  names  for the shell if they contain shell metacharac‐
288                 ters or would cause ambiguous output.
289
290          shell-always
291                 Quote names for the shell, even if they  would  normally  not
292                 require quoting.
293
294          c      Quote names as for a C language string.
295
296          escape Quote  as  with  c  except  omit the surrounding double-quote
297                 characters.
298
299          You can specify the default value of the --quoting-style option with
300          the  environment  variable QUOTING_STYLE.  If that environment vari‐
301          able is not set, the default value is shell.
302
303       -r rejectfile  or  --reject-file=rejectfile
304          Put rejects into rejectfile instead of the default .rej file.
305
306       -R  or  --reverse
307          Assume that this patch was  created  with  the  old  and  new  files
308          swapped.   (Yes,  I'm  afraid  that  does happen occasionally, human
309          nature being what it is.)  patch attempts to swap each  hunk  around
310          before applying it.  Rejects come out in the swapped format.  The -R
311          option does not work with ed diff scripts because there is too  lit‐
312          tle information to reconstruct the reverse operation.
313
314          If  the  first hunk of a patch fails, patch reverses the hunk to see
315          if it can be applied that way.  If it can, you are asked if you want
316          to  have  the -R option set.  If it can't, the patch continues to be
317          applied normally.  (Note: this method cannot detect a reversed patch
318          if  it  is a normal diff and if the first command is an append (i.e.
319          it should have been a delete) since appends always succeed,  due  to
320          the  fact  that  a  null  context  matches  anywhere.  Luckily, most
321          patches add or  change  lines  rather  than  delete  them,  so  most
322          reversed  normal  diffs begin with a delete, which fails, triggering
323          the heuristic.)
324
325       -s  or  --silent  or  --quiet
326          Work silently, unless an error occurs.
327
328       -t  or  --batch
329          Suppress questions like -f, but  make  some  different  assumptions:
330          skip  patches  whose  headers do not contain file names (the same as
331          -f); skip patches for which the file has the wrong version  for  the
332          Prereq:  line  in the patch; and assume that patches are reversed if
333          they look like they are.
334
335       -T  or  --set-time
336          Set the modification and access times of  patched  files  from  time
337          stamps given in context diff headers, assuming that the context diff
338          headers use local time.  This option  is  not  recommended,  because
339          patches  using  local  time cannot easily be used by people in other
340          time zones, and because local time stamps are ambiguous  when  local
341          clocks  move  backwards  during  daylight-saving  time  adjustments.
342          Instead of using this option, generate patches with UTC and use  the
343          -Z or --set-utc option instead.
344
345       -u  or  --unified
346          Interpret the patch file as a unified context diff.
347
348       -v  or  --version
349          Print out patch's revision header and patch level, and exit.
350
351       -V method  or  --version-control=method
352          Use  method  to determine backup file names.  The method can also be
353          given by the PATCH_VERSION_CONTROL (or, if that's not set, the  VER‐
354          SION_CONTROL)  environment  variable,  which  is  overridden by this
355          option.  The method does not affect whether backup files  are  made;
356          it affects only the names of any backup files that are made.
357
358          The  value  of  method is like the GNU Emacs `version-control' vari‐
359          able; patch also recognizes synonyms that are more descriptive.  The
360          valid values for method are (unique abbreviations are accepted):
361
362          existing  or  nil
363             Make  numbered backups of files that already have them, otherwise
364             simple backups.  This is the default.
365
366          numbered  or  t
367             Make numbered backups.  The numbered backup file name  for  F  is
368             F.~N~ where N is the version number.
369
370          simple  or  never
371             Make  simple  backups.  The -B or --prefix, -Y or --basename-pre‐
372             fix, and -z or --suffix options specify the  simple  backup  file
373             name.   If  none of these options are given, then a simple backup
374             suffix is used; it is the value of the SIMPLE_BACKUP_SUFFIX envi‐
375             ronment variable if set, and is .orig otherwise.
376
377          With  numbered  or  simple  backups,  if the backup file name is too
378          long, the backup suffix ~ is used instead; if even appending ~ would
379          make  the  name  too long, then ~ replaces the last character of the
380          file name.
381
382       --verbose
383          Output extra information about the work being done.
384
385       -x num  or  --debug=num
386          Set internal debugging flags of interest only to patch patchers.
387
388       -Y pref  or  --basename-prefix=pref
389          Prefix pref to the basename of a file name when generating its  sim‐
390          ple  backup file name.  For example, with -Y .del/ the simple backup
391          file name for src/patch/util.c is src/patch/.del/util.c.
392
393       -z suffix  or  --suffix=suffix
394          Use suffix as the simple backup suffix.  For example, with -z -  the
395          simple  backup  file name for src/patch/util.c is src/patch/util.c-.
396          The backup suffix may also be specified by the  SIMPLE_BACKUP_SUFFIX
397          environment variable, which is overridden by this option.
398
399       -Z  or  --set-utc
400          Set  the  modification  and  access times of patched files from time
401          stamps given in context diff headers, assuming that the context diff
402          headers  use  Coordinated  Universal Time (UTC, often known as GMT).
403          Also see the -T or --set-time option.
404
405          The -Z or --set-utc and -T or --set-time  options  normally  refrain
406          from  setting  a  file's  time  if the file's original time does not
407          match the time given in the patch header, or if its contents do  not
408          match  the  patch  exactly.  However, if the -f or --force option is
409          given, the file time is set regardless.
410
411          Due to the limitations of diff output format, these  options  cannot
412          update the times of files whose contents have not changed.  Also, if
413          you use these options, you should remove (e.g. with make clean)  all
414          files that depend on the patched files, so that later invocations of
415          make do not get confused by the patched files' times.
416

ENVIRONMENT

418       PATCH_GET
419          This specifies whether patch gets missing or  read-only  files  from
420          RCS, ClearCase, or SCCS by default; see the -g or --get option.
421
422       POSIXLY_CORRECT
423          If  set,  patch  conforms  more  strictly  to  the POSIX standard by
424          default: see the --posix option.
425
426       QUOTING_STYLE
427          Default value of the --quoting-style option.
428
429       SIMPLE_BACKUP_SUFFIX
430          Extension to use for simple backup file names instead of .orig.
431
432       TMPDIR, TMP, TEMP
433          Directory to put temporary files in; patch uses the  first  environ‐
434          ment  variable  in  this  list  that  is  set.  If none are set, the
435          default is system-dependent; it is normally /tmp on Unix hosts.
436
437       VERSION_CONTROL or PATCH_VERSION_CONTROL
438          Selects version control  style;  see  the  -v  or  --version-control
439          option.
440

FILES

442       $TMPDIR/p∗
443          temporary files
444
445       /dev/tty
446          controlling  terminal; used to get answers to questions asked of the
447          user
448

SEE ALSO

450       diff(1), ed(1)
451
452       Marshall T. Rose and Einar A. Stefferud, Proposed Standard for  Message
453       Encapsulation,     Internet    RFC    934    <URL:ftp://ftp.isi.edu/in-
454       notes/rfc934.txt> (1985-01).
455

NOTES FOR PATCH SENDERS

457       There are several things you should bear in mind if you are going to be
458       sending out patches.
459
460       Create  your  patch  systematically.   A  good  method  is  the command
461       diff -Naur old new where old and new identify the old and new  directo‐
462       ries.   The names old and new should not contain any slashes.  The diff
463       command's headers should have dates and times in Universal  Time  using
464       traditional  Unix  format,  so  that patch recipients can use the -Z or
465       --set-utc option.  Here is an example command, using Bourne shell  syn‐
466       tax:
467
468          LC_ALL=C TZ=UTC0 diff -Naur gcc-2.7 gcc-2.8
469
470       Tell  your  recipients  how  to  apply  the patch by telling them which
471       directory to cd to, and which patch options to use.  The option  string
472       -Np1 is recommended.  Test your procedure by pretending to be a recipi‐
473       ent and applying your patch to a copy of the original files.
474
475       You can save people a lot of grief by keeping a patchlevel.h file which
476       is  patched to increment the patch level as the first diff in the patch
477       file you send out.  If you put a Prereq: line in  with  the  patch,  it
478       won't let them apply patches out of order without some warning.
479
480       You  can create a file by sending out a diff that compares /dev/null or
481       an empty file dated the Epoch (1970-01-01 00:00:00 UTC) to the file you
482       want to create.  This only works if the file you want to create doesn't
483       exist already in the target directory.  Conversely, you  can  remove  a
484       file by sending out a context diff that compares the file to be deleted
485       with an empty file dated the Epoch.  The file will  be  removed  unless
486       patch  is conforming to POSIX and the -E or --remove-empty-files option
487       is not given.  An easy way to generate patches that create  and  remove
488       files is to use GNU diff's -N or --new-file option.
489
490       If  the recipient is supposed to use the -pN option, do not send output
491       that looks like this:
492
493          diff -Naur v2.0.29/prog/README prog/README
494          --- v2.0.29/prog/README   Mon Mar 10 15:13:12 1997
495          +++ prog/README   Mon Mar 17 14:58:22 1997
496
497       because the two file names have different numbers of slashes, and  dif‐
498       ferent  versions  of  patch  interpret  the file names differently.  To
499       avoid confusion, send output that looks like this instead:
500
501          diff -Naur v2.0.29/prog/README v2.0.30/prog/README
502          --- v2.0.29/prog/README   Mon Mar 10 15:13:12 1997
503          +++ v2.0.30/prog/README   Mon Mar 17 14:58:22 1997
504
505
506       Avoid sending patches that compare backup file names like  README.orig,
507       since  this  might confuse patch into patching a backup file instead of
508       the real file.  Instead, send patches that compare the same  base  file
509       names in different directories, e.g. old/README and new/README.
510
511       Take  care not to send out reversed patches, since it makes people won‐
512       der whether they already applied the patch.
513
514       Try not to have your patch modify derived files (e.g. the file  config‐
515       ure  where  there  is a line configure: configure.in in your makefile),
516       since the recipient should be able to regenerate the derived files any‐
517       way.  If you must send diffs of derived files, generate the diffs using
518       UTC, have the recipients apply the  patch  with  the  -Z  or  --set-utc
519       option, and have them remove any unpatched files that depend on patched
520       files (e.g. with make clean).
521
522       While you may be able to get away with putting 582 diff  listings  into
523       one  file, it may be wiser to group related patches into separate files
524       in case something goes haywire.
525

DIAGNOSTICS

527       Diagnostics generally indicate that patch  couldn't  parse  your  patch
528       file.
529
530       If  the  --verbose  option  is given, the message Hmm... indicates that
531       there is unprocessed text in the patch file and that patch is  attempt‐
532       ing  to  intuit  whether there is a patch in that text and, if so, what
533       kind of patch it is.
534
535       patch's exit status is 0 if all hunks are applied  successfully,  1  if
536       some  hunks  cannot be applied, and 2 if there is more serious trouble.
537       When applying a set of patches in a loop it behooves you to check  this
538       exit  status  so  you  don't apply a later patch to a partially patched
539       file.
540

CAVEATS

542       Context diffs cannot reliably represent the  creation  or  deletion  of
543       empty  files,  empty  directories,  or  special  files such as symbolic
544       links.  Nor can they represent changes to file metadata like ownership,
545       permissions, or whether one file is a hard link to another.  If changes
546       like these are also  required,  separate  instructions  (e.g.  a  shell
547       script) to accomplish them should accompany the patch.
548
549       patch  cannot tell if the line numbers are off in an ed script, and can
550       detect bad line numbers in a normal diff only when it finds a change or
551       deletion.   A  context diff using fuzz factor 3 may have the same prob‐
552       lem.  Until a suitable interactive interface is added, you should prob‐
553       ably do a context diff in these cases to see if the changes made sense.
554       Of course, compiling without errors is a pretty  good  indication  that
555       the patch worked, but not always.
556
557       patch  usually  produces  the correct results, even when it has to do a
558       lot of guessing.  However, the results are  guaranteed  to  be  correct
559       only  when the patch is applied to exactly the same version of the file
560       that the patch was generated from.
561

COMPATIBILITY ISSUES

563       The POSIX standard specifies behavior that differs from patch's  tradi‐
564       tional  behavior.  You should be aware of these differences if you must
565       interoperate with patch versions 2.1 and earlier, which do not  conform
566       to POSIX.
567
568        · In  traditional  patch,  the -p option's operand was optional, and a
569          bare -p was equivalent to -p0.  The -p option now requires an  oper‐
570          and,  and -p 0 is now equivalent to -p0.  For maximum compatibility,
571          use options like -p0 and -p1.
572
573          Also, traditional patch simply counted slashes when  stripping  path
574          prefixes; patch now counts pathname components.  That is, a sequence
575          of one or more adjacent slashes now counts as a single  slash.   For
576          maximum  portability,  avoid  sending  patches containing // in file
577          names.
578
579        · In traditional patch, backups were enabled by default.  This  behav‐
580          ior is now enabled with the -b or --backup option.
581
582          Conversely,  in POSIX patch, backups are never made, even when there
583          is a mismatch.  In GNU patch, this  behavior  is  enabled  with  the
584          --no-backup-if-mismatch  option,  or by conforming to POSIX with the
585          --posix option or by setting the POSIXLY_CORRECT  environment  vari‐
586          able.
587
588          The  -b suffix  option  of  traditional  patch  is equivalent to the
589          -b -z suffix options of GNU patch.
590
591        · Traditional patch used a complicated (and  incompletely  documented)
592          method  to  intuit the name of the file to be patched from the patch
593          header.  This method did  not  conform  to  POSIX,  and  had  a  few
594          gotchas.   Now patch uses a different, equally complicated (but bet‐
595          ter documented) method that is optionally POSIX-conforming; we  hope
596          it  has  fewer  gotchas.  The two methods are compatible if the file
597          names in the context diff header and the Index: line are all identi‐
598          cal  after  prefix-stripping.   Your patch is normally compatible if
599          each header's file names all contain the same number of slashes.
600
601        · When traditional patch asked the user a question, it sent the  ques‐
602          tion  to standard error and looked for an answer from the first file
603          in the following list that was a terminal: standard error,  standard
604          output,  /dev/tty, and standard input.  Now patch sends questions to
605          standard output and gets answers from /dev/tty.  Defaults  for  some
606          answers  have been changed so that patch never goes into an infinite
607          loop when using default answers.
608
609        · Traditional patch exited with a status value that counted the number
610          of bad hunks, or with status 1 if there was real trouble.  Now patch
611          exits with status 1 if some hunks failed, or with  2  if  there  was
612          real trouble.
613
614        · Limit  yourself  to  the following options when sending instructions
615          meant to be executed by anyone running GNU patch, traditional patch,
616          or  a  patch  that conforms to POSIX.  Spaces are significant in the
617          following list, and operands are required.
618
619             -c
620             -d dir
621             -D define
622             -e
623             -l
624             -n
625             -N
626             -o outfile
627             -pnum
628             -R
629             -r rejectfile
630

BUGS

632       Please report bugs via email to <bug-gnu-utils@gnu.org>.
633
634       patch could be smarter about partial matches, excessively deviant  off‐
635       sets and swapped code, but that would take an extra pass.
636
637       If code has been duplicated (for instance with #ifdef OLDCODE ... #else
638       ... #endif), patch is incapable of patching both versions, and,  if  it
639       works  at  all,  will  likely patch the wrong one, and tell you that it
640       succeeded to boot.
641
642       If you apply a patch you've already  applied,  patch  thinks  it  is  a
643       reversed  patch,  and offers to un-apply the patch.  This could be con‐
644       strued as a feature.
645

COPYING

647       Copyright 1984, 1985, 1986, 1988 Larry Wall.
648       Copyright 1989, 1990, 1991, 1992, 1993, 1994, 1995,  1996,  1997,  1998
649       Free Software Foundation, Inc.
650
651       Permission  is  granted  to make and distribute verbatim copies of this
652       manual provided the copyright notice and  this  permission  notice  are
653       preserved on all copies.
654
655       Permission  is granted to copy and distribute modified versions of this
656       manual under the conditions for verbatim  copying,  provided  that  the
657       entire  resulting derived work is distributed under the terms of a per‐
658       mission notice identical to this one.
659
660       Permission is granted to copy and distribute translations of this  man‐
661       ual into another language, under the above conditions for modified ver‐
662       sions, except that this permission notice may be included  in  transla‐
663       tions approved by the copyright holders instead of in the original Eng‐
664       lish.
665

AUTHORS

667       Larry Wall wrote the original version of patch.   Paul  Eggert  removed
668       patch's  arbitrary limits; added support for binary files, setting file
669       times, and deleting files; and made it conform better to POSIX.   Other
670       contributors  include  Wayne  Davison,  who  added unidiff support, and
671       David MacKenzie, who added configuration and backup support.
672
673
674
675GNU                               1998/03/21                          PATCH(1)
Impressum