#! /bin/bash
# Last edited on 2012-12-08 21:20:49 by stolfilocal

# Converts the bibtool error messages to a format similar
# to the gcc error messages, that is understood by Emacs.

USAGE="bibtool INPUT.bib ... 2>&1 1> SORTED.bib | bibtool-error-filter INPUT.bib"

if [[ $# -lt 1 ]]; then  
  echo "usage: ${USAGE}" ; exit 1
fi
fname="$1"; shift

sed \
  -e 's=[*][*][*] BibTool [A-Z]*: *[(]line ='"${fname}"':=g' \
  -e 's= in <stdin>[)]==g' \
  -e '/^[_]*\^ *$$/d'
