On Sat 31 May 2014 at 23:51:35 +0000, David Holland wrote: > On Sat, May 31, 2014 at 05:14:26PM -0400, Richard Hansen wrote: > > Not necessarily. POSIX does not define "enclosing loop", so it could be > > interpreted as syntactic enclosure (a break/continue command must be a > > command in the compound list associated with the loop for the loop to > > qualify as enclosing the command) or logical enclosure as experienced > > during execution. I can see pros and cons to either behavior. > > Offhand, I would say that continues and breaks should be statically > scoped; dynamic scoping is almost always a mistake. So you certainly > shouldn't be able to break from a loop by calling a function that > contains a break outside a loop. (Although netbsd's sh, bash, and zsh > all seem to allow this, I would call it a bug. ksh rejects it.) I agree. The other way is clearly unworkable. A function with a break or continue outside a loop would be incorrect to call except inside a loop. That is ludicrous. > How this applies to a sourced file isn't so clear though, at least > offhand, as the point of sourcing a file is to read and evaluate it > within the current context. My inclination would be that sourcing a > file is not the same as calling a function; however, I'm far from an > expert on sh. I would say here too that static checking should be the norm. Except that there is an inherent non-staticness here: the file could have been generated dynamically, or the name of the file could be dynamic, or perhaps even more annoying non-static things. -Olaf. -- ___ Olaf 'Rhialto' Seibert -- The Doctor: No, 'eureka' is Greek for \X/ rhialto/at/xs4all.nl -- 'this bath is too hot.'
Attachment:
pgpHWuEWtrOon.pgp
Description: PGP signature