summaryrefslogtreecommitdiff
path: root/biblio/bibtex/utils/printbib/printbib
diff options
context:
space:
mode:
Diffstat (limited to 'biblio/bibtex/utils/printbib/printbib')
-rw-r--r--biblio/bibtex/utils/printbib/printbib87
1 files changed, 87 insertions, 0 deletions
diff --git a/biblio/bibtex/utils/printbib/printbib b/biblio/bibtex/utils/printbib/printbib
new file mode 100644
index 0000000000..e2378281be
--- /dev/null
+++ b/biblio/bibtex/utils/printbib/printbib
@@ -0,0 +1,87 @@
+#! /bin/sh
+# set -x
+usage='usage: printbib[key] [-noprint|-nocheck|-style bibstyle|-title "title"|-output file|-predef "file,file,..."] bibfile...'
+# you may have to change this for your site:
+files=${predef-"/users/bib/predef"}
+title=${title-", sorted by first author"}
+style=${style-skey}
+output=${output-test}
+check=${check-true}
+print=${print-true}
+
+while :
+do
+ case "$1" in
+ -p|-print) print=true; shift;;
+ +p|-noprint) print=false; shift;;
+ -c|-check) check=true; shift;;
+ +c|-nocheck) check=false; shift;;
+ -s|-style) style="$2"; shift 2;;
+ -t|-title) title="$2"; shift 2;;
+ -o|-output) output="$2"; shift 2;;
+ -predef) files="$2"; shift 2;;
+ -*|+*) echo "$usage" >&2; exit 1;;
+ *) break;;
+ esac
+ done
+if [ $# -lt 1 ]
+ then echo $usage >&2
+ exit 1
+ fi
+
+umask 0
+rm -f ${output}.tex ${output}.aux ${output}.bbl ${output}.blg ${output}.log ${output}.dvi ${output}.DVI
+
+echo "Outputting to ${output}.tex" >&2
+
+cat > ${output}.tex << EOD
+
+ % tex file to print bibliography file(s) $@
+ % automatically generated by program $0
+ \\documentstyle[proc]{article}
+ \\begin{document}
+ \\title{Bibliography file $@ $title}
+ \\author{Version of `date '+%a %d-%h-%y %H:%M'`}
+ \\maketitle
+ \\renewcommand\\thebibliography[1]{\\section*{Bibliography\\markboth
+ {BIBLIOGRAPHY}{BIBLIOGRAPHY}}\\list
+ {[\\arabic{enumi}]}{\\settowidth\\labelwidth{12345678}\\leftmargin\\labelwidth
+ \\advance\\leftmargin\\labelsep
+ \\usecounter{enumi}}
+ \\def\\newblock{\\hskip .11em plus .33em minus -.07em}
+ \\sloppy
+ \\sfcode\`\\.=1000\\relax}
+
+ \\bibliography{$files}
+ \\bibliographystyle{${style}}
+ \\end{document}
+
+EOD
+
+echo '\relax' > ${output}.aux
+while [ $# -gt 0 ]
+do
+ f=`basename $1 .bib`
+ if [ ! -r $f.bib ]
+ then echo $usage >&2
+ exit 1
+ fi
+
+ sed -n -e 's+^[ ]*@\([a-zA-Z]*\)[ ]*[({][ ]*\([-:_a-zA-Z0-9]*\),+\\citation{\2}+p' $f.bib >> ${output}.aux
+
+ files="$files,$f"
+ shift
+
+ done
+
+echo "\\bibdata{$files}" >> ${output}.aux
+echo "\\bibstyle{$style}" >> ${output}.aux
+
+bibtex ${output}
+if egrep -l '(^ : |---)' ${output}.blg
+ then echo "There are errors in the bibliography file(s) (see ${output}.blg)" >&2
+ if $check; then exit 1; fi
+ fi
+latex ${output}
+if $print; then lpr -d ${output}.dvi; fi
+