[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: "exit" doesn't work from inside of PIPED read block
From: |
Bob Proulx |
Subject: |
Re: "exit" doesn't work from inside of PIPED read block |
Date: |
Mon, 19 Nov 2007 01:07:50 -0700 |
User-agent: |
Mutt/1.5.13 (2006-08-11) |
Blaine Simpson wrote:
> "exit" doesn't exit the current shell when inside of PIPED read blocks,
> yet everything works find if the input comes from "redirection".
This is because pipes operate in subshells and the exit applies to the
subshell. Please see the bash FAQ question E4 for more information.
ftp://ftp.cwru.edu/pub/bash/FAQ
> cat /tmp/atf | while read; do exit 3; done # for any text file /tmp/atf
> Yet the following works
> cat /tmp/atf | while read; do exit 3; done
Those two are the same. You probably meant to say:
while read; do exit 3; done < /tmp/atf
No pipeline there and so that is done in the current shell.
Bob