我创建了一个任务,它将打开与我选择的路径相对应的文件:
{
"type": "shell",
"label": "Open Selection",
"command": "myFile=`echo ${workspaceFolder}${selectedText} | sed 's/\\.css/\\.scss/g;s/\\.\\.//g;`;code $myFile",
"problemMatcher": []
},
我想将光标插入href,执行“展开选择”,然后执行“打开选择”。但展开选择会获取路径周围的引号。我已在终端(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的终端中失败?
答案 0 :(得分:0)
{
"type": "shell",
"label": "Open Selection",
"command": "myFile=`echo echo ${workspaceFolder}${selectedText} | sed 's/\\.css/\\.scss/g; s/\\.\\.//g;s/\\\"//g'`;code $myFile",
},