unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Tim X <timx@nospam.dev.null>
To: help-gnu-emacs@gnu.org
Subject: Re: reading environment variables
Date: Sun, 06 Jan 2008 19:41:43 +1100	[thread overview]
Message-ID: <87abnjwdko.fsf@lion.rapttech.com.au> (raw)
In-Reply-To: 9q1w8znwho.fsf@aquin.mat.univie.ac.at

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

      parent reply	other threads:[~2008-01-06  8:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87abnjwdko.fsf@lion.rapttech.com.au \
    --to=timx@nospam.dev.null \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).