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 12:20:43 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

On 2013-07-30 13:15, Pierre Gaston wrote:
> There are 2 loop levels in my example, but break only exit the subshell.

Yes, that's what I was saying. I think this should only exit the subshell
(although I'd like to see break and its family returning errors when you are
trying to operate on more loops than you currently have).

> My point is that now, return, break, continue all do the same thing:
> exit the subshell if they are inside one.
> This is a uniform behavior that can be easily documented.

I don't think we should choose this behaviour just because it can be documented
easily.

> Raising an error would mean more cases and it may be a good idea to
> think about all the cases and what that implies.
> eg another one:
>  foo () { if command; then return 1;else return 2;fi & }
> Should this raise an error? it doesn't look so alien to me

In my opinion, yes.

> while :;do ( if true;then continue;else echo again;fi);done # here
> continue seems ok, with an error I would be forced to use "exit"

I think this should return an error.

> while :;do ( if true;then break;else echo again;fi); echo bar;done #
> here it doesn't seem so great, an error would help.

I agree, this should return an error.

Attachment: pgp4sLDjabg9L.pgp
Description: PGP signature


reply via email to

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