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

p
patch(1) patch(1)
EXTERNAL INFLUENCES
Environment Variables
UNIX95 determines which version of patch is used. If this variable is set,
patch exhibits XPG4
behavior.
RETURN VALUE
The following exit values are returned for the XPG4 version:
0 Successful completion.
1 One or more lines were written to a reject file.
>1 An error occurred.
For the non-XPG4 version, exit values vary as follows:
0 Successful completion or one or more lines were written to a reject file.
1 An error occurred.
DIAGNOSTICS
Too many to list here, but generally indicative that
patch couldn’t parse your patch file.
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.
Note that only a few diagnostic messages are printed for the XPG4 version, since it does not support the
verbose option.
WARNINGS
patch cannot tell if the line numbers are off in an ed script, and can only detect bad line numbers in a nor-
mal diff when it finds a change or a delete command. 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.
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, and -n
, which force 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 com-
mands are present in the diff file, then the file is assumed to be an ed diff file and the patch proceeds.
patch 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 suc-
ceeded to boot.
If you apply a patch you have 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 the 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.
FILES
/var/tmp/patch*
SEE ALSO
diff(1), ed(1).
STANDARDS CONFORMANCE
patch: XPG4
HP-UX 11i Version 2: December 2007 Update 4 Hewlett-Packard Company 137