#!/bin/ksh # # @(#) Revision 1.13 - 02/11/98 # check # # Written 03/07/96. # # ============================================================================ # Andrea Whitlock, Mobius Software Services # whitlock@mobius-soft.com # # Bug reports, questions, and suggestions should be emailed to: # mobius@mobius-soft.com # # This software is provided under the terms of the GNU copyleft # (ftp://prep.ai.mit.edu/pub/gnu/COPYING-2.0), without a warranty # of any kind. Use at your own risk. # ============================================================================= # # THIS SCRIPT USES WRAPPER SCCS COMMANDS. GET SCCS.C AND INSTALL THE # THE WRAPPED SCCS COMMANDS FIRST. # # check who - who has files checked out # check new - check in a new file # check in - check in a checked out file # check out | ro - check out a file for edit | read-only # check cancel - cancel a check out (for edit) # check comment - change the SCCS commentary of a file # check hist - show SCCS history (comments) for a file # check diff - compare 2 versions of a file # check view - check ro a file, view it, and remove it # check ver - check version of a file # check where - check where the SCCS repository is for a file # check list - check out a file and list it to the screen # # configure me ################################################################ # prepend the path to your front-end sccs commands to $PATH PATH=/usr/local/bin/sccs:${PATH} export PATH # set your pager for things like check diff and check hist pager="/usr/local/bin/less -ME" # configure me end ############################################################ trap 'cleanup; exit 1' 1 2 3 4 5 6 7 8 15 cleanup() { rm -f /tmp/check.$$ rm -f /tmp/sact.$$ rm -f /tmp/sact.$$.2 rm -f /tmp/checkin.$$ rm -f /tmp/get.$$ rm -f /tmp/checkcdc.$$ rm -rf /tmp/checkview.$$ } usage () { if [ ! "$1" ] then echo "incorrect usage of usage (missing parm)." exit 2 fi if [ "$2" ] then usage$2 $1 else echo "$1: SCCS wrapper" echo "" echo "$1 who - who has files checked out" usagewho $1 echo "" echo "$1 new - check in a new file" usagenew $1 echo "" echo "$1 in - check in a checked out file" usagein $1 echo "" echo "$1 out | ro - check out a file for edit | read-only" usageout $1 echo "" echo "$1 cancel - cancel a check out (for edit)" usagecancel $1 echo "" echo "$1 comment - change the SCCS commentary of a file" usagecomment $1 echo "" echo "$1 hist - show SCCS history (comments) for a file" usagehist $1 echo "" echo "$1 diff - compare 2 versions of a file" usagediff $1 echo "" echo "$1 view - check ro a file, view it, and remove it" usageview $1 echo "" echo "$1 ver - check version of a file" usagever $1 echo "" echo "$1 where - check where the SCCS repository is for file" usagewhere $1 echo "" echo "$1 list - check out a file and list it to the screen" usagelist $1 echo "" echo "$1 uses the environment variable SCCS_PATH to look for SCCS files." echo "" fi exit 1 } usagewho() { echo "usage: $1 who [file [file [...]] | @user [@user [...]]]" echo " ex: $1 who" echo " lists all files checked out" echo " ex: $1 who @andrea @dan" echo " lists all files checked out by andrea and dan" echo " ex: $1 who smd801.txt" echo " lists all versions of smd801.txt checked out" return } usagenew() { echo "usage: $1 new sccsdir file [file [...]]" echo " ex: $1 new /usr/srce.c myfile.c" echo " checks myfile.c into the /usr/srce.c SCCS repository" echo " for the first time" echo " $1 new /usr/srce.c *.c *.h" echo " checks all the .c and .h files into the /usr/srce.c SCCS" echo " repository for the first time" return } usagein() { echo "usage: $1 in [-rversion] [-y\"comment\"] file [file [...]]" echo " ex: $1 in -y\"changes for MR #95-09-097\" myfile.txt myfile.par" echo " checks in myfile.txt and myfile.par with the comment" echo " \"changes for MR #95-09-097\"" echo " ex: $1 in -r1.3 myfile.txt" echo " checks in version 1.3 of myfile.txt" return } usageout() { echo "usage: $1 out | ro [-rversion] file [file [...]]" echo " ex: $1 out myfile.c" echo " checks out myfile.c for edit" echo " ex: $1 ro myfile.txt myfile.par" echo " checks out read-only copies of myfile.txt and myfile.par" echo " ex: $1 ro -r1.3 myfile.txt" echo " checks out version 1.3 of myfile.txt as read-only" return } usagero() { usageout return } usagecancel() { echo "usage: $1 cancel [-rversion] file [file [...]]" echo " ex: $1 cancel -r1.3 myfile.txt" echo " cancels check out of version 1.3 of myfile.txt" echo " ex: $1 cancel myfile.txt myfile.par" echo " cancels check out of myfile.txt and myfile.par" return } usagecomment() { echo "usage: $1 comment -rversion [-y\"comment\"] file [file [...]]" echo " ex: $1 comment -r1.3 myfile.txt" echo " prompts for new comment for version 1.3 of myfile.txt" echo " ex: $1 comment -r1.2 -y\"release 6.02 superama\" files.c dex.h" echo " adds new comment \"release 6.02 superama\" to version 1.2" echo " of files.c and dex.h" return } usagehist() { echo "usage: $1 hist [-rversion] [-e] [-l] [-current] file [file [...]]" echo " ex: $1 hist myfile.txt myfile.par" echo " prints SCCS history for myfile.txt and myfile.par" echo " ex: $1 hist -r1.3 myfile.txt" echo " prints SCCS history for version 1.3 of myfile.txt" echo " ex: $1 hist -r1.7 -e myfile.c" echo " prints SCCS history for versions earlier than 1.7 of myfile.c" echo " ex: $1 hist -r1.3 -l myfile.c" echo " prints SCCS history for versions later than 1.3 of myfile.c" echo " ex: $1 hist -current myfile.c" echo " prints SCCS history for current (latest) version of myfile.c" return } usagediff() { echo "usage: $1 diff [-pprinter] -c | -w | -rversion1 -rversion2 file" echo " -c uses the most current version of the file" echo " -w uses the working (checked out) version of the file" echo " -p causes the differences to be printed (to printer)" echo " ex: $1 diff -r1.3 -r1.4 myfile.c" echo " shows differences between version 1.3 and 1.4 of myfile.c" echo " ex: $1 diff -c -w myfile.c" echo " shows differences between the checked version of myfile.c" echo " and the latest checked in version" echo " ex: $1 diff -pprogram -w -r1.6.1 myfile.c" echo " prints differences between version 1.6.1 of myfile.c and the" echo " working (checked out) version of myfile.c to printer program" echo " note: versions are compared ignoring changes in amount of white" echo " space" return } usageview() { echo "usage: $1 view [-rversion] file [file [...]]" echo " ex: $1 view lookup.c lookup.h" echo " checks out read-only copies of lookup.c and lookup.h and" echo " views them" echo " ex: $1 view -r1.5 ConvDate.h" echo " checks out version 1.5 of ConvDate.h as read-only and views it" return } usagever() { echo "usage: $1 ver file [file [...]]" echo " ex: $1 ver smd330.txt" echo " prints the version of smd330.txt that is in SCCS or is" echo " being edited" return } usagewhere() { echo "usage: $1 where file [file [...]]" echo " ex: $1 where AmaTool.mak" echo " prints the SCCS repository that AmaTool.mak is checked into " return } usagelist() { echo "usage: $1 list [-rversion] file [file [...]]" echo " ex: $1 list -r1.1 AmaTool.mak" echo " prints version 1.1 of AmaTool.mak to the screen" return } checkwho() { if [ $# -eq 0 ] then filelist="s.*" else for f in $@ do sf=`echo $f | awk '{ if (substr($0,1,2) == "s.") { str = $0 } else if (substr($0,1,1) == "@") { str = substr($0,2) } else { str = sprintf("s.%s", $0) } print str }'` list="$list $sf" done echo "$@" | awk '{ for (i=1;i<=NF;i++) { c[i] = substr($i,1,1) if (c[i] == "@") check = 1 } if (check) { for (i=1;i<=NF;i++) { if (c[i] != "@") exit 1 } } exit 0 }' if [ $? -eq 1 ] then echo "cannot have mix of filenames and usernames." echo "" usage$func $prog exit fi firstchar=`echo "$@" | cut -c1-1` if [ "$firstchar" = "@" ] then filelist="s.*" userlist="$list" else filelist="$list" for file in $filelist do if get -g $file > /dev/null 2>&1 then : else echo "file $file not in SCCS." echo "" usage$func $prog exit fi done fi fi for dir in $sccspath do if [ ! -d $dir ] then continue fi cd $dir header="" for file in $filelist do if [ ! -f $file ] then continue fi sact $file 2> /dev/null | grep -v "No outstanding deltas" > \ /tmp/check.$$ if [ -s /tmp/check.$$ ] then if [ "$userlist" ] then skip="yes" for user in $userlist do if grep $user /tmp/check.$$ > /dev/null 2>&1 then skip="" else : fi done if [ "$skip" ] then continue fi fi if [ ! "$header" ] then echo "" echo "------------------------------------------------------------------------" echo "SCCS Directory: $dir" echo "Username Date Time Version Filename" echo "------------------------------------------------------------------------" fi f=`echo $file | awk '{ print substr($0,3) }'` awk '{ printf "%8s %s %s %8s %s\n", $3, $4, $5, $2, f }' f=$f /tmp/check.$$ header="yes" found="yes" fi rm -f /tmp/check.$$ done done if [ ! "$found" ] then if [ "$userlist" ] then echo "File(s) not checked out by user(s)." else echo "File(s) not checked out." fi else echo "" fi return } checknew() { if [ $# -lt 2 ] then usage$func $prog exit fi sdir=$1 if [ ! -d $sdir ] then echo "$sdir not a directory." echo "" usage$func $prog exit fi d1=`echo $sdir | awk '{ print substr($0,1,1) }'` if [ "$d1" != "/" ] then echo "specify absolute path to sccs directory." echo "" usage$func $prog exit fi found="" if [ -h $sdir ] then checksdir=`ll $sdir 2> /dev/null | awk '{ print $NF }'` d1=`echo $checksdir | awk '{ print substr($0,1,1) }'` if [ "$d1" != "/" ] then echo "sccs directory must be sym linked to an absolute path." echo "" usage$func $prog exit fi else checksdir=$sdir fi for testsdir in $sccspath do if [ "$testsdir" = "$checksdir" ] then found="yes" break fi done if [ ! "$found" ] then if [ "$SCCS_PATH" ] then echo "$sdir not an SCCS repository (not found in SCCS_PATH)" else echo "$sdir not an SCCS repository (not found in sccs path)" fi echo "" usage$func $prog exit fi shift for f in "$@" do if [ ! -f $f ] then echo "cannot find file $f." echo "" usage$func $prog exit fi bf=`basename $f` dir=`dirname $f` if sact $bf > /dev/null 2>&1 then sfile=`prs $bf | head -1 | awk -F: '{ print $1 }'` echo "file $f already an SCCS file:" echo "$sfile" echo "" usage$func $prog exit fi flist="$f $flist" done for f in $flist do bf=`basename $f` echo "${bf}:" admin -i$f $sdir/s.$bf done return } checkin() { if [ $# -lt 1 ] then usage$func $prog exit fi args=1 comment="" version="" for f in "$@" do if echo $f | \ awk '{ if (substr($0,1,2) == "-r") { exit 0 } else { exit 1 } }' then if echo $f | \ awk '{ if (length($0) > 2) { exit 0 } else { exit 1 } }' then : else echo "incorrect use of -r." echo "" usage$func $prog exit fi if [ "$version" ] then echo "cannot use -r more than once." echo "" usage$func $prog exit fi version=`echo $f | awk '{ print substr($0,3) }'` if [ ! "$version" ] then echo "$prog: internal error - check${func}() version not calculated ($f)" exit fi continue fi if echo $f | \ awk '{ if (substr($0,1,2) == "-y") { exit 0 } else { exit 1 } }' then if echo $f | \ awk '{ if (length($0) > 2) { exit 0 } else { exit 1 } }' then : else echo "incorrect use of -y." echo "" usage$func $prog exit fi if [ "$comment" ] then echo "cannot use -y more than once." echo "" usage$func $prog exit fi comment=`echo $f | awk '{ print substr($0,3) }'` if [ ! "$comment" ] then echo "$prog: internal error - check${func}() comment not calculated ($f)" exit fi args=`expr $args + 1` continue fi flist="$f $flist" done flist=`echo $flist | awk '{ print $0 }'` if [ ! "$flist" ] then echo "missing file argument." echo "" usage$func $prog $prog exit fi for f in $flist do if [ ! -f $f ] then echo "cannot find file $f." echo "" usage$func $prog exit fi if get -g $f > /dev/null 2>&1 then : else echo "file $f not in SCCS." echo "" usage$func $prog exit fi if get -g $f >/dev/null 2>&1 then : else echo "file $f not in SCCS." echo "" usage$func $prog exit fi sact $f > /tmp/sact.$$ 2>&1 if grep "No outstanding deltas" /tmp/sact.$$ > /dev/null 2>&1 then echo "file $f not checked out." echo "" usage$func $prog rm -f /tmp/sact.$$ exit else grep "`whoami`" /tmp/sact.$$ > /tmp/sact.$$.2 2>/dev/null n=`cat /tmp/sact.$$.2 | wc -l` if [ $n -ne 1 ] then if [ $n -lt 1 ] then echo "file $f not checked out (by `whoami`)." echo "the following versions are checked out:" echo "" cat /tmp/sact.$$ echo "" usage$func $prog rm -f /tmp/sact.$$ rm -f /tmp/sact.$$.2 exit elif [ ! "$version" -a $n -gt 1 ] then echo "specify which version of file $f to check in." echo "the following versions are checked out:" echo "" cat /tmp/sact.$$ echo "" usage$func $prog rm -f /tmp/sact.$$ rm -f /tmp/sact.$$.2 exit fi fi v="$version" if [ "$v" ] then if grep "$v" /tmp/sact.$$.2 >/dev/null 2>&1 then : else echo "file $f version $v not checked out (by `whoami`)." echo "the following versions are checked out:" echo "" cat /tmp/sact.$$ echo "" usage$func $prog rm -f /tmp/sact.$$ rm -f /tmp/sact.$$.2 exit fi fi rm -f /tmp/sact.$$.2 fi rm -f /tmp/sact.$$ done if [ "$version" ] then version="-r$version" fi num=$args for f in $flist do if [ ! "$comment" ] then echo "Enter comments for these changes to $f below this line:\n" \ > /tmp/checkin.$$ vi + /tmp/checkin.$$ c=`tail +2 /tmp/checkin.$$ | awk '{ printf "%s\\n", $0 }'` rm -f /tmp/checkin.$$ else c="$comment" fi echo "${f}:" if delta -y"$c" $version $f then : else if [ $num -lt $# ] then echo "delta not successful; hit return to continue ... \c" read junk else echo "delta not successful." fi echo "" fi num=`expr $num + 1` done return } checkout() { if [ $# -lt 1 ] then usage$func $prog exit fi if [ "$func" != "out" -a "$func" != "ro" ] then echo "$prog: internal error - checkout() type not valid ($func)" exit fi version="" for f in $@ do if echo $f | \ awk '{ if (substr($0,1,2) == "-r") { exit 0 } else { exit 1 } }' then if echo $f | \ awk '{ if (length($0) > 2) { exit 0 } else { exit 1 } }' then : else echo "incorrect use of -r." echo "" usage$func $prog exit fi if [ "$version" ] then echo "cannot use -r more than once." echo "" usage$func $prog exit fi version=`echo $f | awk '{ print substr($0,3) }'` if [ ! "$version" ] then echo "$prog: internal error - check${func}() version not calculated ($f)" exit fi continue else list="$f $list" fi done if [ ! "$list" ] then echo "missing file argument." echo "" usage$func $prog exit fi for f in $list do if get -g $f > /dev/null 2>&1 then : else echo "file $f not in SCCS." echo "" usage$func $prog exit fi if [ "$version" ] then if get -g -r$version $f > /tmp/get.$$ 2>/dev/null then getver=`tail -1 /tmp/get.$$` if [ "$getver" != "$version" ] then echo "file $f version $version not in SCCS." echo "" usage$func $prog rm -f /tmp/get.$$ exit fi else echo "file $f version $version not in SCCS." echo "" usage$func $prog rm -f /tmp/get.$$ exit fi rm -f /tmp/get.$$ fi sact $f > /tmp/sact.$$ 2>&1 if grep "No outstanding deltas" /tmp/sact.$$ > /dev/null 2>&1 then : elif [ "$func" = "out" ] then v="$version" if [ ! "$v" ] then v=`get -g $f | tail -1` fi grep "^$v " /tmp/sact.$$ > /tmp/sact.$$.2 2>/dev/null if [ -s /tmp/sact.$$.2 ] then echo "file $f already checked out:" echo "" cat /tmp/sact.$$ echo "" usage$func $prog rm -f /tmp/sact.$$ rm -f /tmp/sact.$$.2 exit fi rm -f /tmp/sact.$$.2 fi rm -f /tmp/sact.$$ sfile=`prs $f | head -1` sdir=`dirname $sfile` if [ "`pwd`" = "$sdir" ] then echo "you are in the SCCS directory $sdir (can't check $func here)." echo "" usage$func $prog exit fi flist="$f $flist" done if [ "$version" ] then version="-r$version" fi for f in $flist do echo "${f}:" if [ "$func" = "out" ] then get -e $version $f else get $version $f fi done return } checkcancel() { if [ $# -lt 1 ] then usage$func $prog exit fi version="" for f in $@ do if echo $f | \ awk '{ if (substr($0,1,2) == "-r") { exit 0 } else { exit 1 } }' then if echo $f | \ awk '{ if (length($0) > 2) { exit 0 } else { exit 1 } }' then : else echo "incorrect use of -r." echo "" usage$func $prog exit fi if [ "$version" ] then echo "cannot use -r more than once." echo "" usage$func $prog exit fi version=`echo $f | awk '{ print substr($0,3) }'` if [ ! "$version" ] then echo "$prog: internal error - check${func}() version not calculated ($f)" exit fi continue else list="$f $list" fi done if [ ! "$list" ] then echo "missing file argument." echo "" usage$func $prog exit fi for f in $list do if get -g $f > /dev/null 2>&1 then : else echo "file $f not in SCCS." echo "" usage$func $prog exit fi sact $f > /tmp/sact.$$ 2>&1 if grep "No outstanding deltas" /tmp/sact.$$ > /dev/null 2>&1 then echo "file $f not checked out." echo "" usage$func $prog rm -f /tmp/sact.$$ exit else grep "`whoami`" /tmp/sact.$$ > /tmp/sact.$$.2 2>/dev/null n=`cat /tmp/sact.$$.2 | wc -l` if [ $n -ne 1 ] then if [ $n -lt 1 ] then echo "file $f not checked out (by `whoami`)." echo "the following versions are checked out:" echo "" cat /tmp/sact.$$ echo "" usage$func $prog rm -f /tmp/sact.$$ rm -f /tmp/sact.$$.2 exit elif [ ! "$version" -a $n -gt 1 ] then echo "specify which version of file $f to cancel." echo "the following versions are checked out:" echo "" cat /tmp/sact.$$ echo "" usage$func $prog rm -f /tmp/sact.$$ rm -f /tmp/sact.$$.2 exit fi fi v="$version" if [ "$v" ] then grep " $v " /tmp/sact.$$ | grep "`whoami`" > /tmp/sact.$$.2 \ 2>/dev/null if [ ! -s /tmp/sact.$$.2 ] then echo "file $f delta $v not checked out (by `whoami`)." echo "the following versions are checked out:" echo "" cat /tmp/sact.$$ echo "" usage$func $prog rm -f /tmp/sact.$$ rm -f /tmp/sact.$$.2 exit fi grep " $v " /tmp/sact.$$ > /tmp/sact.$$.2 2>/dev/null if [ ! -s /tmp/sact.$$.2 ] then echo "file $f version $v not a new delta." echo "the following versions are checked out:" echo "" cat /tmp/sact.$$ echo "" usage$func $prog rm -f /tmp/sact.$$ rm -f /tmp/sact.$$.2 exit fi fi rm -f /tmp/sact.$$.2 fi rm -f /tmp/sact.$$ flist="$f $flist" done if [ "$version" ] then version="-r$version" fi for f in $flist do echo "${f}:" unget $version $f done return } checkcomment() { if [ $# -lt 1 ] then usage$func $prog exit fi args=2 comment="" version="" for f in "$@" do if echo $f | \ awk '{ if (substr($0,1,2) == "-r") { exit 0 } else { exit 1 } }' then if echo $f | \ awk '{ if (length($0) > 2) { exit 0 } else { exit 1 } }' then : else echo "incorrect use of -r." echo "" usage$func $prog exit fi if [ "$version" ] then echo "cannot use -r more than once." echo "" usage$func $prog exit fi version=`echo $f | awk '{ print substr($0,3) }'` if [ ! "$version" ] then echo "$prog: internal error - check${func}() version not calculated ($f)" exit fi continue fi if echo $f | \ awk '{ if (substr($0,1,2) == "-y") { exit 0 } else { exit 1 } }' then if echo $f | \ awk '{ if (length($0) > 2) { exit 0 } else { exit 1 } }' then : else echo "incorrect use of -y." echo "" usage$func $prog exit fi if [ "$comment" ] then echo "cannot use -y more than once." echo "" usage$func $prog exit fi comment=`echo $f | awk '{ print substr($0,3) }'` if [ ! "$comment" ] then echo "$prog: internal error - check${func}() comment not calculated ($f)" exit fi args=`expr $args + 1` continue fi flist="$f $flist" done if [ ! "$version" ] then echo "missing version argument." echo "" usage$func $prog exit fi if [ ! "$flist" ] then echo "missing file argument." echo "" usage$func $prog exit fi for f in $flist do if get -g -r$version $f > /tmp/get.$$ 2>/dev/null then getver=`tail -1 /tmp/get.$$` if [ "$getver" != "$version" ] then echo "file $f version $version not in SCCS." echo "" usage$func $prog rm -f /tmp/get.$$ exit fi else echo "file $f version $version not in SCCS." echo "" usage$func $prog rm -f /tmp/get.$$ exit fi rm -f /tmp/get.$$ done num=$args for f in $flist do if [ ! "$comment" ] then echo "Enter comments for $f version $version below this line:\n" \ > /tmp/checkcdc.$$ vi + /tmp/checkcdc.$$ c=`tail +2 /tmp/checkcdc.$$ | awk '{ printf "%s\\n", $0 }'` rm -f /tmp/checkcdc.$$ else c="$comment" fi if cdc -r$version -y"$c" $f then : else if [ $num -lt $# ] then echo "cdc not successful ($f); hit return to continue ... \c" read junk else echo "cdc not successful." fi echo "" fi num=`expr $num + 1` done return } checkview() { if [ $# -lt 1 ] then usage$func $prog exit fi version="" for f in $@ do if echo $f | \ awk '{ if (substr($0,1,2) == "-r") { exit 0 } else { exit 1 } }' then if echo $f | \ awk '{ if (length($0) > 2) { exit 0 } else { exit 1 } }' then : else echo "incorrect use of -r." echo "" usage$func $prog exit fi if [ "$version" ] then echo "cannot use -r more than once." echo "" usage$func $prog exit fi version=`echo $f | awk '{ print substr($0,3) }'` if [ ! "$version" ] then echo "$prog: internal error - check${func}() version not calculated ($f)" exit fi else list="$f $list" fi done if [ ! "$list" ] then echo "missing file argument." echo "" usage$func $prog exit fi for f in $list do if get -g $f > /dev/null 2>&1 then : else echo "file $f not in SCCS." echo "" usage$func $prog exit fi if [ "$version" ] then if get -g -r$version $f > /tmp/get.$$ 2>/dev/null then getver=`tail -1 /tmp/get.$$` if [ "$getver" != "$version" ] then echo "file $f version $version not in SCCS." echo "" usage$func $prog rm -f /tmp/get.$$ exit fi else echo "file $f version $version not in SCCS." echo "" usage$func $prog rm -f /tmp/get.$$ exit fi rm -f /tmp/get.$$ fi done startpwd=`pwd` mkdir /tmp/checkview.$$ cd /tmp/checkview.$$ for f in $list do if [ "$version" ] then get -p -r$version $f > $f 2>/dev/null else get -p $f > $f 2>/dev/null fi done view * cd $startpwd rm -rf /tmp/checkview.$$ return } checkhist() { if [ $# -lt 1 ] then usage$func $prog exit fi earlier="" later="" version="" current="" for f in $@ do if echo $f | \ awk '{ if (substr($0,1,2) == "-r") { exit 0 } else { exit 1 } }' then if echo $f | \ awk '{ if (length($0) > 2) { exit 0 } else { exit 1 } }' then : else echo "incorrect use of -r." echo "" usage$func $prog exit fi if [ "$version" ] then echo "cannot use -r more than once." echo "" usage$func $prog exit fi version=`echo $f | awk '{ print substr($0,3) }'` if [ ! "$version" ] then echo "$prog: internal error - check${func}() version not calculated ($f)" exit fi continue elif echo $f | \ awk '{ if (substr($0,1,2) == "-e") { exit 0 } else { exit 1 } }' then if echo $f | \ awk '{ if (length($0) > 2) { exit 0 } else { exit 1 } }' then echo "incorrect use of -e." echo "" usage$func $prog exit fi if [ "$earlier" ] then echo "cannot use -e more than once." echo "" usage$func $prog exit fi earlier="$f" continue elif echo $f | \ awk '{ if (substr($0,1,2) == "-l") { exit 0 } else { exit 1 } }' then if echo $f | \ awk '{ if (length($0) > 2) { exit 0 } else { exit 1 } }' then echo "incorrect use of -l." echo "" usage$func $prog exit fi if [ "$later" ] then echo "cannot use -l more than once." echo "" usage$func $prog exit fi later="$f" continue elif [ "$f" = "-current" ] then if [ "$current" ] then echo "cannot use -current more than once." echo "" usage$func $prog exit fi current="$f" continue else list="$f $list" fi done if [ ! "$list" ] then echo "missing file argument." echo "" usage$func $prog exit fi for f in $list do if get -g $f > /dev/null 2>&1 then : else echo "file $f not in SCCS." echo "" usage$func $prog exit fi if [ "$version" ] then if get -g -r$version $f > /tmp/get.$$ 2>/dev/null then getver=`tail -1 /tmp/get.$$` if [ "$getver" != "$version" ] then echo "file $f version $version not in SCCS." echo "" usage$func $prog rm -f /tmp/get.$$ exit fi else echo "file $f version $version not in SCCS." echo "" usage$func $prog rm -f /tmp/get.$$ exit fi rm -f /tmp/get.$$ fi done for f in $list do if [ "$current" ] then v=`get -g $f 2>/dev/null | tail -1` prs -r$v $f | $pager elif [ "$version" ] then prs -r$version $earlier $later $f | $pager else prs $earlier $later $f | $pager fi done return } checkdiff() { if [ $# -lt 1 ] then usage$func $prog exit fi version="" print="" current="" working="" numr=0 for f in $@ do if echo $f | \ awk '{ if (substr($0,1,2) == "-r") { exit 0 } else { exit 1 } }' then if echo $f | \ awk '{ if (length($0) > 2) { exit 0 } else { exit 1 } }' then : else echo "incorrect use of -r." echo "" usage$func $prog exit fi if [ $numr -ge 2 ] then echo "must use -r exactly twice." echo "" usage$func $prog exit fi versiontmp=`echo $f | awk '{ print substr($0,3) }'` if [ ! "$versiontmp" ] then echo "$prog: internal error - check${func}() version not calculated ($f)" exit fi numr=`expr $numr + 1` version="$version $versiontmp" continue elif echo $f | \ awk '{ if (substr($0,1,2) == "-p") { exit 0 } else { exit 1 } }' then if echo $f | \ awk '{ if (length($0) > 2) { exit 1 } else { exit 0 } }' then if [ "$PRINTER" ] then echo "Enter printer name (type exit to abort): [$PRINTER] \c" read pname if [ ! "$pname" ] then pname="$PRINTER" fi else echo "Enter printer name (hit return to abort): \c" read pname fi if [ ! "$pname" ] then echo "printer not entered, $func aborted." exit elif [ "$pname" = "exit" ] then echo "$func aborted." exit fi else pname=`echo $f | awk '{ print substr($0,3) }'` fi if [ "$print" ] then echo "cannot use -p more than once." echo "" usage$func $prog exit fi print="yes" continue elif echo $f | \ awk '{ if (substr($0,1,2) == "-c") { exit 0 } else { exit 1 } }' then if echo $f | \ awk '{ if (length($0) > 2) { exit 0 } else { exit 1 } }' then echo "incorrect use of -c." echo "" usage$func $prog exit fi if [ "$current" ] then echo "cannot use -c more than once." echo "" usage$func $prog exit fi current="yes" continue elif echo $f | \ awk '{ if (substr($0,1,2) == "-w") { exit 0 } else { exit 1 } }' then if echo $f | \ awk '{ if (length($0) > 2) { exit 0 } else { exit 1 } }' then echo "incorrect use of -w." echo "" usage$func $prog exit fi if [ "$working" ] then echo "cannot use -w more than once." echo "" usage$func $prog exit fi working="yes" continue else list="$f $list" fi done if [ $numr -ne 2 -a ! "$current" -a ! "$working" ] then echo "must use -r, -w and/or -c." echo "" usage$func $prog exit elif [ "$current" ] then if [ ! "$working" -a $numr -ne 1 ] then echo "must use -w or -r with -c." echo "" usage$func $prog exit fi elif [ "$working" ] then if [ ! "$current" -a $numr -ne 1 ] then echo "must use -c or -r with -w." echo "" usage$func $prog exit fi fi if [ ! "$list" ] then echo "missing file argument." echo "" usage$func $prog exit fi v1=`echo "$version" | awk '{ print $1 }'` v2=`echo "$version" | awk '{ print $2 }'` for f in $list do if get -g $f > /dev/null 2>&1 then : else echo "file $f not in SCCS." echo "" usage$func $prog exit fi for vtmp in $v1 $v2 do if get -g -r$vtmp $f > /tmp/get.$$ 2>/dev/null then getver=`tail -1 /tmp/get.$$` if [ "$getver" != "$vtmp" ] then echo "file $f version $vtmp not in SCCS." echo "" usage$func $prog rm -f /tmp/get.$$ exit fi else echo "file $f version $vtmp not in SCCS." echo "" usage$func $prog rm -f /tmp/get.$$ exit fi rm -f /tmp/get.$$ done done for f in $list do if [ "$current" ] then v2="$v1" v1=`get -g $f | tail -1` fi if [ "$current" ] then version1="$v1 (current)" else version1="$v1" fi if [ "$working" ] then version2="working" else version2="$v2" fi if [ "$print" ] then if lpstat -p$pname 2>/dev/null | grep "enable" >/dev/null then : else echo "printer $pname invalid or not enabled, $func aborted." exit fi pagerdisp='pr -h"$f $version1 vs. $version2" | lp -d$pname' else pagerdisp="$pager" fi ( if [ "$working" ] then get -p -r$v1 $f 2>/dev/null | gdiff -b -B -c -L "$f version $v1" - -L "$f working version" $f else get -p -r$v1 $f 2>/dev/null > /tmp/$f.$v1.$$ get -p -r$v2 $f 2>/dev/null > /tmp/$f.$v2.$$ gdiff -b -B -c -L "$f version $v2" /tmp/$f.$v2.$$ -L "$f version $v1" /tmp/$f.$v1.$$ rm -f /tmp/$f.$v1.$$ rm -f /tmp/$f.$v2.$$ fi ) | eval $pagerdisp done return } checkver() { if [ $# -lt 1 ] then usage$func $prog exit fi filelist="$@" for file in $filelist do if get -g $file > /tmp/check.$$ 2>/dev/null then inver=`tail -1 /tmp/check.$$` else echo "file $file not in SCCS." echo "" usage$func $prog rm -f /tmp/check.$$ exit fi rm -f /tmp/check.$$ prs -r$ver $file | tail +3 | head -1 > /tmp/check.$$ inver=`awk '{ print $2 }' /tmp/check.$$` inuser=`awk '{ print $5 }' /tmp/check.$$` indate=`awk '{ print $3 }' /tmp/check.$$` intime=`awk '{ print $4 }' /tmp/check.$$` rm -f /tmp/check.$$ if [ ! "$header" ] then echo "" echo "------------------------------------------------------------------------" echo "key: * = checked out" echo "Username Date Time Version Filename" echo "------------------------------------------------------------------------" header="yes" fi printf "%8s %s %s %8s %s\n" $inuser $indate $intime $inver $file sact $file 2> /dev/null | grep -v "No outstanding deltas" | \ while read junk outver outuser outdate outtime do if [ "$outver" ] then printf "%8s %s %s %8s %s*\n" $outuser $outdate $outtime \ $outver $file fi done done echo "" return } checkwhere() { if [ $# -lt 1 ] then usage$func $prog exit fi filelist="$@" for file in $filelist do if get -g $file > /tmp/check.$$ 2>/dev/null then : else echo "file $file not in SCCS." echo "" usage$func $prog rm -f /tmp/check.$$ exit fi rm -f /tmp/check.$$ dirline=`prs $file | head -1` dir=`dirname $dirline` if [ ! "$header" ] then echo "" echo "------------------------------------------------------------------------" echo "Filename SCCS Repository" echo "------------------------------------------------------------------------" header="yes" fi printf "%-28s %s\n" $file $dir done echo "" return } checklist() { if [ $# -lt 1 ] then usage$func $prog exit fi version="" for f in $@ do if echo $f | \ awk '{ if (substr($0,1,2) == "-r") { exit 0 } else { exit 1 } }' then if echo $f | \ awk '{ if (length($0) > 2) { exit 0 } else { exit 1 } }' then : else echo "incorrect use of -r." echo "" usage$func $prog exit fi if [ "$version" ] then echo "cannot use -r more than once." echo "" usage$func $prog exit fi version=`echo $f | awk '{ print substr($0,3) }'` if [ ! "$version" ] then echo "$prog: internal error - check${func}() version not calculated ($f)" exit fi else list="$f $list" fi done if [ ! "$list" ] then echo "missing file argument." echo "" usage$func $prog exit fi for f in $list do if get -g $f > /dev/null 2>&1 then : else echo "file $f not in SCCS." echo "" usage$func $prog exit fi if [ "$version" ] then if get -g -r$version $f > /tmp/get.$$ 2>/dev/null then getver=`tail -1 /tmp/get.$$` if [ "$getver" != "$version" ] then echo "file $f version $version not in SCCS." echo "" usage$func $prog rm -f /tmp/get.$$ exit fi else echo "file $f version $version not in SCCS." echo "" usage$func $prog rm -f /tmp/get.$$ exit fi rm -f /tmp/get.$$ fi done for f in $list do if [ "$version" ] then get -p -r$version $f 2>/dev/null else get -p $f 2>/dev/null fi done return } prog=`basename $0` if [ ! "$1" ] then usage $prog fi sccspath=`echo $SCCS_PATH | awk -F: '{ for(i=1;i<=NF;i++) print $i }'` if [ ! "$sccspath" ] then echo "set SCCS_PATH so I can find the SCCS files." exit fi case "$1" in who|new|in|out|cancel|hist|diff|comment|view|ver|where|list) func=$1 shift check$func "$@" ;; ro) func=$1 shift checkout "$@" ;; *) usage $prog esac