[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bug in function return statement in while subshell
From: |
Greg Wooledge |
Subject: |
Re: Bug in function return statement in while subshell |
Date: |
Tue, 30 Jul 2013 08:07:57 -0400 |
User-agent: |
Mutt/1.4.2.3i |
On Tue, Jul 30, 2013 at 01:15:59PM +0300, Pierre Gaston wrote:
> >> 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?
The break occurs in a subshell, which means it cannot communicate what
I presume to be the programmer's intent to the parent shell.
All bash can do is pretend the 2 isn't there.
> foo () { if command; then return 1;else return 2;fi & }
> Should this raise an error? it doesn't look so alien to me
It looks "alien" to me, because I can't figure out what the programmer
THINKS is supposed to happen. Does the programmer think the "return"
will cause the function's return status to be set? That's what it looks
like to me, but of course that's NOT what will happen, so to me it
appears the programmer does not know how this language works. On the
other hand, maybe the programmer intends to use "wait" to retrieve the
exit status later (in which case one may argue that "exit" would have
been clearer than "return").
Should it "raise an error"? No. All the syntax is correct.
Is it a programming error? Maybe. Depends on the intent.
- Re: Bug in function return statement in while subshell, (continued)
Re: Bug in function return statement in while subshell, Roman Rakus, 2013/07/29
- Re: Bug in function return statement in while subshell, Pierre Gaston, 2013/07/30
- Re: Bug in function return statement in while subshell, Chris Down, 2013/07/30
- Re: Bug in function return statement in while subshell, Pierre Gaston, 2013/07/30
- Re: Bug in function return statement in while subshell, Chris Down, 2013/07/30
- Re: Bug in function return statement in while subshell, Pierre Gaston, 2013/07/30
- Re: Bug in function return statement in while subshell, Chris Down, 2013/07/30
- Re: Bug in function return statement in while subshell,
Greg Wooledge <=
Re: Bug in function return statement in while subshell, Chet Ramey, 2013/07/30
Re: Bug in function return statement in while subshell, Roman Rakus, 2013/07/30
Re: Bug in function return statement in while subshell, Greg Wooledge, 2013/07/30
Re: Bug in function return statement in while subshell, Chris Down, 2013/07/30
Re: Bug in function return statement in while subshell, Chet Ramey, 2013/07/30