2009-10-28 09:46:49 -0400, Chet Ramey: [...] > >> The Posix grammar has never allowed it (a `function_body' must be a > >> compound command, and that's what bash implements), and there has > >> never been sufficient demand to add it as an extension. > > [...] > > > > It's never allowed it to POSIX _scripts_, but it won't make a > > shell non-conformant to support it (and ksh, pdksh, ash, zsh > > even posh all do support it), just like most POSIX conformant > > shells support arrays for instance even though that's not a > > POSIX feature. > > That's why I said it would be added as an extension.
Sorry, I overlooked that bit. > > bash not supporting it helps for writing POSIX compliant scripts > > (as it will return an error if one tries to use that > > non-standard feature), but as bash is the only POSIX shell that > > doesn't support it, it feels a bit silly. > > "Silly" it may be, but there's not really the demand for it. I can understand it. I was more curious about the origins. After all, that breaks Bourne backward compatibility (in a shell called Bourne-again shell)) and it seems more effort to exclude one form of command rather than include any form of command. f() for i in 1; do echo test; done f() { echo test; } > xx are allowed (and I doubt there has been a lot of demand for that), and can be confusing all the same (the second one for instance is not interpreted POSIXly by zsh). > > I wonder what's the rationale for POSIX not supporting it (is it > > because of bash?). > > That would be the tail wagging the dog, wouldn't it? It's never been > in the grammar. OK, but again, why exclude simple commands here? Would there be some implication? Has there be historical versions of sh that didn't support it? I guess I should ask the question on the POSIX list. Cheers, Stephane