Results 1 to 4 of 4
I am wondering is there a debugger available for Bash Shell script???
I only use vi when programming bash shell script, and I also wonder is there a good editor ...
- 08-16-2008 #1Just Joined!
- Join Date
- Jul 2006
- Posts
- 60
How to debug Linux Bash shell script?
I am wondering is there a debugger available for Bash Shell script???
I only use vi when programming bash shell script, and I also wonder is there a good editor (plus debugger)?
Thanks in advance.
- 08-16-2008 #2Linux Engineer
- Join Date
- Apr 2006
- Location
- Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
- Posts
- 1,117
Hi.
Usually, I use:
1) echo, print, printf, sometimes as a capability to be toggled on / off.
2) option -x, or -vx, essentially a trace:
try it with a hello, world script.Code:bash -x shell-script-file-name arguments
There is a bash debugger written in shell code, see the reference below ... cheers, drl
Title: Learning the bash Shell
Author: Cameron Newham
Edition: Third
Date: 2005
Publisher: O'Reilly
ISBN: 0596009658
Pages: 376
Categories: bash, scripting, unix, linux, shell, programming
Comments: 4 stars, 27 reviews ( Amazon 2007.08 )
Comments: ( I have 2nd edition, 1998 )
Comments: "bashdb", bash debugger, Chapter 9.Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
We look forward to helping you with the challenge of the other 10%.
( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )
- 08-18-2008 #3Linux Guru
- Join Date
- Nov 2007
- Location
- Córdoba (Spain)
- Posts
- 1,513
You can as well add self-contained code for debug purposes. I sometimes just implement it like this:
It's handy sometimes, just uncomment the DEBUG var and the debug sentences will be run. Comment it out again, and no debug messages/commands will be shown/executed.Code:#!/bin/bash #blah blah blah .... #Uncomment this to turn on debugging stuff #DEBUG=yes .... .... .... [ -n "$DEBUG" ] && echo "My debug info, \$var1 value is \"$var1\"" ... ... ...
- 08-23-2008 #4Just Joined!
- Join Date
- Jul 2006
- Posts
- 60
Great, I will have a look at the debugger written in the shell code as mentioned above.
Ideally, I am looking for a shell debugger in a GUI form, which I can set a break point as other programming debugging tool. Run the shell script and the program would be stopped at that break point. Resume, step in or out from a function, etc....
Thanks,
Jiafan


Reply With Quote