我已经安装了带有Bash调试扩展的VSCode。
在此之前,我已经安装了bashdb
,并使用bashdb --version
验证了它的版本,它是4.4。
现在,扩展创建了一个名为launch.json
的空文件。
我写了下面的代码来开始调试,但是仍然什么都没有发生
{
"version": "0.2.0",
"scriptPath": "${command:SelectScriptName}",
"configurations": [
],
"compounds": [
{
"type": "bashdb",
"name": "Compound",
"configurations": []
}
]
}
我应该怎么做才能启用调试?
3条答案
按热度按时间bxjv4tth1#
安装
bashdb
扩展后,将以下代码块添加到launch.json
文件中。此配置允许您调试当前在VS Code上打开的脚本。因此,为了开始调试脚本,您必须在VS Code上打开它,并键入F5
以开始调试它。或者,也可以在VS Code上打开相同的脚本,在VS Code左栏上打开Run and Debug
菜单,然后单击Play
。将
args
参数添加到上面的块中,允许您在调试时将带有参数的数组传递给脚本。vmdwslir2#
我用Bash扩展测试了这段代码:
Visual Studio Code显示项目中的脚本列表,您可以选择要运行的脚本。您也可以选择一个“Bash-Script(硬编码脚本名称)”配置,它允许硬编码脚本路径。
nue99wik3#
如果你想调试一个Bash脚本,我建议你使用-x标志来执行你的脚本。举例来说:
或者在脚本中添加: