Menu

Tree [0c50c7] bash-5.0 / doc /
 History

HTTPS access


File Date Author Commit
 .cvsignore 2007-01-20 rockyb rockyb [5e2eb5] Get ready for 3.1-0.08 release
 .gitignore 2011-03-05 rocky rocky [f5aa61] Save and restore variables in debug command.
 Makefile.am 2017-08-17 rocky rocky [e6dcaa] doc Administrivia...
 README.md 2019-12-10 rocky rocky [b9d9a9] Update version and Add repology badge
 bashdb-man.pod 2016-08-13 rocky rocky [bd115d] in man page: -- goes after script name, not before
 bashdb.texi 2019-10-19 rocky rocky [396695] Add "debug" session example
 copyright.texi 2006-11-02 rockyb rockyb [e46d0d] Address Debian legal concerns, yet again. Actu...
 fdl.texi 2006-01-02 rockyb rockyb [59451c] Initial revision
 gpl.texi 2012-11-10 rocky rocky [9dc5a2] Allow STDIN to be used instead of a tty. Useful...
 how-to-make-a-release.md 2020-05-18 rocky rocky [e89032] Revise instruction on how to update.
 macros.texi.in 2006-01-02 rockyb rockyb [59451c] Initial revision
 notecase-HTML.sh 2014-09-13 rocky rocky [b533ef] tilde expansion reinstated, some embedded blank...

Read Me

Packaging status

Here we have a gdb-like debugger for Bash.

Selecting which version of bashdb to use

The version of bashdb to use has to be compatible with the version
of bash used. Run bash --version to see what version of bash you
are using.

  • If your version of bash is 5.0 or higher, use folder 5.0-1.1.2
  • If your version of bash is 4.4 or higher, use folder 4.4-1.0.1
  • If your version of bash is 4.3 or higher, use folder 4.3-0.91
  • If your version of bash is 4.2 or higher, use folder 4.2-0.8
  • If your version of bash is 4.1 or higher but less than 4.2 use folder 4.1-0.5
  • If your version of bash is 4.0 or higher but less than 4.1 use folder 4.0-0.4
  • If your version of bash is 3.1 or higher and less than 4.0, use folder 3.1-0.09.
  • If your version of bash is 3.0 or higher but less than 3.1, use the folder 3.00-0.05.

As you might guess from the above, the first part of the version in the bashdb version name matches the major version number of bash. This is intentional.

See file file INSTALL in the distribution for detailed installation
instructions.

Using the bashdb debugger

There are 3 ways to get into the debugger. If

  • bash (with debugger support enabled which is the default) is installed, and
  • the debugger is installed properly so that bash can find it

Then run:

bash --debugger -- bash-script-name script-arg1 script-arg2...

If bash isn't installed in a way that will find bashdb, then:

bashdb [bashdb-opts] -- bash-script-name script-arg1 script-arg2...

Note that the call stack will show the invocation to bashdb.

Finally, to invoke the debugger from the script

# my script
# work, work, work, ...

# Load debugger support
BASHDB_INSTALL=/usr/share/bashdb # ADJUST THIS!
source ${BASHDB_INSTALL}/bashdb-trace -L $BASHDB_INSTALL
# work, work, work or not...
_Dbg_debugger; :   # Calls the debugger at the line below
stop_before_running_this_statement

An advantage of the above is that there is no overhead up until you
invoke the debugger. Typically for large bash programs like
configuration scripts, this is a big win.

Important Note if you use the above to debug configure scripts...

stdin is closed by configure early on. This causes the debugger to quit.
You can get around this invoking a command script that sets debugger
up input and output. Run tty to figure out what the terminal tty is set to.

$ tty
/dev/pts/3
$

Above it came out to /dev/pts/3. Let's go with that. Put the folliwng
in a file say /tmp/bashdb-configure:

source /dev/pts/3
tty /dev/pts/3

Now arrange to read that configuration file using the -x (or --eval-command)
switch:

BASHDB_INSTALLATION=/usr/share/bashdb # ADJUST THIS!
source ${BASHDB_INSTALL}/bashdb-trace -L $BASHDB_INSTALL -x /tmp/bashdb-configure

codewall

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.