#! /bin/sh
# Join lines in .bbl files that BibTeX erroneously wraps at
# <percent><newline> so as to prevent line breaks in URLS.
#
# Usage:
#	./unwrapbbl basename(s)
#
# [25-Jan-1997] -- append $$ to /tmp file to guarantee unique name
# [21-May-1996]

for f in $*
do
    awk '{if (substr($0,length($0),1) == "%") printf("%s", substr($0,1,length($0)-1)) ; else print }' <$f.bbl >/tmp/$f.bbl.$$
    /bin/mv /tmp/$f.bbl.$$ $f.bbl
done
