test for function name?

Hi,

I found this:
http://www.unix.com/unix-advanced-expert-users/27318-how-see-function-shell.html
which indicates I can use typeset -f to list the functions.
But it also lists the contents of the functions. Is there a
lighter weight way to see what is defined? Is there an
internal array with the function names? Perhaps there is
a conventional idiom out there for asking your program if a
a particular function name is defined?

Thx.
:smiley:

whence functionname will return 0 or 1 depending on whether a function is defined or not. Of course it will also succeed if a matching programme is found in the PATH, in which case you could test for the presence of "is a function" in the output of whence -v functionname.

That's a Korn shellism I believe; in Bash the roughly equivalent builtin is type -- I think that's in POSIX too?

type is an alias for whence -v in Korn shell. I usually assume a POSIX shell unless another is mentioned! :wink:

Hmm, either you do or you don't? Quote: [whence] is a command unique to the Korn Shell.

type is not defined in IEEE Std 1003.1 (POSIX) or SUSv3 (Single UNIX Specification). It is a builtin in bash. whence is a builtin in ksh/ksh93/pdksh.