help-bash
[Top][All Lists]
Advanced

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

[Help-bash] subtle "break" strangeness


From: Matej Kosik
Subject: [Help-bash] subtle "break" strangeness
Date: Mon, 02 Sep 2013 22:30:55 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130827 Icedove/17.0.8

Hi,

I would like to ascertain that what I see is what is desired (or not).

When I try:

        for i in `seq 1 5`;do echo $i; test $i = 3 && break; done

I see:

        1
        2
        3

So far, so good.

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.

The strange thing is that no error message appears
(as opposed to a situation when "break" is used outside "for", "while", or 
"until" loops).

The "break" command simply behaves as no-op.

(In the morning, I was trying to figure out what is wrong with the script and 
such an error message would have been helpful).

What do you think?



reply via email to

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