Am 02.08.2010 20:16, schrieb Eric Blake:
On 08/02/2010 12:15 PM, Bernd Eggink wrote:
Am 02.08.2010 19:15, schrieb Andreas Schwab:
Bernd Eggink<mono...@sudrala.de>   writes:

          eval "function $name

Don't use function, use "$name ()" instead.

What's wrong with function??

'function name' is a bash extension while 'name()' is POSIX.  If you use
standard POSIX instead of bash extensions, then your approach will more
easily port to other POSIX shells.

It's not just a bash extension. Ksh and zsh also have the 'function' keyword, probably other shells as well. I prefer it in ksh because it makes locally declared variables really local, while with the name() syntax they are shared with the environment. That's one reason why it became a habit. The other is that 'function' is clear and self-explaining, while 'name()' wrongly suggests that function parameters should be surrounded by parentheses. Apart from that, I can't see why I should care for POSIX when writing bash-specific hacks.

Regards,
Bernd

--
Bernd Eggink
http://sudrala.de

Reply via email to