xref: /freebsd/contrib/diff/doc/diff.7 (revision 98e0ffaefb0f241cda3a72395d3be04192ae0d47)
1*2fd5d190SBaptiste Daroussin.Dd 2015-03-02
2*2fd5d190SBaptiste Daroussin.Dt DIFF 7
3*2fd5d190SBaptiste Daroussin.Os
4*2fd5d190SBaptiste Daroussin.Sh NAME
5*2fd5d190SBaptiste Daroussin.Nm diff
6*2fd5d190SBaptiste Daroussin.Nd Comparing and Merging Files
7*2fd5d190SBaptiste Daroussin.Sh  Comparing and Merging Files
8*2fd5d190SBaptiste Daroussin.Sh  Overview
9*2fd5d190SBaptiste DaroussinComputer users often find occasion to ask how two files differ. Perhaps one
10*2fd5d190SBaptiste Daroussinfile is a newer version of the other file. Or maybe the two files started
11*2fd5d190SBaptiste Daroussinout as identical copies but were changed by different people.
12*2fd5d190SBaptiste Daroussin.Pp
13*2fd5d190SBaptiste DaroussinYou can use the
14*2fd5d190SBaptiste Daroussin.Xr diff
15*2fd5d190SBaptiste Daroussincommand to show differences between two files, or each corresponding file
16*2fd5d190SBaptiste Daroussinin two directories.
17*2fd5d190SBaptiste Daroussin.Xr diff
18*2fd5d190SBaptiste Daroussinoutputs differences between files line by line in any of several formats,
19*2fd5d190SBaptiste Daroussinselectable by command line options. This set of differences is often called
20*2fd5d190SBaptiste Daroussina
21*2fd5d190SBaptiste Daroussin.Em diff
22*2fd5d190SBaptiste Daroussinor
23*2fd5d190SBaptiste Daroussin.Em patch .
24*2fd5d190SBaptiste DaroussinFor files that are identical,
25*2fd5d190SBaptiste Daroussin.Xr diff
26*2fd5d190SBaptiste Daroussinnormally produces no output; for binary (non-text) files,
27*2fd5d190SBaptiste Daroussin.Xr diff
28*2fd5d190SBaptiste Daroussinnormally reports only that they are different.
29*2fd5d190SBaptiste Daroussin.Pp
30*2fd5d190SBaptiste DaroussinYou can use the
31*2fd5d190SBaptiste Daroussin.Xr cmp
32*2fd5d190SBaptiste Daroussincommand to show the byte and line numbers where two files differ.
33*2fd5d190SBaptiste Daroussin.Xr cmp
34*2fd5d190SBaptiste Daroussincan also show all the bytes that differ between the two files, side by side.
35*2fd5d190SBaptiste DaroussinA way to compare two files character by character is the Emacs command
36*2fd5d190SBaptiste Daroussin.Li M-x compare-windows .
37*2fd5d190SBaptiste DaroussinSee Section.Dq Other Window ,
38*2fd5d190SBaptiste Daroussinfor more information on that command.
39*2fd5d190SBaptiste Daroussin.Pp
40*2fd5d190SBaptiste DaroussinYou can use the
41*2fd5d190SBaptiste Daroussin.Xr diff3
42*2fd5d190SBaptiste Daroussincommand to show differences among three files. When two people have made independent
43*2fd5d190SBaptiste Daroussinchanges to a common original,
44*2fd5d190SBaptiste Daroussin.Xr diff3
45*2fd5d190SBaptiste Daroussincan report the differences between the original and the two changed versions,
46*2fd5d190SBaptiste Daroussinand can produce a merged file that contains both persons' changes together
47*2fd5d190SBaptiste Daroussinwith warnings about conflicts.
48*2fd5d190SBaptiste Daroussin.Pp
49*2fd5d190SBaptiste DaroussinYou can use the
50*2fd5d190SBaptiste Daroussin.Xr sdiff
51*2fd5d190SBaptiste Daroussincommand to merge two files interactively.
52*2fd5d190SBaptiste Daroussin.Pp
53*2fd5d190SBaptiste DaroussinYou can use the set of differences produced by
54*2fd5d190SBaptiste Daroussin.Xr diff
55*2fd5d190SBaptiste Daroussinto distribute updates to text files (such as program source code) to other
56*2fd5d190SBaptiste Daroussinpeople. This method is especially useful when the differences are small compared
57*2fd5d190SBaptiste Daroussinto the complete files. Given
58*2fd5d190SBaptiste Daroussin.Xr diff
59*2fd5d190SBaptiste Daroussinoutput, you can use the
60*2fd5d190SBaptiste Daroussin.Xr patch
61*2fd5d190SBaptiste Daroussinprogram to update, or
62*2fd5d190SBaptiste Daroussin.Em patch ,
63*2fd5d190SBaptiste Daroussina copy of the file. If you think of
64*2fd5d190SBaptiste Daroussin.Xr diff
65*2fd5d190SBaptiste Daroussinas subtracting one file from another to produce their difference, you can
66*2fd5d190SBaptiste Daroussinthink of
67*2fd5d190SBaptiste Daroussin.Xr patch
68*2fd5d190SBaptiste Daroussinas adding the difference to one file to reproduce the other.
69*2fd5d190SBaptiste Daroussin.Pp
70*2fd5d190SBaptiste DaroussinThis manual first concentrates on making diffs, and later shows how to use
71*2fd5d190SBaptiste Daroussindiffs to update files.
72*2fd5d190SBaptiste Daroussin.Pp
73*2fd5d190SBaptiste DaroussinGNU
74*2fd5d190SBaptiste Daroussin.Xr diff
75*2fd5d190SBaptiste Daroussinwas written by Paul Eggert, Mike Haertel, David Hayes, Richard Stallman, and
76*2fd5d190SBaptiste DaroussinLen Tower. Wayne Davison designed and implemented the unified output format.
77*2fd5d190SBaptiste DaroussinThe basic algorithm is described by Eugene W. Myers in \(lqAn O(ND) Difference
78*2fd5d190SBaptiste DaroussinAlgorithm and its Variations\(rq,
79*2fd5d190SBaptiste Daroussin.Em Algorithmica
80*2fd5d190SBaptiste DaroussinVol. 1 No. 2, 1986, pp. 251--266; and in \(lqA File Comparison Program\(rq, Webb Miller
81*2fd5d190SBaptiste Daroussinand Eugene W. Myers,
82*2fd5d190SBaptiste Daroussin.Em Software---Practice and Experience
83*2fd5d190SBaptiste DaroussinVol. 15 No. 11, 1985, pp. 1025--1040. The algorithm was independently discovered
84*2fd5d190SBaptiste Daroussinas described by E. Ukkonen in \(lqAlgorithms for Approximate String Matching\(rq,
85*2fd5d190SBaptiste Daroussin.Em Information and Control
86*2fd5d190SBaptiste DaroussinVol. 64, 1985, pp. 100--118. Unless the
87*2fd5d190SBaptiste Daroussin.Op --minimal
88*2fd5d190SBaptiste Daroussinoption is used,
89*2fd5d190SBaptiste Daroussin.Xr diff
90*2fd5d190SBaptiste Daroussinuses a heuristic by Paul Eggert that limits the cost to O(N^1.5 log N) at
91*2fd5d190SBaptiste Daroussinthe price of producing suboptimal output for large inputs with many differences.
92*2fd5d190SBaptiste DaroussinRelated algorithms are surveyed by Alfred V. Aho in section 6.3 of \(lqAlgorithms
93*2fd5d190SBaptiste Daroussinfor Finding Patterns in Strings\(rq,
94*2fd5d190SBaptiste Daroussin.Em Handbook of Theoretical Computer Science
95*2fd5d190SBaptiste Daroussin(Jan Van Leeuwen, ed.), Vol. A,
96*2fd5d190SBaptiste Daroussin.Em Algorithms and Complexity ,
97*2fd5d190SBaptiste DaroussinElsevier/MIT Press, 1990, pp. 255--300.
98*2fd5d190SBaptiste Daroussin.Pp
99*2fd5d190SBaptiste DaroussinGNU
100*2fd5d190SBaptiste Daroussin.Xr diff3
101*2fd5d190SBaptiste Daroussinwas written by Randy Smith. GNU
102*2fd5d190SBaptiste Daroussin.Xr sdiff
103*2fd5d190SBaptiste Daroussinwas written by Thomas Lord. GNU
104*2fd5d190SBaptiste Daroussin.Xr cmp
105*2fd5d190SBaptiste Daroussinwas written by Torbj\(:orn Granlund and David MacKenzie.
106*2fd5d190SBaptiste Daroussin.Pp
107*2fd5d190SBaptiste DaroussinGNU
108*2fd5d190SBaptiste Daroussin.Xr patch
109*2fd5d190SBaptiste Daroussinwas written mainly by Larry Wall and Paul Eggert; several GNU enhancements
110*2fd5d190SBaptiste Daroussinwere contributed by Wayne Davison and David MacKenzie. Parts of this manual
111*2fd5d190SBaptiste Daroussinare adapted from a manual page written by Larry Wall, with his permission.
112*2fd5d190SBaptiste Daroussin.Pp
113*2fd5d190SBaptiste Daroussin.Sh  What Comparison Means
114*2fd5d190SBaptiste DaroussinThere are several ways to think about the differences between two files. One
115*2fd5d190SBaptiste Daroussinway to think of the differences is as a series of lines that were deleted
116*2fd5d190SBaptiste Daroussinfrom, inserted in, or changed in one file to produce the other file.
117*2fd5d190SBaptiste Daroussin.Xr diff
118*2fd5d190SBaptiste Daroussincompares two files line by line, finds groups of lines that differ, and reports
119*2fd5d190SBaptiste Daroussineach group of differing lines. It can report the differing lines in several
120*2fd5d190SBaptiste Daroussinformats, which have different purposes.
121*2fd5d190SBaptiste Daroussin.Pp
122*2fd5d190SBaptiste DaroussinGNU
123*2fd5d190SBaptiste Daroussin.Xr diff
124*2fd5d190SBaptiste Daroussincan show whether files are different without detailing the differences. It
125*2fd5d190SBaptiste Daroussinalso provides ways to suppress certain kinds of differences that are not important
126*2fd5d190SBaptiste Daroussinto you. Most commonly, such differences are changes in the amount of white
127*2fd5d190SBaptiste Daroussinspace between words or lines.
128*2fd5d190SBaptiste Daroussin.Xr diff
129*2fd5d190SBaptiste Daroussinalso provides ways to suppress differences in alphabetic case or in lines
130*2fd5d190SBaptiste Daroussinthat match a regular expression that you provide. These options can accumulate;
131*2fd5d190SBaptiste Daroussinfor example, you can ignore changes in both white space and alphabetic case.
132*2fd5d190SBaptiste Daroussin.Pp
133*2fd5d190SBaptiste DaroussinAnother way to think of the differences between two files is as a sequence
134*2fd5d190SBaptiste Daroussinof pairs of bytes that can be either identical or different.
135*2fd5d190SBaptiste Daroussin.Xr cmp
136*2fd5d190SBaptiste Daroussinreports the differences between two files byte by byte, instead of line by
137*2fd5d190SBaptiste Daroussinline. As a result, it is often more useful than
138*2fd5d190SBaptiste Daroussin.Xr diff
139*2fd5d190SBaptiste Daroussinfor comparing binary files. For text files,
140*2fd5d190SBaptiste Daroussin.Xr cmp
141*2fd5d190SBaptiste Daroussinis useful mainly when you want to know only whether two files are identical,
142*2fd5d190SBaptiste Daroussinor whether one file is a prefix of the other.
143*2fd5d190SBaptiste Daroussin.Pp
144*2fd5d190SBaptiste DaroussinTo illustrate the effect that considering changes byte by byte can have compared
145*2fd5d190SBaptiste Daroussinwith considering them line by line, think of what happens if a single newline
146*2fd5d190SBaptiste Daroussincharacter is added to the beginning of a file. If that file is then compared
147*2fd5d190SBaptiste Daroussinwith an otherwise identical file that lacks the newline at the beginning,
148*2fd5d190SBaptiste Daroussin.Xr diff
149*2fd5d190SBaptiste Daroussinwill report that a blank line has been added to the file, while
150*2fd5d190SBaptiste Daroussin.Xr cmp
151*2fd5d190SBaptiste Daroussinwill report that almost every byte of the two files differs.
152*2fd5d190SBaptiste Daroussin.Pp
153*2fd5d190SBaptiste Daroussin.Xr diff3
154*2fd5d190SBaptiste Daroussinnormally compares three input files line by line, finds groups of lines that
155*2fd5d190SBaptiste Daroussindiffer, and reports each group of differing lines. Its output is designed
156*2fd5d190SBaptiste Daroussinto make it easy to inspect two different sets of changes to the same file.
157*2fd5d190SBaptiste Daroussin.Pp
158*2fd5d190SBaptiste Daroussin.Ss  Hunks
159*2fd5d190SBaptiste DaroussinWhen comparing two files,
160*2fd5d190SBaptiste Daroussin.Xr diff
161*2fd5d190SBaptiste Daroussinfinds sequences of lines common to both files, interspersed with groups of
162*2fd5d190SBaptiste Daroussindiffering lines called
163*2fd5d190SBaptiste Daroussin.Em hunks .
164*2fd5d190SBaptiste DaroussinComparing two identical files yields one sequence of common lines and no hunks,
165*2fd5d190SBaptiste Daroussinbecause no lines differ. Comparing two entirely different files yields no
166*2fd5d190SBaptiste Daroussincommon lines and one large hunk that contains all lines of both files. In
167*2fd5d190SBaptiste Daroussingeneral, there are many ways to match up lines between two given files.
168*2fd5d190SBaptiste Daroussin.Xr diff
169*2fd5d190SBaptiste Daroussintries to minimize the total hunk size by finding large sequences of common
170*2fd5d190SBaptiste Daroussinlines interspersed with small hunks of differing lines.
171*2fd5d190SBaptiste Daroussin.Pp
172*2fd5d190SBaptiste DaroussinFor example, suppose the file
173*2fd5d190SBaptiste Daroussin.Pa F
174*2fd5d190SBaptiste Daroussincontains the three lines
175*2fd5d190SBaptiste Daroussin.Li a ,
176*2fd5d190SBaptiste Daroussin.Li b ,
177*2fd5d190SBaptiste Daroussin.Li c ,
178*2fd5d190SBaptiste Daroussinand the file
179*2fd5d190SBaptiste Daroussin.Pa G
180*2fd5d190SBaptiste Daroussincontains the same three lines in reverse order
181*2fd5d190SBaptiste Daroussin.Li c ,
182*2fd5d190SBaptiste Daroussin.Li b ,
183*2fd5d190SBaptiste Daroussin.Li a .
184*2fd5d190SBaptiste DaroussinIf
185*2fd5d190SBaptiste Daroussin.Xr diff
186*2fd5d190SBaptiste Daroussinfinds the line
187*2fd5d190SBaptiste Daroussin.Li c
188*2fd5d190SBaptiste Daroussinas common, then the command
189*2fd5d190SBaptiste Daroussin.Li diff F G
190*2fd5d190SBaptiste Daroussinproduces this output:
191*2fd5d190SBaptiste Daroussin.Pp
192*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
193*2fd5d190SBaptiste Daroussin1,2d0
194*2fd5d190SBaptiste Daroussin< a
195*2fd5d190SBaptiste Daroussin< b
196*2fd5d190SBaptiste Daroussin3a2,3
197*2fd5d190SBaptiste Daroussin> b
198*2fd5d190SBaptiste Daroussin> a
199*2fd5d190SBaptiste Daroussin.Ed
200*2fd5d190SBaptiste Daroussin.Pp
201*2fd5d190SBaptiste DaroussinBut if
202*2fd5d190SBaptiste Daroussin.Xr diff
203*2fd5d190SBaptiste Daroussinnotices the common line
204*2fd5d190SBaptiste Daroussin.Li b
205*2fd5d190SBaptiste Daroussininstead, it produces this output:
206*2fd5d190SBaptiste Daroussin.Pp
207*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
208*2fd5d190SBaptiste Daroussin1c1
209*2fd5d190SBaptiste Daroussin< a
210*2fd5d190SBaptiste Daroussin---
211*2fd5d190SBaptiste Daroussin> c
212*2fd5d190SBaptiste Daroussin3c3
213*2fd5d190SBaptiste Daroussin< c
214*2fd5d190SBaptiste Daroussin---
215*2fd5d190SBaptiste Daroussin> a
216*2fd5d190SBaptiste Daroussin.Ed
217*2fd5d190SBaptiste Daroussin.Pp
218*2fd5d190SBaptiste DaroussinIt is also possible to find
219*2fd5d190SBaptiste Daroussin.Li a
220*2fd5d190SBaptiste Daroussinas the common line.
221*2fd5d190SBaptiste Daroussin.Xr diff
222*2fd5d190SBaptiste Daroussindoes not always find an optimal matching between the files; it takes shortcuts
223*2fd5d190SBaptiste Daroussinto run faster. But its output is usually close to the shortest possible. You
224*2fd5d190SBaptiste Daroussincan adjust this tradeoff with the
225*2fd5d190SBaptiste Daroussin.Op -d
226*2fd5d190SBaptiste Daroussinor
227*2fd5d190SBaptiste Daroussin.Op --minimal
228*2fd5d190SBaptiste Daroussinoption (see Section
229*2fd5d190SBaptiste Daroussin.Dq diff Performance ) .
230*2fd5d190SBaptiste Daroussin.Pp
231*2fd5d190SBaptiste Daroussin.Ss  Suppressing Differences in Blank and Tab Spacing
232*2fd5d190SBaptiste DaroussinThe
233*2fd5d190SBaptiste Daroussin.Op -E
234*2fd5d190SBaptiste Daroussinor
235*2fd5d190SBaptiste Daroussin.Op --ignore-tab-expansion
236*2fd5d190SBaptiste Daroussinoption ignores the distinction between tabs and spaces on input. A tab is
237*2fd5d190SBaptiste Daroussinconsidered to be equivalent to the number of spaces to the next tab stop (see Section
238*2fd5d190SBaptiste Daroussin.Dq Tabs ) .
239*2fd5d190SBaptiste Daroussin.Pp
240*2fd5d190SBaptiste DaroussinThe
241*2fd5d190SBaptiste Daroussin.Op -b
242*2fd5d190SBaptiste Daroussinor
243*2fd5d190SBaptiste Daroussin.Op --ignore-space-change
244*2fd5d190SBaptiste Daroussinoption is stronger. It ignores white space at line end, and considers all
245*2fd5d190SBaptiste Daroussinother sequences of one or more white space characters within a line to be
246*2fd5d190SBaptiste Daroussinequivalent. With this option,
247*2fd5d190SBaptiste Daroussin.Xr diff
248*2fd5d190SBaptiste Daroussinconsiders the following two lines to be equivalent, where
249*2fd5d190SBaptiste Daroussin.Li $
250*2fd5d190SBaptiste Daroussindenotes the line end:
251*2fd5d190SBaptiste Daroussin.Pp
252*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
253*2fd5d190SBaptiste DaroussinHere lyeth  muche rychnesse  in lytell space.   -- John Heywood$
254*2fd5d190SBaptiste DaroussinHere lyeth muche rychnesse in lytell space. -- John Heywood   $
255*2fd5d190SBaptiste Daroussin.Ed
256*2fd5d190SBaptiste Daroussin.Pp
257*2fd5d190SBaptiste DaroussinThe
258*2fd5d190SBaptiste Daroussin.Op -w
259*2fd5d190SBaptiste Daroussinor
260*2fd5d190SBaptiste Daroussin.Op --ignore-all-space
261*2fd5d190SBaptiste Daroussinoption is stronger still. It ignores differences even if one line has white
262*2fd5d190SBaptiste Daroussinspace where the other line has none.
263*2fd5d190SBaptiste Daroussin.Em White space
264*2fd5d190SBaptiste Daroussincharacters include tab, newline, vertical tab, form feed, carriage return,
265*2fd5d190SBaptiste Daroussinand space; some locales may define additional characters to be white space.
266*2fd5d190SBaptiste DaroussinWith this option,
267*2fd5d190SBaptiste Daroussin.Xr diff
268*2fd5d190SBaptiste Daroussinconsiders the following two lines to be equivalent, where
269*2fd5d190SBaptiste Daroussin.Li $
270*2fd5d190SBaptiste Daroussindenotes the line end and
271*2fd5d190SBaptiste Daroussin.Li ^M
272*2fd5d190SBaptiste Daroussindenotes a carriage return:
273*2fd5d190SBaptiste Daroussin.Pp
274*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
275*2fd5d190SBaptiste DaroussinHere lyeth  muche  rychnesse in lytell space.--  John Heywood$
276*2fd5d190SBaptiste Daroussin  He relyeth much erychnes  seinly tells pace.  --John Heywood   ^M$
277*2fd5d190SBaptiste Daroussin.Ed
278*2fd5d190SBaptiste Daroussin.Pp
279*2fd5d190SBaptiste Daroussin.Ss  Suppressing Differences Whose Lines Are All Blank
280*2fd5d190SBaptiste DaroussinThe
281*2fd5d190SBaptiste Daroussin.Op -B
282*2fd5d190SBaptiste Daroussinor
283*2fd5d190SBaptiste Daroussin.Op --ignore-blank-lines
284*2fd5d190SBaptiste Daroussinoption ignores changes that consist entirely of blank lines. With this option,
285*2fd5d190SBaptiste Daroussinfor example, a file containing
286*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
287*2fd5d190SBaptiste Daroussin1.  A point is that which has no part.
288*2fd5d190SBaptiste Daroussin
289*2fd5d190SBaptiste Daroussin2.  A line is breadthless length.
290*2fd5d190SBaptiste Daroussin-- Euclid, The Elements, I
291*2fd5d190SBaptiste Daroussin.Ed
292*2fd5d190SBaptiste Daroussinis considered identical to a file containing
293*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
294*2fd5d190SBaptiste Daroussin1.  A point is that which has no part.
295*2fd5d190SBaptiste Daroussin2.  A line is breadthless length.
296*2fd5d190SBaptiste Daroussin
297*2fd5d190SBaptiste Daroussin
298*2fd5d190SBaptiste Daroussin-- Euclid, The Elements, I
299*2fd5d190SBaptiste Daroussin.Ed
300*2fd5d190SBaptiste Daroussin.Pp
301*2fd5d190SBaptiste DaroussinNormally this option affects only lines that are completely empty, but if
302*2fd5d190SBaptiste Daroussinyou also specify the
303*2fd5d190SBaptiste Daroussin.Op -b
304*2fd5d190SBaptiste Daroussinor
305*2fd5d190SBaptiste Daroussin.Op --ignore-space-change
306*2fd5d190SBaptiste Daroussinoption, or the
307*2fd5d190SBaptiste Daroussin.Op -w
308*2fd5d190SBaptiste Daroussinor
309*2fd5d190SBaptiste Daroussin.Op --ignore-all-space
310*2fd5d190SBaptiste Daroussinoption, lines are also affected if they look empty but contain white space.
311*2fd5d190SBaptiste DaroussinIn other words,
312*2fd5d190SBaptiste Daroussin.Op -B
313*2fd5d190SBaptiste Daroussinis equivalent to
314*2fd5d190SBaptiste Daroussin.Li -I '^$'
315*2fd5d190SBaptiste Daroussinby default, but it is equivalent to
316*2fd5d190SBaptiste Daroussin.Op -I '^[[:space:]]*$'
317*2fd5d190SBaptiste Daroussinif
318*2fd5d190SBaptiste Daroussin.Op -b
319*2fd5d190SBaptiste Daroussinor
320*2fd5d190SBaptiste Daroussin.Op -w
321*2fd5d190SBaptiste Daroussinis also specified.
322*2fd5d190SBaptiste Daroussin.Pp
323*2fd5d190SBaptiste Daroussin.Ss  Suppressing Differences Whose Lines All Match a Regular Expression
324*2fd5d190SBaptiste DaroussinTo ignore insertions and deletions of lines that match a
325*2fd5d190SBaptiste Daroussin.Xr grep
326*2fd5d190SBaptiste Daroussin-style regular expression, use the
327*2fd5d190SBaptiste Daroussin.Op -I Va regexp
328*2fd5d190SBaptiste Daroussinor
329*2fd5d190SBaptiste Daroussin.Op --ignore-matching-lines= Va regexp
330*2fd5d190SBaptiste Daroussinoption. You should escape regular expressions that contain shell metacharacters
331*2fd5d190SBaptiste Daroussinto prevent the shell from expanding them. For example,
332*2fd5d190SBaptiste Daroussin.Li diff -I '^[[:digit:]]'
333*2fd5d190SBaptiste Daroussinignores all changes to lines beginning with a digit.
334*2fd5d190SBaptiste Daroussin.Pp
335*2fd5d190SBaptiste DaroussinHowever,
336*2fd5d190SBaptiste Daroussin.Op -I
337*2fd5d190SBaptiste Daroussinonly ignores the insertion or deletion of lines that contain the regular expression
338*2fd5d190SBaptiste Daroussinif every changed line in the hunk---every insertion and every deletion---matches
339*2fd5d190SBaptiste Daroussinthe regular expression. In other words, for each nonignorable change,
340*2fd5d190SBaptiste Daroussin.Xr diff
341*2fd5d190SBaptiste Daroussinprints the complete set of changes in its vicinity, including the ignorable
342*2fd5d190SBaptiste Daroussinones.
343*2fd5d190SBaptiste Daroussin.Pp
344*2fd5d190SBaptiste DaroussinYou can specify more than one regular expression for lines to ignore by using
345*2fd5d190SBaptiste Daroussinmore than one
346*2fd5d190SBaptiste Daroussin.Op -I
347*2fd5d190SBaptiste Daroussinoption.
348*2fd5d190SBaptiste Daroussin.Xr diff
349*2fd5d190SBaptiste Daroussintries to match each line against each regular expression.
350*2fd5d190SBaptiste Daroussin.Pp
351*2fd5d190SBaptiste Daroussin.Ss  Suppressing Case Differences
352*2fd5d190SBaptiste DaroussinGNU
353*2fd5d190SBaptiste Daroussin.Xr diff
354*2fd5d190SBaptiste Daroussincan treat lower case letters as equivalent to their upper case counterparts,
355*2fd5d190SBaptiste Daroussinso that, for example, it considers
356*2fd5d190SBaptiste Daroussin.Li Funky Stuff ,
357*2fd5d190SBaptiste Daroussin.Li funky STUFF ,
358*2fd5d190SBaptiste Daroussinand
359*2fd5d190SBaptiste Daroussin.Li fUNKy stuFf
360*2fd5d190SBaptiste Daroussinto all be the same. To request this, use the
361*2fd5d190SBaptiste Daroussin.Op -i
362*2fd5d190SBaptiste Daroussinor
363*2fd5d190SBaptiste Daroussin.Op --ignore-case
364*2fd5d190SBaptiste Daroussinoption.
365*2fd5d190SBaptiste Daroussin.Pp
366*2fd5d190SBaptiste Daroussin.Ss  Summarizing Which Files Differ
367*2fd5d190SBaptiste DaroussinWhen you only want to find out whether files are different, and you don't
368*2fd5d190SBaptiste Daroussincare what the differences are, you can use the summary output format. In this
369*2fd5d190SBaptiste Daroussinformat, instead of showing the differences between the files,
370*2fd5d190SBaptiste Daroussin.Xr diff
371*2fd5d190SBaptiste Daroussinsimply reports whether files differ. The
372*2fd5d190SBaptiste Daroussin.Op -q
373*2fd5d190SBaptiste Daroussinor
374*2fd5d190SBaptiste Daroussin.Op --brief
375*2fd5d190SBaptiste Daroussinoption selects this output format.
376*2fd5d190SBaptiste Daroussin.Pp
377*2fd5d190SBaptiste DaroussinThis format is especially useful when comparing the contents of two directories.
378*2fd5d190SBaptiste DaroussinIt is also much faster than doing the normal line by line comparisons, because
379*2fd5d190SBaptiste Daroussin.Xr diff
380*2fd5d190SBaptiste Daroussincan stop analyzing the files as soon as it knows that there are any differences.
381*2fd5d190SBaptiste Daroussin.Pp
382*2fd5d190SBaptiste DaroussinYou can also get a brief indication of whether two files differ by using
383*2fd5d190SBaptiste Daroussin.Xr cmp .
384*2fd5d190SBaptiste DaroussinFor files that are identical,
385*2fd5d190SBaptiste Daroussin.Xr cmp
386*2fd5d190SBaptiste Daroussinproduces no output. When the files differ, by default,
387*2fd5d190SBaptiste Daroussin.Xr cmp
388*2fd5d190SBaptiste Daroussinoutputs the byte and line number where the first difference occurs, or reports
389*2fd5d190SBaptiste Daroussinthat one file is a prefix of the other. You can use the
390*2fd5d190SBaptiste Daroussin.Op -s ,
391*2fd5d190SBaptiste Daroussin.Op --quiet ,
392*2fd5d190SBaptiste Daroussinor
393*2fd5d190SBaptiste Daroussin.Op --silent
394*2fd5d190SBaptiste Daroussinoption to suppress that information, so that
395*2fd5d190SBaptiste Daroussin.Xr cmp
396*2fd5d190SBaptiste Daroussinproduces no output and reports whether the files differ using only its exit
397*2fd5d190SBaptiste Daroussinstatus (see Section
398*2fd5d190SBaptiste Daroussin.Dq Invoking cmp ) .
399*2fd5d190SBaptiste Daroussin.Pp
400*2fd5d190SBaptiste DaroussinUnlike
401*2fd5d190SBaptiste Daroussin.Xr diff ,
402*2fd5d190SBaptiste Daroussin.Xr cmp
403*2fd5d190SBaptiste Daroussincannot compare directories; it can only compare two files.
404*2fd5d190SBaptiste Daroussin.Pp
405*2fd5d190SBaptiste Daroussin.Ss  Binary Files and Forcing Text Comparisons
406*2fd5d190SBaptiste DaroussinIf
407*2fd5d190SBaptiste Daroussin.Xr diff
408*2fd5d190SBaptiste Daroussinthinks that either of the two files it is comparing is binary (a non-text
409*2fd5d190SBaptiste Daroussinfile), it normally treats that pair of files much as if the summary output
410*2fd5d190SBaptiste Daroussinformat had been selected (see Section
411*2fd5d190SBaptiste Daroussin.Dq Brief ) ,
412*2fd5d190SBaptiste Daroussinand reports only that the binary files are different. This is because line
413*2fd5d190SBaptiste Daroussinby line comparisons are usually not meaningful for binary files.
414*2fd5d190SBaptiste Daroussin.Pp
415*2fd5d190SBaptiste Daroussin.Xr diff
416*2fd5d190SBaptiste Daroussindetermines whether a file is text or binary by checking the first few bytes
417*2fd5d190SBaptiste Daroussinin the file; the exact number of bytes is system dependent, but it is typically
418*2fd5d190SBaptiste Daroussinseveral thousand. If every byte in that part of the file is non-null,
419*2fd5d190SBaptiste Daroussin.Xr diff
420*2fd5d190SBaptiste Daroussinconsiders the file to be text; otherwise it considers the file to be binary.
421*2fd5d190SBaptiste Daroussin.Pp
422*2fd5d190SBaptiste DaroussinSometimes you might want to force
423*2fd5d190SBaptiste Daroussin.Xr diff
424*2fd5d190SBaptiste Daroussinto consider files to be text. For example, you might be comparing text files
425*2fd5d190SBaptiste Daroussinthat contain null characters;
426*2fd5d190SBaptiste Daroussin.Xr diff
427*2fd5d190SBaptiste Daroussinwould erroneously decide that those are non-text files. Or you might be comparing
428*2fd5d190SBaptiste Daroussindocuments that are in a format used by a word processing system that uses
429*2fd5d190SBaptiste Daroussinnull characters to indicate special formatting. You can force
430*2fd5d190SBaptiste Daroussin.Xr diff
431*2fd5d190SBaptiste Daroussinto consider all files to be text files, and compare them line by line, by
432*2fd5d190SBaptiste Daroussinusing the
433*2fd5d190SBaptiste Daroussin.Op -a
434*2fd5d190SBaptiste Daroussinor
435*2fd5d190SBaptiste Daroussin.Op --text
436*2fd5d190SBaptiste Daroussinoption. If the files you compare using this option do not in fact contain
437*2fd5d190SBaptiste Daroussintext, they will probably contain few newline characters, and the
438*2fd5d190SBaptiste Daroussin.Xr diff
439*2fd5d190SBaptiste Daroussinoutput will consist of hunks showing differences between long lines of whatever
440*2fd5d190SBaptiste Daroussincharacters the files contain.
441*2fd5d190SBaptiste Daroussin.Pp
442*2fd5d190SBaptiste DaroussinYou can also force
443*2fd5d190SBaptiste Daroussin.Xr diff
444*2fd5d190SBaptiste Daroussinto report only whether files differ (but not how). Use the
445*2fd5d190SBaptiste Daroussin.Op -q
446*2fd5d190SBaptiste Daroussinor
447*2fd5d190SBaptiste Daroussin.Op --brief
448*2fd5d190SBaptiste Daroussinoption for this.
449*2fd5d190SBaptiste Daroussin.Pp
450*2fd5d190SBaptiste DaroussinNormally, differing binary files count as trouble because the resulting
451*2fd5d190SBaptiste Daroussin.Xr diff
452*2fd5d190SBaptiste Daroussinoutput does not capture all the differences. This trouble causes
453*2fd5d190SBaptiste Daroussin.Xr diff
454*2fd5d190SBaptiste Daroussinto exit with status 2. However, this trouble cannot occur with the
455*2fd5d190SBaptiste Daroussin.Op -a
456*2fd5d190SBaptiste Daroussinor
457*2fd5d190SBaptiste Daroussin.Op --text
458*2fd5d190SBaptiste Daroussinoption, or with the
459*2fd5d190SBaptiste Daroussin.Op -q
460*2fd5d190SBaptiste Daroussinor
461*2fd5d190SBaptiste Daroussin.Op --brief
462*2fd5d190SBaptiste Daroussinoption, as these options both cause
463*2fd5d190SBaptiste Daroussin.Xr diff
464*2fd5d190SBaptiste Daroussinto generate a form of output that represents differences as requested.
465*2fd5d190SBaptiste Daroussin.Pp
466*2fd5d190SBaptiste DaroussinIn operating systems that distinguish between text and binary files,
467*2fd5d190SBaptiste Daroussin.Xr diff
468*2fd5d190SBaptiste Daroussinnormally reads and writes all data as text. Use the
469*2fd5d190SBaptiste Daroussin.Op --binary
470*2fd5d190SBaptiste Daroussinoption to force
471*2fd5d190SBaptiste Daroussin.Xr diff
472*2fd5d190SBaptiste Daroussinto read and write binary data instead. This option has no effect on a POSIX-compliant
473*2fd5d190SBaptiste Daroussinsystem like GNU or traditional Unix. However, many personal computer operating
474*2fd5d190SBaptiste Daroussinsystems represent the end of a line with a carriage return followed by a newline.
475*2fd5d190SBaptiste DaroussinOn such systems,
476*2fd5d190SBaptiste Daroussin.Xr diff
477*2fd5d190SBaptiste Daroussinnormally ignores these carriage returns on input and generates them at the
478*2fd5d190SBaptiste Daroussinend of each output line, but with the
479*2fd5d190SBaptiste Daroussin.Op --binary
480*2fd5d190SBaptiste Daroussinoption
481*2fd5d190SBaptiste Daroussin.Xr diff
482*2fd5d190SBaptiste Daroussintreats each carriage return as just another input character, and does not
483*2fd5d190SBaptiste Daroussingenerate a carriage return at the end of each output line. This can be useful
484*2fd5d190SBaptiste Daroussinwhen dealing with non-text files that are meant to be interchanged with POSIX-compliant
485*2fd5d190SBaptiste Daroussinsystems.
486*2fd5d190SBaptiste Daroussin.Pp
487*2fd5d190SBaptiste DaroussinThe
488*2fd5d190SBaptiste Daroussin.Op --strip-trailing-cr
489*2fd5d190SBaptiste Daroussincauses
490*2fd5d190SBaptiste Daroussin.Xr diff
491*2fd5d190SBaptiste Daroussinto treat input lines that end in carriage return followed by newline as if
492*2fd5d190SBaptiste Daroussinthey end in plain newline. This can be useful when comparing text that is
493*2fd5d190SBaptiste Daroussinimperfectly imported from many personal computer operating systems. This option
494*2fd5d190SBaptiste Daroussinaffects how lines are read, which in turn affects how they are compared and
495*2fd5d190SBaptiste Daroussinoutput.
496*2fd5d190SBaptiste Daroussin.Pp
497*2fd5d190SBaptiste DaroussinIf you want to compare two files byte by byte, you can use the
498*2fd5d190SBaptiste Daroussin.Xr cmp
499*2fd5d190SBaptiste Daroussinprogram with the
500*2fd5d190SBaptiste Daroussin.Op -l
501*2fd5d190SBaptiste Daroussinor
502*2fd5d190SBaptiste Daroussin.Op --verbose
503*2fd5d190SBaptiste Daroussinoption to show the values of each differing byte in the two files. With GNU
504*2fd5d190SBaptiste Daroussin.Xr cmp ,
505*2fd5d190SBaptiste Daroussinyou can also use the
506*2fd5d190SBaptiste Daroussin.Op -b
507*2fd5d190SBaptiste Daroussinor
508*2fd5d190SBaptiste Daroussin.Op --print-bytes
509*2fd5d190SBaptiste Daroussinoption to show the ASCII representation of those bytes.See Section
510*2fd5d190SBaptiste Daroussin.Dq Invoking cmp ,
511*2fd5d190SBaptiste Daroussinfor more information.
512*2fd5d190SBaptiste Daroussin.Pp
513*2fd5d190SBaptiste DaroussinIf
514*2fd5d190SBaptiste Daroussin.Xr diff3
515*2fd5d190SBaptiste Daroussinthinks that any of the files it is comparing is binary (a non-text file),
516*2fd5d190SBaptiste Daroussinit normally reports an error, because such comparisons are usually not useful.
517*2fd5d190SBaptiste Daroussin.Xr diff3
518*2fd5d190SBaptiste Daroussinuses the same test as
519*2fd5d190SBaptiste Daroussin.Xr diff
520*2fd5d190SBaptiste Daroussinto decide whether a file is binary. As with
521*2fd5d190SBaptiste Daroussin.Xr diff ,
522*2fd5d190SBaptiste Daroussinif the input files contain a few non-text bytes but otherwise are like text
523*2fd5d190SBaptiste Daroussinfiles, you can force
524*2fd5d190SBaptiste Daroussin.Xr diff3
525*2fd5d190SBaptiste Daroussinto consider all files to be text files and compare them line by line by using
526*2fd5d190SBaptiste Daroussinthe
527*2fd5d190SBaptiste Daroussin.Op -a
528*2fd5d190SBaptiste Daroussinor
529*2fd5d190SBaptiste Daroussin.Op --text
530*2fd5d190SBaptiste Daroussinoption.
531*2fd5d190SBaptiste Daroussin.Pp
532*2fd5d190SBaptiste Daroussin.Sh  Xr diff Output Formats
533*2fd5d190SBaptiste Daroussin.Xr diff
534*2fd5d190SBaptiste Daroussinhas several mutually exclusive options for output format. The following sections
535*2fd5d190SBaptiste Daroussindescribe each format, illustrating how
536*2fd5d190SBaptiste Daroussin.Xr diff
537*2fd5d190SBaptiste Daroussinreports the differences between two sample input files.
538*2fd5d190SBaptiste Daroussin.Pp
539*2fd5d190SBaptiste Daroussin.Ss  Two Sample Input Files
540*2fd5d190SBaptiste DaroussinHere are two sample files that we will use in numerous examples to illustrate
541*2fd5d190SBaptiste Daroussinthe output of
542*2fd5d190SBaptiste Daroussin.Xr diff
543*2fd5d190SBaptiste Daroussinand how various options can change it.
544*2fd5d190SBaptiste Daroussin.Pp
545*2fd5d190SBaptiste DaroussinThis is the file
546*2fd5d190SBaptiste Daroussin.Pa lao :
547*2fd5d190SBaptiste Daroussin.Pp
548*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
549*2fd5d190SBaptiste DaroussinThe Way that can be told of is not the eternal Way;
550*2fd5d190SBaptiste DaroussinThe name that can be named is not the eternal name.
551*2fd5d190SBaptiste DaroussinThe Nameless is the origin of Heaven and Earth;
552*2fd5d190SBaptiste DaroussinThe Named is the mother of all things.
553*2fd5d190SBaptiste DaroussinTherefore let there always be non-being,
554*2fd5d190SBaptiste Daroussin  so we may see their subtlety,
555*2fd5d190SBaptiste DaroussinAnd let there always be being,
556*2fd5d190SBaptiste Daroussin  so we may see their outcome.
557*2fd5d190SBaptiste DaroussinThe two are the same,
558*2fd5d190SBaptiste DaroussinBut after they are produced,
559*2fd5d190SBaptiste Daroussin  they have different names.
560*2fd5d190SBaptiste Daroussin.Ed
561*2fd5d190SBaptiste Daroussin.Pp
562*2fd5d190SBaptiste DaroussinThis is the file
563*2fd5d190SBaptiste Daroussin.Pa tzu :
564*2fd5d190SBaptiste Daroussin.Pp
565*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
566*2fd5d190SBaptiste DaroussinThe Nameless is the origin of Heaven and Earth;
567*2fd5d190SBaptiste DaroussinThe named is the mother of all things.
568*2fd5d190SBaptiste Daroussin
569*2fd5d190SBaptiste DaroussinTherefore let there always be non-being,
570*2fd5d190SBaptiste Daroussin  so we may see their subtlety,
571*2fd5d190SBaptiste DaroussinAnd let there always be being,
572*2fd5d190SBaptiste Daroussin  so we may see their outcome.
573*2fd5d190SBaptiste DaroussinThe two are the same,
574*2fd5d190SBaptiste DaroussinBut after they are produced,
575*2fd5d190SBaptiste Daroussin  they have different names.
576*2fd5d190SBaptiste DaroussinThey both may be called deep and profound.
577*2fd5d190SBaptiste DaroussinDeeper and more profound,
578*2fd5d190SBaptiste DaroussinThe door of all subtleties!
579*2fd5d190SBaptiste Daroussin.Ed
580*2fd5d190SBaptiste Daroussin.Pp
581*2fd5d190SBaptiste DaroussinIn this example, the first hunk contains just the first two lines of
582*2fd5d190SBaptiste Daroussin.Pa lao ,
583*2fd5d190SBaptiste Daroussinthe second hunk contains the fourth line of
584*2fd5d190SBaptiste Daroussin.Pa lao
585*2fd5d190SBaptiste Daroussinopposing the second and third lines of
586*2fd5d190SBaptiste Daroussin.Pa tzu ,
587*2fd5d190SBaptiste Daroussinand the last hunk contains just the last three lines of
588*2fd5d190SBaptiste Daroussin.Pa tzu .
589*2fd5d190SBaptiste Daroussin.Pp
590*2fd5d190SBaptiste Daroussin.Ss  Showing Differences in Their Context
591*2fd5d190SBaptiste DaroussinUsually, when you are looking at the differences between files, you will also
592*2fd5d190SBaptiste Daroussinwant to see the parts of the files near the lines that differ, to help you
593*2fd5d190SBaptiste Daroussinunderstand exactly what has changed. These nearby parts of the files are called
594*2fd5d190SBaptiste Daroussinthe
595*2fd5d190SBaptiste Daroussin.Em context .
596*2fd5d190SBaptiste Daroussin.Pp
597*2fd5d190SBaptiste DaroussinGNU
598*2fd5d190SBaptiste Daroussin.Xr diff
599*2fd5d190SBaptiste Daroussinprovides two output formats that show context around the differing lines:
600*2fd5d190SBaptiste Daroussin.Em context format
601*2fd5d190SBaptiste Daroussinand
602*2fd5d190SBaptiste Daroussin.Em unified format .
603*2fd5d190SBaptiste DaroussinIt can optionally show in which function or section of the file the differing
604*2fd5d190SBaptiste Daroussinlines are found.
605*2fd5d190SBaptiste Daroussin.Pp
606*2fd5d190SBaptiste DaroussinIf you are distributing new versions of files to other people in the form
607*2fd5d190SBaptiste Daroussinof
608*2fd5d190SBaptiste Daroussin.Xr diff
609*2fd5d190SBaptiste Daroussinoutput, you should use one of the output formats that show context so that
610*2fd5d190SBaptiste Daroussinthey can apply the diffs even if they have made small changes of their own
611*2fd5d190SBaptiste Daroussinto the files.
612*2fd5d190SBaptiste Daroussin.Xr patch
613*2fd5d190SBaptiste Daroussincan apply the diffs in this case by searching in the files for the lines of
614*2fd5d190SBaptiste Daroussincontext around the differing lines; if those lines are actually a few lines
615*2fd5d190SBaptiste Daroussinaway from where the diff says they are,
616*2fd5d190SBaptiste Daroussin.Xr patch
617*2fd5d190SBaptiste Daroussincan adjust the line numbers accordingly and still apply the diff correctly.See Section
618*2fd5d190SBaptiste Daroussin.Dq Imperfect ,
619*2fd5d190SBaptiste Daroussinfor more information on using
620*2fd5d190SBaptiste Daroussin.Xr patch
621*2fd5d190SBaptiste Daroussinto apply imperfect diffs.
622*2fd5d190SBaptiste Daroussin.Pp
623*2fd5d190SBaptiste Daroussin.Em  Context Format
624*2fd5d190SBaptiste Daroussin.Pp
625*2fd5d190SBaptiste DaroussinThe context output format shows several lines of context around the lines
626*2fd5d190SBaptiste Daroussinthat differ. It is the standard format for distributing updates to source
627*2fd5d190SBaptiste Daroussincode.
628*2fd5d190SBaptiste Daroussin.Pp
629*2fd5d190SBaptiste DaroussinTo select this output format, use the
630*2fd5d190SBaptiste Daroussin.Op -C Va lines ,
631*2fd5d190SBaptiste Daroussin.Op --context[= Va lines] ,
632*2fd5d190SBaptiste Daroussinor
633*2fd5d190SBaptiste Daroussin.Op -c
634*2fd5d190SBaptiste Daroussinoption. The argument
635*2fd5d190SBaptiste Daroussin.Va lines
636*2fd5d190SBaptiste Daroussinthat some of these options take is the number of lines of context to show.
637*2fd5d190SBaptiste DaroussinIf you do not specify
638*2fd5d190SBaptiste Daroussin.Va lines ,
639*2fd5d190SBaptiste Daroussinit defaults to three. For proper operation,
640*2fd5d190SBaptiste Daroussin.Xr patch
641*2fd5d190SBaptiste Daroussintypically needs at least two lines of context.
642*2fd5d190SBaptiste Daroussin.Pp
643*2fd5d190SBaptiste Daroussin.No  An Example of Context Format
644*2fd5d190SBaptiste Daroussin.Pp
645*2fd5d190SBaptiste DaroussinHere is the output of
646*2fd5d190SBaptiste Daroussin.Li diff -c lao tzu
647*2fd5d190SBaptiste Daroussin(see Section
648*2fd5d190SBaptiste Daroussin.Dq Sample diff Input ,
649*2fd5d190SBaptiste Daroussinfor the complete contents of the two files). Notice that up to three lines
650*2fd5d190SBaptiste Daroussinthat are not different are shown around each line that is different; they
651*2fd5d190SBaptiste Daroussinare the context lines. Also notice that the first two hunks have run together,
652*2fd5d190SBaptiste Daroussinbecause their contents overlap.
653*2fd5d190SBaptiste Daroussin.Pp
654*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
655*2fd5d190SBaptiste Daroussin*** lao	2002-02-21 23:30:39.942229878 -0800
656*2fd5d190SBaptiste Daroussin--- tzu	2002-02-21 23:30:50.442260588 -0800
657*2fd5d190SBaptiste Daroussin***************
658*2fd5d190SBaptiste Daroussin*** 1,7 ****
659*2fd5d190SBaptiste Daroussin- The Way that can be told of is not the eternal Way;
660*2fd5d190SBaptiste Daroussin- The name that can be named is not the eternal name.
661*2fd5d190SBaptiste Daroussin  The Nameless is the origin of Heaven and Earth;
662*2fd5d190SBaptiste Daroussin! The Named is the mother of all things.
663*2fd5d190SBaptiste Daroussin  Therefore let there always be non-being,
664*2fd5d190SBaptiste Daroussin    so we may see their subtlety,
665*2fd5d190SBaptiste Daroussin  And let there always be being,
666*2fd5d190SBaptiste Daroussin--- 1,6 ----
667*2fd5d190SBaptiste Daroussin  The Nameless is the origin of Heaven and Earth;
668*2fd5d190SBaptiste Daroussin! The named is the mother of all things.
669*2fd5d190SBaptiste Daroussin!
670*2fd5d190SBaptiste Daroussin  Therefore let there always be non-being,
671*2fd5d190SBaptiste Daroussin    so we may see their subtlety,
672*2fd5d190SBaptiste Daroussin  And let there always be being,
673*2fd5d190SBaptiste Daroussin***************
674*2fd5d190SBaptiste Daroussin*** 9,11 ****
675*2fd5d190SBaptiste Daroussin--- 8,13 ----
676*2fd5d190SBaptiste Daroussin  The two are the same,
677*2fd5d190SBaptiste Daroussin  But after they are produced,
678*2fd5d190SBaptiste Daroussin    they have different names.
679*2fd5d190SBaptiste Daroussin+ They both may be called deep and profound.
680*2fd5d190SBaptiste Daroussin+ Deeper and more profound,
681*2fd5d190SBaptiste Daroussin+ The door of all subtleties!
682*2fd5d190SBaptiste Daroussin.Ed
683*2fd5d190SBaptiste Daroussin.Pp
684*2fd5d190SBaptiste Daroussin.No  An Example of Context Format with Less Context
685*2fd5d190SBaptiste Daroussin.Pp
686*2fd5d190SBaptiste DaroussinHere is the output of
687*2fd5d190SBaptiste Daroussin.Li diff -C 1 lao tzu
688*2fd5d190SBaptiste Daroussin(see Section
689*2fd5d190SBaptiste Daroussin.Dq Sample diff Input ,
690*2fd5d190SBaptiste Daroussinfor the complete contents of the two files). Notice that at most one context
691*2fd5d190SBaptiste Daroussinline is reported here.
692*2fd5d190SBaptiste Daroussin.Pp
693*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
694*2fd5d190SBaptiste Daroussin*** lao	2002-02-21 23:30:39.942229878 -0800
695*2fd5d190SBaptiste Daroussin--- tzu	2002-02-21 23:30:50.442260588 -0800
696*2fd5d190SBaptiste Daroussin***************
697*2fd5d190SBaptiste Daroussin*** 1,5 ****
698*2fd5d190SBaptiste Daroussin- The Way that can be told of is not the eternal Way;
699*2fd5d190SBaptiste Daroussin- The name that can be named is not the eternal name.
700*2fd5d190SBaptiste Daroussin  The Nameless is the origin of Heaven and Earth;
701*2fd5d190SBaptiste Daroussin! The Named is the mother of all things.
702*2fd5d190SBaptiste Daroussin  Therefore let there always be non-being,
703*2fd5d190SBaptiste Daroussin--- 1,4 ----
704*2fd5d190SBaptiste Daroussin  The Nameless is the origin of Heaven and Earth;
705*2fd5d190SBaptiste Daroussin! The named is the mother of all things.
706*2fd5d190SBaptiste Daroussin!
707*2fd5d190SBaptiste Daroussin  Therefore let there always be non-being,
708*2fd5d190SBaptiste Daroussin***************
709*2fd5d190SBaptiste Daroussin*** 11 ****
710*2fd5d190SBaptiste Daroussin--- 10,13 ----
711*2fd5d190SBaptiste Daroussin    they have different names.
712*2fd5d190SBaptiste Daroussin+ They both may be called deep and profound.
713*2fd5d190SBaptiste Daroussin+ Deeper and more profound,
714*2fd5d190SBaptiste Daroussin+ The door of all subtleties!
715*2fd5d190SBaptiste Daroussin.Ed
716*2fd5d190SBaptiste Daroussin.Pp
717*2fd5d190SBaptiste Daroussin.No  Detailed Description of Context Format
718*2fd5d190SBaptiste Daroussin.Pp
719*2fd5d190SBaptiste DaroussinThe context output format starts with a two-line header, which looks like
720*2fd5d190SBaptiste Daroussinthis:
721*2fd5d190SBaptiste Daroussin.Pp
722*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
723*2fd5d190SBaptiste Daroussin*** from-file from-file-modification-time
724*2fd5d190SBaptiste Daroussin--- to-file to-file-modification time
725*2fd5d190SBaptiste Daroussin.Ed
726*2fd5d190SBaptiste Daroussin.Pp
727*2fd5d190SBaptiste DaroussinThe time stamp normally looks like
728*2fd5d190SBaptiste Daroussin.Li 2002-02-21 23:30:39.942229878 -0800
729*2fd5d190SBaptiste Daroussinto indicate the date, time with fractional seconds, and time zone in
730*2fd5d190SBaptiste Daroussin.Lk ftp://ftp.isi.edu/in-notes/rfc2822.txt .
731*2fd5d190SBaptiste Daroussin(The fractional seconds are omitted on hosts that do not support fractional
732*2fd5d190SBaptiste Daroussintime stamps.) However, a traditional time stamp like
733*2fd5d190SBaptiste Daroussin.Li Thu Feb 21 23:30:39 2002
734*2fd5d190SBaptiste Daroussinis used if the
735*2fd5d190SBaptiste Daroussin.Ev LC_TIME
736*2fd5d190SBaptiste Daroussinlocale category is either
737*2fd5d190SBaptiste Daroussin.Li C
738*2fd5d190SBaptiste Daroussinor
739*2fd5d190SBaptiste Daroussin.Li POSIX .
740*2fd5d190SBaptiste Daroussin.Pp
741*2fd5d190SBaptiste DaroussinYou can change the header's content with the
742*2fd5d190SBaptiste Daroussin.Op --label= Va label
743*2fd5d190SBaptiste Daroussinoption; see Alternate Names.
744*2fd5d190SBaptiste Daroussin.Pp
745*2fd5d190SBaptiste DaroussinNext come one or more hunks of differences; each hunk shows one area where
746*2fd5d190SBaptiste Daroussinthe files differ. Context format hunks look like this:
747*2fd5d190SBaptiste Daroussin.Pp
748*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
749*2fd5d190SBaptiste Daroussin***************
750*2fd5d190SBaptiste Daroussin*** from-file-line-numbers ****
751*2fd5d190SBaptiste Daroussin  from-file-line
752*2fd5d190SBaptiste Daroussin  from-file-line...
753*2fd5d190SBaptiste Daroussin--- to-file-line-numbers ----
754*2fd5d190SBaptiste Daroussin  to-file-line
755*2fd5d190SBaptiste Daroussin  to-file-line...
756*2fd5d190SBaptiste Daroussin.Ed
757*2fd5d190SBaptiste Daroussin.Pp
758*2fd5d190SBaptiste DaroussinIf a hunk contains two or more lines, its line numbers look like
759*2fd5d190SBaptiste Daroussin.Li  Va start, Va end .
760*2fd5d190SBaptiste DaroussinOtherwise only its end line number appears. An empty hunk is considered to
761*2fd5d190SBaptiste Daroussinend at the line that precedes the hunk.
762*2fd5d190SBaptiste Daroussin.Pp
763*2fd5d190SBaptiste DaroussinThe lines of context around the lines that differ start with two space characters.
764*2fd5d190SBaptiste DaroussinThe lines that differ between the two files start with one of the following
765*2fd5d190SBaptiste Daroussinindicator characters, followed by a space character:
766*2fd5d190SBaptiste Daroussin.Pp
767*2fd5d190SBaptiste Daroussin.Bl -tag -width Ds
768*2fd5d190SBaptiste Daroussin.It  !
769*2fd5d190SBaptiste DaroussinA line that is part of a group of one or more lines that changed between the
770*2fd5d190SBaptiste Daroussintwo files. There is a corresponding group of lines marked with
771*2fd5d190SBaptiste Daroussin.Li !
772*2fd5d190SBaptiste Daroussinin the part of this hunk for the other file.
773*2fd5d190SBaptiste Daroussin.Pp
774*2fd5d190SBaptiste Daroussin.It  +
775*2fd5d190SBaptiste DaroussinAn \(lqinserted\(rq line in the second file that corresponds to nothing in the first
776*2fd5d190SBaptiste Daroussinfile.
777*2fd5d190SBaptiste Daroussin.Pp
778*2fd5d190SBaptiste Daroussin.It  -
779*2fd5d190SBaptiste DaroussinA \(lqdeleted\(rq line in the first file that corresponds to nothing in the second
780*2fd5d190SBaptiste Daroussinfile.
781*2fd5d190SBaptiste Daroussin.El
782*2fd5d190SBaptiste Daroussin.Pp
783*2fd5d190SBaptiste DaroussinIf all of the changes in a hunk are insertions, the lines of
784*2fd5d190SBaptiste Daroussin.Va from-file
785*2fd5d190SBaptiste Daroussinare omitted. If all of the changes are deletions, the lines of
786*2fd5d190SBaptiste Daroussin.Va to-file
787*2fd5d190SBaptiste Daroussinare omitted.
788*2fd5d190SBaptiste Daroussin.Pp
789*2fd5d190SBaptiste Daroussin.Em  Unified Format
790*2fd5d190SBaptiste Daroussin.Pp
791*2fd5d190SBaptiste DaroussinThe unified output format is a variation on the context format that is more
792*2fd5d190SBaptiste Daroussincompact because it omits redundant context lines. To select this output format,
793*2fd5d190SBaptiste Daroussinuse the
794*2fd5d190SBaptiste Daroussin.Op -U Va lines ,
795*2fd5d190SBaptiste Daroussin.Op --unified[= Va lines] ,
796*2fd5d190SBaptiste Daroussinor
797*2fd5d190SBaptiste Daroussin.Op -u
798*2fd5d190SBaptiste Daroussinoption. The argument
799*2fd5d190SBaptiste Daroussin.Va lines
800*2fd5d190SBaptiste Daroussinis the number of lines of context to show. When it is not given, it defaults
801*2fd5d190SBaptiste Daroussinto three.
802*2fd5d190SBaptiste Daroussin.Pp
803*2fd5d190SBaptiste DaroussinAt present, only GNU
804*2fd5d190SBaptiste Daroussin.Xr diff
805*2fd5d190SBaptiste Daroussincan produce this format and only GNU
806*2fd5d190SBaptiste Daroussin.Xr patch
807*2fd5d190SBaptiste Daroussincan automatically apply diffs in this format. For proper operation,
808*2fd5d190SBaptiste Daroussin.Xr patch
809*2fd5d190SBaptiste Daroussintypically needs at least three lines of context.
810*2fd5d190SBaptiste Daroussin.Pp
811*2fd5d190SBaptiste Daroussin.No  An Example of Unified Format
812*2fd5d190SBaptiste Daroussin.Pp
813*2fd5d190SBaptiste DaroussinHere is the output of the command
814*2fd5d190SBaptiste Daroussin.Li diff -u lao tzu
815*2fd5d190SBaptiste Daroussin(see Section
816*2fd5d190SBaptiste Daroussin.Dq Sample diff Input ,
817*2fd5d190SBaptiste Daroussinfor the complete contents of the two files):
818*2fd5d190SBaptiste Daroussin.Pp
819*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
820*2fd5d190SBaptiste Daroussin--- lao	2002-02-21 23:30:39.942229878 -0800
821*2fd5d190SBaptiste Daroussin+++ tzu	2002-02-21 23:30:50.442260588 -0800
822*2fd5d190SBaptiste Daroussin@@ -1,7 +1,6 @@
823*2fd5d190SBaptiste Daroussin-The Way that can be told of is not the eternal Way;
824*2fd5d190SBaptiste Daroussin-The name that can be named is not the eternal name.
825*2fd5d190SBaptiste Daroussin The Nameless is the origin of Heaven and Earth;
826*2fd5d190SBaptiste Daroussin-The Named is the mother of all things.
827*2fd5d190SBaptiste Daroussin+The named is the mother of all things.
828*2fd5d190SBaptiste Daroussin+
829*2fd5d190SBaptiste Daroussin Therefore let there always be non-being,
830*2fd5d190SBaptiste Daroussin   so we may see their subtlety,
831*2fd5d190SBaptiste Daroussin And let there always be being,
832*2fd5d190SBaptiste Daroussin@@ -9,3 +8,6 @@
833*2fd5d190SBaptiste Daroussin The two are the same,
834*2fd5d190SBaptiste Daroussin But after they are produced,
835*2fd5d190SBaptiste Daroussin   they have different names.
836*2fd5d190SBaptiste Daroussin+They both may be called deep and profound.
837*2fd5d190SBaptiste Daroussin+Deeper and more profound,
838*2fd5d190SBaptiste Daroussin+The door of all subtleties!
839*2fd5d190SBaptiste Daroussin.Ed
840*2fd5d190SBaptiste Daroussin.Pp
841*2fd5d190SBaptiste Daroussin.No  Detailed Description of Unified Format
842*2fd5d190SBaptiste Daroussin.Pp
843*2fd5d190SBaptiste DaroussinThe unified output format starts with a two-line header, which looks like
844*2fd5d190SBaptiste Daroussinthis:
845*2fd5d190SBaptiste Daroussin.Pp
846*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
847*2fd5d190SBaptiste Daroussin--- from-file from-file-modification-time
848*2fd5d190SBaptiste Daroussin+++ to-file to-file-modification-time
849*2fd5d190SBaptiste Daroussin.Ed
850*2fd5d190SBaptiste Daroussin.Pp
851*2fd5d190SBaptiste DaroussinThe time stamp looks like
852*2fd5d190SBaptiste Daroussin.Li 2002-02-21 23:30:39.942229878 -0800
853*2fd5d190SBaptiste Daroussinto indicate the date, time with fractional seconds, and time zone. The fractional
854*2fd5d190SBaptiste Daroussinseconds are omitted on hosts that do not support fractional time stamps.
855*2fd5d190SBaptiste Daroussin.Pp
856*2fd5d190SBaptiste DaroussinYou can change the header's content with the
857*2fd5d190SBaptiste Daroussin.Op --label= Va label
858*2fd5d190SBaptiste Daroussinoption; seeSee Section
859*2fd5d190SBaptiste Daroussin.Dq Alternate Names .
860*2fd5d190SBaptiste Daroussin.Pp
861*2fd5d190SBaptiste DaroussinNext come one or more hunks of differences; each hunk shows one area where
862*2fd5d190SBaptiste Daroussinthe files differ. Unified format hunks look like this:
863*2fd5d190SBaptiste Daroussin.Pp
864*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
865*2fd5d190SBaptiste Daroussin@@ from-file-line-numbers to-file-line-numbers @@
866*2fd5d190SBaptiste Daroussin line-from-either-file
867*2fd5d190SBaptiste Daroussin line-from-either-file...
868*2fd5d190SBaptiste Daroussin.Ed
869*2fd5d190SBaptiste Daroussin.Pp
870*2fd5d190SBaptiste DaroussinIf a hunk contains just one line, only its start line number appears. Otherwise
871*2fd5d190SBaptiste Daroussinits line numbers look like
872*2fd5d190SBaptiste Daroussin.Li  Va start, Va count .
873*2fd5d190SBaptiste DaroussinAn empty hunk is considered to start at the line that follows the hunk.
874*2fd5d190SBaptiste Daroussin.Pp
875*2fd5d190SBaptiste DaroussinIf a hunk and its context contain two or more lines, its line numbers look
876*2fd5d190SBaptiste Daroussinlike
877*2fd5d190SBaptiste Daroussin.Li  Va start, Va count .
878*2fd5d190SBaptiste DaroussinOtherwise only its end line number appears. An empty hunk is considered to
879*2fd5d190SBaptiste Daroussinend at the line that precedes the hunk.
880*2fd5d190SBaptiste Daroussin.Pp
881*2fd5d190SBaptiste DaroussinThe lines common to both files begin with a space character. The lines that
882*2fd5d190SBaptiste Daroussinactually differ between the two files have one of the following indicator
883*2fd5d190SBaptiste Daroussincharacters in the left print column:
884*2fd5d190SBaptiste Daroussin.Pp
885*2fd5d190SBaptiste Daroussin.Bl -tag -width Ds
886*2fd5d190SBaptiste Daroussin.It  +
887*2fd5d190SBaptiste DaroussinA line was added here to the first file.
888*2fd5d190SBaptiste Daroussin.Pp
889*2fd5d190SBaptiste Daroussin.It  -
890*2fd5d190SBaptiste DaroussinA line was removed here from the first file.
891*2fd5d190SBaptiste Daroussin.El
892*2fd5d190SBaptiste Daroussin.Pp
893*2fd5d190SBaptiste Daroussin.Em  Showing Which Sections Differences Are in
894*2fd5d190SBaptiste Daroussin.Pp
895*2fd5d190SBaptiste DaroussinSometimes you might want to know which part of the files each change falls
896*2fd5d190SBaptiste Daroussinin. If the files are source code, this could mean which function was changed.
897*2fd5d190SBaptiste DaroussinIf the files are documents, it could mean which chapter or appendix was changed.
898*2fd5d190SBaptiste DaroussinGNU
899*2fd5d190SBaptiste Daroussin.Xr diff
900*2fd5d190SBaptiste Daroussincan show this by displaying the nearest section heading line that precedes
901*2fd5d190SBaptiste Daroussinthe differing lines. Which lines are \(lqsection headings\(rq is determined by a regular
902*2fd5d190SBaptiste Daroussinexpression.
903*2fd5d190SBaptiste Daroussin.Pp
904*2fd5d190SBaptiste Daroussin.No  Showing Lines That Match Regular Expressions
905*2fd5d190SBaptiste Daroussin.Pp
906*2fd5d190SBaptiste DaroussinTo show in which sections differences occur for files that are not source
907*2fd5d190SBaptiste Daroussincode for C or similar languages, use the
908*2fd5d190SBaptiste Daroussin.Op -F Va regexp
909*2fd5d190SBaptiste Daroussinor
910*2fd5d190SBaptiste Daroussin.Op --show-function-line= Va regexp
911*2fd5d190SBaptiste Daroussinoption.
912*2fd5d190SBaptiste Daroussin.Xr diff
913*2fd5d190SBaptiste Daroussinconsiders lines that match the
914*2fd5d190SBaptiste Daroussin.Xr grep
915*2fd5d190SBaptiste Daroussin-style regular expression
916*2fd5d190SBaptiste Daroussin.Va regexp
917*2fd5d190SBaptiste Daroussinto be the beginning of a section of the file. Here are suggested regular expressions
918*2fd5d190SBaptiste Daroussinfor some common languages:
919*2fd5d190SBaptiste Daroussin.Pp
920*2fd5d190SBaptiste Daroussin.Bl -tag -width Ds
921*2fd5d190SBaptiste Daroussin.It  ^[[:alpha:]$_]
922*2fd5d190SBaptiste DaroussinC, C++, Prolog
923*2fd5d190SBaptiste Daroussin.It  ^(
924*2fd5d190SBaptiste DaroussinLisp
925*2fd5d190SBaptiste Daroussin.It  ^@node
926*2fd5d190SBaptiste DaroussinTexinfo
927*2fd5d190SBaptiste Daroussin.El
928*2fd5d190SBaptiste Daroussin.Pp
929*2fd5d190SBaptiste DaroussinThis option does not automatically select an output format; in order to use
930*2fd5d190SBaptiste Daroussinit, you must select the context format (see Section
931*2fd5d190SBaptiste Daroussin.Dq Context Format )
932*2fd5d190SBaptiste Daroussinor unified format (see Section
933*2fd5d190SBaptiste Daroussin.Dq Unified Format ) .
934*2fd5d190SBaptiste DaroussinIn other output formats it has no effect.
935*2fd5d190SBaptiste Daroussin.Pp
936*2fd5d190SBaptiste DaroussinThe
937*2fd5d190SBaptiste Daroussin.Op -F
938*2fd5d190SBaptiste Daroussinor
939*2fd5d190SBaptiste Daroussin.Op --show-function-line
940*2fd5d190SBaptiste Daroussinoption finds the nearest unchanged line that precedes each hunk of differences
941*2fd5d190SBaptiste Daroussinand matches the given regular expression. Then it adds that line to the end
942*2fd5d190SBaptiste Daroussinof the line of asterisks in the context format, or to the
943*2fd5d190SBaptiste Daroussin.Li @@
944*2fd5d190SBaptiste Daroussinline in unified format. If no matching line exists, this option leaves the
945*2fd5d190SBaptiste Daroussinoutput for that hunk unchanged. If that line is more than 40 characters long,
946*2fd5d190SBaptiste Daroussinit outputs only the first 40 characters. You can specify more than one regular
947*2fd5d190SBaptiste Daroussinexpression for such lines;
948*2fd5d190SBaptiste Daroussin.Xr diff
949*2fd5d190SBaptiste Daroussintries to match each line against each regular expression, starting with the
950*2fd5d190SBaptiste Daroussinlast one given. This means that you can use
951*2fd5d190SBaptiste Daroussin.Op -p
952*2fd5d190SBaptiste Daroussinand
953*2fd5d190SBaptiste Daroussin.Op -F
954*2fd5d190SBaptiste Daroussintogether, if you wish.
955*2fd5d190SBaptiste Daroussin.Pp
956*2fd5d190SBaptiste Daroussin.No  Showing C Function Headings
957*2fd5d190SBaptiste Daroussin.Pp
958*2fd5d190SBaptiste DaroussinTo show in which functions differences occur for C and similar languages,
959*2fd5d190SBaptiste Daroussinyou can use the
960*2fd5d190SBaptiste Daroussin.Op -p
961*2fd5d190SBaptiste Daroussinor
962*2fd5d190SBaptiste Daroussin.Op --show-c-function
963*2fd5d190SBaptiste Daroussinoption. This option automatically defaults to the context output format (see Section
964*2fd5d190SBaptiste Daroussin.Dq Context Format ) ,
965*2fd5d190SBaptiste Daroussinwith the default number of lines of context. You can override that number
966*2fd5d190SBaptiste Daroussinwith
967*2fd5d190SBaptiste Daroussin.Op -C Va lines
968*2fd5d190SBaptiste Daroussinelsewhere in the command line. You can override both the format and the number
969*2fd5d190SBaptiste Daroussinwith
970*2fd5d190SBaptiste Daroussin.Op -U Va lines
971*2fd5d190SBaptiste Daroussinelsewhere in the command line.
972*2fd5d190SBaptiste Daroussin.Pp
973*2fd5d190SBaptiste DaroussinThe
974*2fd5d190SBaptiste Daroussin.Op -p
975*2fd5d190SBaptiste Daroussinor
976*2fd5d190SBaptiste Daroussin.Op --show-c-function
977*2fd5d190SBaptiste Daroussinoption is equivalent to
978*2fd5d190SBaptiste Daroussin.Op -F '^[[:alpha:]$_]'
979*2fd5d190SBaptiste Daroussinif the unified format is specified, otherwise
980*2fd5d190SBaptiste Daroussin.Op -c -F '^[[:alpha:]$_]'
981*2fd5d190SBaptiste Daroussin(see Section
982*2fd5d190SBaptiste Daroussin.Dq Specified Headings ) .
983*2fd5d190SBaptiste DaroussinGNU
984*2fd5d190SBaptiste Daroussin.Xr diff
985*2fd5d190SBaptiste Daroussinprovides this option for the sake of convenience.
986*2fd5d190SBaptiste Daroussin.Pp
987*2fd5d190SBaptiste Daroussin.Em  Showing Alternate File Names
988*2fd5d190SBaptiste Daroussin.Pp
989*2fd5d190SBaptiste DaroussinIf you are comparing two files that have meaningless or uninformative names,
990*2fd5d190SBaptiste Daroussinyou might want
991*2fd5d190SBaptiste Daroussin.Xr diff
992*2fd5d190SBaptiste Daroussinto show alternate names in the header of the context and unified output formats.
993*2fd5d190SBaptiste DaroussinTo do this, use the
994*2fd5d190SBaptiste Daroussin.Op --label= Va label
995*2fd5d190SBaptiste Daroussinoption. The first time you give this option, its argument replaces the name
996*2fd5d190SBaptiste Daroussinand date of the first file in the header; the second time, its argument replaces
997*2fd5d190SBaptiste Daroussinthe name and date of the second file. If you give this option more than twice,
998*2fd5d190SBaptiste Daroussin.Xr diff
999*2fd5d190SBaptiste Daroussinreports an error. The
1000*2fd5d190SBaptiste Daroussin.Op --label
1001*2fd5d190SBaptiste Daroussinoption does not affect the file names in the
1002*2fd5d190SBaptiste Daroussin.Xr pr
1003*2fd5d190SBaptiste Daroussinheader when the
1004*2fd5d190SBaptiste Daroussin.Op -l
1005*2fd5d190SBaptiste Daroussinor
1006*2fd5d190SBaptiste Daroussin.Op --paginate
1007*2fd5d190SBaptiste Daroussinoption is used (see Section
1008*2fd5d190SBaptiste Daroussin.Dq Pagination ) .
1009*2fd5d190SBaptiste Daroussin.Pp
1010*2fd5d190SBaptiste DaroussinHere are the first two lines of the output from
1011*2fd5d190SBaptiste Daroussin.Li diff -C 2 --label=original --label=modified lao tzu :
1012*2fd5d190SBaptiste Daroussin.Pp
1013*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
1014*2fd5d190SBaptiste Daroussin*** original
1015*2fd5d190SBaptiste Daroussin--- modified
1016*2fd5d190SBaptiste Daroussin.Ed
1017*2fd5d190SBaptiste Daroussin.Pp
1018*2fd5d190SBaptiste Daroussin.Ss  Showing Differences Side by Side
1019*2fd5d190SBaptiste Daroussin.Xr diff
1020*2fd5d190SBaptiste Daroussincan produce a side by side difference listing of two files. The files are
1021*2fd5d190SBaptiste Daroussinlisted in two columns with a gutter between them. The gutter contains one
1022*2fd5d190SBaptiste Daroussinof the following markers:
1023*2fd5d190SBaptiste Daroussin.Pp
1024*2fd5d190SBaptiste Daroussin.Bl -tag -width Ds
1025*2fd5d190SBaptiste Daroussin.It  white space
1026*2fd5d190SBaptiste DaroussinThe corresponding lines are in common. That is, either the lines are identical,
1027*2fd5d190SBaptiste Daroussinor the difference is ignored because of one of the
1028*2fd5d190SBaptiste Daroussin.Op --ignore
1029*2fd5d190SBaptiste Daroussinoptions (see Section
1030*2fd5d190SBaptiste Daroussin.Dq White Space ) .
1031*2fd5d190SBaptiste Daroussin.Pp
1032*2fd5d190SBaptiste Daroussin.It  Li |
1033*2fd5d190SBaptiste DaroussinThe corresponding lines differ, and they are either both complete or both
1034*2fd5d190SBaptiste Daroussinincomplete.
1035*2fd5d190SBaptiste Daroussin.Pp
1036*2fd5d190SBaptiste Daroussin.It  Li <
1037*2fd5d190SBaptiste DaroussinThe files differ and only the first file contains the line.
1038*2fd5d190SBaptiste Daroussin.Pp
1039*2fd5d190SBaptiste Daroussin.It  Li >
1040*2fd5d190SBaptiste DaroussinThe files differ and only the second file contains the line.
1041*2fd5d190SBaptiste Daroussin.Pp
1042*2fd5d190SBaptiste Daroussin.It  Li (
1043*2fd5d190SBaptiste DaroussinOnly the first file contains the line, but the difference is ignored.
1044*2fd5d190SBaptiste Daroussin.Pp
1045*2fd5d190SBaptiste Daroussin.It  Li )
1046*2fd5d190SBaptiste DaroussinOnly the second file contains the line, but the difference is ignored.
1047*2fd5d190SBaptiste Daroussin.Pp
1048*2fd5d190SBaptiste Daroussin.It  Li \e
1049*2fd5d190SBaptiste DaroussinThe corresponding lines differ, and only the first line is incomplete.
1050*2fd5d190SBaptiste Daroussin.Pp
1051*2fd5d190SBaptiste Daroussin.It  Li /
1052*2fd5d190SBaptiste DaroussinThe corresponding lines differ, and only the second line is incomplete.
1053*2fd5d190SBaptiste Daroussin.El
1054*2fd5d190SBaptiste Daroussin.Pp
1055*2fd5d190SBaptiste DaroussinNormally, an output line is incomplete if and only if the lines that it contains
1056*2fd5d190SBaptiste Daroussinare incomplete;See Section
1057*2fd5d190SBaptiste Daroussin.Dq Incomplete Lines .
1058*2fd5d190SBaptiste DaroussinHowever, when an output line represents two differing lines, one might be
1059*2fd5d190SBaptiste Daroussinincomplete while the other is not. In this case, the output line is complete,
1060*2fd5d190SBaptiste Daroussinbut its the gutter is marked
1061*2fd5d190SBaptiste Daroussin.Li \e
1062*2fd5d190SBaptiste Daroussinif the first line is incomplete,
1063*2fd5d190SBaptiste Daroussin.Li /
1064*2fd5d190SBaptiste Daroussinif the second line is.
1065*2fd5d190SBaptiste Daroussin.Pp
1066*2fd5d190SBaptiste DaroussinSide by side format is sometimes easiest to read, but it has limitations.
1067*2fd5d190SBaptiste DaroussinIt generates much wider output than usual, and truncates lines that are too
1068*2fd5d190SBaptiste Daroussinlong to fit. Also, it relies on lining up output more heavily than usual,
1069*2fd5d190SBaptiste Daroussinso its output looks particularly bad if you use varying width fonts, nonstandard
1070*2fd5d190SBaptiste Daroussintab stops, or nonprinting characters.
1071*2fd5d190SBaptiste Daroussin.Pp
1072*2fd5d190SBaptiste DaroussinYou can use the
1073*2fd5d190SBaptiste Daroussin.Xr sdiff
1074*2fd5d190SBaptiste Daroussincommand to interactively merge side by side differences.See Section
1075*2fd5d190SBaptiste Daroussin.Dq Interactive Merging ,
1076*2fd5d190SBaptiste Daroussinfor more information on merging files.
1077*2fd5d190SBaptiste Daroussin.Pp
1078*2fd5d190SBaptiste Daroussin.Em  Controlling Side by Side Format
1079*2fd5d190SBaptiste Daroussin.Pp
1080*2fd5d190SBaptiste DaroussinThe
1081*2fd5d190SBaptiste Daroussin.Op -y
1082*2fd5d190SBaptiste Daroussinor
1083*2fd5d190SBaptiste Daroussin.Op --side-by-side
1084*2fd5d190SBaptiste Daroussinoption selects side by side format. Because side by side output lines contain
1085*2fd5d190SBaptiste Daroussintwo input lines, the output is wider than usual: normally 130 print columns,
1086*2fd5d190SBaptiste Daroussinwhich can fit onto a traditional printer line. You can set the width of the
1087*2fd5d190SBaptiste Daroussinoutput with the
1088*2fd5d190SBaptiste Daroussin.Op -W Va columns
1089*2fd5d190SBaptiste Daroussinor
1090*2fd5d190SBaptiste Daroussin.Op --width= Va columns
1091*2fd5d190SBaptiste Daroussinoption. The output is split into two halves of equal width, separated by a
1092*2fd5d190SBaptiste Daroussinsmall gutter to mark differences; the right half is aligned to a tab stop
1093*2fd5d190SBaptiste Daroussinso that tabs line up. Input lines that are too long to fit in half of an output
1094*2fd5d190SBaptiste Daroussinline are truncated for output.
1095*2fd5d190SBaptiste Daroussin.Pp
1096*2fd5d190SBaptiste DaroussinThe
1097*2fd5d190SBaptiste Daroussin.Op --left-column
1098*2fd5d190SBaptiste Daroussinoption prints only the left column of two common lines. The
1099*2fd5d190SBaptiste Daroussin.Op --suppress-common-lines
1100*2fd5d190SBaptiste Daroussinoption suppresses common lines entirely.
1101*2fd5d190SBaptiste Daroussin.Pp
1102*2fd5d190SBaptiste Daroussin.Em  An Example of Side by Side Format
1103*2fd5d190SBaptiste Daroussin.Pp
1104*2fd5d190SBaptiste DaroussinHere is the output of the command
1105*2fd5d190SBaptiste Daroussin.Li diff -y -W 72 lao tzu
1106*2fd5d190SBaptiste Daroussin(see Section
1107*2fd5d190SBaptiste Daroussin.Dq Sample diff Input ,
1108*2fd5d190SBaptiste Daroussinfor the complete contents of the two files).
1109*2fd5d190SBaptiste Daroussin.Pp
1110*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
1111*2fd5d190SBaptiste DaroussinThe Way that can be told of is n   <
1112*2fd5d190SBaptiste DaroussinThe name that can be named is no   <
1113*2fd5d190SBaptiste DaroussinThe Nameless is the origin of He        The Nameless is the origin of He
1114*2fd5d190SBaptiste DaroussinThe Named is the mother of all t   |    The named is the mother of all t
1115*2fd5d190SBaptiste Daroussin                                   >
1116*2fd5d190SBaptiste DaroussinTherefore let there always be no        Therefore let there always be no
1117*2fd5d190SBaptiste Daroussin  so we may see their subtlety,           so we may see their subtlety,
1118*2fd5d190SBaptiste DaroussinAnd let there always be being,          And let there always be being,
1119*2fd5d190SBaptiste Daroussin  so we may see their outcome.            so we may see their outcome.
1120*2fd5d190SBaptiste DaroussinThe two are the same,                   The two are the same,
1121*2fd5d190SBaptiste DaroussinBut after they are produced,            But after they are produced,
1122*2fd5d190SBaptiste Daroussin  they have different names.              they have different names.
1123*2fd5d190SBaptiste Daroussin                                   >    They both may be called deep and
1124*2fd5d190SBaptiste Daroussin                                   >    Deeper and more profound,
1125*2fd5d190SBaptiste Daroussin                                   >    The door of all subtleties!
1126*2fd5d190SBaptiste Daroussin.Ed
1127*2fd5d190SBaptiste Daroussin.Pp
1128*2fd5d190SBaptiste Daroussin.Ss  Showing Differences Without Context
1129*2fd5d190SBaptiste DaroussinThe \(lqnormal\(rq
1130*2fd5d190SBaptiste Daroussin.Xr diff
1131*2fd5d190SBaptiste Daroussinoutput format shows each hunk of differences without any surrounding context.
1132*2fd5d190SBaptiste DaroussinSometimes such output is the clearest way to see how lines have changed, without
1133*2fd5d190SBaptiste Daroussinthe clutter of nearby unchanged lines (although you can get similar results
1134*2fd5d190SBaptiste Daroussinwith the context or unified formats by using 0 lines of context). However,
1135*2fd5d190SBaptiste Daroussinthis format is no longer widely used for sending out patches; for that purpose,
1136*2fd5d190SBaptiste Daroussinthe context format (see Section
1137*2fd5d190SBaptiste Daroussin.Dq Context Format )
1138*2fd5d190SBaptiste Daroussinand the unified format (see Section
1139*2fd5d190SBaptiste Daroussin.Dq Unified Format )
1140*2fd5d190SBaptiste Daroussinare superior. Normal format is the default for compatibility with older versions
1141*2fd5d190SBaptiste Daroussinof
1142*2fd5d190SBaptiste Daroussin.Xr diff
1143*2fd5d190SBaptiste Daroussinand the POSIX standard. Use the
1144*2fd5d190SBaptiste Daroussin.Op --normal
1145*2fd5d190SBaptiste Daroussinoption to select this output format explicitly.
1146*2fd5d190SBaptiste Daroussin.Pp
1147*2fd5d190SBaptiste Daroussin.Em  An Example of Normal Format
1148*2fd5d190SBaptiste Daroussin.Pp
1149*2fd5d190SBaptiste DaroussinHere is the output of the command
1150*2fd5d190SBaptiste Daroussin.Li diff lao tzu
1151*2fd5d190SBaptiste Daroussin(see Section
1152*2fd5d190SBaptiste Daroussin.Dq Sample diff Input ,
1153*2fd5d190SBaptiste Daroussinfor the complete contents of the two files). Notice that it shows only the
1154*2fd5d190SBaptiste Daroussinlines that are different between the two files.
1155*2fd5d190SBaptiste Daroussin.Pp
1156*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
1157*2fd5d190SBaptiste Daroussin1,2d0
1158*2fd5d190SBaptiste Daroussin< The Way that can be told of is not the eternal Way;
1159*2fd5d190SBaptiste Daroussin< The name that can be named is not the eternal name.
1160*2fd5d190SBaptiste Daroussin4c2,3
1161*2fd5d190SBaptiste Daroussin< The Named is the mother of all things.
1162*2fd5d190SBaptiste Daroussin---
1163*2fd5d190SBaptiste Daroussin> The named is the mother of all things.
1164*2fd5d190SBaptiste Daroussin>
1165*2fd5d190SBaptiste Daroussin11a11,13
1166*2fd5d190SBaptiste Daroussin> They both may be called deep and profound.
1167*2fd5d190SBaptiste Daroussin> Deeper and more profound,
1168*2fd5d190SBaptiste Daroussin> The door of all subtleties!
1169*2fd5d190SBaptiste Daroussin.Ed
1170*2fd5d190SBaptiste Daroussin.Pp
1171*2fd5d190SBaptiste Daroussin.Em  Detailed Description of Normal Format
1172*2fd5d190SBaptiste Daroussin.Pp
1173*2fd5d190SBaptiste DaroussinThe normal output format consists of one or more hunks of differences; each
1174*2fd5d190SBaptiste Daroussinhunk shows one area where the files differ. Normal format hunks look like
1175*2fd5d190SBaptiste Daroussinthis:
1176*2fd5d190SBaptiste Daroussin.Pp
1177*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
1178*2fd5d190SBaptiste Daroussinchange-command
1179*2fd5d190SBaptiste Daroussin< from-file-line
1180*2fd5d190SBaptiste Daroussin< from-file-line...
1181*2fd5d190SBaptiste Daroussin---
1182*2fd5d190SBaptiste Daroussin> to-file-line
1183*2fd5d190SBaptiste Daroussin> to-file-line...
1184*2fd5d190SBaptiste Daroussin.Ed
1185*2fd5d190SBaptiste Daroussin.Pp
1186*2fd5d190SBaptiste DaroussinThere are three types of change commands. Each consists of a line number or
1187*2fd5d190SBaptiste Daroussincomma-separated range of lines in the first file, a single character indicating
1188*2fd5d190SBaptiste Daroussinthe kind of change to make, and a line number or comma-separated range of
1189*2fd5d190SBaptiste Daroussinlines in the second file. All line numbers are the original line numbers in
1190*2fd5d190SBaptiste Daroussineach file. The types of change commands are:
1191*2fd5d190SBaptiste Daroussin.Pp
1192*2fd5d190SBaptiste Daroussin.Bl -tag -width Ds
1193*2fd5d190SBaptiste Daroussin.It  Va la Va r
1194*2fd5d190SBaptiste DaroussinAdd the lines in range
1195*2fd5d190SBaptiste Daroussin.Va r
1196*2fd5d190SBaptiste Daroussinof the second file after line
1197*2fd5d190SBaptiste Daroussin.Va l
1198*2fd5d190SBaptiste Daroussinof the first file. For example,
1199*2fd5d190SBaptiste Daroussin.Li 8a12,15
1200*2fd5d190SBaptiste Daroussinmeans append lines 12--15 of file 2 after line 8 of file 1; or, if changing
1201*2fd5d190SBaptiste Daroussinfile 2 into file 1, delete lines 12--15 of file 2.
1202*2fd5d190SBaptiste Daroussin.Pp
1203*2fd5d190SBaptiste Daroussin.It  Va fc Va t
1204*2fd5d190SBaptiste DaroussinReplace the lines in range
1205*2fd5d190SBaptiste Daroussin.Va f
1206*2fd5d190SBaptiste Daroussinof the first file with lines in range
1207*2fd5d190SBaptiste Daroussin.Va t
1208*2fd5d190SBaptiste Daroussinof the second file. This is like a combined add and delete, but more compact.
1209*2fd5d190SBaptiste DaroussinFor example,
1210*2fd5d190SBaptiste Daroussin.Li 5,7c8,10
1211*2fd5d190SBaptiste Daroussinmeans change lines 5--7 of file 1 to read as lines 8--10 of file 2; or, if
1212*2fd5d190SBaptiste Daroussinchanging file 2 into file 1, change lines 8--10 of file 2 to read as lines
1213*2fd5d190SBaptiste Daroussin5--7 of file 1.
1214*2fd5d190SBaptiste Daroussin.Pp
1215*2fd5d190SBaptiste Daroussin.It  Va rd Va l
1216*2fd5d190SBaptiste DaroussinDelete the lines in range
1217*2fd5d190SBaptiste Daroussin.Va r
1218*2fd5d190SBaptiste Daroussinfrom the first file; line
1219*2fd5d190SBaptiste Daroussin.Va l
1220*2fd5d190SBaptiste Daroussinis where they would have appeared in the second file had they not been deleted.
1221*2fd5d190SBaptiste DaroussinFor example,
1222*2fd5d190SBaptiste Daroussin.Li 5,7d3
1223*2fd5d190SBaptiste Daroussinmeans delete lines 5--7 of file 1; or, if changing file 2 into file 1, append
1224*2fd5d190SBaptiste Daroussinlines 5--7 of file 1 after line 3 of file 2.
1225*2fd5d190SBaptiste Daroussin.El
1226*2fd5d190SBaptiste Daroussin.Pp
1227*2fd5d190SBaptiste Daroussin.Ss  Making Edit Scripts
1228*2fd5d190SBaptiste DaroussinSeveral output modes produce command scripts for editing
1229*2fd5d190SBaptiste Daroussin.Va from-file
1230*2fd5d190SBaptiste Daroussinto produce
1231*2fd5d190SBaptiste Daroussin.Va to-file .
1232*2fd5d190SBaptiste Daroussin.Pp
1233*2fd5d190SBaptiste Daroussin.Em  Xr ed Scripts
1234*2fd5d190SBaptiste Daroussin.Pp
1235*2fd5d190SBaptiste Daroussin.Xr diff
1236*2fd5d190SBaptiste Daroussincan produce commands that direct the
1237*2fd5d190SBaptiste Daroussin.Xr ed
1238*2fd5d190SBaptiste Daroussintext editor to change the first file into the second file. Long ago, this
1239*2fd5d190SBaptiste Daroussinwas the only output mode that was suitable for editing one file into another
1240*2fd5d190SBaptiste Daroussinautomatically; today, with
1241*2fd5d190SBaptiste Daroussin.Xr patch ,
1242*2fd5d190SBaptiste Daroussinit is almost obsolete. Use the
1243*2fd5d190SBaptiste Daroussin.Op -e
1244*2fd5d190SBaptiste Daroussinor
1245*2fd5d190SBaptiste Daroussin.Op --ed
1246*2fd5d190SBaptiste Daroussinoption to select this output format.
1247*2fd5d190SBaptiste Daroussin.Pp
1248*2fd5d190SBaptiste DaroussinLike the normal format (see Section
1249*2fd5d190SBaptiste Daroussin.Dq Normal ) ,
1250*2fd5d190SBaptiste Daroussinthis output format does not show any context; unlike the normal format, it
1251*2fd5d190SBaptiste Daroussindoes not include the information necessary to apply the diff in reverse (to
1252*2fd5d190SBaptiste Daroussinproduce the first file if all you have is the second file and the diff).
1253*2fd5d190SBaptiste Daroussin.Pp
1254*2fd5d190SBaptiste DaroussinIf the file
1255*2fd5d190SBaptiste Daroussin.Pa d
1256*2fd5d190SBaptiste Daroussincontains the output of
1257*2fd5d190SBaptiste Daroussin.Li diff -e old new ,
1258*2fd5d190SBaptiste Daroussinthen the command
1259*2fd5d190SBaptiste Daroussin.Li (cat d && echo w) | ed - old
1260*2fd5d190SBaptiste Daroussinedits
1261*2fd5d190SBaptiste Daroussin.Pa old
1262*2fd5d190SBaptiste Daroussinto make it a copy of
1263*2fd5d190SBaptiste Daroussin.Pa new .
1264*2fd5d190SBaptiste DaroussinMore generally, if
1265*2fd5d190SBaptiste Daroussin.Pa d1 ,
1266*2fd5d190SBaptiste Daroussin.Pa d2 ,
1267*2fd5d190SBaptiste Daroussin\&...,
1268*2fd5d190SBaptiste Daroussin.Pa dN
1269*2fd5d190SBaptiste Daroussincontain the outputs of
1270*2fd5d190SBaptiste Daroussin.Li diff -e old new1 ,
1271*2fd5d190SBaptiste Daroussin.Li diff -e new1 new2 ,
1272*2fd5d190SBaptiste Daroussin\&...,
1273*2fd5d190SBaptiste Daroussin.Li diff -e newN-1 newN ,
1274*2fd5d190SBaptiste Daroussinrespectively, then the command
1275*2fd5d190SBaptiste Daroussin.Li (cat d1 d2 ... dN && echo w) | ed - old
1276*2fd5d190SBaptiste Daroussinedits
1277*2fd5d190SBaptiste Daroussin.Pa old
1278*2fd5d190SBaptiste Daroussinto make it a copy of
1279*2fd5d190SBaptiste Daroussin.Pa newN .
1280*2fd5d190SBaptiste Daroussin.Pp
1281*2fd5d190SBaptiste Daroussin.No  Example Xr ed Script
1282*2fd5d190SBaptiste Daroussin.Pp
1283*2fd5d190SBaptiste DaroussinHere is the output of
1284*2fd5d190SBaptiste Daroussin.Li diff -e lao tzu
1285*2fd5d190SBaptiste Daroussin(see Section
1286*2fd5d190SBaptiste Daroussin.Dq Sample diff Input ,
1287*2fd5d190SBaptiste Daroussinfor the complete contents of the two files):
1288*2fd5d190SBaptiste Daroussin.Pp
1289*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
1290*2fd5d190SBaptiste Daroussin11a
1291*2fd5d190SBaptiste DaroussinThey both may be called deep and profound.
1292*2fd5d190SBaptiste DaroussinDeeper and more profound,
1293*2fd5d190SBaptiste DaroussinThe door of all subtleties!
1294*2fd5d190SBaptiste Daroussin\&.
1295*2fd5d190SBaptiste Daroussin4c
1296*2fd5d190SBaptiste DaroussinThe named is the mother of all things.
1297*2fd5d190SBaptiste Daroussin
1298*2fd5d190SBaptiste Daroussin\&.
1299*2fd5d190SBaptiste Daroussin1,2d
1300*2fd5d190SBaptiste Daroussin.Ed
1301*2fd5d190SBaptiste Daroussin.Pp
1302*2fd5d190SBaptiste Daroussin.No  Detailed Description of Xr ed Format
1303*2fd5d190SBaptiste Daroussin.Pp
1304*2fd5d190SBaptiste DaroussinThe
1305*2fd5d190SBaptiste Daroussin.Xr ed
1306*2fd5d190SBaptiste Daroussinoutput format consists of one or more hunks of differences. The changes closest
1307*2fd5d190SBaptiste Daroussinto the ends of the files come first so that commands that change the number
1308*2fd5d190SBaptiste Daroussinof lines do not affect how
1309*2fd5d190SBaptiste Daroussin.Xr ed
1310*2fd5d190SBaptiste Daroussininterprets line numbers in succeeding commands.
1311*2fd5d190SBaptiste Daroussin.Xr ed
1312*2fd5d190SBaptiste Daroussinformat hunks look like this:
1313*2fd5d190SBaptiste Daroussin.Pp
1314*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
1315*2fd5d190SBaptiste Daroussinchange-command
1316*2fd5d190SBaptiste Daroussinto-file-line
1317*2fd5d190SBaptiste Daroussinto-file-line...
1318*2fd5d190SBaptiste Daroussin\&.
1319*2fd5d190SBaptiste Daroussin.Ed
1320*2fd5d190SBaptiste Daroussin.Pp
1321*2fd5d190SBaptiste DaroussinBecause
1322*2fd5d190SBaptiste Daroussin.Xr ed
1323*2fd5d190SBaptiste Daroussinuses a single period on a line to indicate the end of input, GNU
1324*2fd5d190SBaptiste Daroussin.Xr diff
1325*2fd5d190SBaptiste Daroussinprotects lines of changes that contain a single period on a line by writing
1326*2fd5d190SBaptiste Daroussintwo periods instead, then writing a subsequent
1327*2fd5d190SBaptiste Daroussin.Xr ed
1328*2fd5d190SBaptiste Daroussincommand to change the two periods into one. The
1329*2fd5d190SBaptiste Daroussin.Xr ed
1330*2fd5d190SBaptiste Daroussinformat cannot represent an incomplete line, so if the second file ends in
1331*2fd5d190SBaptiste Daroussina changed incomplete line,
1332*2fd5d190SBaptiste Daroussin.Xr diff
1333*2fd5d190SBaptiste Daroussinreports an error and then pretends that a newline was appended.
1334*2fd5d190SBaptiste Daroussin.Pp
1335*2fd5d190SBaptiste DaroussinThere are three types of change commands. Each consists of a line number or
1336*2fd5d190SBaptiste Daroussincomma-separated range of lines in the first file and a single character indicating
1337*2fd5d190SBaptiste Daroussinthe kind of change to make. All line numbers are the original line numbers
1338*2fd5d190SBaptiste Daroussinin the file. The types of change commands are:
1339*2fd5d190SBaptiste Daroussin.Pp
1340*2fd5d190SBaptiste Daroussin.Bl -tag -width Ds
1341*2fd5d190SBaptiste Daroussin.It  Va la
1342*2fd5d190SBaptiste DaroussinAdd text from the second file after line
1343*2fd5d190SBaptiste Daroussin.Va l
1344*2fd5d190SBaptiste Daroussinin the first file. For example,
1345*2fd5d190SBaptiste Daroussin.Li 8a
1346*2fd5d190SBaptiste Daroussinmeans to add the following lines after line 8 of file 1.
1347*2fd5d190SBaptiste Daroussin.Pp
1348*2fd5d190SBaptiste Daroussin.It  Va rc
1349*2fd5d190SBaptiste DaroussinReplace the lines in range
1350*2fd5d190SBaptiste Daroussin.Va r
1351*2fd5d190SBaptiste Daroussinin the first file with the following lines. Like a combined add and delete,
1352*2fd5d190SBaptiste Daroussinbut more compact. For example,
1353*2fd5d190SBaptiste Daroussin.Li 5,7c
1354*2fd5d190SBaptiste Daroussinmeans change lines 5--7 of file 1 to read as the text file 2.
1355*2fd5d190SBaptiste Daroussin.Pp
1356*2fd5d190SBaptiste Daroussin.It  Va rd
1357*2fd5d190SBaptiste DaroussinDelete the lines in range
1358*2fd5d190SBaptiste Daroussin.Va r
1359*2fd5d190SBaptiste Daroussinfrom the first file. For example,
1360*2fd5d190SBaptiste Daroussin.Li 5,7d
1361*2fd5d190SBaptiste Daroussinmeans delete lines 5--7 of file 1.
1362*2fd5d190SBaptiste Daroussin.El
1363*2fd5d190SBaptiste Daroussin.Pp
1364*2fd5d190SBaptiste Daroussin.Em  Forward Xr ed Scripts
1365*2fd5d190SBaptiste Daroussin.Pp
1366*2fd5d190SBaptiste Daroussin.Xr diff
1367*2fd5d190SBaptiste Daroussincan produce output that is like an
1368*2fd5d190SBaptiste Daroussin.Xr ed
1369*2fd5d190SBaptiste Daroussinscript, but with hunks in forward (front to back) order. The format of the
1370*2fd5d190SBaptiste Daroussincommands is also changed slightly: command characters precede the lines they
1371*2fd5d190SBaptiste Daroussinmodify, spaces separate line numbers in ranges, and no attempt is made to
1372*2fd5d190SBaptiste Daroussindisambiguate hunk lines consisting of a single period. Like
1373*2fd5d190SBaptiste Daroussin.Xr ed
1374*2fd5d190SBaptiste Daroussinformat, forward
1375*2fd5d190SBaptiste Daroussin.Xr ed
1376*2fd5d190SBaptiste Daroussinformat cannot represent incomplete lines.
1377*2fd5d190SBaptiste Daroussin.Pp
1378*2fd5d190SBaptiste DaroussinForward
1379*2fd5d190SBaptiste Daroussin.Xr ed
1380*2fd5d190SBaptiste Daroussinformat is not very useful, because neither
1381*2fd5d190SBaptiste Daroussin.Xr ed
1382*2fd5d190SBaptiste Daroussinnor
1383*2fd5d190SBaptiste Daroussin.Xr patch
1384*2fd5d190SBaptiste Daroussincan apply diffs in this format. It exists mainly for compatibility with older
1385*2fd5d190SBaptiste Daroussinversions of
1386*2fd5d190SBaptiste Daroussin.Xr diff .
1387*2fd5d190SBaptiste DaroussinUse the
1388*2fd5d190SBaptiste Daroussin.Op -f
1389*2fd5d190SBaptiste Daroussinor
1390*2fd5d190SBaptiste Daroussin.Op --forward-ed
1391*2fd5d190SBaptiste Daroussinoption to select it.
1392*2fd5d190SBaptiste Daroussin.Pp
1393*2fd5d190SBaptiste Daroussin.Em  RCS Scripts
1394*2fd5d190SBaptiste Daroussin.Pp
1395*2fd5d190SBaptiste DaroussinThe RCS output format is designed specifically for use by the Revision Control
1396*2fd5d190SBaptiste DaroussinSystem, which is a set of free programs used for organizing different versions
1397*2fd5d190SBaptiste Daroussinand systems of files. Use the
1398*2fd5d190SBaptiste Daroussin.Op -n
1399*2fd5d190SBaptiste Daroussinor
1400*2fd5d190SBaptiste Daroussin.Op --rcs
1401*2fd5d190SBaptiste Daroussinoption to select this output format. It is like the forward
1402*2fd5d190SBaptiste Daroussin.Xr ed
1403*2fd5d190SBaptiste Daroussinformat (see Section
1404*2fd5d190SBaptiste Daroussin.Dq Forward ed ) ,
1405*2fd5d190SBaptiste Daroussinbut it can represent arbitrary changes to the contents of a file because it
1406*2fd5d190SBaptiste Daroussinavoids the forward
1407*2fd5d190SBaptiste Daroussin.Xr ed
1408*2fd5d190SBaptiste Daroussinformat's problems with lines consisting of a single period and with incomplete
1409*2fd5d190SBaptiste Daroussinlines. Instead of ending text sections with a line consisting of a single
1410*2fd5d190SBaptiste Daroussinperiod, each command specifies the number of lines it affects; a combination
1411*2fd5d190SBaptiste Daroussinof the
1412*2fd5d190SBaptiste Daroussin.Li a
1413*2fd5d190SBaptiste Daroussinand
1414*2fd5d190SBaptiste Daroussin.Li d
1415*2fd5d190SBaptiste Daroussincommands are used instead of
1416*2fd5d190SBaptiste Daroussin.Li c .
1417*2fd5d190SBaptiste DaroussinAlso, if the second file ends in a changed incomplete line, then the output
1418*2fd5d190SBaptiste Daroussinalso ends in an incomplete line.
1419*2fd5d190SBaptiste Daroussin.Pp
1420*2fd5d190SBaptiste DaroussinHere is the output of
1421*2fd5d190SBaptiste Daroussin.Li diff -n lao tzu
1422*2fd5d190SBaptiste Daroussin(see Section
1423*2fd5d190SBaptiste Daroussin.Dq Sample diff Input ,
1424*2fd5d190SBaptiste Daroussinfor the complete contents of the two files):
1425*2fd5d190SBaptiste Daroussin.Pp
1426*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
1427*2fd5d190SBaptiste Daroussind1 2
1428*2fd5d190SBaptiste Daroussind4 1
1429*2fd5d190SBaptiste Daroussina4 2
1430*2fd5d190SBaptiste DaroussinThe named is the mother of all things.
1431*2fd5d190SBaptiste Daroussin
1432*2fd5d190SBaptiste Daroussina11 3
1433*2fd5d190SBaptiste DaroussinThey both may be called deep and profound.
1434*2fd5d190SBaptiste DaroussinDeeper and more profound,
1435*2fd5d190SBaptiste DaroussinThe door of all subtleties!
1436*2fd5d190SBaptiste Daroussin.Ed
1437*2fd5d190SBaptiste Daroussin.Pp
1438*2fd5d190SBaptiste Daroussin.Ss  Merging Files with If-then-else
1439*2fd5d190SBaptiste DaroussinYou can use
1440*2fd5d190SBaptiste Daroussin.Xr diff
1441*2fd5d190SBaptiste Daroussinto merge two files of C source code. The output of
1442*2fd5d190SBaptiste Daroussin.Xr diff
1443*2fd5d190SBaptiste Daroussinin this format contains all the lines of both files. Lines common to both
1444*2fd5d190SBaptiste Daroussinfiles are output just once; the differing parts are separated by the C preprocessor
1445*2fd5d190SBaptiste Daroussindirectives
1446*2fd5d190SBaptiste Daroussin.Li #ifdef Va name
1447*2fd5d190SBaptiste Daroussinor
1448*2fd5d190SBaptiste Daroussin.Li #ifndef Va name ,
1449*2fd5d190SBaptiste Daroussin.Li #else ,
1450*2fd5d190SBaptiste Daroussinand
1451*2fd5d190SBaptiste Daroussin.Li #endif .
1452*2fd5d190SBaptiste DaroussinWhen compiling the output, you select which version to use by either defining
1453*2fd5d190SBaptiste Daroussinor leaving undefined the macro
1454*2fd5d190SBaptiste Daroussin.Va name .
1455*2fd5d190SBaptiste Daroussin.Pp
1456*2fd5d190SBaptiste DaroussinTo merge two files, use
1457*2fd5d190SBaptiste Daroussin.Xr diff
1458*2fd5d190SBaptiste Daroussinwith the
1459*2fd5d190SBaptiste Daroussin.Op -D Va name
1460*2fd5d190SBaptiste Daroussinor
1461*2fd5d190SBaptiste Daroussin.Op --ifdef= Va name
1462*2fd5d190SBaptiste Daroussinoption. The argument
1463*2fd5d190SBaptiste Daroussin.Va name
1464*2fd5d190SBaptiste Daroussinis the C preprocessor identifier to use in the
1465*2fd5d190SBaptiste Daroussin.Li #ifdef
1466*2fd5d190SBaptiste Daroussinand
1467*2fd5d190SBaptiste Daroussin.Li #ifndef
1468*2fd5d190SBaptiste Daroussindirectives.
1469*2fd5d190SBaptiste Daroussin.Pp
1470*2fd5d190SBaptiste DaroussinFor example, if you change an instance of
1471*2fd5d190SBaptiste Daroussin.Li wait (&s)
1472*2fd5d190SBaptiste Daroussinto
1473*2fd5d190SBaptiste Daroussin.Li waitpid (-1, &s, 0)
1474*2fd5d190SBaptiste Daroussinand then merge the old and new files with the
1475*2fd5d190SBaptiste Daroussin.Op --ifdef=HAVE_WAITPID
1476*2fd5d190SBaptiste Daroussinoption, then the affected part of your code might look like this:
1477*2fd5d190SBaptiste Daroussin.Pp
1478*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
1479*2fd5d190SBaptiste Daroussin    do {
1480*2fd5d190SBaptiste Daroussin#ifndef HAVE_WAITPID
1481*2fd5d190SBaptiste Daroussin        if ((w = wait (&s)) < 0  &&  errno != EINTR)
1482*2fd5d190SBaptiste Daroussin#else /* HAVE_WAITPID */
1483*2fd5d190SBaptiste Daroussin        if ((w = waitpid (-1, &s, 0)) < 0  &&  errno != EINTR)
1484*2fd5d190SBaptiste Daroussin#endif /* HAVE_WAITPID */
1485*2fd5d190SBaptiste Daroussin            return w;
1486*2fd5d190SBaptiste Daroussin    } while (w != child);
1487*2fd5d190SBaptiste Daroussin.Ed
1488*2fd5d190SBaptiste Daroussin.Pp
1489*2fd5d190SBaptiste DaroussinYou can specify formats for languages other than C by using line group formats
1490*2fd5d190SBaptiste Daroussinand line formats, as described in the next sections.
1491*2fd5d190SBaptiste Daroussin.Pp
1492*2fd5d190SBaptiste Daroussin.Em  Line Group Formats
1493*2fd5d190SBaptiste Daroussin.Pp
1494*2fd5d190SBaptiste DaroussinLine group formats let you specify formats suitable for many applications
1495*2fd5d190SBaptiste Daroussinthat allow if-then-else input, including programming languages and text formatting
1496*2fd5d190SBaptiste Daroussinlanguages. A line group format specifies the output format for a contiguous
1497*2fd5d190SBaptiste Daroussingroup of similar lines.
1498*2fd5d190SBaptiste Daroussin.Pp
1499*2fd5d190SBaptiste DaroussinFor example, the following command compares the TeX files
1500*2fd5d190SBaptiste Daroussin.Pa old
1501*2fd5d190SBaptiste Daroussinand
1502*2fd5d190SBaptiste Daroussin.Pa new ,
1503*2fd5d190SBaptiste Daroussinand outputs a merged file in which old regions are surrounded by
1504*2fd5d190SBaptiste Daroussin.Li \ebegin{em}
1505*2fd5d190SBaptiste Daroussin-
1506*2fd5d190SBaptiste Daroussin.Li \eend{em}
1507*2fd5d190SBaptiste Daroussinlines, and new regions are surrounded by
1508*2fd5d190SBaptiste Daroussin.Li \ebegin{bf}
1509*2fd5d190SBaptiste Daroussin-
1510*2fd5d190SBaptiste Daroussin.Li \eend{bf}
1511*2fd5d190SBaptiste Daroussinlines.
1512*2fd5d190SBaptiste Daroussin.Pp
1513*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
1514*2fd5d190SBaptiste Daroussindiff \e
1515*2fd5d190SBaptiste Daroussin   --old-group-format='\ebegin{em}
1516*2fd5d190SBaptiste Daroussin%<\eend{em}
1517*2fd5d190SBaptiste Daroussin\&' \e
1518*2fd5d190SBaptiste Daroussin   --new-group-format='\ebegin{bf}
1519*2fd5d190SBaptiste Daroussin%>\eend{bf}
1520*2fd5d190SBaptiste Daroussin\&' \e
1521*2fd5d190SBaptiste Daroussin   old new
1522*2fd5d190SBaptiste Daroussin.Ed
1523*2fd5d190SBaptiste Daroussin.Pp
1524*2fd5d190SBaptiste DaroussinThe following command is equivalent to the above example, but it is a little
1525*2fd5d190SBaptiste Daroussinmore verbose, because it spells out the default line group formats.
1526*2fd5d190SBaptiste Daroussin.Pp
1527*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
1528*2fd5d190SBaptiste Daroussindiff \e
1529*2fd5d190SBaptiste Daroussin   --old-group-format='\ebegin{em}
1530*2fd5d190SBaptiste Daroussin%<\eend{em}
1531*2fd5d190SBaptiste Daroussin\&' \e
1532*2fd5d190SBaptiste Daroussin   --new-group-format='\ebegin{bf}
1533*2fd5d190SBaptiste Daroussin%>\eend{bf}
1534*2fd5d190SBaptiste Daroussin\&' \e
1535*2fd5d190SBaptiste Daroussin   --unchanged-group-format='%=' \e
1536*2fd5d190SBaptiste Daroussin   --changed-group-format='\ebegin{em}
1537*2fd5d190SBaptiste Daroussin%<\eend{em}
1538*2fd5d190SBaptiste Daroussin\ebegin{bf}
1539*2fd5d190SBaptiste Daroussin%>\eend{bf}
1540*2fd5d190SBaptiste Daroussin\&' \e
1541*2fd5d190SBaptiste Daroussin   old new
1542*2fd5d190SBaptiste Daroussin.Ed
1543*2fd5d190SBaptiste Daroussin.Pp
1544*2fd5d190SBaptiste DaroussinHere is a more advanced example, which outputs a diff listing with headers
1545*2fd5d190SBaptiste Daroussincontaining line numbers in a \(lqplain English\(rq style.
1546*2fd5d190SBaptiste Daroussin.Pp
1547*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
1548*2fd5d190SBaptiste Daroussindiff \e
1549*2fd5d190SBaptiste Daroussin   --unchanged-group-format=\(rq \e
1550*2fd5d190SBaptiste Daroussin   --old-group-format='-------- %dn line%(n=1?:s) deleted at %df:
1551*2fd5d190SBaptiste Daroussin%<' \e
1552*2fd5d190SBaptiste Daroussin   --new-group-format='-------- %dN line%(N=1?:s) added after %de:
1553*2fd5d190SBaptiste Daroussin%>' \e
1554*2fd5d190SBaptiste Daroussin   --changed-group-format='-------- %dn line%(n=1?:s) changed at %df:
1555*2fd5d190SBaptiste Daroussin%<-------- to:
1556*2fd5d190SBaptiste Daroussin%>' \e
1557*2fd5d190SBaptiste Daroussin   old new
1558*2fd5d190SBaptiste Daroussin.Ed
1559*2fd5d190SBaptiste Daroussin.Pp
1560*2fd5d190SBaptiste DaroussinTo specify a line group format, use
1561*2fd5d190SBaptiste Daroussin.Xr diff
1562*2fd5d190SBaptiste Daroussinwith one of the options listed below. You can specify up to four line group
1563*2fd5d190SBaptiste Daroussinformats, one for each kind of line group. You should quote
1564*2fd5d190SBaptiste Daroussin.Va format ,
1565*2fd5d190SBaptiste Daroussinbecause it typically contains shell metacharacters.
1566*2fd5d190SBaptiste Daroussin.Pp
1567*2fd5d190SBaptiste Daroussin.Bl -tag -width Ds
1568*2fd5d190SBaptiste Daroussin.It  --old-group-format= Va format
1569*2fd5d190SBaptiste DaroussinThese line groups are hunks containing only lines from the first file. The
1570*2fd5d190SBaptiste Daroussindefault old group format is the same as the changed group format if it is
1571*2fd5d190SBaptiste Daroussinspecified; otherwise it is a format that outputs the line group as-is.
1572*2fd5d190SBaptiste Daroussin.Pp
1573*2fd5d190SBaptiste Daroussin.It  --new-group-format= Va format
1574*2fd5d190SBaptiste DaroussinThese line groups are hunks containing only lines from the second file. The
1575*2fd5d190SBaptiste Daroussindefault new group format is same as the changed group format if it is specified;
1576*2fd5d190SBaptiste Daroussinotherwise it is a format that outputs the line group as-is.
1577*2fd5d190SBaptiste Daroussin.Pp
1578*2fd5d190SBaptiste Daroussin.It  --changed-group-format= Va format
1579*2fd5d190SBaptiste DaroussinThese line groups are hunks containing lines from both files. The default
1580*2fd5d190SBaptiste Daroussinchanged group format is the concatenation of the old and new group formats.
1581*2fd5d190SBaptiste Daroussin.Pp
1582*2fd5d190SBaptiste Daroussin.It  --unchanged-group-format= Va format
1583*2fd5d190SBaptiste DaroussinThese line groups contain lines common to both files. The default unchanged
1584*2fd5d190SBaptiste Daroussingroup format is a format that outputs the line group as-is.
1585*2fd5d190SBaptiste Daroussin.El
1586*2fd5d190SBaptiste Daroussin.Pp
1587*2fd5d190SBaptiste DaroussinIn a line group format, ordinary characters represent themselves; conversion
1588*2fd5d190SBaptiste Daroussinspecifications start with
1589*2fd5d190SBaptiste Daroussin.Li %
1590*2fd5d190SBaptiste Daroussinand have one of the following forms.
1591*2fd5d190SBaptiste Daroussin.Pp
1592*2fd5d190SBaptiste Daroussin.Bl -tag -width Ds
1593*2fd5d190SBaptiste Daroussin.It  %<
1594*2fd5d190SBaptiste Daroussinstands for the lines from the first file, including the trailing newline.
1595*2fd5d190SBaptiste DaroussinEach line is formatted according to the old line format (see Section
1596*2fd5d190SBaptiste Daroussin.Dq Line Formats ) .
1597*2fd5d190SBaptiste Daroussin.Pp
1598*2fd5d190SBaptiste Daroussin.It  %>
1599*2fd5d190SBaptiste Daroussinstands for the lines from the second file, including the trailing newline.
1600*2fd5d190SBaptiste DaroussinEach line is formatted according to the new line format.
1601*2fd5d190SBaptiste Daroussin.Pp
1602*2fd5d190SBaptiste Daroussin.It  %=
1603*2fd5d190SBaptiste Daroussinstands for the lines common to both files, including the trailing newline.
1604*2fd5d190SBaptiste DaroussinEach line is formatted according to the unchanged line format.
1605*2fd5d190SBaptiste Daroussin.Pp
1606*2fd5d190SBaptiste Daroussin.It  %%
1607*2fd5d190SBaptiste Daroussinstands for
1608*2fd5d190SBaptiste Daroussin.Li % .
1609*2fd5d190SBaptiste Daroussin.Pp
1610*2fd5d190SBaptiste Daroussin.It  %c' Va C'
1611*2fd5d190SBaptiste Daroussinwhere
1612*2fd5d190SBaptiste Daroussin.Va C
1613*2fd5d190SBaptiste Daroussinis a single character, stands for
1614*2fd5d190SBaptiste Daroussin.Va C .
1615*2fd5d190SBaptiste Daroussin.Va C
1616*2fd5d190SBaptiste Daroussinmay not be a backslash or an apostrophe. For example,
1617*2fd5d190SBaptiste Daroussin.Li %c':'
1618*2fd5d190SBaptiste Daroussinstands for a colon, even inside the then-part of an if-then-else format, which
1619*2fd5d190SBaptiste Daroussina colon would normally terminate.
1620*2fd5d190SBaptiste Daroussin.Pp
1621*2fd5d190SBaptiste Daroussin.It  %c'\e Va O'
1622*2fd5d190SBaptiste Daroussinwhere
1623*2fd5d190SBaptiste Daroussin.Va O
1624*2fd5d190SBaptiste Daroussinis a string of 1, 2, or 3 octal digits, stands for the character with octal
1625*2fd5d190SBaptiste Daroussincode
1626*2fd5d190SBaptiste Daroussin.Va O .
1627*2fd5d190SBaptiste DaroussinFor example,
1628*2fd5d190SBaptiste Daroussin.Li %c'\e0'
1629*2fd5d190SBaptiste Daroussinstands for a null character.
1630*2fd5d190SBaptiste Daroussin.Pp
1631*2fd5d190SBaptiste Daroussin.It  Va F Va n
1632*2fd5d190SBaptiste Daroussinwhere
1633*2fd5d190SBaptiste Daroussin.Va F
1634*2fd5d190SBaptiste Daroussinis a
1635*2fd5d190SBaptiste Daroussin.Li printf
1636*2fd5d190SBaptiste Daroussinconversion specification and
1637*2fd5d190SBaptiste Daroussin.Va n
1638*2fd5d190SBaptiste Daroussinis one of the following letters, stands for
1639*2fd5d190SBaptiste Daroussin.Va n
1640*2fd5d190SBaptiste Daroussin\&'s value formatted with
1641*2fd5d190SBaptiste Daroussin.Va F .
1642*2fd5d190SBaptiste Daroussin.Pp
1643*2fd5d190SBaptiste Daroussin.Bl -tag -width Ds
1644*2fd5d190SBaptiste Daroussin.It  e
1645*2fd5d190SBaptiste DaroussinThe line number of the line just before the group in the old file.
1646*2fd5d190SBaptiste Daroussin.Pp
1647*2fd5d190SBaptiste Daroussin.It  f
1648*2fd5d190SBaptiste DaroussinThe line number of the first line in the group in the old file; equals
1649*2fd5d190SBaptiste Daroussin.Va e
1650*2fd5d190SBaptiste Daroussin+ 1.
1651*2fd5d190SBaptiste Daroussin.Pp
1652*2fd5d190SBaptiste Daroussin.It  l
1653*2fd5d190SBaptiste DaroussinThe line number of the last line in the group in the old file.
1654*2fd5d190SBaptiste Daroussin.Pp
1655*2fd5d190SBaptiste Daroussin.It  m
1656*2fd5d190SBaptiste DaroussinThe line number of the line just after the group in the old file; equals
1657*2fd5d190SBaptiste Daroussin.Va l
1658*2fd5d190SBaptiste Daroussin+ 1.
1659*2fd5d190SBaptiste Daroussin.Pp
1660*2fd5d190SBaptiste Daroussin.It  n
1661*2fd5d190SBaptiste DaroussinThe number of lines in the group in the old file; equals
1662*2fd5d190SBaptiste Daroussin.Va l
1663*2fd5d190SBaptiste Daroussin-
1664*2fd5d190SBaptiste Daroussin.Va f
1665*2fd5d190SBaptiste Daroussin+ 1.
1666*2fd5d190SBaptiste Daroussin.Pp
1667*2fd5d190SBaptiste Daroussin.It  E, F, L, M, N
1668*2fd5d190SBaptiste DaroussinLikewise, for lines in the new file.
1669*2fd5d190SBaptiste Daroussin.Pp
1670*2fd5d190SBaptiste Daroussin.El
1671*2fd5d190SBaptiste DaroussinThe
1672*2fd5d190SBaptiste Daroussin.Li printf
1673*2fd5d190SBaptiste Daroussinconversion specification can be
1674*2fd5d190SBaptiste Daroussin.Li %d ,
1675*2fd5d190SBaptiste Daroussin.Li %o ,
1676*2fd5d190SBaptiste Daroussin.Li %x ,
1677*2fd5d190SBaptiste Daroussinor
1678*2fd5d190SBaptiste Daroussin.Li %X ,
1679*2fd5d190SBaptiste Daroussinspecifying decimal, octal, lower case hexadecimal, or upper case hexadecimal
1680*2fd5d190SBaptiste Daroussinoutput respectively. After the
1681*2fd5d190SBaptiste Daroussin.Li %
1682*2fd5d190SBaptiste Daroussinthe following options can appear in sequence: a series of zero or more flags;
1683*2fd5d190SBaptiste Daroussinan integer specifying the minimum field width; and a period followed by an
1684*2fd5d190SBaptiste Daroussinoptional integer specifying the minimum number of digits. The flags are
1685*2fd5d190SBaptiste Daroussin.Li -
1686*2fd5d190SBaptiste Daroussinfor left-justification,
1687*2fd5d190SBaptiste Daroussin.Li '
1688*2fd5d190SBaptiste Daroussinfor separating the digit into groups as specified by the
1689*2fd5d190SBaptiste Daroussin.Ev LC_NUMERIC
1690*2fd5d190SBaptiste Daroussinlocale category, and
1691*2fd5d190SBaptiste Daroussin.Li 0
1692*2fd5d190SBaptiste Daroussinfor padding with zeros instead of spaces. For example,
1693*2fd5d190SBaptiste Daroussin.Li %5dN
1694*2fd5d190SBaptiste Daroussinprints the number of new lines in the group in a field of width 5 characters,
1695*2fd5d190SBaptiste Daroussinusing the
1696*2fd5d190SBaptiste Daroussin.Li printf
1697*2fd5d190SBaptiste Daroussinformat
1698*2fd5d190SBaptiste Daroussin.Li "%5d" .
1699*2fd5d190SBaptiste Daroussin.Pp
1700*2fd5d190SBaptiste Daroussin.It  ( Va A= Va B? Va T: Va E)
1701*2fd5d190SBaptiste DaroussinIf
1702*2fd5d190SBaptiste Daroussin.Va A
1703*2fd5d190SBaptiste Daroussinequals
1704*2fd5d190SBaptiste Daroussin.Va B
1705*2fd5d190SBaptiste Daroussinthen
1706*2fd5d190SBaptiste Daroussin.Va T
1707*2fd5d190SBaptiste Daroussinelse
1708*2fd5d190SBaptiste Daroussin.Va E .
1709*2fd5d190SBaptiste Daroussin.Va A
1710*2fd5d190SBaptiste Daroussinand
1711*2fd5d190SBaptiste Daroussin.Va B
1712*2fd5d190SBaptiste Daroussinare each either a decimal constant or a single letter interpreted as above.
1713*2fd5d190SBaptiste DaroussinThis format spec is equivalent to
1714*2fd5d190SBaptiste Daroussin.Va T
1715*2fd5d190SBaptiste Daroussinif
1716*2fd5d190SBaptiste Daroussin.Va A
1717*2fd5d190SBaptiste Daroussin\&'s value equals
1718*2fd5d190SBaptiste Daroussin.Va B
1719*2fd5d190SBaptiste Daroussin\&'s; otherwise it is equivalent to
1720*2fd5d190SBaptiste Daroussin.Va E .
1721*2fd5d190SBaptiste Daroussin.Pp
1722*2fd5d190SBaptiste DaroussinFor example,
1723*2fd5d190SBaptiste Daroussin.Li %(N=0?no:%dN) line%(N=1?:s)
1724*2fd5d190SBaptiste Daroussinis equivalent to
1725*2fd5d190SBaptiste Daroussin.Li no lines
1726*2fd5d190SBaptiste Daroussinif
1727*2fd5d190SBaptiste Daroussin.Va N
1728*2fd5d190SBaptiste Daroussin(the number of lines in the group in the new file) is 0, to
1729*2fd5d190SBaptiste Daroussin.Li 1 line
1730*2fd5d190SBaptiste Daroussinif
1731*2fd5d190SBaptiste Daroussin.Va N
1732*2fd5d190SBaptiste Daroussinis 1, and to
1733*2fd5d190SBaptiste Daroussin.Li %dN lines
1734*2fd5d190SBaptiste Daroussinotherwise.
1735*2fd5d190SBaptiste Daroussin.El
1736*2fd5d190SBaptiste Daroussin.Pp
1737*2fd5d190SBaptiste Daroussin.Em  Line Formats
1738*2fd5d190SBaptiste Daroussin.Pp
1739*2fd5d190SBaptiste DaroussinLine formats control how each line taken from an input file is output as part
1740*2fd5d190SBaptiste Daroussinof a line group in if-then-else format.
1741*2fd5d190SBaptiste Daroussin.Pp
1742*2fd5d190SBaptiste DaroussinFor example, the following command outputs text with a one-character change
1743*2fd5d190SBaptiste Daroussinindicator to the left of the text. The first character of output is
1744*2fd5d190SBaptiste Daroussin.Li -
1745*2fd5d190SBaptiste Daroussinfor deleted lines,
1746*2fd5d190SBaptiste Daroussin.Li |
1747*2fd5d190SBaptiste Daroussinfor added lines, and a space for unchanged lines. The formats contain newline
1748*2fd5d190SBaptiste Daroussincharacters where newlines are desired on output.
1749*2fd5d190SBaptiste Daroussin.Pp
1750*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
1751*2fd5d190SBaptiste Daroussindiff \e
1752*2fd5d190SBaptiste Daroussin   --old-line-format='-%l
1753*2fd5d190SBaptiste Daroussin\&' \e
1754*2fd5d190SBaptiste Daroussin   --new-line-format='|%l
1755*2fd5d190SBaptiste Daroussin\&' \e
1756*2fd5d190SBaptiste Daroussin   --unchanged-line-format=' %l
1757*2fd5d190SBaptiste Daroussin\&' \e
1758*2fd5d190SBaptiste Daroussin   old new
1759*2fd5d190SBaptiste Daroussin.Ed
1760*2fd5d190SBaptiste Daroussin.Pp
1761*2fd5d190SBaptiste DaroussinTo specify a line format, use one of the following options. You should quote
1762*2fd5d190SBaptiste Daroussin.Va format ,
1763*2fd5d190SBaptiste Daroussinsince it often contains shell metacharacters.
1764*2fd5d190SBaptiste Daroussin.Pp
1765*2fd5d190SBaptiste Daroussin.Bl -tag -width Ds
1766*2fd5d190SBaptiste Daroussin.It  --old-line-format= Va format
1767*2fd5d190SBaptiste Daroussinformats lines just from the first file.
1768*2fd5d190SBaptiste Daroussin.Pp
1769*2fd5d190SBaptiste Daroussin.It  --new-line-format= Va format
1770*2fd5d190SBaptiste Daroussinformats lines just from the second file.
1771*2fd5d190SBaptiste Daroussin.Pp
1772*2fd5d190SBaptiste Daroussin.It  --unchanged-line-format= Va format
1773*2fd5d190SBaptiste Daroussinformats lines common to both files.
1774*2fd5d190SBaptiste Daroussin.Pp
1775*2fd5d190SBaptiste Daroussin.It  --line-format= Va format
1776*2fd5d190SBaptiste Daroussinformats all lines; in effect, it sets all three above options simultaneously.
1777*2fd5d190SBaptiste Daroussin.El
1778*2fd5d190SBaptiste Daroussin.Pp
1779*2fd5d190SBaptiste DaroussinIn a line format, ordinary characters represent themselves; conversion specifications
1780*2fd5d190SBaptiste Daroussinstart with
1781*2fd5d190SBaptiste Daroussin.Li %
1782*2fd5d190SBaptiste Daroussinand have one of the following forms.
1783*2fd5d190SBaptiste Daroussin.Pp
1784*2fd5d190SBaptiste Daroussin.Bl -tag -width Ds
1785*2fd5d190SBaptiste Daroussin.It  %l
1786*2fd5d190SBaptiste Daroussinstands for the contents of the line, not counting its trailing newline (if
1787*2fd5d190SBaptiste Daroussinany). This format ignores whether the line is incomplete;See Section
1788*2fd5d190SBaptiste Daroussin.Dq Incomplete Lines .
1789*2fd5d190SBaptiste Daroussin.Pp
1790*2fd5d190SBaptiste Daroussin.It  %L
1791*2fd5d190SBaptiste Daroussinstands for the contents of the line, including its trailing newline (if any).
1792*2fd5d190SBaptiste DaroussinIf a line is incomplete, this format preserves its incompleteness.
1793*2fd5d190SBaptiste Daroussin.Pp
1794*2fd5d190SBaptiste Daroussin.It  %%
1795*2fd5d190SBaptiste Daroussinstands for
1796*2fd5d190SBaptiste Daroussin.Li % .
1797*2fd5d190SBaptiste Daroussin.Pp
1798*2fd5d190SBaptiste Daroussin.It  %c' Va C'
1799*2fd5d190SBaptiste Daroussinwhere
1800*2fd5d190SBaptiste Daroussin.Va C
1801*2fd5d190SBaptiste Daroussinis a single character, stands for
1802*2fd5d190SBaptiste Daroussin.Va C .
1803*2fd5d190SBaptiste Daroussin.Va C
1804*2fd5d190SBaptiste Daroussinmay not be a backslash or an apostrophe. For example,
1805*2fd5d190SBaptiste Daroussin.Li %c':'
1806*2fd5d190SBaptiste Daroussinstands for a colon.
1807*2fd5d190SBaptiste Daroussin.Pp
1808*2fd5d190SBaptiste Daroussin.It  %c'\e Va O'
1809*2fd5d190SBaptiste Daroussinwhere
1810*2fd5d190SBaptiste Daroussin.Va O
1811*2fd5d190SBaptiste Daroussinis a string of 1, 2, or 3 octal digits, stands for the character with octal
1812*2fd5d190SBaptiste Daroussincode
1813*2fd5d190SBaptiste Daroussin.Va O .
1814*2fd5d190SBaptiste DaroussinFor example,
1815*2fd5d190SBaptiste Daroussin.Li %c'\e0'
1816*2fd5d190SBaptiste Daroussinstands for a null character.
1817*2fd5d190SBaptiste Daroussin.Pp
1818*2fd5d190SBaptiste Daroussin.It  Va Fn
1819*2fd5d190SBaptiste Daroussinwhere
1820*2fd5d190SBaptiste Daroussin.Va F
1821*2fd5d190SBaptiste Daroussinis a
1822*2fd5d190SBaptiste Daroussin.Li printf
1823*2fd5d190SBaptiste Daroussinconversion specification, stands for the line number formatted with
1824*2fd5d190SBaptiste Daroussin.Va F .
1825*2fd5d190SBaptiste DaroussinFor example,
1826*2fd5d190SBaptiste Daroussin.Li %.5dn
1827*2fd5d190SBaptiste Daroussinprints the line number using the
1828*2fd5d190SBaptiste Daroussin.Li printf
1829*2fd5d190SBaptiste Daroussinformat
1830*2fd5d190SBaptiste Daroussin.Li "%.5d" .
1831*2fd5d190SBaptiste DaroussinSee Section.Dq Line Group Formats ,
1832*2fd5d190SBaptiste Daroussinfor more about printf conversion specifications.
1833*2fd5d190SBaptiste Daroussin.Pp
1834*2fd5d190SBaptiste Daroussin.El
1835*2fd5d190SBaptiste DaroussinThe default line format is
1836*2fd5d190SBaptiste Daroussin.Li %l
1837*2fd5d190SBaptiste Daroussinfollowed by a newline character.
1838*2fd5d190SBaptiste Daroussin.Pp
1839*2fd5d190SBaptiste DaroussinIf the input contains tab characters and it is important that they line up
1840*2fd5d190SBaptiste Daroussinon output, you should ensure that
1841*2fd5d190SBaptiste Daroussin.Li %l
1842*2fd5d190SBaptiste Daroussinor
1843*2fd5d190SBaptiste Daroussin.Li %L
1844*2fd5d190SBaptiste Daroussinin a line format is just after a tab stop (e.g. by preceding
1845*2fd5d190SBaptiste Daroussin.Li %l
1846*2fd5d190SBaptiste Daroussinor
1847*2fd5d190SBaptiste Daroussin.Li %L
1848*2fd5d190SBaptiste Daroussinwith a tab character), or you should use the
1849*2fd5d190SBaptiste Daroussin.Op -t
1850*2fd5d190SBaptiste Daroussinor
1851*2fd5d190SBaptiste Daroussin.Op --expand-tabs
1852*2fd5d190SBaptiste Daroussinoption.
1853*2fd5d190SBaptiste Daroussin.Pp
1854*2fd5d190SBaptiste DaroussinTaken together, the line and line group formats let you specify many different
1855*2fd5d190SBaptiste Daroussinformats. For example, the following command uses a format similar to normal
1856*2fd5d190SBaptiste Daroussin.Xr diff
1857*2fd5d190SBaptiste Daroussinformat. You can tailor this command to get fine control over
1858*2fd5d190SBaptiste Daroussin.Xr diff
1859*2fd5d190SBaptiste Daroussinoutput.
1860*2fd5d190SBaptiste Daroussin.Pp
1861*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
1862*2fd5d190SBaptiste Daroussindiff \e
1863*2fd5d190SBaptiste Daroussin   --old-line-format='< %l
1864*2fd5d190SBaptiste Daroussin\&' \e
1865*2fd5d190SBaptiste Daroussin   --new-line-format='> %l
1866*2fd5d190SBaptiste Daroussin\&' \e
1867*2fd5d190SBaptiste Daroussin   --old-group-format='%df%(f=l?:,%dl)d%dE
1868*2fd5d190SBaptiste Daroussin%<' \e
1869*2fd5d190SBaptiste Daroussin   --new-group-format='%dea%dF%(F=L?:,%dL)
1870*2fd5d190SBaptiste Daroussin%>' \e
1871*2fd5d190SBaptiste Daroussin   --changed-group-format='%df%(f=l?:,%dl)c%dF%(F=L?:,%dL)
1872*2fd5d190SBaptiste Daroussin%<---
1873*2fd5d190SBaptiste Daroussin%>' \e
1874*2fd5d190SBaptiste Daroussin   --unchanged-group-format=\(rq \e
1875*2fd5d190SBaptiste Daroussin   old new
1876*2fd5d190SBaptiste Daroussin.Ed
1877*2fd5d190SBaptiste Daroussin.Pp
1878*2fd5d190SBaptiste Daroussin.Em  An Example of If-then-else Format
1879*2fd5d190SBaptiste Daroussin.Pp
1880*2fd5d190SBaptiste DaroussinHere is the output of
1881*2fd5d190SBaptiste Daroussin.Li diff -DTWO lao tzu
1882*2fd5d190SBaptiste Daroussin(see Section
1883*2fd5d190SBaptiste Daroussin.Dq Sample diff Input ,
1884*2fd5d190SBaptiste Daroussinfor the complete contents of the two files):
1885*2fd5d190SBaptiste Daroussin.Pp
1886*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
1887*2fd5d190SBaptiste Daroussin#ifndef TWO
1888*2fd5d190SBaptiste DaroussinThe Way that can be told of is not the eternal Way;
1889*2fd5d190SBaptiste DaroussinThe name that can be named is not the eternal name.
1890*2fd5d190SBaptiste Daroussin#endif /* ! TWO */
1891*2fd5d190SBaptiste DaroussinThe Nameless is the origin of Heaven and Earth;
1892*2fd5d190SBaptiste Daroussin#ifndef TWO
1893*2fd5d190SBaptiste DaroussinThe Named is the mother of all things.
1894*2fd5d190SBaptiste Daroussin#else /* TWO */
1895*2fd5d190SBaptiste DaroussinThe named is the mother of all things.
1896*2fd5d190SBaptiste Daroussin
1897*2fd5d190SBaptiste Daroussin#endif /* TWO */
1898*2fd5d190SBaptiste DaroussinTherefore let there always be non-being,
1899*2fd5d190SBaptiste Daroussin  so we may see their subtlety,
1900*2fd5d190SBaptiste DaroussinAnd let there always be being,
1901*2fd5d190SBaptiste Daroussin  so we may see their outcome.
1902*2fd5d190SBaptiste DaroussinThe two are the same,
1903*2fd5d190SBaptiste DaroussinBut after they are produced,
1904*2fd5d190SBaptiste Daroussin  they have different names.
1905*2fd5d190SBaptiste Daroussin#ifdef TWO
1906*2fd5d190SBaptiste DaroussinThey both may be called deep and profound.
1907*2fd5d190SBaptiste DaroussinDeeper and more profound,
1908*2fd5d190SBaptiste DaroussinThe door of all subtleties!
1909*2fd5d190SBaptiste Daroussin#endif /* TWO */
1910*2fd5d190SBaptiste Daroussin.Ed
1911*2fd5d190SBaptiste Daroussin.Pp
1912*2fd5d190SBaptiste Daroussin.Em  Detailed Description of If-then-else Format
1913*2fd5d190SBaptiste Daroussin.Pp
1914*2fd5d190SBaptiste DaroussinFor lines common to both files,
1915*2fd5d190SBaptiste Daroussin.Xr diff
1916*2fd5d190SBaptiste Daroussinuses the unchanged line group format. For each hunk of differences in the
1917*2fd5d190SBaptiste Daroussinmerged output format, if the hunk contains only lines from the first file,
1918*2fd5d190SBaptiste Daroussin.Xr diff
1919*2fd5d190SBaptiste Daroussinuses the old line group format; if the hunk contains only lines from the second
1920*2fd5d190SBaptiste Daroussinfile,
1921*2fd5d190SBaptiste Daroussin.Xr diff
1922*2fd5d190SBaptiste Daroussinuses the new group format; otherwise,
1923*2fd5d190SBaptiste Daroussin.Xr diff
1924*2fd5d190SBaptiste Daroussinuses the changed group format.
1925*2fd5d190SBaptiste Daroussin.Pp
1926*2fd5d190SBaptiste DaroussinThe old, new, and unchanged line formats specify the output format of lines
1927*2fd5d190SBaptiste Daroussinfrom the first file, lines from the second file, and lines common to both
1928*2fd5d190SBaptiste Daroussinfiles, respectively.
1929*2fd5d190SBaptiste Daroussin.Pp
1930*2fd5d190SBaptiste DaroussinThe option
1931*2fd5d190SBaptiste Daroussin.Op --ifdef= Va name
1932*2fd5d190SBaptiste Daroussinis equivalent to the following sequence of options using shell syntax:
1933*2fd5d190SBaptiste Daroussin.Pp
1934*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
1935*2fd5d190SBaptiste Daroussin--old-group-format='#ifndef name
1936*2fd5d190SBaptiste Daroussin%<#endif /* ! name */
1937*2fd5d190SBaptiste Daroussin\&' \e
1938*2fd5d190SBaptiste Daroussin--new-group-format='#ifdef name
1939*2fd5d190SBaptiste Daroussin%>#endif /* name */
1940*2fd5d190SBaptiste Daroussin\&' \e
1941*2fd5d190SBaptiste Daroussin--unchanged-group-format='%=' \e
1942*2fd5d190SBaptiste Daroussin--changed-group-format='#ifndef name
1943*2fd5d190SBaptiste Daroussin%<#else /* name */
1944*2fd5d190SBaptiste Daroussin%>#endif /* name */
1945*2fd5d190SBaptiste Daroussin\&'
1946*2fd5d190SBaptiste Daroussin.Ed
1947*2fd5d190SBaptiste Daroussin.Pp
1948*2fd5d190SBaptiste DaroussinYou should carefully check the
1949*2fd5d190SBaptiste Daroussin.Xr diff
1950*2fd5d190SBaptiste Daroussinoutput for proper nesting. For example, when using the
1951*2fd5d190SBaptiste Daroussin.Op -D Va name
1952*2fd5d190SBaptiste Daroussinor
1953*2fd5d190SBaptiste Daroussin.Op --ifdef= Va name
1954*2fd5d190SBaptiste Daroussinoption, you should check that if the differing lines contain any of the C
1955*2fd5d190SBaptiste Daroussinpreprocessor directives
1956*2fd5d190SBaptiste Daroussin.Li #ifdef ,
1957*2fd5d190SBaptiste Daroussin.Li #ifndef ,
1958*2fd5d190SBaptiste Daroussin.Li #else ,
1959*2fd5d190SBaptiste Daroussin.Li #elif ,
1960*2fd5d190SBaptiste Daroussinor
1961*2fd5d190SBaptiste Daroussin.Li #endif ,
1962*2fd5d190SBaptiste Daroussinthey are nested properly and match. If they don't, you must make corrections
1963*2fd5d190SBaptiste Daroussinmanually. It is a good idea to carefully check the resulting code anyway to
1964*2fd5d190SBaptiste Daroussinmake sure that it really does what you want it to; depending on how the input
1965*2fd5d190SBaptiste Daroussinfiles were produced, the output might contain duplicate or otherwise incorrect
1966*2fd5d190SBaptiste Daroussincode.
1967*2fd5d190SBaptiste Daroussin.Pp
1968*2fd5d190SBaptiste DaroussinThe
1969*2fd5d190SBaptiste Daroussin.Xr patch
1970*2fd5d190SBaptiste Daroussin.Op -D Va name
1971*2fd5d190SBaptiste Daroussinoption behaves like the
1972*2fd5d190SBaptiste Daroussin.Xr diff
1973*2fd5d190SBaptiste Daroussin.Op -D Va name
1974*2fd5d190SBaptiste Daroussinoption, except it operates on a file and a diff to produce a merged file;See Section
1975*2fd5d190SBaptiste Daroussin.Dq patch Options .
1976*2fd5d190SBaptiste Daroussin.Pp
1977*2fd5d190SBaptiste Daroussin.Sh  Incomplete Lines
1978*2fd5d190SBaptiste DaroussinWhen an input file ends in a non-newline character, its last line is called
1979*2fd5d190SBaptiste Daroussinan
1980*2fd5d190SBaptiste Daroussin.Em incomplete line
1981*2fd5d190SBaptiste Daroussinbecause its last character is not a newline. All other lines are called
1982*2fd5d190SBaptiste Daroussin.Em full lines
1983*2fd5d190SBaptiste Daroussinand end in a newline character. Incomplete lines do not match full lines unless
1984*2fd5d190SBaptiste Daroussindifferences in white space are ignored (see Section
1985*2fd5d190SBaptiste Daroussin.Dq White Space ) .
1986*2fd5d190SBaptiste Daroussin.Pp
1987*2fd5d190SBaptiste DaroussinAn incomplete line is normally distinguished on output from a full line by
1988*2fd5d190SBaptiste Daroussina following line that starts with
1989*2fd5d190SBaptiste Daroussin.Li \e .
1990*2fd5d190SBaptiste DaroussinHowever, the RCS format (see Section
1991*2fd5d190SBaptiste Daroussin.Dq RCS )
1992*2fd5d190SBaptiste Daroussinoutputs the incomplete line as-is, without any trailing newline or following
1993*2fd5d190SBaptiste Daroussinline. The side by side format normally represents incomplete lines as-is,
1994*2fd5d190SBaptiste Daroussinbut in some cases uses a
1995*2fd5d190SBaptiste Daroussin.Li \e
1996*2fd5d190SBaptiste Daroussinor
1997*2fd5d190SBaptiste Daroussin.Li /
1998*2fd5d190SBaptiste Daroussingutter marker;See Section
1999*2fd5d190SBaptiste Daroussin.Dq Side by Side .
2000*2fd5d190SBaptiste DaroussinThe if-then-else line format preserves a line's incompleteness with
2001*2fd5d190SBaptiste Daroussin.Li %L ,
2002*2fd5d190SBaptiste Daroussinand discards the newline with
2003*2fd5d190SBaptiste Daroussin.Li %l
2004*2fd5d190SBaptiste Daroussin;See Section
2005*2fd5d190SBaptiste Daroussin.Dq Line Formats .
2006*2fd5d190SBaptiste DaroussinFinally, with the
2007*2fd5d190SBaptiste Daroussin.Xr ed
2008*2fd5d190SBaptiste Daroussinand forward
2009*2fd5d190SBaptiste Daroussin.Xr ed
2010*2fd5d190SBaptiste Daroussinoutput formats (see Section
2011*2fd5d190SBaptiste Daroussin.Dq Output Formats )
2012*2fd5d190SBaptiste Daroussin.Xr diff
2013*2fd5d190SBaptiste Daroussincannot represent an incomplete line, so it pretends there was a newline and
2014*2fd5d190SBaptiste Daroussinreports an error.
2015*2fd5d190SBaptiste Daroussin.Pp
2016*2fd5d190SBaptiste DaroussinFor example, suppose
2017*2fd5d190SBaptiste Daroussin.Pa F
2018*2fd5d190SBaptiste Daroussinand
2019*2fd5d190SBaptiste Daroussin.Pa G
2020*2fd5d190SBaptiste Daroussinare one-byte files that contain just
2021*2fd5d190SBaptiste Daroussin.Li f
2022*2fd5d190SBaptiste Daroussinand
2023*2fd5d190SBaptiste Daroussin.Li g ,
2024*2fd5d190SBaptiste Daroussinrespectively. Then
2025*2fd5d190SBaptiste Daroussin.Li diff F G
2026*2fd5d190SBaptiste Daroussinoutputs
2027*2fd5d190SBaptiste Daroussin.Pp
2028*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
2029*2fd5d190SBaptiste Daroussin1c1
2030*2fd5d190SBaptiste Daroussin< f
2031*2fd5d190SBaptiste Daroussin\e No newline at end of file
2032*2fd5d190SBaptiste Daroussin---
2033*2fd5d190SBaptiste Daroussin> g
2034*2fd5d190SBaptiste Daroussin\e No newline at end of file
2035*2fd5d190SBaptiste Daroussin.Ed
2036*2fd5d190SBaptiste Daroussin.Pp
2037*2fd5d190SBaptiste Daroussin(The exact message may differ in non-English locales.)
2038*2fd5d190SBaptiste Daroussin.Li diff -n F G
2039*2fd5d190SBaptiste Daroussinoutputs the following without a trailing newline:
2040*2fd5d190SBaptiste Daroussin.Pp
2041*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
2042*2fd5d190SBaptiste Daroussind1 1
2043*2fd5d190SBaptiste Daroussina1 1
2044*2fd5d190SBaptiste Daroussing
2045*2fd5d190SBaptiste Daroussin.Ed
2046*2fd5d190SBaptiste Daroussin.Pp
2047*2fd5d190SBaptiste Daroussin.Li diff -e F G
2048*2fd5d190SBaptiste Daroussinreports two errors and outputs the following:
2049*2fd5d190SBaptiste Daroussin.Pp
2050*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
2051*2fd5d190SBaptiste Daroussin1c
2052*2fd5d190SBaptiste Daroussing
2053*2fd5d190SBaptiste Daroussin\&.
2054*2fd5d190SBaptiste Daroussin.Ed
2055*2fd5d190SBaptiste Daroussin.Pp
2056*2fd5d190SBaptiste Daroussin.Sh  Comparing Directories
2057*2fd5d190SBaptiste DaroussinYou can use
2058*2fd5d190SBaptiste Daroussin.Xr diff
2059*2fd5d190SBaptiste Daroussinto compare some or all of the files in two directory trees. When both file
2060*2fd5d190SBaptiste Daroussinname arguments to
2061*2fd5d190SBaptiste Daroussin.Xr diff
2062*2fd5d190SBaptiste Daroussinare directories, it compares each file that is contained in both directories,
2063*2fd5d190SBaptiste Daroussinexamining file names in alphabetical order as specified by the
2064*2fd5d190SBaptiste Daroussin.Ev LC_COLLATE
2065*2fd5d190SBaptiste Daroussinlocale category. Normally
2066*2fd5d190SBaptiste Daroussin.Xr diff
2067*2fd5d190SBaptiste Daroussinis silent about pairs of files that contain no differences, but if you use
2068*2fd5d190SBaptiste Daroussinthe
2069*2fd5d190SBaptiste Daroussin.Op -s
2070*2fd5d190SBaptiste Daroussinor
2071*2fd5d190SBaptiste Daroussin.Op --report-identical-files
2072*2fd5d190SBaptiste Daroussinoption, it reports pairs of identical files. Normally
2073*2fd5d190SBaptiste Daroussin.Xr diff
2074*2fd5d190SBaptiste Daroussinreports subdirectories common to both directories without comparing subdirectories'
2075*2fd5d190SBaptiste Daroussinfiles, but if you use the
2076*2fd5d190SBaptiste Daroussin.Op -r
2077*2fd5d190SBaptiste Daroussinor
2078*2fd5d190SBaptiste Daroussin.Op --recursive
2079*2fd5d190SBaptiste Daroussinoption, it compares every corresponding pair of files in the directory trees,
2080*2fd5d190SBaptiste Daroussinas many levels deep as they go.
2081*2fd5d190SBaptiste Daroussin.Pp
2082*2fd5d190SBaptiste DaroussinFor file names that are in only one of the directories,
2083*2fd5d190SBaptiste Daroussin.Xr diff
2084*2fd5d190SBaptiste Daroussinnormally does not show the contents of the file that exists; it reports only
2085*2fd5d190SBaptiste Daroussinthat the file exists in that directory and not in the other. You can make
2086*2fd5d190SBaptiste Daroussin.Xr diff
2087*2fd5d190SBaptiste Daroussinact as though the file existed but was empty in the other directory, so that
2088*2fd5d190SBaptiste Daroussinit outputs the entire contents of the file that actually exists. (It is output
2089*2fd5d190SBaptiste Daroussinas either an insertion or a deletion, depending on whether it is in the first
2090*2fd5d190SBaptiste Daroussinor the second directory given.) To do this, use the
2091*2fd5d190SBaptiste Daroussin.Op -N
2092*2fd5d190SBaptiste Daroussinor
2093*2fd5d190SBaptiste Daroussin.Op --new-file
2094*2fd5d190SBaptiste Daroussinoption.
2095*2fd5d190SBaptiste Daroussin.Pp
2096*2fd5d190SBaptiste DaroussinIf the older directory contains one or more large files that are not in the
2097*2fd5d190SBaptiste Daroussinnewer directory, you can make the patch smaller by using the
2098*2fd5d190SBaptiste Daroussin.Op --unidirectional-new-file
2099*2fd5d190SBaptiste Daroussinoption instead of
2100*2fd5d190SBaptiste Daroussin.Op -N .
2101*2fd5d190SBaptiste DaroussinThis option is like
2102*2fd5d190SBaptiste Daroussin.Op -N
2103*2fd5d190SBaptiste Daroussinexcept that it only inserts the contents of files that appear in the second
2104*2fd5d190SBaptiste Daroussindirectory but not the first (that is, files that were added). At the top of
2105*2fd5d190SBaptiste Daroussinthe patch, write instructions for the user applying the patch to remove the
2106*2fd5d190SBaptiste Daroussinfiles that were deleted before applying the patch.See Section
2107*2fd5d190SBaptiste Daroussin.Dq Making Patches ,
2108*2fd5d190SBaptiste Daroussinfor more discussion of making patches for distribution.
2109*2fd5d190SBaptiste Daroussin.Pp
2110*2fd5d190SBaptiste DaroussinTo ignore some files while comparing directories, use the
2111*2fd5d190SBaptiste Daroussin.Op -x Va pattern
2112*2fd5d190SBaptiste Daroussinor
2113*2fd5d190SBaptiste Daroussin.Op --exclude= Va pattern
2114*2fd5d190SBaptiste Daroussinoption. This option ignores any files or subdirectories whose base names match
2115*2fd5d190SBaptiste Daroussinthe shell pattern
2116*2fd5d190SBaptiste Daroussin.Va pattern .
2117*2fd5d190SBaptiste DaroussinUnlike in the shell, a period at the start of the base of a file name matches
2118*2fd5d190SBaptiste Daroussina wildcard at the start of a pattern. You should enclose
2119*2fd5d190SBaptiste Daroussin.Va pattern
2120*2fd5d190SBaptiste Daroussinin quotes so that the shell does not expand it. For example, the option
2121*2fd5d190SBaptiste Daroussin.Op -x '*.[ao]'
2122*2fd5d190SBaptiste Daroussinignores any file whose name ends with
2123*2fd5d190SBaptiste Daroussin.Li .a
2124*2fd5d190SBaptiste Daroussinor
2125*2fd5d190SBaptiste Daroussin.Li .o .
2126*2fd5d190SBaptiste Daroussin.Pp
2127*2fd5d190SBaptiste DaroussinThis option accumulates if you specify it more than once. For example, using
2128*2fd5d190SBaptiste Daroussinthe options
2129*2fd5d190SBaptiste Daroussin.Op -x 'RCS' -x '*,v'
2130*2fd5d190SBaptiste Daroussinignores any file or subdirectory whose base name is
2131*2fd5d190SBaptiste Daroussin.Li RCS
2132*2fd5d190SBaptiste Daroussinor ends with
2133*2fd5d190SBaptiste Daroussin.Li ,v .
2134*2fd5d190SBaptiste Daroussin.Pp
2135*2fd5d190SBaptiste DaroussinIf you need to give this option many times, you can instead put the patterns
2136*2fd5d190SBaptiste Daroussinin a file, one pattern per line, and use the
2137*2fd5d190SBaptiste Daroussin.Op -X Va file
2138*2fd5d190SBaptiste Daroussinor
2139*2fd5d190SBaptiste Daroussin.Op --exclude-from= Va file
2140*2fd5d190SBaptiste Daroussinoption. Trailing white space and empty lines are ignored in the pattern file.
2141*2fd5d190SBaptiste Daroussin.Pp
2142*2fd5d190SBaptiste DaroussinIf you have been comparing two directories and stopped partway through, later
2143*2fd5d190SBaptiste Daroussinyou might want to continue where you left off. You can do this by using the
2144*2fd5d190SBaptiste Daroussin.Op -S Va file
2145*2fd5d190SBaptiste Daroussinor
2146*2fd5d190SBaptiste Daroussin.Op --starting-file= Va file
2147*2fd5d190SBaptiste Daroussinoption. This compares only the file
2148*2fd5d190SBaptiste Daroussin.Va file
2149*2fd5d190SBaptiste Daroussinand all alphabetically later files in the topmost directory level.
2150*2fd5d190SBaptiste Daroussin.Pp
2151*2fd5d190SBaptiste DaroussinIf two directories differ only in that file names are lower case in one directory
2152*2fd5d190SBaptiste Daroussinand upper case in the upper,
2153*2fd5d190SBaptiste Daroussin.Xr diff
2154*2fd5d190SBaptiste Daroussinnormally reports many differences because it compares file names in a case
2155*2fd5d190SBaptiste Daroussinsensitive way. With the
2156*2fd5d190SBaptiste Daroussin.Op --ignore-file-name-case
2157*2fd5d190SBaptiste Daroussinoption,
2158*2fd5d190SBaptiste Daroussin.Xr diff
2159*2fd5d190SBaptiste Daroussinignores case differences in file names, so that for example the contents of
2160*2fd5d190SBaptiste Daroussinthe file
2161*2fd5d190SBaptiste Daroussin.Pa Tao
2162*2fd5d190SBaptiste Daroussinin one directory are compared to the contents of the file
2163*2fd5d190SBaptiste Daroussin.Pa TAO
2164*2fd5d190SBaptiste Daroussinin the other. The
2165*2fd5d190SBaptiste Daroussin.Op --no-ignore-file-name-case
2166*2fd5d190SBaptiste Daroussinoption cancels the effect of the
2167*2fd5d190SBaptiste Daroussin.Op --ignore-file-name-case
2168*2fd5d190SBaptiste Daroussinoption, reverting to the default behavior.
2169*2fd5d190SBaptiste Daroussin.Pp
2170*2fd5d190SBaptiste DaroussinIf an
2171*2fd5d190SBaptiste Daroussin.Op -x Va pattern
2172*2fd5d190SBaptiste Daroussinor
2173*2fd5d190SBaptiste Daroussin.Op --exclude= Va pattern
2174*2fd5d190SBaptiste Daroussinoption, or an
2175*2fd5d190SBaptiste Daroussin.Op -X Va file
2176*2fd5d190SBaptiste Daroussinor
2177*2fd5d190SBaptiste Daroussin.Op --exclude-from= Va file
2178*2fd5d190SBaptiste Daroussinoption, is specified while the
2179*2fd5d190SBaptiste Daroussin.Op --ignore-file-name-case
2180*2fd5d190SBaptiste Daroussinoption is in effect, case is ignored when excluding file names matching the
2181*2fd5d190SBaptiste Daroussinspecified patterns.
2182*2fd5d190SBaptiste Daroussin.Pp
2183*2fd5d190SBaptiste Daroussin.Sh  Making Xr diff Output Prettier
2184*2fd5d190SBaptiste Daroussin.Xr diff
2185*2fd5d190SBaptiste Daroussinprovides several ways to adjust the appearance of its output. These adjustments
2186*2fd5d190SBaptiste Daroussincan be applied to any output format.
2187*2fd5d190SBaptiste Daroussin.Pp
2188*2fd5d190SBaptiste Daroussin.Ss  Preserving Tab Stop Alignment
2189*2fd5d190SBaptiste DaroussinThe lines of text in some of the
2190*2fd5d190SBaptiste Daroussin.Xr diff
2191*2fd5d190SBaptiste Daroussinoutput formats are preceded by one or two characters that indicate whether
2192*2fd5d190SBaptiste Daroussinthe text is inserted, deleted, or changed. The addition of those characters
2193*2fd5d190SBaptiste Daroussincan cause tabs to move to the next tab stop, throwing off the alignment of
2194*2fd5d190SBaptiste Daroussincolumns in the line. GNU
2195*2fd5d190SBaptiste Daroussin.Xr diff
2196*2fd5d190SBaptiste Daroussinprovides two ways to make tab-aligned columns line up correctly.
2197*2fd5d190SBaptiste Daroussin.Pp
2198*2fd5d190SBaptiste DaroussinThe first way is to have
2199*2fd5d190SBaptiste Daroussin.Xr diff
2200*2fd5d190SBaptiste Daroussinconvert all tabs into the correct number of spaces before outputting them;
2201*2fd5d190SBaptiste Daroussinselect this method with the
2202*2fd5d190SBaptiste Daroussin.Op -t
2203*2fd5d190SBaptiste Daroussinor
2204*2fd5d190SBaptiste Daroussin.Op --expand-tabs
2205*2fd5d190SBaptiste Daroussinoption. To use this form of output with
2206*2fd5d190SBaptiste Daroussin.Xr patch ,
2207*2fd5d190SBaptiste Daroussinyou must give
2208*2fd5d190SBaptiste Daroussin.Xr patch
2209*2fd5d190SBaptiste Daroussinthe
2210*2fd5d190SBaptiste Daroussin.Op -l
2211*2fd5d190SBaptiste Daroussinor
2212*2fd5d190SBaptiste Daroussin.Op --ignore-white-space
2213*2fd5d190SBaptiste Daroussinoption (see Section
2214*2fd5d190SBaptiste Daroussin.Dq Changed White Space ,
2215*2fd5d190SBaptiste Daroussinfor more information).
2216*2fd5d190SBaptiste Daroussin.Xr diff
2217*2fd5d190SBaptiste Daroussinnormally assumes that tab stops are set every 8 print columns, but this can
2218*2fd5d190SBaptiste Daroussinbe altered by the
2219*2fd5d190SBaptiste Daroussin.Op --tabsize= Va columns
2220*2fd5d190SBaptiste Daroussinoption.
2221*2fd5d190SBaptiste Daroussin.Pp
2222*2fd5d190SBaptiste DaroussinThe other method for making tabs line up correctly is to add a tab character
2223*2fd5d190SBaptiste Daroussininstead of a space after the indicator character at the beginning of the line.
2224*2fd5d190SBaptiste DaroussinThis ensures that all following tab characters are in the same position relative
2225*2fd5d190SBaptiste Daroussinto tab stops that they were in the original files, so that the output is aligned
2226*2fd5d190SBaptiste Daroussincorrectly. Its disadvantage is that it can make long lines too long to fit
2227*2fd5d190SBaptiste Daroussinon one line of the screen or the paper. It also does not work with the unified
2228*2fd5d190SBaptiste Daroussinoutput format, which does not have a space character after the change type
2229*2fd5d190SBaptiste Daroussinindicator character. Select this method with the
2230*2fd5d190SBaptiste Daroussin.Op -T
2231*2fd5d190SBaptiste Daroussinor
2232*2fd5d190SBaptiste Daroussin.Op --initial-tab
2233*2fd5d190SBaptiste Daroussinoption.
2234*2fd5d190SBaptiste Daroussin.Pp
2235*2fd5d190SBaptiste Daroussin.Ss  Paginating Xr diff Output
2236*2fd5d190SBaptiste DaroussinIt can be convenient to have long output page-numbered and time-stamped. The
2237*2fd5d190SBaptiste Daroussin.Op -l
2238*2fd5d190SBaptiste Daroussinor
2239*2fd5d190SBaptiste Daroussin.Op --paginate
2240*2fd5d190SBaptiste Daroussinoption does this by sending the
2241*2fd5d190SBaptiste Daroussin.Xr diff
2242*2fd5d190SBaptiste Daroussinoutput through the
2243*2fd5d190SBaptiste Daroussin.Xr pr
2244*2fd5d190SBaptiste Daroussinprogram. Here is what the page header might look like for
2245*2fd5d190SBaptiste Daroussin.Li diff -lc lao tzu :
2246*2fd5d190SBaptiste Daroussin.Pp
2247*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
2248*2fd5d190SBaptiste Daroussin2002-02-22 14:20                 diff -lc lao tzu                 Page 1
2249*2fd5d190SBaptiste Daroussin.Ed
2250*2fd5d190SBaptiste Daroussin.Pp
2251*2fd5d190SBaptiste Daroussin.Sh  Xr diff Performance Tradeoffs
2252*2fd5d190SBaptiste DaroussinGNU
2253*2fd5d190SBaptiste Daroussin.Xr diff
2254*2fd5d190SBaptiste Daroussinruns quite efficiently; however, in some circumstances you can cause it to
2255*2fd5d190SBaptiste Daroussinrun faster or produce a more compact set of changes.
2256*2fd5d190SBaptiste Daroussin.Pp
2257*2fd5d190SBaptiste DaroussinOne way to improve
2258*2fd5d190SBaptiste Daroussin.Xr diff
2259*2fd5d190SBaptiste Daroussinperformance is to use hard or symbolic links to files instead of copies. This
2260*2fd5d190SBaptiste Daroussinimproves performance because
2261*2fd5d190SBaptiste Daroussin.Xr diff
2262*2fd5d190SBaptiste Daroussinnormally does not need to read two hard or symbolic links to the same file,
2263*2fd5d190SBaptiste Daroussinsince their contents must be identical. For example, suppose you copy a large
2264*2fd5d190SBaptiste Daroussindirectory hierarchy, make a few changes to the copy, and then often use
2265*2fd5d190SBaptiste Daroussin.Li diff -r
2266*2fd5d190SBaptiste Daroussinto compare the original to the copy. If the original files are read-only,
2267*2fd5d190SBaptiste Daroussinyou can greatly improve performance by creating the copy using hard or symbolic
2268*2fd5d190SBaptiste Daroussinlinks (e.g., with GNU
2269*2fd5d190SBaptiste Daroussin.Li cp -lR
2270*2fd5d190SBaptiste Daroussinor
2271*2fd5d190SBaptiste Daroussin.Li cp -sR ) .
2272*2fd5d190SBaptiste DaroussinBefore editing a file in the copy for the first time, you should break the
2273*2fd5d190SBaptiste Daroussinlink and replace it with a regular copy.
2274*2fd5d190SBaptiste Daroussin.Pp
2275*2fd5d190SBaptiste DaroussinYou can also affect the performance of GNU
2276*2fd5d190SBaptiste Daroussin.Xr diff
2277*2fd5d190SBaptiste Daroussinby giving it options that change the way it compares files. Performance has
2278*2fd5d190SBaptiste Daroussinmore than one dimension. These options improve one aspect of performance at
2279*2fd5d190SBaptiste Daroussinthe cost of another, or they improve performance in some cases while hurting
2280*2fd5d190SBaptiste Daroussinit in others.
2281*2fd5d190SBaptiste Daroussin.Pp
2282*2fd5d190SBaptiste DaroussinThe way that GNU
2283*2fd5d190SBaptiste Daroussin.Xr diff
2284*2fd5d190SBaptiste Daroussindetermines which lines have changed always comes up with a near-minimal set
2285*2fd5d190SBaptiste Daroussinof differences. Usually it is good enough for practical purposes. If the
2286*2fd5d190SBaptiste Daroussin.Xr diff
2287*2fd5d190SBaptiste Daroussinoutput is large, you might want
2288*2fd5d190SBaptiste Daroussin.Xr diff
2289*2fd5d190SBaptiste Daroussinto use a modified algorithm that sometimes produces a smaller set of differences.
2290*2fd5d190SBaptiste DaroussinThe
2291*2fd5d190SBaptiste Daroussin.Op -d
2292*2fd5d190SBaptiste Daroussinor
2293*2fd5d190SBaptiste Daroussin.Op --minimal
2294*2fd5d190SBaptiste Daroussinoption does this; however, it can also cause
2295*2fd5d190SBaptiste Daroussin.Xr diff
2296*2fd5d190SBaptiste Daroussinto run more slowly than usual, so it is not the default behavior.
2297*2fd5d190SBaptiste Daroussin.Pp
2298*2fd5d190SBaptiste DaroussinWhen the files you are comparing are large and have small groups of changes
2299*2fd5d190SBaptiste Daroussinscattered throughout them, you can use the
2300*2fd5d190SBaptiste Daroussin.Op --speed-large-files
2301*2fd5d190SBaptiste Daroussinoption to make a different modification to the algorithm that
2302*2fd5d190SBaptiste Daroussin.Xr diff
2303*2fd5d190SBaptiste Daroussinuses. If the input files have a constant small density of changes, this option
2304*2fd5d190SBaptiste Daroussinspeeds up the comparisons without changing the output. If not,
2305*2fd5d190SBaptiste Daroussin.Xr diff
2306*2fd5d190SBaptiste Daroussinmight produce a larger set of differences; however, the output will still
2307*2fd5d190SBaptiste Daroussinbe correct.
2308*2fd5d190SBaptiste Daroussin.Pp
2309*2fd5d190SBaptiste DaroussinNormally
2310*2fd5d190SBaptiste Daroussin.Xr diff
2311*2fd5d190SBaptiste Daroussindiscards the prefix and suffix that is common to both files before it attempts
2312*2fd5d190SBaptiste Daroussinto find a minimal set of differences. This makes
2313*2fd5d190SBaptiste Daroussin.Xr diff
2314*2fd5d190SBaptiste Daroussinrun faster, but occasionally it may produce non-minimal output. The
2315*2fd5d190SBaptiste Daroussin.Op --horizon-lines= Va lines
2316*2fd5d190SBaptiste Daroussinoption prevents
2317*2fd5d190SBaptiste Daroussin.Xr diff
2318*2fd5d190SBaptiste Daroussinfrom discarding the last
2319*2fd5d190SBaptiste Daroussin.Va lines
2320*2fd5d190SBaptiste Daroussinlines of the prefix and the first
2321*2fd5d190SBaptiste Daroussin.Va lines
2322*2fd5d190SBaptiste Daroussinlines of the suffix. This gives
2323*2fd5d190SBaptiste Daroussin.Xr diff
2324*2fd5d190SBaptiste Daroussinfurther opportunities to find a minimal output.
2325*2fd5d190SBaptiste Daroussin.Pp
2326*2fd5d190SBaptiste DaroussinSuppose a run of changed lines includes a sequence of lines at one end and
2327*2fd5d190SBaptiste Daroussinthere is an identical sequence of lines just outside the other end. The
2328*2fd5d190SBaptiste Daroussin.Xr diff
2329*2fd5d190SBaptiste Daroussincommand is free to choose which identical sequence is included in the hunk.
2330*2fd5d190SBaptiste DaroussinIn this case,
2331*2fd5d190SBaptiste Daroussin.Xr diff
2332*2fd5d190SBaptiste Daroussinnormally shifts the hunk's boundaries when this merges adjacent hunks, or
2333*2fd5d190SBaptiste Daroussinshifts a hunk's lines towards the end of the file. Merging hunks can make
2334*2fd5d190SBaptiste Daroussinthe output look nicer in some cases.
2335*2fd5d190SBaptiste Daroussin.Pp
2336*2fd5d190SBaptiste Daroussin.Sh  Comparing Three Files
2337*2fd5d190SBaptiste DaroussinUse the program
2338*2fd5d190SBaptiste Daroussin.Xr diff3
2339*2fd5d190SBaptiste Daroussinto compare three files and show any differences among them. (
2340*2fd5d190SBaptiste Daroussin.Xr diff3
2341*2fd5d190SBaptiste Daroussincan also merge files; see diff3 Merging).
2342*2fd5d190SBaptiste Daroussin.Pp
2343*2fd5d190SBaptiste DaroussinThe \(lqnormal\(rq
2344*2fd5d190SBaptiste Daroussin.Xr diff3
2345*2fd5d190SBaptiste Daroussinoutput format shows each hunk of differences without surrounding context.
2346*2fd5d190SBaptiste DaroussinHunks are labeled depending on whether they are two-way or three-way, and
2347*2fd5d190SBaptiste Daroussinlines are annotated by their location in the input files.
2348*2fd5d190SBaptiste Daroussin.Pp
2349*2fd5d190SBaptiste DaroussinSee Section.Dq Invoking diff3 ,
2350*2fd5d190SBaptiste Daroussinfor more information on how to run
2351*2fd5d190SBaptiste Daroussin.Xr diff3 .
2352*2fd5d190SBaptiste Daroussin.Pp
2353*2fd5d190SBaptiste Daroussin.Ss  A Third Sample Input File
2354*2fd5d190SBaptiste DaroussinHere is a third sample file that will be used in examples to illustrate the
2355*2fd5d190SBaptiste Daroussinoutput of
2356*2fd5d190SBaptiste Daroussin.Xr diff3
2357*2fd5d190SBaptiste Daroussinand how various options can change it. The first two files are the same that
2358*2fd5d190SBaptiste Daroussinwe used for
2359*2fd5d190SBaptiste Daroussin.Xr diff
2360*2fd5d190SBaptiste Daroussin(see Section
2361*2fd5d190SBaptiste Daroussin.Dq Sample diff Input ) .
2362*2fd5d190SBaptiste DaroussinThis is the third sample file, called
2363*2fd5d190SBaptiste Daroussin.Pa tao :
2364*2fd5d190SBaptiste Daroussin.Pp
2365*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
2366*2fd5d190SBaptiste DaroussinThe Way that can be told of is not the eternal Way;
2367*2fd5d190SBaptiste DaroussinThe name that can be named is not the eternal name.
2368*2fd5d190SBaptiste DaroussinThe Nameless is the origin of Heaven and Earth;
2369*2fd5d190SBaptiste DaroussinThe named is the mother of all things.
2370*2fd5d190SBaptiste Daroussin
2371*2fd5d190SBaptiste DaroussinTherefore let there always be non-being,
2372*2fd5d190SBaptiste Daroussin  so we may see their subtlety,
2373*2fd5d190SBaptiste DaroussinAnd let there always be being,
2374*2fd5d190SBaptiste Daroussin  so we may see their result.
2375*2fd5d190SBaptiste DaroussinThe two are the same,
2376*2fd5d190SBaptiste DaroussinBut after they are produced,
2377*2fd5d190SBaptiste Daroussin  they have different names.
2378*2fd5d190SBaptiste Daroussin
2379*2fd5d190SBaptiste Daroussin  -- The Way of Lao-Tzu, tr. Wing-tsit Chan
2380*2fd5d190SBaptiste Daroussin.Ed
2381*2fd5d190SBaptiste Daroussin.Pp
2382*2fd5d190SBaptiste Daroussin.Ss  An Example of Xr diff3 Normal Format
2383*2fd5d190SBaptiste DaroussinHere is the output of the command
2384*2fd5d190SBaptiste Daroussin.Li diff3 lao tzu tao
2385*2fd5d190SBaptiste Daroussin(see Section
2386*2fd5d190SBaptiste Daroussin.Dq Sample diff3 Input ,
2387*2fd5d190SBaptiste Daroussinfor the complete contents of the files). Notice that it shows only the lines
2388*2fd5d190SBaptiste Daroussinthat are different among the three files.
2389*2fd5d190SBaptiste Daroussin.Pp
2390*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
2391*2fd5d190SBaptiste Daroussin====2
2392*2fd5d190SBaptiste Daroussin1:1,2c
2393*2fd5d190SBaptiste Daroussin3:1,2c
2394*2fd5d190SBaptiste Daroussin  The Way that can be told of is not the eternal Way;
2395*2fd5d190SBaptiste Daroussin  The name that can be named is not the eternal name.
2396*2fd5d190SBaptiste Daroussin2:0a
2397*2fd5d190SBaptiste Daroussin====1
2398*2fd5d190SBaptiste Daroussin1:4c
2399*2fd5d190SBaptiste Daroussin  The Named is the mother of all things.
2400*2fd5d190SBaptiste Daroussin2:2,3c
2401*2fd5d190SBaptiste Daroussin3:4,5c
2402*2fd5d190SBaptiste Daroussin  The named is the mother of all things.
2403*2fd5d190SBaptiste Daroussin
2404*2fd5d190SBaptiste Daroussin====3
2405*2fd5d190SBaptiste Daroussin1:8c
2406*2fd5d190SBaptiste Daroussin2:7c
2407*2fd5d190SBaptiste Daroussin    so we may see their outcome.
2408*2fd5d190SBaptiste Daroussin3:9c
2409*2fd5d190SBaptiste Daroussin    so we may see their result.
2410*2fd5d190SBaptiste Daroussin====
2411*2fd5d190SBaptiste Daroussin1:11a
2412*2fd5d190SBaptiste Daroussin2:11,13c
2413*2fd5d190SBaptiste Daroussin  They both may be called deep and profound.
2414*2fd5d190SBaptiste Daroussin  Deeper and more profound,
2415*2fd5d190SBaptiste Daroussin  The door of all subtleties!
2416*2fd5d190SBaptiste Daroussin3:13,14c
2417*2fd5d190SBaptiste Daroussin
2418*2fd5d190SBaptiste Daroussin    -- The Way of Lao-Tzu, tr. Wing-tsit Chan
2419*2fd5d190SBaptiste Daroussin.Ed
2420*2fd5d190SBaptiste Daroussin.Pp
2421*2fd5d190SBaptiste Daroussin.Ss  Detailed Description of Xr diff3 Normal Format
2422*2fd5d190SBaptiste DaroussinEach hunk begins with a line marked
2423*2fd5d190SBaptiste Daroussin.Li ==== .
2424*2fd5d190SBaptiste DaroussinThree-way hunks have plain
2425*2fd5d190SBaptiste Daroussin.Li ====
2426*2fd5d190SBaptiste Daroussinlines, and two-way hunks have
2427*2fd5d190SBaptiste Daroussin.Li 1 ,
2428*2fd5d190SBaptiste Daroussin.Li 2 ,
2429*2fd5d190SBaptiste Daroussinor
2430*2fd5d190SBaptiste Daroussin.Li 3
2431*2fd5d190SBaptiste Daroussinappended to specify which of the three input files differ in that hunk. The
2432*2fd5d190SBaptiste Daroussinhunks contain copies of two or three sets of input lines each preceded by
2433*2fd5d190SBaptiste Daroussinone or two commands identifying where the lines came from.
2434*2fd5d190SBaptiste Daroussin.Pp
2435*2fd5d190SBaptiste DaroussinNormally, two spaces precede each copy of an input line to distinguish it
2436*2fd5d190SBaptiste Daroussinfrom the commands. But with the
2437*2fd5d190SBaptiste Daroussin.Op -T
2438*2fd5d190SBaptiste Daroussinor
2439*2fd5d190SBaptiste Daroussin.Op --initial-tab
2440*2fd5d190SBaptiste Daroussinoption,
2441*2fd5d190SBaptiste Daroussin.Xr diff3
2442*2fd5d190SBaptiste Daroussinuses a tab instead of two spaces; this lines up tabs correctly.See Section
2443*2fd5d190SBaptiste Daroussin.Dq Tabs ,
2444*2fd5d190SBaptiste Daroussinfor more information.
2445*2fd5d190SBaptiste Daroussin.Pp
2446*2fd5d190SBaptiste DaroussinCommands take the following forms:
2447*2fd5d190SBaptiste Daroussin.Pp
2448*2fd5d190SBaptiste Daroussin.Bl -tag -width Ds
2449*2fd5d190SBaptiste Daroussin.It  Va file: Va la
2450*2fd5d190SBaptiste DaroussinThis hunk appears after line
2451*2fd5d190SBaptiste Daroussin.Va l
2452*2fd5d190SBaptiste Daroussinof file
2453*2fd5d190SBaptiste Daroussin.Va file ,
2454*2fd5d190SBaptiste Daroussinand contains no lines in that file. To edit this file to yield the other files,
2455*2fd5d190SBaptiste Daroussinone must append hunk lines taken from the other files. For example,
2456*2fd5d190SBaptiste Daroussin.Li 1:11a
2457*2fd5d190SBaptiste Daroussinmeans that the hunk follows line 11 in the first file and contains no lines
2458*2fd5d190SBaptiste Daroussinfrom that file.
2459*2fd5d190SBaptiste Daroussin.Pp
2460*2fd5d190SBaptiste Daroussin.It  Va file: Va rc
2461*2fd5d190SBaptiste DaroussinThis hunk contains the lines in the range
2462*2fd5d190SBaptiste Daroussin.Va r
2463*2fd5d190SBaptiste Daroussinof file
2464*2fd5d190SBaptiste Daroussin.Va file .
2465*2fd5d190SBaptiste DaroussinThe range
2466*2fd5d190SBaptiste Daroussin.Va r
2467*2fd5d190SBaptiste Daroussinis a comma-separated pair of line numbers, or just one number if the range
2468*2fd5d190SBaptiste Daroussinis a singleton. To edit this file to yield the other files, one must change
2469*2fd5d190SBaptiste Daroussinthe specified lines to be the lines taken from the other files. For example,
2470*2fd5d190SBaptiste Daroussin.Li 2:11,13c
2471*2fd5d190SBaptiste Daroussinmeans that the hunk contains lines 11 through 13 from the second file.
2472*2fd5d190SBaptiste Daroussin.El
2473*2fd5d190SBaptiste Daroussin.Pp
2474*2fd5d190SBaptiste DaroussinIf the last line in a set of input lines is incomplete (see Section
2475*2fd5d190SBaptiste Daroussin.Dq Incomplete Lines ) ,
2476*2fd5d190SBaptiste Daroussinit is distinguished on output from a full line by a following line that starts
2477*2fd5d190SBaptiste Daroussinwith
2478*2fd5d190SBaptiste Daroussin.Li \e .
2479*2fd5d190SBaptiste Daroussin.Pp
2480*2fd5d190SBaptiste Daroussin.Ss  Xr diff3 Hunks
2481*2fd5d190SBaptiste DaroussinGroups of lines that differ in two or three of the input files are called
2482*2fd5d190SBaptiste Daroussin.Em diff3 hunks ,
2483*2fd5d190SBaptiste Daroussinby analogy with
2484*2fd5d190SBaptiste Daroussin.Xr diff
2485*2fd5d190SBaptiste Daroussinhunks (see Section
2486*2fd5d190SBaptiste Daroussin.Dq Hunks ) .
2487*2fd5d190SBaptiste DaroussinIf all three input files differ in a
2488*2fd5d190SBaptiste Daroussin.Xr diff3
2489*2fd5d190SBaptiste Daroussinhunk, the hunk is called a
2490*2fd5d190SBaptiste Daroussin.Em three-way hunk
2491*2fd5d190SBaptiste Daroussin; if just two input files differ, it is a
2492*2fd5d190SBaptiste Daroussin.Em two-way hunk .
2493*2fd5d190SBaptiste Daroussin.Pp
2494*2fd5d190SBaptiste DaroussinAs with
2495*2fd5d190SBaptiste Daroussin.Xr diff ,
2496*2fd5d190SBaptiste Daroussinseveral solutions are possible. When comparing the files
2497*2fd5d190SBaptiste Daroussin.Li A ,
2498*2fd5d190SBaptiste Daroussin.Li B ,
2499*2fd5d190SBaptiste Daroussinand
2500*2fd5d190SBaptiste Daroussin.Li C ,
2501*2fd5d190SBaptiste Daroussin.Xr diff3
2502*2fd5d190SBaptiste Daroussinnormally finds
2503*2fd5d190SBaptiste Daroussin.Xr diff3
2504*2fd5d190SBaptiste Daroussinhunks by merging the two-way hunks output by the two commands
2505*2fd5d190SBaptiste Daroussin.Li diff A B
2506*2fd5d190SBaptiste Daroussinand
2507*2fd5d190SBaptiste Daroussin.Li diff A C .
2508*2fd5d190SBaptiste DaroussinThis does not necessarily minimize the size of the output, but exceptions
2509*2fd5d190SBaptiste Daroussinshould be rare.
2510*2fd5d190SBaptiste Daroussin.Pp
2511*2fd5d190SBaptiste DaroussinFor example, suppose
2512*2fd5d190SBaptiste Daroussin.Pa F
2513*2fd5d190SBaptiste Daroussincontains the three lines
2514*2fd5d190SBaptiste Daroussin.Li a ,
2515*2fd5d190SBaptiste Daroussin.Li b ,
2516*2fd5d190SBaptiste Daroussin.Li f ,
2517*2fd5d190SBaptiste Daroussin.Pa G
2518*2fd5d190SBaptiste Daroussincontains the lines
2519*2fd5d190SBaptiste Daroussin.Li g ,
2520*2fd5d190SBaptiste Daroussin.Li b ,
2521*2fd5d190SBaptiste Daroussin.Li g ,
2522*2fd5d190SBaptiste Daroussinand
2523*2fd5d190SBaptiste Daroussin.Pa H
2524*2fd5d190SBaptiste Daroussincontains the lines
2525*2fd5d190SBaptiste Daroussin.Li a ,
2526*2fd5d190SBaptiste Daroussin.Li b ,
2527*2fd5d190SBaptiste Daroussin.Li h .
2528*2fd5d190SBaptiste Daroussin.Li diff3 F G H
2529*2fd5d190SBaptiste Daroussinmight output the following:
2530*2fd5d190SBaptiste Daroussin.Pp
2531*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
2532*2fd5d190SBaptiste Daroussin====2
2533*2fd5d190SBaptiste Daroussin1:1c
2534*2fd5d190SBaptiste Daroussin3:1c
2535*2fd5d190SBaptiste Daroussin  a
2536*2fd5d190SBaptiste Daroussin2:1c
2537*2fd5d190SBaptiste Daroussin  g
2538*2fd5d190SBaptiste Daroussin====
2539*2fd5d190SBaptiste Daroussin1:3c
2540*2fd5d190SBaptiste Daroussin  f
2541*2fd5d190SBaptiste Daroussin2:3c
2542*2fd5d190SBaptiste Daroussin  g
2543*2fd5d190SBaptiste Daroussin3:3c
2544*2fd5d190SBaptiste Daroussin  h
2545*2fd5d190SBaptiste Daroussin.Ed
2546*2fd5d190SBaptiste Daroussin.Pp
2547*2fd5d190SBaptiste Daroussinbecause it found a two-way hunk containing
2548*2fd5d190SBaptiste Daroussin.Li a
2549*2fd5d190SBaptiste Daroussinin the first and third files and
2550*2fd5d190SBaptiste Daroussin.Li g
2551*2fd5d190SBaptiste Daroussinin the second file, then the single line
2552*2fd5d190SBaptiste Daroussin.Li b
2553*2fd5d190SBaptiste Daroussincommon to all three files, then a three-way hunk containing the last line
2554*2fd5d190SBaptiste Daroussinof each file.
2555*2fd5d190SBaptiste Daroussin.Pp
2556*2fd5d190SBaptiste Daroussin.Sh  Merging From a Common Ancestor
2557*2fd5d190SBaptiste DaroussinWhen two people have made changes to copies of the same file,
2558*2fd5d190SBaptiste Daroussin.Xr diff3
2559*2fd5d190SBaptiste Daroussincan produce a merged output that contains both sets of changes together with
2560*2fd5d190SBaptiste Daroussinwarnings about conflicts.
2561*2fd5d190SBaptiste Daroussin.Pp
2562*2fd5d190SBaptiste DaroussinOne might imagine programs with names like
2563*2fd5d190SBaptiste Daroussin.Xr diff4
2564*2fd5d190SBaptiste Daroussinand
2565*2fd5d190SBaptiste Daroussin.Xr diff5
2566*2fd5d190SBaptiste Daroussinto compare more than three files simultaneously, but in practice the need
2567*2fd5d190SBaptiste Daroussinrarely arises. You can use
2568*2fd5d190SBaptiste Daroussin.Xr diff3
2569*2fd5d190SBaptiste Daroussinto merge three or more sets of changes to a file by merging two change sets
2570*2fd5d190SBaptiste Daroussinat a time.
2571*2fd5d190SBaptiste Daroussin.Pp
2572*2fd5d190SBaptiste Daroussin.Xr diff3
2573*2fd5d190SBaptiste Daroussincan incorporate changes from two modified versions into a common preceding
2574*2fd5d190SBaptiste Daroussinversion. This lets you merge the sets of changes represented by the two newer
2575*2fd5d190SBaptiste Daroussinfiles. Specify the common ancestor version as the second argument and the
2576*2fd5d190SBaptiste Daroussintwo newer versions as the first and third arguments, like this:
2577*2fd5d190SBaptiste Daroussin.Pp
2578*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
2579*2fd5d190SBaptiste Daroussindiff3 mine older yours
2580*2fd5d190SBaptiste Daroussin.Ed
2581*2fd5d190SBaptiste Daroussin.Pp
2582*2fd5d190SBaptiste DaroussinYou can remember the order of the arguments by noting that they are in alphabetical
2583*2fd5d190SBaptiste Daroussinorder.
2584*2fd5d190SBaptiste Daroussin.Pp
2585*2fd5d190SBaptiste DaroussinYou can think of this as subtracting
2586*2fd5d190SBaptiste Daroussin.Va older
2587*2fd5d190SBaptiste Daroussinfrom
2588*2fd5d190SBaptiste Daroussin.Va yours
2589*2fd5d190SBaptiste Daroussinand adding the result to
2590*2fd5d190SBaptiste Daroussin.Va mine ,
2591*2fd5d190SBaptiste Daroussinor as merging into
2592*2fd5d190SBaptiste Daroussin.Va mine
2593*2fd5d190SBaptiste Daroussinthe changes that would turn
2594*2fd5d190SBaptiste Daroussin.Va older
2595*2fd5d190SBaptiste Daroussininto
2596*2fd5d190SBaptiste Daroussin.Va yours .
2597*2fd5d190SBaptiste DaroussinThis merging is well-defined as long as
2598*2fd5d190SBaptiste Daroussin.Va mine
2599*2fd5d190SBaptiste Daroussinand
2600*2fd5d190SBaptiste Daroussin.Va older
2601*2fd5d190SBaptiste Daroussinmatch in the neighborhood of each such change. This fails to be true when
2602*2fd5d190SBaptiste Daroussinall three input files differ or when only
2603*2fd5d190SBaptiste Daroussin.Va older
2604*2fd5d190SBaptiste Daroussindiffers; we call this a
2605*2fd5d190SBaptiste Daroussin.Em conflict .
2606*2fd5d190SBaptiste DaroussinWhen all three input files differ, we call the conflict an
2607*2fd5d190SBaptiste Daroussin.Em overlap .
2608*2fd5d190SBaptiste Daroussin.Pp
2609*2fd5d190SBaptiste Daroussin.Xr diff3
2610*2fd5d190SBaptiste Daroussingives you several ways to handle overlaps and conflicts. You can omit overlaps
2611*2fd5d190SBaptiste Daroussinor conflicts, or select only overlaps, or mark conflicts with special
2612*2fd5d190SBaptiste Daroussin.Li <<<<<<<
2613*2fd5d190SBaptiste Daroussinand
2614*2fd5d190SBaptiste Daroussin.Li >>>>>>>
2615*2fd5d190SBaptiste Daroussinlines.
2616*2fd5d190SBaptiste Daroussin.Pp
2617*2fd5d190SBaptiste Daroussin.Xr diff3
2618*2fd5d190SBaptiste Daroussincan output the merge results as an
2619*2fd5d190SBaptiste Daroussin.Xr ed
2620*2fd5d190SBaptiste Daroussinscript that that can be applied to the first file to yield the merged output.
2621*2fd5d190SBaptiste DaroussinHowever, it is usually better to have
2622*2fd5d190SBaptiste Daroussin.Xr diff3
2623*2fd5d190SBaptiste Daroussingenerate the merged output directly; this bypasses some problems with
2624*2fd5d190SBaptiste Daroussin.Xr ed .
2625*2fd5d190SBaptiste Daroussin.Pp
2626*2fd5d190SBaptiste Daroussin.Ss  Selecting Which Changes to Incorporate
2627*2fd5d190SBaptiste DaroussinYou can select all unmerged changes from
2628*2fd5d190SBaptiste Daroussin.Va older
2629*2fd5d190SBaptiste Daroussinto
2630*2fd5d190SBaptiste Daroussin.Va yours
2631*2fd5d190SBaptiste Daroussinfor merging into
2632*2fd5d190SBaptiste Daroussin.Va mine
2633*2fd5d190SBaptiste Daroussinwith the
2634*2fd5d190SBaptiste Daroussin.Op -e
2635*2fd5d190SBaptiste Daroussinor
2636*2fd5d190SBaptiste Daroussin.Op --ed
2637*2fd5d190SBaptiste Daroussinoption. You can select only the nonoverlapping unmerged changes with
2638*2fd5d190SBaptiste Daroussin.Op -3
2639*2fd5d190SBaptiste Daroussinor
2640*2fd5d190SBaptiste Daroussin.Op --easy-only ,
2641*2fd5d190SBaptiste Daroussinand you can select only the overlapping changes with
2642*2fd5d190SBaptiste Daroussin.Op -x
2643*2fd5d190SBaptiste Daroussinor
2644*2fd5d190SBaptiste Daroussin.Op --overlap-only .
2645*2fd5d190SBaptiste Daroussin.Pp
2646*2fd5d190SBaptiste DaroussinThe
2647*2fd5d190SBaptiste Daroussin.Op -e ,
2648*2fd5d190SBaptiste Daroussin.Op -3
2649*2fd5d190SBaptiste Daroussinand
2650*2fd5d190SBaptiste Daroussin.Op -x
2651*2fd5d190SBaptiste Daroussinoptions select only
2652*2fd5d190SBaptiste Daroussin.Em unmerged changes ,
2653*2fd5d190SBaptiste Daroussini.e. changes where
2654*2fd5d190SBaptiste Daroussin.Va mine
2655*2fd5d190SBaptiste Daroussinand
2656*2fd5d190SBaptiste Daroussin.Va yours
2657*2fd5d190SBaptiste Daroussindiffer; they ignore changes from
2658*2fd5d190SBaptiste Daroussin.Va older
2659*2fd5d190SBaptiste Daroussinto
2660*2fd5d190SBaptiste Daroussin.Va yours
2661*2fd5d190SBaptiste Daroussinwhere
2662*2fd5d190SBaptiste Daroussin.Va mine
2663*2fd5d190SBaptiste Daroussinand
2664*2fd5d190SBaptiste Daroussin.Va yours
2665*2fd5d190SBaptiste Daroussinare identical, because they assume that such changes have already been merged.
2666*2fd5d190SBaptiste DaroussinIf this assumption is not a safe one, you can use the
2667*2fd5d190SBaptiste Daroussin.Op -A
2668*2fd5d190SBaptiste Daroussinor
2669*2fd5d190SBaptiste Daroussin.Op --show-all
2670*2fd5d190SBaptiste Daroussinoption (see Section
2671*2fd5d190SBaptiste Daroussin.Dq Marking Conflicts ) .
2672*2fd5d190SBaptiste Daroussin.Pp
2673*2fd5d190SBaptiste DaroussinHere is the output of the command
2674*2fd5d190SBaptiste Daroussin.Xr diff3
2675*2fd5d190SBaptiste Daroussinwith each of these three options (see Section
2676*2fd5d190SBaptiste Daroussin.Dq Sample diff3 Input ,
2677*2fd5d190SBaptiste Daroussinfor the complete contents of the files). Notice that
2678*2fd5d190SBaptiste Daroussin.Op -e
2679*2fd5d190SBaptiste Daroussinoutputs the union of the disjoint sets of changes output by
2680*2fd5d190SBaptiste Daroussin.Op -3
2681*2fd5d190SBaptiste Daroussinand
2682*2fd5d190SBaptiste Daroussin.Op -x .
2683*2fd5d190SBaptiste Daroussin.Pp
2684*2fd5d190SBaptiste DaroussinOutput of
2685*2fd5d190SBaptiste Daroussin.Li diff3 -e lao tzu tao :
2686*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
2687*2fd5d190SBaptiste Daroussin11a
2688*2fd5d190SBaptiste Daroussin
2689*2fd5d190SBaptiste Daroussin  -- The Way of Lao-Tzu, tr. Wing-tsit Chan
2690*2fd5d190SBaptiste Daroussin\&.
2691*2fd5d190SBaptiste Daroussin8c
2692*2fd5d190SBaptiste Daroussin  so we may see their result.
2693*2fd5d190SBaptiste Daroussin\&.
2694*2fd5d190SBaptiste Daroussin.Ed
2695*2fd5d190SBaptiste Daroussin.Pp
2696*2fd5d190SBaptiste DaroussinOutput of
2697*2fd5d190SBaptiste Daroussin.Li diff3 -3 lao tzu tao :
2698*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
2699*2fd5d190SBaptiste Daroussin8c
2700*2fd5d190SBaptiste Daroussin  so we may see their result.
2701*2fd5d190SBaptiste Daroussin\&.
2702*2fd5d190SBaptiste Daroussin.Ed
2703*2fd5d190SBaptiste Daroussin.Pp
2704*2fd5d190SBaptiste DaroussinOutput of
2705*2fd5d190SBaptiste Daroussin.Li diff3 -x lao tzu tao :
2706*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
2707*2fd5d190SBaptiste Daroussin11a
2708*2fd5d190SBaptiste Daroussin
2709*2fd5d190SBaptiste Daroussin  -- The Way of Lao-Tzu, tr. Wing-tsit Chan
2710*2fd5d190SBaptiste Daroussin\&.
2711*2fd5d190SBaptiste Daroussin.Ed
2712*2fd5d190SBaptiste Daroussin.Pp
2713*2fd5d190SBaptiste Daroussin.Ss  Marking Conflicts
2714*2fd5d190SBaptiste Daroussin.Xr diff3
2715*2fd5d190SBaptiste Daroussincan mark conflicts in the merged output by bracketing them with special marker
2716*2fd5d190SBaptiste Daroussinlines. A conflict that comes from two files
2717*2fd5d190SBaptiste Daroussin.Va A
2718*2fd5d190SBaptiste Daroussinand
2719*2fd5d190SBaptiste Daroussin.Va B
2720*2fd5d190SBaptiste Daroussinis marked as follows:
2721*2fd5d190SBaptiste Daroussin.Pp
2722*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
2723*2fd5d190SBaptiste Daroussin<<<<<<< A
2724*2fd5d190SBaptiste Daroussinlines from A
2725*2fd5d190SBaptiste Daroussin=======
2726*2fd5d190SBaptiste Daroussinlines from B
2727*2fd5d190SBaptiste Daroussin>>>>>>> B
2728*2fd5d190SBaptiste Daroussin.Ed
2729*2fd5d190SBaptiste Daroussin.Pp
2730*2fd5d190SBaptiste DaroussinA conflict that comes from three files
2731*2fd5d190SBaptiste Daroussin.Va A ,
2732*2fd5d190SBaptiste Daroussin.Va B
2733*2fd5d190SBaptiste Daroussinand
2734*2fd5d190SBaptiste Daroussin.Va C
2735*2fd5d190SBaptiste Daroussinis marked as follows:
2736*2fd5d190SBaptiste Daroussin.Pp
2737*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
2738*2fd5d190SBaptiste Daroussin<<<<<<< A
2739*2fd5d190SBaptiste Daroussinlines from A
2740*2fd5d190SBaptiste Daroussin||||||| B
2741*2fd5d190SBaptiste Daroussinlines from B
2742*2fd5d190SBaptiste Daroussin=======
2743*2fd5d190SBaptiste Daroussinlines from C
2744*2fd5d190SBaptiste Daroussin>>>>>>> C
2745*2fd5d190SBaptiste Daroussin.Ed
2746*2fd5d190SBaptiste Daroussin.Pp
2747*2fd5d190SBaptiste DaroussinThe
2748*2fd5d190SBaptiste Daroussin.Op -A
2749*2fd5d190SBaptiste Daroussinor
2750*2fd5d190SBaptiste Daroussin.Op --show-all
2751*2fd5d190SBaptiste Daroussinoption acts like the
2752*2fd5d190SBaptiste Daroussin.Op -e
2753*2fd5d190SBaptiste Daroussinoption, except that it brackets conflicts, and it outputs all changes from
2754*2fd5d190SBaptiste Daroussin.Va older
2755*2fd5d190SBaptiste Daroussinto
2756*2fd5d190SBaptiste Daroussin.Va yours ,
2757*2fd5d190SBaptiste Daroussinnot just the unmerged changes. Thus, given the sample input files (see Section
2758*2fd5d190SBaptiste Daroussin.Dq Sample diff3 Input ) ,
2759*2fd5d190SBaptiste Daroussin.Li diff3 -A lao tzu tao
2760*2fd5d190SBaptiste Daroussinputs brackets around the conflict where only
2761*2fd5d190SBaptiste Daroussin.Pa tzu
2762*2fd5d190SBaptiste Daroussindiffers:
2763*2fd5d190SBaptiste Daroussin.Pp
2764*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
2765*2fd5d190SBaptiste Daroussin<<<<<<< tzu
2766*2fd5d190SBaptiste Daroussin=======
2767*2fd5d190SBaptiste DaroussinThe Way that can be told of is not the eternal Way;
2768*2fd5d190SBaptiste DaroussinThe name that can be named is not the eternal name.
2769*2fd5d190SBaptiste Daroussin>>>>>>> tao
2770*2fd5d190SBaptiste Daroussin.Ed
2771*2fd5d190SBaptiste Daroussin.Pp
2772*2fd5d190SBaptiste DaroussinAnd it outputs the three-way conflict as follows:
2773*2fd5d190SBaptiste Daroussin.Pp
2774*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
2775*2fd5d190SBaptiste Daroussin<<<<<<< lao
2776*2fd5d190SBaptiste Daroussin||||||| tzu
2777*2fd5d190SBaptiste DaroussinThey both may be called deep and profound.
2778*2fd5d190SBaptiste DaroussinDeeper and more profound,
2779*2fd5d190SBaptiste DaroussinThe door of all subtleties!
2780*2fd5d190SBaptiste Daroussin=======
2781*2fd5d190SBaptiste Daroussin
2782*2fd5d190SBaptiste Daroussin  -- The Way of Lao-Tzu, tr. Wing-tsit Chan
2783*2fd5d190SBaptiste Daroussin>>>>>>> tao
2784*2fd5d190SBaptiste Daroussin.Ed
2785*2fd5d190SBaptiste Daroussin.Pp
2786*2fd5d190SBaptiste DaroussinThe
2787*2fd5d190SBaptiste Daroussin.Op -E
2788*2fd5d190SBaptiste Daroussinor
2789*2fd5d190SBaptiste Daroussin.Op --show-overlap
2790*2fd5d190SBaptiste Daroussinoption outputs less information than the
2791*2fd5d190SBaptiste Daroussin.Op -A
2792*2fd5d190SBaptiste Daroussinor
2793*2fd5d190SBaptiste Daroussin.Op --show-all
2794*2fd5d190SBaptiste Daroussinoption, because it outputs only unmerged changes, and it never outputs the
2795*2fd5d190SBaptiste Daroussincontents of the second file. Thus the
2796*2fd5d190SBaptiste Daroussin.Op -E
2797*2fd5d190SBaptiste Daroussinoption acts like the
2798*2fd5d190SBaptiste Daroussin.Op -e
2799*2fd5d190SBaptiste Daroussinoption, except that it brackets the first and third files from three-way overlapping
2800*2fd5d190SBaptiste Daroussinchanges. Similarly,
2801*2fd5d190SBaptiste Daroussin.Op -X
2802*2fd5d190SBaptiste Daroussinacts like
2803*2fd5d190SBaptiste Daroussin.Op -x ,
2804*2fd5d190SBaptiste Daroussinexcept it brackets all its (necessarily overlapping) changes. For example,
2805*2fd5d190SBaptiste Daroussinfor the three-way overlapping change above, the
2806*2fd5d190SBaptiste Daroussin.Op -E
2807*2fd5d190SBaptiste Daroussinand
2808*2fd5d190SBaptiste Daroussin.Op -X
2809*2fd5d190SBaptiste Daroussinoptions output the following:
2810*2fd5d190SBaptiste Daroussin.Pp
2811*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
2812*2fd5d190SBaptiste Daroussin<<<<<<< lao
2813*2fd5d190SBaptiste Daroussin=======
2814*2fd5d190SBaptiste Daroussin
2815*2fd5d190SBaptiste Daroussin  -- The Way of Lao-Tzu, tr. Wing-tsit Chan
2816*2fd5d190SBaptiste Daroussin>>>>>>> tao
2817*2fd5d190SBaptiste Daroussin.Ed
2818*2fd5d190SBaptiste Daroussin.Pp
2819*2fd5d190SBaptiste DaroussinIf you are comparing files that have meaningless or uninformative names, you
2820*2fd5d190SBaptiste Daroussincan use the
2821*2fd5d190SBaptiste Daroussin.Op --label= Va label
2822*2fd5d190SBaptiste Daroussinoption to show alternate names in the
2823*2fd5d190SBaptiste Daroussin.Li <<<<<<< ,
2824*2fd5d190SBaptiste Daroussin.Li |||||||
2825*2fd5d190SBaptiste Daroussinand
2826*2fd5d190SBaptiste Daroussin.Li >>>>>>>
2827*2fd5d190SBaptiste Daroussinbrackets. This option can be given up to three times, once for each input
2828*2fd5d190SBaptiste Daroussinfile. Thus
2829*2fd5d190SBaptiste Daroussin.Li diff3 -A --label X --label Y --label Z A B C
2830*2fd5d190SBaptiste Daroussinacts like
2831*2fd5d190SBaptiste Daroussin.Li diff3 -A A B C ,
2832*2fd5d190SBaptiste Daroussinexcept that the output looks like it came from files named
2833*2fd5d190SBaptiste Daroussin.Li X ,
2834*2fd5d190SBaptiste Daroussin.Li Y
2835*2fd5d190SBaptiste Daroussinand
2836*2fd5d190SBaptiste Daroussin.Li Z
2837*2fd5d190SBaptiste Daroussinrather than from files named
2838*2fd5d190SBaptiste Daroussin.Li A ,
2839*2fd5d190SBaptiste Daroussin.Li B
2840*2fd5d190SBaptiste Daroussinand
2841*2fd5d190SBaptiste Daroussin.Li C .
2842*2fd5d190SBaptiste Daroussin.Pp
2843*2fd5d190SBaptiste Daroussin.Ss  Generating the Merged Output Directly
2844*2fd5d190SBaptiste DaroussinWith the
2845*2fd5d190SBaptiste Daroussin.Op -m
2846*2fd5d190SBaptiste Daroussinor
2847*2fd5d190SBaptiste Daroussin.Op --merge
2848*2fd5d190SBaptiste Daroussinoption,
2849*2fd5d190SBaptiste Daroussin.Xr diff3
2850*2fd5d190SBaptiste Daroussinoutputs the merged file directly. This is more efficient than using
2851*2fd5d190SBaptiste Daroussin.Xr ed
2852*2fd5d190SBaptiste Daroussinto generate it, and works even with non-text files that
2853*2fd5d190SBaptiste Daroussin.Xr ed
2854*2fd5d190SBaptiste Daroussinwould reject. If you specify
2855*2fd5d190SBaptiste Daroussin.Op -m
2856*2fd5d190SBaptiste Daroussinwithout an
2857*2fd5d190SBaptiste Daroussin.Xr ed
2858*2fd5d190SBaptiste Daroussinscript option,
2859*2fd5d190SBaptiste Daroussin.Op -A
2860*2fd5d190SBaptiste Daroussinis assumed.
2861*2fd5d190SBaptiste Daroussin.Pp
2862*2fd5d190SBaptiste DaroussinFor example, the command
2863*2fd5d190SBaptiste Daroussin.Li diff3 -m lao tzu tao
2864*2fd5d190SBaptiste Daroussin(see Section
2865*2fd5d190SBaptiste Daroussin.Dq Sample diff3 Input
2866*2fd5d190SBaptiste Daroussinfor a copy of the input files) would output the following:
2867*2fd5d190SBaptiste Daroussin.Pp
2868*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
2869*2fd5d190SBaptiste Daroussin<<<<<<< tzu
2870*2fd5d190SBaptiste Daroussin=======
2871*2fd5d190SBaptiste DaroussinThe Way that can be told of is not the eternal Way;
2872*2fd5d190SBaptiste DaroussinThe name that can be named is not the eternal name.
2873*2fd5d190SBaptiste Daroussin>>>>>>> tao
2874*2fd5d190SBaptiste DaroussinThe Nameless is the origin of Heaven and Earth;
2875*2fd5d190SBaptiste DaroussinThe Named is the mother of all things.
2876*2fd5d190SBaptiste DaroussinTherefore let there always be non-being,
2877*2fd5d190SBaptiste Daroussin  so we may see their subtlety,
2878*2fd5d190SBaptiste DaroussinAnd let there always be being,
2879*2fd5d190SBaptiste Daroussin  so we may see their result.
2880*2fd5d190SBaptiste DaroussinThe two are the same,
2881*2fd5d190SBaptiste DaroussinBut after they are produced,
2882*2fd5d190SBaptiste Daroussin  they have different names.
2883*2fd5d190SBaptiste Daroussin<<<<<<< lao
2884*2fd5d190SBaptiste Daroussin||||||| tzu
2885*2fd5d190SBaptiste DaroussinThey both may be called deep and profound.
2886*2fd5d190SBaptiste DaroussinDeeper and more profound,
2887*2fd5d190SBaptiste DaroussinThe door of all subtleties!
2888*2fd5d190SBaptiste Daroussin=======
2889*2fd5d190SBaptiste Daroussin
2890*2fd5d190SBaptiste Daroussin  -- The Way of Lao-Tzu, tr. Wing-tsit Chan
2891*2fd5d190SBaptiste Daroussin>>>>>>> tao
2892*2fd5d190SBaptiste Daroussin.Ed
2893*2fd5d190SBaptiste Daroussin.Pp
2894*2fd5d190SBaptiste Daroussin.Ss  How Xr diff3 Merges Incomplete Lines
2895*2fd5d190SBaptiste DaroussinWith
2896*2fd5d190SBaptiste Daroussin.Op -m ,
2897*2fd5d190SBaptiste Daroussinincomplete lines (see Section
2898*2fd5d190SBaptiste Daroussin.Dq Incomplete Lines )
2899*2fd5d190SBaptiste Daroussinare simply copied to the output as they are found; if the merged output ends
2900*2fd5d190SBaptiste Daroussinin an conflict and one of the input files ends in an incomplete line, succeeding
2901*2fd5d190SBaptiste Daroussin.Li ||||||| ,
2902*2fd5d190SBaptiste Daroussin.Li =======
2903*2fd5d190SBaptiste Daroussinor
2904*2fd5d190SBaptiste Daroussin.Li >>>>>>>
2905*2fd5d190SBaptiste Daroussinbrackets appear somewhere other than the start of a line because they are
2906*2fd5d190SBaptiste Daroussinappended to the incomplete line.
2907*2fd5d190SBaptiste Daroussin.Pp
2908*2fd5d190SBaptiste DaroussinWithout
2909*2fd5d190SBaptiste Daroussin.Op -m ,
2910*2fd5d190SBaptiste Daroussinif an
2911*2fd5d190SBaptiste Daroussin.Xr ed
2912*2fd5d190SBaptiste Daroussinscript option is specified and an incomplete line is found,
2913*2fd5d190SBaptiste Daroussin.Xr diff3
2914*2fd5d190SBaptiste Daroussingenerates a warning and acts as if a newline had been present.
2915*2fd5d190SBaptiste Daroussin.Pp
2916*2fd5d190SBaptiste Daroussin.Ss  Saving the Changed File
2917*2fd5d190SBaptiste DaroussinTraditional Unix
2918*2fd5d190SBaptiste Daroussin.Xr diff3
2919*2fd5d190SBaptiste Daroussingenerates an
2920*2fd5d190SBaptiste Daroussin.Xr ed
2921*2fd5d190SBaptiste Daroussinscript without the trailing
2922*2fd5d190SBaptiste Daroussin.Li w
2923*2fd5d190SBaptiste Daroussinand
2924*2fd5d190SBaptiste Daroussin.Li q
2925*2fd5d190SBaptiste Daroussincommands that save the changes. System V
2926*2fd5d190SBaptiste Daroussin.Xr diff3
2927*2fd5d190SBaptiste Daroussingenerates these extra commands. GNU
2928*2fd5d190SBaptiste Daroussin.Xr diff3
2929*2fd5d190SBaptiste Daroussinnormally behaves like traditional Unix
2930*2fd5d190SBaptiste Daroussin.Xr diff3 ,
2931*2fd5d190SBaptiste Daroussinbut with the
2932*2fd5d190SBaptiste Daroussin.Op -i
2933*2fd5d190SBaptiste Daroussinoption it behaves like System V
2934*2fd5d190SBaptiste Daroussin.Xr diff3
2935*2fd5d190SBaptiste Daroussinand appends the
2936*2fd5d190SBaptiste Daroussin.Li w
2937*2fd5d190SBaptiste Daroussinand
2938*2fd5d190SBaptiste Daroussin.Li q
2939*2fd5d190SBaptiste Daroussincommands.
2940*2fd5d190SBaptiste Daroussin.Pp
2941*2fd5d190SBaptiste DaroussinThe
2942*2fd5d190SBaptiste Daroussin.Op -i
2943*2fd5d190SBaptiste Daroussinoption requires one of the
2944*2fd5d190SBaptiste Daroussin.Xr ed
2945*2fd5d190SBaptiste Daroussinscript options
2946*2fd5d190SBaptiste Daroussin.Op -AeExX3 ,
2947*2fd5d190SBaptiste Daroussinand is incompatible with the merged output option
2948*2fd5d190SBaptiste Daroussin.Op -m .
2949*2fd5d190SBaptiste Daroussin.Pp
2950*2fd5d190SBaptiste Daroussin.Sh  Interactive Merging with Xr sdiff
2951*2fd5d190SBaptiste DaroussinWith
2952*2fd5d190SBaptiste Daroussin.Xr sdiff ,
2953*2fd5d190SBaptiste Daroussinyou can merge two files interactively based on a side-by-side
2954*2fd5d190SBaptiste Daroussin.Op -y
2955*2fd5d190SBaptiste Daroussinformat comparison (see Section
2956*2fd5d190SBaptiste Daroussin.Dq Side by Side ) .
2957*2fd5d190SBaptiste DaroussinUse
2958*2fd5d190SBaptiste Daroussin.Op -o Va file
2959*2fd5d190SBaptiste Daroussinor
2960*2fd5d190SBaptiste Daroussin.Op --output= Va file
2961*2fd5d190SBaptiste Daroussinto specify where to put the merged text.See Section
2962*2fd5d190SBaptiste Daroussin.Dq Invoking sdiff ,
2963*2fd5d190SBaptiste Daroussinfor more details on the options to
2964*2fd5d190SBaptiste Daroussin.Xr sdiff .
2965*2fd5d190SBaptiste Daroussin.Pp
2966*2fd5d190SBaptiste DaroussinAnother way to merge files interactively is to use the Emacs Lisp package
2967*2fd5d190SBaptiste Daroussin.Xr emerge .
2968*2fd5d190SBaptiste DaroussinSee Section.Dq emerge ,
2969*2fd5d190SBaptiste Daroussinfor more information.
2970*2fd5d190SBaptiste Daroussin.Pp
2971*2fd5d190SBaptiste Daroussin.Ss  Specifying Xr diff Options to Xr sdiff
2972*2fd5d190SBaptiste DaroussinThe following
2973*2fd5d190SBaptiste Daroussin.Xr sdiff
2974*2fd5d190SBaptiste Daroussinoptions have the same meaning as for
2975*2fd5d190SBaptiste Daroussin.Xr diff .
2976*2fd5d190SBaptiste DaroussinSee Section.Dq diff Options ,
2977*2fd5d190SBaptiste Daroussinfor the use of these options.
2978*2fd5d190SBaptiste Daroussin.Pp
2979*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
2980*2fd5d190SBaptiste Daroussin-a -b -d -i -t -v
2981*2fd5d190SBaptiste Daroussin-B -E -I regexp
2982*2fd5d190SBaptiste Daroussin
2983*2fd5d190SBaptiste Daroussin--expand-tabs
2984*2fd5d190SBaptiste Daroussin--ignore-blank-lines  --ignore-case
2985*2fd5d190SBaptiste Daroussin--ignore-matching-lines=regexp  --ignore-space-change
2986*2fd5d190SBaptiste Daroussin--ignore-tab-expansion
2987*2fd5d190SBaptiste Daroussin--left-column  --minimal  --speed-large-files
2988*2fd5d190SBaptiste Daroussin--strip-trailing-cr  --suppress-common-lines
2989*2fd5d190SBaptiste Daroussin--tabsize=columns  --text  --version  --width=columns
2990*2fd5d190SBaptiste Daroussin.Ed
2991*2fd5d190SBaptiste Daroussin.Pp
2992*2fd5d190SBaptiste DaroussinFor historical reasons,
2993*2fd5d190SBaptiste Daroussin.Xr sdiff
2994*2fd5d190SBaptiste Daroussinhas alternate names for some options. The
2995*2fd5d190SBaptiste Daroussin.Op -l
2996*2fd5d190SBaptiste Daroussinoption is equivalent to the
2997*2fd5d190SBaptiste Daroussin.Op --left-column
2998*2fd5d190SBaptiste Daroussinoption, and similarly
2999*2fd5d190SBaptiste Daroussin.Op -s
3000*2fd5d190SBaptiste Daroussinis equivalent to
3001*2fd5d190SBaptiste Daroussin.Op --suppress-common-lines .
3002*2fd5d190SBaptiste DaroussinThe meaning of the
3003*2fd5d190SBaptiste Daroussin.Xr sdiff
3004*2fd5d190SBaptiste Daroussin.Op -w
3005*2fd5d190SBaptiste Daroussinand
3006*2fd5d190SBaptiste Daroussin.Op -W
3007*2fd5d190SBaptiste Daroussinoptions is interchanged from that of
3008*2fd5d190SBaptiste Daroussin.Xr diff :
3009*2fd5d190SBaptiste Daroussinwith
3010*2fd5d190SBaptiste Daroussin.Xr sdiff ,
3011*2fd5d190SBaptiste Daroussin.Op -w Va columns
3012*2fd5d190SBaptiste Daroussinis equivalent to
3013*2fd5d190SBaptiste Daroussin.Op --width= Va columns ,
3014*2fd5d190SBaptiste Daroussinand
3015*2fd5d190SBaptiste Daroussin.Op -W
3016*2fd5d190SBaptiste Daroussinis equivalent to
3017*2fd5d190SBaptiste Daroussin.Op --ignore-all-space .
3018*2fd5d190SBaptiste Daroussin.Xr sdiff
3019*2fd5d190SBaptiste Daroussinwithout the
3020*2fd5d190SBaptiste Daroussin.Op -o
3021*2fd5d190SBaptiste Daroussinoption is equivalent to
3022*2fd5d190SBaptiste Daroussin.Xr diff
3023*2fd5d190SBaptiste Daroussinwith the
3024*2fd5d190SBaptiste Daroussin.Op -y
3025*2fd5d190SBaptiste Daroussinor
3026*2fd5d190SBaptiste Daroussin.Op --side-by-side
3027*2fd5d190SBaptiste Daroussinoption (see Section
3028*2fd5d190SBaptiste Daroussin.Dq Side by Side ) .
3029*2fd5d190SBaptiste Daroussin.Pp
3030*2fd5d190SBaptiste Daroussin.Ss  Merge Commands
3031*2fd5d190SBaptiste DaroussinGroups of common lines, with a blank gutter, are copied from the first file
3032*2fd5d190SBaptiste Daroussinto the output. After each group of differing lines,
3033*2fd5d190SBaptiste Daroussin.Xr sdiff
3034*2fd5d190SBaptiste Daroussinprompts with
3035*2fd5d190SBaptiste Daroussin.Li %
3036*2fd5d190SBaptiste Daroussinand pauses, waiting for one of the following commands. Follow each command
3037*2fd5d190SBaptiste Daroussinwith RET.
3038*2fd5d190SBaptiste Daroussin.Pp
3039*2fd5d190SBaptiste Daroussin.Bl -tag -width Ds
3040*2fd5d190SBaptiste Daroussin.It  e
3041*2fd5d190SBaptiste DaroussinDiscard both versions. Invoke a text editor on an empty temporary file, then
3042*2fd5d190SBaptiste Daroussincopy the resulting file to the output.
3043*2fd5d190SBaptiste Daroussin.Pp
3044*2fd5d190SBaptiste Daroussin.It  eb
3045*2fd5d190SBaptiste DaroussinConcatenate the two versions, edit the result in a temporary file, then copy
3046*2fd5d190SBaptiste Daroussinthe edited result to the output.
3047*2fd5d190SBaptiste Daroussin.Pp
3048*2fd5d190SBaptiste Daroussin.It  ed
3049*2fd5d190SBaptiste DaroussinLike
3050*2fd5d190SBaptiste Daroussin.Li eb ,
3051*2fd5d190SBaptiste Daroussinexcept precede each version with a header that shows what file and lines the
3052*2fd5d190SBaptiste Daroussinversion came from.
3053*2fd5d190SBaptiste Daroussin.Pp
3054*2fd5d190SBaptiste Daroussin.It  el
3055*2fd5d190SBaptiste Daroussin.It  e1
3056*2fd5d190SBaptiste DaroussinEdit a copy of the left version, then copy the result to the output.
3057*2fd5d190SBaptiste Daroussin.Pp
3058*2fd5d190SBaptiste Daroussin.It  er
3059*2fd5d190SBaptiste Daroussin.It  e2
3060*2fd5d190SBaptiste DaroussinEdit a copy of the right version, then copy the result to the output.
3061*2fd5d190SBaptiste Daroussin.Pp
3062*2fd5d190SBaptiste Daroussin.It  l
3063*2fd5d190SBaptiste Daroussin.It  1
3064*2fd5d190SBaptiste DaroussinCopy the left version to the output.
3065*2fd5d190SBaptiste Daroussin.Pp
3066*2fd5d190SBaptiste Daroussin.It  q
3067*2fd5d190SBaptiste DaroussinQuit.
3068*2fd5d190SBaptiste Daroussin.Pp
3069*2fd5d190SBaptiste Daroussin.It  r
3070*2fd5d190SBaptiste Daroussin.It  2
3071*2fd5d190SBaptiste DaroussinCopy the right version to the output.
3072*2fd5d190SBaptiste Daroussin.Pp
3073*2fd5d190SBaptiste Daroussin.It  s
3074*2fd5d190SBaptiste DaroussinSilently copy common lines.
3075*2fd5d190SBaptiste Daroussin.Pp
3076*2fd5d190SBaptiste Daroussin.It  v
3077*2fd5d190SBaptiste DaroussinVerbosely copy common lines. This is the default.
3078*2fd5d190SBaptiste Daroussin.El
3079*2fd5d190SBaptiste Daroussin.Pp
3080*2fd5d190SBaptiste DaroussinThe text editor invoked is specified by the
3081*2fd5d190SBaptiste Daroussin.Ev EDITOR
3082*2fd5d190SBaptiste Daroussinenvironment variable if it is set. The default is system-dependent.
3083*2fd5d190SBaptiste Daroussin.Pp
3084*2fd5d190SBaptiste Daroussin.Sh  Merging with Xr patch
3085*2fd5d190SBaptiste Daroussin.Xr patch
3086*2fd5d190SBaptiste Daroussintakes comparison output produced by
3087*2fd5d190SBaptiste Daroussin.Xr diff
3088*2fd5d190SBaptiste Daroussinand applies the differences to a copy of the original file, producing a patched
3089*2fd5d190SBaptiste Daroussinversion. With
3090*2fd5d190SBaptiste Daroussin.Xr patch ,
3091*2fd5d190SBaptiste Daroussinyou can distribute just the changes to a set of files instead of distributing
3092*2fd5d190SBaptiste Daroussinthe entire file set; your correspondents can apply
3093*2fd5d190SBaptiste Daroussin.Xr patch
3094*2fd5d190SBaptiste Daroussinto update their copy of the files with your changes.
3095*2fd5d190SBaptiste Daroussin.Xr patch
3096*2fd5d190SBaptiste Daroussinautomatically determines the diff format, skips any leading or trailing headers,
3097*2fd5d190SBaptiste Daroussinand uses the headers to determine which file to patch. This lets your correspondents
3098*2fd5d190SBaptiste Daroussinfeed a mail message containing a difference listing directly to
3099*2fd5d190SBaptiste Daroussin.Xr patch .
3100*2fd5d190SBaptiste Daroussin.Pp
3101*2fd5d190SBaptiste Daroussin.Xr patch
3102*2fd5d190SBaptiste Daroussindetects and warns about common problems like forward patches. It saves any
3103*2fd5d190SBaptiste Daroussinpatches that it could not apply. It can also maintain a
3104*2fd5d190SBaptiste Daroussin.Li patchlevel.h
3105*2fd5d190SBaptiste Daroussinfile to ensure that your correspondents apply diffs in the proper order.
3106*2fd5d190SBaptiste Daroussin.Pp
3107*2fd5d190SBaptiste Daroussin.Xr patch
3108*2fd5d190SBaptiste Daroussinaccepts a series of diffs in its standard input, usually separated by headers
3109*2fd5d190SBaptiste Daroussinthat specify which file to patch. It applies
3110*2fd5d190SBaptiste Daroussin.Xr diff
3111*2fd5d190SBaptiste Daroussinhunks (see Section
3112*2fd5d190SBaptiste Daroussin.Dq Hunks )
3113*2fd5d190SBaptiste Daroussinone by one. If a hunk does not exactly match the original file,
3114*2fd5d190SBaptiste Daroussin.Xr patch
3115*2fd5d190SBaptiste Daroussinuses heuristics to try to patch the file as well as it can. If no approximate
3116*2fd5d190SBaptiste Daroussinmatch can be found,
3117*2fd5d190SBaptiste Daroussin.Xr patch
3118*2fd5d190SBaptiste Daroussinrejects the hunk and skips to the next hunk.
3119*2fd5d190SBaptiste Daroussin.Xr patch
3120*2fd5d190SBaptiste Daroussinnormally replaces each file
3121*2fd5d190SBaptiste Daroussin.Va f
3122*2fd5d190SBaptiste Daroussinwith its new version, putting reject hunks (if any) into
3123*2fd5d190SBaptiste Daroussin.Li  Va f.rej .
3124*2fd5d190SBaptiste Daroussin.Pp
3125*2fd5d190SBaptiste DaroussinSee Section.Dq Invoking patch ,
3126*2fd5d190SBaptiste Daroussinfor detailed information on the options to
3127*2fd5d190SBaptiste Daroussin.Xr patch .
3128*2fd5d190SBaptiste Daroussin.Pp
3129*2fd5d190SBaptiste Daroussin.Ss  Selecting the Xr patch Input Format
3130*2fd5d190SBaptiste Daroussin.Xr patch
3131*2fd5d190SBaptiste Daroussinnormally determines which
3132*2fd5d190SBaptiste Daroussin.Xr diff
3133*2fd5d190SBaptiste Daroussinformat the patch file uses by examining its contents. For patch files that
3134*2fd5d190SBaptiste Daroussincontain particularly confusing leading text, you might need to use one of
3135*2fd5d190SBaptiste Daroussinthe following options to force
3136*2fd5d190SBaptiste Daroussin.Xr patch
3137*2fd5d190SBaptiste Daroussinto interpret the patch file as a certain format of diff. The output formats
3138*2fd5d190SBaptiste Daroussinlisted here are the only ones that
3139*2fd5d190SBaptiste Daroussin.Xr patch
3140*2fd5d190SBaptiste Daroussincan understand.
3141*2fd5d190SBaptiste Daroussin.Pp
3142*2fd5d190SBaptiste Daroussin.Bl -tag -width Ds
3143*2fd5d190SBaptiste Daroussin.It  -c
3144*2fd5d190SBaptiste Daroussin.It  --context
3145*2fd5d190SBaptiste Daroussincontext diff.
3146*2fd5d190SBaptiste Daroussin.Pp
3147*2fd5d190SBaptiste Daroussin.It  -e
3148*2fd5d190SBaptiste Daroussin.It  --ed
3149*2fd5d190SBaptiste Daroussin.Xr ed
3150*2fd5d190SBaptiste Daroussinscript.
3151*2fd5d190SBaptiste Daroussin.Pp
3152*2fd5d190SBaptiste Daroussin.It  -n
3153*2fd5d190SBaptiste Daroussin.It  --normal
3154*2fd5d190SBaptiste Daroussinnormal diff.
3155*2fd5d190SBaptiste Daroussin.Pp
3156*2fd5d190SBaptiste Daroussin.It  -u
3157*2fd5d190SBaptiste Daroussin.It  --unified
3158*2fd5d190SBaptiste Daroussinunified diff.
3159*2fd5d190SBaptiste Daroussin.El
3160*2fd5d190SBaptiste Daroussin.Pp
3161*2fd5d190SBaptiste Daroussin.Ss  Revision Control
3162*2fd5d190SBaptiste DaroussinIf a nonexistent input file is under a revision control system supported by
3163*2fd5d190SBaptiste Daroussin.Xr patch ,
3164*2fd5d190SBaptiste Daroussin.Xr patch
3165*2fd5d190SBaptiste Daroussinnormally asks the user whether to get (or check out) the file from the revision
3166*2fd5d190SBaptiste Daroussincontrol system. Patch currently supports RCS, ClearCase and SCCS. Under RCS
3167*2fd5d190SBaptiste Daroussinand SCCS,
3168*2fd5d190SBaptiste Daroussin.Xr patch
3169*2fd5d190SBaptiste Daroussinalso asks when the input file is read-only and matches the default version
3170*2fd5d190SBaptiste Daroussinin the revision control system.
3171*2fd5d190SBaptiste Daroussin.Pp
3172*2fd5d190SBaptiste DaroussinThe
3173*2fd5d190SBaptiste Daroussin.Op -g Va num
3174*2fd5d190SBaptiste Daroussinor
3175*2fd5d190SBaptiste Daroussin.Op --get= Va num
3176*2fd5d190SBaptiste Daroussinoption affects access to files under supported revision control systems. If
3177*2fd5d190SBaptiste Daroussin.Va num
3178*2fd5d190SBaptiste Daroussinis positive,
3179*2fd5d190SBaptiste Daroussin.Xr patch
3180*2fd5d190SBaptiste Daroussingets the file without asking the user; if zero,
3181*2fd5d190SBaptiste Daroussin.Xr patch
3182*2fd5d190SBaptiste Daroussinneither asks the user nor gets the file; and if negative,
3183*2fd5d190SBaptiste Daroussin.Xr patch
3184*2fd5d190SBaptiste Daroussinasks the user before getting the file. The default value of
3185*2fd5d190SBaptiste Daroussin.Va num
3186*2fd5d190SBaptiste Daroussinis given by the value of the
3187*2fd5d190SBaptiste Daroussin.Ev PATCH_GET
3188*2fd5d190SBaptiste Daroussinenvironment variable if it is set; if not, the default value is zero if
3189*2fd5d190SBaptiste Daroussin.Xr patch
3190*2fd5d190SBaptiste Daroussinis conforming to POSIX, negative otherwise.See Section
3191*2fd5d190SBaptiste Daroussin.Dq patch and POSIX .
3192*2fd5d190SBaptiste Daroussin.Pp
3193*2fd5d190SBaptiste DaroussinThe choice of revision control system is unaffected by the
3194*2fd5d190SBaptiste Daroussin.Ev VERSION_CONTROL
3195*2fd5d190SBaptiste Daroussinenvironment variable (see Section
3196*2fd5d190SBaptiste Daroussin.Dq Backup Names ) .
3197*2fd5d190SBaptiste Daroussin.Pp
3198*2fd5d190SBaptiste Daroussin.Ss  Applying Imperfect Patches
3199*2fd5d190SBaptiste Daroussin.Xr patch
3200*2fd5d190SBaptiste Daroussintries to skip any leading text in the patch file, apply the diff, and then
3201*2fd5d190SBaptiste Daroussinskip any trailing text. Thus you can feed a mail message directly to
3202*2fd5d190SBaptiste Daroussin.Xr patch ,
3203*2fd5d190SBaptiste Daroussinand it should work. If the entire diff is indented by a constant amount of
3204*2fd5d190SBaptiste Daroussinwhite space,
3205*2fd5d190SBaptiste Daroussin.Xr patch
3206*2fd5d190SBaptiste Daroussinautomatically ignores the indentation. If a context diff contains trailing
3207*2fd5d190SBaptiste Daroussincarriage return on each line,
3208*2fd5d190SBaptiste Daroussin.Xr patch
3209*2fd5d190SBaptiste Daroussinautomatically ignores the carriage return. If a context diff has been encapsulated
3210*2fd5d190SBaptiste Daroussinby prepending
3211*2fd5d190SBaptiste Daroussin.Li -
3212*2fd5d190SBaptiste Daroussinto lines beginning with
3213*2fd5d190SBaptiste Daroussin.Li -
3214*2fd5d190SBaptiste Daroussinas per
3215*2fd5d190SBaptiste Daroussin.Lk ftp://ftp.isi.edu/in-notes/rfc934.txt ,
3216*2fd5d190SBaptiste Daroussin.Xr patch
3217*2fd5d190SBaptiste Daroussinautomatically unencapsulates the input.
3218*2fd5d190SBaptiste Daroussin.Pp
3219*2fd5d190SBaptiste DaroussinHowever, certain other types of imperfect input require user intervention
3220*2fd5d190SBaptiste Daroussinor testing.
3221*2fd5d190SBaptiste Daroussin.Pp
3222*2fd5d190SBaptiste Daroussin.Em  Applying Patches with Changed White Space
3223*2fd5d190SBaptiste Daroussin.Pp
3224*2fd5d190SBaptiste DaroussinSometimes mailers, editors, or other programs change spaces into tabs, or
3225*2fd5d190SBaptiste Daroussinvice versa. If this happens to a patch file or an input file, the files might
3226*2fd5d190SBaptiste Daroussinlook the same, but
3227*2fd5d190SBaptiste Daroussin.Xr patch
3228*2fd5d190SBaptiste Daroussinwill not be able to match them properly. If this problem occurs, use the
3229*2fd5d190SBaptiste Daroussin.Op -l
3230*2fd5d190SBaptiste Daroussinor
3231*2fd5d190SBaptiste Daroussin.Op --ignore-white-space
3232*2fd5d190SBaptiste Daroussinoption, which makes
3233*2fd5d190SBaptiste Daroussin.Xr patch
3234*2fd5d190SBaptiste Daroussincompare blank characters (i.e. spaces and tabs) loosely so that any nonempty
3235*2fd5d190SBaptiste Daroussinsequence of blanks in the patch file matches any nonempty sequence of blanks
3236*2fd5d190SBaptiste Daroussinin the input files. Non-blank characters must still match exactly. Each line
3237*2fd5d190SBaptiste Daroussinof the context must still match a line in the input file.
3238*2fd5d190SBaptiste Daroussin.Pp
3239*2fd5d190SBaptiste Daroussin.Em  Applying Reversed Patches
3240*2fd5d190SBaptiste Daroussin.Pp
3241*2fd5d190SBaptiste DaroussinSometimes people run
3242*2fd5d190SBaptiste Daroussin.Xr diff
3243*2fd5d190SBaptiste Daroussinwith the new file first instead of second. This creates a diff that is \(lqreversed\(rq.
3244*2fd5d190SBaptiste DaroussinTo apply such patches, give
3245*2fd5d190SBaptiste Daroussin.Xr patch
3246*2fd5d190SBaptiste Daroussinthe
3247*2fd5d190SBaptiste Daroussin.Op -R
3248*2fd5d190SBaptiste Daroussinor
3249*2fd5d190SBaptiste Daroussin.Op --reverse
3250*2fd5d190SBaptiste Daroussinoption.
3251*2fd5d190SBaptiste Daroussin.Xr patch
3252*2fd5d190SBaptiste Daroussinthen attempts to swap each hunk around before applying it. Rejects come out
3253*2fd5d190SBaptiste Daroussinin the swapped format.
3254*2fd5d190SBaptiste Daroussin.Pp
3255*2fd5d190SBaptiste DaroussinOften
3256*2fd5d190SBaptiste Daroussin.Xr patch
3257*2fd5d190SBaptiste Daroussincan guess that the patch is reversed. If the first hunk of a patch fails,
3258*2fd5d190SBaptiste Daroussin.Xr patch
3259*2fd5d190SBaptiste Daroussinreverses the hunk to see if it can apply it that way. If it can,
3260*2fd5d190SBaptiste Daroussin.Xr patch
3261*2fd5d190SBaptiste Daroussinasks you if you want to have the
3262*2fd5d190SBaptiste Daroussin.Op -R
3263*2fd5d190SBaptiste Daroussinoption set; if it can't,
3264*2fd5d190SBaptiste Daroussin.Xr patch
3265*2fd5d190SBaptiste Daroussincontinues to apply the patch normally. This method cannot detect a reversed
3266*2fd5d190SBaptiste Daroussinpatch if it is a normal diff and the first command is an append (which should
3267*2fd5d190SBaptiste Daroussinhave been a delete) since appends always succeed, because a null context matches
3268*2fd5d190SBaptiste Daroussinanywhere. But most patches add or change lines rather than delete them, so
3269*2fd5d190SBaptiste Daroussinmost reversed normal diffs begin with a delete, which fails, and
3270*2fd5d190SBaptiste Daroussin.Xr patch
3271*2fd5d190SBaptiste Daroussinnotices.
3272*2fd5d190SBaptiste Daroussin.Pp
3273*2fd5d190SBaptiste DaroussinIf you apply a patch that you have already applied,
3274*2fd5d190SBaptiste Daroussin.Xr patch
3275*2fd5d190SBaptiste Daroussinthinks it is a reversed patch and offers to un-apply the patch. This could
3276*2fd5d190SBaptiste Daroussinbe construed as a feature. If you did this inadvertently and you don't want
3277*2fd5d190SBaptiste Daroussinto un-apply the patch, just answer
3278*2fd5d190SBaptiste Daroussin.Li n
3279*2fd5d190SBaptiste Daroussinto this offer and to the subsequent \(lqapply anyway\(rq question---or type
3280*2fd5d190SBaptiste Daroussin.Li C-c
3281*2fd5d190SBaptiste Daroussinto kill the
3282*2fd5d190SBaptiste Daroussin.Xr patch
3283*2fd5d190SBaptiste Daroussinprocess.
3284*2fd5d190SBaptiste Daroussin.Pp
3285*2fd5d190SBaptiste Daroussin.Em  Helping Xr patch Find Inexact Matches
3286*2fd5d190SBaptiste Daroussin.Pp
3287*2fd5d190SBaptiste DaroussinFor context diffs, and to a lesser extent normal diffs,
3288*2fd5d190SBaptiste Daroussin.Xr patch
3289*2fd5d190SBaptiste Daroussincan detect when the line numbers mentioned in the patch are incorrect, and
3290*2fd5d190SBaptiste Daroussinit attempts to find the correct place to apply each hunk of the patch. As
3291*2fd5d190SBaptiste Daroussina first guess, it takes the line number mentioned in the hunk, plus or minus
3292*2fd5d190SBaptiste Daroussinany offset used in applying the previous hunk. If that is not the correct
3293*2fd5d190SBaptiste Daroussinplace,
3294*2fd5d190SBaptiste Daroussin.Xr patch
3295*2fd5d190SBaptiste Daroussinscans both forward and backward for a set of lines matching the context given
3296*2fd5d190SBaptiste Daroussinin the hunk.
3297*2fd5d190SBaptiste Daroussin.Pp
3298*2fd5d190SBaptiste DaroussinFirst
3299*2fd5d190SBaptiste Daroussin.Xr patch
3300*2fd5d190SBaptiste Daroussinlooks for a place where all lines of the context match. If it cannot find
3301*2fd5d190SBaptiste Daroussinsuch a place, and it is reading a context or unified diff, and the maximum
3302*2fd5d190SBaptiste Daroussinfuzz factor is set to 1 or more, then
3303*2fd5d190SBaptiste Daroussin.Xr patch
3304*2fd5d190SBaptiste Daroussinmakes another scan, ignoring the first and last line of context. If that fails,
3305*2fd5d190SBaptiste Daroussinand the maximum fuzz factor is set to 2 or more, it makes another scan, ignoring
3306*2fd5d190SBaptiste Daroussinthe first two and last two lines of context are ignored. It continues similarly
3307*2fd5d190SBaptiste Daroussinif the maximum fuzz factor is larger.
3308*2fd5d190SBaptiste Daroussin.Pp
3309*2fd5d190SBaptiste DaroussinThe
3310*2fd5d190SBaptiste Daroussin.Op -F Va lines
3311*2fd5d190SBaptiste Daroussinor
3312*2fd5d190SBaptiste Daroussin.Op --fuzz= Va lines
3313*2fd5d190SBaptiste Daroussinoption sets the maximum fuzz factor to
3314*2fd5d190SBaptiste Daroussin.Va lines .
3315*2fd5d190SBaptiste DaroussinThis option only applies to context and unified diffs; it ignores up to
3316*2fd5d190SBaptiste Daroussin.Va lines
3317*2fd5d190SBaptiste Daroussinlines while looking for the place to install a hunk. Note that a larger fuzz
3318*2fd5d190SBaptiste Daroussinfactor increases the odds of making a faulty patch. The default fuzz factor
3319*2fd5d190SBaptiste Daroussinis 2; there is no point to setting it to more than the number of lines of
3320*2fd5d190SBaptiste Daroussincontext in the diff, ordinarily 3.
3321*2fd5d190SBaptiste Daroussin.Pp
3322*2fd5d190SBaptiste DaroussinIf
3323*2fd5d190SBaptiste Daroussin.Xr patch
3324*2fd5d190SBaptiste Daroussincannot find a place to install a hunk of the patch, it writes the hunk out
3325*2fd5d190SBaptiste Daroussinto a reject file (see Section
3326*2fd5d190SBaptiste Daroussin.Dq Reject Names ,
3327*2fd5d190SBaptiste Daroussinfor information on how reject files are named). It writes out rejected hunks
3328*2fd5d190SBaptiste Daroussinin context format no matter what form the input patch is in. If the input
3329*2fd5d190SBaptiste Daroussinis a normal or
3330*2fd5d190SBaptiste Daroussin.Xr ed
3331*2fd5d190SBaptiste Daroussindiff, many of the contexts are simply null. The line numbers on the hunks
3332*2fd5d190SBaptiste Daroussinin the reject file may be different from those in the patch file: they show
3333*2fd5d190SBaptiste Daroussinthe approximate location where
3334*2fd5d190SBaptiste Daroussin.Xr patch
3335*2fd5d190SBaptiste Daroussinthinks the failed hunks belong in the new file rather than in the old one.
3336*2fd5d190SBaptiste Daroussin.Pp
3337*2fd5d190SBaptiste DaroussinIf the
3338*2fd5d190SBaptiste Daroussin.Op --verbose
3339*2fd5d190SBaptiste Daroussinoption is given, then as it completes each hunk
3340*2fd5d190SBaptiste Daroussin.Xr patch
3341*2fd5d190SBaptiste Daroussintells you whether the hunk succeeded or failed, and if it failed, on which
3342*2fd5d190SBaptiste Daroussinline (in the new file)
3343*2fd5d190SBaptiste Daroussin.Xr patch
3344*2fd5d190SBaptiste Daroussinthinks the hunk should go. If this is different from the line number specified
3345*2fd5d190SBaptiste Daroussinin the diff, it tells you the offset. A single large offset
3346*2fd5d190SBaptiste Daroussin.Em may
3347*2fd5d190SBaptiste Daroussinindicate that
3348*2fd5d190SBaptiste Daroussin.Xr patch
3349*2fd5d190SBaptiste Daroussininstalled a hunk in the wrong place.
3350*2fd5d190SBaptiste Daroussin.Xr patch
3351*2fd5d190SBaptiste Daroussinalso tells you if it used a fuzz factor to make the match, in which case you
3352*2fd5d190SBaptiste Daroussinshould also be slightly suspicious.
3353*2fd5d190SBaptiste Daroussin.Pp
3354*2fd5d190SBaptiste Daroussin.Xr patch
3355*2fd5d190SBaptiste Daroussincannot tell if the line numbers are off in an
3356*2fd5d190SBaptiste Daroussin.Xr ed
3357*2fd5d190SBaptiste Daroussinscript, and can only detect wrong line numbers in a normal diff when it finds
3358*2fd5d190SBaptiste Daroussina change or delete command. It may have the same problem with a context diff
3359*2fd5d190SBaptiste Daroussinusing a fuzz factor equal to or greater than the number of lines of context
3360*2fd5d190SBaptiste Daroussinshown in the diff (typically 3). In these cases, you should probably look
3361*2fd5d190SBaptiste Daroussinat a context diff between your original and patched input files to see if
3362*2fd5d190SBaptiste Daroussinthe changes make sense. Compiling without errors is a pretty good indication
3363*2fd5d190SBaptiste Daroussinthat the patch worked, but not a guarantee.
3364*2fd5d190SBaptiste Daroussin.Pp
3365*2fd5d190SBaptiste DaroussinA patch against an empty file applies to a nonexistent file, and vice versa.See Section
3366*2fd5d190SBaptiste Daroussin.Dq Creating and Removing .
3367*2fd5d190SBaptiste Daroussin.Pp
3368*2fd5d190SBaptiste Daroussin.Xr patch
3369*2fd5d190SBaptiste Daroussinusually produces the correct results, even when it must make many guesses.
3370*2fd5d190SBaptiste DaroussinHowever, the results are guaranteed only when the patch is applied to an exact
3371*2fd5d190SBaptiste Daroussincopy of the file that the patch was generated from.
3372*2fd5d190SBaptiste Daroussin.Pp
3373*2fd5d190SBaptiste Daroussin.Em  Predicting what Xr patch will do
3374*2fd5d190SBaptiste Daroussin.Pp
3375*2fd5d190SBaptiste DaroussinIt may not be obvious in advance what
3376*2fd5d190SBaptiste Daroussin.Xr patch
3377*2fd5d190SBaptiste Daroussinwill do with a complicated or poorly formatted patch. If you are concerned
3378*2fd5d190SBaptiste Daroussinthat the input might cause
3379*2fd5d190SBaptiste Daroussin.Xr patch
3380*2fd5d190SBaptiste Daroussinto modify the wrong files, you can use the
3381*2fd5d190SBaptiste Daroussin.Op --dry-run
3382*2fd5d190SBaptiste Daroussinoption, which causes
3383*2fd5d190SBaptiste Daroussin.Xr patch
3384*2fd5d190SBaptiste Daroussinto print the results of applying patches without actually changing any files.
3385*2fd5d190SBaptiste DaroussinYou can then inspect the diagnostics generated by the dry run to see whether
3386*2fd5d190SBaptiste Daroussin.Xr patch
3387*2fd5d190SBaptiste Daroussinwill modify the files that you expect. If the patch does not do what you want,
3388*2fd5d190SBaptiste Daroussinyou can modify the patch (or the other options to
3389*2fd5d190SBaptiste Daroussin.Xr patch )
3390*2fd5d190SBaptiste Daroussinand try another dry run. Once you are satisfied with the proposed patch you
3391*2fd5d190SBaptiste Daroussincan apply it by invoking
3392*2fd5d190SBaptiste Daroussin.Xr patch
3393*2fd5d190SBaptiste Daroussinas before, but this time without the
3394*2fd5d190SBaptiste Daroussin.Op --dry-run
3395*2fd5d190SBaptiste Daroussinoption.
3396*2fd5d190SBaptiste Daroussin.Pp
3397*2fd5d190SBaptiste Daroussin.Ss  Creating and Removing Files
3398*2fd5d190SBaptiste DaroussinSometimes when comparing two directories, a file may exist in one directory
3399*2fd5d190SBaptiste Daroussinbut not the other. If you give
3400*2fd5d190SBaptiste Daroussin.Xr diff
3401*2fd5d190SBaptiste Daroussinthe
3402*2fd5d190SBaptiste Daroussin.Op -N
3403*2fd5d190SBaptiste Daroussinor
3404*2fd5d190SBaptiste Daroussin.Op --new-file
3405*2fd5d190SBaptiste Daroussinoption, or if you supply an old or new file that is named
3406*2fd5d190SBaptiste Daroussin.Pa /dev/null
3407*2fd5d190SBaptiste Daroussinor is empty and is dated the Epoch (1970-01-01 00:00:00 UTC),
3408*2fd5d190SBaptiste Daroussin.Xr diff
3409*2fd5d190SBaptiste Daroussinoutputs a patch that adds or deletes the contents of this file. When given
3410*2fd5d190SBaptiste Daroussinsuch a patch,
3411*2fd5d190SBaptiste Daroussin.Xr patch
3412*2fd5d190SBaptiste Daroussinnormally creates a new file or removes the old file. However, when conforming
3413*2fd5d190SBaptiste Daroussinto POSIX (see Section
3414*2fd5d190SBaptiste Daroussin.Dq patch and POSIX ) ,
3415*2fd5d190SBaptiste Daroussin.Xr patch
3416*2fd5d190SBaptiste Daroussindoes not remove the old file, but leaves it empty. The
3417*2fd5d190SBaptiste Daroussin.Op -E
3418*2fd5d190SBaptiste Daroussinor
3419*2fd5d190SBaptiste Daroussin.Op --remove-empty-files
3420*2fd5d190SBaptiste Daroussinoption causes
3421*2fd5d190SBaptiste Daroussin.Xr patch
3422*2fd5d190SBaptiste Daroussinto remove output files that are empty after applying a patch, even if the
3423*2fd5d190SBaptiste Daroussinpatch does not appear to be one that removed the file.
3424*2fd5d190SBaptiste Daroussin.Pp
3425*2fd5d190SBaptiste DaroussinIf the patch appears to create a file that already exists,
3426*2fd5d190SBaptiste Daroussin.Xr patch
3427*2fd5d190SBaptiste Daroussinasks for confirmation before applying the patch.
3428*2fd5d190SBaptiste Daroussin.Pp
3429*2fd5d190SBaptiste Daroussin.Ss  Updating Time Stamps on Patched Files
3430*2fd5d190SBaptiste DaroussinWhen
3431*2fd5d190SBaptiste Daroussin.Xr patch
3432*2fd5d190SBaptiste Daroussinupdates a file, it normally sets the file's last-modified time stamp to the
3433*2fd5d190SBaptiste Daroussincurrent time of day. If you are using
3434*2fd5d190SBaptiste Daroussin.Xr patch
3435*2fd5d190SBaptiste Daroussinto track a software distribution, this can cause
3436*2fd5d190SBaptiste Daroussin.Xr make
3437*2fd5d190SBaptiste Daroussinto incorrectly conclude that a patched file is out of date. For example, if
3438*2fd5d190SBaptiste Daroussin.Pa syntax.c
3439*2fd5d190SBaptiste Daroussindepends on
3440*2fd5d190SBaptiste Daroussin.Pa syntax.y ,
3441*2fd5d190SBaptiste Daroussinand
3442*2fd5d190SBaptiste Daroussin.Xr patch
3443*2fd5d190SBaptiste Daroussinupdates
3444*2fd5d190SBaptiste Daroussin.Pa syntax.c
3445*2fd5d190SBaptiste Daroussinand then
3446*2fd5d190SBaptiste Daroussin.Pa syntax.y ,
3447*2fd5d190SBaptiste Daroussinthen
3448*2fd5d190SBaptiste Daroussin.Pa syntax.c
3449*2fd5d190SBaptiste Daroussinwill normally appear to be out of date with respect to
3450*2fd5d190SBaptiste Daroussin.Pa syntax.y
3451*2fd5d190SBaptiste Daroussineven though its contents are actually up to date.
3452*2fd5d190SBaptiste Daroussin.Pp
3453*2fd5d190SBaptiste DaroussinThe
3454*2fd5d190SBaptiste Daroussin.Op -Z
3455*2fd5d190SBaptiste Daroussinor
3456*2fd5d190SBaptiste Daroussin.Op --set-utc
3457*2fd5d190SBaptiste Daroussinoption causes
3458*2fd5d190SBaptiste Daroussin.Xr patch
3459*2fd5d190SBaptiste Daroussinto set a patched file's modification and access times to the time stamps given
3460*2fd5d190SBaptiste Daroussinin context diff headers. If the context diff headers do not specify a time
3461*2fd5d190SBaptiste Daroussinzone, they are assumed to use Coordinated Universal Time (UTC, often known
3462*2fd5d190SBaptiste Daroussinas GMT).
3463*2fd5d190SBaptiste Daroussin.Pp
3464*2fd5d190SBaptiste DaroussinThe
3465*2fd5d190SBaptiste Daroussin.Op -T
3466*2fd5d190SBaptiste Daroussinor
3467*2fd5d190SBaptiste Daroussin.Op --set-time
3468*2fd5d190SBaptiste Daroussinoption acts like
3469*2fd5d190SBaptiste Daroussin.Op -Z
3470*2fd5d190SBaptiste Daroussinor
3471*2fd5d190SBaptiste Daroussin.Op --set-utc ,
3472*2fd5d190SBaptiste Daroussinexcept that it assumes that the context diff headers' time stamps use local
3473*2fd5d190SBaptiste Daroussintime instead of UTC. This option is not recommended, because patches using
3474*2fd5d190SBaptiste Daroussinlocal time cannot easily be used by people in other time zones, and because
3475*2fd5d190SBaptiste Daroussinlocal time stamps are ambiguous when local clocks move backwards during daylight-saving
3476*2fd5d190SBaptiste Daroussintime adjustments. If the context diff headers specify a time zone, this option
3477*2fd5d190SBaptiste Daroussinis equivalent to
3478*2fd5d190SBaptiste Daroussin.Op -Z
3479*2fd5d190SBaptiste Daroussinor
3480*2fd5d190SBaptiste Daroussin.Op --set-utc .
3481*2fd5d190SBaptiste Daroussin.Pp
3482*2fd5d190SBaptiste Daroussin.Xr patch
3483*2fd5d190SBaptiste Daroussinnormally refrains from setting a file's time stamps if the file's original
3484*2fd5d190SBaptiste Daroussinlast-modified time stamp does not match the time given in the diff header,
3485*2fd5d190SBaptiste Daroussinof if the file's contents do not exactly match the patch. However, if the
3486*2fd5d190SBaptiste Daroussin.Op -f
3487*2fd5d190SBaptiste Daroussinor
3488*2fd5d190SBaptiste Daroussin.Op --force
3489*2fd5d190SBaptiste Daroussinoption is given, the file's time stamps are set regardless.
3490*2fd5d190SBaptiste Daroussin.Pp
3491*2fd5d190SBaptiste DaroussinDue to the limitations of the current
3492*2fd5d190SBaptiste Daroussin.Xr diff
3493*2fd5d190SBaptiste Daroussinformat,
3494*2fd5d190SBaptiste Daroussin.Xr patch
3495*2fd5d190SBaptiste Daroussincannot update the times of files whose contents have not changed. Also, if
3496*2fd5d190SBaptiste Daroussinyou set file time stamps to values other than the current time of day, you
3497*2fd5d190SBaptiste Daroussinshould also remove (e.g., with
3498*2fd5d190SBaptiste Daroussin.Li make clean )
3499*2fd5d190SBaptiste Daroussinall files that depend on the patched files, so that later invocations of
3500*2fd5d190SBaptiste Daroussin.Xr make
3501*2fd5d190SBaptiste Daroussindo not get confused by the patched files' times.
3502*2fd5d190SBaptiste Daroussin.Pp
3503*2fd5d190SBaptiste Daroussin.Ss  Multiple Patches in a File
3504*2fd5d190SBaptiste DaroussinIf the patch file contains more than one patch, and if you do not specify
3505*2fd5d190SBaptiste Daroussinan input file on the command line,
3506*2fd5d190SBaptiste Daroussin.Xr patch
3507*2fd5d190SBaptiste Daroussintries to apply each patch as if they came from separate patch files. This
3508*2fd5d190SBaptiste Daroussinmeans that it determines the name of the file to patch for each patch, and
3509*2fd5d190SBaptiste Daroussinthat it examines the leading text before each patch for file names and prerequisite
3510*2fd5d190SBaptiste Daroussinrevision level (see Section
3511*2fd5d190SBaptiste Daroussin.Dq Making Patches ,
3512*2fd5d190SBaptiste Daroussinfor more on that topic).
3513*2fd5d190SBaptiste Daroussin.Pp
3514*2fd5d190SBaptiste Daroussin.Xr patch
3515*2fd5d190SBaptiste Daroussinuses the following rules to intuit a file name from the leading text before
3516*2fd5d190SBaptiste Daroussina patch. First,
3517*2fd5d190SBaptiste Daroussin.Xr patch
3518*2fd5d190SBaptiste Daroussintakes an ordered list of candidate file names as follows:
3519*2fd5d190SBaptiste Daroussin.Pp
3520*2fd5d190SBaptiste Daroussin.Bl -bullet
3521*2fd5d190SBaptiste Daroussin.It
3522*2fd5d190SBaptiste DaroussinIf the header is that of a context diff,
3523*2fd5d190SBaptiste Daroussin.Xr patch
3524*2fd5d190SBaptiste Daroussintakes the old and new file names in the header. A name is ignored if it does
3525*2fd5d190SBaptiste Daroussinnot have enough slashes to satisfy the
3526*2fd5d190SBaptiste Daroussin.Op -p Va num
3527*2fd5d190SBaptiste Daroussinor
3528*2fd5d190SBaptiste Daroussin.Op --strip= Va num
3529*2fd5d190SBaptiste Daroussinoption. The name
3530*2fd5d190SBaptiste Daroussin.Pa /dev/null
3531*2fd5d190SBaptiste Daroussinis also ignored.
3532*2fd5d190SBaptiste Daroussin.Pp
3533*2fd5d190SBaptiste Daroussin.It
3534*2fd5d190SBaptiste DaroussinIf there is an
3535*2fd5d190SBaptiste Daroussin.Li Index:
3536*2fd5d190SBaptiste Daroussinline in the leading garbage and if either the old and new names are both absent
3537*2fd5d190SBaptiste Daroussinor if
3538*2fd5d190SBaptiste Daroussin.Xr patch
3539*2fd5d190SBaptiste Daroussinis conforming to POSIX,
3540*2fd5d190SBaptiste Daroussin.Xr patch
3541*2fd5d190SBaptiste Daroussintakes the name in the
3542*2fd5d190SBaptiste Daroussin.Li Index:
3543*2fd5d190SBaptiste Daroussinline.
3544*2fd5d190SBaptiste Daroussin.Pp
3545*2fd5d190SBaptiste Daroussin.It
3546*2fd5d190SBaptiste DaroussinFor the purpose of the following rules, the candidate file names are considered
3547*2fd5d190SBaptiste Daroussinto be in the order (old, new, index), regardless of the order that they appear
3548*2fd5d190SBaptiste Daroussinin the header.
3549*2fd5d190SBaptiste Daroussin.El
3550*2fd5d190SBaptiste Daroussin.Pp
3551*2fd5d190SBaptiste DaroussinThen
3552*2fd5d190SBaptiste Daroussin.Xr patch
3553*2fd5d190SBaptiste Daroussinselects a file name from the candidate list as follows:
3554*2fd5d190SBaptiste Daroussin.Pp
3555*2fd5d190SBaptiste Daroussin.Bl -bullet
3556*2fd5d190SBaptiste Daroussin.It
3557*2fd5d190SBaptiste DaroussinIf some of the named files exist,
3558*2fd5d190SBaptiste Daroussin.Xr patch
3559*2fd5d190SBaptiste Daroussinselects the first name if conforming to POSIX, and the best name otherwise.
3560*2fd5d190SBaptiste Daroussin.Pp
3561*2fd5d190SBaptiste Daroussin.It
3562*2fd5d190SBaptiste DaroussinIf
3563*2fd5d190SBaptiste Daroussin.Xr patch
3564*2fd5d190SBaptiste Daroussinis not ignoring RCS, ClearCase, and SCCS (see Section
3565*2fd5d190SBaptiste Daroussin.Dq Revision Control ) ,
3566*2fd5d190SBaptiste Daroussinand no named files exist but an RCS, ClearCase, or SCCS master is found,
3567*2fd5d190SBaptiste Daroussin.Xr patch
3568*2fd5d190SBaptiste Daroussinselects the first named file with an RCS, ClearCase, or SCCS master.
3569*2fd5d190SBaptiste Daroussin.Pp
3570*2fd5d190SBaptiste Daroussin.It
3571*2fd5d190SBaptiste DaroussinIf no named files exist, no RCS, ClearCase, or SCCS master was found, some
3572*2fd5d190SBaptiste Daroussinnames are given,
3573*2fd5d190SBaptiste Daroussin.Xr patch
3574*2fd5d190SBaptiste Daroussinis not conforming to POSIX, and the patch appears to create a file,
3575*2fd5d190SBaptiste Daroussin.Xr patch
3576*2fd5d190SBaptiste Daroussinselects the best name requiring the creation of the fewest directories.
3577*2fd5d190SBaptiste Daroussin.Pp
3578*2fd5d190SBaptiste Daroussin.It
3579*2fd5d190SBaptiste DaroussinIf no file name results from the above heuristics, you are asked for the name
3580*2fd5d190SBaptiste Daroussinof the file to patch, and
3581*2fd5d190SBaptiste Daroussin.Xr patch
3582*2fd5d190SBaptiste Daroussinselects that name.
3583*2fd5d190SBaptiste Daroussin.El
3584*2fd5d190SBaptiste Daroussin.Pp
3585*2fd5d190SBaptiste DaroussinTo determine the
3586*2fd5d190SBaptiste Daroussin.Em best
3587*2fd5d190SBaptiste Daroussinof a nonempty list of file names,
3588*2fd5d190SBaptiste Daroussin.Xr patch
3589*2fd5d190SBaptiste Daroussinfirst takes all the names with the fewest path name components; of those,
3590*2fd5d190SBaptiste Daroussinit then takes all the names with the shortest basename; of those, it then
3591*2fd5d190SBaptiste Daroussintakes all the shortest names; finally, it takes the first remaining name.
3592*2fd5d190SBaptiste Daroussin.Pp
3593*2fd5d190SBaptiste DaroussinSee Section.Dq patch and POSIX ,
3594*2fd5d190SBaptiste Daroussinto see whether
3595*2fd5d190SBaptiste Daroussin.Xr patch
3596*2fd5d190SBaptiste Daroussinis conforming to POSIX.
3597*2fd5d190SBaptiste Daroussin.Pp
3598*2fd5d190SBaptiste Daroussin.Ss  Applying Patches in Other Directories
3599*2fd5d190SBaptiste DaroussinThe
3600*2fd5d190SBaptiste Daroussin.Op -d Va directory
3601*2fd5d190SBaptiste Daroussinor
3602*2fd5d190SBaptiste Daroussin.Op --directory= Va directory
3603*2fd5d190SBaptiste Daroussinoption to
3604*2fd5d190SBaptiste Daroussin.Xr patch
3605*2fd5d190SBaptiste Daroussinmakes directory
3606*2fd5d190SBaptiste Daroussin.Va directory
3607*2fd5d190SBaptiste Daroussinthe current directory for interpreting both file names in the patch file,
3608*2fd5d190SBaptiste Daroussinand file names given as arguments to other options (such as
3609*2fd5d190SBaptiste Daroussin.Op -B
3610*2fd5d190SBaptiste Daroussinand
3611*2fd5d190SBaptiste Daroussin.Op -o ) .
3612*2fd5d190SBaptiste DaroussinFor example, while in a mail reading program, you can patch a file in the
3613*2fd5d190SBaptiste Daroussin.Pa /usr/src/emacs
3614*2fd5d190SBaptiste Daroussindirectory directly from a message containing the patch like this:
3615*2fd5d190SBaptiste Daroussin.Pp
3616*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
3617*2fd5d190SBaptiste Daroussin| patch -d /usr/src/emacs
3618*2fd5d190SBaptiste Daroussin.Ed
3619*2fd5d190SBaptiste Daroussin.Pp
3620*2fd5d190SBaptiste DaroussinSometimes the file names given in a patch contain leading directories, but
3621*2fd5d190SBaptiste Daroussinyou keep your files in a directory different from the one given in the patch.
3622*2fd5d190SBaptiste DaroussinIn those cases, you can use the
3623*2fd5d190SBaptiste Daroussin.Op -p Va number
3624*2fd5d190SBaptiste Daroussinor
3625*2fd5d190SBaptiste Daroussin.Op --strip= Va number
3626*2fd5d190SBaptiste Daroussinoption to set the file name strip count to
3627*2fd5d190SBaptiste Daroussin.Va number .
3628*2fd5d190SBaptiste DaroussinThe strip count tells
3629*2fd5d190SBaptiste Daroussin.Xr patch
3630*2fd5d190SBaptiste Daroussinhow many slashes, along with the directory names between them, to strip from
3631*2fd5d190SBaptiste Daroussinthe front of file names. A sequence of one or more adjacent slashes is counted
3632*2fd5d190SBaptiste Daroussinas a single slash. By default,
3633*2fd5d190SBaptiste Daroussin.Xr patch
3634*2fd5d190SBaptiste Daroussinstrips off all leading directories, leaving just the base file names.
3635*2fd5d190SBaptiste Daroussin.Pp
3636*2fd5d190SBaptiste DaroussinFor example, suppose the file name in the patch file is
3637*2fd5d190SBaptiste Daroussin.Pa /gnu/src/emacs/etc/NEWS .
3638*2fd5d190SBaptiste DaroussinUsing
3639*2fd5d190SBaptiste Daroussin.Op -p0
3640*2fd5d190SBaptiste Daroussingives the entire file name unmodified,
3641*2fd5d190SBaptiste Daroussin.Op -p1
3642*2fd5d190SBaptiste Daroussingives
3643*2fd5d190SBaptiste Daroussin.Pa gnu/src/emacs/etc/NEWS
3644*2fd5d190SBaptiste Daroussin(no leading slash),
3645*2fd5d190SBaptiste Daroussin.Op -p4
3646*2fd5d190SBaptiste Daroussingives
3647*2fd5d190SBaptiste Daroussin.Pa etc/NEWS ,
3648*2fd5d190SBaptiste Daroussinand not specifying
3649*2fd5d190SBaptiste Daroussin.Op -p
3650*2fd5d190SBaptiste Daroussinat all gives
3651*2fd5d190SBaptiste Daroussin.Pa NEWS .
3652*2fd5d190SBaptiste Daroussin.Pp
3653*2fd5d190SBaptiste Daroussin.Xr patch
3654*2fd5d190SBaptiste Daroussinlooks for each file (after any slashes have been stripped) in the current
3655*2fd5d190SBaptiste Daroussindirectory, or if you used the
3656*2fd5d190SBaptiste Daroussin.Op -d Va directory
3657*2fd5d190SBaptiste Daroussinoption, in that directory.
3658*2fd5d190SBaptiste Daroussin.Pp
3659*2fd5d190SBaptiste Daroussin.Ss  Backup Files
3660*2fd5d190SBaptiste DaroussinNormally,
3661*2fd5d190SBaptiste Daroussin.Xr patch
3662*2fd5d190SBaptiste Daroussincreates a backup file if the patch does not exactly match the original input
3663*2fd5d190SBaptiste Daroussinfile, because in that case the original data might not be recovered if you
3664*2fd5d190SBaptiste Daroussinundo the patch with
3665*2fd5d190SBaptiste Daroussin.Li patch -R
3666*2fd5d190SBaptiste Daroussin(see Section
3667*2fd5d190SBaptiste Daroussin.Dq Reversed Patches ) .
3668*2fd5d190SBaptiste DaroussinHowever, when conforming to POSIX,
3669*2fd5d190SBaptiste Daroussin.Xr patch
3670*2fd5d190SBaptiste Daroussindoes not create backup files by default.See Section
3671*2fd5d190SBaptiste Daroussin.Dq patch and POSIX .
3672*2fd5d190SBaptiste Daroussin.Pp
3673*2fd5d190SBaptiste DaroussinThe
3674*2fd5d190SBaptiste Daroussin.Op -b
3675*2fd5d190SBaptiste Daroussinor
3676*2fd5d190SBaptiste Daroussin.Op --backup
3677*2fd5d190SBaptiste Daroussinoption causes
3678*2fd5d190SBaptiste Daroussin.Xr patch
3679*2fd5d190SBaptiste Daroussinto make a backup file regardless of whether the patch matches the original
3680*2fd5d190SBaptiste Daroussininput. The
3681*2fd5d190SBaptiste Daroussin.Op --backup-if-mismatch
3682*2fd5d190SBaptiste Daroussinoption causes
3683*2fd5d190SBaptiste Daroussin.Xr patch
3684*2fd5d190SBaptiste Daroussinto create backup files for mismatches files; this is the default when not
3685*2fd5d190SBaptiste Daroussinconforming to POSIX. The
3686*2fd5d190SBaptiste Daroussin.Op --no-backup-if-mismatch
3687*2fd5d190SBaptiste Daroussinoption causes
3688*2fd5d190SBaptiste Daroussin.Xr patch
3689*2fd5d190SBaptiste Daroussinto not create backup files, even for mismatched patches; this is the default
3690*2fd5d190SBaptiste Daroussinwhen conforming to POSIX.
3691*2fd5d190SBaptiste Daroussin.Pp
3692*2fd5d190SBaptiste DaroussinWhen backing up a file that does not exist, an empty, unreadable backup file
3693*2fd5d190SBaptiste Daroussinis created as a placeholder to represent the nonexistent file.
3694*2fd5d190SBaptiste Daroussin.Pp
3695*2fd5d190SBaptiste Daroussin.Ss  Backup File Names
3696*2fd5d190SBaptiste DaroussinNormally,
3697*2fd5d190SBaptiste Daroussin.Xr patch
3698*2fd5d190SBaptiste Daroussinrenames an original input file into a backup file by appending to its name
3699*2fd5d190SBaptiste Daroussinthe extension
3700*2fd5d190SBaptiste Daroussin.Li .orig ,
3701*2fd5d190SBaptiste Daroussinor
3702*2fd5d190SBaptiste Daroussin.Li ~
3703*2fd5d190SBaptiste Daroussinif using
3704*2fd5d190SBaptiste Daroussin.Li .orig
3705*2fd5d190SBaptiste Daroussinwould make the backup file name too long. The
3706*2fd5d190SBaptiste Daroussin.Op -z Va backup-suffix
3707*2fd5d190SBaptiste Daroussinor
3708*2fd5d190SBaptiste Daroussin.Op --suffix= Va backup-suffix
3709*2fd5d190SBaptiste Daroussinoption causes
3710*2fd5d190SBaptiste Daroussin.Xr patch
3711*2fd5d190SBaptiste Daroussinto use
3712*2fd5d190SBaptiste Daroussin.Va backup-suffix
3713*2fd5d190SBaptiste Daroussinas the backup extension instead.
3714*2fd5d190SBaptiste Daroussin.Pp
3715*2fd5d190SBaptiste DaroussinAlternately, you can specify the extension for backup files with the
3716*2fd5d190SBaptiste Daroussin.Ev SIMPLE_BACKUP_SUFFIX
3717*2fd5d190SBaptiste Daroussinenvironment variable, which the options override.
3718*2fd5d190SBaptiste Daroussin.Pp
3719*2fd5d190SBaptiste Daroussin.Xr patch
3720*2fd5d190SBaptiste Daroussincan also create numbered backup files the way GNU Emacs does. With this method,
3721*2fd5d190SBaptiste Daroussininstead of having a single backup of each file,
3722*2fd5d190SBaptiste Daroussin.Xr patch
3723*2fd5d190SBaptiste Daroussinmakes a new backup file name each time it patches a file. For example, the
3724*2fd5d190SBaptiste Daroussinbackups of a file named
3725*2fd5d190SBaptiste Daroussin.Pa sink
3726*2fd5d190SBaptiste Daroussinwould be called, successively,
3727*2fd5d190SBaptiste Daroussin.Pa sink.~1~ ,
3728*2fd5d190SBaptiste Daroussin.Pa sink.~2~ ,
3729*2fd5d190SBaptiste Daroussin.Pa sink.~3~ ,
3730*2fd5d190SBaptiste Daroussinetc.
3731*2fd5d190SBaptiste Daroussin.Pp
3732*2fd5d190SBaptiste DaroussinThe
3733*2fd5d190SBaptiste Daroussin.Op -V Va backup-style
3734*2fd5d190SBaptiste Daroussinor
3735*2fd5d190SBaptiste Daroussin.Op --version-control= Va backup-style
3736*2fd5d190SBaptiste Daroussinoption takes as an argument a method for creating backup file names. You can
3737*2fd5d190SBaptiste Daroussinalternately control the type of backups that
3738*2fd5d190SBaptiste Daroussin.Xr patch
3739*2fd5d190SBaptiste Daroussinmakes with the
3740*2fd5d190SBaptiste Daroussin.Ev PATCH_VERSION_CONTROL
3741*2fd5d190SBaptiste Daroussinenvironment variable, which the
3742*2fd5d190SBaptiste Daroussin.Op -V
3743*2fd5d190SBaptiste Daroussinoption overrides. If
3744*2fd5d190SBaptiste Daroussin.Ev PATCH_VERSION_CONTROL
3745*2fd5d190SBaptiste Daroussinis not set, the
3746*2fd5d190SBaptiste Daroussin.Ev VERSION_CONTROL
3747*2fd5d190SBaptiste Daroussinenvironment variable is used instead. Please note that these options and variables
3748*2fd5d190SBaptiste Daroussincontrol backup file names; they do not affect the choice of revision control
3749*2fd5d190SBaptiste Daroussinsystem (see Section
3750*2fd5d190SBaptiste Daroussin.Dq Revision Control ) .
3751*2fd5d190SBaptiste Daroussin.Pp
3752*2fd5d190SBaptiste DaroussinThe values of these environment variables and the argument to the
3753*2fd5d190SBaptiste Daroussin.Op -V
3754*2fd5d190SBaptiste Daroussinoption are like the GNU Emacs
3755*2fd5d190SBaptiste Daroussin.Li version-control
3756*2fd5d190SBaptiste Daroussinvariable (see Section
3757*2fd5d190SBaptiste Daroussin.Dq Backup Names ,
3758*2fd5d190SBaptiste Daroussinfor more information on backup versions in Emacs). They also recognize synonyms
3759*2fd5d190SBaptiste Daroussinthat are more descriptive. The valid values are listed below; unique abbreviations
3760*2fd5d190SBaptiste Daroussinare acceptable.
3761*2fd5d190SBaptiste Daroussin.Pp
3762*2fd5d190SBaptiste Daroussin.Bl -tag -width Ds
3763*2fd5d190SBaptiste Daroussin.It  t
3764*2fd5d190SBaptiste Daroussin.It  numbered
3765*2fd5d190SBaptiste DaroussinAlways make numbered backups.
3766*2fd5d190SBaptiste Daroussin.Pp
3767*2fd5d190SBaptiste Daroussin.It  nil
3768*2fd5d190SBaptiste Daroussin.It  existing
3769*2fd5d190SBaptiste DaroussinMake numbered backups of files that already have them, simple backups of the
3770*2fd5d190SBaptiste Daroussinothers. This is the default.
3771*2fd5d190SBaptiste Daroussin.Pp
3772*2fd5d190SBaptiste Daroussin.It  never
3773*2fd5d190SBaptiste Daroussin.It  simple
3774*2fd5d190SBaptiste DaroussinAlways make simple backups.
3775*2fd5d190SBaptiste Daroussin.El
3776*2fd5d190SBaptiste Daroussin.Pp
3777*2fd5d190SBaptiste DaroussinYou can also tell
3778*2fd5d190SBaptiste Daroussin.Xr patch
3779*2fd5d190SBaptiste Daroussinto prepend a prefix, such as a directory name, to produce backup file names.
3780*2fd5d190SBaptiste DaroussinThe
3781*2fd5d190SBaptiste Daroussin.Op -B Va prefix
3782*2fd5d190SBaptiste Daroussinor
3783*2fd5d190SBaptiste Daroussin.Op --prefix= Va prefix
3784*2fd5d190SBaptiste Daroussinoption makes backup files by prepending
3785*2fd5d190SBaptiste Daroussin.Va prefix
3786*2fd5d190SBaptiste Daroussinto them. The
3787*2fd5d190SBaptiste Daroussin.Op -Y Va prefix
3788*2fd5d190SBaptiste Daroussinor
3789*2fd5d190SBaptiste Daroussin.Op --basename-prefix= Va prefix
3790*2fd5d190SBaptiste Daroussinprepends
3791*2fd5d190SBaptiste Daroussin.Va prefix
3792*2fd5d190SBaptiste Daroussinto the last file name component of backup file names instead; for example,
3793*2fd5d190SBaptiste Daroussin.Op -Y ~
3794*2fd5d190SBaptiste Daroussincauses the backup name for
3795*2fd5d190SBaptiste Daroussin.Pa dir/file.c
3796*2fd5d190SBaptiste Daroussinto be
3797*2fd5d190SBaptiste Daroussin.Pa dir/~file.c .
3798*2fd5d190SBaptiste DaroussinIf you use either of these prefix options, the suffix-based options are ignored.
3799*2fd5d190SBaptiste Daroussin.Pp
3800*2fd5d190SBaptiste DaroussinIf you specify the output file with the
3801*2fd5d190SBaptiste Daroussin.Op -o
3802*2fd5d190SBaptiste Daroussinoption, that file is the one that is backed up, not the input file.
3803*2fd5d190SBaptiste Daroussin.Pp
3804*2fd5d190SBaptiste DaroussinOptions that affect the names of backup files do not affect whether backups
3805*2fd5d190SBaptiste Daroussinare made. For example, if you specify the
3806*2fd5d190SBaptiste Daroussin.Op --no-backup-if-mismatch
3807*2fd5d190SBaptiste Daroussinoption, none of the options described in this section have any affect, because
3808*2fd5d190SBaptiste Daroussinno backups are made.
3809*2fd5d190SBaptiste Daroussin.Pp
3810*2fd5d190SBaptiste Daroussin.Ss  Reject File Names
3811*2fd5d190SBaptiste DaroussinThe names for reject files (files containing patches that
3812*2fd5d190SBaptiste Daroussin.Xr patch
3813*2fd5d190SBaptiste Daroussincould not find a place to apply) are normally the name of the output file
3814*2fd5d190SBaptiste Daroussinwith
3815*2fd5d190SBaptiste Daroussin.Li .rej
3816*2fd5d190SBaptiste Daroussinappended (or
3817*2fd5d190SBaptiste Daroussin.Li #
3818*2fd5d190SBaptiste Daroussinif using
3819*2fd5d190SBaptiste Daroussin.Li .rej
3820*2fd5d190SBaptiste Daroussinwould make the backup file name too long).
3821*2fd5d190SBaptiste Daroussin.Pp
3822*2fd5d190SBaptiste DaroussinAlternatively, you can tell
3823*2fd5d190SBaptiste Daroussin.Xr patch
3824*2fd5d190SBaptiste Daroussinto place all of the rejected patches in a single file. The
3825*2fd5d190SBaptiste Daroussin.Op -r Va reject-file
3826*2fd5d190SBaptiste Daroussinor
3827*2fd5d190SBaptiste Daroussin.Op --reject-file= Va reject-file
3828*2fd5d190SBaptiste Daroussinoption uses
3829*2fd5d190SBaptiste Daroussin.Va reject-file
3830*2fd5d190SBaptiste Daroussinas the reject file name.
3831*2fd5d190SBaptiste Daroussin.Pp
3832*2fd5d190SBaptiste Daroussin.Ss  Messages and Questions from Xr patch
3833*2fd5d190SBaptiste Daroussin.Xr patch
3834*2fd5d190SBaptiste Daroussincan produce a variety of messages, especially if it has trouble decoding its
3835*2fd5d190SBaptiste Daroussininput. In a few situations where it's not sure how to proceed,
3836*2fd5d190SBaptiste Daroussin.Xr patch
3837*2fd5d190SBaptiste Daroussinnormally prompts you for more information from the keyboard. There are options
3838*2fd5d190SBaptiste Daroussinto produce more or fewer messages, to have it not ask for keyboard input,
3839*2fd5d190SBaptiste Daroussinand to affect the way that file names are quoted in messages.
3840*2fd5d190SBaptiste Daroussin.Pp
3841*2fd5d190SBaptiste Daroussin.Xr patch
3842*2fd5d190SBaptiste Daroussinexits with status 0 if all hunks are applied successfully, 1 if some hunks
3843*2fd5d190SBaptiste Daroussincannot be applied, and 2 if there is more serious trouble. When applying a
3844*2fd5d190SBaptiste Daroussinset of patches in a loop, you should check the exit status, so you don't apply
3845*2fd5d190SBaptiste Daroussina later patch to a partially patched file.
3846*2fd5d190SBaptiste Daroussin.Pp
3847*2fd5d190SBaptiste Daroussin.Em  Controlling the Verbosity of Xr patch
3848*2fd5d190SBaptiste Daroussin.Pp
3849*2fd5d190SBaptiste DaroussinYou can cause
3850*2fd5d190SBaptiste Daroussin.Xr patch
3851*2fd5d190SBaptiste Daroussinto produce more messages by using the
3852*2fd5d190SBaptiste Daroussin.Op --verbose
3853*2fd5d190SBaptiste Daroussinoption. For example, when you give this option, the message
3854*2fd5d190SBaptiste Daroussin.Li Hmm...
3855*2fd5d190SBaptiste Daroussinindicates that
3856*2fd5d190SBaptiste Daroussin.Xr patch
3857*2fd5d190SBaptiste Daroussinis reading text in the patch file, attempting to determine whether there is
3858*2fd5d190SBaptiste Daroussina patch in that text, and if so, what kind of patch it is.
3859*2fd5d190SBaptiste Daroussin.Pp
3860*2fd5d190SBaptiste DaroussinYou can inhibit all terminal output from
3861*2fd5d190SBaptiste Daroussin.Xr patch ,
3862*2fd5d190SBaptiste Daroussinunless an error occurs, by using the
3863*2fd5d190SBaptiste Daroussin.Op -s ,
3864*2fd5d190SBaptiste Daroussin.Op --quiet ,
3865*2fd5d190SBaptiste Daroussinor
3866*2fd5d190SBaptiste Daroussin.Op --silent
3867*2fd5d190SBaptiste Daroussinoption.
3868*2fd5d190SBaptiste Daroussin.Pp
3869*2fd5d190SBaptiste Daroussin.Em  Inhibiting Keyboard Input
3870*2fd5d190SBaptiste Daroussin.Pp
3871*2fd5d190SBaptiste DaroussinThere are two ways you can prevent
3872*2fd5d190SBaptiste Daroussin.Xr patch
3873*2fd5d190SBaptiste Daroussinfrom asking you any questions. The
3874*2fd5d190SBaptiste Daroussin.Op -f
3875*2fd5d190SBaptiste Daroussinor
3876*2fd5d190SBaptiste Daroussin.Op --force
3877*2fd5d190SBaptiste Daroussinoption assumes that you know what you are doing. It causes
3878*2fd5d190SBaptiste Daroussin.Xr patch
3879*2fd5d190SBaptiste Daroussinto do the following:
3880*2fd5d190SBaptiste Daroussin.Pp
3881*2fd5d190SBaptiste Daroussin.Bl -bullet
3882*2fd5d190SBaptiste Daroussin.It
3883*2fd5d190SBaptiste DaroussinSkip patches that do not contain file names in their headers.
3884*2fd5d190SBaptiste Daroussin.Pp
3885*2fd5d190SBaptiste Daroussin.It
3886*2fd5d190SBaptiste DaroussinPatch files even though they have the wrong version for the
3887*2fd5d190SBaptiste Daroussin.Li Prereq:
3888*2fd5d190SBaptiste Daroussinline in the patch;
3889*2fd5d190SBaptiste Daroussin.Pp
3890*2fd5d190SBaptiste Daroussin.It
3891*2fd5d190SBaptiste DaroussinAssume that patches are not reversed even if they look like they are.
3892*2fd5d190SBaptiste Daroussin.El
3893*2fd5d190SBaptiste Daroussin.Pp
3894*2fd5d190SBaptiste DaroussinThe
3895*2fd5d190SBaptiste Daroussin.Op -t
3896*2fd5d190SBaptiste Daroussinor
3897*2fd5d190SBaptiste Daroussin.Op --batch
3898*2fd5d190SBaptiste Daroussinoption is similar to
3899*2fd5d190SBaptiste Daroussin.Op -f ,
3900*2fd5d190SBaptiste Daroussinin that it suppresses questions, but it makes somewhat different assumptions:
3901*2fd5d190SBaptiste Daroussin.Pp
3902*2fd5d190SBaptiste Daroussin.Bl -bullet
3903*2fd5d190SBaptiste Daroussin.It
3904*2fd5d190SBaptiste DaroussinSkip patches that do not contain file names in their headers (the same as
3905*2fd5d190SBaptiste Daroussin.Op -f ) .
3906*2fd5d190SBaptiste Daroussin.Pp
3907*2fd5d190SBaptiste Daroussin.It
3908*2fd5d190SBaptiste DaroussinSkip patches for which the file has the wrong version for the
3909*2fd5d190SBaptiste Daroussin.Li Prereq:
3910*2fd5d190SBaptiste Daroussinline in the patch;
3911*2fd5d190SBaptiste Daroussin.Pp
3912*2fd5d190SBaptiste Daroussin.It
3913*2fd5d190SBaptiste DaroussinAssume that patches are reversed if they look like they are.
3914*2fd5d190SBaptiste Daroussin.El
3915*2fd5d190SBaptiste Daroussin.Pp
3916*2fd5d190SBaptiste Daroussin.Em  Xr patch Quoting Style
3917*2fd5d190SBaptiste Daroussin.Pp
3918*2fd5d190SBaptiste DaroussinWhen
3919*2fd5d190SBaptiste Daroussin.Xr patch
3920*2fd5d190SBaptiste Daroussinoutputs a file name in a diagnostic message, it can format the name in any
3921*2fd5d190SBaptiste Daroussinof several ways. This can be useful to output file names unambiguously, even
3922*2fd5d190SBaptiste Daroussinif they contain punctuation or special characters like newlines. The
3923*2fd5d190SBaptiste Daroussin.Op --quoting-style= Va word
3924*2fd5d190SBaptiste Daroussinoption controls how names are output. The
3925*2fd5d190SBaptiste Daroussin.Va word
3926*2fd5d190SBaptiste Daroussinshould be one of the following:
3927*2fd5d190SBaptiste Daroussin.Pp
3928*2fd5d190SBaptiste Daroussin.Bl -tag -width Ds
3929*2fd5d190SBaptiste Daroussin.It  literal
3930*2fd5d190SBaptiste DaroussinOutput names as-is.
3931*2fd5d190SBaptiste Daroussin.It  shell
3932*2fd5d190SBaptiste DaroussinQuote names for the shell if they contain shell metacharacters or would cause
3933*2fd5d190SBaptiste Daroussinambiguous output.
3934*2fd5d190SBaptiste Daroussin.It  shell-always
3935*2fd5d190SBaptiste DaroussinQuote names for the shell, even if they would normally not require quoting.
3936*2fd5d190SBaptiste Daroussin.It  c
3937*2fd5d190SBaptiste DaroussinQuote names as for a C language string.
3938*2fd5d190SBaptiste Daroussin.It  escape
3939*2fd5d190SBaptiste DaroussinQuote as with
3940*2fd5d190SBaptiste Daroussin.Li c
3941*2fd5d190SBaptiste Daroussinexcept omit the surrounding double-quote characters.
3942*2fd5d190SBaptiste Daroussin.El
3943*2fd5d190SBaptiste Daroussin.Pp
3944*2fd5d190SBaptiste DaroussinYou can specify the default value of the
3945*2fd5d190SBaptiste Daroussin.Op --quoting-style
3946*2fd5d190SBaptiste Daroussinoption with the environment variable
3947*2fd5d190SBaptiste Daroussin.Ev QUOTING_STYLE .
3948*2fd5d190SBaptiste DaroussinIf that environment variable is not set, the default value is
3949*2fd5d190SBaptiste Daroussin.Li shell ,
3950*2fd5d190SBaptiste Daroussinbut this default may change in a future version of
3951*2fd5d190SBaptiste Daroussin.Xr patch .
3952*2fd5d190SBaptiste Daroussin.Pp
3953*2fd5d190SBaptiste Daroussin.Ss  Xr patch and the POSIX Standard
3954*2fd5d190SBaptiste DaroussinIf you specify the
3955*2fd5d190SBaptiste Daroussin.Op --posix
3956*2fd5d190SBaptiste Daroussinoption, or set the
3957*2fd5d190SBaptiste Daroussin.Ev POSIXLY_CORRECT
3958*2fd5d190SBaptiste Daroussinenvironment variable,
3959*2fd5d190SBaptiste Daroussin.Xr patch
3960*2fd5d190SBaptiste Daroussinconforms more strictly to the POSIX standard, as follows:
3961*2fd5d190SBaptiste Daroussin.Pp
3962*2fd5d190SBaptiste Daroussin.Bl -bullet
3963*2fd5d190SBaptiste Daroussin.It
3964*2fd5d190SBaptiste DaroussinTake the first existing file from the list (old, new, index) when intuiting
3965*2fd5d190SBaptiste Daroussinfile names from diff headers.See Section
3966*2fd5d190SBaptiste Daroussin.Dq Multiple Patches .
3967*2fd5d190SBaptiste Daroussin.Pp
3968*2fd5d190SBaptiste Daroussin.It
3969*2fd5d190SBaptiste DaroussinDo not remove files that are removed by a diff.See Section
3970*2fd5d190SBaptiste Daroussin.Dq Creating and Removing .
3971*2fd5d190SBaptiste Daroussin.Pp
3972*2fd5d190SBaptiste Daroussin.It
3973*2fd5d190SBaptiste DaroussinDo not ask whether to get files from RCS, ClearCase, or SCCS.See Section
3974*2fd5d190SBaptiste Daroussin.Dq Revision Control .
3975*2fd5d190SBaptiste Daroussin.Pp
3976*2fd5d190SBaptiste Daroussin.It
3977*2fd5d190SBaptiste DaroussinRequire that all options precede the files in the command line.
3978*2fd5d190SBaptiste Daroussin.Pp
3979*2fd5d190SBaptiste Daroussin.It
3980*2fd5d190SBaptiste DaroussinDo not backup files, even when there is a mismatch.See Section
3981*2fd5d190SBaptiste Daroussin.Dq Backups .
3982*2fd5d190SBaptiste Daroussin.Pp
3983*2fd5d190SBaptiste Daroussin.El
3984*2fd5d190SBaptiste Daroussin.Ss  GNU Xr patch and Traditional Xr patch
3985*2fd5d190SBaptiste DaroussinThe current version of GNU
3986*2fd5d190SBaptiste Daroussin.Xr patch
3987*2fd5d190SBaptiste Daroussinnormally follows the POSIX standard.See Section
3988*2fd5d190SBaptiste Daroussin.Dq patch and POSIX ,
3989*2fd5d190SBaptiste Daroussinfor the few exceptions to this general rule.
3990*2fd5d190SBaptiste Daroussin.Pp
3991*2fd5d190SBaptiste DaroussinUnfortunately, POSIX redefined the behavior of
3992*2fd5d190SBaptiste Daroussin.Xr patch
3993*2fd5d190SBaptiste Daroussinin several important ways. You should be aware of the following differences
3994*2fd5d190SBaptiste Daroussinif you must interoperate with traditional
3995*2fd5d190SBaptiste Daroussin.Xr patch ,
3996*2fd5d190SBaptiste Daroussinor with GNU
3997*2fd5d190SBaptiste Daroussin.Xr patch
3998*2fd5d190SBaptiste Daroussinversion 2.1 and earlier.
3999*2fd5d190SBaptiste Daroussin.Pp
4000*2fd5d190SBaptiste Daroussin.Bl -bullet
4001*2fd5d190SBaptiste Daroussin.It
4002*2fd5d190SBaptiste DaroussinIn traditional
4003*2fd5d190SBaptiste Daroussin.Xr patch ,
4004*2fd5d190SBaptiste Daroussinthe
4005*2fd5d190SBaptiste Daroussin.Op -p
4006*2fd5d190SBaptiste Daroussinoption's operand was optional, and a bare
4007*2fd5d190SBaptiste Daroussin.Op -p
4008*2fd5d190SBaptiste Daroussinwas equivalent to
4009*2fd5d190SBaptiste Daroussin.Op -p0 .
4010*2fd5d190SBaptiste DaroussinThe
4011*2fd5d190SBaptiste Daroussin.Op -p
4012*2fd5d190SBaptiste Daroussinoption now requires an operand, and
4013*2fd5d190SBaptiste Daroussin.Op -p 0
4014*2fd5d190SBaptiste Daroussinis now equivalent to
4015*2fd5d190SBaptiste Daroussin.Op -p0 .
4016*2fd5d190SBaptiste DaroussinFor maximum compatibility, use options like
4017*2fd5d190SBaptiste Daroussin.Op -p0
4018*2fd5d190SBaptiste Daroussinand
4019*2fd5d190SBaptiste Daroussin.Op -p1 .
4020*2fd5d190SBaptiste Daroussin.Pp
4021*2fd5d190SBaptiste DaroussinAlso, traditional
4022*2fd5d190SBaptiste Daroussin.Xr patch
4023*2fd5d190SBaptiste Daroussinsimply counted slashes when stripping path prefixes;
4024*2fd5d190SBaptiste Daroussin.Xr patch
4025*2fd5d190SBaptiste Daroussinnow counts pathname components. That is, a sequence of one or more adjacent
4026*2fd5d190SBaptiste Daroussinslashes now counts as a single slash. For maximum portability, avoid sending
4027*2fd5d190SBaptiste Daroussinpatches containing
4028*2fd5d190SBaptiste Daroussin.Pa //
4029*2fd5d190SBaptiste Daroussinin file names.
4030*2fd5d190SBaptiste Daroussin.Pp
4031*2fd5d190SBaptiste Daroussin.It
4032*2fd5d190SBaptiste DaroussinIn traditional
4033*2fd5d190SBaptiste Daroussin.Xr patch ,
4034*2fd5d190SBaptiste Daroussinbackups were enabled by default. This behavior is now enabled with the
4035*2fd5d190SBaptiste Daroussin.Op -b
4036*2fd5d190SBaptiste Daroussinor
4037*2fd5d190SBaptiste Daroussin.Op --backup
4038*2fd5d190SBaptiste Daroussinoption.
4039*2fd5d190SBaptiste Daroussin.Pp
4040*2fd5d190SBaptiste DaroussinConversely, in POSIX
4041*2fd5d190SBaptiste Daroussin.Xr patch ,
4042*2fd5d190SBaptiste Daroussinbackups are never made, even when there is a mismatch. In GNU
4043*2fd5d190SBaptiste Daroussin.Xr patch ,
4044*2fd5d190SBaptiste Daroussinthis behavior is enabled with the
4045*2fd5d190SBaptiste Daroussin.Op --no-backup-if-mismatch
4046*2fd5d190SBaptiste Daroussinoption, or by conforming to POSIX.
4047*2fd5d190SBaptiste Daroussin.Pp
4048*2fd5d190SBaptiste DaroussinThe
4049*2fd5d190SBaptiste Daroussin.Op -b  Va suffix
4050*2fd5d190SBaptiste Daroussinoption of traditional
4051*2fd5d190SBaptiste Daroussin.Xr patch
4052*2fd5d190SBaptiste Daroussinis equivalent to the
4053*2fd5d190SBaptiste Daroussin.Li -b -z  Va suffix
4054*2fd5d190SBaptiste Daroussinoptions of GNU
4055*2fd5d190SBaptiste Daroussin.Xr patch .
4056*2fd5d190SBaptiste Daroussin.Pp
4057*2fd5d190SBaptiste Daroussin.It
4058*2fd5d190SBaptiste DaroussinTraditional
4059*2fd5d190SBaptiste Daroussin.Xr patch
4060*2fd5d190SBaptiste Daroussinused a complicated (and incompletely documented) method to intuit the name
4061*2fd5d190SBaptiste Daroussinof the file to be patched from the patch header. This method did not conform
4062*2fd5d190SBaptiste Daroussinto POSIX, and had a few gotchas. Now
4063*2fd5d190SBaptiste Daroussin.Xr patch
4064*2fd5d190SBaptiste Daroussinuses a different, equally complicated (but better documented) method that
4065*2fd5d190SBaptiste Daroussinis optionally POSIX-conforming; we hope it has fewer gotchas. The two methods
4066*2fd5d190SBaptiste Daroussinare compatible if the file names in the context diff header and the
4067*2fd5d190SBaptiste Daroussin.Li Index:
4068*2fd5d190SBaptiste Daroussinline are all identical after prefix-stripping. Your patch is normally compatible
4069*2fd5d190SBaptiste Daroussinif each header's file names all contain the same number of slashes.
4070*2fd5d190SBaptiste Daroussin.Pp
4071*2fd5d190SBaptiste Daroussin.It
4072*2fd5d190SBaptiste DaroussinWhen traditional
4073*2fd5d190SBaptiste Daroussin.Xr patch
4074*2fd5d190SBaptiste Daroussinasked the user a question, it sent the question to standard error and looked
4075*2fd5d190SBaptiste Daroussinfor an answer from the first file in the following list that was a terminal:
4076*2fd5d190SBaptiste Daroussinstandard error, standard output,
4077*2fd5d190SBaptiste Daroussin.Pa /dev/tty ,
4078*2fd5d190SBaptiste Daroussinand standard input. Now
4079*2fd5d190SBaptiste Daroussin.Xr patch
4080*2fd5d190SBaptiste Daroussinsends questions to standard output and gets answers from
4081*2fd5d190SBaptiste Daroussin.Pa /dev/tty .
4082*2fd5d190SBaptiste DaroussinDefaults for some answers have been changed so that
4083*2fd5d190SBaptiste Daroussin.Xr patch
4084*2fd5d190SBaptiste Daroussinnever goes into an infinite loop when using default answers.
4085*2fd5d190SBaptiste Daroussin.Pp
4086*2fd5d190SBaptiste Daroussin.It
4087*2fd5d190SBaptiste DaroussinTraditional
4088*2fd5d190SBaptiste Daroussin.Xr patch
4089*2fd5d190SBaptiste Daroussinexited with a status value that counted the number of bad hunks, or with status
4090*2fd5d190SBaptiste Daroussin1 if there was real trouble. Now
4091*2fd5d190SBaptiste Daroussin.Xr patch
4092*2fd5d190SBaptiste Daroussinexits with status 1 if some hunks failed, or with 2 if there was real trouble.
4093*2fd5d190SBaptiste Daroussin.Pp
4094*2fd5d190SBaptiste Daroussin.It
4095*2fd5d190SBaptiste DaroussinLimit yourself to the following options when sending instructions meant to
4096*2fd5d190SBaptiste Daroussinbe executed by anyone running GNU
4097*2fd5d190SBaptiste Daroussin.Xr patch ,
4098*2fd5d190SBaptiste Daroussintraditional
4099*2fd5d190SBaptiste Daroussin.Xr patch ,
4100*2fd5d190SBaptiste Daroussinor a
4101*2fd5d190SBaptiste Daroussin.Xr patch
4102*2fd5d190SBaptiste Daroussinthat conforms to POSIX. Spaces are significant in the following list, and
4103*2fd5d190SBaptiste Daroussinoperands are required.
4104*2fd5d190SBaptiste Daroussin.Pp
4105*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
4106*2fd5d190SBaptiste Daroussin-c
4107*2fd5d190SBaptiste Daroussin-d dir
4108*2fd5d190SBaptiste Daroussin-D define
4109*2fd5d190SBaptiste Daroussin-e
4110*2fd5d190SBaptiste Daroussin-l
4111*2fd5d190SBaptiste Daroussin-n
4112*2fd5d190SBaptiste Daroussin-N
4113*2fd5d190SBaptiste Daroussin-o outfile
4114*2fd5d190SBaptiste Daroussin-pnum
4115*2fd5d190SBaptiste Daroussin-R
4116*2fd5d190SBaptiste Daroussin-r rejectfile
4117*2fd5d190SBaptiste Daroussin.Ed
4118*2fd5d190SBaptiste Daroussin.Pp
4119*2fd5d190SBaptiste Daroussin.El
4120*2fd5d190SBaptiste Daroussin.Sh  Tips for Making and Using Patches
4121*2fd5d190SBaptiste DaroussinUse some common sense when making and using patches. For example, when sending
4122*2fd5d190SBaptiste Daroussinbug fixes to a program's maintainer, send several small patches, one per independent
4123*2fd5d190SBaptiste Daroussinsubject, instead of one large, harder-to-digest patch that covers all the
4124*2fd5d190SBaptiste Daroussinsubjects.
4125*2fd5d190SBaptiste Daroussin.Pp
4126*2fd5d190SBaptiste DaroussinHere are some other things you should keep in mind if you are going to distribute
4127*2fd5d190SBaptiste Daroussinpatches for updating a software package.
4128*2fd5d190SBaptiste Daroussin.Pp
4129*2fd5d190SBaptiste Daroussin.Ss  Tips for Patch Producers
4130*2fd5d190SBaptiste DaroussinTo create a patch that changes an older version of a package into a newer
4131*2fd5d190SBaptiste Daroussinversion, first make a copy of the older and newer versions in adjacent subdirectories.
4132*2fd5d190SBaptiste DaroussinIt is common to do that by unpacking
4133*2fd5d190SBaptiste Daroussin.Xr tar
4134*2fd5d190SBaptiste Daroussinarchives of the two versions.
4135*2fd5d190SBaptiste Daroussin.Pp
4136*2fd5d190SBaptiste DaroussinTo generate the patch, use the command
4137*2fd5d190SBaptiste Daroussin.Li diff -Naur Va old Va new
4138*2fd5d190SBaptiste Daroussinwhere
4139*2fd5d190SBaptiste Daroussin.Va old
4140*2fd5d190SBaptiste Daroussinand
4141*2fd5d190SBaptiste Daroussin.Va new
4142*2fd5d190SBaptiste Daroussinidentify the old and new directories. The names
4143*2fd5d190SBaptiste Daroussin.Va old
4144*2fd5d190SBaptiste Daroussinand
4145*2fd5d190SBaptiste Daroussin.Va new
4146*2fd5d190SBaptiste Daroussinshould not contain any slashes. The
4147*2fd5d190SBaptiste Daroussin.Op -N
4148*2fd5d190SBaptiste Daroussinoption lets the patch create and remove files;
4149*2fd5d190SBaptiste Daroussin.Op -a
4150*2fd5d190SBaptiste Daroussinlets the patch update non-text files;
4151*2fd5d190SBaptiste Daroussin.Op -u
4152*2fd5d190SBaptiste Daroussingenerates useful time stamps and enough context; and
4153*2fd5d190SBaptiste Daroussin.Op -r
4154*2fd5d190SBaptiste Daroussinlets the patch update subdirectories. Here is an example command, using Bourne
4155*2fd5d190SBaptiste Daroussinshell syntax:
4156*2fd5d190SBaptiste Daroussin.Pp
4157*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
4158*2fd5d190SBaptiste Daroussindiff -Naur gcc-3.0.3 gcc-3.0.4
4159*2fd5d190SBaptiste Daroussin.Ed
4160*2fd5d190SBaptiste Daroussin.Pp
4161*2fd5d190SBaptiste DaroussinTell your recipients how to apply the patches. This should include which working
4162*2fd5d190SBaptiste Daroussindirectory to use, and which
4163*2fd5d190SBaptiste Daroussin.Xr patch
4164*2fd5d190SBaptiste Daroussinoptions to use; the option
4165*2fd5d190SBaptiste Daroussin.Li -p1
4166*2fd5d190SBaptiste Daroussinis recommended. Test your procedure by pretending to be a recipient and applying
4167*2fd5d190SBaptiste Daroussinyour patches to a copy of the original files.
4168*2fd5d190SBaptiste Daroussin.Pp
4169*2fd5d190SBaptiste DaroussinSee Section.Dq Avoiding Common Mistakes ,
4170*2fd5d190SBaptiste Daroussinfor how to avoid common mistakes when generating a patch.
4171*2fd5d190SBaptiste Daroussin.Pp
4172*2fd5d190SBaptiste Daroussin.Ss  Tips for Patch Consumers
4173*2fd5d190SBaptiste DaroussinA patch producer should tell recipients how to apply the patches, so the first
4174*2fd5d190SBaptiste Daroussinrule of thumb for a patch consumer is to follow the instructions supplied
4175*2fd5d190SBaptiste Daroussinwith the patch.
4176*2fd5d190SBaptiste Daroussin.Pp
4177*2fd5d190SBaptiste DaroussinGNU
4178*2fd5d190SBaptiste Daroussin.Xr diff
4179*2fd5d190SBaptiste Daroussincan analyze files with arbitrarily long lines and files that end in incomplete
4180*2fd5d190SBaptiste Daroussinlines. However, older versions of
4181*2fd5d190SBaptiste Daroussin.Xr patch
4182*2fd5d190SBaptiste Daroussincannot patch such files. If you are having trouble applying such patches,
4183*2fd5d190SBaptiste Daroussintry upgrading to a recent version of GNU
4184*2fd5d190SBaptiste Daroussin.Xr patch .
4185*2fd5d190SBaptiste Daroussin.Pp
4186*2fd5d190SBaptiste Daroussin.Ss  Avoiding Common Mistakes
4187*2fd5d190SBaptiste DaroussinWhen producing a patch for multiple files, apply
4188*2fd5d190SBaptiste Daroussin.Xr diff
4189*2fd5d190SBaptiste Daroussinto directories whose names do not have slashes. This reduces confusion when
4190*2fd5d190SBaptiste Daroussinthe patch consumer specifies the
4191*2fd5d190SBaptiste Daroussin.Op -p Va number
4192*2fd5d190SBaptiste Daroussinoption, since this option can have surprising results when the old and new
4193*2fd5d190SBaptiste Daroussinfile names have different numbers of slashes. For example, do not send a patch
4194*2fd5d190SBaptiste Daroussinwith a header that looks like this:
4195*2fd5d190SBaptiste Daroussin.Pp
4196*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
4197*2fd5d190SBaptiste Daroussindiff -Naur v2.0.29/prog/README prog/README
4198*2fd5d190SBaptiste Daroussin--- v2.0.29/prog/README	2002-03-10 23:30:39.942229878 -0800
4199*2fd5d190SBaptiste Daroussin+++ prog/README	2002-03-17 20:49:32.442260588 -0800
4200*2fd5d190SBaptiste Daroussin.Ed
4201*2fd5d190SBaptiste Daroussin.Pp
4202*2fd5d190SBaptiste Daroussinbecause the two file names have different numbers of slashes, and different
4203*2fd5d190SBaptiste Daroussinversions of
4204*2fd5d190SBaptiste Daroussin.Xr patch
4205*2fd5d190SBaptiste Daroussininterpret the file names differently. To avoid confusion, send output that
4206*2fd5d190SBaptiste Daroussinlooks like this instead:
4207*2fd5d190SBaptiste Daroussin.Pp
4208*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
4209*2fd5d190SBaptiste Daroussindiff -Naur v2.0.29/prog/README v2.0.30/prog/README
4210*2fd5d190SBaptiste Daroussin--- v2.0.29/prog/README	2002-03-10 23:30:39.942229878 -0800
4211*2fd5d190SBaptiste Daroussin+++ v2.0.30/prog/README	2002-03-17 20:49:32.442260588 -0800
4212*2fd5d190SBaptiste Daroussin.Ed
4213*2fd5d190SBaptiste Daroussin.Pp
4214*2fd5d190SBaptiste DaroussinMake sure you have specified the file names correctly, either in a context
4215*2fd5d190SBaptiste Daroussindiff header or with an
4216*2fd5d190SBaptiste Daroussin.Li Index:
4217*2fd5d190SBaptiste Daroussinline. Take care to not send out reversed patches, since these make people
4218*2fd5d190SBaptiste Daroussinwonder whether they have already applied the patch.
4219*2fd5d190SBaptiste Daroussin.Pp
4220*2fd5d190SBaptiste DaroussinAvoid sending patches that compare backup file names like
4221*2fd5d190SBaptiste Daroussin.Pa README.orig
4222*2fd5d190SBaptiste Daroussinor
4223*2fd5d190SBaptiste Daroussin.Pa README~ ,
4224*2fd5d190SBaptiste Daroussinsince this might confuse
4225*2fd5d190SBaptiste Daroussin.Xr patch
4226*2fd5d190SBaptiste Daroussininto patching a backup file instead of the real file. Instead, send patches
4227*2fd5d190SBaptiste Daroussinthat compare the same base file names in different directories, e.g.
4228*2fd5d190SBaptiste Daroussin.Pa old/README
4229*2fd5d190SBaptiste Daroussinand
4230*2fd5d190SBaptiste Daroussin.Pa new/README .
4231*2fd5d190SBaptiste Daroussin.Pp
4232*2fd5d190SBaptiste DaroussinTo save people from partially applying a patch before other patches that should
4233*2fd5d190SBaptiste Daroussinhave gone before it, you can make the first patch in the patch file update
4234*2fd5d190SBaptiste Daroussina file with a name like
4235*2fd5d190SBaptiste Daroussin.Pa patchlevel.h
4236*2fd5d190SBaptiste Daroussinor
4237*2fd5d190SBaptiste Daroussin.Pa version.c ,
4238*2fd5d190SBaptiste Daroussinwhich contains a patch level or version number. If the input file contains
4239*2fd5d190SBaptiste Daroussinthe wrong version number,
4240*2fd5d190SBaptiste Daroussin.Xr patch
4241*2fd5d190SBaptiste Daroussinwill complain immediately.
4242*2fd5d190SBaptiste Daroussin.Pp
4243*2fd5d190SBaptiste DaroussinAn even clearer way to prevent this problem is to put a
4244*2fd5d190SBaptiste Daroussin.Li Prereq:
4245*2fd5d190SBaptiste Daroussinline before the patch. If the leading text in the patch file contains a line
4246*2fd5d190SBaptiste Daroussinthat starts with
4247*2fd5d190SBaptiste Daroussin.Li Prereq: ,
4248*2fd5d190SBaptiste Daroussin.Xr patch
4249*2fd5d190SBaptiste Daroussintakes the next word from that line (normally a version number) and checks
4250*2fd5d190SBaptiste Daroussinwhether the next input file contains that word, preceded and followed by either
4251*2fd5d190SBaptiste Daroussinwhite space or a newline. If not,
4252*2fd5d190SBaptiste Daroussin.Xr patch
4253*2fd5d190SBaptiste Daroussinprompts you for confirmation before proceeding. This makes it difficult to
4254*2fd5d190SBaptiste Daroussinaccidentally apply patches in the wrong order.
4255*2fd5d190SBaptiste Daroussin.Pp
4256*2fd5d190SBaptiste Daroussin.Ss  Generating Smaller Patches
4257*2fd5d190SBaptiste DaroussinThe simplest way to generate a patch is to use
4258*2fd5d190SBaptiste Daroussin.Li diff -Naur
4259*2fd5d190SBaptiste Daroussin(see Section
4260*2fd5d190SBaptiste Daroussin.Dq Tips for Patch Producers ) ,
4261*2fd5d190SBaptiste Daroussinbut you might be able to reduce the size of the patch by renaming or removing
4262*2fd5d190SBaptiste Daroussinsome files before making the patch. If the older version of the package contains
4263*2fd5d190SBaptiste Daroussinany files that the newer version does not, or if any files have been renamed
4264*2fd5d190SBaptiste Daroussinbetween the two versions, make a list of
4265*2fd5d190SBaptiste Daroussin.Xr rm
4266*2fd5d190SBaptiste Daroussinand
4267*2fd5d190SBaptiste Daroussin.Xr mv
4268*2fd5d190SBaptiste Daroussincommands for the user to execute in the old version directory before applying
4269*2fd5d190SBaptiste Daroussinthe patch. Then run those commands yourself in the scratch directory.
4270*2fd5d190SBaptiste Daroussin.Pp
4271*2fd5d190SBaptiste DaroussinIf there are any files that you don't need to include in the patch because
4272*2fd5d190SBaptiste Daroussinthey can easily be rebuilt from other files (for example,
4273*2fd5d190SBaptiste Daroussin.Pa TAGS
4274*2fd5d190SBaptiste Daroussinand output from
4275*2fd5d190SBaptiste Daroussin.Xr yacc
4276*2fd5d190SBaptiste Daroussinand
4277*2fd5d190SBaptiste Daroussin.Xr makeinfo ) ,
4278*2fd5d190SBaptiste Daroussinexclude them from the patch by giving
4279*2fd5d190SBaptiste Daroussin.Xr diff
4280*2fd5d190SBaptiste Daroussinthe
4281*2fd5d190SBaptiste Daroussin.Op -x Va pattern
4282*2fd5d190SBaptiste Daroussinoption (see Section
4283*2fd5d190SBaptiste Daroussin.Dq Comparing Directories ) .
4284*2fd5d190SBaptiste DaroussinIf you want your patch to modify a derived file because your recipients lack
4285*2fd5d190SBaptiste Daroussintools to build it, make sure that the patch for the derived file follows any
4286*2fd5d190SBaptiste Daroussinpatches for files that it depends on, so that the recipients' time stamps
4287*2fd5d190SBaptiste Daroussinwill not confuse
4288*2fd5d190SBaptiste Daroussin.Xr make .
4289*2fd5d190SBaptiste Daroussin.Pp
4290*2fd5d190SBaptiste DaroussinNow you can create the patch using
4291*2fd5d190SBaptiste Daroussin.Li diff -Naur .
4292*2fd5d190SBaptiste DaroussinMake sure to specify the scratch directory first and the newer directory second.
4293*2fd5d190SBaptiste Daroussin.Pp
4294*2fd5d190SBaptiste DaroussinAdd to the top of the patch a note telling the user any
4295*2fd5d190SBaptiste Daroussin.Xr rm
4296*2fd5d190SBaptiste Daroussinand
4297*2fd5d190SBaptiste Daroussin.Xr mv
4298*2fd5d190SBaptiste Daroussincommands to run before applying the patch. Then you can remove the scratch
4299*2fd5d190SBaptiste Daroussindirectory.
4300*2fd5d190SBaptiste Daroussin.Pp
4301*2fd5d190SBaptiste DaroussinYou can also shrink the patch size by using fewer lines of context, but bear
4302*2fd5d190SBaptiste Daroussinin mind that
4303*2fd5d190SBaptiste Daroussin.Xr patch
4304*2fd5d190SBaptiste Daroussintypically needs at least two lines for proper operation when patches do not
4305*2fd5d190SBaptiste Daroussinexactly match the input files.
4306*2fd5d190SBaptiste Daroussin.Pp
4307*2fd5d190SBaptiste Daroussin.Sh  Invoking Xr cmp
4308*2fd5d190SBaptiste DaroussinThe
4309*2fd5d190SBaptiste Daroussin.Xr cmp
4310*2fd5d190SBaptiste Daroussincommand compares two files, and if they differ, tells the first byte and line
4311*2fd5d190SBaptiste Daroussinnumber where they differ or reports that one file is a prefix of the other.
4312*2fd5d190SBaptiste DaroussinBytes and lines are numbered starting with 1. The arguments of
4313*2fd5d190SBaptiste Daroussin.Xr cmp
4314*2fd5d190SBaptiste Daroussinare as follows:
4315*2fd5d190SBaptiste Daroussin.Pp
4316*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
4317*2fd5d190SBaptiste Daroussincmp options... from-file [to-file [from-skip [to-skip]]]
4318*2fd5d190SBaptiste Daroussin.Ed
4319*2fd5d190SBaptiste Daroussin.Pp
4320*2fd5d190SBaptiste DaroussinThe file name
4321*2fd5d190SBaptiste Daroussin.Pa -
4322*2fd5d190SBaptiste Daroussinis always the standard input.
4323*2fd5d190SBaptiste Daroussin.Xr cmp
4324*2fd5d190SBaptiste Daroussinalso uses the standard input if one file name is omitted. The
4325*2fd5d190SBaptiste Daroussin.Va from-skip
4326*2fd5d190SBaptiste Daroussinand
4327*2fd5d190SBaptiste Daroussin.Va to-skip
4328*2fd5d190SBaptiste Daroussinoperands specify how many bytes to ignore at the start of each file; they
4329*2fd5d190SBaptiste Daroussinare equivalent to the
4330*2fd5d190SBaptiste Daroussin.Op --ignore-initial= Va from-skip: Va to-skip
4331*2fd5d190SBaptiste Daroussinoption.
4332*2fd5d190SBaptiste Daroussin.Pp
4333*2fd5d190SBaptiste DaroussinBy default,
4334*2fd5d190SBaptiste Daroussin.Xr cmp
4335*2fd5d190SBaptiste Daroussinoutputs nothing if the two files have the same contents. If one file is a
4336*2fd5d190SBaptiste Daroussinprefix of the other,
4337*2fd5d190SBaptiste Daroussin.Xr cmp
4338*2fd5d190SBaptiste Daroussinprints to standard error a message of the following form:
4339*2fd5d190SBaptiste Daroussin.Pp
4340*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
4341*2fd5d190SBaptiste Daroussincmp: EOF on shorter-file
4342*2fd5d190SBaptiste Daroussin.Ed
4343*2fd5d190SBaptiste Daroussin.Pp
4344*2fd5d190SBaptiste DaroussinOtherwise,
4345*2fd5d190SBaptiste Daroussin.Xr cmp
4346*2fd5d190SBaptiste Daroussinprints to standard output a message of the following form:
4347*2fd5d190SBaptiste Daroussin.Pp
4348*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
4349*2fd5d190SBaptiste Daroussinfrom-file to-file differ: char byte-number, line line-number
4350*2fd5d190SBaptiste Daroussin.Ed
4351*2fd5d190SBaptiste Daroussin.Pp
4352*2fd5d190SBaptiste DaroussinThe message formats can differ outside the POSIX locale. Also, POSIX allows
4353*2fd5d190SBaptiste Daroussinthe EOF message to be followed by a blank and some additional information.
4354*2fd5d190SBaptiste Daroussin.Pp
4355*2fd5d190SBaptiste DaroussinAn exit status of 0 means no differences were found, 1 means some differences
4356*2fd5d190SBaptiste Daroussinwere found, and 2 means trouble.
4357*2fd5d190SBaptiste Daroussin.Pp
4358*2fd5d190SBaptiste Daroussin.Ss  Options to Xr cmp
4359*2fd5d190SBaptiste DaroussinBelow is a summary of all of the options that GNU
4360*2fd5d190SBaptiste Daroussin.Xr cmp
4361*2fd5d190SBaptiste Daroussinaccepts. Most options have two equivalent names, one of which is a single
4362*2fd5d190SBaptiste Daroussinletter preceded by
4363*2fd5d190SBaptiste Daroussin.Li - ,
4364*2fd5d190SBaptiste Daroussinand the other of which is a long name preceded by
4365*2fd5d190SBaptiste Daroussin.Li -- .
4366*2fd5d190SBaptiste DaroussinMultiple single letter options (unless they take an argument) can be combined
4367*2fd5d190SBaptiste Daroussininto a single command line word:
4368*2fd5d190SBaptiste Daroussin.Op -bl
4369*2fd5d190SBaptiste Daroussinis equivalent to
4370*2fd5d190SBaptiste Daroussin.Op -b -l .
4371*2fd5d190SBaptiste Daroussin.Pp
4372*2fd5d190SBaptiste Daroussin.Bl -tag -width Ds
4373*2fd5d190SBaptiste Daroussin.It  -b
4374*2fd5d190SBaptiste Daroussin.It  --print-bytes
4375*2fd5d190SBaptiste DaroussinPrint the differing bytes. Display control bytes as a
4376*2fd5d190SBaptiste Daroussin.Li ^
4377*2fd5d190SBaptiste Daroussinfollowed by a letter of the alphabet and precede bytes that have the high
4378*2fd5d190SBaptiste Daroussinbit set with
4379*2fd5d190SBaptiste Daroussin.Li M-
4380*2fd5d190SBaptiste Daroussin(which stands for \(lqmeta\(rq).
4381*2fd5d190SBaptiste Daroussin.Pp
4382*2fd5d190SBaptiste Daroussin.It  --help
4383*2fd5d190SBaptiste DaroussinOutput a summary of usage and then exit.
4384*2fd5d190SBaptiste Daroussin.Pp
4385*2fd5d190SBaptiste Daroussin.It  -i Va skip
4386*2fd5d190SBaptiste Daroussin.It  --ignore-initial= Va skip
4387*2fd5d190SBaptiste DaroussinIgnore any differences in the first
4388*2fd5d190SBaptiste Daroussin.Va skip
4389*2fd5d190SBaptiste Daroussinbytes of the input files. Treat files with fewer than
4390*2fd5d190SBaptiste Daroussin.Va skip
4391*2fd5d190SBaptiste Daroussinbytes as if they are empty. If
4392*2fd5d190SBaptiste Daroussin.Va skip
4393*2fd5d190SBaptiste Daroussinis of the form
4394*2fd5d190SBaptiste Daroussin.Op  Va from-skip: Va to-skip ,
4395*2fd5d190SBaptiste Daroussinskip the first
4396*2fd5d190SBaptiste Daroussin.Va from-skip
4397*2fd5d190SBaptiste Daroussinbytes of the first input file and the first
4398*2fd5d190SBaptiste Daroussin.Va to-skip
4399*2fd5d190SBaptiste Daroussinbytes of the second.
4400*2fd5d190SBaptiste Daroussin.Pp
4401*2fd5d190SBaptiste Daroussin.It  -l
4402*2fd5d190SBaptiste Daroussin.It  --verbose
4403*2fd5d190SBaptiste DaroussinOutput the (decimal) byte numbers and (octal) values of all differing bytes,
4404*2fd5d190SBaptiste Daroussininstead of the default standard output.
4405*2fd5d190SBaptiste Daroussin.Pp
4406*2fd5d190SBaptiste Daroussin.It  -n Va count
4407*2fd5d190SBaptiste Daroussin.It  --bytes= Va count
4408*2fd5d190SBaptiste DaroussinCompare at most
4409*2fd5d190SBaptiste Daroussin.Va count
4410*2fd5d190SBaptiste Daroussininput bytes.
4411*2fd5d190SBaptiste Daroussin.Pp
4412*2fd5d190SBaptiste Daroussin.It  -s
4413*2fd5d190SBaptiste Daroussin.It  --quiet
4414*2fd5d190SBaptiste Daroussin.It  --silent
4415*2fd5d190SBaptiste DaroussinDo not print anything; only return an exit status indicating whether the files
4416*2fd5d190SBaptiste Daroussindiffer.
4417*2fd5d190SBaptiste Daroussin.Pp
4418*2fd5d190SBaptiste Daroussin.It  -v
4419*2fd5d190SBaptiste Daroussin.It  --version
4420*2fd5d190SBaptiste DaroussinOutput version information and then exit.
4421*2fd5d190SBaptiste Daroussin.El
4422*2fd5d190SBaptiste Daroussin.Pp
4423*2fd5d190SBaptiste DaroussinIn the above table, operands that are byte counts are normally decimal, but
4424*2fd5d190SBaptiste Daroussinmay be preceded by
4425*2fd5d190SBaptiste Daroussin.Li 0
4426*2fd5d190SBaptiste Daroussinfor octal and
4427*2fd5d190SBaptiste Daroussin.Li 0x
4428*2fd5d190SBaptiste Daroussinfor hexadecimal.
4429*2fd5d190SBaptiste Daroussin.Pp
4430*2fd5d190SBaptiste DaroussinA byte count can be followed by a suffix to specify a multiple of that count;
4431*2fd5d190SBaptiste Daroussinin this case an omitted integer is understood to be 1. A bare size letter,
4432*2fd5d190SBaptiste Daroussinor one followed by
4433*2fd5d190SBaptiste Daroussin.Li iB ,
4434*2fd5d190SBaptiste Daroussinspecifies a multiple using powers of 1024. A size letter followed by
4435*2fd5d190SBaptiste Daroussin.Li B
4436*2fd5d190SBaptiste Daroussinspecifies powers of 1000 instead. For example,
4437*2fd5d190SBaptiste Daroussin.Op -n 4M
4438*2fd5d190SBaptiste Daroussinand
4439*2fd5d190SBaptiste Daroussin.Op -n 4MiB
4440*2fd5d190SBaptiste Daroussinare equivalent to
4441*2fd5d190SBaptiste Daroussin.Op -n 4194304 ,
4442*2fd5d190SBaptiste Daroussinwhereas
4443*2fd5d190SBaptiste Daroussin.Op -n 4MB
4444*2fd5d190SBaptiste Daroussinis equivalent to
4445*2fd5d190SBaptiste Daroussin.Op -n 4000000 .
4446*2fd5d190SBaptiste DaroussinThis notation is upward compatible with the
4447*2fd5d190SBaptiste Daroussin.Lk http://www.bipm.fr/enus/3_SI/si-prefixes.html
4448*2fd5d190SBaptiste Daroussinfor decimal multiples and with the
4449*2fd5d190SBaptiste Daroussin.Lk http://physics.nist.gov/cuu/Units/binary.html .
4450*2fd5d190SBaptiste Daroussin.Pp
4451*2fd5d190SBaptiste DaroussinThe following suffixes are defined. Large sizes like
4452*2fd5d190SBaptiste Daroussin.Li 1Y
4453*2fd5d190SBaptiste Daroussinmay be rejected by your computer due to limitations of its arithmetic.
4454*2fd5d190SBaptiste Daroussin.Pp
4455*2fd5d190SBaptiste Daroussin.Bl -tag -width Ds
4456*2fd5d190SBaptiste Daroussin.It  kB
4457*2fd5d190SBaptiste Daroussinkilobyte: 10^3 = 1000.
4458*2fd5d190SBaptiste Daroussin.It  k
4459*2fd5d190SBaptiste Daroussin.It  K
4460*2fd5d190SBaptiste Daroussin.It  KiB
4461*2fd5d190SBaptiste Daroussinkibibyte: 2^10 = 1024.
4462*2fd5d190SBaptiste Daroussin.Li K
4463*2fd5d190SBaptiste Daroussinis special: the SI prefix is
4464*2fd5d190SBaptiste Daroussin.Li k
4465*2fd5d190SBaptiste Daroussinand the IEC 60027-2 prefix is
4466*2fd5d190SBaptiste Daroussin.Li Ki ,
4467*2fd5d190SBaptiste Daroussinbut tradition and POSIX use
4468*2fd5d190SBaptiste Daroussin.Li k
4469*2fd5d190SBaptiste Daroussinto mean
4470*2fd5d190SBaptiste Daroussin.Li KiB .
4471*2fd5d190SBaptiste Daroussin.It  MB
4472*2fd5d190SBaptiste Daroussinmegabyte: 10^6 = 1,000,000.
4473*2fd5d190SBaptiste Daroussin.It  M
4474*2fd5d190SBaptiste Daroussin.It  MiB
4475*2fd5d190SBaptiste Daroussinmebibyte: 2^20 = 1,048,576.
4476*2fd5d190SBaptiste Daroussin.It  GB
4477*2fd5d190SBaptiste Daroussingigabyte: 10^9 = 1,000,000,000.
4478*2fd5d190SBaptiste Daroussin.It  G
4479*2fd5d190SBaptiste Daroussin.It  GiB
4480*2fd5d190SBaptiste Daroussingibibyte: 2^30 = 1,073,741,824.
4481*2fd5d190SBaptiste Daroussin.It  TB
4482*2fd5d190SBaptiste Daroussinterabyte: 10^12 = 1,000,000,000,000.
4483*2fd5d190SBaptiste Daroussin.It  T
4484*2fd5d190SBaptiste Daroussin.It  TiB
4485*2fd5d190SBaptiste Daroussintebibyte: 2^40 = 1,099,511,627,776.
4486*2fd5d190SBaptiste Daroussin.It  PB
4487*2fd5d190SBaptiste Daroussinpetabyte: 10^15 = 1,000,000,000,000,000.
4488*2fd5d190SBaptiste Daroussin.It  P
4489*2fd5d190SBaptiste Daroussin.It  PiB
4490*2fd5d190SBaptiste Daroussinpebibyte: 2^50 = 1,125,899,906,842,624.
4491*2fd5d190SBaptiste Daroussin.It  EB
4492*2fd5d190SBaptiste Daroussinexabyte: 10^18 = 1,000,000,000,000,000,000.
4493*2fd5d190SBaptiste Daroussin.It  E
4494*2fd5d190SBaptiste Daroussin.It  EiB
4495*2fd5d190SBaptiste Daroussinexbibyte: 2^60 = 1,152,921,504,606,846,976.
4496*2fd5d190SBaptiste Daroussin.It  ZB
4497*2fd5d190SBaptiste Daroussinzettabyte: 10^21 = 1,000,000,000,000,000,000,000
4498*2fd5d190SBaptiste Daroussin.It  Z
4499*2fd5d190SBaptiste Daroussin.It  ZiB
4500*2fd5d190SBaptiste Daroussin2^70 = 1,180,591,620,717,411,303,424. (
4501*2fd5d190SBaptiste Daroussin.Li Zi
4502*2fd5d190SBaptiste Daroussinis a GNU extension to IEC 60027-2.)
4503*2fd5d190SBaptiste Daroussin.It  YB
4504*2fd5d190SBaptiste Daroussinyottabyte: 10^24 = 1,000,000,000,000,000,000,000,000.
4505*2fd5d190SBaptiste Daroussin.It  Y
4506*2fd5d190SBaptiste Daroussin.It  YiB
4507*2fd5d190SBaptiste Daroussin2^80 = 1,208,925,819,614,629,174,706,176. (
4508*2fd5d190SBaptiste Daroussin.Li Yi
4509*2fd5d190SBaptiste Daroussinis a GNU extension to IEC 60027-2.)
4510*2fd5d190SBaptiste Daroussin.El
4511*2fd5d190SBaptiste Daroussin.Pp
4512*2fd5d190SBaptiste Daroussin.Sh  Invoking Xr diff
4513*2fd5d190SBaptiste DaroussinThe format for running the
4514*2fd5d190SBaptiste Daroussin.Xr diff
4515*2fd5d190SBaptiste Daroussincommand is:
4516*2fd5d190SBaptiste Daroussin.Pp
4517*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
4518*2fd5d190SBaptiste Daroussindiff options... files...
4519*2fd5d190SBaptiste Daroussin.Ed
4520*2fd5d190SBaptiste Daroussin.Pp
4521*2fd5d190SBaptiste DaroussinIn the simplest case, two file names
4522*2fd5d190SBaptiste Daroussin.Va from-file
4523*2fd5d190SBaptiste Daroussinand
4524*2fd5d190SBaptiste Daroussin.Va to-file
4525*2fd5d190SBaptiste Daroussinare given, and
4526*2fd5d190SBaptiste Daroussin.Xr diff
4527*2fd5d190SBaptiste Daroussincompares the contents of
4528*2fd5d190SBaptiste Daroussin.Va from-file
4529*2fd5d190SBaptiste Daroussinand
4530*2fd5d190SBaptiste Daroussin.Va to-file .
4531*2fd5d190SBaptiste DaroussinA file name of
4532*2fd5d190SBaptiste Daroussin.Pa -
4533*2fd5d190SBaptiste Daroussinstands for text read from the standard input. As a special case,
4534*2fd5d190SBaptiste Daroussin.Li diff - -
4535*2fd5d190SBaptiste Daroussincompares a copy of standard input to itself.
4536*2fd5d190SBaptiste Daroussin.Pp
4537*2fd5d190SBaptiste DaroussinIf one file is a directory and the other is not,
4538*2fd5d190SBaptiste Daroussin.Xr diff
4539*2fd5d190SBaptiste Daroussincompares the file in the directory whose name is that of the non-directory.
4540*2fd5d190SBaptiste DaroussinThe non-directory file must not be
4541*2fd5d190SBaptiste Daroussin.Pa - .
4542*2fd5d190SBaptiste Daroussin.Pp
4543*2fd5d190SBaptiste DaroussinIf two file names are given and both are directories,
4544*2fd5d190SBaptiste Daroussin.Xr diff
4545*2fd5d190SBaptiste Daroussincompares corresponding files in both directories, in alphabetical order; this
4546*2fd5d190SBaptiste Daroussincomparison is not recursive unless the
4547*2fd5d190SBaptiste Daroussin.Op -r
4548*2fd5d190SBaptiste Daroussinor
4549*2fd5d190SBaptiste Daroussin.Op --recursive
4550*2fd5d190SBaptiste Daroussinoption is given.
4551*2fd5d190SBaptiste Daroussin.Xr diff
4552*2fd5d190SBaptiste Daroussinnever compares the actual contents of a directory as if it were a file. The
4553*2fd5d190SBaptiste Daroussinfile that is fully specified may not be standard input, because standard input
4554*2fd5d190SBaptiste Daroussinis nameless and the notion of \(lqfile with the same name\(rq does not apply.
4555*2fd5d190SBaptiste Daroussin.Pp
4556*2fd5d190SBaptiste DaroussinIf the
4557*2fd5d190SBaptiste Daroussin.Op --from-file= Va file
4558*2fd5d190SBaptiste Daroussinoption is given, the number of file names is arbitrary, and
4559*2fd5d190SBaptiste Daroussin.Va file
4560*2fd5d190SBaptiste Daroussinis compared to each named file. Similarly, if the
4561*2fd5d190SBaptiste Daroussin.Op --to-file= Va file
4562*2fd5d190SBaptiste Daroussinoption is given, each named file is compared to
4563*2fd5d190SBaptiste Daroussin.Va file .
4564*2fd5d190SBaptiste Daroussin.Pp
4565*2fd5d190SBaptiste Daroussin.Xr diff
4566*2fd5d190SBaptiste Daroussinoptions begin with
4567*2fd5d190SBaptiste Daroussin.Li - ,
4568*2fd5d190SBaptiste Daroussinso normally file names may not begin with
4569*2fd5d190SBaptiste Daroussin.Li - .
4570*2fd5d190SBaptiste DaroussinHowever,
4571*2fd5d190SBaptiste Daroussin.Op --
4572*2fd5d190SBaptiste Daroussinas an argument by itself treats the remaining arguments as file names even
4573*2fd5d190SBaptiste Daroussinif they begin with
4574*2fd5d190SBaptiste Daroussin.Li - .
4575*2fd5d190SBaptiste Daroussin.Pp
4576*2fd5d190SBaptiste DaroussinAn exit status of 0 means no differences were found, 1 means some differences
4577*2fd5d190SBaptiste Daroussinwere found, and 2 means trouble. Normally, differing binary files count as
4578*2fd5d190SBaptiste Daroussintrouble, but this can be altered by using the
4579*2fd5d190SBaptiste Daroussin.Op -a
4580*2fd5d190SBaptiste Daroussinor
4581*2fd5d190SBaptiste Daroussin.Op --text
4582*2fd5d190SBaptiste Daroussinoption, or the
4583*2fd5d190SBaptiste Daroussin.Op -q
4584*2fd5d190SBaptiste Daroussinor
4585*2fd5d190SBaptiste Daroussin.Op --brief
4586*2fd5d190SBaptiste Daroussinoption.
4587*2fd5d190SBaptiste Daroussin.Pp
4588*2fd5d190SBaptiste Daroussin.Ss  Options to Xr diff
4589*2fd5d190SBaptiste DaroussinBelow is a summary of all of the options that GNU
4590*2fd5d190SBaptiste Daroussin.Xr diff
4591*2fd5d190SBaptiste Daroussinaccepts. Most options have two equivalent names, one of which is a single
4592*2fd5d190SBaptiste Daroussinletter preceded by
4593*2fd5d190SBaptiste Daroussin.Li - ,
4594*2fd5d190SBaptiste Daroussinand the other of which is a long name preceded by
4595*2fd5d190SBaptiste Daroussin.Li -- .
4596*2fd5d190SBaptiste DaroussinMultiple single letter options (unless they take an argument) can be combined
4597*2fd5d190SBaptiste Daroussininto a single command line word:
4598*2fd5d190SBaptiste Daroussin.Op -ac
4599*2fd5d190SBaptiste Daroussinis equivalent to
4600*2fd5d190SBaptiste Daroussin.Op -a -c .
4601*2fd5d190SBaptiste DaroussinLong named options can be abbreviated to any unique prefix of their name.
4602*2fd5d190SBaptiste DaroussinBrackets ([ and ]) indicate that an option takes an optional argument.
4603*2fd5d190SBaptiste Daroussin.Pp
4604*2fd5d190SBaptiste Daroussin.Bl -tag -width Ds
4605*2fd5d190SBaptiste Daroussin.It  -a
4606*2fd5d190SBaptiste Daroussin.It  --text
4607*2fd5d190SBaptiste DaroussinTreat all files as text and compare them line-by-line, even if they do not
4608*2fd5d190SBaptiste Daroussinseem to be text.See Section
4609*2fd5d190SBaptiste Daroussin.Dq Binary .
4610*2fd5d190SBaptiste Daroussin.Pp
4611*2fd5d190SBaptiste Daroussin.It  -b
4612*2fd5d190SBaptiste Daroussin.It  --ignore-space-change
4613*2fd5d190SBaptiste DaroussinIgnore changes in amount of white space.See Section
4614*2fd5d190SBaptiste Daroussin.Dq White Space .
4615*2fd5d190SBaptiste Daroussin.Pp
4616*2fd5d190SBaptiste Daroussin.It  -B
4617*2fd5d190SBaptiste Daroussin.It  --ignore-blank-lines
4618*2fd5d190SBaptiste DaroussinIgnore changes that just insert or delete blank lines.See Section
4619*2fd5d190SBaptiste Daroussin.Dq Blank Lines .
4620*2fd5d190SBaptiste Daroussin.Pp
4621*2fd5d190SBaptiste Daroussin.It  --binary
4622*2fd5d190SBaptiste DaroussinRead and write data in binary mode.See Section
4623*2fd5d190SBaptiste Daroussin.Dq Binary .
4624*2fd5d190SBaptiste Daroussin.Pp
4625*2fd5d190SBaptiste Daroussin.It  -c
4626*2fd5d190SBaptiste DaroussinUse the context output format, showing three lines of context.See Section
4627*2fd5d190SBaptiste Daroussin.Dq Context Format .
4628*2fd5d190SBaptiste Daroussin.Pp
4629*2fd5d190SBaptiste Daroussin.It  -C Va lines
4630*2fd5d190SBaptiste Daroussin.It  --context[= Va lines]
4631*2fd5d190SBaptiste DaroussinUse the context output format, showing
4632*2fd5d190SBaptiste Daroussin.Va lines
4633*2fd5d190SBaptiste Daroussin(an integer) lines of context, or three if
4634*2fd5d190SBaptiste Daroussin.Va lines
4635*2fd5d190SBaptiste Daroussinis not given.See Section
4636*2fd5d190SBaptiste Daroussin.Dq Context Format .
4637*2fd5d190SBaptiste DaroussinFor proper operation,
4638*2fd5d190SBaptiste Daroussin.Xr patch
4639*2fd5d190SBaptiste Daroussintypically needs at least two lines of context.
4640*2fd5d190SBaptiste Daroussin.Pp
4641*2fd5d190SBaptiste DaroussinOn older systems,
4642*2fd5d190SBaptiste Daroussin.Xr diff
4643*2fd5d190SBaptiste Daroussinsupports an obsolete option
4644*2fd5d190SBaptiste Daroussin.Op - Va lines
4645*2fd5d190SBaptiste Daroussinthat has effect when combined with
4646*2fd5d190SBaptiste Daroussin.Op -c
4647*2fd5d190SBaptiste Daroussinor
4648*2fd5d190SBaptiste Daroussin.Op -p .
4649*2fd5d190SBaptiste DaroussinPOSIX 1003.1-2001 (see Section
4650*2fd5d190SBaptiste Daroussin.Dq Standards conformance )
4651*2fd5d190SBaptiste Daroussindoes not allow this; use
4652*2fd5d190SBaptiste Daroussin.Op -C Va lines
4653*2fd5d190SBaptiste Daroussininstead.
4654*2fd5d190SBaptiste Daroussin.Pp
4655*2fd5d190SBaptiste Daroussin.It  --changed-group-format= Va format
4656*2fd5d190SBaptiste DaroussinUse
4657*2fd5d190SBaptiste Daroussin.Va format
4658*2fd5d190SBaptiste Daroussinto output a line group containing differing lines from both files in if-then-else
4659*2fd5d190SBaptiste Daroussinformat.See Section
4660*2fd5d190SBaptiste Daroussin.Dq Line Group Formats .
4661*2fd5d190SBaptiste Daroussin.Pp
4662*2fd5d190SBaptiste Daroussin.It  -d
4663*2fd5d190SBaptiste Daroussin.It  --minimal
4664*2fd5d190SBaptiste DaroussinChange the algorithm perhaps find a smaller set of changes. This makes
4665*2fd5d190SBaptiste Daroussin.Xr diff
4666*2fd5d190SBaptiste Daroussinslower (sometimes much slower).See Section
4667*2fd5d190SBaptiste Daroussin.Dq diff Performance .
4668*2fd5d190SBaptiste Daroussin.Pp
4669*2fd5d190SBaptiste Daroussin.It  -D Va name
4670*2fd5d190SBaptiste Daroussin.It  --ifdef= Va name
4671*2fd5d190SBaptiste DaroussinMake merged
4672*2fd5d190SBaptiste Daroussin.Li #ifdef
4673*2fd5d190SBaptiste Daroussinformat output, conditional on the preprocessor macro
4674*2fd5d190SBaptiste Daroussin.Va name .
4675*2fd5d190SBaptiste DaroussinSee Section.Dq If-then-else .
4676*2fd5d190SBaptiste Daroussin.Pp
4677*2fd5d190SBaptiste Daroussin.It  -e
4678*2fd5d190SBaptiste Daroussin.It  --ed
4679*2fd5d190SBaptiste DaroussinMake output that is a valid
4680*2fd5d190SBaptiste Daroussin.Xr ed
4681*2fd5d190SBaptiste Daroussinscript.See Section
4682*2fd5d190SBaptiste Daroussin.Dq ed Scripts .
4683*2fd5d190SBaptiste Daroussin.Pp
4684*2fd5d190SBaptiste Daroussin.It  -E
4685*2fd5d190SBaptiste Daroussin.It  --ignore-tab-expansion
4686*2fd5d190SBaptiste DaroussinIgnore changes due to tab expansion.See Section
4687*2fd5d190SBaptiste Daroussin.Dq White Space .
4688*2fd5d190SBaptiste Daroussin.Pp
4689*2fd5d190SBaptiste Daroussin.It  -f
4690*2fd5d190SBaptiste Daroussin.It  --forward-ed
4691*2fd5d190SBaptiste DaroussinMake output that looks vaguely like an
4692*2fd5d190SBaptiste Daroussin.Xr ed
4693*2fd5d190SBaptiste Daroussinscript but has changes in the order they appear in the file.See Section
4694*2fd5d190SBaptiste Daroussin.Dq Forward ed .
4695*2fd5d190SBaptiste Daroussin.Pp
4696*2fd5d190SBaptiste Daroussin.It  -F Va regexp
4697*2fd5d190SBaptiste Daroussin.It  --show-function-line= Va regexp
4698*2fd5d190SBaptiste DaroussinIn context and unified format, for each hunk of differences, show some of
4699*2fd5d190SBaptiste Daroussinthe last preceding line that matches
4700*2fd5d190SBaptiste Daroussin.Va regexp .
4701*2fd5d190SBaptiste DaroussinSee Section.Dq Specified Headings .
4702*2fd5d190SBaptiste Daroussin.Pp
4703*2fd5d190SBaptiste Daroussin.It  --from-file= Va file
4704*2fd5d190SBaptiste DaroussinCompare
4705*2fd5d190SBaptiste Daroussin.Va file
4706*2fd5d190SBaptiste Daroussinto each operand;
4707*2fd5d190SBaptiste Daroussin.Va file
4708*2fd5d190SBaptiste Daroussinmay be a directory.
4709*2fd5d190SBaptiste Daroussin.Pp
4710*2fd5d190SBaptiste Daroussin.It  --help
4711*2fd5d190SBaptiste DaroussinOutput a summary of usage and then exit.
4712*2fd5d190SBaptiste Daroussin.Pp
4713*2fd5d190SBaptiste Daroussin.It  --horizon-lines= Va lines
4714*2fd5d190SBaptiste DaroussinDo not discard the last
4715*2fd5d190SBaptiste Daroussin.Va lines
4716*2fd5d190SBaptiste Daroussinlines of the common prefix and the first
4717*2fd5d190SBaptiste Daroussin.Va lines
4718*2fd5d190SBaptiste Daroussinlines of the common suffix.See Section
4719*2fd5d190SBaptiste Daroussin.Dq diff Performance .
4720*2fd5d190SBaptiste Daroussin.Pp
4721*2fd5d190SBaptiste Daroussin.It  -i
4722*2fd5d190SBaptiste Daroussin.It  --ignore-case
4723*2fd5d190SBaptiste DaroussinIgnore changes in case; consider upper- and lower-case letters equivalent.See Section
4724*2fd5d190SBaptiste Daroussin.Dq Case Folding .
4725*2fd5d190SBaptiste Daroussin.Pp
4726*2fd5d190SBaptiste Daroussin.It  -I Va regexp
4727*2fd5d190SBaptiste Daroussin.It  --ignore-matching-lines= Va regexp
4728*2fd5d190SBaptiste DaroussinIgnore changes that just insert or delete lines that match
4729*2fd5d190SBaptiste Daroussin.Va regexp .
4730*2fd5d190SBaptiste DaroussinSee Section.Dq Specified Lines .
4731*2fd5d190SBaptiste Daroussin.Pp
4732*2fd5d190SBaptiste Daroussin.It  --ignore-file-name-case
4733*2fd5d190SBaptiste DaroussinIgnore case when comparing file names during recursive comparison.See Section
4734*2fd5d190SBaptiste Daroussin.Dq Comparing Directories .
4735*2fd5d190SBaptiste Daroussin.Pp
4736*2fd5d190SBaptiste Daroussin.It  -l
4737*2fd5d190SBaptiste Daroussin.It  --paginate
4738*2fd5d190SBaptiste DaroussinPass the output through
4739*2fd5d190SBaptiste Daroussin.Xr pr
4740*2fd5d190SBaptiste Daroussinto paginate it.See Section
4741*2fd5d190SBaptiste Daroussin.Dq Pagination .
4742*2fd5d190SBaptiste Daroussin.Pp
4743*2fd5d190SBaptiste Daroussin.It  --label= Va label
4744*2fd5d190SBaptiste DaroussinUse
4745*2fd5d190SBaptiste Daroussin.Va label
4746*2fd5d190SBaptiste Daroussininstead of the file name in the context format (see Section
4747*2fd5d190SBaptiste Daroussin.Dq Context Format )
4748*2fd5d190SBaptiste Daroussinand unified format (see Section
4749*2fd5d190SBaptiste Daroussin.Dq Unified Format )
4750*2fd5d190SBaptiste Daroussinheaders.See Section
4751*2fd5d190SBaptiste Daroussin.Dq RCS .
4752*2fd5d190SBaptiste Daroussin.Pp
4753*2fd5d190SBaptiste Daroussin.It  --left-column
4754*2fd5d190SBaptiste DaroussinPrint only the left column of two common lines in side by side format.See Section
4755*2fd5d190SBaptiste Daroussin.Dq Side by Side Format .
4756*2fd5d190SBaptiste Daroussin.Pp
4757*2fd5d190SBaptiste Daroussin.It  --line-format= Va format
4758*2fd5d190SBaptiste DaroussinUse
4759*2fd5d190SBaptiste Daroussin.Va format
4760*2fd5d190SBaptiste Daroussinto output all input lines in if-then-else format.See Section
4761*2fd5d190SBaptiste Daroussin.Dq Line Formats .
4762*2fd5d190SBaptiste Daroussin.Pp
4763*2fd5d190SBaptiste Daroussin.It  -n
4764*2fd5d190SBaptiste Daroussin.It  --rcs
4765*2fd5d190SBaptiste DaroussinOutput RCS-format diffs; like
4766*2fd5d190SBaptiste Daroussin.Op -f
4767*2fd5d190SBaptiste Daroussinexcept that each command specifies the number of lines affected.See Section
4768*2fd5d190SBaptiste Daroussin.Dq RCS .
4769*2fd5d190SBaptiste Daroussin.Pp
4770*2fd5d190SBaptiste Daroussin.It  -N
4771*2fd5d190SBaptiste Daroussin.It  --new-file
4772*2fd5d190SBaptiste DaroussinIn directory comparison, if a file is found in only one directory, treat it
4773*2fd5d190SBaptiste Daroussinas present but empty in the other directory.See Section
4774*2fd5d190SBaptiste Daroussin.Dq Comparing Directories .
4775*2fd5d190SBaptiste Daroussin.Pp
4776*2fd5d190SBaptiste Daroussin.It  --new-group-format= Va format
4777*2fd5d190SBaptiste DaroussinUse
4778*2fd5d190SBaptiste Daroussin.Va format
4779*2fd5d190SBaptiste Daroussinto output a group of lines taken from just the second file in if-then-else
4780*2fd5d190SBaptiste Daroussinformat.See Section
4781*2fd5d190SBaptiste Daroussin.Dq Line Group Formats .
4782*2fd5d190SBaptiste Daroussin.Pp
4783*2fd5d190SBaptiste Daroussin.It  --new-line-format= Va format
4784*2fd5d190SBaptiste DaroussinUse
4785*2fd5d190SBaptiste Daroussin.Va format
4786*2fd5d190SBaptiste Daroussinto output a line taken from just the second file in if-then-else format.See Section
4787*2fd5d190SBaptiste Daroussin.Dq Line Formats .
4788*2fd5d190SBaptiste Daroussin.Pp
4789*2fd5d190SBaptiste Daroussin.It  --old-group-format= Va format
4790*2fd5d190SBaptiste DaroussinUse
4791*2fd5d190SBaptiste Daroussin.Va format
4792*2fd5d190SBaptiste Daroussinto output a group of lines taken from just the first file in if-then-else
4793*2fd5d190SBaptiste Daroussinformat.See Section
4794*2fd5d190SBaptiste Daroussin.Dq Line Group Formats .
4795*2fd5d190SBaptiste Daroussin.Pp
4796*2fd5d190SBaptiste Daroussin.It  --old-line-format= Va format
4797*2fd5d190SBaptiste DaroussinUse
4798*2fd5d190SBaptiste Daroussin.Va format
4799*2fd5d190SBaptiste Daroussinto output a line taken from just the first file in if-then-else format.See Section
4800*2fd5d190SBaptiste Daroussin.Dq Line Formats .
4801*2fd5d190SBaptiste Daroussin.Pp
4802*2fd5d190SBaptiste Daroussin.It  -p
4803*2fd5d190SBaptiste Daroussin.It  --show-c-function
4804*2fd5d190SBaptiste DaroussinShow which C function each change is in.See Section
4805*2fd5d190SBaptiste Daroussin.Dq C Function Headings .
4806*2fd5d190SBaptiste Daroussin.Pp
4807*2fd5d190SBaptiste Daroussin.It  -q
4808*2fd5d190SBaptiste Daroussin.It  --brief
4809*2fd5d190SBaptiste DaroussinReport only whether the files differ, not the details of the differences.See Section
4810*2fd5d190SBaptiste Daroussin.Dq Brief .
4811*2fd5d190SBaptiste Daroussin.Pp
4812*2fd5d190SBaptiste Daroussin.It  -r
4813*2fd5d190SBaptiste Daroussin.It  --recursive
4814*2fd5d190SBaptiste DaroussinWhen comparing directories, recursively compare any subdirectories found.See Section
4815*2fd5d190SBaptiste Daroussin.Dq Comparing Directories .
4816*2fd5d190SBaptiste Daroussin.Pp
4817*2fd5d190SBaptiste Daroussin.It  -s
4818*2fd5d190SBaptiste Daroussin.It  --report-identical-files
4819*2fd5d190SBaptiste DaroussinReport when two files are the same.See Section
4820*2fd5d190SBaptiste Daroussin.Dq Comparing Directories .
4821*2fd5d190SBaptiste Daroussin.Pp
4822*2fd5d190SBaptiste Daroussin.It  -S Va file
4823*2fd5d190SBaptiste Daroussin.It  --starting-file= Va file
4824*2fd5d190SBaptiste DaroussinWhen comparing directories, start with the file
4825*2fd5d190SBaptiste Daroussin.Va file .
4826*2fd5d190SBaptiste DaroussinThis is used for resuming an aborted comparison.See Section
4827*2fd5d190SBaptiste Daroussin.Dq Comparing Directories .
4828*2fd5d190SBaptiste Daroussin.Pp
4829*2fd5d190SBaptiste Daroussin.It  --speed-large-files
4830*2fd5d190SBaptiste DaroussinUse heuristics to speed handling of large files that have numerous scattered
4831*2fd5d190SBaptiste Daroussinsmall changes.See Section
4832*2fd5d190SBaptiste Daroussin.Dq diff Performance .
4833*2fd5d190SBaptiste Daroussin.Pp
4834*2fd5d190SBaptiste Daroussin.It  --strip-trailing-cr
4835*2fd5d190SBaptiste DaroussinStrip any trailing carriage return at the end of an input line.See Section
4836*2fd5d190SBaptiste Daroussin.Dq Binary .
4837*2fd5d190SBaptiste Daroussin.Pp
4838*2fd5d190SBaptiste Daroussin.It  --suppress-common-lines
4839*2fd5d190SBaptiste DaroussinDo not print common lines in side by side format.See Section
4840*2fd5d190SBaptiste Daroussin.Dq Side by Side Format .
4841*2fd5d190SBaptiste Daroussin.Pp
4842*2fd5d190SBaptiste Daroussin.It  -t
4843*2fd5d190SBaptiste Daroussin.It  --expand-tabs
4844*2fd5d190SBaptiste DaroussinExpand tabs to spaces in the output, to preserve the alignment of tabs in
4845*2fd5d190SBaptiste Daroussinthe input files.See Section
4846*2fd5d190SBaptiste Daroussin.Dq Tabs .
4847*2fd5d190SBaptiste Daroussin.Pp
4848*2fd5d190SBaptiste Daroussin.It  -T
4849*2fd5d190SBaptiste Daroussin.It  --initial-tab
4850*2fd5d190SBaptiste DaroussinOutput a tab rather than a space before the text of a line in normal or context
4851*2fd5d190SBaptiste Daroussinformat. This causes the alignment of tabs in the line to look normal.See Section
4852*2fd5d190SBaptiste Daroussin.Dq Tabs .
4853*2fd5d190SBaptiste Daroussin.Pp
4854*2fd5d190SBaptiste Daroussin.It  --tabsize= Va columns
4855*2fd5d190SBaptiste DaroussinAssume that tab stops are set every
4856*2fd5d190SBaptiste Daroussin.Va columns
4857*2fd5d190SBaptiste Daroussin(default 8) print columns.See Section
4858*2fd5d190SBaptiste Daroussin.Dq Tabs .
4859*2fd5d190SBaptiste Daroussin.Pp
4860*2fd5d190SBaptiste Daroussin.It  --to-file= Va file
4861*2fd5d190SBaptiste DaroussinCompare each operand to
4862*2fd5d190SBaptiste Daroussin.Va file
4863*2fd5d190SBaptiste Daroussin;
4864*2fd5d190SBaptiste Daroussin.Va file
4865*2fd5d190SBaptiste Daroussinmay be a directory.
4866*2fd5d190SBaptiste Daroussin.Pp
4867*2fd5d190SBaptiste Daroussin.It  -u
4868*2fd5d190SBaptiste DaroussinUse the unified output format, showing three lines of context.See Section
4869*2fd5d190SBaptiste Daroussin.Dq Unified Format .
4870*2fd5d190SBaptiste Daroussin.Pp
4871*2fd5d190SBaptiste Daroussin.It  --unchanged-group-format= Va format
4872*2fd5d190SBaptiste DaroussinUse
4873*2fd5d190SBaptiste Daroussin.Va format
4874*2fd5d190SBaptiste Daroussinto output a group of common lines taken from both files in if-then-else format.See Section
4875*2fd5d190SBaptiste Daroussin.Dq Line Group Formats .
4876*2fd5d190SBaptiste Daroussin.Pp
4877*2fd5d190SBaptiste Daroussin.It  --unchanged-line-format= Va format
4878*2fd5d190SBaptiste DaroussinUse
4879*2fd5d190SBaptiste Daroussin.Va format
4880*2fd5d190SBaptiste Daroussinto output a line common to both files in if-then-else format.See Section
4881*2fd5d190SBaptiste Daroussin.Dq Line Formats .
4882*2fd5d190SBaptiste Daroussin.Pp
4883*2fd5d190SBaptiste Daroussin.It  --unidirectional-new-file
4884*2fd5d190SBaptiste DaroussinWhen comparing directories, if a file appears only in the second directory
4885*2fd5d190SBaptiste Daroussinof the two, treat it as present but empty in the other.See Section
4886*2fd5d190SBaptiste Daroussin.Dq Comparing Directories .
4887*2fd5d190SBaptiste Daroussin.Pp
4888*2fd5d190SBaptiste Daroussin.It  -U Va lines
4889*2fd5d190SBaptiste Daroussin.It  --unified[= Va lines]
4890*2fd5d190SBaptiste DaroussinUse the unified output format, showing
4891*2fd5d190SBaptiste Daroussin.Va lines
4892*2fd5d190SBaptiste Daroussin(an integer) lines of context, or three if
4893*2fd5d190SBaptiste Daroussin.Va lines
4894*2fd5d190SBaptiste Daroussinis not given.See Section
4895*2fd5d190SBaptiste Daroussin.Dq Unified Format .
4896*2fd5d190SBaptiste DaroussinFor proper operation,
4897*2fd5d190SBaptiste Daroussin.Xr patch
4898*2fd5d190SBaptiste Daroussintypically needs at least two lines of context.
4899*2fd5d190SBaptiste Daroussin.Pp
4900*2fd5d190SBaptiste DaroussinOn older systems,
4901*2fd5d190SBaptiste Daroussin.Xr diff
4902*2fd5d190SBaptiste Daroussinsupports an obsolete option
4903*2fd5d190SBaptiste Daroussin.Op - Va lines
4904*2fd5d190SBaptiste Daroussinthat has effect when combined with
4905*2fd5d190SBaptiste Daroussin.Op -u .
4906*2fd5d190SBaptiste DaroussinPOSIX 1003.1-2001 (see Section
4907*2fd5d190SBaptiste Daroussin.Dq Standards conformance )
4908*2fd5d190SBaptiste Daroussindoes not allow this; use
4909*2fd5d190SBaptiste Daroussin.Op -U Va lines
4910*2fd5d190SBaptiste Daroussininstead.
4911*2fd5d190SBaptiste Daroussin.Pp
4912*2fd5d190SBaptiste Daroussin.It  -v
4913*2fd5d190SBaptiste Daroussin.It  --version
4914*2fd5d190SBaptiste DaroussinOutput version information and then exit.
4915*2fd5d190SBaptiste Daroussin.Pp
4916*2fd5d190SBaptiste Daroussin.It  -w
4917*2fd5d190SBaptiste Daroussin.It  --ignore-all-space
4918*2fd5d190SBaptiste DaroussinIgnore white space when comparing lines.See Section
4919*2fd5d190SBaptiste Daroussin.Dq White Space .
4920*2fd5d190SBaptiste Daroussin.Pp
4921*2fd5d190SBaptiste Daroussin.It  -W Va columns
4922*2fd5d190SBaptiste Daroussin.It  --width= Va columns
4923*2fd5d190SBaptiste DaroussinOutput at most
4924*2fd5d190SBaptiste Daroussin.Va columns
4925*2fd5d190SBaptiste Daroussin(default 130) print columns per line in side by side format.See Section
4926*2fd5d190SBaptiste Daroussin.Dq Side by Side Format .
4927*2fd5d190SBaptiste Daroussin.Pp
4928*2fd5d190SBaptiste Daroussin.It  -x Va pattern
4929*2fd5d190SBaptiste Daroussin.It  --exclude= Va pattern
4930*2fd5d190SBaptiste DaroussinWhen comparing directories, ignore files and subdirectories whose basenames
4931*2fd5d190SBaptiste Daroussinmatch
4932*2fd5d190SBaptiste Daroussin.Va pattern .
4933*2fd5d190SBaptiste DaroussinSee Section.Dq Comparing Directories .
4934*2fd5d190SBaptiste Daroussin.Pp
4935*2fd5d190SBaptiste Daroussin.It  -X Va file
4936*2fd5d190SBaptiste Daroussin.It  --exclude-from= Va file
4937*2fd5d190SBaptiste DaroussinWhen comparing directories, ignore files and subdirectories whose basenames
4938*2fd5d190SBaptiste Daroussinmatch any pattern contained in
4939*2fd5d190SBaptiste Daroussin.Va file .
4940*2fd5d190SBaptiste DaroussinSee Section.Dq Comparing Directories .
4941*2fd5d190SBaptiste Daroussin.Pp
4942*2fd5d190SBaptiste Daroussin.It  -y
4943*2fd5d190SBaptiste Daroussin.It  --side-by-side
4944*2fd5d190SBaptiste DaroussinUse the side by side output format.See Section
4945*2fd5d190SBaptiste Daroussin.Dq Side by Side Format .
4946*2fd5d190SBaptiste Daroussin.El
4947*2fd5d190SBaptiste Daroussin.Pp
4948*2fd5d190SBaptiste Daroussin.Sh  Invoking Xr diff3
4949*2fd5d190SBaptiste DaroussinThe
4950*2fd5d190SBaptiste Daroussin.Xr diff3
4951*2fd5d190SBaptiste Daroussincommand compares three files and outputs descriptions of their differences.
4952*2fd5d190SBaptiste DaroussinIts arguments are as follows:
4953*2fd5d190SBaptiste Daroussin.Pp
4954*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
4955*2fd5d190SBaptiste Daroussindiff3 options... mine older yours
4956*2fd5d190SBaptiste Daroussin.Ed
4957*2fd5d190SBaptiste Daroussin.Pp
4958*2fd5d190SBaptiste DaroussinThe files to compare are
4959*2fd5d190SBaptiste Daroussin.Va mine ,
4960*2fd5d190SBaptiste Daroussin.Va older ,
4961*2fd5d190SBaptiste Daroussinand
4962*2fd5d190SBaptiste Daroussin.Va yours .
4963*2fd5d190SBaptiste DaroussinAt most one of these three file names may be
4964*2fd5d190SBaptiste Daroussin.Pa - ,
4965*2fd5d190SBaptiste Daroussinwhich tells
4966*2fd5d190SBaptiste Daroussin.Xr diff3
4967*2fd5d190SBaptiste Daroussinto read the standard input for that file.
4968*2fd5d190SBaptiste Daroussin.Pp
4969*2fd5d190SBaptiste DaroussinAn exit status of 0 means
4970*2fd5d190SBaptiste Daroussin.Xr diff3
4971*2fd5d190SBaptiste Daroussinwas successful, 1 means some conflicts were found, and 2 means trouble.
4972*2fd5d190SBaptiste Daroussin.Pp
4973*2fd5d190SBaptiste Daroussin.Ss  Options to Xr diff3
4974*2fd5d190SBaptiste DaroussinBelow is a summary of all of the options that GNU
4975*2fd5d190SBaptiste Daroussin.Xr diff3
4976*2fd5d190SBaptiste Daroussinaccepts. Multiple single letter options (unless they take an argument) can
4977*2fd5d190SBaptiste Daroussinbe combined into a single command line argument.
4978*2fd5d190SBaptiste Daroussin.Pp
4979*2fd5d190SBaptiste Daroussin.Bl -tag -width Ds
4980*2fd5d190SBaptiste Daroussin.It  -a
4981*2fd5d190SBaptiste Daroussin.It  --text
4982*2fd5d190SBaptiste DaroussinTreat all files as text and compare them line-by-line, even if they do not
4983*2fd5d190SBaptiste Daroussinappear to be text.See Section
4984*2fd5d190SBaptiste Daroussin.Dq Binary .
4985*2fd5d190SBaptiste Daroussin.Pp
4986*2fd5d190SBaptiste Daroussin.It  -A
4987*2fd5d190SBaptiste Daroussin.It  --show-all
4988*2fd5d190SBaptiste DaroussinIncorporate all unmerged changes from
4989*2fd5d190SBaptiste Daroussin.Va older
4990*2fd5d190SBaptiste Daroussinto
4991*2fd5d190SBaptiste Daroussin.Va yours
4992*2fd5d190SBaptiste Daroussininto
4993*2fd5d190SBaptiste Daroussin.Va mine ,
4994*2fd5d190SBaptiste Daroussinsurrounding conflicts with bracket lines.See Section
4995*2fd5d190SBaptiste Daroussin.Dq Marking Conflicts .
4996*2fd5d190SBaptiste Daroussin.Pp
4997*2fd5d190SBaptiste Daroussin.It  --diff-program= Va program
4998*2fd5d190SBaptiste DaroussinUse the compatible comparison program
4999*2fd5d190SBaptiste Daroussin.Va program
5000*2fd5d190SBaptiste Daroussinto compare files instead of
5001*2fd5d190SBaptiste Daroussin.Xr diff .
5002*2fd5d190SBaptiste Daroussin.Pp
5003*2fd5d190SBaptiste Daroussin.It  -e
5004*2fd5d190SBaptiste Daroussin.It  --ed
5005*2fd5d190SBaptiste DaroussinGenerate an
5006*2fd5d190SBaptiste Daroussin.Xr ed
5007*2fd5d190SBaptiste Daroussinscript that incorporates all the changes from
5008*2fd5d190SBaptiste Daroussin.Va older
5009*2fd5d190SBaptiste Daroussinto
5010*2fd5d190SBaptiste Daroussin.Va yours
5011*2fd5d190SBaptiste Daroussininto
5012*2fd5d190SBaptiste Daroussin.Va mine .
5013*2fd5d190SBaptiste DaroussinSee Section.Dq Which Changes .
5014*2fd5d190SBaptiste Daroussin.Pp
5015*2fd5d190SBaptiste Daroussin.It  -E
5016*2fd5d190SBaptiste Daroussin.It  --show-overlap
5017*2fd5d190SBaptiste DaroussinLike
5018*2fd5d190SBaptiste Daroussin.Op -e ,
5019*2fd5d190SBaptiste Daroussinexcept bracket lines from overlapping changes' first and third files.See Section
5020*2fd5d190SBaptiste Daroussin.Dq Marking Conflicts .
5021*2fd5d190SBaptiste DaroussinWith
5022*2fd5d190SBaptiste Daroussin.Op -E ,
5023*2fd5d190SBaptiste Daroussinan overlapping change looks like this:
5024*2fd5d190SBaptiste Daroussin.Pp
5025*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
5026*2fd5d190SBaptiste Daroussin<<<<<<< mine
5027*2fd5d190SBaptiste Daroussinlines from mine
5028*2fd5d190SBaptiste Daroussin=======
5029*2fd5d190SBaptiste Daroussinlines from yours
5030*2fd5d190SBaptiste Daroussin>>>>>>> yours
5031*2fd5d190SBaptiste Daroussin.Ed
5032*2fd5d190SBaptiste Daroussin.Pp
5033*2fd5d190SBaptiste Daroussin.It  --help
5034*2fd5d190SBaptiste DaroussinOutput a summary of usage and then exit.
5035*2fd5d190SBaptiste Daroussin.Pp
5036*2fd5d190SBaptiste Daroussin.It  -i
5037*2fd5d190SBaptiste DaroussinGenerate
5038*2fd5d190SBaptiste Daroussin.Li w
5039*2fd5d190SBaptiste Daroussinand
5040*2fd5d190SBaptiste Daroussin.Li q
5041*2fd5d190SBaptiste Daroussincommands at the end of the
5042*2fd5d190SBaptiste Daroussin.Xr ed
5043*2fd5d190SBaptiste Daroussinscript for System V compatibility. This option must be combined with one of
5044*2fd5d190SBaptiste Daroussinthe
5045*2fd5d190SBaptiste Daroussin.Op -AeExX3
5046*2fd5d190SBaptiste Daroussinoptions, and may not be combined with
5047*2fd5d190SBaptiste Daroussin.Op -m .
5048*2fd5d190SBaptiste DaroussinSee Section.Dq Saving the Changed File .
5049*2fd5d190SBaptiste Daroussin.Pp
5050*2fd5d190SBaptiste Daroussin.It  --label= Va label
5051*2fd5d190SBaptiste DaroussinUse the label
5052*2fd5d190SBaptiste Daroussin.Va label
5053*2fd5d190SBaptiste Daroussinfor the brackets output by the
5054*2fd5d190SBaptiste Daroussin.Op -A ,
5055*2fd5d190SBaptiste Daroussin.Op -E
5056*2fd5d190SBaptiste Daroussinand
5057*2fd5d190SBaptiste Daroussin.Op -X
5058*2fd5d190SBaptiste Daroussinoptions. This option may be given up to three times, one for each input file.
5059*2fd5d190SBaptiste DaroussinThe default labels are the names of the input files. Thus
5060*2fd5d190SBaptiste Daroussin.Li diff3 --label X --label Y --label Z -m A B C
5061*2fd5d190SBaptiste Daroussinacts like
5062*2fd5d190SBaptiste Daroussin.Li diff3 -m A B C ,
5063*2fd5d190SBaptiste Daroussinexcept that the output looks like it came from files named
5064*2fd5d190SBaptiste Daroussin.Li X ,
5065*2fd5d190SBaptiste Daroussin.Li Y
5066*2fd5d190SBaptiste Daroussinand
5067*2fd5d190SBaptiste Daroussin.Li Z
5068*2fd5d190SBaptiste Daroussinrather than from files named
5069*2fd5d190SBaptiste Daroussin.Li A ,
5070*2fd5d190SBaptiste Daroussin.Li B
5071*2fd5d190SBaptiste Daroussinand
5072*2fd5d190SBaptiste Daroussin.Li C .
5073*2fd5d190SBaptiste DaroussinSee Section.Dq Marking Conflicts .
5074*2fd5d190SBaptiste Daroussin.Pp
5075*2fd5d190SBaptiste Daroussin.It  -m
5076*2fd5d190SBaptiste Daroussin.It  --merge
5077*2fd5d190SBaptiste DaroussinApply the edit script to the first file and send the result to standard output.
5078*2fd5d190SBaptiste DaroussinUnlike piping the output from
5079*2fd5d190SBaptiste Daroussin.Xr diff3
5080*2fd5d190SBaptiste Daroussinto
5081*2fd5d190SBaptiste Daroussin.Xr ed ,
5082*2fd5d190SBaptiste Daroussinthis works even for binary files and incomplete lines.
5083*2fd5d190SBaptiste Daroussin.Op -A
5084*2fd5d190SBaptiste Daroussinis assumed if no edit script option is specified.See Section
5085*2fd5d190SBaptiste Daroussin.Dq Bypassing ed .
5086*2fd5d190SBaptiste Daroussin.Pp
5087*2fd5d190SBaptiste Daroussin.It  --strip-trailing-cr
5088*2fd5d190SBaptiste DaroussinStrip any trailing carriage return at the end of an input line.See Section
5089*2fd5d190SBaptiste Daroussin.Dq Binary .
5090*2fd5d190SBaptiste Daroussin.Pp
5091*2fd5d190SBaptiste Daroussin.It  -T
5092*2fd5d190SBaptiste Daroussin.It  --initial-tab
5093*2fd5d190SBaptiste DaroussinOutput a tab rather than two spaces before the text of a line in normal format.
5094*2fd5d190SBaptiste DaroussinThis causes the alignment of tabs in the line to look normal.See Section
5095*2fd5d190SBaptiste Daroussin.Dq Tabs .
5096*2fd5d190SBaptiste Daroussin.Pp
5097*2fd5d190SBaptiste Daroussin.It  -v
5098*2fd5d190SBaptiste Daroussin.It  --version
5099*2fd5d190SBaptiste DaroussinOutput version information and then exit.
5100*2fd5d190SBaptiste Daroussin.Pp
5101*2fd5d190SBaptiste Daroussin.It  -x
5102*2fd5d190SBaptiste Daroussin.It  --overlap-only
5103*2fd5d190SBaptiste DaroussinLike
5104*2fd5d190SBaptiste Daroussin.Op -e ,
5105*2fd5d190SBaptiste Daroussinexcept output only the overlapping changes.See Section
5106*2fd5d190SBaptiste Daroussin.Dq Which Changes .
5107*2fd5d190SBaptiste Daroussin.Pp
5108*2fd5d190SBaptiste Daroussin.It  -X
5109*2fd5d190SBaptiste DaroussinLike
5110*2fd5d190SBaptiste Daroussin.Op -E ,
5111*2fd5d190SBaptiste Daroussinexcept output only the overlapping changes. In other words, like
5112*2fd5d190SBaptiste Daroussin.Op -x ,
5113*2fd5d190SBaptiste Daroussinexcept bracket changes as in
5114*2fd5d190SBaptiste Daroussin.Op -E .
5115*2fd5d190SBaptiste DaroussinSee Section.Dq Marking Conflicts .
5116*2fd5d190SBaptiste Daroussin.Pp
5117*2fd5d190SBaptiste Daroussin.It  -3
5118*2fd5d190SBaptiste Daroussin.It  --easy-only
5119*2fd5d190SBaptiste DaroussinLike
5120*2fd5d190SBaptiste Daroussin.Op -e ,
5121*2fd5d190SBaptiste Daroussinexcept output only the nonoverlapping changes.See Section
5122*2fd5d190SBaptiste Daroussin.Dq Which Changes .
5123*2fd5d190SBaptiste Daroussin.El
5124*2fd5d190SBaptiste Daroussin.Pp
5125*2fd5d190SBaptiste Daroussin.Sh  Invoking Xr patch
5126*2fd5d190SBaptiste DaroussinNormally
5127*2fd5d190SBaptiste Daroussin.Xr patch
5128*2fd5d190SBaptiste Daroussinis invoked like this:
5129*2fd5d190SBaptiste Daroussin.Pp
5130*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
5131*2fd5d190SBaptiste Daroussinpatch <patchfile
5132*2fd5d190SBaptiste Daroussin.Ed
5133*2fd5d190SBaptiste Daroussin.Pp
5134*2fd5d190SBaptiste DaroussinThe full format for invoking
5135*2fd5d190SBaptiste Daroussin.Xr patch
5136*2fd5d190SBaptiste Daroussinis:
5137*2fd5d190SBaptiste Daroussin.Pp
5138*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
5139*2fd5d190SBaptiste Daroussinpatch options... [origfile [patchfile]]
5140*2fd5d190SBaptiste Daroussin.Ed
5141*2fd5d190SBaptiste Daroussin.Pp
5142*2fd5d190SBaptiste DaroussinYou can also specify where to read the patch from with the
5143*2fd5d190SBaptiste Daroussin.Op -i Va patchfile
5144*2fd5d190SBaptiste Daroussinor
5145*2fd5d190SBaptiste Daroussin.Op --input= Va patchfile
5146*2fd5d190SBaptiste Daroussinoption. If you do not specify
5147*2fd5d190SBaptiste Daroussin.Va patchfile ,
5148*2fd5d190SBaptiste Daroussinor if
5149*2fd5d190SBaptiste Daroussin.Va patchfile
5150*2fd5d190SBaptiste Daroussinis
5151*2fd5d190SBaptiste Daroussin.Pa - ,
5152*2fd5d190SBaptiste Daroussin.Xr patch
5153*2fd5d190SBaptiste Daroussinreads the patch (that is, the
5154*2fd5d190SBaptiste Daroussin.Xr diff
5155*2fd5d190SBaptiste Daroussinoutput) from the standard input.
5156*2fd5d190SBaptiste Daroussin.Pp
5157*2fd5d190SBaptiste DaroussinIf you do not specify an input file on the command line,
5158*2fd5d190SBaptiste Daroussin.Xr patch
5159*2fd5d190SBaptiste Daroussintries to intuit from the
5160*2fd5d190SBaptiste Daroussin.Em leading text
5161*2fd5d190SBaptiste Daroussin(any text in the patch that comes before the
5162*2fd5d190SBaptiste Daroussin.Xr diff
5163*2fd5d190SBaptiste Daroussinoutput) which file to edit.See Section
5164*2fd5d190SBaptiste Daroussin.Dq Multiple Patches .
5165*2fd5d190SBaptiste Daroussin.Pp
5166*2fd5d190SBaptiste DaroussinBy default,
5167*2fd5d190SBaptiste Daroussin.Xr patch
5168*2fd5d190SBaptiste Daroussinreplaces the original input file with the patched version, possibly after
5169*2fd5d190SBaptiste Daroussinrenaming the original file into a backup file (see Section
5170*2fd5d190SBaptiste Daroussin.Dq Backup Names ,
5171*2fd5d190SBaptiste Daroussinfor a description of how
5172*2fd5d190SBaptiste Daroussin.Xr patch
5173*2fd5d190SBaptiste Daroussinnames backup files). You can also specify where to put the output with the
5174*2fd5d190SBaptiste Daroussin.Op -o Va file
5175*2fd5d190SBaptiste Daroussinor
5176*2fd5d190SBaptiste Daroussin.Op --output= Va file
5177*2fd5d190SBaptiste Daroussinoption; however, do not use this option if
5178*2fd5d190SBaptiste Daroussin.Va file
5179*2fd5d190SBaptiste Daroussinis one of the input files.
5180*2fd5d190SBaptiste Daroussin.Pp
5181*2fd5d190SBaptiste Daroussin.Ss  Options to Xr patch
5182*2fd5d190SBaptiste DaroussinHere is a summary of all of the options that GNU
5183*2fd5d190SBaptiste Daroussin.Xr patch
5184*2fd5d190SBaptiste Daroussinaccepts.See Section
5185*2fd5d190SBaptiste Daroussin.Dq patch and Tradition ,
5186*2fd5d190SBaptiste Daroussinfor which of these options are safe to use in older versions of
5187*2fd5d190SBaptiste Daroussin.Xr patch .
5188*2fd5d190SBaptiste Daroussin.Pp
5189*2fd5d190SBaptiste DaroussinMultiple single-letter options that do not take an argument can be combined
5190*2fd5d190SBaptiste Daroussininto a single command line argument with only one dash.
5191*2fd5d190SBaptiste Daroussin.Pp
5192*2fd5d190SBaptiste Daroussin.Bl -tag -width Ds
5193*2fd5d190SBaptiste Daroussin.It  -b
5194*2fd5d190SBaptiste Daroussin.It  --backup
5195*2fd5d190SBaptiste DaroussinBack up the original contents of each file, even if backups would normally
5196*2fd5d190SBaptiste Daroussinnot be made.See Section
5197*2fd5d190SBaptiste Daroussin.Dq Backups .
5198*2fd5d190SBaptiste Daroussin.Pp
5199*2fd5d190SBaptiste Daroussin.It  -B Va prefix
5200*2fd5d190SBaptiste Daroussin.It  --prefix= Va prefix
5201*2fd5d190SBaptiste DaroussinPrepend
5202*2fd5d190SBaptiste Daroussin.Va prefix
5203*2fd5d190SBaptiste Daroussinto backup file names.See Section
5204*2fd5d190SBaptiste Daroussin.Dq Backup Names .
5205*2fd5d190SBaptiste Daroussin.Pp
5206*2fd5d190SBaptiste Daroussin.It  --backup-if-mismatch
5207*2fd5d190SBaptiste DaroussinBack up the original contents of each file if the patch does not exactly match
5208*2fd5d190SBaptiste Daroussinthe file. This is the default behavior when not conforming to POSIX.See Section
5209*2fd5d190SBaptiste Daroussin.Dq Backups .
5210*2fd5d190SBaptiste Daroussin.Pp
5211*2fd5d190SBaptiste Daroussin.It  --binary
5212*2fd5d190SBaptiste DaroussinRead and write all files in binary mode, except for standard output and
5213*2fd5d190SBaptiste Daroussin.Pa /dev/tty .
5214*2fd5d190SBaptiste DaroussinThis option has no effect on POSIX-conforming systems like GNU/Linux. On systems
5215*2fd5d190SBaptiste Daroussinwhere this option makes a difference, the patch should be generated by
5216*2fd5d190SBaptiste Daroussin.Li diff -a --binary .
5217*2fd5d190SBaptiste DaroussinSee Section.Dq Binary .
5218*2fd5d190SBaptiste Daroussin.Pp
5219*2fd5d190SBaptiste Daroussin.It  -c
5220*2fd5d190SBaptiste Daroussin.It  --context
5221*2fd5d190SBaptiste DaroussinInterpret the patch file as a context diff.See Section
5222*2fd5d190SBaptiste Daroussin.Dq patch Input .
5223*2fd5d190SBaptiste Daroussin.Pp
5224*2fd5d190SBaptiste Daroussin.It  -d Va directory
5225*2fd5d190SBaptiste Daroussin.It  --directory= Va directory
5226*2fd5d190SBaptiste DaroussinMake directory
5227*2fd5d190SBaptiste Daroussin.Va directory
5228*2fd5d190SBaptiste Daroussinthe current directory for interpreting both file names in the patch file,
5229*2fd5d190SBaptiste Daroussinand file names given as arguments to other options.See Section
5230*2fd5d190SBaptiste Daroussin.Dq patch Directories .
5231*2fd5d190SBaptiste Daroussin.Pp
5232*2fd5d190SBaptiste Daroussin.It  -D Va name
5233*2fd5d190SBaptiste Daroussin.It  --ifdef= Va name
5234*2fd5d190SBaptiste DaroussinMake merged if-then-else output using
5235*2fd5d190SBaptiste Daroussin.Va name .
5236*2fd5d190SBaptiste DaroussinSee Section.Dq If-then-else .
5237*2fd5d190SBaptiste Daroussin.Pp
5238*2fd5d190SBaptiste Daroussin.It  --dry-run
5239*2fd5d190SBaptiste DaroussinPrint the results of applying the patches without actually changing any files.See Section
5240*2fd5d190SBaptiste Daroussin.Dq Dry Runs .
5241*2fd5d190SBaptiste Daroussin.Pp
5242*2fd5d190SBaptiste Daroussin.It  -e
5243*2fd5d190SBaptiste Daroussin.It  --ed
5244*2fd5d190SBaptiste DaroussinInterpret the patch file as an
5245*2fd5d190SBaptiste Daroussin.Xr ed
5246*2fd5d190SBaptiste Daroussinscript.See Section
5247*2fd5d190SBaptiste Daroussin.Dq patch Input .
5248*2fd5d190SBaptiste Daroussin.Pp
5249*2fd5d190SBaptiste Daroussin.It  -E
5250*2fd5d190SBaptiste Daroussin.It  --remove-empty-files
5251*2fd5d190SBaptiste DaroussinRemove output files that are empty after the patches have been applied.See Section
5252*2fd5d190SBaptiste Daroussin.Dq Creating and Removing .
5253*2fd5d190SBaptiste Daroussin.Pp
5254*2fd5d190SBaptiste Daroussin.It  -f
5255*2fd5d190SBaptiste Daroussin.It  --force
5256*2fd5d190SBaptiste DaroussinAssume that the user knows exactly what he or she is doing, and do not ask
5257*2fd5d190SBaptiste Daroussinany questions.See Section
5258*2fd5d190SBaptiste Daroussin.Dq patch Messages .
5259*2fd5d190SBaptiste Daroussin.Pp
5260*2fd5d190SBaptiste Daroussin.It  -F Va lines
5261*2fd5d190SBaptiste Daroussin.It  --fuzz= Va lines
5262*2fd5d190SBaptiste DaroussinSet the maximum fuzz factor to
5263*2fd5d190SBaptiste Daroussin.Va lines .
5264*2fd5d190SBaptiste DaroussinSee Section.Dq Inexact .
5265*2fd5d190SBaptiste Daroussin.Pp
5266*2fd5d190SBaptiste Daroussin.It  -g Va num
5267*2fd5d190SBaptiste Daroussin.It  --get= Va num
5268*2fd5d190SBaptiste DaroussinIf
5269*2fd5d190SBaptiste Daroussin.Va num
5270*2fd5d190SBaptiste Daroussinis positive, get input files from a revision control system as necessary;
5271*2fd5d190SBaptiste Daroussinif zero, do not get the files; if negative, ask the user whether to get the
5272*2fd5d190SBaptiste Daroussinfiles.See Section
5273*2fd5d190SBaptiste Daroussin.Dq Revision Control .
5274*2fd5d190SBaptiste Daroussin.Pp
5275*2fd5d190SBaptiste Daroussin.It  --help
5276*2fd5d190SBaptiste DaroussinOutput a summary of usage and then exit.
5277*2fd5d190SBaptiste Daroussin.Pp
5278*2fd5d190SBaptiste Daroussin.It  -i Va patchfile
5279*2fd5d190SBaptiste Daroussin.It  --input= Va patchfile
5280*2fd5d190SBaptiste DaroussinRead the patch from
5281*2fd5d190SBaptiste Daroussin.Va patchfile
5282*2fd5d190SBaptiste Daroussinrather than from standard input.See Section
5283*2fd5d190SBaptiste Daroussin.Dq patch Options .
5284*2fd5d190SBaptiste Daroussin.Pp
5285*2fd5d190SBaptiste Daroussin.It  -l
5286*2fd5d190SBaptiste Daroussin.It  --ignore-white-space
5287*2fd5d190SBaptiste DaroussinLet any sequence of blanks (spaces or tabs) in the patch file match any sequence
5288*2fd5d190SBaptiste Daroussinof blanks in the input file.See Section
5289*2fd5d190SBaptiste Daroussin.Dq Changed White Space .
5290*2fd5d190SBaptiste Daroussin.Pp
5291*2fd5d190SBaptiste Daroussin.It  -n
5292*2fd5d190SBaptiste Daroussin.It  --normal
5293*2fd5d190SBaptiste DaroussinInterpret the patch file as a normal diff.See Section
5294*2fd5d190SBaptiste Daroussin.Dq patch Input .
5295*2fd5d190SBaptiste Daroussin.Pp
5296*2fd5d190SBaptiste Daroussin.It  -N
5297*2fd5d190SBaptiste Daroussin.It  --forward
5298*2fd5d190SBaptiste DaroussinIgnore patches that
5299*2fd5d190SBaptiste Daroussin.Xr patch
5300*2fd5d190SBaptiste Daroussinthinks are reversed or already applied. See also
5301*2fd5d190SBaptiste Daroussin.Op -R .
5302*2fd5d190SBaptiste DaroussinSee Section.Dq Reversed Patches .
5303*2fd5d190SBaptiste Daroussin.Pp
5304*2fd5d190SBaptiste Daroussin.It  --no-backup-if-mismatch
5305*2fd5d190SBaptiste DaroussinDo not back up the original contents of files. This is the default behavior
5306*2fd5d190SBaptiste Daroussinwhen conforming to POSIX.See Section
5307*2fd5d190SBaptiste Daroussin.Dq Backups .
5308*2fd5d190SBaptiste Daroussin.Pp
5309*2fd5d190SBaptiste Daroussin.It  -o Va file
5310*2fd5d190SBaptiste Daroussin.It  --output= Va file
5311*2fd5d190SBaptiste DaroussinUse
5312*2fd5d190SBaptiste Daroussin.Va file
5313*2fd5d190SBaptiste Daroussinas the output file name.See Section
5314*2fd5d190SBaptiste Daroussin.Dq patch Options .
5315*2fd5d190SBaptiste Daroussin.Pp
5316*2fd5d190SBaptiste Daroussin.It  -p Va number
5317*2fd5d190SBaptiste Daroussin.It  --strip= Va number
5318*2fd5d190SBaptiste DaroussinSet the file name strip count to
5319*2fd5d190SBaptiste Daroussin.Va number .
5320*2fd5d190SBaptiste DaroussinSee Section.Dq patch Directories .
5321*2fd5d190SBaptiste Daroussin.Pp
5322*2fd5d190SBaptiste Daroussin.It  --posix
5323*2fd5d190SBaptiste DaroussinConform to POSIX, as if the
5324*2fd5d190SBaptiste Daroussin.Ev POSIXLY_CORRECT
5325*2fd5d190SBaptiste Daroussinenvironment variable had been set.See Section
5326*2fd5d190SBaptiste Daroussin.Dq patch and POSIX .
5327*2fd5d190SBaptiste Daroussin.Pp
5328*2fd5d190SBaptiste Daroussin.It  --quoting-style= Va word
5329*2fd5d190SBaptiste DaroussinUse style
5330*2fd5d190SBaptiste Daroussin.Va word
5331*2fd5d190SBaptiste Daroussinto quote names in diagnostics, as if the
5332*2fd5d190SBaptiste Daroussin.Ev QUOTING_STYLE
5333*2fd5d190SBaptiste Daroussinenvironment variable had been set to
5334*2fd5d190SBaptiste Daroussin.Va word .
5335*2fd5d190SBaptiste DaroussinSee Section.Dq patch Quoting Style .
5336*2fd5d190SBaptiste Daroussin.Pp
5337*2fd5d190SBaptiste Daroussin.It  -r Va reject-file
5338*2fd5d190SBaptiste Daroussin.It  --reject-file= Va reject-file
5339*2fd5d190SBaptiste DaroussinUse
5340*2fd5d190SBaptiste Daroussin.Va reject-file
5341*2fd5d190SBaptiste Daroussinas the reject file name.See Section
5342*2fd5d190SBaptiste Daroussin.Dq Reject Names .
5343*2fd5d190SBaptiste Daroussin.Pp
5344*2fd5d190SBaptiste Daroussin.It  -R
5345*2fd5d190SBaptiste Daroussin.It  --reverse
5346*2fd5d190SBaptiste DaroussinAssume that this patch was created with the old and new files swapped.See Section
5347*2fd5d190SBaptiste Daroussin.Dq Reversed Patches .
5348*2fd5d190SBaptiste Daroussin.Pp
5349*2fd5d190SBaptiste Daroussin.It  -s
5350*2fd5d190SBaptiste Daroussin.It  --quiet
5351*2fd5d190SBaptiste Daroussin.It  --silent
5352*2fd5d190SBaptiste DaroussinWork silently unless an error occurs.See Section
5353*2fd5d190SBaptiste Daroussin.Dq patch Messages .
5354*2fd5d190SBaptiste Daroussin.Pp
5355*2fd5d190SBaptiste Daroussin.It  -t
5356*2fd5d190SBaptiste Daroussin.It  --batch
5357*2fd5d190SBaptiste DaroussinDo not ask any questions.See Section
5358*2fd5d190SBaptiste Daroussin.Dq patch Messages .
5359*2fd5d190SBaptiste Daroussin.Pp
5360*2fd5d190SBaptiste Daroussin.It  -T
5361*2fd5d190SBaptiste Daroussin.It  --set-time
5362*2fd5d190SBaptiste DaroussinSet the modification and access times of patched files from time stamps given
5363*2fd5d190SBaptiste Daroussinin context diff headers, assuming that the context diff headers use local
5364*2fd5d190SBaptiste Daroussintime.See Section
5365*2fd5d190SBaptiste Daroussin.Dq Patching Time Stamps .
5366*2fd5d190SBaptiste Daroussin.Pp
5367*2fd5d190SBaptiste Daroussin.It  -u
5368*2fd5d190SBaptiste Daroussin.It  --unified
5369*2fd5d190SBaptiste DaroussinInterpret the patch file as a unified diff.See Section
5370*2fd5d190SBaptiste Daroussin.Dq patch Input .
5371*2fd5d190SBaptiste Daroussin.Pp
5372*2fd5d190SBaptiste Daroussin.It  -v
5373*2fd5d190SBaptiste Daroussin.It  --version
5374*2fd5d190SBaptiste DaroussinOutput version information and then exit.
5375*2fd5d190SBaptiste Daroussin.Pp
5376*2fd5d190SBaptiste Daroussin.It  -V Va backup-style
5377*2fd5d190SBaptiste Daroussin.It  --version=control= Va backup-style
5378*2fd5d190SBaptiste DaroussinSelect the naming convention for backup file names.See Section
5379*2fd5d190SBaptiste Daroussin.Dq Backup Names .
5380*2fd5d190SBaptiste Daroussin.Pp
5381*2fd5d190SBaptiste Daroussin.It  --verbose
5382*2fd5d190SBaptiste DaroussinPrint more diagnostics than usual.See Section
5383*2fd5d190SBaptiste Daroussin.Dq patch Messages .
5384*2fd5d190SBaptiste Daroussin.Pp
5385*2fd5d190SBaptiste Daroussin.It  -x Va number
5386*2fd5d190SBaptiste Daroussin.It  --debug= Va number
5387*2fd5d190SBaptiste DaroussinSet internal debugging flags. Of interest only to
5388*2fd5d190SBaptiste Daroussin.Xr patch
5389*2fd5d190SBaptiste Daroussinpatchers.
5390*2fd5d190SBaptiste Daroussin.Pp
5391*2fd5d190SBaptiste Daroussin.It  -Y Va prefix
5392*2fd5d190SBaptiste Daroussin.It  --basename-prefix= Va prefix
5393*2fd5d190SBaptiste DaroussinPrepend
5394*2fd5d190SBaptiste Daroussin.Va prefix
5395*2fd5d190SBaptiste Daroussinto base names of backup files.See Section
5396*2fd5d190SBaptiste Daroussin.Dq Backup Names .
5397*2fd5d190SBaptiste Daroussin.Pp
5398*2fd5d190SBaptiste Daroussin.It  -z Va suffix
5399*2fd5d190SBaptiste Daroussin.It  --suffix= Va suffix
5400*2fd5d190SBaptiste DaroussinUse
5401*2fd5d190SBaptiste Daroussin.Va suffix
5402*2fd5d190SBaptiste Daroussinas the backup extension instead of
5403*2fd5d190SBaptiste Daroussin.Li .orig
5404*2fd5d190SBaptiste Daroussinor
5405*2fd5d190SBaptiste Daroussin.Li ~ .
5406*2fd5d190SBaptiste DaroussinSee Section.Dq Backup Names .
5407*2fd5d190SBaptiste Daroussin.Pp
5408*2fd5d190SBaptiste Daroussin.It  -Z
5409*2fd5d190SBaptiste Daroussin.It  --set-utc
5410*2fd5d190SBaptiste DaroussinSet the modification and access times of patched files from time stamps given
5411*2fd5d190SBaptiste Daroussinin context diff headers, assuming that the context diff headers use UTC.See Section
5412*2fd5d190SBaptiste Daroussin.Dq Patching Time Stamps .
5413*2fd5d190SBaptiste Daroussin.Pp
5414*2fd5d190SBaptiste Daroussin.El
5415*2fd5d190SBaptiste Daroussin.Sh  Invoking Xr sdiff
5416*2fd5d190SBaptiste DaroussinThe
5417*2fd5d190SBaptiste Daroussin.Xr sdiff
5418*2fd5d190SBaptiste Daroussincommand merges two files and interactively outputs the results. Its arguments
5419*2fd5d190SBaptiste Daroussinare as follows:
5420*2fd5d190SBaptiste Daroussin.Pp
5421*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
5422*2fd5d190SBaptiste Daroussinsdiff -o outfile options... from-file to-file
5423*2fd5d190SBaptiste Daroussin.Ed
5424*2fd5d190SBaptiste Daroussin.Pp
5425*2fd5d190SBaptiste DaroussinThis merges
5426*2fd5d190SBaptiste Daroussin.Va from-file
5427*2fd5d190SBaptiste Daroussinwith
5428*2fd5d190SBaptiste Daroussin.Va to-file ,
5429*2fd5d190SBaptiste Daroussinwith output to
5430*2fd5d190SBaptiste Daroussin.Va outfile .
5431*2fd5d190SBaptiste DaroussinIf
5432*2fd5d190SBaptiste Daroussin.Va from-file
5433*2fd5d190SBaptiste Daroussinis a directory and
5434*2fd5d190SBaptiste Daroussin.Va to-file
5435*2fd5d190SBaptiste Daroussinis not,
5436*2fd5d190SBaptiste Daroussin.Xr sdiff
5437*2fd5d190SBaptiste Daroussincompares the file in
5438*2fd5d190SBaptiste Daroussin.Va from-file
5439*2fd5d190SBaptiste Daroussinwhose file name is that of
5440*2fd5d190SBaptiste Daroussin.Va to-file ,
5441*2fd5d190SBaptiste Daroussinand vice versa.
5442*2fd5d190SBaptiste Daroussin.Va from-file
5443*2fd5d190SBaptiste Daroussinand
5444*2fd5d190SBaptiste Daroussin.Va to-file
5445*2fd5d190SBaptiste Daroussinmay not both be directories.
5446*2fd5d190SBaptiste Daroussin.Pp
5447*2fd5d190SBaptiste Daroussin.Xr sdiff
5448*2fd5d190SBaptiste Daroussinoptions begin with
5449*2fd5d190SBaptiste Daroussin.Li - ,
5450*2fd5d190SBaptiste Daroussinso normally
5451*2fd5d190SBaptiste Daroussin.Va from-file
5452*2fd5d190SBaptiste Daroussinand
5453*2fd5d190SBaptiste Daroussin.Va to-file
5454*2fd5d190SBaptiste Daroussinmay not begin with
5455*2fd5d190SBaptiste Daroussin.Li - .
5456*2fd5d190SBaptiste DaroussinHowever,
5457*2fd5d190SBaptiste Daroussin.Op --
5458*2fd5d190SBaptiste Daroussinas an argument by itself treats the remaining arguments as file names even
5459*2fd5d190SBaptiste Daroussinif they begin with
5460*2fd5d190SBaptiste Daroussin.Li - .
5461*2fd5d190SBaptiste DaroussinYou may not use
5462*2fd5d190SBaptiste Daroussin.Pa -
5463*2fd5d190SBaptiste Daroussinas an input file.
5464*2fd5d190SBaptiste Daroussin.Pp
5465*2fd5d190SBaptiste Daroussin.Xr sdiff
5466*2fd5d190SBaptiste Daroussinwithout
5467*2fd5d190SBaptiste Daroussin.Op -o
5468*2fd5d190SBaptiste Daroussin(or
5469*2fd5d190SBaptiste Daroussin.Op --output )
5470*2fd5d190SBaptiste Daroussinproduces a side-by-side difference. This usage is obsolete; use the
5471*2fd5d190SBaptiste Daroussin.Op -y
5472*2fd5d190SBaptiste Daroussinor
5473*2fd5d190SBaptiste Daroussin.Op --side-by-side
5474*2fd5d190SBaptiste Daroussinoption of
5475*2fd5d190SBaptiste Daroussin.Xr diff
5476*2fd5d190SBaptiste Daroussininstead.
5477*2fd5d190SBaptiste Daroussin.Pp
5478*2fd5d190SBaptiste DaroussinAn exit status of 0 means no differences were found, 1 means some differences
5479*2fd5d190SBaptiste Daroussinwere found, and 2 means trouble.
5480*2fd5d190SBaptiste Daroussin.Pp
5481*2fd5d190SBaptiste Daroussin.Ss  Options to Xr sdiff
5482*2fd5d190SBaptiste DaroussinBelow is a summary of all of the options that GNU
5483*2fd5d190SBaptiste Daroussin.Xr sdiff
5484*2fd5d190SBaptiste Daroussinaccepts. Each option has two equivalent names, one of which is a single letter
5485*2fd5d190SBaptiste Daroussinpreceded by
5486*2fd5d190SBaptiste Daroussin.Li - ,
5487*2fd5d190SBaptiste Daroussinand the other of which is a long name preceded by
5488*2fd5d190SBaptiste Daroussin.Li -- .
5489*2fd5d190SBaptiste DaroussinMultiple single letter options (unless they take an argument) can be combined
5490*2fd5d190SBaptiste Daroussininto a single command line argument. Long named options can be abbreviated
5491*2fd5d190SBaptiste Daroussinto any unique prefix of their name.
5492*2fd5d190SBaptiste Daroussin.Pp
5493*2fd5d190SBaptiste Daroussin.Bl -tag -width Ds
5494*2fd5d190SBaptiste Daroussin.It  -a
5495*2fd5d190SBaptiste Daroussin.It  --text
5496*2fd5d190SBaptiste DaroussinTreat all files as text and compare them line-by-line, even if they do not
5497*2fd5d190SBaptiste Daroussinappear to be text.See Section
5498*2fd5d190SBaptiste Daroussin.Dq Binary .
5499*2fd5d190SBaptiste Daroussin.Pp
5500*2fd5d190SBaptiste Daroussin.It  -b
5501*2fd5d190SBaptiste Daroussin.It  --ignore-space-change
5502*2fd5d190SBaptiste DaroussinIgnore changes in amount of white space.See Section
5503*2fd5d190SBaptiste Daroussin.Dq White Space .
5504*2fd5d190SBaptiste Daroussin.Pp
5505*2fd5d190SBaptiste Daroussin.It  -B
5506*2fd5d190SBaptiste Daroussin.It  --ignore-blank-lines
5507*2fd5d190SBaptiste DaroussinIgnore changes that just insert or delete blank lines.See Section
5508*2fd5d190SBaptiste Daroussin.Dq Blank Lines .
5509*2fd5d190SBaptiste Daroussin.Pp
5510*2fd5d190SBaptiste Daroussin.It  -d
5511*2fd5d190SBaptiste Daroussin.It  --minimal
5512*2fd5d190SBaptiste DaroussinChange the algorithm to perhaps find a smaller set of changes. This makes
5513*2fd5d190SBaptiste Daroussin.Xr sdiff
5514*2fd5d190SBaptiste Daroussinslower (sometimes much slower).See Section
5515*2fd5d190SBaptiste Daroussin.Dq diff Performance .
5516*2fd5d190SBaptiste Daroussin.Pp
5517*2fd5d190SBaptiste Daroussin.It  --diff-program= Va program
5518*2fd5d190SBaptiste DaroussinUse the compatible comparison program
5519*2fd5d190SBaptiste Daroussin.Va program
5520*2fd5d190SBaptiste Daroussinto compare files instead of
5521*2fd5d190SBaptiste Daroussin.Xr diff .
5522*2fd5d190SBaptiste Daroussin.Pp
5523*2fd5d190SBaptiste Daroussin.It  -E
5524*2fd5d190SBaptiste Daroussin.It  --ignore-tab-expansion
5525*2fd5d190SBaptiste DaroussinIgnore changes due to tab expansion.See Section
5526*2fd5d190SBaptiste Daroussin.Dq White Space .
5527*2fd5d190SBaptiste Daroussin.Pp
5528*2fd5d190SBaptiste Daroussin.It  --help
5529*2fd5d190SBaptiste DaroussinOutput a summary of usage and then exit.
5530*2fd5d190SBaptiste Daroussin.Pp
5531*2fd5d190SBaptiste Daroussin.It  -i
5532*2fd5d190SBaptiste Daroussin.It  --ignore-case
5533*2fd5d190SBaptiste DaroussinIgnore changes in case; consider upper- and lower-case to be the same.See Section
5534*2fd5d190SBaptiste Daroussin.Dq Case Folding .
5535*2fd5d190SBaptiste Daroussin.Pp
5536*2fd5d190SBaptiste Daroussin.It  -I Va regexp
5537*2fd5d190SBaptiste Daroussin.It  --ignore-matching-lines= Va regexp
5538*2fd5d190SBaptiste DaroussinIgnore changes that just insert or delete lines that match
5539*2fd5d190SBaptiste Daroussin.Va regexp .
5540*2fd5d190SBaptiste DaroussinSee Section.Dq Specified Lines .
5541*2fd5d190SBaptiste Daroussin.Pp
5542*2fd5d190SBaptiste Daroussin.It  -l
5543*2fd5d190SBaptiste Daroussin.It  --left-column
5544*2fd5d190SBaptiste DaroussinPrint only the left column of two common lines.See Section
5545*2fd5d190SBaptiste Daroussin.Dq Side by Side Format .
5546*2fd5d190SBaptiste Daroussin.Pp
5547*2fd5d190SBaptiste Daroussin.It  -o Va file
5548*2fd5d190SBaptiste Daroussin.It  --output= Va file
5549*2fd5d190SBaptiste DaroussinPut merged output into
5550*2fd5d190SBaptiste Daroussin.Va file .
5551*2fd5d190SBaptiste DaroussinThis option is required for merging.
5552*2fd5d190SBaptiste Daroussin.Pp
5553*2fd5d190SBaptiste Daroussin.It  -s
5554*2fd5d190SBaptiste Daroussin.It  --suppress-common-lines
5555*2fd5d190SBaptiste DaroussinDo not print common lines.See Section
5556*2fd5d190SBaptiste Daroussin.Dq Side by Side Format .
5557*2fd5d190SBaptiste Daroussin.Pp
5558*2fd5d190SBaptiste Daroussin.It  --speed-large-files
5559*2fd5d190SBaptiste DaroussinUse heuristics to speed handling of large files that have numerous scattered
5560*2fd5d190SBaptiste Daroussinsmall changes.See Section
5561*2fd5d190SBaptiste Daroussin.Dq diff Performance .
5562*2fd5d190SBaptiste Daroussin.Pp
5563*2fd5d190SBaptiste Daroussin.It  --strip-trailing-cr
5564*2fd5d190SBaptiste DaroussinStrip any trailing carriage return at the end of an input line.See Section
5565*2fd5d190SBaptiste Daroussin.Dq Binary .
5566*2fd5d190SBaptiste Daroussin.Pp
5567*2fd5d190SBaptiste Daroussin.It  -t
5568*2fd5d190SBaptiste Daroussin.It  --expand-tabs
5569*2fd5d190SBaptiste DaroussinExpand tabs to spaces in the output, to preserve the alignment of tabs in
5570*2fd5d190SBaptiste Daroussinthe input files.See Section
5571*2fd5d190SBaptiste Daroussin.Dq Tabs .
5572*2fd5d190SBaptiste Daroussin.Pp
5573*2fd5d190SBaptiste Daroussin.It  --tabsize= Va columns
5574*2fd5d190SBaptiste DaroussinAssume that tab stops are set every
5575*2fd5d190SBaptiste Daroussin.Va columns
5576*2fd5d190SBaptiste Daroussin(default 8) print columns.See Section
5577*2fd5d190SBaptiste Daroussin.Dq Tabs .
5578*2fd5d190SBaptiste Daroussin.Pp
5579*2fd5d190SBaptiste Daroussin.It  -v
5580*2fd5d190SBaptiste Daroussin.It  --version
5581*2fd5d190SBaptiste DaroussinOutput version information and then exit.
5582*2fd5d190SBaptiste Daroussin.Pp
5583*2fd5d190SBaptiste Daroussin.It  -w Va columns
5584*2fd5d190SBaptiste Daroussin.It  --width= Va columns
5585*2fd5d190SBaptiste DaroussinOutput at most
5586*2fd5d190SBaptiste Daroussin.Va columns
5587*2fd5d190SBaptiste Daroussin(default 130) print columns per line.See Section
5588*2fd5d190SBaptiste Daroussin.Dq Side by Side Format .
5589*2fd5d190SBaptiste DaroussinNote that for historical reasons, this option is
5590*2fd5d190SBaptiste Daroussin.Op -W
5591*2fd5d190SBaptiste Daroussinin
5592*2fd5d190SBaptiste Daroussin.Xr diff ,
5593*2fd5d190SBaptiste Daroussin.Op -w
5594*2fd5d190SBaptiste Daroussinin
5595*2fd5d190SBaptiste Daroussin.Xr sdiff .
5596*2fd5d190SBaptiste Daroussin.Pp
5597*2fd5d190SBaptiste Daroussin.It  -W
5598*2fd5d190SBaptiste Daroussin.It  --ignore-all-space
5599*2fd5d190SBaptiste DaroussinIgnore white space when comparing lines.See Section
5600*2fd5d190SBaptiste Daroussin.Dq White Space .
5601*2fd5d190SBaptiste DaroussinNote that for historical reasons, this option is
5602*2fd5d190SBaptiste Daroussin.Op -w
5603*2fd5d190SBaptiste Daroussinin
5604*2fd5d190SBaptiste Daroussin.Xr diff ,
5605*2fd5d190SBaptiste Daroussin.Op -W
5606*2fd5d190SBaptiste Daroussinin
5607*2fd5d190SBaptiste Daroussin.Xr sdiff .
5608*2fd5d190SBaptiste Daroussin.El
5609*2fd5d190SBaptiste Daroussin.Pp
5610*2fd5d190SBaptiste Daroussin.Sh  Standards conformance
5611*2fd5d190SBaptiste DaroussinIn a few cases, the GNU utilities' default behavior is incompatible with the
5612*2fd5d190SBaptiste DaroussinPOSIX standard. To suppress these incompatibilities, define the
5613*2fd5d190SBaptiste Daroussin.Ev POSIXLY_CORRECT
5614*2fd5d190SBaptiste Daroussinenvironment variable. Unless you are checking for POSIX conformance, you probably
5615*2fd5d190SBaptiste Daroussindo not need to define
5616*2fd5d190SBaptiste Daroussin.Ev POSIXLY_CORRECT .
5617*2fd5d190SBaptiste Daroussin.Pp
5618*2fd5d190SBaptiste DaroussinNormally options and operands can appear in any order, and programs act as
5619*2fd5d190SBaptiste Daroussinif all the options appear before any operands. For example,
5620*2fd5d190SBaptiste Daroussin.Li diff lao tzu -C 2
5621*2fd5d190SBaptiste Daroussinacts like
5622*2fd5d190SBaptiste Daroussin.Li diff -C 2 lao tzu ,
5623*2fd5d190SBaptiste Daroussinsince
5624*2fd5d190SBaptiste Daroussin.Li 2
5625*2fd5d190SBaptiste Daroussinis an option-argument of
5626*2fd5d190SBaptiste Daroussin.Op -C .
5627*2fd5d190SBaptiste DaroussinHowever, if the
5628*2fd5d190SBaptiste Daroussin.Ev POSIXLY_CORRECT
5629*2fd5d190SBaptiste Daroussinenvironment variable is set, options must appear before operands, unless otherwise
5630*2fd5d190SBaptiste Daroussinspecified for a particular command.
5631*2fd5d190SBaptiste Daroussin.Pp
5632*2fd5d190SBaptiste DaroussinNewer versions of POSIX are occasionally incompatible with older versions.
5633*2fd5d190SBaptiste DaroussinFor example, older versions of POSIX allowed the command
5634*2fd5d190SBaptiste Daroussin.Li diff -c -10
5635*2fd5d190SBaptiste Daroussinto have the same meaning as
5636*2fd5d190SBaptiste Daroussin.Li diff -C 10 ,
5637*2fd5d190SBaptiste Daroussinbut POSIX 1003.1-2001
5638*2fd5d190SBaptiste Daroussin.Li diff
5639*2fd5d190SBaptiste Daroussinno longer allows digit-string options like
5640*2fd5d190SBaptiste Daroussin.Op -10 .
5641*2fd5d190SBaptiste Daroussin.Pp
5642*2fd5d190SBaptiste DaroussinThe GNU utilities normally conform to the version of POSIX that is standard
5643*2fd5d190SBaptiste Daroussinfor your system. To cause them to conform to a different version of POSIX,
5644*2fd5d190SBaptiste Daroussindefine the
5645*2fd5d190SBaptiste Daroussin.Ev _POSIX2_VERSION
5646*2fd5d190SBaptiste Daroussinenvironment variable to a value of the form
5647*2fd5d190SBaptiste Daroussin.Va yyyymm
5648*2fd5d190SBaptiste Daroussinspecifying the year and month the standard was adopted. Two values are currently
5649*2fd5d190SBaptiste Daroussinsupported for
5650*2fd5d190SBaptiste Daroussin.Ev _POSIX2_VERSION :
5651*2fd5d190SBaptiste Daroussin.Li 199209
5652*2fd5d190SBaptiste Daroussinstands for POSIX 1003.2-1992, and
5653*2fd5d190SBaptiste Daroussin.Li 200112
5654*2fd5d190SBaptiste Daroussinstands for POSIX 1003.1-2001. For example, if you are running older software
5655*2fd5d190SBaptiste Daroussinthat assumes an older version of POSIX and uses
5656*2fd5d190SBaptiste Daroussin.Li diff -c -10 ,
5657*2fd5d190SBaptiste Daroussinyou can work around the compatibility problems by setting
5658*2fd5d190SBaptiste Daroussin.Li _POSIX2_VERSION=199209
5659*2fd5d190SBaptiste Daroussinin your environment.
5660*2fd5d190SBaptiste Daroussin.Pp
5661*2fd5d190SBaptiste Daroussin.Sh  Future Projects
5662*2fd5d190SBaptiste DaroussinHere are some ideas for improving GNU
5663*2fd5d190SBaptiste Daroussin.Xr diff
5664*2fd5d190SBaptiste Daroussinand
5665*2fd5d190SBaptiste Daroussin.Xr patch .
5666*2fd5d190SBaptiste DaroussinThe GNU project has identified some improvements as potential programming
5667*2fd5d190SBaptiste Daroussinprojects for volunteers. You can also help by reporting any bugs that you
5668*2fd5d190SBaptiste Daroussinfind.
5669*2fd5d190SBaptiste Daroussin.Pp
5670*2fd5d190SBaptiste DaroussinIf you are a programmer and would like to contribute something to the GNU
5671*2fd5d190SBaptiste Daroussinproject, please consider volunteering for one of these projects. If you are
5672*2fd5d190SBaptiste Daroussinseriously contemplating work, please write to
5673*2fd5d190SBaptiste Daroussin.Mt gvc@gnu.org
5674*2fd5d190SBaptiste Daroussinto coordinate with other volunteers.
5675*2fd5d190SBaptiste Daroussin.Pp
5676*2fd5d190SBaptiste Daroussin.Ss  Suggested Projects for Improving GNU Xr diff and Xr patch
5677*2fd5d190SBaptiste DaroussinOne should be able to use GNU
5678*2fd5d190SBaptiste Daroussin.Xr diff
5679*2fd5d190SBaptiste Daroussinto generate a patch from any pair of directory trees, and given the patch
5680*2fd5d190SBaptiste Daroussinand a copy of one such tree, use
5681*2fd5d190SBaptiste Daroussin.Xr patch
5682*2fd5d190SBaptiste Daroussinto generate a faithful copy of the other. Unfortunately, some changes to directory
5683*2fd5d190SBaptiste Daroussintrees cannot be expressed using current patch formats; also,
5684*2fd5d190SBaptiste Daroussin.Xr patch
5685*2fd5d190SBaptiste Daroussindoes not handle some of the existing formats. These shortcomings motivate
5686*2fd5d190SBaptiste Daroussinthe following suggested projects.
5687*2fd5d190SBaptiste Daroussin.Pp
5688*2fd5d190SBaptiste Daroussin.Em  Handling Multibyte and Varying-Width Characters
5689*2fd5d190SBaptiste Daroussin.Pp
5690*2fd5d190SBaptiste Daroussin.Xr diff ,
5691*2fd5d190SBaptiste Daroussin.Xr diff3
5692*2fd5d190SBaptiste Daroussinand
5693*2fd5d190SBaptiste Daroussin.Xr sdiff
5694*2fd5d190SBaptiste Daroussintreat each line of input as a string of unibyte characters. This can mishandle
5695*2fd5d190SBaptiste Daroussinmultibyte characters in some cases. For example, when asked to ignore spaces,
5696*2fd5d190SBaptiste Daroussin.Xr diff
5697*2fd5d190SBaptiste Daroussindoes not properly ignore a multibyte space character.
5698*2fd5d190SBaptiste Daroussin.Pp
5699*2fd5d190SBaptiste DaroussinAlso,
5700*2fd5d190SBaptiste Daroussin.Xr diff
5701*2fd5d190SBaptiste Daroussincurrently assumes that each byte is one column wide, and this assumption is
5702*2fd5d190SBaptiste Daroussinincorrect in some locales, e.g., locales that use UTF-8 encoding. This causes
5703*2fd5d190SBaptiste Daroussinproblems with the
5704*2fd5d190SBaptiste Daroussin.Op -y
5705*2fd5d190SBaptiste Daroussinor
5706*2fd5d190SBaptiste Daroussin.Op --side-by-side
5707*2fd5d190SBaptiste Daroussinoption of
5708*2fd5d190SBaptiste Daroussin.Xr diff .
5709*2fd5d190SBaptiste Daroussin.Pp
5710*2fd5d190SBaptiste DaroussinThese problems need to be fixed without unduly affecting the performance of
5711*2fd5d190SBaptiste Daroussinthe utilities in unibyte environments.
5712*2fd5d190SBaptiste Daroussin.Pp
5713*2fd5d190SBaptiste DaroussinThe IBM GNU/Linux Technology Center Internationalization Team has proposed
5714*2fd5d190SBaptiste Daroussin.Lk http://oss.software.ibm.com/developer/opensource/linux/patches/i18n/diffutils-2.7.2-i18n-0.1.patch.gz .
5715*2fd5d190SBaptiste DaroussinUnfortunately, these patches are incomplete and are to an older version of
5716*2fd5d190SBaptiste Daroussin.Xr diff ,
5717*2fd5d190SBaptiste Daroussinso more work needs to be done in this area.
5718*2fd5d190SBaptiste Daroussin.Pp
5719*2fd5d190SBaptiste Daroussin.Em  Handling Changes to the Directory Structure
5720*2fd5d190SBaptiste Daroussin.Pp
5721*2fd5d190SBaptiste Daroussin.Xr diff
5722*2fd5d190SBaptiste Daroussinand
5723*2fd5d190SBaptiste Daroussin.Xr patch
5724*2fd5d190SBaptiste Daroussindo not handle some changes to directory structure. For example, suppose one
5725*2fd5d190SBaptiste Daroussindirectory tree contains a directory named
5726*2fd5d190SBaptiste Daroussin.Li D
5727*2fd5d190SBaptiste Daroussinwith some subsidiary files, and another contains a file with the same name
5728*2fd5d190SBaptiste Daroussin.Li D .
5729*2fd5d190SBaptiste Daroussin.Li diff -r
5730*2fd5d190SBaptiste Daroussindoes not output enough information for
5731*2fd5d190SBaptiste Daroussin.Xr patch
5732*2fd5d190SBaptiste Daroussinto transform the directory subtree into the file.
5733*2fd5d190SBaptiste Daroussin.Pp
5734*2fd5d190SBaptiste DaroussinThere should be a way to specify that a file has been removed without having
5735*2fd5d190SBaptiste Daroussinto include its entire contents in the patch file. There should also be a way
5736*2fd5d190SBaptiste Daroussinto tell
5737*2fd5d190SBaptiste Daroussin.Xr patch
5738*2fd5d190SBaptiste Daroussinthat a file was renamed, even if there is no way for
5739*2fd5d190SBaptiste Daroussin.Xr diff
5740*2fd5d190SBaptiste Daroussinto generate such information. There should be a way to tell
5741*2fd5d190SBaptiste Daroussin.Xr patch
5742*2fd5d190SBaptiste Daroussinthat a file's time stamp has changed, even if its contents have not changed.
5743*2fd5d190SBaptiste Daroussin.Pp
5744*2fd5d190SBaptiste DaroussinThese problems can be fixed by extending the
5745*2fd5d190SBaptiste Daroussin.Xr diff
5746*2fd5d190SBaptiste Daroussinoutput format to represent changes in directory structure, and extending
5747*2fd5d190SBaptiste Daroussin.Xr patch
5748*2fd5d190SBaptiste Daroussinto understand these extensions.
5749*2fd5d190SBaptiste Daroussin.Pp
5750*2fd5d190SBaptiste Daroussin.Em  Files that are Neither Directories Nor Regular Files
5751*2fd5d190SBaptiste Daroussin.Pp
5752*2fd5d190SBaptiste DaroussinSome files are neither directories nor regular files: they are unusual files
5753*2fd5d190SBaptiste Daroussinlike symbolic links, device special files, named pipes, and sockets. Currently,
5754*2fd5d190SBaptiste Daroussin.Xr diff
5755*2fd5d190SBaptiste Daroussintreats symbolic links as if they were the pointed-to files, except that a
5756*2fd5d190SBaptiste Daroussinrecursive
5757*2fd5d190SBaptiste Daroussin.Xr diff
5758*2fd5d190SBaptiste Daroussinreports an error if it detects infinite loops of symbolic links (e.g., symbolic
5759*2fd5d190SBaptiste Daroussinlinks to
5760*2fd5d190SBaptiste Daroussin.Pa .. ) .
5761*2fd5d190SBaptiste Daroussin.Xr diff
5762*2fd5d190SBaptiste Daroussintreats other special files like regular files if they are specified at the
5763*2fd5d190SBaptiste Daroussintop level, but simply reports their presence when comparing directories. This
5764*2fd5d190SBaptiste Daroussinmeans that
5765*2fd5d190SBaptiste Daroussin.Xr patch
5766*2fd5d190SBaptiste Daroussincannot represent changes to such files. For example, if you change which file
5767*2fd5d190SBaptiste Daroussina symbolic link points to,
5768*2fd5d190SBaptiste Daroussin.Xr diff
5769*2fd5d190SBaptiste Daroussinoutputs the difference between the two files, instead of the change to the
5770*2fd5d190SBaptiste Daroussinsymbolic link.
5771*2fd5d190SBaptiste Daroussin.Pp
5772*2fd5d190SBaptiste Daroussin.Xr diff
5773*2fd5d190SBaptiste Daroussinshould optionally report changes to special files specially, and
5774*2fd5d190SBaptiste Daroussin.Xr patch
5775*2fd5d190SBaptiste Daroussinshould be extended to understand these extensions.
5776*2fd5d190SBaptiste Daroussin.Pp
5777*2fd5d190SBaptiste Daroussin.Em  File Names that Contain Unusual Characters
5778*2fd5d190SBaptiste Daroussin.Pp
5779*2fd5d190SBaptiste DaroussinWhen a file name contains an unusual character like a newline or white space,
5780*2fd5d190SBaptiste Daroussin.Li diff -r
5781*2fd5d190SBaptiste Daroussingenerates a patch that
5782*2fd5d190SBaptiste Daroussin.Xr patch
5783*2fd5d190SBaptiste Daroussincannot parse. The problem is with format of
5784*2fd5d190SBaptiste Daroussin.Xr diff
5785*2fd5d190SBaptiste Daroussinoutput, not just with
5786*2fd5d190SBaptiste Daroussin.Xr patch ,
5787*2fd5d190SBaptiste Daroussinbecause with odd enough file names one can cause
5788*2fd5d190SBaptiste Daroussin.Xr diff
5789*2fd5d190SBaptiste Daroussinto generate a patch that is syntactically correct but patches the wrong files.
5790*2fd5d190SBaptiste DaroussinThe format of
5791*2fd5d190SBaptiste Daroussin.Xr diff
5792*2fd5d190SBaptiste Daroussinoutput should be extended to handle all possible file names.
5793*2fd5d190SBaptiste Daroussin.Pp
5794*2fd5d190SBaptiste Daroussin.Em  Outputting Diffs in Time Stamp Order
5795*2fd5d190SBaptiste Daroussin.Pp
5796*2fd5d190SBaptiste DaroussinApplying
5797*2fd5d190SBaptiste Daroussin.Xr patch
5798*2fd5d190SBaptiste Daroussinto a multiple-file diff can result in files whose time stamps are out of order.
5799*2fd5d190SBaptiste DaroussinGNU
5800*2fd5d190SBaptiste Daroussin.Xr patch
5801*2fd5d190SBaptiste Daroussinhas options to restore the time stamps of the updated files (see Section
5802*2fd5d190SBaptiste Daroussin.Dq Patching Time Stamps ) ,
5803*2fd5d190SBaptiste Daroussinbut sometimes it is useful to generate a patch that works even if the recipient
5804*2fd5d190SBaptiste Daroussindoes not have GNU patch, or does not use these options. One way to do this
5805*2fd5d190SBaptiste Daroussinwould be to implement a
5806*2fd5d190SBaptiste Daroussin.Xr diff
5807*2fd5d190SBaptiste Daroussinoption to output diffs in time stamp order.
5808*2fd5d190SBaptiste Daroussin.Pp
5809*2fd5d190SBaptiste Daroussin.Em  Ignoring Certain Changes
5810*2fd5d190SBaptiste Daroussin.Pp
5811*2fd5d190SBaptiste DaroussinIt would be nice to have a feature for specifying two strings, one in
5812*2fd5d190SBaptiste Daroussin.Va from-file
5813*2fd5d190SBaptiste Daroussinand one in
5814*2fd5d190SBaptiste Daroussin.Va to-file ,
5815*2fd5d190SBaptiste Daroussinwhich should be considered to match. Thus, if the two strings are
5816*2fd5d190SBaptiste Daroussin.Li foo
5817*2fd5d190SBaptiste Daroussinand
5818*2fd5d190SBaptiste Daroussin.Li bar ,
5819*2fd5d190SBaptiste Daroussinthen if two lines differ only in that
5820*2fd5d190SBaptiste Daroussin.Li foo
5821*2fd5d190SBaptiste Daroussinin file 1 corresponds to
5822*2fd5d190SBaptiste Daroussin.Li bar
5823*2fd5d190SBaptiste Daroussinin file 2, the lines are treated as identical.
5824*2fd5d190SBaptiste Daroussin.Pp
5825*2fd5d190SBaptiste DaroussinIt is not clear how general this feature can or should be, or what syntax
5826*2fd5d190SBaptiste Daroussinshould be used for it.
5827*2fd5d190SBaptiste Daroussin.Pp
5828*2fd5d190SBaptiste DaroussinA partial substitute is to filter one or both files before comparing, e.g.:
5829*2fd5d190SBaptiste Daroussin.Pp
5830*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
5831*2fd5d190SBaptiste Daroussinsed 's/foo/bar/g' file1 | diff - file2
5832*2fd5d190SBaptiste Daroussin.Ed
5833*2fd5d190SBaptiste Daroussin.Pp
5834*2fd5d190SBaptiste DaroussinHowever, this outputs the filtered text, not the original.
5835*2fd5d190SBaptiste Daroussin.Pp
5836*2fd5d190SBaptiste Daroussin.Em  Improving Performance
5837*2fd5d190SBaptiste Daroussin.Pp
5838*2fd5d190SBaptiste DaroussinWhen comparing two large directory structures, one of which was originally
5839*2fd5d190SBaptiste Daroussincopied from the other with time stamps preserved (e.g., with
5840*2fd5d190SBaptiste Daroussin.Li cp -pR ) ,
5841*2fd5d190SBaptiste Daroussinit would greatly improve performance if an option told
5842*2fd5d190SBaptiste Daroussin.Xr diff
5843*2fd5d190SBaptiste Daroussinto assume that two files with the same size and time stamps have the same
5844*2fd5d190SBaptiste Daroussincontent.See Section
5845*2fd5d190SBaptiste Daroussin.Dq diff Performance .
5846*2fd5d190SBaptiste Daroussin.Pp
5847*2fd5d190SBaptiste Daroussin.Ss  Reporting Bugs
5848*2fd5d190SBaptiste DaroussinIf you think you have found a bug in GNU
5849*2fd5d190SBaptiste Daroussin.Xr cmp ,
5850*2fd5d190SBaptiste Daroussin.Xr diff ,
5851*2fd5d190SBaptiste Daroussin.Xr diff3 ,
5852*2fd5d190SBaptiste Daroussinor
5853*2fd5d190SBaptiste Daroussin.Xr sdiff ,
5854*2fd5d190SBaptiste Daroussinplease report it by electronic mail to the
5855*2fd5d190SBaptiste Daroussin.Lk http://mail.gnu.org/mailman/listinfo/bug-gnu-utils
5856*2fd5d190SBaptiste Daroussin.Mt bug-gnu-utils@gnu.org .
5857*2fd5d190SBaptiste DaroussinPlease send bug reports for GNU
5858*2fd5d190SBaptiste Daroussin.Xr patch
5859*2fd5d190SBaptiste Daroussinto
5860*2fd5d190SBaptiste Daroussin.Mt bug-patch@gnu.org .
5861*2fd5d190SBaptiste DaroussinSend as precise a description of the problem as you can, including the output
5862*2fd5d190SBaptiste Daroussinof the
5863*2fd5d190SBaptiste Daroussin.Op --version
5864*2fd5d190SBaptiste Daroussinoption and sample input files that produce the bug, if applicable. If you
5865*2fd5d190SBaptiste Daroussinhave a nontrivial fix for the bug, please send it as well. If you have a patch,
5866*2fd5d190SBaptiste Daroussinplease send it too. It may simplify the maintainer's job if the patch is relative
5867*2fd5d190SBaptiste Daroussinto a recent test release, which you can find in the directory
5868*2fd5d190SBaptiste Daroussin.Lk ftp://alpha.gnu.org/gnu/diffutils/ .
5869*2fd5d190SBaptiste Daroussin.Pp
5870*2fd5d190SBaptiste Daroussin.Sh  Copying This Manual
5871*2fd5d190SBaptiste Daroussin.Ss  GNU Free Documentation License
5872*2fd5d190SBaptiste Daroussin.Bd -filled -offset indent
5873*2fd5d190SBaptiste DaroussinCopyright \(co 2000,2001,2002 Free Software Foundation, Inc. 59 Temple Place,
5874*2fd5d190SBaptiste DaroussinSuite 330, Boston, MA 02111-1307, USA
5875*2fd5d190SBaptiste Daroussin.Pp
5876*2fd5d190SBaptiste DaroussinEveryone is permitted to copy and distribute verbatim copies of this license
5877*2fd5d190SBaptiste Daroussindocument, but changing it is not allowed.
5878*2fd5d190SBaptiste Daroussin.Ed
5879*2fd5d190SBaptiste Daroussin.Pp
5880*2fd5d190SBaptiste Daroussin.Bl -enum
5881*2fd5d190SBaptiste Daroussin.It
5882*2fd5d190SBaptiste DaroussinPREAMBLE
5883*2fd5d190SBaptiste Daroussin.Pp
5884*2fd5d190SBaptiste DaroussinThe purpose of this License is to make a manual, textbook, or other functional
5885*2fd5d190SBaptiste Daroussinand useful document
5886*2fd5d190SBaptiste Daroussin.Em free
5887*2fd5d190SBaptiste Daroussinin the sense of freedom: to assure everyone the effective freedom to copy
5888*2fd5d190SBaptiste Daroussinand redistribute it, with or without modifying it, either commercially or
5889*2fd5d190SBaptiste Daroussinnoncommercially. Secondarily, this License preserves for the author and publisher
5890*2fd5d190SBaptiste Daroussina way to get credit for their work, while not being considered responsible
5891*2fd5d190SBaptiste Daroussinfor modifications made by others.
5892*2fd5d190SBaptiste Daroussin.Pp
5893*2fd5d190SBaptiste DaroussinThis License is a kind of \(lqcopyleft\(rq, which means that derivative works of the
5894*2fd5d190SBaptiste Daroussindocument must themselves be free in the same sense. It complements the GNU
5895*2fd5d190SBaptiste DaroussinGeneral Public License, which is a copyleft license designed for free software.
5896*2fd5d190SBaptiste Daroussin.Pp
5897*2fd5d190SBaptiste DaroussinWe have designed this License in order to use it for manuals for free software,
5898*2fd5d190SBaptiste Daroussinbecause free software needs free documentation: a free program should come
5899*2fd5d190SBaptiste Daroussinwith manuals providing the same freedoms that the software does. But this
5900*2fd5d190SBaptiste DaroussinLicense is not limited to software manuals; it can be used for any textual
5901*2fd5d190SBaptiste Daroussinwork, regardless of subject matter or whether it is published as a printed
5902*2fd5d190SBaptiste Daroussinbook. We recommend this License principally for works whose purpose is instruction
5903*2fd5d190SBaptiste Daroussinor reference.
5904*2fd5d190SBaptiste Daroussin.Pp
5905*2fd5d190SBaptiste Daroussin.It
5906*2fd5d190SBaptiste DaroussinAPPLICABILITY AND DEFINITIONS
5907*2fd5d190SBaptiste Daroussin.Pp
5908*2fd5d190SBaptiste DaroussinThis License applies to any manual or other work, in any medium, that contains
5909*2fd5d190SBaptiste Daroussina notice placed by the copyright holder saying it can be distributed under
5910*2fd5d190SBaptiste Daroussinthe terms of this License. Such a notice grants a world-wide, royalty-free
5911*2fd5d190SBaptiste Daroussinlicense, unlimited in duration, to use that work under the conditions stated
5912*2fd5d190SBaptiste Daroussinherein. The \(lqDocument\(rq, below, refers to any such manual or work. Any member
5913*2fd5d190SBaptiste Daroussinof the public is a licensee, and is addressed as \(lqyou\(rq. You accept the license
5914*2fd5d190SBaptiste Daroussinif you copy, modify or distribute the work in a way requiring permission under
5915*2fd5d190SBaptiste Daroussincopyright law.
5916*2fd5d190SBaptiste Daroussin.Pp
5917*2fd5d190SBaptiste DaroussinA \(lqModified Version\(rq of the Document means any work containing the Document
5918*2fd5d190SBaptiste Daroussinor a portion of it, either copied verbatim, or with modifications and/or translated
5919*2fd5d190SBaptiste Daroussininto another language.
5920*2fd5d190SBaptiste Daroussin.Pp
5921*2fd5d190SBaptiste DaroussinA \(lqSecondary Section\(rq is a named appendix or a front-matter section of the Document
5922*2fd5d190SBaptiste Daroussinthat deals exclusively with the relationship of the publishers or authors
5923*2fd5d190SBaptiste Daroussinof the Document to the Document's overall subject (or to related matters)
5924*2fd5d190SBaptiste Daroussinand contains nothing that could fall directly within that overall subject.
5925*2fd5d190SBaptiste Daroussin(Thus, if the Document is in part a textbook of mathematics, a Secondary Section
5926*2fd5d190SBaptiste Daroussinmay not explain any mathematics.) The relationship could be a matter of historical
5927*2fd5d190SBaptiste Daroussinconnection with the subject or with related matters, or of legal, commercial,
5928*2fd5d190SBaptiste Daroussinphilosophical, ethical or political position regarding them.
5929*2fd5d190SBaptiste Daroussin.Pp
5930*2fd5d190SBaptiste DaroussinThe \(lqInvariant Sections\(rq are certain Secondary Sections whose titles are designated,
5931*2fd5d190SBaptiste Daroussinas being those of Invariant Sections, in the notice that says that the Document
5932*2fd5d190SBaptiste Daroussinis released under this License. If a section does not fit the above definition
5933*2fd5d190SBaptiste Daroussinof Secondary then it is not allowed to be designated as Invariant. The Document
5934*2fd5d190SBaptiste Daroussinmay contain zero Invariant Sections. If the Document does not identify any
5935*2fd5d190SBaptiste DaroussinInvariant Sections then there are none.
5936*2fd5d190SBaptiste Daroussin.Pp
5937*2fd5d190SBaptiste DaroussinThe \(lqCover Texts\(rq are certain short passages of text that are listed, as Front-Cover
5938*2fd5d190SBaptiste DaroussinTexts or Back-Cover Texts, in the notice that says that the Document is released
5939*2fd5d190SBaptiste Daroussinunder this License. A Front-Cover Text may be at most 5 words, and a Back-Cover
5940*2fd5d190SBaptiste DaroussinText may be at most 25 words.
5941*2fd5d190SBaptiste Daroussin.Pp
5942*2fd5d190SBaptiste DaroussinA \(lqTransparent\(rq copy of the Document means a machine-readable copy, represented
5943*2fd5d190SBaptiste Daroussinin a format whose specification is available to the general public, that is
5944*2fd5d190SBaptiste Daroussinsuitable for revising the document straightforwardly with generic text editors
5945*2fd5d190SBaptiste Daroussinor (for images composed of pixels) generic paint programs or (for drawings)
5946*2fd5d190SBaptiste Daroussinsome widely available drawing editor, and that is suitable for input to text
5947*2fd5d190SBaptiste Daroussinformatters or for automatic translation to a variety of formats suitable for
5948*2fd5d190SBaptiste Daroussininput to text formatters. A copy made in an otherwise Transparent file format
5949*2fd5d190SBaptiste Daroussinwhose markup, or absence of markup, has been arranged to thwart or discourage
5950*2fd5d190SBaptiste Daroussinsubsequent modification by readers is not Transparent. An image format is
5951*2fd5d190SBaptiste Daroussinnot Transparent if used for any substantial amount of text. A copy that is
5952*2fd5d190SBaptiste Daroussinnot \(lqTransparent\(rq is called \(lqOpaque\(rq.
5953*2fd5d190SBaptiste Daroussin.Pp
5954*2fd5d190SBaptiste DaroussinExamples of suitable formats for Transparent copies include plain ascii without
5955*2fd5d190SBaptiste Daroussinmarkup, Texinfo input format, LaTeX input format, SGML or XML using a publicly
5956*2fd5d190SBaptiste Daroussinavailable DTD, and standard-conforming simple HTML, PostScript or PDF designed
5957*2fd5d190SBaptiste Daroussinfor human modification. Examples of transparent image formats include PNG,
5958*2fd5d190SBaptiste DaroussinXCF and JPG. Opaque formats include proprietary formats that can be read and
5959*2fd5d190SBaptiste Daroussinedited only by proprietary word processors, SGML or XML for which the DTD
5960*2fd5d190SBaptiste Daroussinand/or processing tools are not generally available, and the machine-generated
5961*2fd5d190SBaptiste DaroussinHTML, PostScript or PDF produced by some word processors for output purposes
5962*2fd5d190SBaptiste Daroussinonly.
5963*2fd5d190SBaptiste Daroussin.Pp
5964*2fd5d190SBaptiste DaroussinThe \(lqTitle Page\(rq means, for a printed book, the title page itself, plus such
5965*2fd5d190SBaptiste Daroussinfollowing pages as are needed to hold, legibly, the material this License
5966*2fd5d190SBaptiste Daroussinrequires to appear in the title page. For works in formats which do not have
5967*2fd5d190SBaptiste Daroussinany title page as such, \(lqTitle Page\(rq means the text near the most prominent
5968*2fd5d190SBaptiste Daroussinappearance of the work's title, preceding the beginning of the body of the
5969*2fd5d190SBaptiste Daroussintext.
5970*2fd5d190SBaptiste Daroussin.Pp
5971*2fd5d190SBaptiste DaroussinA section \(lqEntitled XYZ\(rq means a named subunit of the Document whose title either
5972*2fd5d190SBaptiste Daroussinis precisely XYZ or contains XYZ in parentheses following text that translates
5973*2fd5d190SBaptiste DaroussinXYZ in another language. (Here XYZ stands for a specific section name mentioned
5974*2fd5d190SBaptiste Daroussinbelow, such as \(lqAcknowledgements\(rq, \(lqDedications\(rq, \(lqEndorsements\(rq, or \(lqHistory\(rq.) To
5975*2fd5d190SBaptiste Daroussin\(lqPreserve the Title\(rq of such a section when you modify the Document means that
5976*2fd5d190SBaptiste Daroussinit remains a section \(lqEntitled XYZ\(rq according to this definition.
5977*2fd5d190SBaptiste Daroussin.Pp
5978*2fd5d190SBaptiste DaroussinThe Document may include Warranty Disclaimers next to the notice which states
5979*2fd5d190SBaptiste Daroussinthat this License applies to the Document. These Warranty Disclaimers are
5980*2fd5d190SBaptiste Daroussinconsidered to be included by reference in this License, but only as regards
5981*2fd5d190SBaptiste Daroussindisclaiming warranties: any other implication that these Warranty Disclaimers
5982*2fd5d190SBaptiste Daroussinmay have is void and has no effect on the meaning of this License.
5983*2fd5d190SBaptiste Daroussin.Pp
5984*2fd5d190SBaptiste Daroussin.It
5985*2fd5d190SBaptiste DaroussinVERBATIM COPYING
5986*2fd5d190SBaptiste Daroussin.Pp
5987*2fd5d190SBaptiste DaroussinYou may copy and distribute the Document in any medium, either commercially
5988*2fd5d190SBaptiste Daroussinor noncommercially, provided that this License, the copyright notices, and
5989*2fd5d190SBaptiste Daroussinthe license notice saying this License applies to the Document are reproduced
5990*2fd5d190SBaptiste Daroussinin all copies, and that you add no other conditions whatsoever to those of
5991*2fd5d190SBaptiste Daroussinthis License. You may not use technical measures to obstruct or control the
5992*2fd5d190SBaptiste Daroussinreading or further copying of the copies you make or distribute. However,
5993*2fd5d190SBaptiste Daroussinyou may accept compensation in exchange for copies. If you distribute a large
5994*2fd5d190SBaptiste Daroussinenough number of copies you must also follow the conditions in section 3.
5995*2fd5d190SBaptiste Daroussin.Pp
5996*2fd5d190SBaptiste DaroussinYou may also lend copies, under the same conditions stated above, and you
5997*2fd5d190SBaptiste Daroussinmay publicly display copies.
5998*2fd5d190SBaptiste Daroussin.Pp
5999*2fd5d190SBaptiste Daroussin.It
6000*2fd5d190SBaptiste DaroussinCOPYING IN QUANTITY
6001*2fd5d190SBaptiste Daroussin.Pp
6002*2fd5d190SBaptiste DaroussinIf you publish printed copies (or copies in media that commonly have printed
6003*2fd5d190SBaptiste Daroussincovers) of the Document, numbering more than 100, and the Document's license
6004*2fd5d190SBaptiste Daroussinnotice requires Cover Texts, you must enclose the copies in covers that carry,
6005*2fd5d190SBaptiste Daroussinclearly and legibly, all these Cover Texts: Front-Cover Texts on the front
6006*2fd5d190SBaptiste Daroussincover, and Back-Cover Texts on the back cover. Both covers must also clearly
6007*2fd5d190SBaptiste Daroussinand legibly identify you as the publisher of these copies. The front cover
6008*2fd5d190SBaptiste Daroussinmust present the full title with all words of the title equally prominent
6009*2fd5d190SBaptiste Daroussinand visible. You may add other material on the covers in addition. Copying
6010*2fd5d190SBaptiste Daroussinwith changes limited to the covers, as long as they preserve the title of
6011*2fd5d190SBaptiste Daroussinthe Document and satisfy these conditions, can be treated as verbatim copying
6012*2fd5d190SBaptiste Daroussinin other respects.
6013*2fd5d190SBaptiste Daroussin.Pp
6014*2fd5d190SBaptiste DaroussinIf the required texts for either cover are too voluminous to fit legibly,
6015*2fd5d190SBaptiste Daroussinyou should put the first ones listed (as many as fit reasonably) on the actual
6016*2fd5d190SBaptiste Daroussincover, and continue the rest onto adjacent pages.
6017*2fd5d190SBaptiste Daroussin.Pp
6018*2fd5d190SBaptiste DaroussinIf you publish or distribute Opaque copies of the Document numbering more
6019*2fd5d190SBaptiste Daroussinthan 100, you must either include a machine-readable Transparent copy along
6020*2fd5d190SBaptiste Daroussinwith each Opaque copy, or state in or with each Opaque copy a computer-network
6021*2fd5d190SBaptiste Daroussinlocation from which the general network-using public has access to download
6022*2fd5d190SBaptiste Daroussinusing public-standard network protocols a complete Transparent copy of the
6023*2fd5d190SBaptiste DaroussinDocument, free of added material. If you use the latter option, you must take
6024*2fd5d190SBaptiste Daroussinreasonably prudent steps, when you begin distribution of Opaque copies in
6025*2fd5d190SBaptiste Daroussinquantity, to ensure that this Transparent copy will remain thus accessible
6026*2fd5d190SBaptiste Daroussinat the stated location until at least one year after the last time you distribute
6027*2fd5d190SBaptiste Daroussinan Opaque copy (directly or through your agents or retailers) of that edition
6028*2fd5d190SBaptiste Daroussinto the public.
6029*2fd5d190SBaptiste Daroussin.Pp
6030*2fd5d190SBaptiste DaroussinIt is requested, but not required, that you contact the authors of the Document
6031*2fd5d190SBaptiste Daroussinwell before redistributing any large number of copies, to give them a chance
6032*2fd5d190SBaptiste Daroussinto provide you with an updated version of the Document.
6033*2fd5d190SBaptiste Daroussin.Pp
6034*2fd5d190SBaptiste Daroussin.It
6035*2fd5d190SBaptiste DaroussinMODIFICATIONS
6036*2fd5d190SBaptiste Daroussin.Pp
6037*2fd5d190SBaptiste DaroussinYou may copy and distribute a Modified Version of the Document under the conditions
6038*2fd5d190SBaptiste Daroussinof sections 2 and 3 above, provided that you release the Modified Version
6039*2fd5d190SBaptiste Daroussinunder precisely this License, with the Modified Version filling the role of
6040*2fd5d190SBaptiste Daroussinthe Document, thus licensing distribution and modification of the Modified
6041*2fd5d190SBaptiste DaroussinVersion to whoever possesses a copy of it. In addition, you must do these
6042*2fd5d190SBaptiste Daroussinthings in the Modified Version:
6043*2fd5d190SBaptiste Daroussin.Pp
6044*2fd5d190SBaptiste Daroussin.Bl -enum
6045*2fd5d190SBaptiste Daroussin.It
6046*2fd5d190SBaptiste DaroussinUse in the Title Page (and on the covers, if any) a title distinct from that
6047*2fd5d190SBaptiste Daroussinof the Document, and from those of previous versions (which should, if there
6048*2fd5d190SBaptiste Daroussinwere any, be listed in the History section of the Document). You may use the
6049*2fd5d190SBaptiste Daroussinsame title as a previous version if the original publisher of that version
6050*2fd5d190SBaptiste Daroussingives permission.
6051*2fd5d190SBaptiste Daroussin.Pp
6052*2fd5d190SBaptiste Daroussin.It
6053*2fd5d190SBaptiste DaroussinList on the Title Page, as authors, one or more persons or entities responsible
6054*2fd5d190SBaptiste Daroussinfor authorship of the modifications in the Modified Version, together with
6055*2fd5d190SBaptiste Daroussinat least five of the principal authors of the Document (all of its principal
6056*2fd5d190SBaptiste Daroussinauthors, if it has fewer than five), unless they release you from this requirement.
6057*2fd5d190SBaptiste Daroussin.Pp
6058*2fd5d190SBaptiste Daroussin.It
6059*2fd5d190SBaptiste DaroussinState on the Title page the name of the publisher of the Modified Version,
6060*2fd5d190SBaptiste Daroussinas the publisher.
6061*2fd5d190SBaptiste Daroussin.Pp
6062*2fd5d190SBaptiste Daroussin.It
6063*2fd5d190SBaptiste DaroussinPreserve all the copyright notices of the Document.
6064*2fd5d190SBaptiste Daroussin.Pp
6065*2fd5d190SBaptiste Daroussin.It
6066*2fd5d190SBaptiste DaroussinAdd an appropriate copyright notice for your modifications adjacent to the
6067*2fd5d190SBaptiste Daroussinother copyright notices.
6068*2fd5d190SBaptiste Daroussin.Pp
6069*2fd5d190SBaptiste Daroussin.It
6070*2fd5d190SBaptiste DaroussinInclude, immediately after the copyright notices, a license notice giving
6071*2fd5d190SBaptiste Daroussinthe public permission to use the Modified Version under the terms of this
6072*2fd5d190SBaptiste DaroussinLicense, in the form shown in the Addendum below.
6073*2fd5d190SBaptiste Daroussin.Pp
6074*2fd5d190SBaptiste Daroussin.It
6075*2fd5d190SBaptiste DaroussinPreserve in that license notice the full lists of Invariant Sections and required
6076*2fd5d190SBaptiste DaroussinCover Texts given in the Document's license notice.
6077*2fd5d190SBaptiste Daroussin.Pp
6078*2fd5d190SBaptiste Daroussin.It
6079*2fd5d190SBaptiste DaroussinInclude an unaltered copy of this License.
6080*2fd5d190SBaptiste Daroussin.Pp
6081*2fd5d190SBaptiste Daroussin.It
6082*2fd5d190SBaptiste DaroussinPreserve the section Entitled \(lqHistory\(rq, Preserve its Title, and add to it an
6083*2fd5d190SBaptiste Daroussinitem stating at least the title, year, new authors, and publisher of the Modified
6084*2fd5d190SBaptiste DaroussinVersion as given on the Title Page. If there is no section Entitled \(lqHistory\(rq
6085*2fd5d190SBaptiste Daroussinin the Document, create one stating the title, year, authors, and publisher
6086*2fd5d190SBaptiste Daroussinof the Document as given on its Title Page, then add an item describing the
6087*2fd5d190SBaptiste DaroussinModified Version as stated in the previous sentence.
6088*2fd5d190SBaptiste Daroussin.Pp
6089*2fd5d190SBaptiste Daroussin.It
6090*2fd5d190SBaptiste DaroussinPreserve the network location, if any, given in the Document for public access
6091*2fd5d190SBaptiste Daroussinto a Transparent copy of the Document, and likewise the network locations
6092*2fd5d190SBaptiste Daroussingiven in the Document for previous versions it was based on. These may be
6093*2fd5d190SBaptiste Daroussinplaced in the \(lqHistory\(rq section. You may omit a network location for a work
6094*2fd5d190SBaptiste Daroussinthat was published at least four years before the Document itself, or if the
6095*2fd5d190SBaptiste Daroussinoriginal publisher of the version it refers to gives permission.
6096*2fd5d190SBaptiste Daroussin.Pp
6097*2fd5d190SBaptiste Daroussin.It
6098*2fd5d190SBaptiste DaroussinFor any section Entitled \(lqAcknowledgements\(rq or \(lqDedications\(rq, Preserve the Title
6099*2fd5d190SBaptiste Daroussinof the section, and preserve in the section all the substance and tone of
6100*2fd5d190SBaptiste Daroussineach of the contributor acknowledgements and/or dedications given therein.
6101*2fd5d190SBaptiste Daroussin.Pp
6102*2fd5d190SBaptiste Daroussin.It
6103*2fd5d190SBaptiste DaroussinPreserve all the Invariant Sections of the Document, unaltered in their text
6104*2fd5d190SBaptiste Daroussinand in their titles. Section numbers or the equivalent are not considered
6105*2fd5d190SBaptiste Daroussinpart of the section titles.
6106*2fd5d190SBaptiste Daroussin.Pp
6107*2fd5d190SBaptiste Daroussin.It
6108*2fd5d190SBaptiste DaroussinDelete any section Entitled \(lqEndorsements\(rq. Such a section may not be included
6109*2fd5d190SBaptiste Daroussinin the Modified Version.
6110*2fd5d190SBaptiste Daroussin.Pp
6111*2fd5d190SBaptiste Daroussin.It
6112*2fd5d190SBaptiste DaroussinDo not retitle any existing section to be Entitled \(lqEndorsements\(rq or to conflict
6113*2fd5d190SBaptiste Daroussinin title with any Invariant Section.
6114*2fd5d190SBaptiste Daroussin.Pp
6115*2fd5d190SBaptiste Daroussin.It
6116*2fd5d190SBaptiste DaroussinPreserve any Warranty Disclaimers.
6117*2fd5d190SBaptiste Daroussin.El
6118*2fd5d190SBaptiste Daroussin.Pp
6119*2fd5d190SBaptiste DaroussinIf the Modified Version includes new front-matter sections or appendices that
6120*2fd5d190SBaptiste Daroussinqualify as Secondary Sections and contain no material copied from the Document,
6121*2fd5d190SBaptiste Daroussinyou may at your option designate some or all of these sections as invariant.
6122*2fd5d190SBaptiste DaroussinTo do this, add their titles to the list of Invariant Sections in the Modified
6123*2fd5d190SBaptiste DaroussinVersion's license notice. These titles must be distinct from any other section
6124*2fd5d190SBaptiste Daroussintitles.
6125*2fd5d190SBaptiste Daroussin.Pp
6126*2fd5d190SBaptiste DaroussinYou may add a section Entitled \(lqEndorsements\(rq, provided it contains nothing
6127*2fd5d190SBaptiste Daroussinbut endorsements of your Modified Version by various parties---for example,
6128*2fd5d190SBaptiste Daroussinstatements of peer review or that the text has been approved by an organization
6129*2fd5d190SBaptiste Daroussinas the authoritative definition of a standard.
6130*2fd5d190SBaptiste Daroussin.Pp
6131*2fd5d190SBaptiste DaroussinYou may add a passage of up to five words as a Front-Cover Text, and a passage
6132*2fd5d190SBaptiste Daroussinof up to 25 words as a Back-Cover Text, to the end of the list of Cover Texts
6133*2fd5d190SBaptiste Daroussinin the Modified Version. Only one passage of Front-Cover Text and one of Back-Cover
6134*2fd5d190SBaptiste DaroussinText may be added by (or through arrangements made by) any one entity. If
6135*2fd5d190SBaptiste Daroussinthe Document already includes a cover text for the same cover, previously
6136*2fd5d190SBaptiste Daroussinadded by you or by arrangement made by the same entity you are acting on behalf
6137*2fd5d190SBaptiste Daroussinof, you may not add another; but you may replace the old one, on explicit
6138*2fd5d190SBaptiste Daroussinpermission from the previous publisher that added the old one.
6139*2fd5d190SBaptiste Daroussin.Pp
6140*2fd5d190SBaptiste DaroussinThe author(s) and publisher(s) of the Document do not by this License give
6141*2fd5d190SBaptiste Daroussinpermission to use their names for publicity for or to assert or imply endorsement
6142*2fd5d190SBaptiste Daroussinof any Modified Version.
6143*2fd5d190SBaptiste Daroussin.Pp
6144*2fd5d190SBaptiste Daroussin.It
6145*2fd5d190SBaptiste DaroussinCOMBINING DOCUMENTS
6146*2fd5d190SBaptiste Daroussin.Pp
6147*2fd5d190SBaptiste DaroussinYou may combine the Document with other documents released under this License,
6148*2fd5d190SBaptiste Daroussinunder the terms defined in section 4 above for modified versions, provided
6149*2fd5d190SBaptiste Daroussinthat you include in the combination all of the Invariant Sections of all of
6150*2fd5d190SBaptiste Daroussinthe original documents, unmodified, and list them all as Invariant Sections
6151*2fd5d190SBaptiste Daroussinof your combined work in its license notice, and that you preserve all their
6152*2fd5d190SBaptiste DaroussinWarranty Disclaimers.
6153*2fd5d190SBaptiste Daroussin.Pp
6154*2fd5d190SBaptiste DaroussinThe combined work need only contain one copy of this License, and multiple
6155*2fd5d190SBaptiste Daroussinidentical Invariant Sections may be replaced with a single copy. If there
6156*2fd5d190SBaptiste Daroussinare multiple Invariant Sections with the same name but different contents,
6157*2fd5d190SBaptiste Daroussinmake the title of each such section unique by adding at the end of it, in
6158*2fd5d190SBaptiste Daroussinparentheses, the name of the original author or publisher of that section
6159*2fd5d190SBaptiste Daroussinif known, or else a unique number. Make the same adjustment to the section
6160*2fd5d190SBaptiste Daroussintitles in the list of Invariant Sections in the license notice of the combined
6161*2fd5d190SBaptiste Daroussinwork.
6162*2fd5d190SBaptiste Daroussin.Pp
6163*2fd5d190SBaptiste DaroussinIn the combination, you must combine any sections Entitled \(lqHistory\(rq in the
6164*2fd5d190SBaptiste Daroussinvarious original documents, forming one section Entitled \(lqHistory\(rq; likewise
6165*2fd5d190SBaptiste Daroussincombine any sections Entitled \(lqAcknowledgements\(rq, and any sections Entitled
6166*2fd5d190SBaptiste Daroussin\(lqDedications\(rq. You must delete all sections Entitled \(lqEndorsements.\(rq
6167*2fd5d190SBaptiste Daroussin.Pp
6168*2fd5d190SBaptiste Daroussin.It
6169*2fd5d190SBaptiste DaroussinCOLLECTIONS OF DOCUMENTS
6170*2fd5d190SBaptiste Daroussin.Pp
6171*2fd5d190SBaptiste DaroussinYou may make a collection consisting of the Document and other documents released
6172*2fd5d190SBaptiste Daroussinunder this License, and replace the individual copies of this License in the
6173*2fd5d190SBaptiste Daroussinvarious documents with a single copy that is included in the collection, provided
6174*2fd5d190SBaptiste Daroussinthat you follow the rules of this License for verbatim copying of each of
6175*2fd5d190SBaptiste Daroussinthe documents in all other respects.
6176*2fd5d190SBaptiste Daroussin.Pp
6177*2fd5d190SBaptiste DaroussinYou may extract a single document from such a collection, and distribute it
6178*2fd5d190SBaptiste Daroussinindividually under this License, provided you insert a copy of this License
6179*2fd5d190SBaptiste Daroussininto the extracted document, and follow this License in all other respects
6180*2fd5d190SBaptiste Daroussinregarding verbatim copying of that document.
6181*2fd5d190SBaptiste Daroussin.Pp
6182*2fd5d190SBaptiste Daroussin.It
6183*2fd5d190SBaptiste DaroussinAGGREGATION WITH INDEPENDENT WORKS
6184*2fd5d190SBaptiste Daroussin.Pp
6185*2fd5d190SBaptiste DaroussinA compilation of the Document or its derivatives with other separate and independent
6186*2fd5d190SBaptiste Daroussindocuments or works, in or on a volume of a storage or distribution medium,
6187*2fd5d190SBaptiste Daroussinis called an \(lqaggregate\(rq if the copyright resulting from the compilation is
6188*2fd5d190SBaptiste Daroussinnot used to limit the legal rights of the compilation's users beyond what
6189*2fd5d190SBaptiste Daroussinthe individual works permit. When the Document is included in an aggregate,
6190*2fd5d190SBaptiste Daroussinthis License does not apply to the other works in the aggregate which are
6191*2fd5d190SBaptiste Daroussinnot themselves derivative works of the Document.
6192*2fd5d190SBaptiste Daroussin.Pp
6193*2fd5d190SBaptiste DaroussinIf the Cover Text requirement of section 3 is applicable to these copies of
6194*2fd5d190SBaptiste Daroussinthe Document, then if the Document is less than one half of the entire aggregate,
6195*2fd5d190SBaptiste Daroussinthe Document's Cover Texts may be placed on covers that bracket the Document
6196*2fd5d190SBaptiste Daroussinwithin the aggregate, or the electronic equivalent of covers if the Document
6197*2fd5d190SBaptiste Daroussinis in electronic form. Otherwise they must appear on printed covers that bracket
6198*2fd5d190SBaptiste Daroussinthe whole aggregate.
6199*2fd5d190SBaptiste Daroussin.Pp
6200*2fd5d190SBaptiste Daroussin.It
6201*2fd5d190SBaptiste DaroussinTRANSLATION
6202*2fd5d190SBaptiste Daroussin.Pp
6203*2fd5d190SBaptiste DaroussinTranslation is considered a kind of modification, so you may distribute translations
6204*2fd5d190SBaptiste Daroussinof the Document under the terms of section 4. Replacing Invariant Sections
6205*2fd5d190SBaptiste Daroussinwith translations requires special permission from their copyright holders,
6206*2fd5d190SBaptiste Daroussinbut you may include translations of some or all Invariant Sections in addition
6207*2fd5d190SBaptiste Daroussinto the original versions of these Invariant Sections. You may include a translation
6208*2fd5d190SBaptiste Daroussinof this License, and all the license notices in the Document, and any Warranty
6209*2fd5d190SBaptiste DaroussinDisclaimers, provided that you also include the original English version of
6210*2fd5d190SBaptiste Daroussinthis License and the original versions of those notices and disclaimers. In
6211*2fd5d190SBaptiste Daroussincase of a disagreement between the translation and the original version of
6212*2fd5d190SBaptiste Daroussinthis License or a notice or disclaimer, the original version will prevail.
6213*2fd5d190SBaptiste Daroussin.Pp
6214*2fd5d190SBaptiste DaroussinIf a section in the Document is Entitled \(lqAcknowledgements\(rq, \(lqDedications\(rq, or
6215*2fd5d190SBaptiste Daroussin\(lqHistory\(rq, the requirement (section 4) to Preserve its Title (section 1) will
6216*2fd5d190SBaptiste Daroussintypically require changing the actual title.
6217*2fd5d190SBaptiste Daroussin.Pp
6218*2fd5d190SBaptiste Daroussin.It
6219*2fd5d190SBaptiste DaroussinTERMINATION
6220*2fd5d190SBaptiste Daroussin.Pp
6221*2fd5d190SBaptiste DaroussinYou may not copy, modify, sublicense, or distribute the Document except as
6222*2fd5d190SBaptiste Daroussinexpressly provided for under this License. Any other attempt to copy, modify,
6223*2fd5d190SBaptiste Daroussinsublicense or distribute the Document is void, and will automatically terminate
6224*2fd5d190SBaptiste Daroussinyour rights under this License. However, parties who have received copies,
6225*2fd5d190SBaptiste Daroussinor rights, from you under this License will not have their licenses terminated
6226*2fd5d190SBaptiste Daroussinso long as such parties remain in full compliance.
6227*2fd5d190SBaptiste Daroussin.Pp
6228*2fd5d190SBaptiste Daroussin.It
6229*2fd5d190SBaptiste DaroussinFUTURE REVISIONS OF THIS LICENSE
6230*2fd5d190SBaptiste Daroussin.Pp
6231*2fd5d190SBaptiste DaroussinThe Free Software Foundation may publish new, revised versions of the GNU
6232*2fd5d190SBaptiste DaroussinFree Documentation License from time to time. Such new versions will be similar
6233*2fd5d190SBaptiste Daroussinin spirit to the present version, but may differ in detail to address new
6234*2fd5d190SBaptiste Daroussinproblems or concerns. See
6235*2fd5d190SBaptiste Daroussin.Lk http://www.gnu.org/copyleft/ .
6236*2fd5d190SBaptiste Daroussin.Pp
6237*2fd5d190SBaptiste DaroussinEach version of the License is given a distinguishing version number. If the
6238*2fd5d190SBaptiste DaroussinDocument specifies that a particular numbered version of this License \(lqor any
6239*2fd5d190SBaptiste Daroussinlater version\(rq applies to it, you have the option of following the terms and
6240*2fd5d190SBaptiste Daroussinconditions either of that specified version or of any later version that has
6241*2fd5d190SBaptiste Daroussinbeen published (not as a draft) by the Free Software Foundation. If the Document
6242*2fd5d190SBaptiste Daroussindoes not specify a version number of this License, you may choose any version
6243*2fd5d190SBaptiste Daroussinever published (not as a draft) by the Free Software Foundation.
6244*2fd5d190SBaptiste Daroussin.El
6245*2fd5d190SBaptiste Daroussin.Pp
6246*2fd5d190SBaptiste Daroussin.Em  ADDENDUM: How to use this License for your documents
6247*2fd5d190SBaptiste Daroussin.Pp
6248*2fd5d190SBaptiste DaroussinTo use this License in a document you have written, include a copy of the
6249*2fd5d190SBaptiste DaroussinLicense in the document and put the following copyright and license notices
6250*2fd5d190SBaptiste Daroussinjust after the title page:
6251*2fd5d190SBaptiste Daroussin.Pp
6252*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
6253*2fd5d190SBaptiste Daroussin
6254*2fd5d190SBaptiste Daroussin  Copyright (C)  year  your name.
6255*2fd5d190SBaptiste Daroussin  Permission is granted to copy, distribute and/or modify this document
6256*2fd5d190SBaptiste Daroussin  under the terms of the GNU Free Documentation License, Version 1.2
6257*2fd5d190SBaptiste Daroussin  or any later version published by the Free Software Foundation;
6258*2fd5d190SBaptiste Daroussin  with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
6259*2fd5d190SBaptiste Daroussin  Texts.  A copy of the license is included in the section entitled \(lqGNU
6260*2fd5d190SBaptiste Daroussin  Free Documentation License\(rq.
6261*2fd5d190SBaptiste Daroussin
6262*2fd5d190SBaptiste Daroussin.Ed
6263*2fd5d190SBaptiste Daroussin.Pp
6264*2fd5d190SBaptiste DaroussinIf you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, replace
6265*2fd5d190SBaptiste Daroussinthe \(lqwith...Texts.\(rq line with this:
6266*2fd5d190SBaptiste Daroussin.Pp
6267*2fd5d190SBaptiste Daroussin.Bd -literal -offset indent
6268*2fd5d190SBaptiste Daroussin
6269*2fd5d190SBaptiste Daroussin    with the Invariant Sections being list their titles, with
6270*2fd5d190SBaptiste Daroussin    the Front-Cover Texts being list, and with the Back-Cover Texts
6271*2fd5d190SBaptiste Daroussin    being list.
6272*2fd5d190SBaptiste Daroussin
6273*2fd5d190SBaptiste Daroussin.Ed
6274*2fd5d190SBaptiste Daroussin.Pp
6275*2fd5d190SBaptiste DaroussinIf you have Invariant Sections without Cover Texts, or some other combination
6276*2fd5d190SBaptiste Daroussinof the three, merge those two alternatives to suit the situation.
6277*2fd5d190SBaptiste Daroussin.Pp
6278*2fd5d190SBaptiste DaroussinIf your document contains nontrivial examples of program code, we recommend
6279*2fd5d190SBaptiste Daroussinreleasing these examples in parallel under your choice of free software license,
6280*2fd5d190SBaptiste Daroussinsuch as the GNU General Public License, to permit their use in free software.
6281*2fd5d190SBaptiste Daroussin.Pp
6282*2fd5d190SBaptiste Daroussin.Sh  Translations of This Manual
6283*2fd5d190SBaptiste DaroussinNishio Futoshi of the GNUjdoc project has prepared a Japanese translation
6284*2fd5d190SBaptiste Daroussinof this manual. Its most recent version can be found at
6285*2fd5d190SBaptiste Daroussin.Lk http://openlab.ring.gr.jp/gnujdoc/cvsweb/cvsweb.cgi/gnujdoc/ .
6286*2fd5d190SBaptiste Daroussin.Pp
6287*2fd5d190SBaptiste Daroussin.Sh  Index
6288