[tex-live] Patch for "texdoc -s" to use the ls-R database

George N. White III gnwiii at gmail.com
Sat May 26 19:06:32 CEST 2007

On 5/25/07, Frank Küster <frank at kuesterei.ch> wrote:

> Hi all,
> with teTeX, I've been using "texdoc -s" a lot.  With a full texlive
> install, this is hardly usable, because it runs "find" over all
> $TEXMF/doc trees, which takes ages.  Of course if you use it a second
> time, it's much faster as long as the directories are cached, but you
> never want to use it the first time, not with utilities like "locate"
> present on your system.

I not sure what you mean.  Your script just looks in the last
texmf-tree.  The reason for using TEXDOCS is to ensure that
all the $TEXMF/doc trees are searched.

Unfortunately, kpsewhich --expand-path='$TEXDOCS'
gives directories under the top-level "doc" directory.

> I suggest that "texdoc -s" should use the ls-R database, just as usual
> texdoc does.  It's hard, however, to get the exactly same result as the
> current behavior only with shell scripting, because of the format of the
> ls-R database.  The approach I took was to search for directories that
> match first (that makes long listings more readable, anyway), and for
> non-directory files afterwards.
> The attached patch does that, except that I don't know whether
> tree=${database%ls-R}
> is portable (would have to use echo | sed instead).
> Comments?

I like that it lists the directories (I've been using a version hacked
to add a "-d" option that only looks for directories).

The loop to construct lsR_files:

      for path in `kpsewhich --expand-path='$TEXMF'`; do
       lsR_files=$(eval TEXMFDBS=\$path kpsewhich ls-R)

saves only the last one.  Do you want to exclude the other
trees, or did you mean:

       lsR_files="$lsR_files $(env TEXMFDBS=$path kpsewhich ls-R)"

There are still performance problems.  Try to find the latin modern

"texdoc -s lmodern" doesn't help, but "texdoc -s lm" takes much too
long because the last kpathsea search is run for every lm*.tfm file!

What is needed is a way to select only the shortest prefixes from
"kpsewhich --expand-path='$TEXDOCS'" so that find isn't searching
the same places over and over:

$ kpsewhich --expand-path='$TEXDOCS' | tr ':' ' ' | wc
      1    1630  110497

George N. White III <aa056 at chebucto.ns.ca>
Head of St. Margarets Bay, Nova Scotia

More information about the tex-live mailing list