rogalmic / vscode-bash-debug

Bash shell debugger extension for VSCode (based on bashdb)
MIT License
222 stars 26 forks source link

How to debug and trace into several bash files #152

Open Starli0n opened 3 years ago

Starli0n commented 3 years ago

Hi,

First thank you for your awesome plugin 👋

I would like to know if it is possible to debug in several files.

For instance, I manage perfectly to debug a sh file but at some I would like to step in (F11) another sh file. I have a sh file that is calling another one. But the later, it seems I cannot trace into it.

I do not know if it is even possible as I even tried to call the secondary script with its full path and put breakpoints there, without success. If yes, could you please tell me how please ?

Thank you

rogalmic commented 3 years ago

It is possible, when you use bash "source" keyword, or simply "."

https://superuser.com/questions/46139/what-does-source-do

Starli0n commented 3 years ago

This solution enables to step in other scripts, thanks.

However it changes the behavior. For instance, let's say that I set a variable at the beginning of each script like:

SCRIPT_NAME=$(basename $0)

all my sourced scripts would have the value of the main script calling them instead of their own value.

Is there a workaround to this ?

rogalmic commented 3 years ago

There is no workaround, since separate bash process is created when you execute script instead of calling it via source.