1/*
2 *	aegis - project change supervisor
3 *	This file is in the Public Domain, 2006, Peter Miller.
4 *
5 * The ${quote ...} construct is used to quote filenames which contain
6 * shell special characters.  A minimum of quoting is performed, so if
7 * the filenames do not contain shell special characters, no quotes will
8 * be used.
9 */
10
11
12/*
13 * Compare two files using GNU diff.  The -U -1 option produces an output
14 * with inserts and deletes shown line, with the whole file as context.
15 * This is usually superior to -c, as it shows what happened
16 * more clearly (and it takes less space).  The -b option could be added
17 * to compare runs of white space as equal.
18 *
19 * The variant of the diff_command deals with binary files.  If the diff
20 * return code is greater then 1, then make sure that diff spit out the
21 * 'Binary files differ message' and return 0, otherwise return 1
22 *
23 * This command is used by aed(1) to produce a difference listing when
24 * file in the development directory was originally copied from the
25 * current version in the baseline.
26 *
27 * All of the command substitutions described in aesub(5) are available.
28 * In addition, the following substitutions are also available:
29 *
30 * ${ORiginal}
31 *	The absolute path name of a file containing the version
32 *	originally copied.  Usually in the baseline.
33 * ${Input}
34 *	The absolute path name of the edited version of the file.
35 *	Usually in the development directory.
36 * ${Output}
37 *	The absolute path name of the file in which to write the
38 *	difference listing.  Usually in the development directory.
39 *
40 * An exit status of 0 means successful, even of the files differ (and
41 * they usually do).  An exit status which is non-zero means something
42 * is wrong.  (So we need to massage the exit status, because diff does
43 * things a little differently.)
44 */
45diff_command =
46       "set +e; "
47       "diff -U -1 -a ${quote $original} ${quote $input} > ${quote $output}; "
48       "if test $? -gt 1; then "
49       "grep -q '^Binary' ${quote $output}; "
50       "test $? -eq 0; "
51       "else true; fi";
52