Penguin
Annotated edit history of patch(1) version 4, including all changes. View license author blame.
Rev Author # Line
3 CraigBox 1 !!Name
1 perry 2
3 patch - apply a diff file to an original
4
3 CraigBox 5 !!Synopsis
1 perry 6
3 CraigBox 7 __patch__ [[''options''] [[''originalfile'' [[''patchfile'']]
1 perry 8
9 but usually just
10
3 CraigBox 11 __patch -p__ ''num patchfile''
1 perry 12
3 CraigBox 13 !!Description
1 perry 14
3 CraigBox 15 __patch__ takes a patch file ''patchfile'' containing a difference listing produced by the __diff__ program and applies those
16 differences to one or more original files, producing patched versions. Normally the patched versions are put in place of the originals.
17 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,
18 but if there's just one file to be patched it can specified on the command line as ''originalfile''.
1 perry 19
3 CraigBox 20 Upon startup, patch attempts to determine the type of the diff listing, unless overruled by a __-c__ (__--context__), __-e__ (__--
21 ed__), __-n__ (__--normal__), or __-u__ (__--unified__) option. Context diffs (old-style, new-style, and unified) and normal diffs are
22 applied by the __patch__ program itself, while __ed__ diffs are simply fed to the ed(1) editor via a pipe.
1 perry 23
3 CraigBox 24 __patch__ tries to skip any leading garbage, apply the diff, and then skip any trailing garbage. Thus you could feed an article or
25 message containing a diff listing to __patch__, and it should work. If the entire diff is indented by a consistent amount, or if a
26 context diff contains lines ending in CRLF or is encapsulated one or more times by prepending -__ __-__ __
1 perry 27
3 CraigBox 28 With context diffs, and to a lesser extent with normal diffs, __patch__ can detect when the line numbers mentioned in the patch are incorrect, and attempts 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, __patch__ scans both forwards and backwards for a set of lines matching the context given in the hunk. First __patch__ looks for a place where all lines of the context match. If no such place is found, and it's a context diff, and the maximum fuzz factor is set to 1 or more, then another scan takes place ignoring the first and last line of context. If that fails, and the maximum fuzz factor is set to 2 or more, the first two and last two lines of context are ignored, and another scan is made. (The default maximum fuzz factor is 2.) If __patch__ cannot find a place to install that hunk of the patch, it puts the hunk out to a reject file, which normally is the name of the output file plus a __.rej__ suffix, or __#__ if __.rej__ would generate a file name that is too long (if even appending the single character __#__ makes the file name too long, then __#__ replaces the file name's last character). (The rejected hunk comes out in ordinary context diff form regardless of the input patch's form. If the input was a normal diff, many of the contexts are simply null.) The line numbers on the hunks in the reject file may be different than in the patch file: they reflect the approximate location patch thinks the failed hunks belong in the new file rather than the old one.
1 perry 29
3 CraigBox 30 As each hunk is completed, you are told if the hunk failed, and if so which line (in the new file) __patch__ thought the hunk should go on. If the hunk is installed at a different line from the line number specified in the diff you are told the offset. A single large offset ''may'' indicate that a hunk was installed in the wrong place. You are also told if a fuzz factor was used to make the match, in which case you should also be slightly suspicious. If the __--verbose__ option is given, you are also told about hunks that match exactly.
1 perry 31
3 CraigBox 32 If no original file ''origfile'' is specified on the command line, __patch__ tries to figure out from the leading garbage what the name of the file to edit is, using the following rules.
1 perry 33
3 CraigBox 34 First, __patch__ takes an ordered list of candidate file names as follows:
1 perry 35
3 CraigBox 36 If the header is that of a context diff, __patch__ takes the old and new file names in the header. A name is ignored if it does not have enough slashes to satisfy the __-p__''num'' or __--strip=__''num'' option. The name __/dev/null__ is also ignored.
1 perry 37
3 CraigBox 38 If there is an __Index:__ line in the leading garbage and if either the old and new names are both absent or if __patch__ is conforming to POSIX , __patch__ takes the name in the __Index:__ line.
1 perry 39
3 CraigBox 40 For the purpose of the following rules, the candidate file names are considered to be in the order (old, new, index), regardless of the order that they appear in the header.
1 perry 41
3 CraigBox 42 Then __patch__ selects a file name from the candidate list as follows:
1 perry 43
3 CraigBox 44 If some of the named files exist, __patch__ selects the first name if conforming to POSIX , and the best name otherwise.
1 perry 45
3 CraigBox 46 If __patch__ is not ignoring RCS , !ClearCase, and SCCS (see the __-g__ ''num'' or __--get=__''num'' option), and no named files exist but an RCS , !ClearCase, or SCCS master is found, __patch__ selects the first named file with an RCS , !ClearCase, or SCCS master.
1 perry 47
3 CraigBox 48 If no named files exist, no RCS , !ClearCase, or SCCS master was found, some names are given, __patch__ is not conforming to POSIX , and the patch appears to create a file, __patch__ selects the best name requiring the creation of the fewest directories.
1 perry 49
3 CraigBox 50 If no file name results from the above heuristics, you are asked for the name of the file to patch, and __patch__ selects that name.
1 perry 51
3 CraigBox 52 To determine the ''best'' of a nonempty list of file names, __patch__ first takes all the names with the fewest path name components; of those, it then takes all the names with the shortest basename; of those, it then takes all the shortest names; finally, it takes the first remaining name.
1 perry 53
3 CraigBox 54 Additionally, if the leading garbage contains a __Prereq:__ line, __patch__ takes the first word from the prerequisites line (normally a version number) and checks the original file to see if that word can be found. If not, __patch__ asks for confirmation before proceeding.
1 perry 55
3 CraigBox 56 The upshot of all this is that you should be able to say, while in a news interface, something like the following:
1 perry 57
3 CraigBox 58 __| patch -d /usr/src/local/blurfl__
1 perry 59
3 CraigBox 60 and patch a file in the __blurfl__ directory directly from the article containing the patch.
1 perry 61
3 CraigBox 62 If the patch file contains more than one patch, __patch__ tries to apply each of them as if they came from separate patch files. This means, among other things, that it is assumed that the name of the file to patch must be determined for each diff listing, and that the garbage before each diff listing contains interesting things such as file names and revision level, as mentioned previously.
1 perry 63
3 CraigBox 64 !!Options
1 perry 65
3 CraigBox 66 ; __-b__ or __--backup__ : Make backup files. That is, when patching a file, rename or copy the original instead of removing it. When backing up a file that does not exist, an empty, unreadable backup file is created as a placeholder to represent the nonexistent file. See the __-V__ or __--version-control__ option for details about how backup file names are determined.
67 ; __--backup-if-mismatch__ : Back up a file if the patch does not match the file exactly and if backups are not otherwise requested. This is the default unless __patch__ is conforming to POSIX .
68 ; __--no-backup-if-mismatch__ : Do not back up a file if the patch does not match the file exactly and if backups are not otherwise requested. This is the default if __patch__ is conforming to POSIX .
69 ; __-B__ ''pref'' or __--prefix=__''pref'' : Prefix ''pref'' to a file name when generating its simple backup file name. For example, with __-B /junk/__ the simple backup file name for __src/patch/util.c__ is __/junk/src/patch/util.c__.
70 ; __--binary__ : Read and write all files in binary mode, except for standard output and __/dev/tty__. This option has no effect on POSIX -conforming systems. On systems like DOS where this option makes a difference, the patch should be generated by __diff -a --binary__.
71 ; __-c__ or __--context__ : Interpret the patch file as a ordinary context diff.
72 ; __-d__ ''dir'' or __--directory=__''dir'' : Change to the directory ''dir'' immediately, before doing anything else.
73 ; __-D__ ''define'' or __--ifdef=__''define'' : Use the __#ifdef__ ... __#endif__ construct to mark changes, with ''define'' as the differentiating symbol.
74 ; __--dry-run__ : Print the results of applying the patches without actually changing any files.
75 ; __-e__ or __--ed__ : Interpret the patch file as an __ed__ script.
76 ; __-E__ or __--remove-empty-files__ : Remove output files that are empty after the patches have been applied. Normally this option is unnecessary, since __patch__ can examine the time stamps on the header to determine whether a file should exist after patching. However, if the input is not a context diff or if __patch__ is conforming to POSIX , __patch__ does not remove empty patched files unless this option is given. When __patch__ removes a file, it also attempts to remove any empty ancestor directories.
77 ; __-f__ or __--force__ : Assume that the user knows exactly what he or she is doing, and do not ask any questions. Skip patches whose headers do not say which file is to be patched; patch files even though they have the wrong version for the __Prereq:__ line in the patch; and assume that patches are not reversed even if they look like they are. This option does not suppress commentary; use __-s__ for that.
78 ; __-F__ ''num'' or __--fuzz=__''num'' : Set the maximum fuzz factor. This option only applies to diffs that have context, and causes __patch__ to ignore up to that many lines in looking for places to install a hunk. Note that a larger fuzz factor increases the odds of a faulty patch. The default fuzz factor is 2, and it may not be set to more than the number of lines of context in the context diff, ordinarily 3.
79 ; __-g__ ''num'' or __--get=__''num'' : This option controls __patch__'s actions when a file is under RCS or SCCS control, and does not exist or is read-only and matches the default version, or when a file is under !ClearCase control and does not exist. If ''num'' is positive, __patch__ gets (or checks out) the file from the revision control system; if zero, __patch__ ignores RCS , !ClearCase, and SCCS and does not get the file; and if negative, __patch__ asks the user whether to get the file. The default value of this option is given by the value of the __PATCH_GET__ environment variable if it is set; if not, the default value is zero if __patch__ is conforming to POSIX , negative otherwise.
80 ; __--help__ : Print a summary of options and exit.
81 ; __-i__ ''patchfile'' or __--input=__''patchfile'' : Read the patch from ''patchfile''. If ''patchfile'' is __-__, read from standard input, the default.
82 ; __-l__ or __--ignore-whitespace__ : Match patterns loosely, in case tabs or spaces have been munged in your files. Any sequence of one or more blanks in the patch file matches any sequence in the original file, and sequences of blanks at the ends of lines are ignored. Normal characters must still match exactly. Each line of the context must still match a line in the original file.
83 ; __-n__ or __--normal__ : Interpret the patch file as a normal diff.
1 perry 84
3 CraigBox 85 ; __-N__ or __--forward__ : Ignore patches that seem to be reversed or already applied. See also __-R__.
86 ; __-o__ ''outfile'' or __--output=__''outfile'' : Send output to ''outfile'' instead of patching files in place.
1 perry 87
3 CraigBox 88 ; __-p__''num'' or __--strip=__''num'' : Strip the smallest prefix containing ''num'' leading slashes from each file name found in the patch file. A sequence of one or more adjacent slashes is counted as a single slash. This controls how file names found in the patch file are treated, in case you keep your files in a different directory than the person who sent out the patch. For example, supposing the file name in the patch file was %%%
89 __/u/howard/src/blurfl/blurfl.c__ %%%
90 setting __-p0__ gives the entire file name unmodified, __-p1__ gives %%%
91 __u/howard/src/blurfl/blurfl.c__ %%%
92 without the leading slash, __-p4__ gives %%%
93 __blurfl/blurfl.c__ %%%
94 and not specifying __-p__ at all just gives you __blurfl.c__. Whatever you end up with is looked for either in the current directory, or the directory specified by the __-d__ option.
1 perry 95
3 CraigBox 96 ; __--posix__ : Conform more strictly to the POSIX standard, as follows.
1 perry 97
3 CraigBox 98 * Take the first existing file from the list (old, new, index) when intuiting file names from diff headers.
99 * Do not remove files that are empty after patching.
100 * Do not ask whether to get files from RCS, !ClearCase, or SCCS.
101 * Require that all options precede the files in the command line.
102 * Do not backup files when there is a mismatch.
1 perry 103
3 CraigBox 104 ; __--quoting-style=__''word'' : Use style ''word'' to quote output names. The ''word'' should be one of the following: %%%
105 __literal__ Output names as-is. %%%
106 __shell__ Quote names for the shell if they contain shell metacharacters or would cause ambiguous output. %%%
107 __shell-always__ Quote names for the shell, even if they would normally not require quoting. %%%
108 __c__ Quote names as for a C language string. %%%
109 __escape__ Quote as with __c__ except omit the surrounding double-quote characters. %%%
110 %%%
111 You can specify the default value of the __--quoting-style__ option with the environment variable __QUOTING_STYLE__. If that environment variable is not set, the default value is __shell__.
1 perry 112
3 CraigBox 113 ; __-r__ ''rejectfile'' or __--reject-file=__''rejectfile'' : Put rejects into ''rejectfile'' instead of the default __.rej__ file.
1 perry 114
3 CraigBox 115 ; __-R__ or __--reverse__ : Assume that this patch was created with the old and new files swapped. (Yes, I'm afraid that does happen occasionally, human nature being what it is.) __patch__ attempts to swap each hunk around before applying it. Rejects come out in the swapped format. The __-R__ option does not work with __ed__ diff scripts because there is too little information to reconstruct the reverse operation. %%% If the first hunk of a patch fails, __patch__ reverses the hunk to see if it can be applied that way. If it can, you are asked if you want to have the __-R__ option set. If it can't, the patch continues to be applied normally. (Note: this method cannot detect a reversed patch if it is a normal diff and if the first command is an append (i.e. it should have been a delete) since appends always succeed, due to the fact that a null context matches anywhere. Luckily, most patches add or change lines rather than delete them, so most reversed normal diffs begin with a delete, which fails, triggering the heuristic.)
1 perry 116
3 CraigBox 117 ; __-s__ or __--silent__ or __--quiet__ : Work silently, unless an error occurs.
1 perry 118
3 CraigBox 119 ; __-t__ or __--batch__ : Suppress questions like __-f__, but make some different assumptions: skip patches whose headers do not contain file names (the same as __-f__); skip patches for which the file has the wrong version for the __Prereq:__ line in the patch; and assume that patches are reversed if they look like they are.
1 perry 120
3 CraigBox 121 ; __-T__ or __--set-time__ : Set the modification and access times of patched files from time stamps given in context diff headers, assuming that the context diff headers use local time. This option is not recommended, because patches using local time cannot easily be used by people in other time zones, and because local time stamps are ambiguous when local clocks move backwards during daylight-saving time adjustments. Instead of using this option, generate patches with UTC and use the __-Z__ or __--set-utc__ option instead.
1 perry 122
3 CraigBox 123 ; __-u__ or __--unified__ : Interpret the patch file as a unified context diff.
1 perry 124
3 CraigBox 125 ; __-v__ or __--version__ : Print out __patch__'s revision header and patch level, and exit.
1 perry 126
3 CraigBox 127 ; __-V__ ''method'' or __--version-control=__''method'' : Use ''method'' to determine backup file names. The method can also be given by the __PATCH_VERSION_CONTROL__ (or, if that's not set, the __VERSION_CONTROL__) environment variable, which is overridden by this option. The method does not affect whether backup files are made; it affects only the names of any backup files that are made. %%% The value of ''method'' is like the GNU Emacs `version-control' variable; __patch__ also recognizes synonyms that are more descriptive. The valid values for ''method'' are (unique abbreviations are accepted): %%%
128 __existing__ or __nil__ Make numbered backups of files that already have them, therwise simple backups. This is the default. %%%
129 __numbered__ or __t__ Make numbered backups. The numbered backup file name for ''F'' is ''F''__.~__''N''__~__ where ''N'' is the version number. %%%
130 __simple__ or __never__ Make simple backups. The __-B__ or __--prefix__, __-Y__ or __--basename-prefix__, and __-z__ or __--suffix__ options specify the simple backup file name. If none of these options are given, then a simple backup suffix is used; it is the value of the __SIMPLE_BACKUP_SUFFIX__ environment variable if set, and is __.orig__ otherwise.%%%
131 With numbered or simple backups, if the backup file name is too long, the backup suffix __~__ is used instead; if even appending __~__ would make the name too long, then __~__ replaces the last character of the file name.
1 perry 132
3 CraigBox 133 ; __--verbose__ : Output extra information about the work being done. ; __-x__ ''num'' or __--debug=__''num'' : Set internal debugging flags of interest only to __patch__ patchers.
1 perry 134
3 CraigBox 135 ; __-Y__ ''pref'' or __--basename-prefix=__''pref'' : Prefix ''pref'' to the basename of a file name when generating its simple backup file name. For example, with __-Y .del/__ the simple backup file name for __src/patch/util.c__ is __src/patch/.del/util.c__.
1 perry 136
3 CraigBox 137 ; __-z__ ''suffix'' or __--suffix=__''suffix'' : Use ''suffix'' as the simple backup suffix. For example, with __-z -__ the simple backup file name for __src/patch/util.c__ is __src/patch/util.c-__. The backup suffix may also be specified by the __SIMPLE_BACKUP_SUFFIX__ environment variable, which is overridden by this option.
1 perry 138
3 CraigBox 139 ; __-Z__ or __--set-utc__ : Set the modification and access times of patched files from time stamps given in context diff headers, assuming that the context diff headers use Coordinated Universal Time ( UTC , often known as GMT ). Also see the __-T__ or __--set-time__ option. %%% The __-Z__ or __--set-utc__ and __-T__ or __--set-time__ options normally refrain from setting a file's time if the file's original time does not match the time given in the patch header, or if its contents do not match the patch exactly. However, if the __-f__ or __--force__ option is given, the file time is set regardless. %%% Due to the limitations of __diff__ output format, these options cannot update the times of files whose contents have not changed. Also, if you use these options, you should remove (e.g. with __make clean__) all files that depend on the patched files, so that later invocations of __make__ do not get confused by the patched files' times.
1 perry 140
3 CraigBox 141 !!Environment
1 perry 142
3 CraigBox 143 ; __PATCH_GET__ : This specifies whether __patch__ gets missing or read-only files from RCS , !ClearCase, or SCCS by default; see the __-g__ or __--get__ option.
1 perry 144
3 CraigBox 145 ; __POSIXLY_CORRECT__ : If set, __patch__ conforms more strictly to the POSIX standard by default: see the __--posix__ option.
1 perry 146
3 CraigBox 147 ; __QUOTING_STYLE__ : Default value of the __--quoting-style__ option.
1 perry 148
3 CraigBox 149 ; __SIMPLE_BACKUP_SUFFIX__ : Extension to use for simple backup file names instead of __.orig__.
1 perry 150
3 CraigBox 151 ; __TMPDIR__, __TMP__, __TEMP__ : Directory to put temporary files in; __patch__ uses the first environment variable in this list that is set. If none are set, the default is system-dependent; it is normally __/tmp__ on Unix hosts.
1 perry 152
3 CraigBox 153 ; __VERSION_CONTROL__ or __PATCH_VERSION_CONTROL__ : Selects version control style; see the __-v__ or __--version-control__ option.
1 perry 154
3 CraigBox 155 !!Files
1 perry 156
3 CraigBox 157 ; ''$TMPDIR''__/p__ : temporary files
158 ; __/dev/tty__ : controlling terminal; used to get answers to questions asked of the user
1 perry 159
160
3 CraigBox 161 !!See Also
1 perry 162
163 diff(1), ed(1)
164
3 CraigBox 165 Marshall T. Rose and Einar A. Stefferud, Proposed Standard for Message Encapsulation, Internet RFC:934
1 perry 166
3 CraigBox 167 !!Notes for Patch Senders
1 perry 168
3 CraigBox 169 There are several things you should bear in mind if you are going to be sending out patches.
1 perry 170
3 CraigBox 171 Create your patch systematically. A good method is the command __diff -Naur__ ''old new'' where ''old'' and ''new'' identify the old and new directories. The names ''old'' and ''new'' should not contain any slashes. The __diff__ command's headers should have dates and times in Universal Time using traditional Unix format, so that patch recipients can use the __-Z__ or __--set-utc__ option. Here is an example command, using Bourne shell syntax:
1 perry 172
3 CraigBox 173 __LC_ALL=C TZ=UTC0 diff -Naur gcc-2.7 gcc-2.8__
1 perry 174
3 CraigBox 175 Tell your recipients how to apply the patch by telling them which directory to __cd__ to, and which __patch__ options to use. The option string __-Np1__ is recommended. Test your procedure by pretending to be a recipient and applying your patch to a copy of the original files.
1 perry 176
3 CraigBox 177 You can save people a lot of grief by keeping a __patchlevel.h__ file which is patched to increment the patch level as the first diff in the patch file you send out. If you put a __Prereq:__ line in with the patch, it won't let them apply patches out of order without some warning.
1 perry 178
3 CraigBox 179 You can create a file by sending out a diff that compares __/dev/null__ or an empty file dated the Epoch (1970-01-01 00:00:00 UTC ) to the file you want to create. This only works if the file you want to create doesn't exist already in the target directory. Conversely, you can remove a file by sending out a context diff that compares the file to be deleted with an empty file dated the Epoch. The file will be removed unless __patch__ is conforming to POSIX and the __-E__ or __--remove-empty-files__ option is not given. An easy way to generate patches that create and remove files is to use GNU __diff__'s __-N__ or __--new-file__ option.
1 perry 180
3 CraigBox 181 If the recipient is supposed to use the __-p__''N'' option, do not send output that looks like this:
1 perry 182
3 CraigBox 183 __diff -Naur v2.0.29/prog/README prog/README
184 --- v2.0.29/prog/README Mon Mar 10 15:13:12 1997
185 +++ prog/README Mon Mar 17 14:58:22 1997__
1 perry 186
3 CraigBox 187 because the two file names have different numbers of slashes, and different versions of __patch__ interpret the file names differently. To avoid confusion, send output that looks like this instead:
1 perry 188
3 CraigBox 189 __diff -Naur v2.0.29/prog/README v2.0.30/prog/README
190 --- v2.0.29/prog/README Mon Mar 10 15:13:12 1997
191 +++ v2.0.30/prog/README Mon Mar 17 14:58:22 1997__
1 perry 192
193
3 CraigBox 194 Avoid sending patches that compare backup file names like __README.orig__, since this might confuse __patch__ into patching a backup file instead of the real file. Instead, send patches that compare the same base file names in different directories, e.g. __old/README__ and __new/README__.
1 perry 195
3 CraigBox 196 Take care not to send out reversed patches, since it makes people wonder whether they already applied the patch.
1 perry 197
3 CraigBox 198 Try not to have your patch modify derived files (e.g. the file __configure__ where there is a line __configure: configure.in__ in your makefile), since the recipient should be able to regenerate the derived files anyway. If you must send diffs of derived files, generate the diffs using UTC , have the recipients apply the patch with the __-Z__ or __--set-utc__ option, and have them remove any unpatched files that depend on patched files (e.g. with __make clean__).
1 perry 199
3 CraigBox 200 While you may be able to get away with putting 582 diff listings into one file, it may be wiser to group related patches into separate files in case something goes haywire.
1 perry 201
3 CraigBox 202 !!Diagnostics
1 perry 203
3 CraigBox 204 Diagnostics generally indicate that __patch__ couldn't parse your patch file.
1 perry 205
3 CraigBox 206 If the __--verbose__ option is given, the message __Hmm...__ indicates that there is unprocessed text in the patch file and that __patch__ is attempting to intuit whether there is a patch in that text and, if so, what kind of patch it is.
1 perry 207
3 CraigBox 208 __patch__'s exit status is 0 if all hunks are applied successfully, 1 if some hunks cannot be applied, and 2 if there is more serious trouble. When applying a set of patches in a loop it behooves you to check this exit status so you don't apply a later patch to a partially patched file. !!CAVEATS
1 perry 209
3 CraigBox 210 Context diffs cannot reliably represent the creation or deletion of empty files, empty directories, or special files such as symbolic links. Nor can they represent changes to file metadata like ownership, permissions, or whether one file is a hard link to another. If changes like these are also required, separate instructions (e.g. a shell script) to accomplish them should accompany the patch.
1 perry 211
3 CraigBox 212 __patch__ cannot tell if the line numbers are off in an __ed__ script, and can detect bad line numbers in a normal diff only when it finds a change or deletion. A context diff using fuzz factor 3 may have the same problem. Until a suitable interactive interface is added, you should probably do a context diff in these cases to see if the changes made sense. Of course, compiling without errors is a pretty good indication that the patch worked, but not always.
1 perry 213
3 CraigBox 214 __patch__ usually produces the correct results, even when it has to do a lot of guessing. However, the results are guaranteed to be correct only when the patch is applied to exactly the same version of the file that the patch was generated from.
1 perry 215
3 CraigBox 216 !!Compatibility Issues
1 perry 217
3 CraigBox 218 The POSIX standard specifies behavior that differs from __patch__'s traditional behavior. You should be aware of these differences if you must interoperate with __patch__ versions 2.1 and earlier, which do not conform to POSIX .
1 perry 219
3 CraigBox 220 In traditional __patch__, the __-p__ option's operand was optional, and a bare __-p__ was equivalent to __-p0.__ The __-p__ option now requires an operand, and __-p 0__ is now equivalent to __-p0__. For maximum compatibility, use options like __-p0__ and __-p1__.
1 perry 221
3 CraigBox 222 Also, traditional __patch__ simply counted slashes when stripping path prefixes; __patch__ now counts pathname components. That is, a sequence of one or more adjacent slashes now counts as a single slash. For maximum portability, avoid sending patches containing __//__ in file names.
1 perry 223
3 CraigBox 224 In traditional __patch__, backups were enabled by default. This behavior is now enabled with the __-b__ or __--backup__ option.
1 perry 225
3 CraigBox 226 Conversely, in POSIX __patch__, backups are never made, even when there is a mismatch. In GNU __patch__, this behavior is enabled with the __--no-backup-if-mismatch__ option, or by conforming to POSIX with the __--posix__ option or by setting the __POSIXLY_CORRECT__ environment variable.
1 perry 227
3 CraigBox 228 The __-b__ ''suffix'' option of traditional __patch__ is equivalent to the __-b -z__ ''suffix'' options of GNU __patch__.
1 perry 229
3 CraigBox 230 Traditional __patch__ used a complicated (and incompletely documented) method to intuit the name of the file to be patched from the patch header. This method did not conform to POSIX , and had a few gotchas. Now __patch__ uses a different, equally complicated (but better documented) method that is optionally POSIX -conforming; we hope it has fewer gotchas. The two methods are compatible if the file names in the context diff header and the __Index:__ line are all identical after prefix-stripping. Your patch is normally compatible if each header's file names all contain the same number of slashes.
1 perry 231
3 CraigBox 232 When traditional __patch__ asked the user a question, it sent the question to standard error and looked for an answer from the first file in the following list that was a terminal: standard error, standard output, __/dev/tty__, and standard input. Now __patch__ sends questions to standard output and gets answers from __/dev/tty__. Defaults for some answers have been changed so that __patch__ never goes into an infinite loop when using default answers.
1 perry 233
234
3 CraigBox 235 Traditional __patch__ exited with a status value that counted the number of bad hunks, or with status 1 if there was real trouble. Now __patch__ exits with status 1 if some hunks failed, or with 2 if there was real trouble.
1 perry 236
237
3 CraigBox 238 Limit yourself to the following options when sending instructions meant to be executed by anyone running GNU __patch__, traditional __patch__, or a __patch__ that conforms to POSIX . Spaces are significant in the following list, and operands are required.
1 perry 239
3 CraigBox 240 * -c
241 * -d dir
242 * -D define
243 * -e
244 * -l
245 * -n
246 * -N
247 * -o outfile
248 * -pnum
249 * -R
250 * -r rejectfile
1 perry 251
3 CraigBox 252 !!Bugs
1 perry 253
3 CraigBox 254 Please report bugs via email to <bug-gnu-utils@gnu.org>.
1 perry 255
3 CraigBox 256 __patch__ could be smarter about partial matches, excessively deviant offsets and swapped code, but that would take an extra pass.
1 perry 257
3 CraigBox 258 If code has been duplicated (for instance with __#ifdef OLDCODE__ ... __#else ... #endif__), __patch__ is incapable of patching both versions, and, if it works at all, will likely patch the wrong one, and tell you that it succeeded to boot.
1 perry 259
3 CraigBox 260 If you apply a patch you've already applied, __patch__ thinks it is a reversed patch, and offers to un-apply the patch. This could be construed as a feature.
1 perry 261
3 CraigBox 262 !!Copying
1 perry 263
3 CraigBox 264 Copyright 1984, 1985, 1986, 1988 Larry Wall. Copyright 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
1 perry 265
3 CraigBox 266 Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.
1 perry 267
3 CraigBox 268 Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.
1 perry 269
3 CraigBox 270 Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that this permission notice may be included in translations approved by the copyright holders instead of in the original English.
1 perry 271
3 CraigBox 272 !!Authors
1 perry 273
3 CraigBox 274 Larry Wall wrote the original version of __patch__. Paul Eggert removed __patch__'s arbitrary limits; added support for binary files, setting file times, and deleting files; and made it conform better to POSIX . Other contributors include Wayne Davison, who added unidiff support, and David !MacKenzie, who added configuration and backup support.
1 perry 275
276 ----
4 JohnMcPherson 277 !! WLUG Notes
278 See also the PatchNotes page.
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.

PHP Warning

lib/blame.php:177: Warning: Invalid argument supplied for foreach() (...repeated 4 times)