My investigations indicate that it is still true that as per Debian bug report (https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=403304) --debugger does NOT start the debugger UNLESS the debugged script has a $1. For example

/bin/bash --debugger --  ~/scripts/ex1.sh

will just run the script but

/bin/bash --debugger --  ~/scripts/ex1.sh  XXX

will enter the debugger. To comment on the other prior information on the Debian bug report:

1. The upstream bashdb developer is correct that checking "strings `which bash` | grep bashdb" is a good test for whether bash will find bashdb-main.inc, but this is not relevant to Debian becase this is set correctly in Debian's case. 2. If you take an upstream tarball of bash and compile it then even the extra $1 will not make the debugger run under that bash, unless you link the upsteram location of '/usr/local/share/bashdb' to the Debian value of /usr/share/bashdb.

In other words the other commenters were correct but had not got to the root issue. The root issue is appears to be this line in shell.c in the bash code:

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

I enclose a patch that I believe would address this, and suggest it is an upstream bash issue.
Description: correct check on $0 in conditions for entering debugger
Author: Nicholas Bamber <nicho...@periapt.co.uk>
Bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=403304
Last-Update: 2015-10-12
Index: bash-4.3/shell.c
===================================================================
--- bash-4.3.orig/shell.c
+++ bash-4.3/shell.c
@@ -720,7 +720,7 @@ main (argc, argv, env)
   /* Bind remaining args to $1 ... $n */
   arg_index = bind_args (argv, arg_index, argc, 1);
 
-  if (debugging_mode && locally_skip_execution == 0 && running_setuid == 0 && dollar_vars[1])
+  if (debugging_mode && locally_skip_execution == 0 && running_setuid == 0 && dollar_vars[0])
     start_debugger ();
 
   /* Do the things that should be done only for interactive shells. */

Reply via email to