summaryrefslogtreecommitdiff
path: root/biblio/bibtex/utils/bibtools/bibify
blob: 4d33d9c1d98d7498cd193b621095f04e9ab328f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/csh -f

if ($1 !~ *.aux) then
    set input=$1.aux
    set bbl = $1.bbl
else
    set input=$1
    set bbl=$1:r.bbl
endif

set file=/tmp/bibify$$
onintr clean

cat $input > $file

set style=`sed -n 's/\\bibstyle{\(.*\)}/\1/p' $input`

switch($style)
case "alpha":
case "abstract":
 cat $bbl | sed -n 's/bibitem\[\(.*\)\]{\(.*\)}/bibcite{\2}{\1}/p' >> $file
 breaksw
case "plain":
case "unsrt":
case "abbrv":
 cat $bbl | sed -n 's/bibitem/bibcite/p'| awk '{print $1"{"NR"}"}' >> $file
 breaksw
default:
 echo unknown bibliography style, cannot bibify.
 goto clean
endsw

mv $file $input

clean:
/bin/rm -f $file.* >& /dev/null