Writing Better Shell Scripts � Part 1
Jun 16, 2010, 05:13 (0 Talkback[s])
Desktop-as-a-Service Designed for Any Cloud ? Nutanix Frame
"One of the difficulties with debugging a shell script is that
BASH typically doesn't give you very much information to go on. You
might get error output showing a line number, but that's just the
line where the shell became aware of the error, not necessarily the
line where the error actually occurred. Add in a vague error
message such as the one in Listing 1, and it gets difficult to tell
what's going on inside your script.
"This post is written with the intent of giving you knowledge
that will help when you see an error like the one in Listing 1
while trying to run a script. This type of error is just one of
many errors that the shell may give you, and is more easily dealt
with when you have a good understanding of scripting syntax and the
debugging tools at your disposal.
"Along with talking about debugging tools/techniques, I'm going
to introduce a handy script debugger called BASHDB. BASHDB allows
you to step through a script in much the same way as a program
debugger like GNU's GDB does with C code."