Skip to content

Collect selected cli args and pass them to sub-invocations of bashrc#72

Open
hawicz wants to merge 1 commit into
Trepan-Debuggers:bash-5.2from
hawicz:bash-5.2
Open

Collect selected cli args and pass them to sub-invocations of bashrc#72
hawicz wants to merge 1 commit into
Trepan-Debuggers:bash-5.2from
hawicz:bash-5.2

Conversation

@hawicz

@hawicz hawicz commented Jun 28, 2026

Copy link
Copy Markdown

…through the "debug" command. Fixes Issue #71

@rocky

rocky commented Jun 28, 2026

Copy link
Copy Markdown
Collaborator

@hawicz Thanks for doing this. I'll look at this in detail a little later.

Comment thread init/opts.sh
_Dbg_tty:--tty=
_Dbg_tty_in:--tty_in=
_Dbg_tmpdir:--tempdir=
_Dbg_set_linetrace:--trace

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I needed to add:

_Dbg_libdir:-L=

because, my initial bash invocation was:

/tmp/bashdb/bashdb -L /tmp/bashdb --tty /dev/tty --tty_in /dev/tty /tmp/somescript

Here is what I got initially without the above change (following the issue instructions):

$ git checkout HEAD
bash debugger, bashdb, release 5.2-1.2.0

Copyright 2002-2004, 2006-2012, 2014, 2016-2019, 2021, 2023-2024 Rocky Bernstein
This is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.

/tmp/bashdb/init/opts.sh: line 294: ((: /tmp/bashdb: syntax error: operand expected (error token is "/tmp/bashdb")
(/tmp/somescript:1):
1:	/tmp/otherscript
bashdb<0> 
bashdb: That's all, folks...

@rocky

rocky commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

It all looks good, but I think there is one more bashdb variable that needs to get passed through (Ddbg_dir or the -L option).

The thing I'd ask though, is to work up some test for this. It could either be a unit test using shunit (in test/unit) or an integration tests (in test/integration) or both — up to you.

@hawicz

hawicz commented Jun 29, 2026

Copy link
Copy Markdown
Author

Hmm... I thought there already was special handling for the -L option, and I didn't want to duplicate what that was doing. I'll take a other look

@hawicz

hawicz commented Jul 3, 2026

Copy link
Copy Markdown
Author
cd /tmp
git clone  git clone  https://github.com/hawicz/bashdb
cd bashdb
./autogen.sh
./configure --prefix /tmp/inst
make && make install

Followed by the steps from #71, except I changed the bashdb command to:

/tmp/inst/bin/bashdb -L /tmp/inst/share/bashdb --tty /dev/tty --tty_in /dev/tty /tmp/somescript

uerh@LAPTOP-UVU6TEG3:/tmp/bashdb/myrepo$ git checkout HEAD
bash debugger, bashdb, release 5.2-1.2.0

Copyright 2002-2004, 2006-2012, 2014, 2016-2019, 2021, 2023-2024 Rocky Bernstein
This is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.

(/tmp/somescript:1):
1: /tmp/otherscript
bashdb<0> debug
Debugging new script with /usr/bin/bash /tmp/inst/bin/bashdb -q -L /tmp/inst/share/bashdb --tty /dev/tty --tty_in /dev/tty --tempdir /tmp -- /tmp/otherscript
(/tmp/otherscript:1):
1: echo in otherscript

I also tried using the uninstalled script from /tmp/bashdb with

/tmp/bashdb/bashdb -L /tmp/bashdb --tty /dev/tty --tty_in /dev/tty /tmp/somescript

but with the same working result. I'm using bash 5.2.37.

the relevant lines in opts.sh are:

    293         elif (( subarg_var )) ; then
    294             _Dbg_subdebug_args+=("${subarg_cli%}")
    295         fi

So I don't understand how you could have seen that error on line 294.

@rocky

rocky commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator
cd /tmp
git clone  git clone  https://github.com/hawicz/bashdb
cd bashdb
./autogen.sh
./configure --prefix /tmp/inst
make && make install

Followed by the steps from #71, except I changed the bashdb command to:

/tmp/inst/bin/bashdb -L /tmp/inst/share/bashdb --tty /dev/tty --tty_in /dev/tty /tmp/somescript

uerh@LAPTOP-UVU6TEG3:/tmp/bashdb/myrepo$ git checkout HEAD
bash debugger, bashdb, release 5.2-1.2.0
Copyright 2002-2004, 2006-2012, 2014, 2016-2019, 2021, 2023-2024 Rocky Bernstein
This is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
(/tmp/somescript:1):
1: /tmp/otherscript
bashdb<0> debug
Debugging new script with /usr/bin/bash /tmp/inst/bin/bashdb -q -L /tmp/inst/share/bashdb --tty /dev/tty --tty_in /dev/tty --tempdir /tmp -- /tmp/otherscript
(/tmp/otherscript:1):
1: echo in otherscript

I also tried using the uninstalled script from /tmp/bashdb with

/tmp/bashdb/bashdb -L /tmp/bashdb --tty /dev/tty --tty_in /dev/tty /tmp/somescript

but with the same working result. I'm using bash 5.2.37.

the relevant lines in opts.sh are:

    293         elif (( subarg_var )) ; then
    294             _Dbg_subdebug_args+=("${subarg_cli%}")
    295         fi

So I don't understand how you could have seen that error on line 294.

One can get this behavior if you have bashdb installed in the place that bash thinks bashdb should be installed by default. (This might be "/usr/share/bashdb/bashdb-main.inc")

Make sure you do not have bashdb installed before running this test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants