]> git.lyx.org Git - features.git/commitdiff
update to TeXFiles.sh
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 15 Oct 2001 13:59:11 +0000 (13:59 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 15 Oct 2001 13:59:11 +0000 (13:59 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2886 a592a061-630c-0410-9148-cb99ea01b6c8

lib/ChangeLog
lib/scripts/TeXFiles.sh

index 6b4d32e43f440a8d77a79cb0d6a5d0e2c6b3e24a..706601aec9640d489947618d51a9210c76fc26f5 100644 (file)
@@ -1,3 +1,8 @@
+2001-10-15  Jean-Marc Lasgouttes  <Jean-Marc.Lasgouttes@inria.fr>
+
+       * scripts/TeXFiles.sh: rewrite to use kpsewhich --show-path.
+       Hopefully more precise and much faster.
+
 2001-10-15  José Matos  <jamatos@fep.up.pt>
 
        * layouts/db_stdtitle.inc: add AuthorGroup, RevisionHistory,
index 0863b1501be6cf6f693e1d65dc78edada71a68d4..976c8749ac797a5c4a8e85874af334bf9d58e7c8 100755 (executable)
 #
 # Herbert Voss <voss@perce.org>
 #
+# Updates from Jean-Marc Lasgouttes.
+#
 CLS_STYLEFILE=clsFiles.lst
 STY_STYLEFILE=styFiles.lst
 BST_STYLEFILE=bstFiles.lst
-version='$Id: TeXFiles.sh,v 0.1 2001-10-01'
+version='$Id: TeXFiles.sh,v 0.2 2001-10-15'
 progname=`echo $0 | sed 's%.*/%%'`
-echo "$version"
 usage="Usage: TeXFiles.sh [-version | cls | sty | bst] 
        Default is without any Parameters,
        so that all files will be created"
 
+types=$1
+test -z "$types" && types="cls sty bst"
+
 #
 # MS-DOS and MS-Windows define $COMSPEC or $ComSpec and use ';' to separate
 # directories in path lists whereas Unixes uses ':'.
@@ -32,21 +36,7 @@ usage="Usage: TeXFiles.sh [-version | cls | sty | bst]
 #???????????????
 #
 if test -z "$COMSPEC" && test -z "$ComSpec"; then SEP=':'; else SEP=';'; fi
-#
-# Add the location of the script to the PATH if necessary.  This must
-# be done before kpsewhich can be called, and thus cannot be put into
-# mktex.opt
-#
-dirname=`echo $0 | sed 's%/*[^/][^/]*$%%'`
-echo "Actual Dir: $dirname"
-case $dirname in                       # $dirname correct?
-  "")                                  # Do nothing
-      ;;
-  /* | [A-z]:/*)                       # / -> Absolute name 
-      PATH="$dirname$SEP$PATH" ;;
-   *)                                          # other -> Relative name
-      PATH="`pwd`/$dirname$SEP$PATH" ;;
-esac                                   # end of case
+
 #
 # A copy of some stuff from mktex.opt, so we can run in the presence of
 # terminally damaged ls-R files.
@@ -59,58 +49,29 @@ elif test "x$1" = x--version || test "x$1" = x-version; then
   kpsewhich --version
   exit 0
 fi
-#
-# find the directories with kpsewhich. TeX has files ls-R to hold
-# the tex-tree
-#
-test $# = 0 && {
-  OIFS=$IFS; IFS=$SEP; set x `kpsewhich --show-path=ls-R 2>/dev/null`; shift; IFS=$OIFS
-}
-echo 'Delete old *files.lst, if present'
-case "$1" in
-    "cls")
-       rm -f $CLS_STYLEFILE
-       touch $CLS_STYLEFILE            # create new file
-    ;;
-    "sty")
-       rm -f $STY_STYLEFILE
-       touch $STY_STYLEFILE            # create new file
-    ;;
-    "bst")
-       rm -f $BST_STYLEFILE
-       touch $BST_STYLEFILE            # create new file
-    ;;
-    *)                                         # all other
-       rm -f $CLS_STYLEFILE $STY_STYLEFILE $BST_STYLEFILE
-       touch $CLS_STYLEFILE $STY_STYLEFILE $BST_STYLEFILE 
-    ;;
-esac
-echo "looking for all bst-style files in the latex tree";
-for TEXMFLSR in "$@"; do               # go through the dirs
-  case "$TEXMFLSR" in                  # Prepend cwd if the directory was relative.
-  "") continue ;;                      # it is an error if this case is taken.
-  /* | [A-z]:/*) ;;                    # leading /
-  *)  TEXMFLSR="`pwd`/$TEXMFLS_R"      # all other
+
+for type in $types ; do
+  echo "Indexing files of type $type"
+  case $type in 
+   cls) outfile=$CLS_STYLEFILE
+        kpsetype=.tex;;
+   sty) outfile=$STY_STYLEFILE
+        kpsetype=.tex;;
+   bst) outfile=$BST_STYLEFILE
+        kpsetype=.bst;;
+   *)   echo "ERROR: unknown type $type"
+        exit 1;;
   esac
-  echo "Dir: <$TEXMFLSR>"
-case "$1" in                           # list all files with suffix bst
-    "cls")
-       find $TEXMFLSR -follow -name *.cls >> $CLS_STYLEFILE
-    ;;
-    "sty")
-       find $TEXMFLSR -follow -name *.sty >> $STY_STYLEFILE
-    ;;
-    "bst")
-       find $TEXMFLSR -follow -name *.bst >> $BST_STYLEFILE
-    ;;
-    *) 
-       find $TEXMFLSR -follow -name *.cls >> $CLS_STYLEFILE
-       find $TEXMFLSR -follow -name *.sty >> $STY_STYLEFILE
-       find $TEXMFLSR -follow -name *.bst >> $BST_STYLEFILE
-    ;;
-esac
 
-  echo "done!"
+  rm -f $outfile
+  touch $outfile
+
+  dirs=`kpsewhich --show-path=$kpsetype 2>/dev/null | tr "$SEP" " " | sed -e 's%///%/%' -e 's%//%/%g' -e 's%!!%%g'`
+
+  for dir in $dirs ; do
+    find $dir -follow -name "*.$type" >>$outfile 2>/dev/null
+  done
+
 done
 #echo "list saved in $STYLEFILE"
 #echo `wc -l $CLS_STYLEFILE`           # only for information