summaryrefslogtreecommitdiff
path: root/biblio/tib/sk/texswlist.sh
blob: 97cfb90fb0e7fdff400ab5e93f144ced76291aa5 (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/csh -f

#	S. Kremer, Sep 1989.

# 	texswlist - make a 'swlist' file from a bibliographic database
#	and TeX it.

set swortcp=AAAAA/swortcp	# splits the %W lines of the ref file
set tiblist=BBBBB/tiblist
set swlist_tibstyle=texswlist		# the file has a .tib suffix
set tibinputs=CCCCC	# contains $swlist_tibstyle
set tex=DDDDD
set tmp=/tmp/swlist$$
alias announce 'if ($V == 1) echo'

# init
set tibopt=(-d $tibinputs -s $swlist_tibstyle -i quote.ttx)
	# quote.ttx uses `` and '' instead of german quotes

set V=0	tib_verbose='-z'	# do not be verbose as default
set K=0				# do not keep tmp files

if ($#argv == 0) then
	echo 'Usage:' $0 '[-vk] [tib options] file[.ref]'
	echo '-v: be verbose'
	echo "-k: keep intermediate files and don't run TeX"
	exit
endif

set infile=$argv[$#argv]	# last arg is filename
set argv[$#argv]=''		# delete it form arg list

foreach i ($*)
	switch("$i")
	case '-v': 
		set V=1 tib_verbose='' 
		breaksw
	case '-k':
		set K=1
		breaksw
	case '-vk':
	case '-kv':
		set V=1 tib_verbose='' K=1
		breaksw
	default:
		set tibopt=($tibopt $i)
	endsw
end

set in=$infile	# the original input file name
# If specified input file does not exist, user probably forgot .ref.
# We fix it for him:
if (! -f $in && -f $in.ref) set in=$in.ref
set root=$in:r	# root name of input file

$swortcp $in	> $root-s.ref				|| exit 1
echo '\def\jobname{'$in:r' (swlist)}'	> $tmp.1
$tiblist $tib_verbose $tibopt $root-s.ref -x > $tmp.2	|| exit 1
/bin/cat $tmp.[1-2]			> $root-s.tex
/bin/rm -f $tmp.[1-2]

if ($K == 1) then	# do no tex and do not clean up
	announce Tiblist output is in $root-s.tex
	exit
endif

if ($V == 0) then
	$tex $root-s.tex		> /dev/null 	|| exit 1
else
	$tex $root-s.tex				|| exit 1
endif
if ($K == 0) then
	announce Removing $root-s.{ref,tex,log}
	/bin/rm -f $root-s.{ref,tex,log}
endif