Paul Jarc wrote:
> [EMAIL PROTECTED] wrote:
> > a exit inside a loop inside a pipe exits's the loop and not the
> > script. may bee a error.
>
> This is normal. Each element of a pipeline is run in a child process.
Yes. Another more clear way of seeing this in the example would be
something like this which more clearly illustrates the pipeline aspect
of this issue.
#!/bin/bash
x() {
exit 1
}
echo foo | x
echo "after the pipeline"
> cat error.fil | while read a; do
Although I am sure this is reduced from a larger script the example
also has a "useless use of cat" as submitted. Changing from a
multiprocess pipeline to a single process fixes both. Here is a
slightly changed version of your example.
#!/bin/bash
x() {
exit 1
}
echo -e "1\n2\n" >error.fil
echo "start"
while read a; do
x
done < error.fil
# this should never be executed
echo "if you see this, it's an error"
By the way, thanks for posting such a good example illustrating the
behavior. Very nice. Thanks.
Bob
_______________________________________________
Bug-bash mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-bash