[alt.sources] ksh macros for use with SCCS

davidsen@sixhub.UUCP (Wm E. Davidsen Jr) (01/04/90)

  This package is useful for working with SCCS on machines without the
sccs command (and I use it there too, but hacked). It add "s." where
needed and understands the SCCS directory.

#!/bin/sh
# shar:	Shell Archiver  (v1.24)
#
#	Run the following text with /bin/sh to create:
#	  SCCS.ksh
#	  SCCS.ksh.doc
#
echo "x - extracting SCCS.ksh (Text)"
sed 's/^X//' << 'SHAR_EOF' > SCCS.ksh &&
X# define SCCS macros for ksh
X#	Copyright (c) 1987,88,90 Bill Davidsen, all rights reserved.
X#	This package may be freely used and distributed by anyone.
X
X# allow use of SCCS commands without typing s. on everything.
X#	"sccs get -e foo.c" generates "get -e s.foo.c" and so forth
X
Xsccs()
X{ # anything not starting with '-' is assumed to be a filename
X  typeset an=2 cmd="$1"
X  echotype=$(echo -- xx | wc -w)
X
X  while [ $an -le $# ]
X  do
X   # this works for old echo (no options) as well
X   if [ $echotype -eq 1 ]
X    then arg=`eval echo -- "\\$$an"`
X    else arg=`eval echo "\\$$an"`
X   fi
X
X   case "$arg" in
X   -*) # any argument
X    cmd="$cmd $arg";;
X   s.*)# already in filename format
X    if [ -r "$arg" ]
X    then
X     cmd="$cmd $arg"
X    else
X     if [ -r "SCCS/$arg" ]
X     then
X      cmd="$cmd SCCS/$arg"
X     else
X      echo "Missing file $arg"
X      return
X     fi
X    fi
X    ;;
X   *)  # assume filename
X    if [ -d "SCCS" ]
X    then  # use the SCCS directory
X     cmd="$cmd SCCS/s.$arg"
X    else
X     cmd="$cmd s.$arg"
X    fi
X    ;;
X   esac
X   let an=an+1
X  done
X  
X  # now execute the command
X  $cmd
X}
X#
X# do a diff between the last saved versions and the current version
X
XSdiff()
X{
X  typeset sfile=s.$1
X  
X  if [ $# -lt 1 ]
X  then
X    echo "$0: file [diff opts]"
X    echo "  ex: $0 foo.c"
X    echo "      $0 foo.c -e"
X    return 1
X  fi
X
X  if [ ! -r $sfile ]
X  then
X    sfile=SCCS/$sfile
X    if [ ! -r $sfile ]
X    then
X      echo "No sccs file for $1"
X      return 1
X    fi
X  fi
X  get -p -k -s $sfile | diff $2 - $1
X}
X
X# do a diff between the 1st saved versions and the current
X#	mainly useful when hacking code you got elsewhere, when sending
X#	back fixes and stuff
X
XSdiff1()
X{
X  typeset sfile=s.$1
X
X  if [ $# -lt 1 ]
X  then
X    echo "$0: file [diff opts]"
X    echo "  ex: $0 foo.c"
X    echo "      $0 foo.c -e"
X    return 1
X  fi
X
X  if [ ! -r $sfile ]
X  then
X    sfile=SCCS/$sfile
X    if [ ! -r $sfile ]
X    then
X      echo "No sccs file for $1"
X      return 1
X    fi
X  fi
X  get -p -k -s -r1.1 $sfile | diff $2 - $1
X}
X
SHAR_EOF
chmod 0644 SCCS.ksh || echo "restore of SCCS.ksh fails"
echo "x - extracting SCCS.ksh.doc (Text)"
sed 's/^X//' << 'SHAR_EOF' > SCCS.ksh.doc &&
X                       SCCS macros for Korn shell
X               Bill Davidsen (davidsen@crdos1.crd.ge.com)
X                              Jan 3, 1990
X
X
X  These are the macros I have been using for several years to ease use
Xof SCCS with Korn shell. This version has recently been updated to work
Xwith ksh.88 as well as the several older versions. It has NOT been
Xtested with bash.
X
X  Although the object of this was to overcome my tendancy to forget to
Xtype "s." when needed, this package provides several other things. It
Xsupports an SCCS directory, such that if a command is issued and there
Xis (a) no sccs file in the current directory, and (b) there is a
Xdirectory called SCCS, and (c) there is a file of the correct name in
Xthe SCCS directory, then the filename will be changed before the raw
XSCCS command is invoked.
X
X  The two diff commands are useful to me in day to day operation. The
XSdiff produces a diff between the current version of the file and the
Xlast saved version in the SCCS file. I use this just before doing a
Xdelta so that I don't forget something in the comments.
X
X  The Sdiff1 command produces the diff between the current version and
Xthe earliest version in the SCCS file. I use this when I get software
Xfrom someone else, and modify it extensively, and then want to produce a
Xcomplete list of all the changes I've made.
X
X  Copyright (c) 1990 by Bill Davidsen, all rights reserved. This
Xpackage may be freely used and distributed by anyone.
X
X
SHAR_EOF
chmod 0644 SCCS.ksh.doc || echo "restore of SCCS.ksh.doc fails"
exit 0

-- 
	bill davidsen - sysop *IX BBS and Public Access UNIX
davidsen@sixhub.uucp		...!uunet!crdgw1!sixhub!davidsen

"Getting old is bad, but it beats the hell out of the alternative" -anon