help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: reading environment variables


From: Tim X
Subject: Re: reading environment variables
Date: Sun, 06 Jan 2008 19:41:43 +1100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/23.0.50 (gnu/linux)

Martin Rubey <axiomize@yahoo.de> writes:

> Dear gnu emacs gurus,
>
> I'm trying to get hold of an environment variable a process sets that I'm
> starting with make-comint.
>
> I know of getenv, but that doesn't seem to do the right thing: as far as I can
> see it only knows about variables that affect emacs, rather than a given
> process.
>
> Unfortunately, the value of this variable decides how emacs will communicate
> with the subprocess, therefore I cannot really ask the process about the
> value...  Well, maybe I can somehow, but I'm hoping for an easy way.
>

The getenv function will report on any environment variable which existed
and was exported from the parent shell running emacs - that is, all
environment variables that are defined in the environment when emacs
started. 

When a shell variable is created, it is local to the process where it was
created. If the variable is also 'exported', it will be visible to
sub-processes. However, variables created in a sub process are not visible
to parent processes even if the variable is exported. Your problem here is
that the comint process you are starting is a sub process of your emacs
session. Any variables created as part of that process will not be visible
to the parent process (i.e. emacs).

There are a number of ways you may be able to get around this issue,
depending on whether you can edit the script or program you are running as
a sub process. For example, you could have it write the information to a
temp file or possibly return the information via stdout/stderr
etc. However, there is no standard way to communicate a variable's value
back to a parent process. 

Could you just set the env variable in your .bash_profiel (or whatever)
prior to starting emacs? 

Tim


-- 
tcross (at) rapttech dot com dot au


reply via email to

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