Debugging Bash, using VSCode

Brian Sturgill bsturgill at
Sat Jan 22 14:06:45 MST 2022

Visual Studio Code (VSCode) is an open source editor based on electron and
It is probably the best open source editor available, with wide support by
many, many projects.
It works equally well on Linux, Windows and MacOS. I use it routinely on
all three platforms.
One such project is the Bash Debugger Project and is a great way to get

This is a quick start guide:

Install VSCode:
Click on the 4 box icon at the left (the top left box is raised away from
the other three).
Use the Search box at the top of the list of extensions list to find:
(I also just discovered Bash Extension, which installs all three plus more).
    Bash Debug
You might also want to install:
    Bash Beautify
    Bash IDE
    sudo apt install python-is-python3  # My version of Linux has only
version 3 installed.


Create a directory somewhere using your shell and then cd to it and type:
    code .

Click the "explorer" button at the top left (looks like two sheets of
Now move your mouse near the name of the directory and click the new file
Create a file.
for f in /proc/*; do
   echo $f

If you installed Bash Beautify you'll see it with syntax coloring.
To the left of line 3 single click twice (pause between)... this will set a
A red "led" will appear there.

>From the "Run" menu select "Add Configuration..."
Choose "Bash Debug".
You'll be placed into the file "launch.json".
Switch back to your bash file.
>From "Run" menu select "Start Debugging".
You'll stop at first line of code.
Select "continue" from debug controls at top.
You'll stop at line 3.
Hover over "$f"... you'll see it's value.
Add $f in the watch expressions at the left.
Hit "continue" a few times.

By now, you'll have a good idea of how the debugging works.
Hit the red square button to stop debugging.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the NCLUG mailing list