#!/bin/bash

TREDLIB="."

if [ ! -f ${TREDLIB}/indentperl.el ]; then 

  TREDLIB="./tredlib"
  echo trying $TREDLIB

  if  [ ! -f ${TREDLIB}/indentperl.el ]; then

    TREDLIB=`dirname $0`/../lib/tredlib
    echo trying $TREDLIB
  
    if  [ ! -f ${TREDLIB}/indentperl.el ]; then

      TREDLIB=`dirname $0`/../lib/tred
      echo trying $TREDLIB

      if  [ ! -f ${TREDLIB}/indentperl.el ]; then

	TREDLIB=`dirname $0`/tredlib
	echo trying $TREDLIB
      fi

    fi


  fi

fi

if [ -f ${TREDLIB}/indentperl.el ]; then 

  echo Using indentperl.el from $TREDLIB directory
  emacs -batch $* -l ${TREDLIB}/indentperl.el

else

  echo Sorry, could not find indentperl.el in $TREDLIB!
  echo You may try to locate it and use the following command:
  echo '   > emacs -batch $* -l the_right_path_to/indentperl.el'
  echo 

fi