]> git.lyx.org Git - lyx.git/blob - lib/scripts/TeXFiles.sh
Extract the necessary magic from epstopdf.
[lyx.git] / lib / scripts / TeXFiles.sh
1 #!/bin/sh
2 # file: ~/bin/TeXFiles.sh
3 # all files             -> without option
4 # TeX class files       -> option cls 
5 # TeX style files       -> option sty
6 # bibtex style files    -> option bst
7 # bibtex database files -> option bib
8 #
9 # with the help
10 # of kpsewhich and creates a 
11 # bstFiles.lst, clsFiles.lst, styFiles.lst, bibFiles.lst
12 # without any parameter all files are created.
13 #
14 # Herbert Voss <voss@perce.org>
15 #
16 # Updates from Jean-Marc Lasgouttes.
17 #
18 # bib support added by Juergen Spitzmueller (v0.3)
19 #
20 CLS_STYLEFILE=clsFiles.lst
21 STY_STYLEFILE=styFiles.lst
22 BST_STYLEFILE=bstFiles.lst
23 BIB_FILES=bibFiles.lst
24 version='$Id: TeXFiles.sh,v 0.3 2003-02-14'
25 progname=`echo $0 | sed 's%.*/%%'`
26 usage="Usage: TeXFiles.sh [-version | cls | sty | bst | bib ] 
27        Default is without any Parameters,
28        so that all files will be created"
29
30 types=$1
31 test -z "$types" && types="cls sty bst bib"
32
33 #
34 # MS-DOS and MS-Windows define $COMSPEC or $ComSpec and use ';' to separate
35 # directories in path lists whereas Unixes uses ':'.
36 # $SEP holds the right character to be used by the scripts.
37 #
38 #???????????????
39 # never used this one with windows and what happens with mac??
40 #???????????????
41 #
42 if test -z "$COMSPEC" && test -z "$ComSpec"; then SEP=':'; else SEP=';'; fi
43
44 #
45 # A copy of some stuff from mktex.opt, so we can run in the presence of
46 # terminally damaged ls-R files.
47 #
48 if test "x$1" = x--help || test "x$1" = x-help; then
49   echo "$usage"
50   exit 0
51 elif test "x$1" = x--version || test "x$1" = x-version; then
52   echo "`basename $0` $version"
53   kpsewhich --version
54   exit 0
55 fi
56
57 for type in $types ; do
58   echo "Indexing files of type $type"
59   case $type in 
60    cls) outfile=$CLS_STYLEFILE
61         kpsetype=.tex;;
62    sty) outfile=$STY_STYLEFILE
63         kpsetype=.tex;;
64    bst) outfile=$BST_STYLEFILE
65         kpsetype=.bst;;
66    bib) outfile=$BIB_FILES
67         kpsetype=.bib;;
68    *)   echo "ERROR: unknown type $type"
69         exit 1;;
70   esac
71
72   rm -f $outfile
73   touch $outfile
74
75   dirs=`kpsewhich --show-path=$kpsetype 2>/dev/null | tr "$SEP" " " | sed -e 's%///%/%' -e 's%//%/%g' -e 's%!!%%g'`
76
77   for dir in $dirs ; do
78     find $dir -follow -name "*.$type" >>$outfile 2>/dev/null
79   done
80
81 done
82 #echo "list saved in $STYLEFILE"
83 #echo `wc -l $CLS_STYLEFILE`            # only for information
84 #
85 # this is the end my friends ... Jim Morrison and the Doors in "The End"