die () { message="$1" echo "$tool -> .local_tool_wrapper: $message Exiting ..." exit 1 } ############################ main ############################## tool=`basename $0` ARGV="$*" TRE_PROJECT=$DV_ROOT if [ -z "$TRE_PROJECT" ]; then die "TRE_PROJECT not defined" fi TRE_ROOT=$TRE_PROJECT/tools TOOL_ROOT=$TRE_PROJECT/tools/perlmod/$tool ### Verify TRE_SEARCH and TRE_ENTRY are defined and non-null if [ -z "$TRE_SEARCH" ]; then die "TRE_SEARCH not defined" fi if [ -z "$TRE_ENTRY" ]; then die "TRE_ENTRY not defined" fi ### Get version, based on tool invoked, and $TRE_ENTRY version=`configsrch $tool $TRE_ENTRY` if [ $? != 0 ] ; then die "configsrch returned error code!" fi ### Verify configsrch delivered a non-null version if [ -z "$version" ]; then die "No version set by configsrch" fi ### Assemble directory-oriented executable ... ### (eliminate the extra layer of shell redirection...) exe=$TOOL_ROOT/$version/bin/$tool if [ -x $exe ]; then exec $exe "$@" fi ### Assemble do-file name. If it's there, execute and test status. exe=$TRE_ROOT/$tool,$version.do if [ -x $exe ]; then $exe dostat=$? if [ $dostat != 0 ] ; then die "Error return from do file" fi fi exe=$TRE_ROOT/$tool,$version if [ -x $exe ]; then exec $exe "$@" else die "executable $exe not found!" fi ### If none of the above executable patterns hit, then die with errors... echo "FATAL: Couldn't find any executable form:" echo "FATAL: $TOOL_ROOT/$version/bin/$tool" echo "FATAL: $TRE_ROOT/$tool,$version.do" echo "FATAL: $TRE_ROOT/$tool,$version" die "FATAL: $tool executable not found!"