Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to debug bash scripts line-by-line?

I'll love something like Microsoft Visual Studio's line-by-line debugging in bash, with current variables values and so.

Is there any tool or way to do it? set -x and set -v are nice but not perfect.

like image 928
emi Avatar asked Feb 15 '13 06:02

emi


2 Answers

See bashdb.

If it's installed on your system, see man bashdb.

If it's not installed, see http://bashdb.sourceforge.net

like image 54
aks Avatar answered Sep 22 '22 05:09

aks


Yes. Use "bashdb" from http://bashdb.sourceforge.net/

Latest version at time of writing http://sourceforge.net/projects/bashdb/files/bashdb/4.2-0.8/

If you are on a Mac (like I was) then you might need to install the GNU version of Bash.

I did that using "MacPorts" http://www.macports.org/

Once you have MacPorts...

port install bash

Then follow the instructions to

./configure (in bashdb unpacked directory)

make

sudo make install

Then add the folder where bashdb can be found in your PATH

like image 44
Andrew Mackenzie Avatar answered Sep 22 '22 05:09

Andrew Mackenzie