[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: effect of assignment to a shell variable inside while list is lost o
From: |
John Lumby |
Subject: |
Re: effect of assignment to a shell variable inside while list is lost outside list |
Date: |
Fri, 24 Jan 2003 12:54:30 -0500 |
Oh - I see - thanks. I think ksh, which I am used to, somehow avoids
this - it msut run the pipeline in a thread of the same proc.
In case you are interested, I found another way (not in the FAQ) of
handling this - instead of setting the rc inside the while read list, I
call a function which sends myself a signal, which I trap earlier and set
the rc there. Hideous and poorly performing if the signal is executed
many times, which in my case it isn't, but makes the programming inside the
loop more natural (to me).
Cheers, John
On 2003.01.24 12:16 Paul Jarc wrote:
> "John Lumby" <johnlumby@hotmail.com> wrote:
> > when I run this:
> > typeset -i rc=1;line="";echo -e "line 1\\nline 2" | while read
> -r
> > line; do { [[ "$line" == *1 ]] && rc=0 && echo "rc=$rc line=$line" &&
> > break; };done;echo "rc=$rc line=$line"
> >
> > I see this:
> > rc=0 line=line 1
> > rc=1 line=
>
> This is covered in entry E4 in the bash FAQ.
>
>
> paul
>