#!/bin/sh
# This script is called by ACEDB Pick_me_to_call records.
# It copies the file to a temporary file in the current working directory, 
# and then runs the appropriate viewer. After viewing, the 
# temporary file is deleted.  
# $ACE_EDIT_COMMAND is the name of the program. 
# $1 is the file for the program to use.

# RM_CMD - command to be used for removing files and directories
if [ -f /usr/bin/rm ]
	then
   RM_CMD=/usr/bin/rm
else
   if [ -f /bin/rm ]
   	then
      RM_CMD=/bin/rm
   else
      RM_CMD=rm
   fi
fi

#Choose a WYSIWIG editor for viewing ASCII files. 
# Xcoral is a nice alternative. However, due to typical shell weirdness,
# trying to execute external programs (other than xv, for some reason)
#gives getwd errors. So, the fix is to have a shell script in a
#fully qualified path, that does what we want.
if [ -z ${ACE_EDIT_COMMAND} ]
   then
     ACE_EDIT_COMMAND=xemacs
fi
export ACE_EDIT_COMMAND


#echo Copying $1

tempfile=acedb_$$
cp $1 ./$tempfile

#ls -l ./$tempfile

($ACE_EDIT_COMMAND $tempfile; $RM_CMD -f $tempfile) &