如何使用转义双引号替换批处理文件参数中的所有双引号?这是我当前的批处理文件,它扩展了字符串中的所有命令行参数:
@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(这非常失败.)
我想如果我可以将参数连接成一个单独的字符串然后转义它应该正常工作的引号,但我很难确定如何做到这一点.有人知道吗?
我知道如何使用cmake命令传递编译器选项
set(CMAKE_CXX_FLAGS "-Wall -Wno-dev -Wl,-rpath=/home/abcd/libs/")
Run Code Online (Sandbox Code Playgroud)
是否还有任何方法可以从命令行传递选项,这将覆盖CMakeList.txt选项,类似于 -
cmake -Wl,-rpath=/home/abcd/newlibs/ path/to/CMakeLists.txt
Run Code Online (Sandbox Code Playgroud)
要么
cmake -D CMAKE_CXX_FLAGS="-Wno-dev -Wl,-rpath=/home/abcd/libs/" path/to/CMakeLists.txt
Run Code Online (Sandbox Code Playgroud)
我的主要问题是我想知道如何追加标志以及如何从命令行覆盖现有的编译器标志.
当我为自己阅读和体验时,VBScript会删除所有双引号和参数.有没有人知道这方面的方法?如何将双引号传递给脚本?
我需要从Windows 7中的命令行运行以下命令:
SumatraPDF.exe -inverse-search "\"C:\Program Files\eclipse\inverse_search.bat\" \"%f\" %l"
但是我需要稍微修改它,因为我的Eclipse安装位于:
C:\Program Files (x86)\Eclipse (C++)
如何正确逃避此行?我是否还需要避开括号和加号?或者它是否足以逃脱双引号?
我有以下 cURL 请求:
curl -H 'Host: example.com' -H 'Accept-encoding: gzip, deflate' -H 'Accept: / ' -H 'User-Agent: iPhone' -H 'Secret-Key: 04d798d5ed2e560fb596bcfc3838fec0' -H 'Date : 2017-04-23T00:57:00.05+0200' -H 'Content-type: application/json' --data-binary '{"RegDate": "2017-04-23", "Username": "JamesRicky" , "密码": "0001"}' 'example.com/user'
它在 Linux 上运行良好,但在 Windows 上(使用命令提示符/Powershell),它给了我以下响应:
curl: (6) Couldn't resolve host 'example.com''
curl: (6) Couldn't resolve host 'gzip,'
curl: (6) Couldn't resolve host 'deflate''
curl: (6) Couldn't resolve host '*'
curl: (6) Couldn't resolve host 'iPhone''
curl: (6) Couldn't resolve host '04d798d5ed2e560fb596bcfc3838fec0''
curl: (6) …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用此代码创建一个目录,以查看代码是否正在执行,但由于某种原因,它执行时没有错误,但从未创建过该目录。我的代码中是否有错误?
var startInfo = new
var startinfo = new ProcessStartInfo();
startinfo.WorkingDirectory = "/home";
proc.StartInfo.FileName = "/bin/bash";
proc.StartInfo.Arguments = "-c cd Desktop && mkdir hey";
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = true;
proc.Start ();
Console.WriteLine ("Shell has been executed!");
Console.ReadLine();
Run Code Online (Sandbox Code Playgroud) 当通过批处理脚本调用的 powershell 实例传递时,我的测试消息中不会保留双引号结构,详细信息如下:
set test={"this":"is","a":"test"}
FOR /F "delims=" %%i in (' powershell -Command "& {$message = '%test%'; echo $message}" ') DO SET message=%%i
echo %test%
echo %message%
Run Code Online (Sandbox Code Playgroud)
输出如下:
{"this":"is","a":"test"}
{this:is,a:test}
Run Code Online (Sandbox Code Playgroud)
我想保留引号以在 powershell 中进一步处理字符串,但正如您所看到的,它们在引入变量时被删除$message。
关于如何解决这个问题有什么见解吗?
batch-file ×3
windows ×3
escaping ×2
bash ×1
c# ×1
cmake ×1
cmd ×1
command-line ×1
curl ×1
mono ×1
parameters ×1
powershell ×1
quotes ×1
scripting ×1
shell ×1
ubuntu ×1
vbscript ×1