Re: finding locations of many files via kpse

Erik Nijenhuis <[email protected]>
Newsgroups gmane.comp.tex.texhax
Message-ID <[email protected]>
I was a little bit confusing for option two I guess. Here's the MWE:

Execute with: texlua kpse_search.lua

For example:
texlua kpse_search.lua logo.png gitinfo-lua.lua lua-placeholders.sty

Prints:
Found: logo.png -> /home/erik/texmf/tex/generic/images/logo.png
Found: gitinfo-lua.lua -> /home/erik/src/latex/gitinfo-lua/scripts/gitinfo-
lua.lua
Found: lua-placeholders.sty -> /home/erik/src/latex/lua-placeholders/tex/lua-
placeholders.sty

Contents kpse_search.lua:
-- kpse_search.lua

local kpse = kpse or require 'kpse'

kpse.set_program_name('lualatex')

local function print_usage()
    print("Usage: kpse_search.lua <path1> <path2> ... <pathN>")
end

local paths = arg

if #paths == 0 then
    print("No paths provided.")
    print_usage()
    os.exit(1)
end

for _, path in ipairs(paths) do
    local result = kpse.find_file(path)
    if result then
        print(string.format("Found: %s -> %s", path, result))
    else
        print(string.format("Not found: %s", path))
    end
end
-- end of file

Sorry for the earlier clutter :|
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.