#!/bin/bash
#--------------------------------------------------------------------------------
#	Licensed Program Product:
#	VisualAge for Smalltalk for Linux
#
#	(C) COPYRIGHT International Business Machines Corp. 1995, 2002
#	All Rights Reserved
#
#	US Government Users Restricted Rights - Use, duplication or
#	disclosure restricted by GSA ADP Schedule Contract with
#	IBM Corp. and its licensors.
#
#--------------------------------------------------------------------------------

if [ -z "$VAST_60_ENV_SET" ]
then

	# Ensure that the environment variables get set only once -- even when
	# this script gets called recursively.
	export VAST_60_ENV_SET=yes

	if [ -d /opt/IBMvast/6.0/server ]
	then
		export VASTROOT_60=${VASTROOT_60:-/opt/IBMvast/6.0/server}
	else
		export VASTROOT_60=${VASTROOT_60:-/opt/IBMvast/6.0}
	fi
	export PATH=$VASTROOT_60/bin:$PATH

	#
	# Setup platform-specific shared library search path
	#
	abtslpath=$VASTROOT_60/bin

	if [ ! -z "$DB2INSTANCE" ]
	then
			eval 'cd ~'${DB2INSTANCE}
	abtinstpath=`(pwd)`
	abtslpath=$abtslpath:$abtinstpath/sqllib/lib
	cd -
	fi

	if [ ! -z "$ORACLE_HOME" ]
	then
		abtslpath=$abtslpath:$ORACLE_HOME/lib
	fi

	export LD_LIBRARY_PATH=$abtslpath:$LD_LIBRARY_PATH
	export PATH=$abtslpath:$PATH 
fi

#
# Image location logic:
#
# 1. If "-i<imagename>" was specified, use it.
#    NOTE:  -ini:<optionfilename> has been added as a valid parm and
#           must be accounted for in the following test
# 2. Otherwise, check for "<shellName>.icx".  If present, use it.
# 3. Otherwise, 'es' will default to "image".

IMAGE=""
IOPTION=0

# NOTE:  VA ST options don't conform to standard Unix syntax since the
#        parameter MUST be immediately adjacent to the option AND
#        multicharacter options are supported.  This means that we can't
#        use getopts to parse the command line!
for KEY in $*
do
  test ${KEY#-i} != $KEY  &&  test ${KEY#-ini:} = $KEY  &&  IOPTION=1
done
test  $IOPTION -eq 0  &&  test -r $0.icx  &&  IMAGE="-i$0.icx"

$VASTROOT_60/bin/esnx -no_break $IMAGE $*


