相关疑难解决方法(0)

在批处理脚本中转义双引号

如何使用转义双引号替换批处理文件参数中的所有双引号?这是我当前的批处理文件,它扩展了字符串中的所有命令行参数:

@echo off
call bash --verbose -c "g++-linux-4.1 %*"
Run Code Online (Sandbox Code Playgroud)

然后它使用该字符串调用Cygwin的bash,执行Linux交叉编译器.不幸的是,我将这些参数传递给我的批处理文件:

"launch-linux-g++.bat" -ftemplate-depth-128 -O3 -finline-functions 
-Wno-inline -Wall  -DNDEBUG   -c 
-o "C:\Users\Me\Documents\Testing\SparseLib\bin\Win32\LinuxRelease\hello.o" 
"c:\Users\Me\Documents\Testing\SparseLib\SparseLib\hello.cpp"
Run Code Online (Sandbox Code Playgroud)

传入第一个路径的第一个引用是过早地结束传递给GCC的字符串,并将其余参数直接传递给bash(这非常失败.)

我想如果我可以将参数连接成一个单独的字符串然后转义它应该正常工作的引号,但我很难确定如何做到这一点.有人知道吗?

parameters quotes scripting escaping batch-file

84
推荐指数
4
解决办法
13万
查看次数

标签 统计

batch-file ×1

escaping ×1

parameters ×1

quotes ×1

scripting ×1