#/bin/zsh
# mrcheckbib - version DBL_MIN
# checks a bibtex file (.bib) against the AMS MRef database
#
# Copyright (C) 2006 John Cagnol
# University Leonard de Vinci, Paris, France
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. This document can
# be obtained at http://www.gnu.org/licenses/gpl.txt
#
# Usage:
# mrcheckbib basename
#
# Where:
# basename.bib is the bibtex file to be checked
#
# Output:
# result is placed in file-mrefed.bib and log is placed in
# file-mrefed.log
#
# Example:
# mrcheckbib references
#
# checks file references.bib against MRef and places the result in
# references-mrefed.bib
#
# Purpose of the script:
#
# This script takes every entry in a bibtex file (.bib) and checks it
# against the AMS MRef database (see http://www.ams.org/mref). If it
# finds a unique MRef entry, then your entry will be replaced by the
# MRef one. For example, if your bibtex entry is
#
# @article{greens,
# Author="Cagnol, J. and Lebiedzik, C.},
# Title="On the free boundary conditions for a dynamic shell model
# based on intrinsic differential geometry
# Journal="Applicable Analysis", Year=2004}
#
# It will be replaced by
#
# @article {greens,
# AUTHOR = {Cagnol, John and Lebiedzik, Catherine},
# TITLE = {On the free boundary conditions for a dynamic shell
# model based on intrinsic differential geometry},
# JOURNAL = {Appl. Anal.},
# FJOURNAL = {Applicable Analysis. An International Journal},
# VOLUME = {83},
# YEAR = {2004},
# NUMBER = {6},
# PAGES = {607--633},
# ISSN = {0003-6811},
# MRCLASS = {74K25 (35B35 53B50 74H99)},
# MRNUMBER = {MR2059476 (2006c:74066)},
# MRREVIEWER = {Liliana Gratie},
# }
#
# The latter is more complete than the former (page numbers, etc.).
# Please note that mrcheckbib does not try to figure out which entry
# is more complete. If a unique MRef entry is found, then your entry
# is gone. In most cases, this is good because the MRef entry is more
# complete.
#
# mrcheckbib is intended to be used with a standard bibfile, with no
# comment line. It is assumed your shell is zsh and that have a
# non-interactive network retriever such as wget. If you use curl
# or any other retriever, you'll need to adapt the options.
#
# The script relies on the fact that MRef response is bracketed by
#