
#!/bin/sh
if [ ! -r ENVIRONMENT ]
then
	echo "You must be in the top S-PLUS directory when SETUP is run."
	exit 1
fi

# Check to see if they move an old version of S-PLUS to old.version.
# If so, run that $A/ENVIRONMENT and then create an oldSplus shell script. 

if [ -r old.version/ENVIRONMENT ]
then
	# setup the old environment
	WHERE=`pwd`
	cd old.version
	OLDHOME=$HOME
	HOME=`pwd`; export HOME
	SHOME=`pwd`; export SHOME
	. ./ENVIRONMENT
	if [ -x adm/cmd/SETUP.Splus ]
	then
		adm/cmd/SETUP.Splus > /dev/null 2>&1 
	fi

	# reset old stuff
	cd $WHERE
	HOME=$OLDHOME; export HOME

	# check to make sure the above worked okay
	if [ -x old.version/Splus ]
	then
		mv old.version/Splus oldSplus
		echo
		echo "Created the shell script \"oldSplus\" which will start your old version"
		echo "of S-PLUS.  Edit \"oldSplus\" and install it next to the Splus shell script."
		echo
	else
		echo
		echo "Unable to create the \"oldSplus\" shell script for your previous version."
		echo
	fi
fi

# make the new stuff
. ./ENVIRONMENT

$A/SETUP.Splus
