David Ross wrote:

> > i am dumbfounded as to why setenv() does nothing.  
> > this is the code fragment:
> > 
> > setenv(env_name, new_value, 1);
> > 
> > env_name's contents are 'TERM', and new_value contains 'vt100'.  After
> > running the program, however, I notice that TERM still contains the value
> > 'linux'.  Did I just change the value of term for the duration of my 
> > program?  If so, how can I make the change permanent?
> 
> Try reading the manpages for fork and exec[v](2). When a process is created the 
> address space of the parent including enviroment strings is cloned. Any changes 
> that the child process makes are not visible to the parent unless the parent 
> uses the dot (.) operator or the child process explicitly exports changes.
> 
> If you invoke your program as follows you should get the result you want:
> 
> coolprompt> . proggy

Nope, that won't work. `source' (or `.') only works for shell scripts. 
It simply reads the contents of the specified script as if it were
part of the input stream (either user input, or the script which
performs the `source').

The only solution is to make the program emit shell commands, and then 
use
        eval `proggy`

This is the approach which `dircolors' uses.

-- 
Glynn Clements <[EMAIL PROTECTED]>

Reply via email to