[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

setting env variables

From: Ian Mondragon
Subject: setting env variables
Date: Mon, 29 Jan 2001 01:29:02 -0500
User-agent: Mutt/1.2.5i


a while back i wrote in about the troubles i was having with simply setting
environment variables within a GNUstep program - i've just recommenced pounding
away on the program i was referring to (gshell - which populates a user's env
via the GNUstepDefaults as opposed to the shell's .rc file) and i've concluded
that something is inherently wrong with the difficulty involved in doing this.
objective-c is by far superior to many other languages just by allowing the
mixture of objective-c code with straight ANSI C code...which i think we can
all agree on.  this provides an objc programmer with options simply not there
for people working in other languages.  agreed?  ok.

but try something as simple as this:

// stupid test program to prove a point

#import <Foundation/Foundation.h>

int main(void)
  NSAutoreleasePool *pool;
  NSString          *test;

  // create and set an environment variable
  test = @"LOOK_AT_ME=fineAndDandy";
  putenv([test_one cString]);

  // print out the contents of the current environment

  // go bye-bye
  [pool release];

  return 0;

you'll see that the environment variables that get dumped during the course
of the program include the variable "LOOK_AT_ME".  unfortunately,  after the
program is done running, this variable no longer exists in your environment
due to the fact that this only modified the environment that NSProcessInfo
was holding on to for the course of the little test.

shouldn't there be a far simpler way to add variables to a user's environment
(i.e. sticking to the standard C routines putenv() and setenv()) than going
through the trouble of creating a subclass of NSProcessInfo and whatever other
garbage that may be neccessary to get the job done?

has anyone else run into the same problem for whatever reason?



Ian Mondragon  - address@hidden

FreeBSD - Objective-C - Python.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]