sandbox_status.sh revision 1.1.1.1.2.2 1 1.1.1.1.2.2 jym #! /bin/sh
2 1.1.1.1.2.2 jym #
3 1.1.1.1.2.2 jym # Copyright (C) 1995-2005 The Free Software Foundation, Inc.
4 1.1.1.1.2.2 jym #
5 1.1.1.1.2.2 jym # This program is free software; you can redistribute it and/or modify
6 1.1.1.1.2.2 jym # it under the terms of the GNU General Public License as published by
7 1.1.1.1.2.2 jym # the Free Software Foundation; either version 2, or (at your option)
8 1.1.1.1.2.2 jym # any later version.
9 1.1.1.1.2.2 jym #
10 1.1.1.1.2.2 jym # This program is distributed in the hope that it will be useful,
11 1.1.1.1.2.2 jym # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 1.1.1.1.2.2 jym # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 1.1.1.1.2.2 jym # GNU General Public License for more details.
14 1.1.1.1.2.2 jym #
15 1.1.1.1.2.2 jym # sandbox_status - identify files added, changed, or removed
16 1.1.1.1.2.2 jym # in CVS working directory
17 1.1.1.1.2.2 jym #
18 1.1.1.1.2.2 jym # Contributed by Lowell Skoog <fluke!lowell (at] uunet.uu.net>
19 1.1.1.1.2.2 jym #
20 1.1.1.1.2.2 jym # This program should be run in a working directory that has been
21 1.1.1.1.2.2 jym # checked out using CVS. It identifies files that have been added,
22 1.1.1.1.2.2 jym # changed, or removed in the working directory, but not "cvs
23 1.1.1.1.2.2 jym # committed". It also determines whether the files have been "cvs
24 1.1.1.1.2.2 jym # added" or "cvs removed". For directories, it is only practical to
25 1.1.1.1.2.2 jym # determine whether they have been added.
26 1.1.1.1.2.2 jym
27 1.1.1.1.2.2 jym name=sandbox_status
28 1.1.1.1.2.2 jym changes=0
29 1.1.1.1.2.2 jym
30 1.1.1.1.2.2 jym # If we can't run CVS commands in this directory
31 1.1.1.1.2.2 jym cvs status . > /dev/null 2>&1
32 1.1.1.1.2.2 jym if [ $? != 0 ] ; then
33 1.1.1.1.2.2 jym
34 1.1.1.1.2.2 jym # Bail out
35 1.1.1.1.2.2 jym echo "$name: there is no version here; bailing out" 1>&2
36 1.1.1.1.2.2 jym exit 1
37 1.1.1.1.2.2 jym fi
38 1.1.1.1.2.2 jym
39 1.1.1.1.2.2 jym # Identify files added to working directory
40 1.1.1.1.2.2 jym for file in .* * ; do
41 1.1.1.1.2.2 jym
42 1.1.1.1.2.2 jym # Skip '.' and '..'
43 1.1.1.1.2.2 jym if [ $file = '.' -o $file = '..' ] ; then
44 1.1.1.1.2.2 jym continue
45 1.1.1.1.2.2 jym fi
46 1.1.1.1.2.2 jym
47 1.1.1.1.2.2 jym # If a regular file
48 1.1.1.1.2.2 jym if [ -f $file ] ; then
49 1.1.1.1.2.2 jym if cvs status $file | grep -s '^From:[ ]*New file' ; then
50 1.1.1.1.2.2 jym echo "file added: $file - not CVS committed"
51 1.1.1.1.2.2 jym changes=`expr $changes + 1`
52 1.1.1.1.2.2 jym elif cvs status $file | grep -s '^From:[ ]*no entry for' ; then
53 1.1.1.1.2.2 jym echo "file added: $file - not CVS added, not CVS committed"
54 1.1.1.1.2.2 jym changes=`expr $changes + 1`
55 1.1.1.1.2.2 jym fi
56 1.1.1.1.2.2 jym
57 1.1.1.1.2.2 jym # Else if a directory
58 1.1.1.1.2.2 jym elif [ -d $file -a $file != CVS.adm ] ; then
59 1.1.1.1.2.2 jym
60 1.1.1.1.2.2 jym # Move into it
61 1.1.1.1.2.2 jym cd $file
62 1.1.1.1.2.2 jym
63 1.1.1.1.2.2 jym # If CVS commands don't work inside
64 1.1.1.1.2.2 jym cvs status . > /dev/null 2>&1
65 1.1.1.1.2.2 jym if [ $? != 0 ] ; then
66 1.1.1.1.2.2 jym echo "directory added: $file - not CVS added"
67 1.1.1.1.2.2 jym changes=`expr $changes + 1`
68 1.1.1.1.2.2 jym fi
69 1.1.1.1.2.2 jym
70 1.1.1.1.2.2 jym # Move back up
71 1.1.1.1.2.2 jym cd ..
72 1.1.1.1.2.2 jym fi
73 1.1.1.1.2.2 jym done
74 1.1.1.1.2.2 jym
75 1.1.1.1.2.2 jym # Identify changed files
76 1.1.1.1.2.2 jym changedfiles=`cvs diff | egrep '^diff' | awk '{print $3}'`
77 1.1.1.1.2.2 jym for file in $changedfiles ; do
78 1.1.1.1.2.2 jym echo "file changed: $file - not CVS committed"
79 1.1.1.1.2.2 jym changes=`expr $changes + 1`
80 1.1.1.1.2.2 jym done
81 1.1.1.1.2.2 jym
82 1.1.1.1.2.2 jym # Identify files removed from working directory
83 1.1.1.1.2.2 jym removedfiles=`cvs status | egrep '^File:[ ]*no file' | awk '{print $4}'`
84 1.1.1.1.2.2 jym
85 1.1.1.1.2.2 jym # Determine whether each file has been cvs removed
86 1.1.1.1.2.2 jym for file in $removedfiles ; do
87 1.1.1.1.2.2 jym if cvs status $file | grep -s '^From:[ ]*-' ; then
88 1.1.1.1.2.2 jym echo "file removed: $file - not CVS committed"
89 1.1.1.1.2.2 jym else
90 1.1.1.1.2.2 jym echo "file removed: $file - not CVS removed, not CVS committed"
91 1.1.1.1.2.2 jym fi
92 1.1.1.1.2.2 jym changes=`expr $changes + 1`
93 1.1.1.1.2.2 jym done
94 1.1.1.1.2.2 jym
95 1.1.1.1.2.2 jym exit $changes
96