On Thu, Jun 05, 2008 at 06:31:36AM +0200, Jan Schampera wrote: [...] > The function definition is allowed in 3 forms: > 1. NAME() ...
That's the Bourne and POSIX syntax > 3. function NAME ... That's the ksh syntax. It's probably only there for compatibility with ksh (note that bash doesn't make the same distinctions as AT&T ksh does when using that syntax). ksh doesn't support function foo (echo), so it's fine with bash not to either, I'd say. > 2. function NAME() ... [...] Not sure where that syntax comes from. It could be that it works by accident or it could be that someone thought that it was a good idea to have yet another syntax. It happens to be the same syntax as awk. In anycase, given that those syntaxes are not different functionnaly (contrary to in ksh), I think it would be a good idea to have the manual say that only "1." should be used as it's the standard one. I suspect this: $ sh -c 'function() { echo a; }; function' sh: -c: line 0: syntax error near unexpected token `(' sh: -c: line 0: `function() { echo a; }; function' breaks POSIX conformance, BTW (but then it's the same for AT&T ksh, pdksh, zsh). -- Stéphane