From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tim X Newsgroups: gmane.emacs.help Subject: Re: reading environment variables Date: Sun, 06 Jan 2008 19:41:43 +1100 Organization: Posted via Supernews, http://www.supernews.com Message-ID: <87abnjwdko.fsf@lion.rapttech.com.au> References: <9q1w8znwho.fsf@aquin.mat.univie.ac.at> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1199612481 7063 80.91.229.12 (6 Jan 2008 09:41:21 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 6 Jan 2008 09:41:21 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Jan 06 10:41:43 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JBS0k-0007rx-KS for geh-help-gnu-emacs@m.gmane.org; Sun, 06 Jan 2008 10:41:42 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JBS0N-0005Do-TD for geh-help-gnu-emacs@m.gmane.org; Sun, 06 Jan 2008 04:41:19 -0500 Original-Path: shelby.stanford.edu!headwall.stanford.edu!newsfeed.news2me.com!newsfeed.icl.net!newsfeed.fjserv.net!oleane.net!oleane!news.ecp.fr!feeder1.cambrium.nl!feed.tweaknews.nl!138.199.65.86.MISMATCH!sn-xt-ams-06!sn-xt-ams-05!sn-post-ams-02!sn-post-sjc-01!supernews.com!corp.supernews.com!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/23.0.50 (gnu/linux) Cancel-Lock: sha1:t1aRFn8THIGn61qOb+KE1T+6hGI= Original-X-Complaints-To: abuse@supernews.com Original-Lines: 44 Original-Xref: shelby.stanford.edu gnu.emacs.help:155105 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:50526 Archived-At: Martin Rubey 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