以 post 死亡模式启动 pdb。避免输入 "c" 的任何技巧

start pdb in post mortem mode. any trick to avoid typing "c"

我想创建一个小帮手(例如 shell 函数),它允许我在 pdb post mortem 模式下调用任何 python 脚本。

withpdb() {
    cmd="" ; shift
    python -m pdb -- "$(which $cmd)" "$@"
}

所以如果我输入例如

mycmd.py param1 param2

我遇到了错误,我想用 pydb 进行分析。 我只是在我的 bash 历史记录中添加 withpdb

作为前缀
withpbd mycmd.py param1 param2

现在 pdb 使用我的脚本启动,只要我按下 c 和 return,脚本就会启动。

我的问题是: 有什么技巧可以避免输入首字母 "c" + enter?

如果我必须在 python 或其他 alngauge 中编写一些包装代码,那也可以

使用-c选项在启动时执行c。 (并且由于您只需编写一次函数,为清楚起见,请使用 continue 而不是缩写。)

withpdb() {
  cmd="" ; shift
  python -m pdb -c continue -- "$(which $cmd)" "$@"
}