delorie.com/archives/browse.cgi | search |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sources.redhat.com/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/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: | <409A6618.79304D0D@dessent.net> |
Date: | Thu, 06 May 2004 09:21:44 -0700 |
From: | Brian Dessent <brian AT dessent DOT net> |
Organization: | My own little world... |
MIME-Version: | 1.0 |
To: | "'cygwin AT cygwin DOT com'" <cygwin AT cygwin DOT com> |
Subject: | Re: 1.5.9: Trouble with setting variables using 'read' in a script |
References: | <201BC46BD93D244AB0A910D1203FFC1904B6A873 AT ecexchange02 DOT euphony DOT com> |
X-IsSubscribed: | yes |
Reply-To: | cygwin AT cygwin DOT com |
Kevan Gelling wrote: > All of the following lines fail to set $var and return a blank line. > - echo "text" | read var ; echo $var > - cat file | read var ; echo $var > - read var < file | echo $var The other reply by Andy R is spot on, you can't modify the current environment from a subshell. If you want to use the above idioms, you can use: echo "text" | (read var; echo $var) This causes the 'echo' to be run from the same subshell as 'read', so it will see the modified environment. None of this is specific to Cygwin, it's the design of sh/ash/bash type shells, and so there are better places to ask about these kinds of things than the Cygwin list. Try looking for newsgroups, FAQs, or books dealing with Bourne shell programming. 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/
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |