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

export VASTROOT_55=${VASTROOT_55:-/opt/IBMvast/5.5/server}
export PATH=$VASTROOT_55/bin:$PATH

#
# Setup platform-specific shared library search path
#
abtslpath=$VASTROOT_55/bin:/usr/dt/lib

if [ ! -z "$DB2INSTANCE" ]
then
	abtslpath=$abtslpath:$(echo ~$DB2INSTANCE)/sqllib/lib
fi

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

typeset -l platform=$(uname)
case $platform in
  aix)
    export LIBPATH=$abtslpath:$LIBPATH ;;
  hp-ux)
    export SHLIB_PATH=$abtslpath:$SHLIB_PATH ;;
  sunos)
    export LD_LIBRARY_PATH=$abtslpath:/usr/ucblib:/usr/openwin/lib:$LD_LIBRARY_PATH ;;
esac

#
# 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_55/bin/esnx -no_break $IMAGE $*

