Stephane Chazelas <stephane.chaze...@gmail.com> wrote: > 2018-08-14 03:45:29 -0400, Shware Systems: > > By XCU 2.9.2 Exit Status, the ! is right associative and all > > shells should return 1 for "! break" in any context that > > permits a pipeline; even if the pipe only has one element and > > no "|" involved. I don't see that there's any ambiguity; while > > special, break is still considered a command, not a keyword > > like while or do. > [...] > > But "break" is meant to break out of the loop. One can argue > that it may happen *before* and preempts the shell retrieving > its exit status and apply ! on it.
break is a command that has an exit code that is the previous saved exit code and that has the side effect of leaving the loop. The ! statement negates the current saved exit code and makes it the new saved exit code. > Same applies for "! exit 0" or "! return 0". Should that return > with a 0 or 1 exit status? AFAICT, all shells return with 0 for > "exit", but ash-based shells and zsh return with 1 for "return". > > See also: > > $ mksh -c 'for i in 1 2; do echo "$?"; (exit 3); continue; done' > 0 > 3 I expect 0 0 > $ mksh -c 'for i in 1 2; do echo "$?"; ! continue; done' > 0 > 0 I expect 0 1 Jörg -- EMail:jo...@schily.net (home) Jörg Schilling D-13353 Berlin joerg.schill...@fokus.fraunhofer.de (work) Blog: http://schily.blogspot.com/ URL: http://cdrecord.org/private/ http://sf.net/projects/schilytools/files/'