Reputation: 5630
I'd like to create a small helper (e.g. a shell function), that allows me to call any python script in pdb post mortem mode.
withpdb() {
cmd="$1" ; shift
python -m pdb -- "$(which $cmd)" "$@"
}
So if I typed for example
mycmd.py param1 param2
and I encounter errors, that I want to analyze with pydb.
I just go up in my bash history and prefix with withpdb
withpbd mycmd.py param1 param2
Now pdb is started with my script and as soon as I press c
and return the script starts.
My question is: Is there any trick to avoid typing the initial "c" + enter?
If I have to write some wrapper code in python or another alngauge, that's also OK
Upvotes: 1
Views: 187
Reputation: 530843
Use the -c
option to execute c
upon startup. (And since you only have to write the function once, use continue
instead of the abbreviation for clarity.)
withpdb() {
cmd="$1" ; shift
python -m pdb -c continue -- "$(which $cmd)" "$@"
}
Upvotes: 4