default function in shell scripts

Hi,

Are their any default functions which can be written in a shell script to add new behavior.

May be I want to do something before the shell script starts and something which I would like to do at the end of script.

You can write as many functions as you want. Things that are being needed often with a great value of reuse.
Just write them as function in a separate file and in the main script, "source" them by

. /some/dir/_my_math.lib

for example.
So all functions defined in _my_math.lib will be recognized in the main script. Works like an include.

I am doing the same. using a file as library with a lot of useful function.

I was trying to find if any specific function is invoked by shell itself either at start up or during exit.

For example, at the end of script, I want to cleanup specific temp dir.
Today I have to call the cleanup function at the end of every script. I want to avoid doing this.
This make me think if shell can provide me a hook function which I can implement in this library which does the cleanup job.

Hope I could communicate my requirement ...