HP-UX Reference (11i v1 05/09) - 1 User Commands N-Z (vol 2)
p
patch(1) patch(1)
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.
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.
The result obtained from the XPG4 options
-c, -e, -n which forces the patch command to interpret the
diff file either as a context diff or as an ed script or as a normal diff respectively is unspecified. For example,
if one forces the patch command to treat the context diff file as an ed script, the result is unspecified. The
same is true if one forces patch to treat an ed script as a context file and so on.. When a diff is forced with
the above options, the diff file is searched for patterns that are specific to that type of diff file. If the diff file
is not what was specified by the option, the file is checked for ed commands. If ed commands are present in
the diff file, then the file is assumed to be an ed_diff file and the patch proceeds.
FILES
/var/tmp/patch*
SEE ALSO
diff(1), ed(1).
NOTES FOR PATCH SENDERS
There are several things you should bear in mind if you are going to be sending out patches. First, 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. Second, make sure you’ve specified the filenames right, either
in a context diff header, or with an Index: line. If you are patching something in a subdirectory, be sure to
tell the patch user to specify a -p switch as needed. Third, you can create a file by sending out a diff that
compares a null file to the file you want to create. This will only work if the file you want to create doesn’t
exist already in the target directory. Fourth, take care not to send out reversed patches, since it makes
people wonder whether they already applied the patch. Fifth, while you may be able to get away with put-
ting 582 diff listings into one file, it is probably wiser to group related patches into separate files in case
something goes haywire.
BUGS
Could be smarter about partial matches, excessively deviant offsets and swapped code, but that would take
an extra pass.
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.
If you apply a patch you’ve already applied, patch will think it is a reversed patch, and offer to un-apply the
patch. This could be construed as a feature.
One more thing to be noted with respect to XPG4 version of patch. If you are using multiple patches for
different files, group patches that have to be applied to a single file. Otherwise, intermediate versions of the
previous patches of a file will not be used for the current patch.
STANDARDS CONFORMANCE
patch: XPG4
HP-UX 11i Version 1: September 2005 − 4 − Hewlett-Packard Company Section 1−−695