I know in Perl debugger perl -d, I can put the snippet $DB::single=1 anywhere in source so the debugger can stop right there.
It is really convenient.
I would like to know is there the equivalent snippet when I use bashdb so I can put it in a bash file?
CodePudding user response:
According to the question's comment(thanks for every who commented) and the official docs, I find two ways to do this:
- Add
kill -INT $$; :in your bash script right before the line you wish to stop, then usebashdb your-script.shto start debug, the debugger can stop but show it was stopped at first line. You can enternand ENTER, then your debugger can stop at the right line.
- Add
source /usr/local/share/bashdb/bashdb-traceat the beginning of your script(the path may be varied), then add_Dbg_debuggerright before the line you wish to stop. Usebash your-script.shto start debug, the debugger can stop at your target line correctly. I recommend to use this method because it is most similar to$DB::single=1.
