File: cvs.recursadd

package info (click to toggle)
grass 6.0.2-6
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 40,044 kB
  • ctags: 31,303
  • sloc: ansic: 321,125; tcl: 25,676; sh: 11,176; cpp: 10,098; makefile: 5,025; fortran: 1,846; yacc: 493; lex: 462; perl: 133; sed: 1
file content (95 lines) | stat: -rwxr-xr-x 2,455 bytes parent folder | download | duplicates (3)
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/sh
#
# recursive CVS add/commit with comment
#
# written by Markus Neteler 3/2000
# based on useful hints by Bernhard Reiter
# $Id: cvs.recursadd,v 1.5 2003/02/08 21:30:18 markus Exp $

# what to do in case of user break:
function exitprocedure()
{
 echo "User break!"
 exit 1
}
# shell check for user break (signal list: trap -l)
trap "exitprocedure" 2 3 9 15


# add files recursivly to CVS
if [ $# = 0 -o "$1" = "" -o "$1" = "help" -o "$1" = "-h" -o "$1" = "-help" ]
    then
     echo "USAGE: cvs.r.add comment"
     echo "  This command runs recursively within a directory tree"
     echo "  'cvs add' and 'cvs commit' are called within the script."
    else
     comment=$1
fi

if [ ! "$comment" ]
then
   exit
fi

echo "Walking through the tree..., ignore CVS dirs and OBJ dirs"

if test -d CVS
then
 echo "CVS dir is already present. Please check that."
 exit 1
fi

#add the current directory
current=`pwd |tr / ' '|wc -w`         # count the words in path
current=`expr $current + 1`
local_dir=`pwd| cut -d'/' -f$current` # get the name
cd ..
#-------------------------------------
# insert the job here:
 currpwd=`pwd`
 echo "cvs add $local_dir [$currpwd]"
 cvs add $local_dir
#-------------------------------------
cd $local_dir

echo "Adding the files in current directory to CVS (if any)..."
files=`find . -type f -maxdepth 1`
count=`echo $files |wc -w`
if [ $count -gt 0 ]; then
      cvs add $files
      cvs ci -m"$comment" $files
fi

echo "Proceeding..."
dirnames=`find . -type d |grep -v CVS |grep -v OBJ`
for i in $dirnames ; do
   pushd . >/dev/null
   cd $i
   # get the last directory name:
   words=`echo $i |tr / ' '|wc -w`         # count the words
   local_dir=`echo $i| cut -d'/' -f$words` # get the name
   if [ $local_dir != "." ]; then          # don't work on current dir
#-------------------------------------
# insert the job here:
   currpwd=`pwd`

   echo "cvs add $local_dir [$currpwd]"
   cd ..                                   # we were already inside
   cvs add $local_dir
   cd $local_dir                           # o.k. now jump into it

   echo "Add the files in current directory to CVS (if any)..."
   files=`find . -type f -maxdepth 1`
   count=`echo $files |wc -w`
   if [ $count -gt 0 ]; then
    echo files found
      cvs add $files
      cvs ci -m"$comment" $files
   fi
   cd ..
#-------------------------------------
   popd >/dev/null
   fi
done

echo "The End. You may check with cvs update"