Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , 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 Organization: My own little world... MIME-Version: 1.0 To: "'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> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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/