#!/bin/bash

# Usage: $0 logfile
# prints the first compiler error from the -file-line-error info

n=`echo "$1" | sed 's%[^/]*$%%'`
egrep -h -A 2 '\./test-[0-9]+-[0-9]+[a-zA-Z]*\.tex:[0-9]+:' $1 \
| sed "s@^\./@$n@" \
| sed "s/-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][a-zA-Z]*\.tex/.tex/" \
| head -3
