3 ms·
Well, bash's new behaviour (noisily complain and do nothing, reporting success) doesn't do anything useful, so implementing it gratuitously breaks old code to n
by naniwaduni 5y ago
Well, bash's new behaviour (noisily complain and do nothing, reporting success) doesn't do anything useful, so implementing it gratuitously breaks old code to no gain.
Dynamic stack-crawling is more or less the most popular historical behaviour (though afaict the Bourne/Korn lineage just silently fails breaks outside the enclosing function); it's just generally consistent with everything else in the shell that's globally/dynamically scoped. Even in the shells where you can't break out of your enclosing function, `eval break` still breaks through loops in your current context, and that kind of looks like a function you called that called break if you squint.
(POSIX expressly leaves this case undefined with a carveout for break/continue inside the body of a function lexically contained within a loop.)