#!/bin/sh
# cvsupdate -- update all my CVS projects (or the current directory)
#
# SUMMARY: If you give this no parameters,
#          it looks first in the current directory, if that's a CVS directory,
#          then it acts like cvs -q update -d -P.
#          If there are no arguments,
#          and if the current directory isn't a CVS directory, then
#          it updates all of the immediate subdirectories of . that are CVS
#          directories.
#          If you give it arguments, it updates all of the given directories.
#          This is useful if you don't want to set CVSROOT on cygwin, where
#          the script incorrectly checks CVSROOT first before looking
#          in the directories.
#
# AUTHOR: Gary T. Leavens

[ -n "$echo" ] && set -x

USAGE='cvsupdate [dir] ...'

# no options allowed
case "$1" in
-*)
	echo "$USAGE" >&2
	exit 2
	;;
esac

if test $# -eq 0
then
	if test -d CVS
	then
		CVSDIRS='.'
	else
		: ${CVSDIRS=`echo */CVS | sed -e 's@/CVS@@g'`}
	fi
else
	CVSDIRS="$@"
fi

ret=0

for d in $CVSDIRS
do
	cd $d && echo $d
	cvs -q update -d -P || ret=1
	cd ..
done

exit $ret
