Debugging bash scripts.

Ralf Mardorf silver.bullet at zoho.com
Sat Feb 16 20:02:31 UTC 2019


On Sat, 2019-02-16 at 19:11 +0000, Ian Bruntlett wrote:
> Thanks for your replies. I'm looking for a Bash debugger because I'm
> working my way through "The Linux Command Line" (downloadable as a PDF
> from http://linuxcommand.org/tlcl.php  - I have the printed version)
> and I am being thorough and want to use Bash and a debugger to gain
> fluency in bash.

Well that's fair enough :)!

I'm an Assembly language dino who migrated from Commodore 64 and Atari
ST (+ 80286 hardware emulator) to Linux, so regarding to my background I
even prefer the trial-and-error principle and some googling over even
reading man bash and man dash, let alone the guide you mentioned or
similar guides. Actually most of my older scripts would have benefit
from reading the man pages in the first place :D. At least the 'shift'
command did render tons of lines of my old script needless. However,
there are some common used guides available. I was stupid and mostly
ignored them, so I actually don't remember the links. IIRC the common
recommended guides might be
https://www.tldp.org/LDP/Bash-Beginners-Guide/html/ and 
https://www.tldp.org/LDP/abs/html/, but I might be mistaken, somebody
else should chime in.

A debugger for shell scripts IMO still seems to be inappropriate, but
it's possible that I miss the benefits of such a debugger, OTOH
seemingly neither Ubuntu and Debian, nor Arch provide it by official
repositories. At least for Arch I found a user repository providing 
https://aur.archlinux.org/packages/bashdb/, "Description: A debugger for
Bash scripts loosely modeled on the gdb command syntax".

While I'm nowadays able to understand the "--help" and "man pages"
syntax, I remeber that it was way to hard to understand when I started,
so Google and guides are good in combination with the trial-and-error
principle.

While I prefer other search engines over Google, Google most of the
times provide better search results, if we are unaware about the
smartest search terms ;).

I wonder if somebody on this list does use a debugger for bash scripts.

Regards,
Ralf

PS: I try to write scripts that are at lest bash and dash compatible. As
the log in shell I prefer bash, because I use it for almost everything
directory/file and package management related on Ubuntu and Arch Linux,
but to run fast scripts, I prefer dash over bash, when ever possible. In
short, dash is faster, but so called 'bashisms' sometimes are more
comfortable to use. Dash is more portable than bash, assuming you want
to take a look at other POSIX/UNIXoid operating systems. However, bash
without doubts is used as the most common login shell for Linux distros,
so it's wise to care about bash.

I still doubt that the debugger is useful, but perhaps the time comes
you are able to prove me wrong :).








More information about the ubuntu-users mailing list