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/

Reply via email to