#! /bin/sh
#
#  use NeXT display PostScript to convert a PostScript file to Adobe
#  Illustrator 

#  by George White <gwhite@trevnx.bio.dfo.ca>
#
PSPATH=/LocalApps
LOCALPATH=/NextDeveloper/Apps
PATH=/bin:/usr/bin:/usr/ucb\:$LOCALPATH\

export PATH outfile
usage="Usage: $0 file.ps [file.ext]"

if [ $# = 0 ] ; then
  echo $usage ; exit 1
fi

case $# in
1|2) infile=$1
   ;;
*)	echo $usage 1>&2
	exit 1
   ;;
esac

infile=$infile

if [ $# -eq 1 ]
then
	case "${infile}" in
	  *.ps)		base=`basename ${infile} .ps` ;;
	  *.ai)		base=`basename ${infile} .ai` ;;
	  *.cps)	base=`basename ${infile} .cps` ;;
	  *.eps)	base=`basename ${infile} .eps` ;;
	  *.epsf)	base=`basename ${infile} .epsf` ;;
	  *)		base=`basename ${infile}` ;;
	esac
	outfile=${base}.ai
else
	outfile=$2
fi

case $infile in 

/* ) ;;
*) infile=`pwd`/$infile
   ;;
esac
case $outfile in 

/* ) ;;
*) outfile=`pwd`/$outfile
   ;;
esac

cat <<XXX >/tmp/ps2ai.$$.ps
%!
/jout true def            % true=file 

/joutput ($outfile) def   % Name of Output file
/jinput ($infile) def   % Name of Input file
XXX
cat $PSPATH/ps2ai.ps $infile >>/tmp/ps2ai.$$.ps
open -a Yap.app /tmp/ps2ai.$$.ps
echo To create $outfile, execute in Yap


