Hi Bruce,

Am 19.08.25 um 03:35 schrieb Bruce Horrocks:
On 18 Aug 2025, at 18:34, Henning Hraban Ramm <te...@fiee.net> wrote:

I guess that was what I was asking for, but not what I needed.

I'm still confused as to what you're actually trying to do!

In a module, I want to accept paths that contain ~ (=$HOME) or other shell variables.

For my current needs, I only need to expand ~, but I’m trying to learn to do things in Lua that I know in Python.

$TEXMFsomething was a bad example since the TeX variables contain a list of directories.

An OS independent solution would be best – since it’s %HOME% on Windows, AFAIK.

1) Do you want a list of all environment variables that are set? If so and your target 
system is Unix-like, then there is the command `printenv` that you could call via 
os.execute("printenv").

no

2) Do you want process a string containing a file path where some of the 
components might be environment variables and you want to expand them the way 
the shell would?

yes

If so then there is a Posix function `wordexp` (man 3 wordexp) which does that. 
You'll need to wrap it in a C API call.

wordexp looks like the right thing, but I don’t speak C – would I need to write & compile some C code for that? It looks like that in the Lua manual.

There’s also luaposix, but I’d like to avoid a dependency.

Hraban
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / 
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