一、实现思路

        方案一:在windows系统下如果要实现shell调试需要先让windows系统下可以运行shell脚本,本次不使用这种方案。

        方案二:在linux系统下可以正常运行shell脚本 ,但是我们要用vscode远程连接上传,然后再vscode中安装一个调试shell的调试工具bash debug插件,本次使用就是用这个方案。

二、使用vscode远程连接linux服务

        按照下图步骤进行操作

输入完成回车。

连接成功的标志。

打开对应的开发项目目录

因为是测试这里就在一个demo空目录下,相当于一个新环境

创建一个测试shell脚本

三、配置安装一个bash debug插件

        按图操作

        安装好操作后进行debug配置操作,接着看图操作

        操作完成后会接着就是配置debug了,看图操作

        接着全部配置bashdb的所有配置项

        这可以看到配置完成后就会多出一个配置向,如图

        接着配置第三个

        最终配置如图

        配置文件如下

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "bashdb",
            "request": "launch",
            "name": "Bash-Debug (type in script name)",
            "cwd": "${workspaceFolder}",
            "program": "${command:AskForScriptName}",
            "args": []
        },
        {
            "type": "bashdb",
            "request": "launch",
            "name": "Bash-Debug (select script from list of sh files)",
            "cwd": "${workspaceFolder}",
            "program": "${command:SelectScriptName}",
            "args": []
        },
        {
            "type": "bashdb",
            "request": "launch",
            "name": "Bash-Debug (hardcoded script name)",
            "cwd": "${workspaceFolder}",
            "program": "${workspaceFolder}/path/to/script.sh",
            "args": []
        },
        {
            "type": "bashdb",
            "request": "launch",
            "name": "Bash-Debug (simplest configuration)",
            "program": "${file}"
        }
    ]
}

四、运行并调试

        看图操作

        运行成功完结,撒花

Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐