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