#! /bin/sh
#    This is grep.sim -- a Unix script view simibm.idx on Unix systems.
#    Copyright (C) 1990  David J. Camp
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 1, or (at your option)
#    any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# [email protected]             ^     Mr. David J. Camp
# david%[email protected]    < * >   +1 314 382 0584
# ...!uunet!wugate!wubios!david      v     "God loves material things."
#
IDX=/mirrors/msdos/filedocs/simibm.idx
if test "$1" = "-help"
   then
   echo "usage: grep.sim"
   echo "   or: grep.sim PATTERN"
   echo "calls your pager displaying only lines matching PATTERN"
   echo "but also includes the directories containing the matches"
   exit 1
   fi
if test "${PAGER:=UNDEFINED}" = "UNDEFINED"
   then
   if ( `which less` > /dev/null )
       then
       PAGER=`which less`
   else
       PAGER=`which more`
       fi
   fi
if test "$1" = ""
   then
   set -- '.*'
   fi
exec simcvt < $IDX 2>&1 | \
   sed -n -e '/PD[0-9]*:<.*\..*>/{x;s/.*/ /;x;H;d;}' \
       -e "/$*/{H;g;p;s/.*//;h;}" | \
   grep -v '^$' | \
   $PAGER