#!/bin/ksh93 # Copyright (C) 2004, Thomas Esser. Public domain. # 2005-03-08: New option "--crop", Rolf Niepraschk. # dvips call only if the dvi file exist (RN). # 2005-06-27: ps2pdf call only if the ps file exist (RN). # 2006-04-05: "\RequirePackage{pst-pdf}" added to the (pdf)LaTeX calls # as suggested by Niall Murphy. # 2006-07-14: Better temp dir handling (suggested by Karl Berry) (RN). # 2006-07-23: New option --Xps2pdf and code cleanup (thanks to Karl Berry) (RN). # 2008-08-04: Remove the parameter "-Ppdf" from the dvips call (RN). VERSION='1.0' typeset -r FPROG=${.sh.file} typeset -r PROG=${FPROG##*/} SDIR=${FPROG%/*} function showUsage { [[ -z $1 ]] && X='--man' || X='-?' getopts -a ${PROG} "${ print ${USAGE} ; }" OPT $X } TFILE= function cleanup { cd [[ -n ${TFILE} && -f ${TFILE} ]] && rm -f ${TFILE} } ############################################################################### # myexec(args) # execute the command given as "args"; abort on error; redirect messages to # log in "silent" mode; redirect stdin (${TFILE} 2>&1 ps -> pdf processor] [+DESCRIPTION?Process LaTeX document FILE using the pst-pdf package, including running \blatex\b(1), \bdvips\b,(1) and \bps2pdf\b(1) as necessary.] [h:help?Print this help and exit.] [F:functions?Print a list of all functions available.] [T:trace]:[fnList?A comma separated list of functions of this script to trace (convinience for troubleshooting).] [+?] [X:Xps2pdf]:[opt?Pass \aopt\a to ps2pdf ("-dAutoRotatePages=/None" is always passed). Quote the argument to avoid headaches!] [c:crop?Run pdfcrop on ps2pdf output.] [v:verbose?Do not run in "quiet" mode.] [q:quiet?Quiet mode - show the output of sub processes only if an error occured. Also run them in non-interactive mode (use /dev/null as stdin).] [V:version?Print version information and exit.] \n\n\afile\a ' X="${ print ${USAGE} ; }" unset OPTS; typeset -a OPTS=( '-dAutoRotatePages=/None' ) integer SILENT=1 CROP=0 while getopts "${X}" OPT ; do case ${OPT} in h) showUsage ; exit 0 ;; T) if [[ ${OPTARG} == 'ALL' ]]; then typeset -ft ${ typeset +f ; } else typeset -ft ${OPTARG//,/ } fi ;; F) typeset +f && exit 0 ;; c) CROP=1 ;; q) SILENT=1 ;; v) SILENT=0 ;; V) print -u2 "${PROG} version ${VERSION}" ; exit 0 ;; X) X+=( "${OPTARG}" ) ;; esac done X=$((OPTIND-1)) shift $X && OPTIND=1 unset X trap cleanup EXIT doMain "$@"