3 # run-fop: Attempt to run fop (or fop.sh), fail articulately otherwise.
5 # Usage: run-fop.sh [FOP_ARGS...]
7 # This script is meant to be invoked by book translation Makefiles.
8 # Arguments are passed along to `fop'.
10 # If the user has a .foprc, source it.
11 if [ -f ${HOME}/.foprc
]; then
15 # The fop of last resort.
16 DESPERATION_FOP_DIR
="`dirname \"$0\"`/../fop"
17 DESPERATION_FOP_PGM
=${DESPERATION_FOP_DIR}/fop.sh
19 if [ "${FOP_HOME}X" = X
]; then
20 FOP_HOME
=${DESPERATION_FOP_DIR}
25 # Unfortunately, 'which' seems to behave slightly differently on every
26 # platform, making it unreliable for shell scripts. Just do it inline
27 # instead. Also, note that we search for `fop' or `fop.sh', since
28 # different systems seem to package it different ways.
31 PATH
=${PATH}:${FOP_HOME}
32 for dir
in ${PATH}; do
33 if [ -x ${dir}/fop
-a "${FOP_PGM}X" = X
]; then
35 elif [ -x ${dir}/fop.sh
-a "${FOP_PGM}X" = X
]; then
41 if [ "${FOP_PGM}X" = X
]; then
42 FOP_PGM
=${DESPERATION_FOP_PGM}
45 echo "(Using '${FOP_PGM}' for FOP)"
47 # FOP is noisy on stdout, and -q doesn't seem to help, so stuff that
48 # garbage into /dev/null.
49 ${FOP_PGM} $@ |
grep -v "\[ERROR\]"