home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
- #
- # Script to automatically add changebars to troff docs.
- #
- if [ $# -lt 1 ]; then
- #
- # If user does not enter parameters, show usage info.
- #
- echo
- echo " changebar --> Usage: changebar OLDFILE NEWFILE"
- echo
- echo " Produces NEWFILE.chbar that is NEWFILE with changebars,"
- echo " leaves original files intact."
- echo
- else
- # Run a context diff on the two files
- #
- diff -c $2 $1 > $1.diff
- #
- # Install change bars in the context diff,
- # for ADDITIONS and MODIFICATIONS only.
- # DELETIONS not marked -- reverse the
- # sequence of the file names and run it
- # again to get an original file with
- # deletions and modifications marked.
- #
- chbar < $1.diff > $1.patch
- #
- # Run the patch program to install the
- # now-modified context diffs.
- #
- patch -R < $1.patch
- #
- # Remove the intermediate files;
- # assumes that all of the patches worked.
- #
- rm $1.diff $1.patch
- #
- # Translate ^G to \n, installed for
- # convenience to make patch work unmodified.
- # Name the filtered version as $2.chbar.
- #
- tr '\007' '\012' < $1 > $2.chbar
- #
- # Make the patched (intermediate) file removable
- #
- chmod 666 $1
- #
- # Patch renamed original file;
- # restore the original name
- #
- mv $1.orig $1
- #
- # Now tell the user what we did.
- #
- echo
- echo "All of the hunks should have succeeded"
- echo
- echo "There is now a new file named $2.chbar that is exactly"
- echo "like your file named $2, but it has changebars installed."
- echo
- fi
-