]> git.lyx.org Git - lyx.git/blob - lib/scripts/TeXFiles.sh
Generate python code in GraphicsConverter.C, replace convertDefault.sh by convertDefa...
[lyx.git] / lib / scripts / TeXFiles.sh
1 #!/bin/sh
2
3 # file TeXFiles.sh
4 # This file is part of LyX, the document processor.
5 # Licence details can be found in the file COPYING.
6
7 # author Herbert Voß
8 # author Jean-Marc Lasgouttes
9 # author Jürgen Spitzmüller
10
11 # Full author contact details are available in file CREDITS.
12
13 # all files             -> without option
14 # TeX class files       -> option cls
15 # TeX style files       -> option sty
16 # bibtex style files    -> option bst
17 # bibtex database files -> option bib
18 #
19 # with the help
20 # of kpsewhich and creates a
21 # bstFiles.lst, clsFiles.lst, styFiles.lst, bibFiles.lst
22 # without any parameter all files are created.
23 #
24 # Herbert Voss <voss@perce.org>
25 #
26 # Updates from Jean-Marc Lasgouttes.
27 #
28 # bib support added by Juergen Spitzmueller (v0.3)
29 #
30 CLS_STYLEFILE=clsFiles.lst
31 STY_STYLEFILE=styFiles.lst
32 BST_STYLEFILE=bstFiles.lst
33 BIB_FILES=bibFiles.lst
34 version='$Id: TeXFiles.sh,v 0.3 2003-02-14'
35 progname=`echo $0 | sed 's%.*/%%'`
36 usage="Usage: TeXFiles.sh [-version | cls | sty | bst | bib ]
37        Default is without any Parameters,
38        so that all files will be created"
39
40 types=$1
41 test -z "$types" && types="cls sty bst bib"
42
43 #
44 # MS-DOS and MS-Windows define $COMSPEC or $ComSpec and use `;' to separate
45 # directories in path lists whereas Unix uses `:'.  Make an exception for
46 # Cygwin, where we could have either teTeX (using `:') or MikTeX (using `;').
47 # Create a variable that holds the right character to be used by the scripts.
48 DOSISH=no
49 case `uname -s` in
50   CYGWIN*|Cygwin*|cygwin*)
51     # MikTeX's kpsewhich says "kpathsea emulation version x.x.x", whereas
52     # teTeX's simply "kpathsea version x.x.x".
53     if kpsewhich --version | grep emulation >/dev/null 2>&1; then DOSISH=yes; fi
54     ;;
55   *) if test -n "$COMSPEC" || test -n "$ComSpec"; then DOSISH=yes; fi
56 esac
57 if test "$DOSISH" = "no"; then SEP=':'; else SEP=';'; fi
58
59 #
60 # A copy of some stuff from mktex.opt, so we can run in the presence of
61 # terminally damaged ls-R files.
62 #
63 if test "x$1" = x--help || test "x$1" = x-help; then
64   echo "$usage"
65   exit 0
66 elif test "x$1" = x--version || test "x$1" = x-version; then
67   echo "`basename $0` $version"
68   kpsewhich --version
69   exit 0
70 fi
71
72 for type in $types ; do
73   echo "Indexing files of type $type"
74   case $type in
75    cls) outfile=$CLS_STYLEFILE
76         kpsetype=.tex;;
77    sty) outfile=$STY_STYLEFILE
78         kpsetype=.tex;;
79    bst) outfile=$BST_STYLEFILE
80         kpsetype=.bst;;
81    bib) outfile=$BIB_FILES
82         kpsetype=.bib;;
83    *)   echo "ERROR: unknown type $type"
84         exit 1;;
85   esac
86
87   rm -f $outfile
88   touch $outfile
89
90   dirs=`kpsewhich --show-path=$kpsetype 2>/dev/null | tr "$SEP" " " | sed -e 's%/\{2,\}%/%g' -e 's%!!%%g'`
91
92   for dir in $dirs ; do
93     find $dir -follow -name "*.$type" >>$outfile 2>/dev/null
94   done
95
96 done
97 #echo "list saved in $STYLEFILE"
98 #echo `wc -l $CLS_STYLEFILE`            # only for information
99 #
100 # this is the end my friends ... Jim Morrison and the Doors in "The End"