On Mon, 02 Sep 2013 05:27:55 -0400 (EDT), Matej Kosik wrote:
> 
> This morning I have been puzzled by bash.
> After typing the following command:
> 
>       for i in `seq 1 5`;do echo $i; test $i = 3 && break; done
> 
> I see:
> 
>       1
>       2
>       3
> 
> Which is OK.
> 
> However, if the "break" command appears in a subshell:
> 
>       for i in `seq 1 5`;do echo $i; test $i = 3 && (break); done
> 
> then the "break" command does not seem to have any effect
> 
>       1
>       2
>       3
>       4
>       5
> 
> I am curious, is this something to be expected?

Interesting.  If "break" appears out of context, you should get
an error message something like:

   bash: break: only meaningful in a 'for', 'while', or 'until' loop

You didn't get an error message, so part of bash thinks it is in context.
Yet it did not exit the loop.  It seems to me that you should get one
behavior or the other.  Either you should get an error message or it
should exit the loop.

-- 
  .''`.     Stephen Powell    
 : :'  :
 `. `'`
   `-


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: 
http://lists.debian.org/1155847423.2945873.1378139177503.javamail.r...@md01.wow.synacor.com

Reply via email to