summaryrefslogtreecommitdiff
path: root/usr.bin/diff/diff.1
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2003-06-25 01:20:53 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2003-06-25 01:20:53 +0000
commite05edc6c22b8df9867ca93031a94a18910e2bfbf (patch)
tree2f05c40bd06943ff93f46c8156c842e9e45f4962 /usr.bin/diff/diff.1
parent87fbad9497b86c2a8876f24bbdddaa18deec5376 (diff)
4.3reno diff. This is free because of the Caldera license. Nasty, but a
place to start.
Diffstat (limited to 'usr.bin/diff/diff.1')
-rw-r--r--usr.bin/diff/diff.1402
1 files changed, 402 insertions, 0 deletions
diff --git a/usr.bin/diff/diff.1 b/usr.bin/diff/diff.1
new file mode 100644
index 00000000000..e570bcf9c03
--- /dev/null
+++ b/usr.bin/diff/diff.1
@@ -0,0 +1,402 @@
+.\" Copyright (c) 1980, 1990 The Regents of the University of California.
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms are permitted provided
+.\" that: (1) source distributions retain this entire copyright notice and
+.\" comment, and (2) distributions including binaries display the following
+.\" acknowledgement: ``This product includes software developed by the
+.\" University of California, Berkeley and its contributors'' in the
+.\" documentation or other materials provided with the distribution and in
+.\" all advertising materials mentioning features or use of this software.
+.\" Neither the name of the University nor the names of its contributors may
+.\" be used to endorse or promote products derived from this software without
+.\" specific prior written permission.
+.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+.\"
+.\" @(#)diff.1 6.6 (Berkeley) 7/24/90
+.\"
+.Dd July 24, 1990
+.Dt DIFF 1
+.Os BSD 4
+.Sh NAME
+.Nm diff
+.Nd differential file and directory comparator
+.Sh SYNOPSIS
+.Nm diff
+.Op Fl cefhn
+.Op Fl biwt
+.Ar file1 file2
+.Nm diff
+.Op Fl D Ar string
+.Op Fl biw
+.Ar file1 file2
+.Nm diff
+.Op Fl l
+.Op Fl r
+.Op Fl s
+.Op Fl cefhn
+.Op Fl biwt
+.Ar dir1 dir2
+.Sh DESCRIPTION
+The
+.Nm diff
+utility compares the contents of
+.Ar file1
+and
+.Ar file2
+and writes to the standard output the list of changes necessary to
+convert one file into the other.
+No output is produced if the files are identical.
+.Pp
+Output options (mutually exclusive):
+.Tw Fl
+.Tp 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
+.Fl c10 .
+With
+.Fl c
+the output format is modified slightly:
+the output beginning with identification of the files involved and
+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
+.Ar file2
+are marked `+ '. Lines which are changed from one
+file to the other are marked in both files with with `! '.
+Changes which lie within <context> lines of each other are grouped
+together on output. (This is a change from the previous ``diff -c''
+but the resulting output is usually much easier to interpret.)
+.Tp Fl e
+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
+script for converting text files which are common to the two directories
+from their state in
+.Ar dir1
+to their state in
+.Ar dir2 .
+.Tp Fl f
+identical output of the
+.Fl e
+flag, but in reverse order. It cannot
+be digested by
+.Xr ed 1 .
+.Tp 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.
+.Tp Fl n
+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 .
+.Tc Fl D
+.Ar string
+.Cx
+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
+.Ar file1 ,
+while defining
+.Ar string
+will yield
+.Ar file2 .
+.Tp
+.Pp
+Comparison options:
+.Tp Fl b
+causes trailing blanks (spaces and tabs) to be ignored, and other
+strings of blanks to compare equal.
+.Tp Fl i
+ignores the case of letters. E.g., ``A'' will compare equal to ``a''.
+.Tp Fl t
+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.
+.Tp Fl w
+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)''.
+.Tp
+.Pp
+Directory comparison options:
+.Tw Fl
+.Tp Fl l
+long output format; each text file
+.Sf Nm diff \'d
+is piped through
+.Xr pr 1
+to paginate it,
+other differences are remembered and summarized
+after all text file differences are reported.
+.Tp Fl r
+causes application of
+.Nm diff
+recursively to common subdirectories encountered.
+.Tp Fl s
+causes
+.Nm diff
+to report files which are the same, which are otherwise not mentioned.
+.Tc Fl S
+.Ar name
+.Cx
+re-starts a directory
+.Nm diff
+in the middle beginning with file
+.Ar name .
+.Tp
+.Pp
+If both arguments are directories,
+.Nm diff
+sorts the contents of the directories by name, and then runs the
+regular file
+.Nm diff
+algorithm, producing a change list,
+on text files which are different.
+Binary files which differ,
+common subdirectories, and files which appear in only one directory
+are described as such.
+.Pp
+If only one of
+.Ar file1
+and
+.Ar file2
+is a directory,
+.Nm diff
+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.
+.Pp
+If either the
+.Ar file1
+or
+.Ar file2
+is
+.Fl ,
+the standard input is
+used in its place.
+.Ss Output Style
+The default (without
+.Fl e ,
+.Fl c ,
+or
+.Fl n
+.\" -C
+options)
+output contains lines of these forms, where
+.Va XX , YY , ZZ , QQ
+are line numbers respective of file order.
+.Pp
+.Dp Cx Li XX
+.Ic a
+.Li YY
+.Cx
+At (the end of) line
+.Va XX
+of
+.Ar file1 ,
+append the contents
+of line
+.Va YY
+of
+.Ar file2
+to make them equal.
+.Dp Cx Li XX
+.Ic a
+.Li YY ,
+.Li ZZ
+.Cx
+Same as above, but append the range of lines,
+.Va YY
+through
+.Va ZZ
+of
+.Ar file2
+to line
+.Va XX
+of file1.
+.Dp Cx Li XX
+.Ic d
+.Li YY
+.Cx
+At line
+.Va XX
+delete
+the line. The value
+.Va YY
+tells to which line the change
+would bring
+.Ar file1
+in line with
+.Ar file1 .
+.Dp Cx Li XX ,
+.Li YY
+.Ic d
+.Li ZZ
+.Cx
+Delete the range of lines
+.Va XX
+through
+.Va YY
+in
+.Ar file1 .
+.Dp Cx Li XX
+.Ic c
+.Li YY
+.Cx
+Change the line
+.Va XX
+in
+.Ar file1
+to the line
+.Va YY
+in
+.Ar file2.
+.Dp Cx Li XX ,
+.Li YY
+.Ic c
+.Li ZZ
+.Cx
+Replace the range of specified lines with the line
+.Va ZZ .
+.Dp Cx Li XX ,
+.Li YY
+.Ic c
+.Li ZZ ,
+.Li QQ
+.Cx
+Replace the range
+.Cx Va XX ,
+.Va YY
+.Cx
+from
+.Ar file1
+with the range
+.Cx Va ZZ ,
+.Va QQ
+.Cx
+from
+.Ar file2 .
+.Dp
+.Pp
+These lines resemble
+.Xr ed 1
+subcommands to convert
+.Ar file1
+into
+.Ar file2 .
+The line numbers before the action letters pertain to
+.Ar file1 ;
+those after pertain to
+.Ar file2 .
+Thus, by exchanging
+.Ic a
+for
+.Ic d
+and reading the line in reverse order, one can also
+determine how to convert
+.Ar file2
+into
+.Ar file1 .
+As in
+.Xr ed 1 ,
+identical
+pairs (where num1 = num2) are abbreviated as a single
+number.
+.Sh ENVIRONMENT
+.Tw Fl
+.Tp Ev TMPDIR
+If the environment variable
+.Ev TMPDIR
+exists,
+.Nm Diff
+will use the name specified by
+.Ev TMPDIR
+as an alternate temporary directory.
+.Tp
+.Sh FILES
+.Dw /usr/bin/diffh
+.Di L
+.Dp Pa /tmp/d?????
+.br
+.Dp Pa /usr/bin/diffh
+Alternate algorithm version (used by option
+.Fl h ) .
+.Dp Pa /usr/bin/diff
+for directory diffs
+.Dp Pa /usr/bin/pr
+used by the
+.Fl l
+option.
+.Dp
+.Sh SEE ALSO
+.Xr cmp 1 ,
+.Xr cc 1 ,
+.Xr comm 1 ,
+.Xr ed 1 ,
+.Xr diff3 1
+.Sh HISTORY
+.Nm Diff
+appeared in Version 6 AT&T Unix.
+.Sh DIAGNOSTICS
+The
+.Nm diff
+utility exits with one of the following values:
+.Dw Ds
+.Dp \&0
+No differences were found.
+.Dp \&1
+Differences were found.
+.Dp \&>\&1
+An error occurred.
+.Dp
+.Sh BUGS
+The
+.Fl f
+and
+.Fl e
+options
+do not provide special handling for lines on which the
+first and only character is
+.Dq Li \&. .
+This can cause problems for
+.Xr ed 1 .
+.Pp
+When comparing directories with the
+.Fl b ,
+.Fl w
+or
+.Fl i
+options specified,
+.Nm diff
+first compares the files ala
+.Ar cmp ,
+and then decides to run the
+.Nm diff
+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 STANDARDS