summaryrefslogtreecommitdiffstats
path: root/c/build-tools/rcs-clean.in
blob: 83fed051282e98a63ce804155e909f8c2a1104f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!@KSH@ -p
#
#  $Id$
#
# Delete all files from the current directory that can be recreated
#  via RCS 'co' commonds
# Used by 'make clobber'
#

progname=${0##*/}        # fast basename hack for ksh, bash

USAGE=\
"usage: $progname [ -v ]"

fatal() {
    if [ "$1" ]
    then
        echo $* >&2
    fi
    echo "$USAGE" 1>&2
    exit 1
}

#
# process the options
#

verbose=""

while getopts v OPT
do
    case "$OPT" in
	v)
	    verbose="yes";;
        *)
            fatal
    esac
done

let $((shiftcount = $OPTIND - 1))
shift $shiftcount

args=$*
[ "$args" ] && fatal

[ -d RCS/. ] || exit 0

# there is probably a better way to do this

rcs_files=`echo RCS/*,v | sed -e 's?RCS/??g' -e's/,v//g'`

kills=""
for f in $rcs_files
do
   # build list of all files in RCS/*,v that are *not* locked
   if [ -f $f ] && [ ! -w $f ] && [ -f RCS/$f,v ]
   then
        locked=`rlog -L -R $f`
        [ "$locked" = "" ] && kills="$kills $f"
   fi
done

if [ "$kills" ]
then
     [ "$verbose" ] && echo rm -f $kills
     rm -f $kills
fi

exit 0

# Local Variables: ***
# mode:ksh ***
# End: ***