[m-users.] How to get the environment

Volker Wysk post at volker-wysk.de
Sun Mar 24 21:56:15 AEDT 2019


Am Sonntag, 24. März 2019, 02:34:36 CET schrieb Peter Wang:
> On Fri, 22 Mar 2019 12:50:18 +0100, Volker Wysk <post at volker-wysk.de> wrote:
> > Hi
> > 
> > There is io.get_environment_var/4, but this gets just one environment
> > variable. For the posix.exec/5 predicate, the entire environment is
> > needed, as a map(string,string). There are no foreign predicates for the
> > other variants of exec (such as execv), which don't require the
> > environment.
> > 
> > I've searched in the io and posix libraries, but couldn't find any way to
> > query the entire environment. Could it be that there isn't any...?
> 
> Hi,
> 
> There isn't any yet, possibly because POSIX does not define any way to
> do so. The foreign proc would need to read from the non-POSIX `environ'
> global variable or _NSGetEnviron() on MacOS.

I could add support for the "exec" variants "execv" and "execvp", which use 
the existing environment, and don't take a new environment as an argument. 
This would be the first time I do something like this in Mercury, but it 
should not be difficult, since "execv" is already implemented. 

Bye
Volker




More information about the users mailing list