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

p
patch(1) patch(1)
-p number
sets the path name strip count, which controls how path names found in the patch file are treated, in
case the you keep your files in a different directory than the person who sent out the patch. The strip
count specifies how many backslashes are to be stripped from the front of the path name. (Any inter-
vening directory names also go away.) For example, supposing the file name in the patch file was
/u/howard/src/blurfl/blurfl.c
setting -p or -p0 gives the entire path name 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 option.
-r causes the next argument to be interpreted as the reject file name.
-R informs patch that this patch was created with the old and new files swapped.
patch will attempt
to swap each hunk around before applying it. Rejects will come out in the swapped format. The
-R
option 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 option set. If it can not, 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 (that is, it should have been a delete) since appends always succeed, due
to the fact that a null context will match anywhere. 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 the UNIX
Standard version.
-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 the UNIX Standard
version.
-v causes patch to print out its revision header and patch level. This option is not supported by the
UNIX Standard version.
-x number
sets internal debugging flags, and is of interest only to patch patchers. This option is not supported
by the UNIX Standard version.
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 will not let
them apply patches out of order without some warning. Second, make sure you have specified the file
names 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 option 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 does not 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 putting 582 diff listings into one file, it is probably wiser to group related patches into
separate files in case something goes haywire.
RETURN VALUE
The following exit values are returned for the UNIX Standard (see standards(5)) version:
0 Successful completion.
HP-UX 11i Version 3: February 2007 3 Hewlett-Packard Company 97