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.