在 macOS 上設定 VSCode 任務

在 macOS 上設定 VSCode 任務

嘗試在 macOS (10.14.6) 上的 VSCode (1.38.1) 中將 bash 腳本作為任務執行時出現問題。使用整合終端,腳本按預期運行。但是,當我將其作為 VSCode 任務運行時,執行 shell 明顯不同,並且我不確定如何配置它。

任務如下:

  "tasks": [
    {
      "label": "List files",
      "type": "shell",
      "command": "source ./scripts/test_ls.sh",
      "problemMatcher": []
    }
  ]

test_ls.sh 腳本很簡單:

#!/bin/bash
echo "${BASH_VERSION}"
ls

我已按如下方式配置整合終端(在 settings.json 中):

    "terminal.integrated.shell.osx": "/bin/bash",

當我從整合終端手動運行(使用命令“bash”或“source”)時,它會將 bash 版本聲明為 3.2.57(1)-release,然後按預期列出文件,但如果我運行上面的任務shell 給出以下輸出:

> Executing task in folder sdc1-scoring: source ./scripts/test_ls.sh -r <

3.2.57(1)-release
./scripts/test_ls.sh: line 3: ls: No such file or directory
The terminal process terminated with exit code: 127

這就引出了一個問題,如果它不使用 bash 運行腳本,那麼它使用的是什麼?如何配置?

相關內容