home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume18 / changebar / changebar < prev    next >
Encoding:
Text File  |  1989-03-12  |  1.4 KB  |  63 lines

  1. #!/bin/sh
  2. #
  3. #  Script to automatically add changebars to troff docs.
  4. #
  5. if [ $# -lt 1 ]; then
  6. #
  7. #  If user does not enter parameters, show usage info.
  8. #
  9.     echo
  10.     echo "    changebar --> Usage:   changebar OLDFILE NEWFILE"
  11.     echo
  12.     echo "    Produces NEWFILE.chbar that is NEWFILE with changebars,"
  13.     echo "    leaves original files intact."
  14.     echo
  15. else
  16. #  Run a context diff on the two files
  17. #
  18.     diff -c $2 $1 > $1.diff
  19. #
  20. #  Install change bars in the context diff,
  21. #  for ADDITIONS and MODIFICATIONS only.
  22. #  DELETIONS not marked -- reverse the
  23. #  sequence of the file names and run it
  24. #  again to get an original file with
  25. #  deletions and modifications marked.
  26. #
  27.     chbar < $1.diff > $1.patch
  28. #
  29. #  Run the patch program to install the
  30. #  now-modified context diffs.
  31. #
  32.     patch -R < $1.patch
  33. #
  34. #  Remove the intermediate files;
  35. #  assumes that all of the patches worked.
  36. #
  37.     rm $1.diff $1.patch
  38. #
  39. #  Translate ^G to \n, installed for
  40. #  convenience to make patch work unmodified.
  41. #  Name the filtered version as $2.chbar.
  42. #
  43.     tr '\007' '\012' < $1 > $2.chbar
  44. #
  45. #  Make the patched (intermediate) file removable
  46. #
  47.     chmod 666 $1
  48. #
  49. #  Patch renamed original file;
  50. #  restore the original name
  51. #
  52.     mv $1.orig $1
  53. #
  54. #  Now tell the user what we did.
  55. #
  56.     echo 
  57.     echo "All of the hunks should have succeeded"
  58.     echo
  59.     echo "There is now a new file named $2.chbar that is exactly"
  60.     echo "like your file named $2, but it has changebars installed."
  61.     echo
  62. fi
  63.