逃避“逃跑” cygwin 中的命令行选项
我在通过“run”将参数传递到 Windows 端时遇到问题
为了演示,它看起来像这样:
run C:\foo.exe /BUILD
“/BUILD”参数永远不会传递给可执行文件。 有谁知道 有办法解决这个问题吗?
谢谢!
I'm having issues passing arguments through "run" to the windows side
To demonstrate, it looks something like this:
run C:\foo.exe /BUILD
The '/BUILD' parameter is never passed to the executable. Anyone know
of a way to get around this?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
经过大量研究后,正确的答案是将其传递给批处理文件 - 强制“运行”仅执行单个命令,将所有执行传递给批处理文件。
The correct answer, after lots of research was to pass this through a batch file - forcing 'run' to only execute a single cmd, passing all execution off to the batch file.
我不经常使用 Cygwin,但可能是:
run 'c:\foo.exe /BUILD'
(如果不是单引号,那么可能是双引号?)
I don't use Cygwin a lot, but possibly:
run 'c:\foo.exe /BUILD'
(if not single- then maybe double-quotes?)
您是否尝试过将其括在引号中,例如:
我想知道 shell 是否会混淆参数属于谁 - 也就是说,“run”正在消耗 /BUILD,而不是传递它。
Have you tried enclosing it in quotes like:
I wonder if the shell's getting confused who the argument belongs to - that is, "run" is consuming the /BUILD, not passing it along.
foo.exe 应该做什么,你怎么知道它没有获得 /build 命令行选项? 如果你执行
info run
你会得到:最后一点很重要——它隐藏了控制台窗口。 因此,您会看到类似这样的内容:
但是如果您运行此命令,您会看到不同的内容:
第一个命令正在运行,但它正在打印到不存在的控制台窗口。
注意:我会用 DOS 命令解释器来完成这个示例,就像您正在尝试做的那样,但是 XP cmd.exe 不处理“>” 正确,并将其交给
run
而不是ls
。What is foo.exe supposed to do, and how do you know it's not getting the /build command line option? If you do
info run
you'll get:That last bit is important -- it's hiding the console window. So, you'll see something like this:
but if you run this instead, you'll see something different:
The first command is running, but it's printing to a non-existent console window.
NOTE: I would have done the example with a DOS command interpreter, as it seems you are trying to do, but the XP cmd.exe doesn't handle the '>' correctly, and hands it to
run
instead ofls
.