#!/bin/ksh93 # Copyright (C) 1994-2015 Werner Lemberg # Portions Copyright (C) 2015 Jens Elkner (ksh93 port) # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program in doc/COPYING; if not, write to the Free # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, # MA 02110-1301 USA typeset -r FPROG=${.sh.file} typeset -r PROG=${FPROG##*/} SDIR=${FPROG%/*} # Usually the name of the converter + ${TEXCMD} is the name of this script. # So we deduce: [[ ${PROG: -8:8} == 'pdflatex' ]] && TEXCMD='pdflatex' || TEXCMD='latex' X=${PROG:0:3} [[ $X == 'gbk' || $X == 'bg5+' ]] && \ CONV='extconv' || CONV="${PROG%${TEXCMD}}conv" X=${ whence ${CONV} ; } [[ -z $X ]] && print -u2 '${CONV} tool not found - exiting.' && exit 1 integer N=1 ARGV= # get last argument while (( $# > 1 )); do eval ARGV$N=\$1 # JEL: why eval here?, and again later? ARGV="${ARGV} \"\${ARGV}$N\"" (( N++ )) shift done # replace extension with .cjk or append .cjk if there is no extension TEX=$1 [[ -z ${TEX} || ${TEX: -4:4} == '.cjk' ]] && \ print -u2 "Usage: ${PROG} [options] ${TEXCMD}-file" && exit 1 X="${TEX##*/}" EXT="${X##*.}" [[ -n ${.sh.match} ]] && AUX="${TEX%${EXT}}.cjk" || AUX="${TEX}.cjk" ${CONV} < "${TEX}" > "${AUX}" && eval ${TEXCMD} "${ARGV}" "\${AUX}"