On Sat, Oct 30, 2021 at 4:50 PM Greg Wooledge <g...@wooledge.org> wrote: > As Chet said, it's counterintuitive. Most people don't expect function A > to be able to affect loops inside function B.
I do, and a subshell can prevent function A from affecting loops inside function B. But that is not a real problem, you wouldn't call, say `break 3', when you're only 2 loop levels deep in a function unless you wanted to exit from the loop from within the function is called after returning. > It's a violation of scope. It's a violation of lexical scope, I'm asking why not implement dynamic scope, what's wrong with it? > > Can you name *any* other language where functions can break out of their > caller's loops? The only thing that comes to mind for me is C's "longjmp", > which I've never used even once. (Not that I do any C programming these > days, but back in the 1990s, I did.) As far as I know `longjmp' is far more advanced than shell's break/continue. I can't name another language, but netbsd sh, busybox sh, and zsh are shells that implement dynamically scoped break and continue. > > What are you actually trying to do? > Nothing. Idle curiosity.