unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* reading environment variables
@ 2008-01-03  8:28 Martin Rubey
  2008-01-04  1:24 ` Barry Margolin
  2008-01-06  8:41 ` Tim X
  0 siblings, 2 replies; 3+ messages in thread
From: Martin Rubey @ 2008-01-03  8:28 UTC (permalink / raw)
  To: help-gnu-emacs

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.

Many thanks,

Martin

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: reading environment variables
  2008-01-03  8:28 reading environment variables Martin Rubey
@ 2008-01-04  1:24 ` Barry Margolin
  2008-01-06  8:41 ` Tim X
  1 sibling, 0 replies; 3+ messages in thread
From: Barry Margolin @ 2008-01-04  1:24 UTC (permalink / raw)
  To: help-gnu-emacs

In article <9q1w8znwho.fsf@aquin.mat.univie.ac.at>,
 Martin Rubey <axiomize@yahoo.de> wrote:

> 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.

I don't think there's any general mechanism to look up variables in 
another process's environment.  This is a limitation in most OSes, not 
anything particular to Emacs.

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: reading environment variables
  2008-01-03  8:28 reading environment variables Martin Rubey
  2008-01-04  1:24 ` Barry Margolin
@ 2008-01-06  8:41 ` Tim X
  1 sibling, 0 replies; 3+ messages in thread
From: Tim X @ 2008-01-06  8:41 UTC (permalink / raw)
  To: help-gnu-emacs

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-01-06  8:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-03  8:28 reading environment variables Martin Rubey
2008-01-04  1:24 ` Barry Margolin
2008-01-06  8:41 ` Tim X

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).