Author: | Martin Blais <blais@furius.ca> |
---|---|
Version: | 1.9 |
Abstract
Useful script to conditionally replace a original by a generated file.
Useful script to conditionally replace a original by a generated file.
Basically, you invoke some script or pipeline of scripts to perform modifications on an original text file and store the results in a temporary file (the modified-file), and then invoke this script to conditionally overwrite the contents of the orig-file with those of the modified file.
This works like copy (cp), except that xxdiff is shown to ask the user whether to copy the file or not. This is useful to run in a loop, for example:
for i in `*/*.xml` ; do cat $i | ...pipeline of cmds that modifies the file... > /tmp/out.xml # copy only if the user accepts or merges. xxdiff-cond-replace $i /tmp/out.xml done
IMPORTANT: Notice well that the original file which will be overwritten is on the LEFT side. The syntax is reversed that of the UNIX cp command.
This program exits with status 0 if the copy operation was accepted or merged, with 1 otherwise.
xxdiff-cond-replace [<options>] <orig-file> <modified-file>
--version show program's version number and exit -h, --help show this help message and exit --command=COMMAND xxdiff command prefix to use. -bCHOICE, --backup-type=CHOICE selects the backup type ('parallel', 'other', 'none') --backup-dir=BACKUP_DIR specify backup directory for type 'other' -C, --checkout-clearcase checkout files with clearcase before storing. -n, --dry-run print the commands that would be executed but don't really run them. -q, --silent, --quiet Do not output anything. Normally the decision status and backup file location is output. -x, --diff Run a diff and log the differences on stdout. -d, --delete Instead of copying the temporary file, move it (delete it after copying). -X, --no-confirm do not ask for confirmation with graphical diff viewer. This essentially generates a diff log and copies the file over with backups.
Copyright (C) 2003-2004 Martin Blais <blais@furius.ca>. This code is distributed under the terms of the GNU General Public License.