if test -z "$a" ; then
if grep -qF "bummer" <<< 'a' ; then
elif [ 'a' != 'b' ] ; then
There seems to be some error with the exit code tracking:
bashdb<6> ev [ ! "${DO_NOT_TRACK:-0}" -eq 0 ]
$? is 0
bashdb<7> ev [ ! "${DO_NOT_TRACK:-0}" -eq 0 ]; echo $?
1
$? is 0
This is open-source code and bash is pretty simple to debug. Feel free to investigate and put in a patch.
Last edit: Roland Christmann 2021-07-08
This doesn't seem like a proper fix in that it may address one problem but cause another. The purpose of that line is to save the value of $0 so that it can be restored when returning from the debugger.
Do you have any idea how to solve that ?
Last edit: Roland Christmann 2021-07-08
Probably saving and restoring the return code value.
Sorry but I have no access to the patch section.
This way the value of $0 is saved and the expression is correctly evaluated because it must be the last line of
_$Dbg_evalfile
file.Last edit: Roland Christmann 2021-07-12
Ok - I agree that this code is bettter. But it doesn't change the behavior of the example at the very beginning.
It would be great to add a test to show how the current version fails and this revised version fixes that.
The current version will always return 0
The expression evaluates the assignment of a variable (BASH_ARGV0 in this case) which is always true.
Would you please write a test case in that can be run that fails with the current code, and succeeds after this patch is changed.?
I am learning how to write a test case, it's the first time ...
Last edit: Roland Christmann 2021-07-12
Last edit: Roland Christmann 2021-07-12
move to bug #71
Last edit: Roland Christmann 2021-07-12
move to bug #71
Last edit: Roland Christmann 2021-07-12
Commits 28d4d2f and 2359ac3 should now have these patches. Thanks!
Automated tests need to be written sometime before release.
Also please make each separate bug be separate. This helps track progress of individual bugs. Thanks again.
before the lib/fns.sh patch :
/data/projects/bashdb-5.1/test/unit # ./test-eval.sh
test_eval_subst
ASSERT:expected:<(( x == 1 ))> but was:<if (( x == 1 )); then>
ASSERT:expected:<test -z "$x" > but was:<est -z "$x" >
Ran 1 test. 12 assert(s): 10 passed, 2 failed, 0 skipped.
FAILED (failures=2)
after the lib/fns.sh patch :
/data/projects/bashdb-5.1/test/unit # ./test-eval.sh
test_eval_subst
Ran 1 test. 12 assert(s): 12 passed, 0 failed, 0 skipped.
OK
Please modify the patch with <tab> instead of spaces for these two lines :</tab>
The same patch should also be applied on test-lib-eval.sh.in
I don't see any difference between these two files :
Commit 4d33360e8fd75b217963fbafbbfed29bafc19e1f removes this.
Yes, test-lib-eval.sh.in is the newer, more precise name while test-eval.sh was the older name. The newer name is only found in zshdb for example.
Thanks - I'll clean this up when I get a chance.
very nice work, thanks for all.
As you have noticed, while still serviceable, (and as far as I know it is the only serious debugger for bash ever written), has signs of age.
It was written before bash had, for example, associative arrays and some of this may still be reflected in library code. I really haven't been keeping up to date bash or with its more recent additions like the introduction of regular expression character classes. (Again, when this was first written there were no regular expressions at all.)
At this point, that this is kept alive or current at is up to those willing to contribute to it.
For myself, I rarely have need to use it beyond what is already there.
This was fixed in 28d4d2 and broken (again) with the 9a0bf97 ...
😕
The debugger is working fine, but unfortunately it doesn't work like you want it to work ...
test_eval
$ bashdb -- test_eval
bash debugger, bashdb, release 5.1-1.1.2
Copyright 2002-2004, 2006-2012, 2014, 2016-2019, 2021 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.
(test_eval:3):
3: a=false
bashdb<0> n
(test_eval:4):
4: if $a ; then echo true; else echo false; fi
bashdb<1> ev?
eval: $a
$? is 1
bashdb<2> n
(test_eval:4):
4: if $a ; then echo true; else echo false; fi
echo false
bashdb<3> n
false
(test_eval:5):
5: a=true
bashdb<4> n
(test_eval:6):
6: if $a ; then echo true; else echo false; fi
bashdb<5> ev?
eval: $a
$? is 0
bashdb<6> n
(test_eval:6):
6: if $a ; then echo true; else echo false; fi
echo true
bashdb<7> q
bashdb: That's all, folks...