| 1 |
#!/usr/bin/env perl |
| 2 |
# $Id: nmbibtex.pl,v 1.1 2015-04-26 00:19:37 boris Exp $ |
| 3 |
# |
| 4 |
# Copyright 2015, Michael Cohen <[email protected]> |
| 5 |
# and Boris Veytsman <[email protected]> |
| 6 |
# This work may be distributed and/or modified under the |
| 7 |
# conditions of the LaTeX Project Public License, either |
| 8 |
# version 1.3 of this license or (at your option) any |
| 9 |
# later version. |
| 10 |
# The latest version of the license is in |
| 11 |
# http://www.latex-project.org/lppl.txt |
| 12 |
# and version 1.3 or later is part of all distributions of |
| 13 |
# LaTeX version 2003/06/01 or later. |
| 14 |
# |
| 15 |
# This work has the LPPL maintenance status `maintained'. |
| 16 |
# |
| 17 |
# The Current Maintainer of this work is Boris Veytsman |
| 18 |
|
| 19 |
=pod |
| 20 |
|
| 21 |
=head1 NAME |
| 22 |
|
| 23 |
nmbibtex - a program to compile bibliographies for the package nmbib |
| 24 |
|
| 25 |
=head1 SYNOPSIS |
| 26 |
|
| 27 |
nmbibtex I<OPTIONS> I<FILE> |
| 28 |
|
| 29 |
=head1 DESCRIPTION |
| 30 |
|
| 31 |
nmbibtex calls L<bibtex(1)> for all aux files produced by the package |
| 32 |
nmbib |
| 33 |
|
| 34 |
=head1 OPTIONS |
| 35 |
|
| 36 |
=over 4 |
| 37 |
|
| 38 |
=item B<-h> |
| 39 |
|
| 40 |
Print the help information and exit |
| 41 |
|
| 42 |
=item B<-min-crossrefs> I<number> |
| 43 |
|
| 44 |
Send the option C<-min-crossref=NUMBER> to L<bibtex(1)> |
| 45 |
|
| 46 |
=item B<-terse> |
| 47 |
|
| 48 |
Send the option C<-terse> to L<bibtex(1)> |
| 49 |
|
| 50 |
=item B<-v> |
| 51 |
|
| 52 |
Print the copyright information and exit |
| 53 |
|
| 54 |
=back |
| 55 |
|
| 56 |
=head1 AUTHORS AND LICENSE |
| 57 |
|
| 58 |
Copyright 2015, Michael Cohen [email protected] |
| 59 |
and Boris Veytsman [email protected] |
| 60 |
|
| 61 |
This work may be distributed and/or modified under the |
| 62 |
conditions of the LaTeX Project Public License, either |
| 63 |
version 1.3 of this license or (at your option) any |
| 64 |
later version. |
| 65 |
|
| 66 |
=cut |
| 67 |
|
| 68 |
use strict; |
| 69 |
|
| 70 |
my $USAGE = <<'END'; |
| 71 |
Usage: nmbibtex [-min-crossref NUMBER] [-terse] FILE |
| 72 |
|
| 73 |
Copyright 2015, Michael Cohen [email protected] |
| 74 |
and Boris Veytsman [email protected] |
| 75 |
|
| 76 |
This work may be distributed and/or modified under the |
| 77 |
conditions of the LaTeX Project Public License, either |
| 78 |
version 1.3 of this license or (at your option) any |
| 79 |
later version. |
| 80 |
END |
| 81 |
|
| 82 |
use Getopt::Long; |
| 83 |
|
| 84 |
my $help=0; |
| 85 |
my $terse=0; |
| 86 |
my $mincross=-1; |
| 87 |
|
| 88 |
GetOptions("h" => \$help, |
| 89 |
'v' => \$help, |
| 90 |
'-terse' => \$terse, |
| 91 |
"-min-crossrefs=i" => \$mincross) or die $USAGE; |
| 92 |
|
| 93 |
if ($help){ |
| 94 |
die $USAGE; |
| 95 |
} |
| 96 |
|
| 97 |
my $cmdline = "bibtex "; |
| 98 |
if ($terse) { |
| 99 |
$cmdline .= "-terse "; |
| 100 |
} |
| 101 |
if ($mincross>0) { |
| 102 |
$cmdline .= "-min-crossrefs=$mincross "; |
| 103 |
} |
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
my $file = shift; |
| 108 |
|
| 109 |
if (!length($file)) { |
| 110 |
die $USAGE; |
| 111 |
} |
| 112 |
|
| 113 |
# Just in case strip the suffix |
| 114 |
$file =~ s/\.aux$//; |
| 115 |
$file =~ s/\.AUX$//; |
| 116 |
|
| 117 |
my @auxfiles = glob("$file-*.aux"); |
| 118 |
foreach my $auxfile (@auxfiles) { |
| 119 |
print `$cmdline $auxfile`; |
| 120 |
} |