I'm using Ubuntu within Windows Subsystem for Linux.
With the approach suggested by this answer I can run code when a new non-interactive shell is started:
$ cat ~/.bashenv
if [[ $- != *i* ]]; then
echo foo
fi
$ export BASH_ENV=~/.bashenv
$ bash -c 'echo bar'
foo
bar
Now I am looking to setup a trap function with shopt extdebug enabled.
I tried something like this:
$ cat ~/.bashenv
#!/bin/bash
say_foo() {
echo "foo"
}
set -T
trap 'say_foo' DEBUG
shopt -s extdebug
$ export BASH_ENV=~/.bashenv
$ bash -c 'echo bar'
foo
bash: /usr/share/bashdb/bashdb-main.inc: No such file or directory
bash: warning: cannot start debugger; debugging mode disabled
foo
bar
Is there any way to fix this?
A shorter way of reproducing the same issue:
$ bash --debugger -c 'echo hello'
bash: /usr/share/bashdb/bashdb-main.inc: No such file or directory
bash: warning: cannot start debugger; debugging mode disabled
hello
(Running an in-line bash
script with --debugger
is the same as setting extdebug
in a file read via $BASH_ENV
.)
bash
executable on the system you are using? A package (what distribution?) or was it compiled locally? – Kusalananda Mar 14 '24 at 16:52bash
then? – Foo Mar 14 '24 at 17:09