#!/bin/sh
#
#  Ales Cepek, 2001
#
# $Id: gamalib_rgrep,v 1.2 2002/09/21 10:15:33 cepek Exp $

if [ "$2" = "" ]; then

sed 's/^X//' << 'GAMALIB_RGREP_EOF'      # > 'output to std' &&


usage: gamalib_rgrep  version  rgrep_par...

version         Explicit file name can be used or gamalib version. In the
		latter cace file gamalib-'version'.tgz is searched for
		in the current directory and in the directory
		./archive (if exists).

rgrep_par       archive file is extracted into a /tmp and searched by
		`rgrep -I rgrep_par...' (-I option is implicitly added)


GAMALIB_RGREP_EOF

exit 1
fi
# ----------------------------------------------------------------------------

TEMPDIR=/tmp/gamalib___$$
RGREPAR=`echo $@ | sed s/[^\ ]*[\ ]//`

WORKDIR=`pwd`
if [ -f $1 ]; then
   GAMALIB=$WORKDIR/$1
elif [ -f gamalib-$1.tgz ]; then 
   GAMALIB=$WORKDIR/gamalib-$1.tgz
else
   if [ -d $WORKDIR/archive ]; then
      GAMALIB=`find $WORKDIR/archive/* -name *$1\.*`
   fi
fi;

if [ "$GAMALIB" = "" ]; then
echo
echo gamalib $1 not found
echo
exit 1
fi

mkdir $TEMPDIR
cd    $TEMPDIR

tar xzf $GAMALIB
rgrep -I $RGREPAR .

cd /tmp
rm -rf $TEMPDIR

# echo GAMALIB : $GAMALIB
# echo TEMPDIR : $TEMPDIR
# echo RGREPAR : $RGREPAR


