@@ -388,65 +388,10 @@ TEMP_PDF_FILE="$(basename ${input_file}).pdf"
388388
389389LATEX_LOG=" ${build_dir} /latex.log"
390390
391- # Get the time in Unix epoch milliseconds of the given line
392- timestamp_of () {
393- local LINE=" $1 "
394- local TIMESTAMP=$( echo " ${LINE} " | cut -d ' ' -f 1 | tr -d " []" )
395-
396-
397- local SECONDS=$( echo " ${TIMESTAMP} " | cut -d ' .' -f 1)
398- local MILLISECONDS=$( echo " ${TIMESTAMP} " | cut -d ' .' -f 2 | head -c 3)
399- # MILLISECONDS might have some leading 0's. Trim them by converting it as a base-10 integer.
400- echo $(( $SECONDS * 1000 + 10 #$MILLISECONDS ))
401- }
402-
403- # Get the duration in human-readable time between two patterns in the logfile
404- time_between () {
405- local LOGFILE=" $1 "
406- local FIRST_PATTERN=" $2 "
407- local SECOND_PATTERN=" $3 "
408-
409- local FIRST_LINE=$( grep " ${FIRST_PATTERN} " " ${LOGFILE} " | head -n 1)
410- local SECOND_LINE=$( grep " ${SECOND_PATTERN} " " ${LOGFILE} " | head -n 1)
411-
412- if [ -z " ${FIRST_LINE} " -o -z " ${SECOND_LINE} " ]; then
413- echo " n/a"
414- else
415- local FIRST_TIME=$( timestamp_of " ${FIRST_LINE} " )
416- local SECOND_TIME=$( timestamp_of " ${SECOND_LINE} " )
417-
418- ELAPSED_MS=$(( ${SECOND_TIME} - ${FIRST_TIME} ))
419-
420- ELAPSED_S=$(( $ELAPSED_MS / 1000 ))
421- ELAPSED_MS=$(( $ELAPSED_MS % 1000 ))
422-
423- ELAPSED_M=$(( $ELAPSED_S / 60 ))
424- ELAPSED_S=$(( $ELAPSED_S % 60 ))
425-
426- ELAPSED_MS=" ${ELAPSED_MS} ms"
427-
428- if [ ${ELAPSED_M} -gt 0 ]; then
429- ELAPSED_M=" ${ELAPSED_M} m "
430- # Don't print the milliseconds if we got more than a minute.
431- ELAPSED_MS=" "
432- else
433- ELAPSED_M=" "
434- fi
435-
436- if [ ${ELAPSED_S} -gt 0 ]; then
437- ELAPSED_S=" ${ELAPSED_S} s "
438- else
439- ELAPSED_S=" "
440- fi
441-
442- echo " ${ELAPSED_M}${ELAPSED_S}${ELAPSED_MS} "
443- fi
444- }
445-
446391analyze_latex_logs () {
447392 local LOGFILE=$1
448393
449- local RUNCOUNT=$( grep " Run number " " ${LOGFILE} " | tail -n 1 | cut -d ' ' -f 4 )
394+ local RUNCOUNT=$( grep " Run number " " ${LOGFILE} " | tail -n 1 | cut -d ' ' -f 3 )
450395 local PASSES=" passes"
451396 if [ " ${RUNCOUNT} " -eq " 1" ]; then
452397 PASSES=" pass"
@@ -457,10 +402,7 @@ analyze_latex_logs() {
457402 local WARNINGS=$( sed -n " /Run number ${RUNCOUNT} /,$ p" " ${LOGFILE} " | grep " LaTeX Warning: " )
458403 if [ ! -z " ${WARNINGS} " ]; then
459404 echo " LaTeX warnings (may be ignorable - check the output!):"
460- echo " ${WARNINGS} " | while read LINE; do
461- local CUT_LINE=$( echo " ${LINE} " | cut -d ' ' -f2-)
462- echo " ${CUT_LINE} "
463- done
405+ echo " ${WARNINGS} "
464406 fi
465407}
466408
@@ -521,7 +463,7 @@ if [ -n "${pdf_output}" -o -n "${latex_output}" ]; then
521463 start=$( date +%s)
522464 # Run twice to populate aux, lof, lot, toc, then update the page numbers due
523465 # to the impact of populating the lof, lot, toc.
524- latexmk " ${TEMP_TEX_FILE} " -pdflatex=xelatex -pdf -diagnostics | ts ' [%.s] ' > " ${LATEX_LOG} "
466+ latexmk " ${TEMP_TEX_FILE} " -pdflatex=xelatex -pdf -diagnostics > " ${LATEX_LOG} "
525467 if [ $? -ne 0 ]; then
526468 FAILED=true
527469 echo " PDF output failed"
@@ -538,7 +480,7 @@ if [ -n "${pdf_output}" -o -n "${latex_output}" ]; then
538480 fi
539481 echo " Elapsed time: $(( $end - $start )) seconds"
540482 # Write any LaTeX errors to stderr.
541- >&2 grep -A 5 " ] ! " " ${LATEX_LOG} "
483+ >&2 grep -A 5 " ! " " ${LATEX_LOG} "
542484 if [[ ! " ${FAILED} " = " true" ]]; then
543485 mv " ${TEMP_PDF_FILE} " " ${pdf_output} "
544486 analyze_latex_logs " ${LATEX_LOG} "
0 commit comments