#!/bin/sh

ARGS=""
if [ "$1" = "-l" ] ; then
  ARGS="$ARGS -l"
  shift
fi

GREPTYPE=-P
if [ "$(uname)" = "Darwin" ] ; then
  # Fall back to traditional grep on Mac, which doesn't support PCRE grep
  GREPTYPE=-G
fi

grep $GREPTYPE -n -i ${ARGS} "${1}" *.bas *.bi *.rbas | grep $GREPTYPE -i -v "^[^ ]+\.rbas\.bas:"
