# Set up ESP OS shell environment
# $Source: /home/cvs/ESP/gen2/software/esp/bin/ESPenv,v $
# $Id: ESPenv,v 1.10 2005/06/23 21:27:20 brent Exp $

home=${1-~/esp2}      #default if no home specified

# remove all fields $1 from list delminated by $2 starting with $3
# send the filtered version of $2 to stdout
remove ()
{
  toDelete=$1
  IFS=$2
  shift 2
  [ "$@" ] && {
    set $@
    unset separator
    for field; do
      if [ "$field" != "$toDelete" ]; then
        echo -n "$separator$field"
        separator=$IFS
      fi
    done
  }
}


if [ "$ESPhome" ]; then
  PATH=`remove "$ESPhome/bin" : "$PATH"`
  RUBYLIB=`remove "$ESPhome/lib" : "$RUBYLIB"`      #system library
  RUBYLIB=`remove "$ESPhome/utils" : "$RUBYLIB"`    #utility scripts
  RUBYLIB=`remove "$ESPhome/protocol" : "$RUBYLIB"` #mission protocol scripts
fi

export ESPhome=$home
export PATH=$PATH:$ESPhome/bin

# path for ESP libraries
export RUBYLIB="${RUBYLIB:+$RUBYLIB:}$ESPhome/lib:$ESPhome/utils:$ESPhome/protocol"

# path for mission and admin scripts
export ESPpath=.:$ESPhome/admin:$ESPhome/mission:$ESPhome/protocol

unset remove

# default operational mode
#possible modes include simfast, simreal, real
export ESPmode=real
