chiark / gitweb /
wip make it compile; add warnings to Makefile
[inn-innduct.git] / site / getsafe.sh
1 #! /bin/sh 
2 ##  $Revision: 847 $
3 ##
4 ##  Safely get a file from the samples directory.  Usage:
5 ##      getsafe <sample> <localfile>
6 case $# in
7 2)
8     ;;
9 *)
10     echo "Can't get INN sample file:  wrong number of arguments." 1>&2
11     exit 1
12     ;;
13 esac
14
15 SRC=$1
16 DEST=$2
17
18 ##  Try RCS.
19 if [ -f RCS/${DEST},v ] ; then
20     echo "Note: ${SRC} has changed; please compare."
21     test -f ${DEST} && exit 0
22     exec co -q ${DEST}
23 fi
24
25 ##  Try SCCS.
26 if [ -f SCCS/s.${DEST} ] ; then
27     echo "Note: ${SRC} has changed; please compare."
28     test -f ${DEST} && exit 0
29     exec sccs get -s ${DEST}
30 fi
31
32 ##  File exist locally?
33 if [ -f ${DEST} ] ; then
34     cmp ${SRC} ${DEST}
35     if [ $? -eq 0 ] ; then
36         touch ${DEST}
37         exit 0
38     fi
39     echo "${SRC} has changed; please update ${DEST}"
40     exit 1
41 fi
42
43 echo Using sample version of ${DEST}
44 cp ${SRC} ${DEST}
45
46 exit 0