[Dev-luatex] kpse.find_file

Reinhard Kotucha reinhard.kotucha at web.de
Sun Feb 17 23:53:41 CET 2008


Hi,
I'm using kpse.find_file() in order to determine the location of some
config files.  In some cases I have to set kpse.set_program_name.

Here is the code:
_______________________________________________________

#!/usr/bin/env texlua
--*- Lua -*-

if string.find(arg[0], "/") then -- UNIX path
   filename=select(1, string.gsub(arg[0], ".*/", ""))
elseif string.find(arg[0], "\\") then -- Windows path
   filename=select(1, string.gsub(arg[0], ".*\\", ""))
else -- no path
   filename=arg[0]
end
basename=select(1, string.gsub(filename, "\.texlua$", ""))

kpse.set_program_name(filename, basename)

print(kpse.find_file('pdftexconfig.tex', 'tex', true))
print(kpse.find_file('config.ps', 'dvips config', true))

kpse.set_program_name('xdvi')
print(kpse.find_file('XDvi', 'other text files', true))

kpse.set_program_name('dvipdfm')
print(kpse.find_file('config', 'other text files', true))
print(kpse.find_file('dvipdfmx.cfg', 'other text files', true))

kpse.set_program_name(filename, basename)

os.exit(0)
______________________________________________________


The result is:
______________________________________________________

/home/reinhard/.texlive-alpha/texmf-config/tex/generic/config/pdftexconfig.tex
/home/reinhard/.texlive-alpha/texmf-config/dvips/config/config.ps
/home/reinhard/.texlive-alpha/texmf-config/xdvi/XDvi
nil
nil
______________________________________________________


Note that the last two entries are 'nil'.

When I comment out the line 

   print(kpse.find_file('XDvi', 'other text files', true))

then I get:
______________________________________________________

/home/reinhard/.texlive-alpha/texmf-config/tex/generic/config/pdftexconfig.tex
/home/reinhard/.texlive-alpha/texmf-config/dvips/config/config.ps
/home/reinhard/.texlive-alpha/texmf-config/dvipdfm/config/config
/home/reinhard/.texlive-alpha/texmf-config/dvipdfm/config/dvipdfmx.cfg
______________________________________________________


Is there anything wrong with the XDvi entry?  It produces correct
output but why are the other entries 'nil'?

Regards,
  Reinhard

-- 
----------------------------------------------------------------------------
Reinhard Kotucha			              Phone: +49-511-4592165
Marschnerstr. 25
D-30167 Hannover	                      mailto:reinhard.kotucha at web.de
----------------------------------------------------------------------------
Microsoft isn't the answer. Microsoft is the question, and the answer is NO.
----------------------------------------------------------------------------


More information about the dev-luatex mailing list