BS> There is no standard way to set an environment variable, although
BS> there are several more-or-less portable, albeit non-standard
BS> extensions.
It depends what one means by "non-standard". Just because something isn't in
ISO IEC 9899:1989 (The ISO C Standard) doesn't make it non-standard.
putenv() was in draft 3 of the first revision to ISO IEC 9445-1:1990, the
Portable Operating System API (C language) standard. Whether it made it into
the final document I don't know.
*However*, putenv() is *certainly* defined by some non-ISO standards, such as
UNIX95 and UNIX98 from The Open Group (putenv() can be found on page 672 of
the Single UNIX Specification, version 2). Since Jamie Kowinsky, the
original poster, was targetting two UNIX-like platforms, HP-UX and Linux, he
can perfectly happily use putenv().
He is even, in practice, guaranteed portability to non-UNIX and non-POSIX
platforms, like DOS, OS/2, and Windows NT, since just about all of the C/C++
compilers for those platforms implement the putenv() function (and, indeed,
many other POSIX functions, such as read() and close()).
¯ JdeBP ®
--- FleetStreet 1.19 NR
---------------
* Origin: JdeBP's point, using Squish (2:440/4.3)
|