Shell script functions

Simple shell script :

date
test_fn()
{
echo "function within test shell script "
}

on the shell prompt I run
> . test

Then I invoke the function on the command line as below :
test_fn()

It echos the line
function within test shell script
and works as expected.

Question (1) how do I find out what are all the shell functions known to the current shell ? I tried set but that does not show my function . I tried which test_fn but that too says it does not know about test_fn
(2) how to I make the current shell get rid of the function. I tried unset test_fn - but that does not do it and returns an exit status of 1.

Thank you
Ram

try man bash! (or ksh,csh-tcsh whichever)
it will give you the right
variables to find status and such

for example
if you want to know the return status of the last command
type:
$ $?

to find out what parameter options were set i believe its
$- (ex, set -C,) would return a noclobber option
and so on..

man bash is usually where you will get answers to questions like
these.. set -F etc, etc.

hope that helps :slight_smile:
moxxx68

moxxx68 - Thanks for your reply, but, that didn't help much.
I want to know what are the exact command and switches in order to display the names of all the functions currently known to the shell.
And how to remove the definition of the function from the shell.

Thanks,
Ram

In ksh, use "typeset +f" and "unset -f".

can't be that difficult to look it in the man pages can it?
moxxx68
your're welcome! :eek: :smiley: :smiley:

Perderabo - Super ! Those worked. Thanks much.