[Top][All Lists]

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

Re: [Help-bash] subtle "break" strangeness

From: Chet Ramey
Subject: Re: [Help-bash] subtle "break" strangeness
Date: Tue, 03 Sep 2013 10:16:37 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130801 Thunderbird/17.0.8

On 9/2/13 5:30 PM, Matej Kosik wrote:

> However, when I try:
>       for i in `seq 1 5`;do echo $i; test $i = 3 && (break); done
> then I see:
>       1
>       2
>       3
>       4
>       5
> I guess that "break" need not to be supposed to work inside a subshell.

How can it?  The subshell started to run `break' understands that it is
running in a loop -- it inherits that understanding from its parent --
but there is no way to communicate the `breaking' status from a child
back to its parent.

``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden

reply via email to

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