[net.sources] interface scripts for sccs

larry@geowhiz.UUCP (Larry McVoy) (01/28/86)

*** REPLACE THIS LINE WITH YOUR MASSAGE ***

#
# These are my interface to SCCS.  I use these exclusively.  See the article
# in net.unix for an explanation.
#
# This is a shell archive.  Remove anything before this line, then
# unpack it by saving it in a file and typing "sh file".  (Files
# unpacked will be owned by you and have default permissions.)
#
# This archive contains:
# sccs.doc get update

echo x - sccs.doc
cat > "sccs.doc" << '//E*O*F sccs.doc//'
Help with SCCS  --  January 1986  -- Larry McVoy

Here's how I do it:

I have some shell scripts (csh but I have made an attempt at sh versions)
which are human oriented versions of get & delta.  Both of these assume the
following conditions:

	$cwd has a subdirectory called 'S' in which all s.xxxxx files are kept.
	$cwd is the directory in which you work. 
	(These can be faked by linking the SCCS directory to a subdirectory
	 called S in your work dir.  Requires 4.2)

My version of get takes the ordinary file name (like get foo.c, not get s.foo.c)
as well as the -e option for edit.  This is nice in csh, you can

	% get -e foo.c
	% vi !$
	vi foo.c

I do that a lot.  The full options to get are listed below.

My version of delta is called update.  It will delta all files which are
writable (default: *.[che]) or all writable files in the arg list.
I generally just say update and it prompts me for comments etc.  See below
for full options.

Summary:  I use these 2 shell scripts exclusively for all my SCCSed stuff.
	  I've used them alot, in makefiles as well, and I think they're
	  fairly robust.  I find that they make SCCS actually usable.

get defaults:
	non-edit mode (444)
	user specified file list
get options:
	-a	gets ALL files in the S directory.  Can be used w/ -e.
	-e 	gets w/ write permission (like get(1))
	-p	just prints it to stdout (gimme a look)
	-rR
	-r R	gets revision R.

update defaults:
	*.[che]
	once it's rolling, it won't prompt for each file (see askeach)
	gets a 444 mode version after update
	asks for comments for SCCS
	SCCSes on SCCSed files (with a prompt).  This replaces admin.
update options:
	-check	    Just list which files are writable (ie out in edit mode)
	-askeach    Prompt for comments on each file updated
	-clean	    Don't get the new version
	-comments   Don't ask for any comments
//E*O*F sccs.doc//

echo x - get
cat > "get" << '//E*O*F get//'
#!/bin/csh -f
# Shell script to check out SCCS files
#
set edit rev pflg
while ( $#argv )
    switch ( $argv[1] )
        case "-e":
            set edit = "-e "
            breaksw
        case "-a":
            set getall
            breaksw
        case "-r":
            shift
            set rev = "-r$argv[1] "
            breaksw
        case "-r[1-9]*":
            set rev = "$argv[1] "
            breaksw
        case "-p"
            set pflg = "-p "
            breaksw
        case "-*"
            echo Unknown option \"$argv[1]\" ignored.
            breaksw
        default:
            if ( ! $?args ) set args
            set args = ( $args S/s.$argv[1] )
            set getall
            breaksw
    endsw
    shift
end
if ( ! -e S ) then
    echo -n "No S directory."
    goto quit
endif
if ( ! $?args ) set args = S/s.*
if ( $#args == 0 ) then
    echo "No files."
    goto quit
endif
foreach i ( $args )
    if ( ! $?getall ) then
        echo -n "Get $pflg$edit$rev`basename $i` (y/n)? "
        set ans = $<
        if ( $ans == "y" ) /usr/bin/get -s $pflg$edit $rev $i
    else
        echo $pflg$edit$rev $i
        /usr/bin/get -s $pflg$edit $rev $i
    endif
end
quit:
//E*O*F get//

echo x - update
cat > "update" << '//E*O*F update//'
#!/bin/csh -f
# Shell script to put back checked out SCCS files and get them again for 
# release.
#
set edit rev 
while ( $#argv )
    switch ( $argv[1] )
        case "-check":
            set checkonly
            breaksw
        case "-askeach":
            set askeach
            breaksw
        case "-clean":
            set clean
            breaksw
        case "-comments":
            set comments        # so it won't bark below
            breaksw
        case "-*"
            echo Unkown option \"$argv[1]\" ignored.
            breaksw
        default:
            if ( ! $?args ) set args
            set args = ( $args $argv[1] )
            breaksw
    endsw
    shift
end
if ( ! -e S ) then
    echo -n "No S directory, make it? "
    set ans = $<
    if ( $ans == "y" ) then
        mkdir S
    else if ( ! $?checkonly ) then
        echo Quit.
        exit
    endif
endif
if ( ! $?args ) set args = ( *.[che] )
foreach i ( $args )
    if ( ! -w $i ) then
        if ( $?clean ) then
            /bin/rm -f $i
        endif
    else
        if ( $?checkonly ) then
            echo "$i"
        else
            echo -n "$i? "
            set ans = $<
            if ( $ans == "y" ) then
                if ( ! ( -e S/s.$i ) ) then
                    echo -n "$i is not SCCSed.  SCCS it (y/n)? "
                    set ans = $<
                    if ( $ans == "y" ) then
                        admin -i$i S/s.$i
                        /bin/rm $i
                        if ( ! $?clean ) /usr/bin/get -s S/s.$i
                    endif
                    continue
                endif
                if ( $?askeach  ||  !( $?comments ) ) then
                    echo -n "Comments for sccs? "
                    set comments = $<
                endif
                delta -s -y"$comments" S/s.$i
                if ( ! $?clean ) /usr/bin/get -s S/s.$i
            endif
        endif
    endif
end
//E*O*F update//

exit 0
-- 
Larry McVoy
-----------
Arpa:  mcvoy@rsch.wisc.edu                              
Uucp:  {seismo, ihnp4}!uwvax!geowhiz!geophiz!larry      

"If you are undertaking anything substantial, C is the only reasonable 
 choice of programming language"  --  Brian W. Kerninghan