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 / ci-script next >
Encoding:
Text File  |  1994-08-02  |  3.0 KB  |  97 lines

  1. #! /bin/csh -f
  2. #
  3. # $Id: ci-script,v 1.2 1992/10/27 10:10:30 carlson Exp carlson $
  4. #
  5. # ci-script    Performs a ci on the file passed.
  6. #
  7. #    Added functionality includes:
  8. #    1. Always performs default options $opt (defined in this script).
  9. #    2. Performs options found in environment variable RCSOPTS.
  10. #    3. Passes arguments from command line to ci.
  11. #    4. Performs options found in file .rcsopts.
  12. #
  13. # Revision History:
  14. #    $Log: ci-script,v $
  15. # Revision 1.2  1992/10/27  10:10:30  carlson
  16. # When breaking out the options, break out three characters instead of
  17. #   just two to allow checking of just the character following the dash.
  18. # Remove default options that conflict with command line options.
  19. #
  20. # Revision 1.1  91/08/27  13:13:01  carlson
  21. # Initial revision
  22. #------------------------------------------------------------------------
  23. # Set default options for ci command here.
  24. #
  25. set opt = ( )
  26. if ( $?RCSOPTS ) then
  27.     set opt = ( $opt $RCSOPTS )
  28. endif
  29. if ( -e ./.rcsopts ) then
  30.     set x = ( `grep "^ci[     ]" ./.rcsopts` )
  31.     if ( $#x > 1 ) set opt = ( $opt $x[2-] )
  32. endif
  33.  
  34. #----
  35. # Scan for end of options in parameter list.  We need to do this to
  36. # find where the file names start.
  37. #
  38. # While scanning, do the following:
  39. #    1. Remove any duplicated options from $opt.
  40. #    2. Remove any default options that conflict with user-specified
  41. #       options on the command line.
  42. #
  43. # How it is done:
  44. #    1. set arg_chars to all of the characters in the argument separated
  45. #       with spaces (so they are separate and distinct.
  46. #    2. If the argument does not start with a '-', we are done so we
  47. #       quit the loop.
  48. #    3. If the argument is "--", then we are done but ci won't accept
  49. #       this form so we have to remove it from argv.
  50. #    ---
  51. #    4. Scan the default options for duplicate options or options that
  52. #       are contradictory.
  53. #        a. set opt_chars to all of the characters in the option
  54. #           separated with spaces (so they are separate and
  55. #           distinct).
  56. #        b. If the option does not start with a '-', we are done
  57. #           so we quit the loop.
  58. #        c. If the option character is the same as the argument
  59. #           character, remove the option.
  60. #        d. If the option character is a contradictory character
  61. #           to the argument, remove the option.
  62. #
  63. @ first = 1
  64.  
  65. while ( $first <= $#argv )
  66.     set arg_chars = ( `echo $argv[$first] | sed "s/\(.\)\(.\)\(.\)/\1 \2 \3/\\
  67. s/\(.\)\(.\)/\1 \2/"` )
  68.     if ( "$arg_chars[1]" != "-" ) break
  69.     if ( "$arg_chars[2]" == "-" ) then
  70.     set argv[$first]
  71.     break
  72.     endif
  73.     @ secnd = 1
  74.     while ( $secnd <= $#opt )
  75.     set opt_chars = ( `echo $opt[$secnd] | sed "s/\(.\)\(.\)\(.\)/\1 \2 \3/\\
  76. s/\(.\)\(.\)/\1 \2/"` )
  77.     if ( "$opt_chars[1]" != "-" ) break
  78.     if ( "$opt_chars[2]" == "$arg_chars[2]" ) set opt[$secnd]
  79.     if ( "$opt_chars[2]" == "u" && "$arg_chars[2]" == "l" ) \
  80.         set opt[$secnd]
  81.     if ( "$opt_chars[2]" == 'l' && "$arg_chars[2]" == "u" ) \
  82.         set opt[$secnd]
  83.     @ secnd = $secnd + 1
  84.     end
  85.     @ first=$first + 1
  86. end
  87.  
  88. #----
  89. # Check out files with arguments passed.
  90. #
  91. /usr/sbin/ci $opt $argv
  92.  
  93. ### Local Variables:
  94. ### auto-fill-hook: nil
  95. ### End:
  96.