#! /bin/sh
# match:    Time-stamp: <2004-11-02 16:15:44>
#
S="grep -i "
if test $# -ge 1
then
    case $1 in
        -v) S="grep -iv " ; shift ;;
	-o) shift; match_or $*; exit;;
	-h)
	    echo match - a grep pipeline;
	    echo 'Usage: match [-v] {pat}';
	    echo 'Eg: cat file | match str1 str2 str3'
	    echo '     is equivalent to:'
	    echo '    cat file | grep -i str1 | grep -i str2 | grep -i str3'
	    echo '    match -v makes it grep -iv'
	    echo '    match -o calls match_or'
	    echo '       (Enter "match -o -h" for more info)'
	    exit
	    ;;
    esac
fi
case $# in
    0) cat - ;;
    1) $S $1 ;; 
    2) $S $1 | $S $2 ;;
    3) $S $1 | $S $2 | $S $3 ;;
    4) $S $1 | $S $2 | $S $3 | $S $4 ;;
    5) $S $1 | $S $2 | $S $3 | $S $4 | $S $5 ;;
    6) $S $1 | $S $2 | $S $3 | $S $4 | $S $5 | $S $6 ;;
    7) $S $1 | $S $2 | $S $3 | $S $4 | $S $5 | $S $6 | $S $7 ;;
    8) $S $1 | $S $2 | $S $3 | $S $4 | $S $5 | $S $6 | $S $7 | $S $8 ;;
    9) $S $1 | $S $2 | $S $3 | $S $4 | $S $5 | $S $6 | $S $7 | $S $8 | $S $9 ;;
    *) echo 'too many qualifiers (max is 9)'
       echo "Usage qualify qualifier ... ";;
esac

exit