Home > OS >  `perl -d` `$DB::single=1` equivalent in `bashdb`
`perl -d` `$DB::single=1` equivalent in `bashdb`

Time:11-28

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:

  1. Add kill -INT $$; : in your bash script right before the line you wish to stop, then use bashdb your-script.sh to start debug, the debugger can stop but show it was stopped at first line. You can enter n and ENTER, then your debugger can stop at the right line.

  1. Add source /usr/local/share/bashdb/bashdb-trace at the beginning of your script(the path may be varied), then add _Dbg_debugger right before the line you wish to stop. Use bash your-script.sh to 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.
  • Related