Getting environment variables?

Christopher Wright dhasenan at gmail.com
Sat Nov 22 18:28:30 PST 2008


Jarrett Billingsley wrote:
> On Sat, Nov 22, 2008 at 12:55 PM, Christopher Wright <dhasenan at gmail.com> wrote:
>> Hey all,
>>
>> How do I get environment variables in a D program? I specifically want the
>> path to a user's home folder.
>>
>> Ta muchly.
>>
> 
> In Tango, there's tango.sys.Environment
> (http://www.dsource.org/projects/tango/docs/current/tango.sys.Environment.html)
> which provides a nice interface to environment variables.
> 
> In Phobos, I think you have to use the C functions to get at
> environment variables, but std.path.expandTilde can be abused to get
> the home folder ;)

Thanks, that's exactly what I was looking for.

I thought (perhaps wrongly) C allowed you to declare main as taking a 
list of environment variables, which is why I asked here rather than 
Tango's forums. But D doesn't, so I probably should have asked at the 
library-specific forums.


More information about the Digitalmars-d-learn mailing list