[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#488038: texlive-base-bin: kpsewhere weirdness



On Thu, Jun 26, 2008 at 21:59 +0200, Frank Küster wrote:
> This code
> 
> #!/bin/sh
> 
> IFS=':'
> kpsepath=$(kpsewhich --expand-path='$TEXMF')
> for path in $kpsepath
> do 
>   eval FOO=\$path echo $FOO
> done
> 
> Just echo's nothing, and therefore, if we replace "echo $FOO" by a
> kpsewhich call and the assignment to FOO with one to TEXMF, nothing
> changes. In some strange way, however, it works in kpsewhere.

I you run the above code through 'sh -x', you see that $FOO is
expanded before the line is evaluated. At that point, $FOO is still
empty and is therefore expanded to nothing. In order to simulate the
behavior of kpsewhere, you need a slight delay between evaluation of
the line and hence definition of $FOO on the one hand and using the
value of $FOO on the other hand:

#!/bin/sh

function echoFOO(){
  echo $FOO
}

IFS=':'
kpsepath=$(kpsewhich --expand-path='$TEXMF')
for path in $kpsepath
do 
  eval FOO=\$path echoFOO
done
 
> What I don't understand that --format has such an effect. Without it,
> libkpathsea assumes I'm looking for a cnf file, and finds one of the
> three, eight times. With it, it assumes I'm looking for a web2c file,
> and finds
> 
> - the very same file it found as a cnf file
> 
> - plus two files at the exactly same relative path in a TEXMF tree
> 
> Why doesn't it find the same in all cases?

Because kpsewhich uses different search pathes when looking for files
of type "web2c files" or "cnf". The search path for "web2c files"
depends on TEXMF, while the search path for "cnf" does not:

ralf@skye:~$ kpsewhere -show-path=cnf foo
/usr/share/texmf/web2c:/usr/share/texmf-texlive/web2c:/usr/local/share/texmf/web2c
/usr/share/texmf/web2c:/usr/share/texmf-texlive/web2c:/usr/local/share/texmf/web2c
/usr/share/texmf/web2c:/usr/share/texmf-texlive/web2c:/usr/local/share/texmf/web2c
/usr/share/texmf/web2c:/usr/share/texmf-texlive/web2c:/usr/local/share/texmf/web2c
/usr/share/texmf/web2c:/usr/share/texmf-texlive/web2c:/usr/local/share/texmf/web2c
/usr/share/texmf/web2c:/usr/share/texmf-texlive/web2c:/usr/local/share/texmf/web2c
ralf@skye:~$ kpsewhere -show-path="web2c files" foo
/home/ralf/.texmf-var/web2c
/home/ralf/texmf/web2c
/etc/texmf/web2c
/var/lib/texmf/web2c
/usr/share/texmf/web2c
/usr/share/texmf-texlive/web2c

[The 'foo' seems to be nevessary to trick kpsewhere ... ]

So when looking for "cnf" files, the same path is used for every
search and hence the same file is found. In the case of "web2c files"
(and in most (all?) other cases) altering TEXMF does alter the search
path, which allows for finding different files.

cheerio
ralf



Reply to: