除錯 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/