Open bam80 opened 5 years ago
This is not really my area of expertise, but I guess the use case would be like this:
Backtrace () {
i=1
while caller $i
do
i=$((i+1))
done
}
trap 'Backtrace' EXIT ERR
Then you get a trace like:
test.sh|33| MY_UNBOUND_VARIABLE: unbound variable
|| 39 bbb /home/wolfgang/path/test.sh
|| 42 main /home/wolfgang/path/test.sh
@WolfgangMehner thanks, could you please attach the test script here?
My point was mainly about the format we need to be able to pass. I guessed the following format:
<line-number> <function-name> <file-name>
Here is the full script (can not upload *.sh
for some reason):
Extended the error format for testing: https://github.com/WolfgangMehner/vim-plugins/tree/bashsupport-trace-test
@WolfgangMehner Thanks for your kind. The links is broken
Can you find the branch "bashsupport-trace-test" anyway?
I'm not sure I fully understood your last comment, sorry. Which link or links is broken?
Sorry, my fault - I just didn't catch the link points to the other branch.
We already can jump to error place in the script. But it would be fine if we could have also call stack in QuickFix window. That way we could jump on the stack even without debugger. The call stack can be traced out with
caller
builtin, usingtrap
on error. We just need to tune 'errorformat' to parse it properly.