how to write shell specific commands?

I am using Fedora 8,Red hat 9.
Whenever we write a new command. Then we goto "/usr/bin" and then place this in this directory.And hence we can use it as a command anywhere from the terminal.
We generally see commands like "trap" which run only in bash shell.We also have other shell specific commands which are limited to one shell alone...I wanted to know how is bash able to do it.How can we make a command work in one shell but not in the other ???

That is not a good idea, at all, for a variety of reasons. bash is already extensible - meaning you can write code to do special roll-your-own-commands, and then have bash include the command.

If you absolutely have to 'add commands' the way you are doing it, put the command scripts in /usr/local/bin or maybe /opt/local/bin/<some name>. The directory cannot be world write nor can any script be writable by anybody but root -- or you create giant security hole.

Now you can change the PATH variable at run time. If the PATH has ":/usr/local/bin" in it then you execute one of your special commands. If the PATH does not have it, then the special command will not be found. Simply change the PATH at runtime.