#!/bin/csh -f # file://save # # Save archives the file specified as $1 parameter. # # Save first creates a sub-directory called 'old' in the directory # that contains the file specified by $1 if it does not already # exist. Note that this sub-directory can be called something other # then 'old' if the environment variable 'SAVEDIR' is set. In the # sub-directory another sub-directory is created with the same name # as the archived file if it does not already exist. Within this lower # subdirectory the archive file will be copied and named in the # following fashion: user-id.archive-revision. archive-revision # starts with '000' and increments by 1 positively for each archive # until '999' is reached at which time the next the archive will # reset to '000' again and each sucessive archive will be overwritten # in ascending numerical order. This way you are garunteed to save # at least 999 versions back in successive order. The companion 'unsave' # command will automatically understand this behavior. # # The revisions are always zero-filled 3 digit to maintain compatibility # with the MS-DOS version (written in Turbo C) version of this command. # # An example of save'ing the file test.dat will create the following # directories and file: # # pwd # /home/kinscoe/test # % save test.dat # # /home/kinscoe/test/old/test.dat/kinscoe.000 # # This way you know what userid, when (ls -l) and what revision # the file was saved as. # # Bug reports for both the unix and MS-DOS versions should # go to inscoe@iag.net or kevin.inscoe@cbis.com. # # The unix version is known to work correctly on the following # platforms: # # Solaris 2.5-2.6 # SunOS 4.1.3-4.1.4 # AIX 4.2 # HP-UX 10.20 # Linux 2.0.30-2.0.33 # A seperate version is available for SGI IRIX 5.x & 6.x from # kmk@iag.net. I no longer have access to IRIX to test this # release. # # # Modification Log: # # Name Date Why # ---- ---- --- # Kevin Inscoe (inscoe@iag.net) 1/27/98 Created orginal # # # Check to see if required parameter $1 is present # if ( $1 == "" ) then /bin/echo "usage: save file" exit 1 endif # # Set environment and global variables # set ver = "1.0" # uncomment and set this if you want to use a different sub-directory # then 'old' #setenv SAVEDIR "old" if ( $?SAVEDIR ) then set sdir = `/bin/echo $SAVEDIR else set sdir = "old" endif # # parse and check our parameter # if ( ! -e $1 ) then /bin/echo "save: `/bin/echo $1`: No such file or directory" exit 1 endif # now determine what directory this file is in set dir = `dirname $1` set file = `basename $1` # # create our sub-directories if they do not already exist # if ( ! -e $dir/$old )