📄 patch.man
字号:
.\" -*- nroff -*-.rn '' }`'\" $Header: patch.man,v 2.0.1.2 88/06/22 20:47:18 lwall Locked $'\" '\" $Log: patch.man,v $'\" Revision 2.0.1.2 88/06/22 20:47:18 lwall'\" patch12: now avoids Bell System Logo'\" '\" Revision 2.0.1.1 88/06/03 15:12:51 lwall'\" patch10: -B switch was contributed.'\" '\" Revision 2.0 86/09/17 15:39:09 lwall'\" Baseline for netwide release.'\" '\" Revision 1.4 86/08/01 19:23:22 lwall'\" Documented -v, -p, -F.'\" Added notes to patch senders.'\" '\" Revision 1.3 85/03/26 15:11:06 lwall'\" Frozen.'\" '\" Revision 1.2.1.4 85/03/12 16:14:27 lwall'\" Documented -p.'\" '\" Revision 1.2.1.3 85/03/12 16:09:41 lwall'\" Documented -D.'\" '\" Revision 1.2.1.2 84/12/05 11:06:55 lwall'\" Added -l switch, and noted bistability bug.'\" '\" Revision 1.2.1.1 84/12/04 17:23:39 lwall'\" Branch for sdcrdcf changes.'\" '\" Revision 1.2 84/12/04 17:22:02 lwall'\" Baseline version.'\" .de Sh.br.ne 5.PP\fB\\$1\fR.PP...de Sp.if t .sp .5v.if n .sp..'\"'\" Set up \*(-- to give an unbreakable dash;'\" string Tr holds user defined translation string.'\" Bell System Logo is used as a dummy character.'\"'\" Shut up a groff -ww warning..if \n(.g .if !dTr .ds Tr.ie n \{\.tr \(*W-\*(Tr.ds -- \(*W-.if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch.if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch.ds L" "".ds R" "".ds L' '.ds R' ''br \}.el \{\.ds -- \(em\|.tr \*(Tr.ds L" ``.ds R" ''.ds L' `.ds R' ''br\}.TH PATCH 1 LOCAL.SH NAMEpatch - apply a diff file to an original.SH SYNOPSIS.B patch[options] [origfile [patchfile]] [+ [options] [origfile]]....spbut usually just.sp.B patch<patchfile.SH DESCRIPTION.I Patchwill take a patch file containing any of the four forms of differencelisting produced by the.I diffprogram and apply those differences to an original file, producing a patchedversion.By default, the patched version is put in place of the original, withthe original file backed up to the same name with theextension \*(L".orig\*(R" (\*(L"~\*(R" on systems that do notsupport long filenames), or as specified by the.BR -b ,.BR -B ,or.B -Vswitches.The extension used for making backup files may also be specified in the.B SIMPLE_BACKUP_SUFFIXenvironment variable, which is overridden by above switches..PPIf the backup file already exists,.B patchcreates a new backup file name by changing the first lowercase letterin the last component of the file's name into uppercase. If there areno more lowercase letters in the name, it removes the first characterfrom the name. It repeats this process until it comes up with abackup file that does not already exist..PPYou may also specify where you want the output to go with a.B -oswitch; if that file already exists, it is backed up first..PPIf.I patchfileis omitted, or is a hyphen, the patch will be read from standard input..PPUpon startup, patch will attempt to determine the type of the diff listing,unless over-ruled by a.BR -c ,.BR -e ,.BR -n ,or.B -uswitch.Context diffs (old-style, new-style, and unified) andnormal diffs are applied by the.I patchprogram itself, while ed diffs are simply fed to the.I ededitor via a pipe..PP.I Patchwill try to skip any leading garbage, apply the diff,and then skip any trailing garbage.Thus you could feed an article or message containing adiff listing to.IR patch ,and it should work.If the entire diff is indented by a consistent amount,this will be taken into account..PPWith context diffs, and to a lesser extent with normal diffs,.I patchcan detect when the line numbers mentioned in the patch are incorrect,and will attempt to find the correct place to apply each hunk of the patch.As a first guess, it takes the line number mentioned for the hunk, plus orminus any offset used in applying the previous hunk.If that is not the correct place,.I patchwill scan both forwards and backwards for a set of lines matching the contextgiven in the hunk.First.I patchlooks for a place where all lines of the context match.If no such place is found, and it's a context diff, and the maximum fuzz factoris set to 1 or more, then another scan takes place ignoring the first and lastline of context.If that fails, and the maximum fuzz factor is set to 2 or more,the first two and last two lines of context are ignored,and another scan is made.(The default maximum fuzz factor is 2.)If.I patchcannot find a place to install that hunk of the patch, it will put thehunk out to a reject file, which normally is the name of the output fileplus \*(L".rej\*(R" (\*(L"#\*(R" on systems that do not supportlong filenames).(Note that the rejected hunk will come out in context diff form whether theinput patch was a context diff or a normal diff.If the input was a normal diff, many of the contexts will simply be null.)The line numbers on the hunks in the reject file may be different thanin the patch file: they reflect the approximate location patch thinks thefailed hunks belong in the new file rather than the old one..PPAs each hunk is completed, you will be told whether the hunk succeeded orfailed, and which line (in the new file).I patchthought the hunk should go on.If this is different from the line number specified in the diff you willbe told the offset.A single large offset MAY be an indication that a hunk was installed in thewrong place.You will also be told if a fuzz factor was used to make the match, in whichcase you should also be slightly suspicious..PPIf no original file is specified on the command line,.I patchwill try to figure out from the leading garbage what the name of the fileto edit is.In the header of a context diff, the filename is found from lines beginningwith \*(L"***\*(R" or \*(L"---\*(R", with the shortest name of an existingfile winning.Only context diffs have lines like that, but if there is an \*(L"Index:\*(R"line in the leading garbage,.I patchwill try to use the filename from that line.The context diff header takes precedence over an Index line.If no filename can be intuited from the leading garbage, you will be askedfor the name of the file to patch..PPIf the original file cannot be found or is read-only, but a suitableSCCS or RCS file is handy,.I patchwill attempt to get or check out the file..PPAdditionally, if the leading garbage contains a \*(L"Prereq: \*(R" line,.I patchwill take the first word from the prerequisites line (normally a versionnumber) and check the input file to see if that word can be found.If not,.I patchwill ask for confirmation before proceeding..PPThe upshot of all this is that you should be able to say, while in a newsinterface, the following:.Sp | patch -d /usr/src/local/blurfl.Spand patch a file in the blurfl directory directly from the article containingthe patch..PPIf the patch file contains more than one patch,.I patchwill try to apply each of them as if they came from separate patch files.This means, among other things, that it is assumed that the name of the fileto patch must be determined for each diff listing,and that the garbage before each diff listing willbe examined for interesting things such as filenames and revision level, asmentioned previously.You can give switches (and another original file name) for the second andsubsequent patches by separating the corresponding argument listsby a \*(L'+\*(R'.(The argument list for a second or subsequent patch may not specify a newpatch file, however.).PP.I Patchrecognizes the following switches:.TP 5.B \-bcauses the next argument to be interpreted as the backup extension, to beused in place of \*(L".orig\*(R" or \*(L"~\*(R"..TP 5.B \-Bcauses the next argument to be interpreted as a prefix to the backup filename. If this argument is specified any argument from -b will be ignored..TP 5.B \-cforces.I patchto interpret the patch file as a context diff..TP 5.B \-dcauses.I patchto interpret the next argument as a directory, and cd to it before doinganything else..TP 5.B \-Dcauses.I patchto use the "#ifdef...#endif" construct to mark changes.The argument following will be used as the differentiating symbol.Note that, unlike the C compiler, there must be a space between the.B \-Dand the argument..TP 5.B \-eforces.I patchto interpret the patch file as an ed script..TP 5.B \-Ecauses.I patch
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -