Difference between revisions of "Patch"

From Sega Retro

old>Kram1024
old>Kram1024
Line 13: Line 13:
  
 
Upon startup, patch attempts to determine the type of the diff listing, unless overruled by a  '''-c''' ('''--context'''), '''-e''' ('''--ed'''), '''-n''' ('''--normal'''), or '''-u''' (--unified) option.  Context diffs (old-style, new-style, and unified) and normal diffs are applied by the  '''patch'''  program  itself, while '''ed''' diffs are simply fed to the '''ed'''(1) editor via a pipe.
 
Upon startup, patch attempts to determine the type of the diff listing, unless overruled by a  '''-c''' ('''--context'''), '''-e''' ('''--ed'''), '''-n''' ('''--normal'''), or '''-u''' (--unified) option.  Context diffs (old-style, new-style, and unified) and normal diffs are applied by the  '''patch'''  program  itself, while '''ed''' diffs are simply fed to the '''ed'''(1) editor via a pipe.
 +
 +
'''patch''' tries 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 '''patch''', and it should work.  If the entire diff is indented by a consistent amount, or if a context diff contains lines ending in CRLF or is encapsulated one or more times by prepending "'''-'''  " to lines starting with "'''-'''" as specified by Internet RFC 934, this is taken into account.

Revision as of 13:59, 20 February 2009

NAME

patch - apply a diff file to an original

SYNOPSIS

patch [options] [originalfile [patchfile]]

but usually just

patch -pnum <patchfile

DESCRIPTION

patch takes a patch file patchfile containing a difference listing produced by the diff program and applies those differences to one or more original files, producing patched versions. Normally the patched versions are put in place of the originals. Backups can be made; see the -b or --backup option. The names of the files to be patched are usually taken from the patch file, but if there’s just one file to be patched it can specified on the command line as originalfile.

Upon startup, patch attempts to determine the type of the diff listing, unless overruled by a -c (--context), -e (--ed), -n (--normal), or -u (--unified) option. Context diffs (old-style, new-style, and unified) and normal diffs are applied by the patch program itself, while ed diffs are simply fed to the ed(1) editor via a pipe.

patch tries 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 patch, and it should work. If the entire diff is indented by a consistent amount, or if a context diff contains lines ending in CRLF or is encapsulated one or more times by prepending "- " to lines starting with "-" as specified by Internet RFC 934, this is taken into account.