Next Previous Contents

25. slist

NOTE : Get the Korn shell /bin/ksh by installing pdksh*.rpm from the Linux contrib cdrom

Save this file as a text file and chmod a+rx on it.

Note that there is also another Unix command by the name slist (list available Netware servers). You should make sure the CVS script slist comes before other in your PATH environment.


#!/bin/ksh

# CVS program slist
# Program to list all edited source files from CVS

# Every filename is composed of 3 parts - Home directory, sub-directory 
# and the filename. The full-path is $HOME/$subdir/$fname
# And in CVS the same directory structure is maintained (by 
# variable $subdir) therefore in cvs we will have $CVSROOT/$subdir/$fname
# In this program these 4 variables $HOME, $CVSROOT, $subdir and $fname
# play an important role. For example, sample values can be like
# HOME=/home/aldev, subdir=myproject/src CVSROOT=/home/cvsroot 
# and fname=foo.cpp

# Caution: Put double-quotes to protect the variables having 
#          spaces, like "$HOME/$subdir" if subdir is 'some foo.cpp'

# Usage:
#               $ slist      (All files and sub-directories)
#               $ slist *.*      (All files)
#               $ slist *      (All files and sub-directories)
#               $ slist ab*      (All files starting with ab wild-card)

homedir=` echo $HOME | cut -f1 -d' '  `
if [ "$homedir" = "" ]; then
        print "\nError: \$HOME is not set!!\n"
        exit
fi

cur_dir=`pwd`
#echo $cur_dir

len=${#homedir}
len=$(($len + 2))
#echo $len

subdir=` echo $cur_dir | cut -b $len-2000 `
#echo "subdir is : " $subdir

# If file is already checked out by another developer....
cvs_root=` echo $CVSROOT | cut -f1 -d' '  `
if [ "$cvs_root" = "" ]; then
        print "\nError: \$CVSROOT is not set!!\n"
        exit
fi

# If the current directory tree is not in cvs-root then exit
if [ ! -d $CVSROOT/$subdir ]; then
        print "\nThe directory $subdir does not exist in $CVSROOT"
        exit
fi

#echo "no of params : " $#
#echo "The arg $ 1 is : " $1
#echo "all args : " $@

if [ $# -eq 0 ]; then
        #tmpbb=` find * -prune -type d `
        tmpbb=` find * -maxdepth 0 -type d `
elif [ $# -eq 1 ]; then
        if [ "$1" = "." ]; then
                #tmpbb=` find * -prune -type d `
                tmpbb=` find * -maxdepth 0 -type d `
        else
                if [ -d $1 -a ! -d $CVSROOT/$subdir/$1 ]; then
                        print "\nThe directory $subdir/$1 does not exist in $CVSROOT"
                        exit
                fi
                tmpbb=$@
        fi
else
        tmpbb=$@
fi

#echo "The tmpbb is : " $tmpbb

# Now, remove all the directory names which are not in cvs-root
dirnames=""
for ii in $tmpbb ; do
        if [ -d $CVSROOT/$subdir/$ii ]; then
                dirnames="$dirnames $ii "
        fi
done
#echo "The dirnames is : " $dirnames

if [ "$dirnames" != "" ]; then
        find $dirnames  -type f |
        while read ii
        do
                # List only those files which are in cvs system
                if [ -f "$CVSROOT/$subdir/$ii,v" ]; then
                        #echo "ii is : " $ii
                        ls -l $ii | grep ^\-rw
                fi
        done;
fi

# Get all the files in the current directory
listfiles=`ls $tmpbb `
# Option prune does not work use maxdepth
#find * -prune -type f |
find * -maxdepth 0 -type f |
while read ii
do
        for jj in $listfiles ; do
                if [ "$jj" = "$ii" ]; then
                        # List only those files which are in cvs system
                        if [ -f "$CVSROOT/$subdir/$ii,v" ]; then
                                #echo "ii is : " $ii
                                ls -l $ii | grep ^\-rw
                        fi
                fi
        done
done;


Next Previous Contents