| 1 |
#!/bin/csh -f |
| 2 |
# |
| 3 |
# makebib - make a bib file that has the given citations |
| 4 |
# |
| 5 |
# usage: |
| 6 |
# makebib [-n | -d | -u] file.bib... [citekey]... |
| 7 |
# Where -n means "no comment", ie, don't include any "comment" fields. |
| 8 |
# And -d means "dfk", ie, add attribution to dfk to all comment fields. |
| 9 |
# And -u means "unsorted", and comments are still included. |
| 10 |
# Output is to subset.bib. If citekey is not given, then all refs in |
| 11 |
# the bibfile are included. |
| 12 |
# |
| 13 |
# dfk 11/24/92: write the subset.aux file directly, skipping latex |
| 14 |
# dfk 9/99: add unsorted option |
| 15 |
|
| 16 |
onintr cleanup |
| 17 |
|
| 18 |
if ($#argv < 1) then |
| 19 |
echo 'usage: makebib [-n|-d] file.bib... [citekey]...' |
| 20 |
exit 1 |
| 21 |
endif |
| 22 |
|
| 23 |
if ("$1" == "-n") then |
| 24 |
set bst=subset-nocomment |
| 25 |
shift |
| 26 |
else |
| 27 |
if ("$1" == "-d") then |
| 28 |
set bst=subset-dfk |
| 29 |
shift |
| 30 |
else |
| 31 |
if ("$1" == "-u") then |
| 32 |
set bst=subset-unsorted |
| 33 |
shift |
| 34 |
else |
| 35 |
set bst=subset |
| 36 |
endif |
| 37 |
endif |
| 38 |
endif |
| 39 |
|
| 40 |
if ($#argv < 1) then |
| 41 |
echo 'usage: makebib [-n|-d|-u] file.bib... [citekey]...' |
| 42 |
exit 1 |
| 43 |
endif |
| 44 |
|
| 45 |
set files = $1:r |
| 46 |
shift |
| 47 |
|
| 48 |
while ($1:e == bib) |
| 49 |
set files=($files,$1:r) |
| 50 |
shift |
| 51 |
end |
| 52 |
|
| 53 |
echo creating subset.aux for $files |
| 54 |
|
| 55 |
cat > subset.aux <<EOF |
| 56 |
\relax |
| 57 |
\bibstyle{$bst} |
| 58 |
\bibdata{$files} |
| 59 |
EOF |
| 60 |
|
| 61 |
# an annoying incompatibility in the way "echo" treats backslash... |
| 62 |
if (`uname` == Linux) then |
| 63 |
set citation="\\citation" |
| 64 |
else |
| 65 |
set citation="\citation" |
| 66 |
endif |
| 67 |
|
| 68 |
if ($#argv > 0) then |
| 69 |
foreach f ($*) |
| 70 |
echo $citation"{$f}" >> subset.aux |
| 71 |
end |
| 72 |
else |
| 73 |
echo $citation'{*}' >> subset.aux |
| 74 |
endif |
| 75 |
rm -f subset.{log,dvi,bbl,blg} |
| 76 |
|
| 77 |
echo bibtex subset |
| 78 |
bibtex subset |
| 79 |
|
| 80 |
if (-e makebib.sed.Z) uncompress makebib.sed |
| 81 |
if (-e makebib.sed.gz) gunzip makebib.sed |
| 82 |
|
| 83 |
echo "" |
| 84 |
echo 'Fixing these lines (might be doing the wrong thing)' |
| 85 |
grep '[^\\]%$' subset.bbl |
| 86 |
echo end. |
| 87 |
echo "" |
| 88 |
|
| 89 |
sed -f makebib.sed subset.bbl > subset.bib |
| 90 |
|
| 91 |
echo "" |
| 92 |
echo output is in subset.bib |
| 93 |
|
| 94 |
cleanup: |
| 95 |
rm -f subset.{tex,aux,log,dvi,bbl,blg,sed} |