正斜杠而不是文件路径中的反斜杠 [英] Forward slashes instead of back in filepath

查看:142
本文介绍了正斜杠而不是文件路径中的反斜杠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Visual Studio代码构建任务参数中用反斜杠替换反斜杠.

How do I replace the backslashes with forward slashes in the Visual Studio Code build task argument.

我尝试在Bash命令中使用反斜杠,但是控制台只是删除了斜杠.

I've tried using backslashes in my Bash command, but the console simply removes the slashes.

"command": "xxxxxxxx.exe",
"type": "shell",
"args": [
    "--dir=${workspaceFolder}",
]

在控制台中,它似乎是:

In the console it appears to be:

> Executing task: xxxxxxxx.exe --dir=C:UsersUserDesktopProject

但我希望它是

> Executing task: xxxxxxxx.exe --dir=C:/Users/User/Desktop/Project/

推荐答案

您将反斜杠加倍了吗?它们是一个引号,因此您可能必须使用一个引号.

Did you double the backslashes? They are a quoting character, so you likely have to use one to quote the next.

$: echo "C:\Users\Public" | sed 's,\\,/,g'
C:/Users/Public

使用参数扩展而不会产生sed-

Using parameter expension without spawning a sed -

$: x="C:\Users\Public"
$: echo "${x//\\/\/}"
C:/Users/Public

这篇关于正斜杠而不是文件路径中的反斜杠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆