如何从Visual Studio代码运行Windows Bash作为运行任务?
下面是我在tasks.json上做的一些尝试。
{ "version": "0.1.0","command": "cmd","isShellCommand": true,"args": [ "RunShellScript.bat" ],"showOutput": "always" }
RunShellScript.bat只有这一行: bash myShellScript.sh 。 如果你只是从开始打开CMD,并input该行,它将执行。 如果你只是双击文件,它也可以很好地运行。 但是,从VSCode启动时,此输出只是挂起,直到我终止它。
尝试编号2:
在webserver上备份文件! 和〜
将带参数的命令作为string传递给docker运行
{ "version": "0.1.0","args": [ "bash myShellScript.sh" ],"showOutput": "always" }
这也挂起,就像上面一样。
尝试3号:
{ "version": "0.1.0","command": "C:/Windows/System32/bash","isShellCommand": false,"args": [ "myShellScript.sh" ],"showOutput": "always" }
这给了我:
Failed to launch external program C:/Windows/System32/bash myShellScript.sh spawn C:/Windows/System32/bash ENOENT
我也尝试过在某些情况下将"isShellCommand"variables设置为true和false,但无济于事。
有谁知道如何做到这一点?
如何pipe理进程的输出到logging器命令和头部命令?
了解代码({0..1} {0..1} {0..1} {0..1} {0..1} {0..1} {0..1} {0..1 })
OSX shell脚本打开新的terminal窗口并运行程序
如何在一定数量的结果之后停止查找
我也想看看我能做同样的事情。
andlrc – 我已经试过了你的两个选项,而且他们都没有做到这一点。 这个问题似乎是因为在Visual Studio Code运行它的任何上下文中,bash都无法识别。我尝试了各种方法:
“command”:“C:/Windows/System32/bash.exe”
“命令”:“bash”
“command”:“bash.exe”
如果我找到工作,我会继续尝试并回复。
编辑 :明白了。 信用这个人 – https://aigeec.com/using-windows-10-anniversary-bash-with-visual-studio-code/
总之,它归结为我在64位操作系统上,这意味着bash.exe位于C: Windows System32中。 一旦我将bash.exe复制到SysWOW64中,正如博客文章所示,Visual Studio代码的默认构建操作(Ctrl + Shift + B)按照您所期望的那样运行。
这看起来似乎是一个诡计多端的解决方法 – 可能值得与MSFT提高,看看我们能做些什么。
编辑 :这是我的tasks.json按要求:
{ // See https://go.microsoft.com/fwlink/?LinkId=733558 // for the documentation about the tasks.json format "version": "0.1.0","command": "bash","args": [ "./gulp.sh" ],"showOutput": "always","tasks": [{ "taskName": "scripts","isBuildCommand": true,"problemmatcher": "$gulp-tsc","isWatching": true }]
}
gulp.sh只包含一个命令; 'gulp':-)但是你可以把你想要的东西放在里面,我想你可以有几个.sh脚本来满足不同的任务磁带
为了响应Sysnative的使用,不幸的是似乎没有理解,并且构建任务不能运行。
在我的Windows 10机器上有一个新安装的bash ,这对我来说很好:
{ "version": "0.1.0","args": [ "shellscript.sh" ],"showOutput": "always" }
贝壳版本的shellscript.sh作为command不适用于我。
你也可以使用bash -c "<command>"来运行一个任意命令:
{ "version": "0.1.0","args": ["-c","echo "test""],"showOutput": "always" }
尝试:
{ "version": "0.1.0","showOutput": "always" }
#!/bin/bash
然后写入脚本的路径:
{ "version": "0.1.0","command": "/path/to/script.sh","args": [],"showOutput": "always" }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。