Re: RFE? request for an undefined attribute for functions
Le 02/08/2010 20:11, Bernd Eggink a écrit : The other is that 'function' is clear and self-explaining, while 'name()' wrongly suggests that function parameters should be surrounded by parentheses. ... but only to people whose experience with Unix shells is close to zero. Functions are not really an advanced feature.
Re: RFE? request for an undefined attribute for functions
On Sun, Aug 01, 2010 at 06:10:31PM -0700, Linda Walsh wrote: I had(have) several functions that I don't use on a regular basis (rarely), that I had put into a subdir func_lib under my local-definitions directory. This came from ksh, which allows you to define functions with an undef attribute, and at runtime, the first time these functions were referenced, (You lost some words here.) Is this something that might have been considered for bash? It seems like it could have some usefulness? There is a command_not_found_handle in bash 4. You could define it to look for functions in your directory.
Re: RFE? request for an undefined attribute for functions
Am 02.08.2010 03:10, schrieb Linda Walsh: I had(have) several functions that I don't use on a regular basis (rarely), that I had put into a subdir func_lib under my local-definitions directory. This came from ksh, which allows you to define functions with an undef attribute, and at runtime, the first time these functions were referenced, Is this something that might have been considered for bash? It seems like it could have some usefulness? If you are concerned about memory usage, you could use a mechanism like this: #- function undef { local name for name do eval function $name { source $FUNCDIR/$name $name \\...@\ } done } #- The call undef f1 f2 f3 (corresponding to 'autoload f1 f2 f3' in ksh) creates small placeholder functions f1, f2, and f3. The first call to any of these functions will replace its definition by the one found in $FUNCDIR, and also call the latter. I'm not sure, however, if this is guaranteed to work in any case (and in any bash version). Greetings, Bernd -- Bernd Eggink http://sudrala.de
Re: RFE? request for an undefined attribute for functions
Bernd Eggink mono...@sudrala.de writes: eval function $name Don't use function, use $name () instead. Andreas. -- Andreas Schwab, sch...@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 And now for something completely different.
Re: RFE? request for an undefined attribute for functions
Am 02.08.2010 19:15, schrieb Andreas Schwab: Bernd Egginkmono...@sudrala.de writes: eval function $name Don't use function, use $name () instead. What's wrong with function?? Bernd -- Bernd Eggink http://sudrala.de
Re: RFE? request for an undefined attribute for functions
On 08/02/2010 12:15 PM, Bernd Eggink wrote: Am 02.08.2010 19:15, schrieb Andreas Schwab: Bernd Egginkmono...@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. -- Eric Blake ebl...@redhat.com+1-801-349-2682 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
Re: RFE? request for an undefined attribute for functions
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 Egginkmono...@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
Re: RFE? request for an undefined attribute for functions
On Mon, Aug 02, 2010 at 09:11:23PM +0200, Bernd Eggink wrote: 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. What?! imadev:~$ ksh -c 'unset var; var=main; foo() { typeset var; var=local; }; foo; echo $var' main That's ksh88. arc3:~$ ksh -c 'unset var; var=main; foo() { typeset var; var=local; }; foo; echo $var' local That's ksh93. Oh, how fun. Whee! Good thing I'm using bash, not ksh.
Re: RFE? request for an undefined attribute for functions
On 8/1/10 9:10 PM, Linda Walsh wrote: I had(have) several functions that I don't use on a regular basis (rarely), that I had put into a subdir func_lib under my local-definitions directory. This came from ksh, which allows you to define functions with an undef attribute, and at runtime, the first time these functions were referenced, Is this something that might have been considered for bash? It seems like it could have some usefulness? There are several versions of `autoload' in examples/functions. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/
Re: RFE? request for an undefined attribute for functions
On 8/2/2010 1:13 PM, Chet Ramey wrote: There are several versions of `autoload' in examples/functions. Chet === I've been using 'man bash' as my reference. I don't see a reference to examples or autoload, and finding 'functions' doesn't show me any examples. Is there another manpage I should be regularly consulting? Thanks! -linda
Re: RFE? request for an undefined attribute for functions
On Mon, Aug 02, 2010 at 01:20:58PM -0700, Linda Walsh wrote: On 8/2/2010 1:13 PM, Chet Ramey wrote: There are several versions of `autoload' in examples/functions. I've been using 'man bash' as my reference. I don't see a reference to examples or autoload, and finding 'functions' doesn't show me any examples. Is there another manpage I should be regularly consulting? examples is a subdirectory of the bash source code. functions is a subdirectory underneath that.
Re: RFE? request for an undefined attribute for functions
Linda Walsh wrote: On 8/2/2010 1:13 PM, Chet Ramey wrote: There are several versions of `autoload' in examples/functions. Chet === I've been using 'man bash' as my reference. I don't see a reference to examples or autoload, and finding 'functions' doesn't show me any examples. Is there another manpage I should be regularly consulting? It's a directory in the Bash distribution. Jan
RFE? request for an undefined attribute for functions
I had(have) several functions that I don't use on a regular basis (rarely), that I had put into a subdir func_lib under my local-definitions directory. This came from ksh, which allows you to define functions with an undef attribute, and at runtime, the first time these functions were referenced, Is this something that might have been considered for bash? It seems like it could have some usefulness?