#!/bin/sh # Written by Daniel Bosk, 2010. # Contact: 1024D/D5FF00F6 Daniel Bosk # # Available under the MIT license. # # This script fetches a reference for a supplied ISBN from the Libris # database at the Royal Library of Sweden. The reference can be specified to # be in e.g. BibTeX-format. format=bibtex usage() { echo 'Usage: libris [-bho] {[-i] ISBN}' } args=$(getopt bhi:o $*) if [ $# = 0 ]; then usage exit 2 fi set -- $args while [ $# -ge 0 ]; do case "$1" in -b) format=bibtex; shift;; -h) format=harvard; shift;; -o) format=oxford; shift;; -i) isbn=$( echo "$2" | sed "s/-//g" ) shift; shift;; --) shift; break;; esac done if [ "${isbn}" = "" -a "${1}" != "" ]; then isbn=$( echo "$1" | sed "s/-//g" ) elif [ "${isbn}" = "" ]; then usage exit 2 fi lynx -dump "http://libris.kb.se/xsearch?query=ISXN:${isbn}&format=${format}"