From: Michael Smith Date: Wed, 30 Mar 2005 07:35:29 +0000 (+0000) Subject: intial add; hack to find trang in a "portable" way, and run it X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c1e57ab7e55cb50f00fa8d542a416ace38f89f45;p=docbook-dsssl intial add; hack to find trang in a "portable" way, and run it --- diff --git a/cvstools/runtrang b/cvstools/runtrang new file mode 100755 index 000000000..2aaf260cc --- /dev/null +++ b/cvstools/runtrang @@ -0,0 +1,52 @@ +#!/bin/bash + +# $Id$ + +# This script attempts to find and run trang with "simple" +# conversions (one input file and output file specified, with no +# other arguments). +# +# Usage: trang + +# if trang is found in CLASSPATH, then call trang "manually" +if [[ $CLASSPATH == *trang* ]]; then + TRANG="java com.thaiopensource.relaxng.translate.Driver"; +else + # otherwise, try to find trang.jar using the "locate" command + if [ "$(locate tng.jar)" ]; then + for jar in `locate trang.jar`; do + TRANG="java -jar $jar"; + break; + done + else + # otherwise, look in a few likely places + if \ + [ -f "/usr/share/java/trang.jar" ] || \ + [ -f "/usr/local/java/trang.jar" ] || \ + [ -f "/usr/local/share/java/trang.jar" ]; then + for jar in \ + "/usr/share/java/trang.jar" \ + "/usr/local/java/trang.jar" \ + "/usr/local/share/java/trang.jar"; do + if [ -f "$jar" ]; then + TRANG="java -jar $jar" + break + fi + done + else + # otherwise, look for a non-jar "trang" executable (as in Debian) + if [ "$(which trang)" ]; then + TRANG=`which trang`; + fi + fi + fi +fi + +# if trang was found, run it +if [ -n "$TRANG" ]; then + echo $TRANG $1 $2 +else + # otherwise, exit with an error + echo "error: cannot locate trang" 1>&2 + exit 1 +fi