#!/bin/ksh93 typeset -r FPROG=${.sh.file} typeset -r PROG=${FPROG##*/} SDIR=${FPROG%/*} GIND='gind.ist' GGLO='gglo.ist' function showUsage { [[ -z $1 ]] && X='--man' || X='-?' getopts -a ${PROG} "${ print ${USAGE} ; }" OPT $X } function doMain { [[ -z $1 ]] && showUsage 1 && return 1 # remember starting directory DIR="${PWD}" # loop over all files while [[ -n $1 ]]; do X="$1" [[ $X =~ / ]] && { cd "${X%/*}" || continue ; } X=${1##*/} BN="${X%.idx}" [[ -f ${BN}.idx ]] && makeindex -s ${GIND} "${BN}" [[ -f ${BN}.glo ]] && makeindex -s ${GGLO} -o "${BN}.gls" "${BN}.glo" cd "${DIR}" done } USAGE='[-?1.0 ] [+NAME?'"${PROG}"' - a makeindex wrapper] [+DESCRIPTION?'"${PROG}"' is a simple wrapper around \bmakeindex\b(1). The script changes into the directory of each given index \afile\a and calls \bmakeindex\b(1) if a corresponding index file already exists. It is using the styles \b'"${GGLO}"'\b for \b*.idx\b and \b'"${GIND}"'\b for \b.glo\b index files.] [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).] \n\n\afile\a[\b.idx\b] ... ' X="${ print ${USAGE} ; }" 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 ;; esac done X=$((OPTIND-1)) shift $X && OPTIND=1 unset X doMain "$@"