bug-bash
[Top][All Lists]
Advanced

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

Re: Bug in function return statement in while subshell


From: Chris Down
Subject: Re: Bug in function return statement in while subshell
Date: Tue, 30 Jul 2013 11:51:32 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

On 2013-07-30 12:45, Pierre Gaston wrote:
> On Tue, Jul 30, 2013 at 12:29 PM, Chris Down <address@hidden> wrote:
> > On 2013-07-30 12:11, Pierre Gaston wrote:
> >> what about things like this: foo () (  return 1; )
> >
> > Except in this case, the return has a valid context. I don't see how it's 
> > really
> > comparable to the represented case.
>
> It's a return in a subshell in a function, i don't think the
> comparison is far fetched.

Except in this case the function and the subshell are linked constructs.

> I see what you mean,  but that raises the question of what's a valid context.
> Should we make a special case if the subshell is the "outer" compound
> command of a function?

I am not totally convinced that this is a special case since the subshell
basically becomes the declaration.

> The same thing with by break and continue example:
>
> while :;do ( while :;do break 2; done);echo foo;done
>
> Should this raise an error? is the break in a loop context? what's a
> loop context?

Well, breaking to an undef level is already allowed and doesn't return an error
(although I think that's not your point).

        $ while :; do break 999; done
        $ echo $?
        0

If you mean "should it break the outer loop", then my opinion is no.

Attachment: pgpWelQ9ogZP0.pgp
Description: PGP signature


reply via email to

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