A recent post about debugging constructs surprised me. There were quite a few comments about how you didn’t need a debugger, as long as you had
printf. For that matter, we’ve all debugged systems where you had nothing but an LED to flash or otherwise turn on to communicate with the user. However, it is hard to deny that a debugger can help with complex code.
To say you only need
printf would be like saying you only need machine language. Technically accurate — you can do anything in machine language. But it sure makes things easier to have an assembler or some language to help you work out your problem. If you write a simple bash script, you can use the equivalent to
printf — maybe that’s the
echo command, although there is usually a
printf command on a typical system, if you want to use it. However, there are other things you can do with bash including a pretty cool debugger if you know how to find it.
I assume you already know how to use
printf, but let’s dig into how to use trace execution line by line without the need for
echo statements on every other line. Along the way, you’ll learn how to get started with the bash debugger.