We hope that we have convinced you that bash can be used as a serious UNIX programming environment. It certainly has enough features, control structures, etc. But another essential part of a programming environment is a set of powerful, integrated support tools . For example, there is a wide assortment of screen editors, compilers, debuggers , profilers, cross-referencers, etc., for languages like C and C++. If you program in one of these languages, you probably take such tools for granted, and you would undoubtedly cringe at the thought of having to develop code with, say, the ed editor and the adb machine-language debugger.
But what about programming support tools for bash ? Of course, you can use any editor you like, including vi and emacs . And because the shell is an interpreted language, you don't need a compiler.  But there are no other tools available.
 Actually, if you are really concerned about efficiency, there are shell code compilers on the market; they convert shell scripts to C code that often runs quite a bit faster.
This chapter looks at some useful features that you can use to debug shell programs. We'll look at how you can utilize them in the first part of this chapter. We'll then look at some powerful new features of bash , not present in most Bourne shell workalikes, that will help in building a shell script debugging tool. At the end of the chapter, we'll show step by step how to build a debugger for bash . The debugger, called bashdb , is a basic yet functional program that will not only serve as an extended example of various shell programming techniques, but will also provide you with a useful tool for examining the workings of your own shell scripts.