我创建了一个任务,该任务将打开与我选择的路径相对应的文件:
{
"type": "shell",
"label": "Open Selection",
"command": "myFile=`echo ${workspaceFolder}${selectedText} | sed 's/\\.css/\\.scss/g;s/\\.\\.//g;`;code $myFile",
"problemMatcher": []
},
我想将光标插入一个 href,执行“扩展选择”然后执行“打开选择”。但是 Expand Selection 会抓取路径周围的引号。我已经在终端(OS X)中成功解决了这个问题,但是作为 VS Code 任务它失败了......
"command": "myFile=`echo ${workspaceFolder}${selectedText} | sed 's/\\.css/\\.scss/g;s/\\.\\.//g;s/\\\"//g`;code $myFile"
在 VS Code 中失败。出现错误:
/bin/bash: command substitution: line 0: unexpected EOF while looking for matching `''
但奇怪的是,当我复制 VS Code 错误的命令时
> Executing task: myFile... <
并在终端中运行它,它可以工作。所以我很困惑,为什么一个命令会在终端中成功而在 VS Code 的终端中失败?