bash 如何让 Perl 和 Python 打印正在执行的程序的每一行?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2872089/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 22:06:54  来源:igfitidea点击:

How can I make Perl and Python print each line of the program being executed?

pythonbashperldebuggingtrace

提问by Vi.

I know that bash -x script.shwill execute script printing each line before actual execution. How to make Perl and Python interpreters do the same?

我知道这bash -x script.sh将在实际执行之前执行打印每一行的脚本。如何让 Perl 和 Python 解释器做同样的事情?

回答by msw

Devel::Traceis the Perl analogue, the trace moduleis Python's.

Devel::Trace是 Perl 的类似物,trace 模块是 Python 的。

回答by mob

Devel::DumpTracewas released in 2011 and has more features than Devel::Trace, such as evaluating variable values in the trace output.

Devel::DumpTrace于 2011 年发布,具有比 多的功能Devel::Trace,例如评估跟踪输出中的变量值。