#! /bin/sh## Shell script to run FOP, adapted from the Jakarta-Ant project.if[-f$HOME/.foprc];then.$HOME/.foprc
fi# OS specific support. $var _must_ be set to either true or false.cygwin=false;darwin=false;case"`uname`"inCYGWIN*)cygwin=true;;Darwin*)darwin=true;;esacif[-z"$FOP_HOME"];then# try to find FOPif[-d/opt/fop];thenFOP_HOME=/opt/fop
fiif[-d${HOME}/opt/fop];thenFOP_HOME=${HOME}/opt/fop
fi## resolve links - $0 may be a link to fop's homePRG=$0progname=`basename$0`while[-h"$PRG"];dols=`ls-ld"$PRG"`link=`expr"$ls":'.*-> \(.*\)$'`ifexpr"$link":'.*/.*'>/dev/null;thenPRG="$link"elsePRG="`dirname $PRG`/$link"fidoneFOP_HOME=`dirname"$PRG"`fi# For Cygwin, ensure paths are in UNIX format before anything is touchedif$cygwin;then[-n"$FOP_HOME"]&&FOP_HOME=`cygpath--unix"$FOP_HOME"`[-n"$JAVA_HOME"]&&JAVA_HOME=`cygpath--unix"$JAVA_HOME"`[-n"$CLASSPATH"]&&CLASSPATH=`cygpath--path--unix"$CLASSPATH"`fiif[-z"$JAVACMD"];thenif[-n"$JAVA_HOME"];thenif[-x"$JAVA_HOME/jre/sh/java"];then# IBM's JDK on AIX uses strange locations for the executablesJAVACMD=$JAVA_HOME/jre/sh/java
elseJAVACMD=$JAVA_HOME/bin/java
fielseJAVACMD=java
fifiif[!-x"$JAVACMD"];thenecho"Error: JAVA_HOME is not defined correctly."echo" We cannot execute $JAVACMD"exitfiif[-n"$CLASSPATH"];thenLOCALCLASSPATH=$CLASSPATHfi# add fop.jar, which resides in $FOP_HOME/buildLOCALCLASSPATH=${FOP_HOME}/build/fop.jar:$LOCALCLASSPATH# add in the dependency .jar files, which reside in $FOP_HOME/libDIRLIBS=${FOP_HOME}/lib/*.jar
foriin${DIRLIBS}do# if the directory is empty, then it will return the input string# this is stupid, so case for itif["$i"!="${DIRLIBS}"];thenif[-z"$LOCALCLASSPATH"];thenLOCALCLASSPATH=$ielseLOCALCLASSPATH="$i":$LOCALCLASSPATHfifidone# For Cygwin, switch paths to Windows format before running javaif$cygwin;thenFOP_HOME=`cygpath--path--windows"$FOP_HOME"`JAVA_HOME=`cygpath--path--windows"$JAVA_HOME"`LOCALCLASSPATH=`cygpath--path--windows"$LOCALCLASSPATH"`fi$JAVACMD-classpath"$LOCALCLASSPATH"$FOP_OPTSorg.apache.fop.apps.Fop"$@"