On Thu, 17 Nov 2011, Reinier Olislagers wrote:
Hi list,
It seems FPC allows one to retrieve environment variables on Linux/Unix
(GetEnvironmentVariable) but not to set them.
Is that correct?
Yes.
Some digging:
Setting environment variables on Unix with gnu libc:
http://www.gnu.org/s/libc/manual/html_node/Environment-Access.html#Environment-Access
int setenv (const char *name, const char *value, int replace)
The setenv function can be used to add a new definition to the
environment. The entry with the name name is replaced by the value
‘name=value’.
If replace = 1, replace existing variable.
This one seems not to be present in FPC libc code
Maybe something like (taken from netware source\rtl\netwlibc\libc.pp):
function setenv(_para1:Pchar; _para2:Pchar;
_para3:longint):longint;cdecl;external clib name 'setenv';
No. Unix works differently.
Environment variables are specified on startup, and are then immutable.
If you want to specify the environment for a process, you must do it at the
start.
Michael.
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal