#!/bin/sh
autoepicsScriptname=autoepics
status=0
#sourced call of this routine "leading ." ?, if not print Help
if [ ${0##*/} = $autoepicsScriptname ]; 
then  
        echo Error: $epicsScriptname: script has not been called with a leading '. ', exiting! >&2  
	status=1
else
	if [ -f configure/RELEASE ]
        then 
		home=$(dirname $(grep ^EPICS_BASE configure/RELEASE | tail -n 1 | cut -d "="  -f 2)); 
		. epics -P "" -H $(dirname $home) $(basename $home)
	else
		echo Error: $epicsScriptname: directory/file 'configure/RELEASE' does not exist>&2
		status=1
	fi
fi
unset home
unset autoepicsScriptname
#last line
[ $status -ne 0 ] || ( 	unset status; false; ) && ( unset status; true; )
