BibTeX tools

I use some scripts to grab references from ADS. I download a library for each author, and then combine those to a single big library, all.bib. This causes some references to appear multiple times in all.bib. BibTeX simply prints out a warning and ignores the duplicate entry. This is fine if you call BibTeX yourself, but I use rubber to compile my LaTeX documents. Rubber not only automagically calls LaTeX a sufficient number of times, it also runs BibTeX if required. However, it aborts when BibTeX exits uncleanly, such as in the case of duplicate labels.

At first, I hacked rubber to not check for BibTeX errors. While this works, in case of a real error, rubber simply continues like nothing's wrong. Clearly, this is not what we want. We want to strip out the duplicates in all.bib.

Nelson Beebe has produced a number of tools for BibTeX. I installed bibparse-1.06, bibsort-0.17, and bibjoin-0.09. I had to patch bibparse-1.06/biblex.l with this patch in order for it to work properly with ADS labels. It is then easy to eliminate duplicates and reformat all.bib using a short script:

#!/bin/bash
biblex $* | bibunlex | sed -e 's/[^,]$/&,/' | bibsort | bibjoin | fmt -s

Bugs & feature requests

Please send bugreports and feature requests to dwijn at iluvatar.org.