delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/05/21/04:53:30

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <428EF711.46C085B2@dessent.net>
Date: Sat, 21 May 2005 01:53:37 -0700
From: Brian Dessent <brian AT dessent DOT net>
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: setting environment variables from a bash script
References: <052d01c55de0$2382f690$0400a8c0 AT AMDLAPTOP1>
X-IsSubscribed: yes
Reply-To: cygwin AT cygwin DOT com

Aaron Gray wrote:

> Is it possible to set an environment variable using a bash script and for
> that variable to be able to be seen within bash once the script is
> finnished.

It's impossible for a child process to modify the environment of its
parent.  By executing the file as a script you spawn a shell subprocess,
meaning the changes to the environment are for that process only.

You can get around that by sourcing the script instead of executing it,
because in that case you tell the current shell to read and execute the
commands in the file rather than spawning a subprocess to do it.

Brian

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019