HP-UX Reference (11i v2 07/12) - 1 User Commands N-Z (vol 2)

p
patch(1) patch(1)
Additionally, if the leading garbage contains a
Prereq: line, patch will take the first word from the
prerequisites line (normally a version number) and check the input file to see if that word can be found. If
not,
patch will ask for confirmation before proceeding.
The upshot of all this is that you should be able to say, while in a news interface, the following:
| patch -d /usr/src/local/blurfl
and patch a file in the
blurfl directory directly from the article containing the patch.
If the patch file contains more than one patch,
patch will try 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 will be examined for
interesting things such as file names and revision level, as mentioned previously. You can give options (and
another original file name) for the second and subsequent patches by separating the corresponding argu-
ment lists with a
+. (The argument list for a second or subsequent patch cannot specify a new patch file,
however.)
With the XPG4 version, the processing of multiple patches varies considerably. You cannot specify different
options for different patches. Options remain the same for all the patches. This also affects the contents of
output file specified with the -o option. See the description of this option for more details.
Options
patch recognizes the following options:
-b ext
causes the argument to be interpreted as the backup extension, to be used in place of .orig
.
(For the XPG4 version, no argument is required; the option only enables the backup process.
The default extension is always used.)
-c forces patch to interpret the patch file as a context diff.
-d dir
causes patch to interpret the argument as a directory, and to cd to it before doing anything
else.
-D define
causes patch to use the #ifdef...#endif construct to mark changes. The argument is used
as the differentiating symbol. Note that, unlike the C compiler, there must be a space between
the -D and the argument. (For the XPG4 version, the #ifndef constructor is not used.)
-e forces patch to interpret the patch file as an ed script.
-f forces patch to assume that the user knows exactly what he or she is doing, and to not ask any
questions. It does not suppress commentary, however. Use -s for that. (This option is not
supported by the XPG4 version.)
-F number
sets the maximum fuzz factor. This switch only applied to context diffs, 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 cannot be set to more
than the number of lines of context in the context diff, ordinarily 3. (This option is not supported
by the XPG4 version.)
-i patchfile
This option is supported only by the XPG4 version. It causes the argument to be interpreted as
the patch file name.
-l causes the pattern matching to be done loosely, in case the tabs and spaces have been munged in
your input file. Any sequence of whitespace in the pattern line will match any sequence in the
input file. Normal characters must still match exactly. Each line of the context must still match
a line in the input file.
-n forces patch to interpret the patch file as a normal diff.
-N causes patch to ignore patches that it thinks are reversed or already applied. See also -R.
-o outfile
causes the argument to be interpreted as the output file name. There are some added features
for the XPG4 version. Multiple patches for a single file will be applied to the intermediate ver-
sions of the file created by any previous patches, and will result in multiple, concatenated
HP-UX 11i Version 2: December 2007 Update 2 Hewlett-Packard Company 135