On 8/18/2025 3:10 PM, Henning Hraban Ramm wrote:
How would you resolve shell/environment variables like $TEXMFHOME or ~ ($HOME) in Lua code?

dir.expandname doesn’t do that.

Search and replace iterating over os.env?

These tex related variables are often encoded in a special way so you need to do more (and also know hoe that coding works). Anyway, it's not the kind of code one sees / uses everyday (but it's nearly 20 years old now so quite stable):

\startluacode
    local function whatever(v)
        local p = resolvers.expandedpathlistfromvariable(v)
        inspect(p)
        for i=1,#p do
            print(resolvers.resolve(p[i]))
        end
        for i=1,#p do
            print(resolvers.cleanpath(resolvers.resolve(p[i])))
        end
    end
    whatever("TEXMFHOME")
    whatever("TEXMF")
\stopluacode

which of course you will now wikify ...

  mtxrun --help

show some options to explore variables and paths

(we're operating in TDS but context has a bit more abstraction so that we can relocate trees easier)

Hans

Hans

-----------------------------------------------------------------
                                          Hans Hagen | PRAGMA ADE
              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
       tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : [email protected] / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

Reply via email to