逃避“逃跑” cygwin 中的命令行选项

发布于 2024-07-13 09:44:48 字数 176 浏览 4 评论 0原文

我在通过“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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

热血少△年 2024-07-20 09:44:48

经过大量研究后,正确的答案是将其传递给批处理文件 - 强制“运行”仅执行单个命令,将所有执行传递给批处理文件。

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.

老街孤人 2024-07-20 09:44:48

我不经常使用 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?)

帅冕 2024-07-20 09:44:48

您是否尝试过将其括在引号中,例如:

run "C:\foo.exe /BUILD"

我想知道 shell 是否会混淆参数属于谁 - 也就是说,“run”正在消耗 /BUILD,而不是传递它。

Have you tried enclosing it in quotes like:

run "C:\foo.exe /BUILD"

I wonder if the shell's getting confused who the argument belongs to - that is, "run" is consuming the /BUILD, not passing it along.

清晰传感 2024-07-20 09:44:48

foo.exe 应该做什么,你怎么知道它没有获得 /build 命令行选项? 如果你执行 info run 你会得到:

Windows  programs  are  either  GUI  programs or console programs. When
started console  programs  will  either  attach  to an existing console
or  create a new one. GUI programs can  never attach to an exiting con-
sole. There is no way to attach to an existing console but hide  it  if
started as GUI program.

run  will  do this for you. It works  as intermediate and starts a pro-
gram but makes the console window hidden.

最后一点很重要——它隐藏了控制台窗口。 因此,您会看到类似这样的内容:

</cygdrive/d/sandbox> $ run ls -la
</cygdrive/d/sandbox> $

但是如果您运行此命令,您会看到不同的内容:

</cygdrive/d/sandbox> $ cat foo.lst
cat: foo.lst: No such file or directory
</cygdrive/d/sandbox> $ run ls -la >foo.lst
</cygdrive/d/sandbox> $
</cygdrive/d/sandbox> $ cat foo.lst
total 9272280
drwx------+ 15 jcasadonte     ????????             0 Feb  7 10:39 .
drwxrwxr-x+ 14 Administrators SYSTEM               0 Feb  7 00:44 ..
-rwx------+  1 jcasadonte     ????????         26300 Apr 10  2006 ATT01779.jpg
[...etc...]

第一个命令正在运行,但它正在打印到不存在的控制台窗口。

注意:我会用 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:

Windows  programs  are  either  GUI  programs or console programs. When
started console  programs  will  either  attach  to an existing console
or  create a new one. GUI programs can  never attach to an exiting con-
sole. There is no way to attach to an existing console but hide  it  if
started as GUI program.

run  will  do this for you. It works  as intermediate and starts a pro-
gram but makes the console window hidden.

That last bit is important -- it's hiding the console window. So, you'll see something like this:

</cygdrive/d/sandbox> $ run ls -la
</cygdrive/d/sandbox> $

but if you run this instead, you'll see something different:

</cygdrive/d/sandbox> $ cat foo.lst
cat: foo.lst: No such file or directory
</cygdrive/d/sandbox> $ run ls -la >foo.lst
</cygdrive/d/sandbox> $
</cygdrive/d/sandbox> $ cat foo.lst
total 9272280
drwx------+ 15 jcasadonte     ????????             0 Feb  7 10:39 .
drwxrwxr-x+ 14 Administrators SYSTEM               0 Feb  7 00:44 ..
-rwx------+  1 jcasadonte     ????????         26300 Apr 10  2006 ATT01779.jpg
[...etc...]

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 of ls.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文