3

I installed bashdb on fedora 21 which uses bash 4.3 . I need to run using --debugger because I want $0 to be set correctly to the name of the script rather than bashdb.

bash --debugger my.bash

But the script is just executed, there is no debug session. On the other hand running:

bash --debugger my.bash "" 

works fine.

What am I doing wrong?

rocky
  • 7,226
  • 3
  • 33
  • 74
ericj
  • 2,138
  • 27
  • 44
  • 1
    I do not know how you installed `bashdb` but could it be that bash can't find it ? According to the doc http://bashdb.sourceforge.net/bashdb.html#Starting-the-BASH-debugger, you could try this way: `bash path-to-bashdb/bashdb bashdb-options -- script script-arguments...` – tgo Feb 27 '15 at 20:35
  • Hi, it doesn't work. By the way, `bash --debugger /usr/bin/bashdb my_script.bash` works. It seems I can only debug `/usr/bin/bashdb` with `bash --debugger`. But that does not help me with `$0`, because it is still `/usr/bin/bashdb` instead of `my_script.bash`. – ericj Feb 28 '15 at 20:47

2 Answers2

2

This is a bug that I think was introduced in bash 4.3: Wed Feb 26 09:36:43 2014 -0500 Bash-4.3 distribution sources and documentation

The code added that causes this is:

if (debugging_mode && locally_skip_execution == 0 && running_setuid == 0 && dollar_vars[1])
    start_debugger ();

I have posted a bug report on this. See http://lists.gnu.org/archive/html/bug-bash/2015-04/msg00183.html

The short story in the above thread is that although bash versions 4.3 up to 4.3.33 have this bug, in the next release after 4.3.33 (sometime after April 2015), this bug will be fixed.

rocky
  • 7,226
  • 3
  • 33
  • 74
0

When you use bash --debugger, the debugger has to be installed in the location that bash expects. Although the configure script tries to figure this out, many times it gets this wrong. To see where bash thinks the debugger should be installed, run:

strings /bin/bash | grep bashdb

On Ubuntu, the answer I got was: /usr/share/bashdb/bashdb-main.inc. So bashdb is expected to be installed in /usr/share/bashdb. Using this, then run configure like this:

/bin/bash ./configure -with-bashdb-main.inc=/usr/share/bashdb/bashdb-main.inc

rocky
  • 7,226
  • 3
  • 33
  • 74
  • Thanks, but that was not the problem. I debugged the source code of bashdb, and found out that you always have to give an argument, in my case an empty string, because I had no arguments. So $ bash --debugger myscript.sh "". – ericj Apr 28 '15 at 12:29
  • @ericj Um, I just deubgged the source code of _bashdb_ too; and it doesn't look like a problem in _bashdb_, but in _bash_ itself, possibly in _shell.c_ around line 724. (_bashdb_ has enough bugs on its own that you don't need to find bugs elsewhere to ascribe to it). I've just reported this in bugs-bash@gnu.org . However when you find something like this that looks like a bug, it would super if you'd report it as such either in bugs-bash@gnu.org or https://sourceforge.net/p/bashdb/bugs/ . Thanks. – rocky Apr 29 '15 at 02:20