Open System Services Shell and Utilities Reference Manual (G06.29+, H06.08+, J06.03+)

patch(1) OSS Shell and Utilities Reference Manual
Make sure you specify the filenames correctly, 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 ag as needed.
You can create a file by using a diff script that compares a null file to the file you want to
create. This works only if the file you want to create does not already exist in the target
directory.
Take care not to send out reversed patches, because this makes users wonder whether
they have already applied the patch.
While you might be able to put many diff scripts into one file, it is advisable to group
related patches into separate files.
The patch command can detect bad line numbers in a normal diff script only when it
finds a change or a delete command.
The results of the patch command are guaranteed to be correct only when the patch is
applied to exactly the same version of the file from which the patch was generated.
If the code has been duplicated (for example, with #ifdef OLDCODE ... #else ...
#endif), patch is incapable of patching both versions, and, if patch works at all, it will
likely patch the wrong version and tell you that it succeeded.
If you apply a patch you have already applied, patch assumes it is a reversed patch and
offers to undo it.
Environment Variables
This command supports the use of the LANG, LC_ALL, LC_CTYPE, LC_MESSAGES,
NLSPATH, and LC_TIME environment variables.
DIAGNOSTICS
The message Hmm... indicates that there is unprocessed text in the patch file and that patch is
attempting to determine whether there is a patch in that text and, if there is, what kind of patch it
is.
EXIT VALUES
The patch command returns the following values:
0 (zero) The command completed successfully.
1 At least one reject file was created.
>1 An error occurred.
When applying a set of patches in a loop, you should check this exit status after each call to
patch, so that you do not apply a later patch to a partially patched file.
RELATED INFORMATION
Commands: diff(1).
STANDARDS CONFORMANCE
This command conforms to the XPG4 Version 2 specification with extensions.
710 Hewlett-Packard Company 527188-021