summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason McIntyre <jmc@cvs.openbsd.org>2003-06-25 18:52:47 +0000
committerJason McIntyre <jmc@cvs.openbsd.org>2003-06-25 18:52:47 +0000
commitc6ed51c694ae72c86cbad0e1570afc0046266996 (patch)
tree9d953f064b5b0d672826a941a504c06d5eda838e
parent5ffcb5c03b077a83bc7f05cd5c582badad6907d7 (diff)
cleanup;
ok deraadt@
-rw-r--r--usr.bin/diff/diff.1163
1 files changed, 89 insertions, 74 deletions
diff --git a/usr.bin/diff/diff.1 b/usr.bin/diff/diff.1
index ad5ec0ca68b..1557b75aeae 100644
--- a/usr.bin/diff/diff.1
+++ b/usr.bin/diff/diff.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: diff.1,v 1.4 2003/06/25 16:10:05 deraadt Exp $
+.\" $OpenBSD: diff.1,v 1.5 2003/06/25 18:52:46 jmc Exp $
.\" Copyright (c) 1980, 1990, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -30,14 +30,14 @@
.\"
.Dd June 30, 1993
.Dt DIFF 1
-.Os BSD 4
+.Os
.Sh NAME
.Nm diff
.Nd differential file and directory comparator
.Sh SYNOPSIS
.Nm diff
.Op Fl cefhn
-.Op Fl biwt
+.Op Fl bitw
.Ar file1 file2
.Nm diff
.Op Fl D Ns Ar string
@@ -48,12 +48,12 @@
.Op Fl r
.Op Fl s
.Op Fl cefhn
-.Op Fl biwt
+.Op Fl bitw
.Op Fl S Ns Ar name
.Ar dir1 dir2
.Sh DESCRIPTION
The
-.Nm diff
+.Nm
utility compares the contents of
.Ar file1
and
@@ -65,8 +65,9 @@ No output is produced if the files are identical.
Output options (mutually exclusive):
.Bl -tag -width Ds
.It Fl c
-produces a diff with lines of context.
-The default is to present 3 lines of context and may be changed, e.g., to 10, by
+Produces a diff with lines of context.
+The default is to present 3 lines of context and may be changed, e.g., to 10,
+by
.Fl c10 .
With
.Fl c
@@ -76,54 +77,62 @@ their creation dates and then each change is separated
by a line with a dozen *'s.
The lines removed from
.Ar file1
-are marked with `\(mi '; those added to
+are marked with
+.Sq \-\ \& ;
+those added to
.Ar file2
-are marked `+ '. Lines which are changed from one
-file to the other are marked in both files with `! '.
-Changes which lie within <context> lines of each other are grouped
-together on output. (This is a change from the previous ``diff -c''
+are marked
+.Sq \+\ \& .
+Lines which are changed from one file to the other are marked in
+both files with
+.Sq !\ \& .
+Changes which lie within
+.Aq context
+lines of each other are grouped together on output.
+(This is a change from the previous
+.Dq diff -c
but the resulting output is usually much easier to interpret.)
.It Fl e
-produces output in a form suitable as input for the editor utility,
+Produces output in a form suitable as input for the editor utility,
.Xr ed 1 ,
which can then be used to convert file1 into file2.
.Pp
Extra commands are added to the output when comparing directories with
.Fl e ,
so that the result is a
-.Xr sh 1
+.Xr sh 1
script for converting text files which are common to the two directories
from their state in
.Ar dir1
to their state in
.Ar dir2 .
.It Fl f
-identical output to that of the
+Identical output to that of the
.Fl e
-flag, but in reverse order. It cannot
-be digested by
+flag, but in reverse order.
+It cannot be digested by
.Xr ed 1 .
.It Fl h
Invokes an alternate algorithm which can handle files of very long lengths.
-There is a trade off. The algorithm can only deal with changes which are
-clearly delimited and brief. Long sections of changes and overlaps will
-confuse it.
+There is a trade off.
+The algorithm can only deal with changes which are clearly delimited and brief.
+Long sections of changes and overlaps will confuse it.
.It Fl n
-produces a script similar to that of
+Produces a script similar to that of
.Fl e ,
but in the opposite order and with a count of changed lines on each
-insert or delete command. This is the form used by
-.Xr rcsdiff 1 .
+insert or delete command.
+This is the form used by
+.Xr rcsdiff 1 .
.It Fl D Ns Ar string
-creates a merged version of
+Creates a merged version of
.Ar file1
and
.Ar file2
on the standard output, with C preprocessor controls included so that
a compilation of the result without defining
.Ar string
-is equivalent
-to compiling
+is equivalent to compiling
.Ar file1 ,
while defining
.Ar string
@@ -134,54 +143,62 @@ will yield
Comparison options:
.Bl -tag -width Ds
.It Fl b
-causes trailing blanks (spaces and tabs) to be ignored, and other
+Causes trailing blanks (spaces and tabs) to be ignored, and other
strings of blanks to compare equal.
.It Fl i
-ignores the case of letters. E.g., ``A'' will compare equal to ``a''.
+Ignores the case of letters.
+E.g.,
+.Dq A
+will compare equal to
+.Dq a .
.It Fl t
-will expand tabs in output lines. Normal or
+Will expand tabs in output lines.
+Normal or
.Fl c
output adds character(s) to the front of each line which may screw up
the indentation of the original source lines and make the output listing
-difficult to interpret. This option will preserve the original source's
-indentation.
+difficult to interpret.
+This option will preserve the original source's indentation.
.It Fl w
-is similar to
+Is similar to
.Fl b
-but causes whitespace (blanks and tabs) to be totally ignored. E.g.,
-``if\ (\ a\ ==\ b\ )'' will compare equal to ``if(a==b)''.
+but causes whitespace (blanks and tabs) to be totally ignored.
+E.g.,
+.Dq if (\ \&a == b \&)
+will compare equal to
+.Dq if(a==b) .
.El
.Pp
Directory comparison options:
.Bl -tag -width Ds
.It Fl l
-long output format; each text file
+Long output format; each text file
.Nm diff Ns \'d
is piped through
-.Xr pr 1
-to paginate it,
+.Xr pr 1
+to paginate it;
other differences are remembered and summarized
after all text file differences are reported.
.It Fl r
-causes application of
-.Nm diff
+Causes application of
+.Nm
recursively to common subdirectories encountered.
.It Fl s
-causes
-.Nm diff
+Causes
+.Nm
to report files which are the same, which are otherwise not mentioned.
.It Fl S Ns Ar name
-re-starts a directory
-.Nm diff
-in the middle beginning with file
+Re-starts a directory
+.Nm
+in the middle, beginning with file
.Ar name .
.El
.Pp
If both arguments are directories,
-.Nm diff
+.Nm
sorts the contents of the directories by name, and then runs the
regular file
-.Nm diff
+.Nm
algorithm, producing a change list,
on text files which are different.
Binary files which differ,
@@ -193,7 +210,7 @@ If only one of
and
.Ar file2
is a directory,
-.Nm diff
+.Nm
is applied to the non-directory file and the file contained in
the directory file with a filename that is the same as the
last component of the non-directory file.
@@ -212,7 +229,7 @@ The default (without
.Fl c ,
or
.Fl n
-.\" -C
+.\" -C
options)
output contains lines of these forms, where
.Va XX , YY , ZZ , QQ
@@ -244,10 +261,10 @@ of file1.
At line
.Va XX
delete
-the line. The value
+the line.
+The value
.Va YY
-tells to which line the change
-would bring
+tells to which line the change would bring
.Ar file1
in line with
.Ar file1 .
@@ -266,7 +283,7 @@ in
to the line
.Va YY
in
-.Ar file2.
+.Ar file2 .
.It Li XX,YY Ns Ic c Ns Li ZZ
Replace the range of specified lines with the line
.Va ZZ .
@@ -311,7 +328,7 @@ number.
If the environment variable
.Ev TMPDIR
exists,
-.Nm diff
+.Nm
will use the directory specified by
.Ev TMPDIR
as the temporary directory.
@@ -323,23 +340,15 @@ as the temporary directory.
Alternate algorithm version (used by option
.Fl h ) .
.It Pa /usr/bin/diff
-for directory diffs
+For directory diffs.
.It Pa /usr/bin/pr
-used by the
+Used by the
.Fl l
option.
.El
-.Sh SEE ALSO
-.Xr cmp 1 ,
-.Xr cc 1 ,
-.Xr comm 1 ,
-.Xr ed 1 ,
-.Xr diff3 1
-.br
-.ne 1i
.Sh DIAGNOSTICS
The
-.Nm diff
+.Nm
utility exits with one of the following values:
.Pp
.Bl -tag -width Ds -compact -offset indent
@@ -347,9 +356,20 @@ utility exits with one of the following values:
No differences were found.
.It \&1
Differences were found.
-.It "\&>\&1"
+.It \*[Gt]\&1
An error occurred.
.El
+.Sh SEE ALSO
+.Xr cc 1 ,
+.Xr cmp 1 ,
+.Xr comm 1 ,
+.Xr diff3 1 ,
+.Xr ed 1
+.Sh HISTORY
+A
+.Nm
+command appeared in
+.At v6 .
.Sh BUGS
The
.Fl f
@@ -368,17 +388,12 @@ When comparing directories with the
or
.Fl i
options specified,
-.Nm diff
+.Nm
first compares the files ala
-.Ar cmp ,
+.Xr cmp 1 ,
and then decides to run the
-.Nm diff
+.Nm
algorithm if they are not equal.
This may cause a small amount of spurious output if the files
then turn out to be identical because the only differences are
-insignificant white space or case differences.
-.Sh HISTORY
-A
-.Nm
-command appeared in
-.At v6 .
+insignificant whitespace or case differences.