#!/bin/sh
# Free text search

help () {
  echo "Free text search in the source code"
  echo "Options:"
  echo "-p  Search only python code."
  exit
}

if test "x$1" = "x-p" ; then
  if test "x$2" = "x" ; then
    help
  fi
fi

if test "x$1" = "x-h" ; then
  help
fi

if test "x$1" = "x" ; then
  help
fi

if test "x$1" = "x-p" ; then
  find -name "*.py" | xargs egrep --color=auto -n "$2" Makefile.in
else
  find -name "*.py" | xargs egrep --color=auto -n "$1" Makefile.in
  egrep "$1" -d recurse --color=auto exercises/standard/lesson-files/*
  find -name Makefile | xargs egrep --color=auto  -n "$1"
  egrep --color=auto -n "$1" *.xml
  cd help/C && find | xargs egrep -d recurse --color=auto -n "$1"
fi
