调试 usigh bashdb

Bashdb 是一个类似于 gdb 的实用程序,因为你可以在一行或一个函数中设置断点,打印变量内容,重启脚本执行等等。

你通常可以通过软件包管理器安装它,例如在 Fedora 上:

sudo dnf install bashdb 

或者从主页获取 。然后你可以用脚本作为参数运行它:

bashdb <YOUR SCRIPT>

以下是一些可以帮助你入门的命令:

l - show local lines, press l again to scroll down
s - step to next line 
print $VAR - echo out content of variable 
restart - reruns bashscript, it re-loads it prior to execution.
eval - evaluate some custom command, ex: eval echo hi

b <line num> set breakpoint on some line 
c - continue till some breakpoint 
i b - info on break points 
d <line #> - delete breakpoint at line #

shell - launch a sub-shell in the middle of execution, this is handy for manipulating variables

有关详细信息,我建议你阅读手册: http//www.rodericksmith.plus.com/outlines/manuals/bashdbOutline.html

另见主页: http
//bashdb.sourceforge.net/