bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: exit from a piped while read does not exit program but function


From: Chet Ramey
Subject: Re: exit from a piped while read does not exit program but function
Date: Thu, 7 Mar 2002 09:04:02 -0500

> Machine Type: i586-pc-linux-gnu
> 
> Bash Version: 2.05a
> Patch Level: 0
> Release Status: release
> 
> Description:
>       [Detailed description of the problem, suggestion, or complaint.]
>       
> I have a test program below that reads a file in a function and if an error 
> occurs it is supposed to
> exit the program.  
> 
> However, as you can see from this simple program it does not exit.
> 
> Am I missing the purpose or function of the exit statement?

You are missing the fact that each element of a pipeline is run in a
subshell.  The `exit' exits the subshell, not the calling program.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet)

Chet Ramey, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]