Section 27.11 introduces shell functions for all Bourne-type shells. This article covers details of functions in specific shells.
A system administrator might want to set read-only functions from a system-wide setup file (Section 3.3) like /etc/profile. bash users can't unset read-only functions, though. So once a function foo has been defined, how can you define your own foo? As Section 27.9 explains, you can type command foo to use a command named foo from your search path. Or define an alias named foo; aliases are used before functions. Finally, if you'd like to redefine the function, make an alias with the same name, then make the alias invoke a function with a (usually similar) name. For instance, to override a read-only function named foo:
alias foo=_foo function _foo( ) { ...your foo function... }
$ VISUAL=emacs work todo
For instance, maybe you use setopt nounset to make your interactive shell complain if you try to expand an unset shell variable. During your func function, though, you want to use the unset option to allow unset variables. Define the function like this:
function mullog( ) { setopt unset local_options ...do whatever... }
-- JP and SJC
Copyright © 2003 O'Reilly & Associates. All rights reserved.