I heard about the bash debugger ( bashdb
) after reading a comment so I thought I should try it out and see if it can help me analyze bash scripts or more generally the execution of commands. There are facilities which can be leveraged independently of any external program but there is the question of convenience and bashdb runs in the shell and can be called directly or with bash --debugger command
when properly configured.
So I tried something trivial in a script:
#!/usr/bin/env bash
{ echo 'abc'; echo 'def'; } | cat
Which is just two echo
commands in a list uselessly piped into the cat
command. Using bashdb scriptname
I get:
(/home/user/bin/scriptname:3):
3: { echo 'abc'; echo 'def'; } | cat
(/home/user/bin/scriptname:3):
3: { echo 'abc'; echo 'def'; } | cat
bashdb<0> bashdb<(0)> step
So there is a pipe operator and a subshell is created - the parentheses around the 0 are tribute to that. I try to step
in right away. A newline is output but I don't get back the debugger prompt... until I press enter again. By that point I have lost the output of what I type in the debugger and performance seems highly degraded. Doing q
and pressing enter, I exit the debugger and now my terminal no longer outputs my commands either. Commands get executed but I need to exit a start a new terminal window to regain any command echo. In some cases, both in the tool and after quitting in bash, not only the commands are no longer echoed but the newline following commands is gone too.
So obviously I have very little experience with that sort of software but this seems to be the desired behavior as I get similar results both on Gentoo and Archbang?? So what happened here and what did I step into?