delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/06/07/11:32:53

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: <20020607153155.27751.qmail@web14407.mail.yahoo.com>
Date: Fri, 7 Jun 2002 08:31:55 -0700 (PDT)
From: Gerald Reno <grenoml AT yahoo DOT com>
Subject: Re: Cygwin 1.3.10 read command and W2K
To: Randall R Schulz <rrschulz AT cris DOT com>, cygwin AT cygwin DOT com
In-Reply-To: <5.1.0.14.2.20020606224316.01bfadc8@pop3.cris.com>
MIME-Version: 1.0

Ah yes, I had forgotten about the subshell.  Isn't
there a construction such as "echo text |& read -p
var" that will allow you to read into parent shell?


--- Randall R Schulz <rrschulz AT cris DOT com> wrote:
> Gerald,
> 
> [ The usual disclaimer: None of this is Cygwin
> specific. ]
> 
> 
> When you use a pipe, the shell forks. In your
> example, the read command was 
> occurring in a forked sub-shell, and hence the
> side-effect on $var is not 
> seen in the shell that reads and interprets the
> pipeline you gave (and 
> subsequent commands).
> 
> Compare the output of this pipeline:
> 
> % echo foo |read bar; echo $bar
> 
> %
> 
> With that of this one:
> 
> % echo foo | (read bar; echo $bar)
> foo
> %
> 
> 
> Depending on the complexity of your script, this
> construct might work:
> 
> % bar="$(echo foo)"
> % echo $bar
> foo
> 
> 
> Randall Schulz
> Mountain View, CA USA
> 
> 
> 
> At 13:01 2002-06-06, Gerald Reno wrote:
> >I have scripts with reads that are failing.  Why
> doesn't "echo text | read 
> >var; echo $var" work?  var is just empty.  Doesn't
> 'read' default to 
> >stdin?  All other commands seem to be working only
> read is having problem.
> 


__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.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