Lines Matching refs:command
14 and documents the @sc{gnu} @command{diff}, @command{diff3},
15 @command{sdiff}, and @command{cmp} commands for showing the
16 differences between files and the @sc{gnu} @command{patch} command for
80 * Adjusting Output:: Making @command{diff} output prettier.
81 * diff Performance:: Making @command{diff} smarter or faster.
86 * Interactive Merging:: Interactive merging with @command{sdiff}.
88 * Merging with patch:: Using @command{patch} to change old files into new ones.
106 @cindex overview of @command{diff} and @command{patch}
112 You can use the @command{diff} command to show differences between two
113 files, or each corresponding file in two directories. @command{diff}
115 formats, selectable by command line options. This set of differences is
117 @command{diff} normally produces no output; for binary (non-text) files,
118 @command{diff} normally reports only that they are different.
120 You can use the @command{cmp} command to show the byte and line numbers
121 where two files differ. @command{cmp} can also show all the bytes
123 two files character by character is the Emacs command @kbd{M-x
125 Emacs Manual}, for more information on that command.
127 You can use the @command{diff3} command to show differences among three
129 original, @command{diff3} can report the differences between the original
133 You can use the @command{sdiff} command to merge two files interactively.
135 You can use the set of differences produced by @command{diff} to distribute
138 to the complete files. Given @command{diff} output, you can use the
139 @command{patch} program to update, or @dfn{patch}, a copy of the file. If you
140 think of @command{diff} as subtracting one file from another to produce
141 their difference, you can think of @command{patch} as adding the difference
147 @sc{gnu} @command{diff} was written by Paul Eggert, Mike Haertel,
168 @sc{gnu} @command{diff3} was written by Randy Smith. @sc{gnu}
169 @command{sdiff} was written by Thomas Lord. @sc{gnu} @command{cmp}
172 @command{patch} was written mainly by Larry Wall and Paul Eggert;
184 file. @command{diff} compares two files line by line, finds groups of
189 @sc{gnu} @command{diff} can show whether files are different without detailing
193 lines. @command{diff} also provides ways to suppress differences in
200 different. @command{cmp} reports the differences between two files
202 more useful than @command{diff} for comparing binary files. For text
203 files, @command{cmp} is useful mainly when you want to know only whether
210 that lacks the newline at the beginning, @command{diff} will report that a
211 blank line has been added to the file, while @command{cmp} will report that
214 @command{diff3} normally compares three input files line by line, finds
233 When comparing two files, @command{diff} finds sequences of lines common to
239 match up lines between two given files. @command{diff} tries to minimize
246 @command{diff} finds the line @samp{c} as common, then the command
259 But if @command{diff} notices the common line @samp{b} instead, it produces
274 It is also possible to find @samp{a} as the common line. @command{diff}
287 equivalent to the number of spaces to the next tab stop. @command{diff}
293 options, @command{diff} considers the following two lines to be equivalent,
306 With these options, @command{diff} considers the
344 @sc{gnu} @command{diff} can treat lower case letters as equivalent to their
354 @command{grep}-style regular expression, use the @option{-I
364 words, for each nonignorable change, @command{diff} prints the complete set
368 using more than one @option{-I} option. @command{diff} tries to match each
379 files, @command{diff} simply reports whether files differ. The @option{-q}
384 comparisons, because @command{diff} can stop analyzing the files as soon as
388 @command{cmp}. For files that are identical, @command{cmp} produces no
389 output. When the files differ, by default, @command{cmp} outputs the byte
391 the @option{-s} option to suppress that information, so that @command{cmp}
396 Unlike @command{diff}, @command{cmp} cannot compare directories; it can only
404 If @command{diff} thinks that either of the two files it is comparing is
410 @command{diff} determines whether a file is text or binary by checking the
413 that part of the file is non-null, @command{diff} considers the file to be
416 Sometimes you might want to force @command{diff} to consider files to be
418 null characters; @command{diff} would erroneously decide that those are
421 indicate special formatting. You can force @command{diff} to consider all
425 newline characters, and the @command{diff} output will consist of hunks
429 You can also force @command{diff} to consider all files to be binary files,
434 resulting @command{diff} output does not capture all the differences.
435 This trouble causes @command{diff} to exit with status 2. However,
438 options both cause @command{diff} to treat binary files like text
442 @command{diff} normally reads and writes all data as text. Use the
443 @option{--binary} option to force @command{diff} to read and write binary
447 followed by a newline. On such systems, @command{diff} normally ignores
449 output line, but with the @option{--binary} option @command{diff} treats
455 The @option{--strip-trailing-cr} causes @command{diff} to treat input
463 @command{cmp} program with the @option{-l} option to show the values
464 of each differing byte in the two files. With @sc{gnu} @command{cmp},
469 If @command{diff3} thinks that any of the files it is comparing is binary
471 comparisons are usually not useful. @command{diff3} uses the same test as
472 @command{diff} to decide whether a file is binary. As with @command{diff}, if
474 text files, you can force @command{diff3} to consider all files to be text
479 @chapter @command{diff} Output Formats
481 @cindex format of @command{diff} output
483 @command{diff} has several mutually exclusive options for output format.
485 @command{diff} reports the differences between two sample input files.
488 * Sample diff Input:: Sample @command{diff} input files for examples.
498 @cindex @command{diff} sample input
499 @cindex sample input for @command{diff}
502 illustrate the output of @command{diff} and how various options can change
549 The ``normal'' @command{diff} output format shows each hunk of differences
557 compatibility with older versions of @command{diff} and the @sc{posix}
574 @var{change-command}
614 Here is the output of the command @samp{diff lao tzu}
644 @sc{gnu} @command{diff} provides two output formats that show context
650 form of @command{diff} output, you should use one of the output formats
652 made small changes of their own to the files. @command{patch} can apply
655 lines away from where the diff says they are, @command{patch} can adjust
657 @xref{Imperfect}, for more information on using @command{patch} to apply
678 defaults to three. For proper operation, @command{patch} typically needs
829 At present, only @sc{gnu} @command{diff} can produce this format and
830 only @sc{gnu} @command{patch} can automatically apply diffs in this
831 format. For proper operation, @command{patch} typically needs at
882 Here is the output of the command @samp{diff -u lao tzu}
915 appendix was changed. @sc{gnu} @command{diff} can show this by displaying the
931 or @option{--show-function-line=@var{regexp}} option. @command{diff}
932 considers lines that match the @command{grep}-style regular expression
959 regular expression for such lines; @command{diff} tries to match each line
973 command line. You can override both the format and the number with
974 @option{-U @var{lines}} elsewhere in the command line.
979 @command{diff} provides them for the sake of convenience.
987 names, you might want @command{diff} to show alternate names in the header
993 twice, @command{diff} reports an error. The @option{--label} option does not
994 affect the file names in the @command{pr} header when the @option{-l} or
1011 @command{diff} can produce a side by side difference listing of two files.
1057 You can use the @command{sdiff} command to interactively merge side by side
1086 Here is the output of the command @samp{diff -y -W 72 lao tzu}
1111 Several output modes produce command scripts for editing @var{from-file}
1115 * ed Scripts:: Using @command{diff} to produce commands for @command{ed}.
1116 * Forward ed:: Making forward @command{ed} scripts.
1117 * RCS:: A special @command{diff} output format used by @sc{rcs}.
1121 @subsection @command{ed} Scripts
1122 @cindex @command{ed} script output format
1124 @command{diff} can produce commands that direct the @command{ed} text editor
1127 automatically; today, with @command{patch}, it is almost obsolete. Use the
1136 the command @samp{(cat d && echo w) | ed - old} edits @file{old} to make
1140 respectively, then the command @samp{(cat d1 d2 @dots{} dN && echo w) |
1144 * Detailed ed:: A detailed description of @command{ed} format.
1145 * Example ed:: A sample @command{ed} script.
1149 @subsubsection Detailed Description of @command{ed} Format
1151 The @command{ed} output format consists of one or more hunks of
1154 @command{ed} interprets line numbers in succeeding commands. @command{ed}
1158 @var{change-command}
1164 Because @command{ed} uses a single period on a line to indicate the end of
1165 input, @sc{gnu} @command{diff} protects lines of changes that contain a single
1167 subsequent @command{ed} command to change the two periods into one. The
1168 @command{ed} format cannot represent an incomplete line, so if the second
1169 file ends in a changed incomplete line, @command{diff} reports an error and
1196 @subsubsection Example @command{ed} Script
1215 @subsection Forward @command{ed} Scripts
1216 @cindex forward @command{ed} script output format
1218 @command{diff} can produce output that is like an @command{ed} script, but
1220 is also changed slightly: command characters precede the lines they
1223 @command{ed} format, forward @command{ed} format cannot represent incomplete
1226 Forward @command{ed} format is not very useful, because neither @command{ed}
1227 nor @command{patch} can apply diffs in this format. It exists mainly for
1228 compatibility with older versions of @command{diff}. Use the @option{-f} or
1239 forward @command{ed} format (@pxref{Forward ed}), but it can represent
1241 forward @command{ed} format's problems with lines consisting of a single
1243 a line consisting of a single period, each command specifies the number
1269 @cindex @command{ifdef} output format
1271 You can use @command{diff} to merge two files of C source code. The output
1272 of @command{diff} in this format contains all the lines of both files.
1279 To merge two files, use @command{diff} with the @option{-D @var{name}} or
1320 For example, the following command compares the TeX files @file{old}
1336 The following command is equivalent to the above example, but it is a
1372 To specify a line group format, use @command{diff} with one of the options
1492 For example, the following command outputs text with a one-character
1572 different formats. For example, the following command uses a format
1573 similar to normal @command{diff} format. You can tailor this command
1574 to get fine control over @command{diff} output.
1596 For lines common to both files, @command{diff} uses the unchanged line
1599 @command{diff} uses the old line group format; if the hunk contains only
1600 lines from the second file, @command{diff} uses the new group format;
1601 otherwise, @command{diff} uses the changed group format.
1624 You should carefully check the @command{diff} output for proper nesting.
1635 The @command{patch} @option{-D @var{name}} option behaves like
1636 the @command{diff} @option{-D @var{name}} option, except it operates on
1675 @cindex newline treatment by @command{diff}
1691 @command{ed} and forward @command{ed} output formats (@pxref{Output Formats})
1692 @command{diff} cannot represent an incomplete line, so it pretends there
1731 You can use @command{diff} to compare some or all of the files in two
1732 directory trees. When both file name arguments to @command{diff} are
1736 @command{diff} is silent about pairs of files that contain no differences,
1738 it reports pairs of identical files. Normally @command{diff} reports
1744 For file names that are in only one of the directories, @command{diff}
1747 can make @command{diff} act as though the file existed but was empty in the
1788 one directory and upper case in the upper, @command{diff} normally
1791 @command{diff} ignores case differences in file names, so that for example
1805 @chapter Making @command{diff} Output Prettier
1807 @command{diff} provides several ways to adjust the appearance of its output.
1812 * Pagination:: Page numbering and time-stamping @command{diff} output.
1820 The lines of text in some of the @command{diff} output formats are preceded
1824 line. @sc{gnu} @command{diff} provides two ways to make tab-aligned columns
1827 The first way is to have @command{diff} convert all tabs into the correct
1829 @option{-t} or @option{--expand-tabs} option. @command{diff} assumes that
1831 @command{patch}, you must give @command{patch} the @option{-l} or
1847 @section Paginating @command{diff} Output
1848 @cindex paginating @command{diff} output
1852 @command{diff} output through the @command{pr} program. Here is what the page
1860 @chapter @command{diff} Performance Tradeoffs
1861 @cindex performance of @command{diff}
1863 @sc{gnu} @command{diff} runs quite efficiently; however, in some circumstances
1866 One way to improve @command{diff} performance is to use hard or
1868 because @command{diff} normally does not need to read two hard or
1878 You can also affect the performance of @sc{gnu} @command{diff} by
1884 The way that @sc{gnu} @command{diff} determines which lines have changed always
1886 enough for practical purposes. If the @command{diff} output is large, you
1887 might want @command{diff} to use a modified algorithm that sometimes
1890 @command{diff} to run more slowly than usual, so it is not the default
1896 the algorithm that @command{diff} uses. If the input files have a constant
1898 changing the output. If not, @command{diff} might produce a larger set of
1901 Normally @command{diff} discards the prefix and suffix that is common to
1903 This makes @command{diff} run faster, but occasionally it may produce
1905 prevents @command{diff} from discarding the last @var{lines} lines of the
1907 @command{diff} further opportunities to find a minimal output.
1911 The @command{diff} command is free to choose which identical sequence is
1912 included in the hunk. In this case, @command{diff} normally shifts the
1920 @cindex format of @command{diff3} output
1922 Use the program @command{diff3} to compare three files and show any
1923 differences among them. (@command{diff3} can also merge files; see
1926 The ``normal'' @command{diff3} output format shows each hunk of
1931 @xref{Invoking diff3}, for more information on how to run @command{diff3}.
1934 * Sample diff3 Input:: Sample @command{diff3} input for examples.
1942 @cindex @command{diff3} sample input
1943 @cindex sample input for @command{diff3}
1946 the output of @command{diff3} and how various options can change it. The
1947 first two files are the same that we used for @command{diff} (@pxref{Sample
1968 @section Detailed Description of @command{diff3} Normal Format
1979 option, @command{diff3} uses a tab instead of two spaces; this lines up
2006 @section @command{diff3} Hunks
2007 @cindex hunks for @command{diff3}
2008 @cindex @command{diff3} hunks
2011 called @dfn{diff3 hunks}, by analogy with @command{diff} hunks
2012 (@pxref{Hunks}). If all three input files differ in a @command{diff3}
2016 As with @command{diff}, several solutions are possible. When comparing the
2017 files @samp{A}, @samp{B}, and @samp{C}, @command{diff3} normally finds
2018 @command{diff3} hunks by merging the two-way hunks output by the two
2050 @section An Example of @command{diff3} Normal Format
2052 Here is the output of the command @samp{diff3 lao tzu tao}
2093 @command{diff3} can produce a merged output that contains both sets of
2096 One might imagine programs with names like @command{diff4} and @command{diff5}
2098 need rarely arises. You can use @command{diff3} to merge three or more
2101 @command{diff3} can incorporate changes from two modified versions into a
2126 @command{diff3} gives you several ways to handle overlaps and conflicts.
2130 @command{diff3} can output the merge results as an @command{ed} script that
2132 However, it is usually better to have @command{diff3} generate the merged
2133 output directly; this bypasses some problems with @command{ed}.
2139 * Merging Incomplete Lines:: How @command{diff3} merges incomplete lines.
2162 Here is the output of the command @command{diff3} with each of these three
2198 @command{diff3} can mark conflicts in the merged output by
2281 @cindex merged @command{diff3} format
2283 With the @option{-m} or @option{--merge} option, @command{diff3} outputs the
2284 merged file directly. This is more efficient than using @command{ed} to
2285 generate it, and works even with non-text files that @command{ed} would
2286 reject. If you specify @option{-m} without an @command{ed} script option,
2289 For example, the command @samp{diff3 -m lao tzu tao}
2320 @section How @command{diff3} Merges Incomplete Lines
2330 Without @option{-m}, if an @command{ed} script option is specified and an
2331 incomplete line is found, @command{diff3} generates a warning and acts as
2336 @cindex System V @command{diff3} compatibility
2338 Traditional Unix @command{diff3} generates an @command{ed} script without the
2340 System V @command{diff3} generates these extra commands. @sc{gnu}
2341 @command{diff3} normally behaves like traditional Unix
2342 @command{diff3}, but with the @option{-i} option it behaves like
2343 System V @command{diff3} and appends the @samp{w} and @samp{q}
2346 The @option{-i} option requires one of the @command{ed} script options
2351 @chapter Interactive Merging with @command{sdiff}
2355 With @command{sdiff}, you can merge two files interactively based on a
2359 options to @command{sdiff}.
2362 package @command{emerge}. @xref{emerge, , emerge, emacs, The @sc{gnu} Emacs
2366 * sdiff Option Summary:: Summary of @command{sdiff} options.
2371 @section Specifying @command{diff} Options to @command{sdiff}
2372 @cindex @command{sdiff} output format
2374 The following @command{sdiff} options have the same meaning as for
2375 @command{diff}. @xref{diff Options}, for the use of these options.
2389 For historical reasons, @command{sdiff} has alternate names for some
2392 to @option{--suppress-common-lines}. The meaning of the @command{sdiff}
2394 @command{diff}: with @command{sdiff}, @option{-w @var{columns}} is
2396 equivalent to @option{--ignore-all-space}. @command{sdiff} without the
2397 @option{-o} option is equivalent to @command{diff} with the @option{-y}
2406 file to the output. After each group of differing lines, @command{sdiff}
2408 commands. Follow each command with @key{RET}.
2451 @chapter Merging with @command{patch}
2453 @command{patch} takes comparison output produced by @command{diff} and applies
2455 version. With @command{patch}, you can distribute just the changes to a
2457 correspondents can apply @command{patch} to update their copy of the files
2458 with your changes. @command{patch} automatically determines the diff
2462 @command{patch}.
2464 @command{patch} detects and warns about common problems like forward
2469 @command{patch} accepts a series of diffs in its standard input, usually
2471 @command{diff} hunks (@pxref{Hunks}) one by one. If a hunk does not
2472 exactly match the original file, @command{patch} uses heuristics to try to
2474 @command{patch} rejects the hunk and skips to the next hunk. @command{patch}
2479 @command{patch}.
2482 * patch Input:: Selecting the type of @command{patch} input.
2492 * patch Messages:: Messages and questions @command{patch} can produce.
2494 * patch and Tradition:: @sc{gnu} versus traditional @command{patch}.
2498 @section Selecting the @command{patch} Input Format
2499 @cindex @command{patch} input format
2501 @command{patch} normally determines which @command{diff} format the patch
2504 following options to force @command{patch} to interpret the patch file as a
2506 ones that @command{patch} can understand.
2515 @command{ed} script.
2535 supported by @command{patch}, @command{patch} normally asks the user
2538 Under @sc{rcs} and @sc{sccs}, @command{patch} also asks when the input
2545 positive, @command{patch} gets the file without asking the user; if
2546 zero, @command{patch} neither asks the user nor gets the file; and if
2547 negative, @command{patch} asks the user before getting the file. The
2550 value is zero if @command{patch} is conforming to @sc{posix}, negative
2561 @command{patch} tries to skip any leading text in the patch file,
2563 mail message directly to @command{patch}, and it should work. If the
2565 @command{patch} automatically ignores the indentation. If a context
2566 diff contains trailing carriage return on each line, @command{patch}
2570 @command{patch} automatically unencapsulates the input.
2578 * Inexact:: Helping @command{patch} find close matches.
2579 * Dry Runs:: Predicting what @command{patch} will do.
2588 files might look the same, but @command{patch} will not be able to match
2590 @option{--ignore-white-space} option, which makes @command{patch} compare
2601 Sometimes people run @command{diff} with the new file first instead of
2603 patches, give @command{patch} the @option{-R} or @option{--reverse} option.
2604 @command{patch} then attempts to swap each hunk around before applying it.
2607 Often @command{patch} can guess that the patch is reversed. If the first
2608 hunk of a patch fails, @command{patch} reverses the hunk to see if it can
2609 apply it that way. If it can, @command{patch} asks you if you want to have
2610 the @option{-R} option set; if it can't, @command{patch} continues to apply
2612 a normal diff and the first command is an append (which should have been
2616 @command{patch} notices.
2618 If you apply a patch that you have already applied, @command{patch} thinks
2623 @command{patch} process.
2626 @subsection Helping @command{patch} Find Inexact Matches
2630 For context diffs, and to a lesser extent normal diffs, @command{patch} can
2635 the correct place, @command{patch} scans both forward and backward for a
2638 First @command{patch} looks for a place where all lines of the context
2641 @command{patch} makes another scan, ignoring the first and last line of
2655 If @command{patch} cannot find a place to install a hunk of the patch, it
2659 normal or @command{ed} diff, many of the contexts are simply null. The
2661 in the patch file: they show the approximate location where @command{patch}
2666 as it completes each hunk @command{patch} tells you whether the hunk
2668 @command{patch} thinks the hunk should go. If this is different from the
2670 large offset @emph{may} indicate that @command{patch} installed a hunk in
2671 the wrong place. @command{patch} also tells you if it used a fuzz factor
2674 @command{patch} cannot tell if the line numbers are off in an @command{ed}
2676 finds a change or delete command. It may have the same problem with a
2686 @command{patch} usually produces the correct results, even when it must
2692 @subsection Predicting what @command{patch} will do
2693 @cindex testing @command{patch}
2694 @cindex dry runs for @command{patch}
2696 It may not be obvious in advance what @command{patch} will do with a
2698 input might cause @command{patch} to modify the wrong files, you can
2699 use the @option{--dry-run} option, which causes @command{patch} to
2702 to see whether @command{patch} will modify the files that you expect.
2704 the other options to @command{patch}) and try another dry run. Once
2706 @command{patch} as before, but this time without the
2716 directory but not the other. If you give @command{diff} the
2719 Epoch (1970-01-01 00:00:00 UTC), @command{diff} outputs a patch that
2721 @command{patch} normally creates a new file or removes the old file.
2723 @command{patch} does not remove the old file, but leaves it empty.
2725 @command{patch} to remove output files that are empty after applying a
2730 @command{patch} asks for confirmation before applying the patch.
2736 When @command{patch} updates a file, it normally sets the file's
2738 @command{patch} to track a software distribution, this can cause
2739 @command{make} to incorrectly conclude that a patched file is out of
2741 @command{patch} updates @file{syntax.c} and then @file{syntax.y}, then
2745 The @option{-Z} or @option{--set-utc} option causes @command{patch} to
2760 @command{patch} normally refrains from setting a file's time stamps if
2766 Due to the limitations of the current @command{diff} format,
2767 @command{patch} cannot update the times of files whose contents have
2771 invocations of @command{make} do not get confused by the patched
2780 specify an input file on the command line, @command{patch} tries to
2787 @command{patch} uses the following rules to intuit a file name from
2788 the leading text before a patch. First, @command{patch} takes an
2793 If the header is that of a context diff, @command{patch} takes the old
2801 the old and new names are both absent or if @command{patch} is
2802 conforming to @sc{posix}, @command{patch} takes the name in the
2812 Then @command{patch} selects a file name from the candidate list as
2817 If some of the named files exist, @command{patch} selects the first
2821 If @command{patch} is not ignoring @sc{rcs}, ClearCase, and @sc{sccs}
2823 ClearCase, or @sc{sccs} master is found, @command{patch} selects the
2828 was found, some names are given, @command{patch} is not conforming to
2829 @sc{posix}, and the patch appears to create a file, @command{patch}
2835 the name of the file to patch, and @command{patch} selects that name.
2839 @command{patch} first takes all the names with the fewest path name
2844 @xref{patch and POSIX}, to see whether @command{patch} is conforming
2853 option to @command{patch} makes directory @var{directory} the current
2869 count tells @command{patch} how many slashes, along with the directory
2872 default, @command{patch} strips off all leading directories, leaving
2881 @command{patch} looks for each file (after any slashes have been stripped)
2889 Normally, @command{patch} creates a backup file if the patch does not
2893 to @sc{posix}, @command{patch} does not create backup files by
2896 The @option{-b} or @option{--backup} option causes @command{patch} to
2899 @command{patch} to create backup files for mismatches files; this is
2901 @option{--no-backup-if-mismatch} option causes @command{patch} to not
2913 Normally, @command{patch} renames an original input file into a backup
2916 long.@footnote{A coding error in @sc{gnu} @command{patch} version
2919 @option{--suffix=@var{backup-suffix}} option causes @command{patch} to
2927 @command{patch} can also create numbered backup files the way @sc{gnu} Emacs
2929 @command{patch} makes a new backup file name each time it patches a file.
2938 control the type of backups that @command{patch} makes with the
2968 You can also tell @command{patch} to prepend a prefix, such as a
2991 @command{patch} could not find a place to apply) are normally the name
2995 Alternatively, you can tell @command{patch} to place all of the rejected
3001 @section Messages and Questions from @command{patch}
3002 @cindex @command{patch} messages and questions
3003 @cindex diagnostics from @command{patch}
3004 @cindex messages from @command{patch}
3006 @command{patch} can produce a variety of messages, especially if it
3008 sure how to proceed, @command{patch} normally prompts you for more
3014 * More or Fewer Messages:: Controlling the verbosity of @command{patch}.
3019 @command{patch} exits with status 0 if all hunks are applied successfully,
3026 @subsection Controlling the Verbosity of @command{patch}
3027 @cindex verbose messages from @command{patch}
3028 @cindex inhibit messages from @command{patch}
3030 You can cause @command{patch} to produce more messages by using the
3032 the message @samp{Hmm...} indicates that @command{patch} is reading text in
3036 You can inhibit all terminal output from @command{patch}, unless an error
3042 @cindex keyboard input to @command{patch}
3044 There are two ways you can prevent @command{patch} from asking you any
3046 what you are doing. It causes @command{patch} to do the following:
3078 @subsection @command{patch} Quoting Style
3081 When @command{patch} outputs a file name in a diagnostic message, it
3115 but this default may change in a future version of @command{patch}.
3118 @section @command{patch} and the @sc{posix} Standard
3123 @env{POSIXLY_CORRECT} environment variable, @command{patch} conforms
3140 Require that all options precede the files in the command line.
3148 @section @sc{gnu} @command{patch} and Traditional @command{patch}
3149 @cindex traditional @command{patch}
3151 The current version of @sc{gnu} @command{patch} normally follows the
3155 Unfortunately, @sc{posix} redefined the behavior of @command{patch} in
3157 differences if you must interoperate with traditional @command{patch},
3158 or with @sc{gnu} @command{patch} version 2.1 and earlier.
3162 In traditional @command{patch}, the @option{-p} option's operand was
3168 Also, traditional @command{patch} simply counted slashes when
3169 stripping path prefixes; @command{patch} now counts pathname
3175 In traditional @command{patch}, backups were enabled by default. This
3179 Conversely, in @sc{posix} @command{patch}, backups are never made,
3180 even when there is a mismatch. In @sc{gnu} @command{patch}, this
3184 The @option{-b@ @var{suffix}} option of traditional @command{patch} is
3186 @command{patch}.
3189 Traditional @command{patch} used a complicated (and incompletely
3192 a few gotchas. Now @command{patch} uses a different, equally
3201 When traditional @command{patch} asked the user a question, it sent
3205 @command{patch} sends questions to standard output and gets answers
3207 that @command{patch} never goes into an infinite loop when using
3211 Traditional @command{patch} exited with a status value that counted
3213 Now @command{patch} exits with status 1 if some hunks failed, or with
3218 meant to be executed by anyone running @sc{gnu} @command{patch},
3219 traditional @command{patch}, or a @command{patch} that conforms to
3253 * Avoiding Common Mistakes:: Avoiding common mistakes when using @command{patch}.
3264 @command{tar} archives of the two versions.
3266 To generate the patch, use the command @samp{diff -Naur @var{old}
3272 the patch update subdirectories. Here is an example command, using
3280 which working directory to use, and which @command{patch} options to
3296 @sc{gnu} @command{diff} can analyze files with arbitrarily long lines
3298 @command{patch} cannot patch such files. If you are having trouble
3300 @command{patch}.
3307 When producing a patch for multiple files, apply @command{diff} to
3322 different versions of @command{patch} interpret the file names
3339 @command{patch} into patching a backup file instead of the real file.
3347 the input file contains the wrong version number, @command{patch} will
3352 line that starts with @samp{Prereq:}, @command{patch} takes the next word
3355 white space or a newline. If not, @command{patch} prompts you for
3368 between the two versions, make a list of @command{rm} and @command{mv}
3375 @file{TAGS} and output from @command{yacc} and @command{makeinfo}),
3376 exclude them from the patch by giving @command{diff} the @option{-x
3381 stamps will not confuse @command{make}.
3386 Add to the top of the patch a note telling the user any @command{rm} and
3387 @command{mv} commands to run before applying the patch. Then you can
3391 but bear in mind that @command{patch} typically needs at least two
3396 @chapter Invoking @command{cmp}
3397 @cindex invoking @command{cmp}
3398 @cindex @command{cmp} invocation
3400 The @command{cmp} command compares two files, and if they differ,
3402 lines are numbered starting with 1. The arguments of @command{cmp}
3409 The file name @file{-} is always the standard input. @command{cmp}
3419 * cmp Options:: Summary of options to @command{cmp}.
3423 @section Options to @command{cmp}
3424 @cindex @command{cmp} options
3425 @cindex options for @command{cmp}
3427 Below is a summary of all of the options that @sc{gnu} @command{cmp} accepts.
3431 argument) can be combined into a single command line word: @option{-bl} is
3554 @chapter Invoking @command{diff}
3555 @cindex invoking @command{diff}
3556 @cindex @command{diff} invocation
3558 The format for running the @command{diff} command is:
3565 @var{to-file} are given, and @command{diff} compares the contents of
3570 If one file is a directory and the other is not, @command{diff} compares
3575 @command{diff} compares corresponding files in both directories, in
3577 @option{-r} or @option{--recursive} option is given. @command{diff} never
3588 @command{diff} options begin with @samp{-}, so normally file names
3597 * diff Options:: Summary of options to @command{diff}.
3601 @section Options to @command{diff}
3602 @cindex @command{diff} options
3603 @cindex options for @command{diff}
3605 Below is a summary of all of the options that @sc{gnu} @command{diff} accepts.
3609 argument) can be combined into a single command line word: @option{-ac} is
3640 For proper operation, @command{patch} typically needs at least two lines of
3643 On older systems, @command{diff} supports an obsolete option
3656 @command{diff} slower (sometimes much slower). @xref{diff Performance}.
3665 Make output that is a valid @command{ed} script. @xref{ed Scripts}.
3674 Make output that looks vaguely like an @command{ed} script but has changes
3710 Pass the output through @command{pr} to paginate it. @xref{Pagination}.
3727 Output @sc{rcs}-format diffs; like @option{-f} except that each command
3822 For proper operation, @command{patch} typically needs at least two lines of
3825 On older systems, @command{diff} supports an obsolete option
3859 @chapter Invoking @command{diff3}
3860 @cindex invoking @command{diff3}
3861 @cindex @command{diff3} invocation
3863 The @command{diff3} command compares three files and outputs descriptions
3872 which tells @command{diff3} to read the standard input for that file.
3874 An exit status of 0 means @command{diff3} was successful, 1 means some
3878 * diff3 Options:: Summary of options to @command{diff3}.
3882 @section Options to @command{diff3}
3883 @cindex @command{diff3} options
3884 @cindex options for @command{diff3}
3886 Below is a summary of all of the options that @sc{gnu} @command{diff3}
3888 can be combined into a single command line argument.
3904 instead of @command{diff}.
3908 Generate an @command{ed} script that incorporates all the changes from
3930 Generate @samp{w} and @samp{q} commands at the end of the @command{ed}
3948 output. Unlike piping the output from @command{diff3} to @command{ed}, this
3978 @chapter Invoking @command{patch}
3979 @cindex invoking @command{patch}
3980 @cindex @command{patch} invocation
3982 Normally @command{patch} is invoked like this:
3988 The full format for invoking @command{patch} is:
3997 @file{-}, @command{patch} reads the patch (that is, the @command{diff} output)
4000 If you do not specify an input file on the command line, @command{patch}
4002 that comes before the @command{diff} output) which file to edit.
4005 By default, @command{patch} replaces the original input file with the
4008 @command{patch} names backup files). You can also specify where to
4014 * patch Options:: Summary table of options to @command{patch}.
4018 @section Options to @command{patch}
4019 @cindex @command{patch} options
4020 @cindex options for @command{patch}
4022 Here is a summary of all of the options that @sc{gnu} @command{patch}
4024 safe to use in older versions of @command{patch}.
4027 combined into a single command line argument with only one dash.
4071 Interpret the patch file as an @command{ed} script. @xref{patch Input}.
4112 Ignore patches that @command{patch} thinks are reversed or already applied.
4177 Set internal debugging flags. Of interest only to @command{patch}
4198 @chapter Invoking @command{sdiff}
4199 @cindex invoking @command{sdiff}
4200 @cindex @command{sdiff} invocation
4202 The @command{sdiff} command merges two files and interactively outputs the
4210 If @var{from-file} is a directory and @var{to-file} is not, @command{sdiff}
4215 @command{sdiff} options begin with @samp{-}, so normally @var{from-file}
4220 @command{sdiff} without @option{-o} (or @option{--output}) produces a
4222 or @option{--side-by-side} option of @command{diff} instead.
4228 * sdiff Options:: Summary of options to @command{diff}.
4232 @section Options to @command{sdiff}
4233 @cindex @command{sdiff} options
4234 @cindex options for @command{sdiff}
4236 Below is a summary of all of the options that @sc{gnu} @command{sdiff} accepts.
4240 an argument) can be combined into a single command line argument. Long
4261 makes @command{sdiff} slower (sometimes much slower). @xref{diff
4266 instead of @command{diff}.
4320 option is @option{-W} in @command{diff}, @option{-w} in @command{sdiff}.
4325 Note that for historical reasons, this option is @option{-w} in @command{diff},
4326 @option{-W} in @command{sdiff}.
4345 before operands, unless otherwise specified for a particular command.
4349 command @samp{diff -c -10} to have the same meaning as @samp{diff -C
4369 Here are some ideas for improving @sc{gnu} @command{diff} and
4370 @command{patch}. The @sc{gnu} project has identified some
4385 @section Suggested Projects for Improving @sc{gnu} @command{diff} and @command{patch}
4388 One should be able to use @sc{gnu} @command{diff} to generate a patch from any
4390 tree, use @command{patch} to generate a faithful copy of the other.
4392 current patch formats; also, @command{patch} does not handle some of the
4411 @command{diff}, @command{diff3} and @command{sdiff} treat each line of
4414 @command{diff} does not properly ignore a multibyte space character.
4416 Also, @command{diff} currently assumes that each byte is one column
4419 @option{--side-by-side} option of @command{diff}.
4425 proposed some patches to support internationalized @command{diff}
4428 version of @command{diff}, so more work needs to be done in this area.
4434 @command{diff} and @command{patch} do not handle some changes to directory
4438 information for @command{patch} to transform the directory subtree into
4443 also be a way to tell @command{patch} that a file was renamed, even if
4444 there is no way for @command{diff} to generate such information.
4445 There should be a way to tell @command{patch} that a file's time stamp
4448 These problems can be fixed by extending the @command{diff} output format
4449 to represent changes in directory structure, and extending @command{patch}
4458 sockets. Currently, @command{diff} treats symbolic links like regular files;
4461 directories. This means that @command{patch} cannot represent changes
4463 points to, @command{diff} outputs the difference between the two files,
4468 @command{diff} should optionally report changes to special files specially,
4469 and @command{patch} should be extended to understand these extensions.
4476 white space, @samp{diff -r} generates a patch that @command{patch} cannot
4477 parse. The problem is with format of @command{diff} output, not just with
4478 @command{patch}, because with odd enough file names one can cause
4479 @command{diff} to generate a patch that is syntactically correct but
4480 patches the wrong files. The format of @command{diff} output should be
4486 Applying @command{patch} to a multiple-file diff can result in files
4487 whose time stamps are out of order. @sc{gnu} @command{patch} has
4492 implement a @command{diff} option to output diffs in time stamp order.
4521 told @command{diff} to assume that two files with the same size and
4529 If you think you have found a bug in @sc{gnu} @command{cmp},
4530 @command{diff}, @command{diff3}, or @command{sdiff}, please report it
4534 bug reports for @sc{gnu} @command{patch} to