
###############################################################################
#                                                                             #
#               GNU Interactive Tools 4.3.7 recursive grep script             #
#               Copyright (C) 1994 Free Software Foundation, Inc.             #
#                   Written by Tudor Hulubei and Andrei Pitis.                #
#                                                                             #
###############################################################################

#
# /bin/sh should support functions in order to run this script.
# Use bash to be sure. Since few systems have bash as /bin/sh, I
# didn't put #!/bin/sh at the begining of this file.
#
# Standard Bourne shell users should delete the function keyword.
#

function parse
{
#    set -xv

#   Thanks to Han Holl for removing the space between -c and $skip
    echo "."`pwd | cut -c$skip-`"/:"

    grep $p1 $p2 $p3 $p4 $p5 $p6 $p7 $p8 $p9 2> /dev/null

    for i in * .*
    do
        if [ -d $i -a $i != "." -a $i != ".." ]
        then
            cd $i
            parse
            cd ..
        fi
    done
}


p1="$1";p2="$2";p3="$3";p4="$4";p5="$5";p6="$6";p7="$7";p8="$8";p9="$9"

# Thanks to Han Holl for adding the sed pipe
skip=`pwd | wc -c | sed 's/ //g'`

parse
