bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: RFE? request for an "undefined" attribute for functions


From: Bernd Eggink
Subject: Re: RFE? request for an "undefined" attribute for functions
Date: Mon, 02 Aug 2010 21:11:23 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; de; rv:1.9.2.7) Gecko/20100713 Thunderbird/3.1.1

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<monoped@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

[Prev in Thread] Current Thread [Next in Thread]