[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bash: variables inside 'while'
From: |
Paul Jarc |
Subject: |
Re: bash: variables inside 'while' |
Date: |
Thu, 30 Aug 2001 12:11:56 -0400 |
User-agent: |
Gnus/5.090004 (Oort Gnus v0.04) Emacs/20.7 |
This belongs on bash-bug. Followup-To and Mail-Followup-To set.
zach@cs.uni-bonn.de (Gabriel Zachmann) wrote:
> cat file |
> while read p l
> do
> xx=$p
> echo xx=$xx
> break
> done
> echo xx=$xx
This is related to entry E4 in the bash FAQ. Each element of a
pipeline is run in a separate process, so variable settings are in
effect only within that element. Try this:
cat file | { while read p l; do ...; done; echo xx=$xx; }
Or this:
while read p l; do ...; done < file; echo xx=$xx
(but that will still break on some other sh'es.)
paul
- Re: bash: variables inside 'while',
Paul Jarc <=