HP-UX Reference (11i v1 05/09) - 1 User Commands N-Z (vol 2)
p
patch(1) patch(1)
setting -p or -p0 gives the entire pathname unmodified,
-p1 gives
u/howard/src/blurfl/blurfl.c
without the leading slash, -p4 gives
blurfl/blurfl.c
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 switch.
-r causes the next argument to be interpreted as the reject file name.
-R tells patch 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 will attempt to swap each hunk
around before applying it. Rejects will come out in the swapped format. The
-R switch will 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 will reverse the hunk to see if it can be applied that way. If it
can, you will be asked if you want to have the
-R switch set. If it can’t, the patch will continue 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 will match anywhere. Luckily, most patches add or change lines rather
than delete them, so most reversed normal diffs will begin with a delete, which will fail, triggering the
heuristic.)
-s makes patch do its work silently, unless an error occurs. (This option is not supported by XPG4 ver-
sion.)
-S causes patch to ignore this patch from the patch file, but continue on looking for the next patch in the
file. Thus
patch -S + -S + <patchfile
will ignore the first and second of three patches. (This option is not supported by XPG4 version.)
-v causes patch to print out it’s revision header and patch level. (This option is not supported by XPG4
version.)
-x number
sets internal debugging flags, and is of interest only to patch patchers. (This option is not supported
by XPG4 version.)
EXTERNAL INFLUENCES
Environment Variables
UNIX95 determines which version of patch is used. If this variable is set, patch exhibits XPG4 behaviour.
RETURN VALUE
The following exit values are returned for XPG4 version:
0 Successful completion.
1 One or more lines were written to a reject file.
>1 An error occurred.
For 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 attempt-
ing to intuit whether there is a patch in that text and, if so, what kind of patch it is.
Note that only few diagnostic messages are printed for XPG4 version, since it does not support 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
Section 1−−694 Hewlett-Packard Company − 3 − HP-UX 11i Version 1: September 2005