home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / irix / scripts / rcs / col-script < prev    next >
Encoding:
Text File  |  1994-08-02  |  3.6 KB  |  127 lines

  1. #! /bin/csh -f
  2. #
  3. # $Id: col-script,v 1.6 92/10/27 10:09:46 carlson Exp $
  4. #
  5. # col-script    Performs a co -l on the file passed and performs a
  6. #        diff on it and the version in ../src/hcrsgi.
  7. #
  8. #    Added functionality includes:
  9. #    1. Always performs default options $opt.
  10. #    2. Performs options found in environment variable RCSOPTS.
  11. #    3. Passes arguments from command line to co.
  12. #    4. Compares the file with the version in ../src/hcrsgi.
  13. #    5. Added option -i skips comparison of files.
  14. #    6. Performs options found in file .rcsopts.
  15. #
  16. # Revision History:
  17. #    $Log:    col-script,v $
  18. # Revision 1.6  92/10/27  10:09:46  carlson
  19. # When breaking out the options, break out three characters instead of
  20. #   just two to allow checking of just the character following the dash.
  21. # Remove default options that conflict with command line options.
  22. # Revision 1.5  92/01/22  15:21:53  carlson
  23. # No longer set the time of the file to that in the RCS file.
  24. # Revision 1.4  91/08/27  13:25:56  carlson
  25. # Fixed problems with handling new .rcsopts file.
  26. # Revision 1.3  91/08/27  13:11:59  carlson
  27. # Allow new style .rcsopts files.
  28. # Added comments.
  29. # Revision 1.2  91/07/29  09:01:33  chris
  30. # Cleaned up to use less code.  Doesn't separate option from argument
  31. #   anymore and then put them back together.
  32. # Added RCS symbols.
  33. #-----------------------------------------------------------------------
  34. # Set default options for co command here.
  35. #
  36. set opt = ( "-l" )
  37. if ( $?RCSOPTS ) then
  38.     set opt = ( $opt $RCSOPTS )
  39. endif
  40. if ( -e ./.rcsopts ) then
  41.     set x = ( `grep "^col[     ]" ./.rcsopts` )
  42.     if ( "$x" == "" ) set x = ( `grep "^co[     ]" ./.rcsopts` )
  43.     if ( $#x > 1 ) then
  44.     set opt = ( $opt $x[2-] )
  45.     else
  46.     set x = ( `cat ./.rcsopts` )
  47.     if ( "$x[1]" != "ci" ) then
  48.         echo "*** Old style .rcsopts file ***"
  49.         set opt = ( $opt `cat ./.rcsopts` )
  50.     endif
  51.     endif
  52. endif
  53. set ignore = 0
  54.  
  55. #----
  56. # Scan for end of options in parameter list.  We need to do this to
  57. # find where the file names start.
  58. #
  59. # While scanning, do the following:
  60. #    1. Remove any duplicated options from $opt.
  61. #    2. Check for -i option and set flag to remind us to check the
  62. #       differences in hcrsgi.
  63. #
  64. @ first = 1
  65.  
  66. while ( $first <= $#argv )
  67.     set arg_chars = ( `echo $argv[$first] | sed "s/\(.\)\(.\)\(.\)/\1 \2 \3/\\
  68. s/\(.\)\(.\)/\1 \2/"` )
  69.     if ( "$arg_chars[1]" != "-" ) break
  70.     if ( "$arg_chars[2]" == "-" ) then
  71.     set argv[$first]
  72.     break
  73.     endif
  74.     @ secnd = 1
  75.     while ( $secnd <= $#opt )
  76.     set opt_chars = ( `echo $opt[$secnd] | sed "s/\(.\)\(.\)\(.\)/\1 \2 \3/\\
  77. s/\(.\)\(.\)/\1 \2/"` )
  78.     if ( "$opt_chars[1]" != "-" ) break
  79.     if ( "$opt_chars[2]" == "$arg_chars[2]" ) set opt[$secnd]
  80.     if ( "$opt_chars[2]" == "u" && "$arg_chars[2]" == "l" ) \
  81.         set opt[$secnd]
  82.     if ( "$opt_chars[2]" == 'l' && "$arg_chars[2]" == "u" ) \
  83.         set opt[$secnd]
  84.     @ secnd = $secnd + 1
  85.     end
  86.     if ( "$argv[$first]" == "-i" ) then
  87.     set argv[$first]
  88.     set ignore = 1
  89.     endif
  90.     @ first=$first + 1
  91. end
  92.  
  93. #----
  94. # Check out files with arguments passed.
  95. #
  96. /usr/sbin/co $opt $argv
  97. if ( $status != 0 ) exit $status
  98. if ( $ignore == 1 ) exit 0
  99.  
  100. #----
  101. # Compare the differences between this version and the one in
  102. # ../src/hcrsgi.
  103. #
  104. if ( $first >= $#argv ) then
  105.     foreach arg ( $argv )
  106.     echo "----------------------------------$arg"
  107.     /bin/diff $arg ../src/hcrsgi/$arg
  108.     echo "----------------------------------$arg"
  109.     end
  110. else
  111.     @ first=$first + 1
  112.     foreach arg ( $argv[$first-] )
  113.     echo "----------------------------------$arg"
  114.     /bin/diff $arg ../src/hcrsgi/$arg
  115.     echo "----------------------------------$arg"
  116.     end
  117. endif
  118.  
  119. ### Local Variables:
  120. ### auto-fill-hook: nil
  121. ### End:
  122.