patch - a program for applying a diff file to an original
.SH SYNOPSIS
.B patch
[options] orig patchfile [+ [options] orig]
.sp
but usually just
.sp
.B patch
<patchfile
.SH DESCRIPTION
.I Patch
will take a patch file containing any of the three forms of difference
listing produced by the
.I diff
program and apply those differences to an original file, producing a patched
version.
By default, the patched version is put in place of the original, with
the original file backed up to the same name with the
extension \*(L".orig\*(R" or \*(L"~\*(R" , or as specified by the
.B -b
switch.
You may also specify where you want the output to go with a
.B -o
switch.
If
.I patchfile
is omitted, or is a hyphen, the patch will be read from standard input.
.PP
Upon startup, patch will attempt to determine the type of the diff listing,
unless over-ruled by a
.BR -c ,
.BR -e ,
or
.B -n
switch.
Context diffs and normal diffs are applied by the
.I patch
program itself, while ed diffs are simply fed to the
.I ed
editor via a pipe.
.PP
.I Patch
will try to skip any leading garbage, apply the diff,
and then skip any trailing garbage.
Thus you could feed an article or message containing a
diff listing to
.IR patch ,
and it should work.
If the entire diff is indented by a consistent amount,
this will be taken into account.
.PP
With context diffs, and to a lesser extent with normal diffs,
.I patch
can detect when the line numbers mentioned in the patch are incorrect,
and will attempt to find the correct place to apply each hunk of the patch.
As a first guess, it takes the line number mentioned for the hunk, plus or
minus any offset used in applying the previous hunk.
If that is not the correct place,
.I patch
will scan both forwards and backwards for a set of lines matching the context
given in the hunk.
First
.I patch
looks for a place where all li Ø⇩'ij⇦gijIJג'ה @ג⇧ijτij◆ ה⇧αxI⇦gij@'א ╱⇧τבijו╱⇦'IJ⇩'ג@ Dατו DτIJ Σ⇩'ו'ה @ג⇧ijτגIJ⇦D`τו DτijIJג'ij◆⇧IJ 'ג@ @gגG╱ ij⇩xA⇩'א⇦ τijij'π'ij⇩gij ⇩D τijIJג gו @ IJג⇩gא╱◆ gijו ⇦⇩'בijו╱⇦'IJ⇦ @⇩A D'ijIJגH⑨á«⓪Ã⇨q´ _,ast
lindOÇ✓נî üê⇨üij≡Æ✓נüât fails, and the maximum fuzz factor is set to 2 or more,
the first two and last tw lipê⇦OÅø⑦ה @ג⇧ijτו⇩D'IJ⇦ @⇩D⇦α°G Dτו @ IJג⇩gא╱◆ gIJ⇩'ij◆⇦ג xaijIJג'גג⇦G ijτij◆⇧IJ 'ג@ @gגG╱ ij⇩gIJ⇩'Γ`a8I⇦x`I'בו ה⇧°F◆ @@ τגA Dτו'בijו╱⇦'ijij'IJ B ו ijτijIJו τIJij @'ij⇦gijIJג'בו ה⇧ατIJ τij⇧ ijτבij τijIJג8Aij @'ij τijij'ו'אD D╱ τגA ג τij⇧IJ╱⇧τij@⇩@◆ ijIJ'IJ⇩'ijIJג'ijG ⇦'ij⇦gijIJג'ij בij τגA ג8Cijij⇩'ijαaזµ`BD @αaאfgij⇩gijαaזµf αaאfgαxaז@ ג'ijIJו τijIJג'אD D╱ ג⇦τIJij @'ij⇧ ijτה ⇦'ij τIJ gה @ג⇧ijτגIJ⇦Dgג@⇩@'ij⇧ג IJג⇩gijIJג8A Cij τבו ה⇧τij◆⇩'ו'ה @ג⇧ijτגIJ⇦Dgij⇩gו'ij@⇩[X[✓⑨əYÖïéÆYêə⑨Hə[£]✓