#!/bin/sh
#
# Launch script for Adobe ShowPS PostScript Previewer
# Copyright 1994, Adobe Systems Incorporated
#
MAJOR_VERSION=1
MINOR_VERSION=0
REVISION=5d
LAST_INSTALL_DATE=FilledInByPostinstall
#
EXECNAME=showps_exec
INSTALL_DIR=FilledInByPostinstall
if [ ! -d "$INSTALL_DIR" ] ; then
    INSTALL_DIR=${SHOWPS_HOME:-"/usr/adobe/ShowPS_${MAJOR_VERSION}.${MINOR_VERSION}.5"}
    if [ ! -d "$INSTALL_DIR" ] ; then
	# Try to determine automatically the parent directory to this launch script.
	thisscriptname=$0

	# Follow any symbolic links in thisscriptname.
	while : ; do
		lsresult=`ls -l $thisscriptname`
		symlink=`expr "$lsresult" : '.*>'.*`

		if [ "$symlink" -gt 0 ] ; then
			oldscriptname="$thisscriptname"
			thisscriptname=`echo $lsresult | sed -e 's/^.*-> *\(.*\) *$/\1/g'`
			abspath_new=`expr "$thisscriptname" : '^/'`
			if [ $abspath_new != 1 ] ; then
				abspath_old=`expr "$oldscriptname" : '^/'`
				if [ $abspath_old != 1 ] ; then
					olddir=`pwd`
				else
					olddir=`expr "$oldscriptname" : '\(.*\)/'`
				fi
				thisscriptname="$olddir/$thisscriptname"
			fi
		else
			break
		fi
	done

	# Determine directory containing this shell script.
	scriptdir=`expr $thisscriptname : '\(.*\)/'` 
	if [ "$scriptdir" = "" -o "$scriptdir" = "." ] ; then
		scriptdir=`pwd`
	fi

	# Determine root directory for installation ($scriptdir/..).
	parentdir=`expr $scriptdir : '\(.*\)/'` 

	if [ -r "$parentdir/exec/$EXECNAME" ] ; then
		INSTALL_DIR="$parentdir"
	fi
    fi
fi
if [ ! -d "$INSTALL_DIR" ] ; then
    echo "showps: Error: can't find ShowPS program."
    exit 1
fi
LOCAL_APPDEFS="$INSTALL_DIR/app-defaults/Showps"
EXEC_DIR="$INSTALL_DIR/exec"
XFILESEARCHPATH="${LOCAL_APPDEFS}${XFILESEARCHPATH:+:$XFILESEARCHPATH}"
XKEYSYMDB="${XKEYSYMDB:-$INSTALL_DIR/app-defaults/XKeysymDB}"
XNLSPATH="${XNLSPATH:-$INSTALL_DIR/app-defaults/nls}"
export XKEYSYMDB
export XFILESEARCHPATH
export XNLSPATH
exec $EXEC_DIR/$EXECNAME ${1+"$@"}
