]> git.lyx.org Git - lyx.git/blob - lib/scripts/TeXFiles.sh
fixes to tex-info stuff
[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 CLS_STYLEFILE=clsFiles.lst
16 STY_STYLEFILE=styFiles.lst
17 BST_STYLEFILE=bstFiles.lst
18 version='$Id: TeXFiles.sh,v 0.1 2001-10-01'
19 progname=`echo $0 | sed 's%.*/%%'`
20 echo "$version"
21 usage="Usage: TeXFiles.sh [-version | cls | sty | bst] 
22        Default is without any Parameters,
23        so that all files will be created"
24
25 #
26 # MS-DOS and MS-Windows define $COMSPEC or $ComSpec and use ';' to separate
27 # directories in path lists whereas Unixes uses ':'.
28 # $SEP holds the right character to be used by the scripts.
29 #
30 #???????????????
31 # never used this one with windows and what happens with mac??
32 #???????????????
33 #
34 if test -z "$COMSPEC" && test -z "$ComSpec"; then SEP=':'; else SEP=';'; fi
35 #
36 # Add the location of the script to the PATH if necessary.  This must
37 # be done before kpsewhich can be called, and thus cannot be put into
38 # mktex.opt
39 #
40 dirname=`echo $0 | sed 's%/*[^/][^/]*$%%'`
41 echo "Actual Dir: $dirname"
42 case $dirname in                        # $dirname correct?
43   "")                                   # Do nothing
44       ;;
45   /* | [A-z]:/*)                        # / -> Absolute name 
46       PATH="$dirname$SEP$PATH" ;;
47    *)                                   # other -> Relative name
48       PATH="`pwd`/$dirname$SEP$PATH" ;;
49 esac                                    # end of case
50 #
51 # A copy of some stuff from mktex.opt, so we can run in the presence of
52 # terminally damaged ls-R files.
53 #
54 if test "x$1" = x--help || test "x$1" = x-help; then
55   echo "$usage"
56   exit 0
57 elif test "x$1" = x--version || test "x$1" = x-version; then
58   echo "`basename $0` $version"
59   kpsewhich --version
60   exit 0
61 fi
62 #
63 # find the directories with kpsewhich. TeX has files ls-R to hold
64 # the tex-tree
65 #
66 test $# = 0 && {
67   OIFS=$IFS; IFS=$SEP; set x `kpsewhich --show-path=ls-R 2>/dev/null`; shift; IFS=$OIFS
68 }
69 echo 'Delete old *files.lst, if present'
70 case "$1" in
71     "cls")
72         rm -f $CLS_STYLEFILE
73         touch $CLS_STYLEFILE            # create new file
74     ;;
75     "sty")
76         rm -f $STY_STYLEFILE
77         touch $STY_STYLEFILE            # create new file
78     ;;
79     "bst")
80         rm -f $BST_STYLEFILE
81         touch $BST_STYLEFILE            # create new file
82     ;;
83     *)                                  # all other
84         rm -f $CLS_STYLEFILE $STY_STYLEFILE $BST_STYLEFILE
85         touch $CLS_STYLEFILE $STY_STYLEFILE $BST_STYLEFILE 
86     ;;
87 esac
88 echo "looking for all bst-style files in the latex tree";
89 for TEXMFLSR in "$@"; do                # go through the dirs
90   case "$TEXMFLSR" in                   # Prepend cwd if the directory was relative.
91   "") continue ;;                       # it is an error if this case is taken.
92   /* | [A-z]:/*) ;;                     # leading /
93   *)  TEXMFLSR="`pwd`/$TEXMFLS_R"       # all other
94   esac
95   echo "Dir: <$TEXMFLSR>"
96 case "$1" in                            # list all files with suffix bst
97     "cls")
98         find $TEXMFLSR -follow -name *.cls >> $CLS_STYLEFILE
99     ;;
100     "sty")
101         find $TEXMFLSR -follow -name *.sty >> $STY_STYLEFILE
102     ;;
103     "bst")
104         find $TEXMFLSR -follow -name *.bst >> $BST_STYLEFILE
105     ;;
106     *) 
107         find $TEXMFLSR -follow -name *.cls >> $CLS_STYLEFILE
108         find $TEXMFLSR -follow -name *.sty >> $STY_STYLEFILE
109         find $TEXMFLSR -follow -name *.bst >> $BST_STYLEFILE
110     ;;
111 esac
112
113   echo "done!"
114 done
115 #echo "list saved in $STYLEFILE"
116 #echo `wc -l $CLS_STYLEFILE`            # only for information
117 #
118 # this is the end my friends ... Jim Morrison and the Doors in "The End"