| delorie.com/archives/browse.cgi | search |
| X-Spam-Check-By: | sourceware.org |
| To: | cygwin AT cygwin DOT com |
| From: | Matthew Woehlke <mw_triad AT users DOT sourceforge DOT net> |
| Subject: | Re: bash does not retain env when running script |
| Date: | Tue, 14 Nov 2006 13:52:09 -0600 |
| Lines: | 30 |
| Message-ID: | <ejd6p9$h8e$1@sea.gmane.org> |
| References: | <20061114183911 DOT 4926 DOT qmail AT web32701 DOT mail DOT mud DOT yahoo DOT com> |
| Mime-Version: | 1.0 |
| User-Agent: | Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.8) Gecko/20061025 Thunderbird/1.5.0.8 Mnenhy/0.7.4.0 |
| In-Reply-To: | <20061114183911.4926.qmail@web32701.mail.mud.yahoo.com> |
| X-IsSubscribed: | yes |
| Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
| List-Unsubscribe: | <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com> |
| 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 |
Arto Stimms wrote:
> I would like to run a bash script with a few changes in the environment. I would expect this to work:
> [snip]
> As a small example I have tried using these two minimal files
>
> init.sh:
> hello () { echo "hello world"; }
> alias listdir=ls
>
> script:
> hello
> listdir
>
> I get the following output:
>
> $ bash --rcfile init.sh script
> script: line 1: hello: command not found
> script: line 2: listdir: command not found
>
> What can I do to make my changes work in the script?
'script' is being run in a subshell, and you cannot export aliases to a
subshell (but there are things you can do to get an rc file to run for a
subshell; read 'man bash'). For the function, try 'export'ing it.
None of this has anything to do with Cygwin.
--
Matthew
Not to be used as a flotation device.
--
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/
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |