#!/bin/bash # Paul Jolly # # makelatex # # Usage: # # makelatex [root_tex_file.tex] make_arg1 make_arg2 ... # # As indicated, the root_tex_file.tex argument is optional. If supplied and the file exists, # texdep is called on that file followed by a make on the generated Makefile with make_args # passed as a parameter. # # If the root_tex_file.tex argument isn't supplied, makelatex scans the current directory for # .tex files. Only in the event that one .tex file is found are texdep and make subsequently called # as above. Otherwise the call to makelatex is ambiguous (more than one .tex file) or nonsensical # (no .tex files exist). if expr "$1" : '.*\(\.tex\)$' &> /dev/null then if ! test -f $1 then echo "File $1 not found." exit 1 fi tex_file=$1 shift fi if [ "$tex_file" = "" ] then num_texs=`find -maxdepth 1 -name "*.tex" | wc -l` if [[ $num_texs = 0 ]] then echo "No TeX file supplied or found in current directory" exit 2 elif [[ $num_texs > 1 ]] then echo "Multiple TeX files found in current directory. Please specify one as the first argument." exit 3 else tex_file=`/bin/ls *.tex` fi fi if ! [ "$*" = "" ] then make_args="$*" fi texdep $tex_file && exec make $make_args