巴什在Git中的Windows:运行一个命令的CMD.exe / C与ARGS怪诞的时候 [英] Bash in Git for Windows: Weirdness when running a command with CMD.exe /C with args

查看:135
本文介绍了巴什在Git中的Windows:运行一个命令的CMD.exe / C与ARGS怪诞的时候的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是更大的烦恼,而不是一个问题,但我非常想了解这里的语义。

This is more of an annoyance rather than a problem but I would very much like to understand the semantics here.

所有我想要做的是运行在它本身一个bash会话下运行的临时命令提示符会话任意命令。

All I want to do is to run an arbitrary command on a temporary command-prompt session which itself running under a bash session.

我的成功率是50/50的预期,而其他人没有这么多一些命令的作品。

My success rate is 50/50 as some command works as expected whereas others not so much.

我认为这个问题的可以谎言围绕论点不排队正确(即丢失或合并参数)

I think the problem may lie around arguments not lining up properly (i.e. missing or merged arguments)

我会尽力通过一系列的命令和响应来解释的怪异的我是什么意思。 (我试图得到了这个词的测试的要打印在屏幕上。)

I'll try to explain what I mean by weird by a series of commands and responses. (I'm trying to get the word test to be printed on the screen.)

我在 GNU的bash,版本3.1.0(1) - 释放(i686的-PC-MSYS)捆绑的Git-1.8.4运行这些:

I'm running these under GNU bash, version 3.1.0(1)-release (i686-pc-msys) Bundled with Git-1.8.4:

第一次尝试:

$ cmd /c echo test
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.
c:\>

第二次尝试:

$ cmd '/c echo test'
test"

第三次尝试:

$ cmd "/c echo test"
test"

第四次尝试:

$ cmd /c\ echo\ test
test"

第五次尝试:

$ cmd "/c echo" test
'echo" test' is not recognized as an internal or external command,
operable program or batch file.

我真的AP preciate上面,因为这是unintuitional给我,快把我逼疯了任何指针或见解的行为!

I'd really appreciate any pointers or insights into the behaviors above as this is unintuitional to me and driving me crazy!

编辑:
有<一个href=\"http://stackoverflow.com/questions/11865085/out-of-a-git-console-how-do-i-execute-a-batch-file-and-then-return-to-git-conso\">another 这个问题似乎与此类似,但它真的不是,主要是因为它是关于通过CMD / C,不需要任何参数运行批处理文件。

There is another question that appears similar to this, but it really isn't, mainly because it's about running batch files through CMD /C that doesn't require any arguments.

这并没有真正回答我有关如何正确提供的参数窗口的命令行应用程序,即使例子是关于CMD / C,这里的答案可以应用程序,以及适用于许多其他的Windows命令行的问题。

It doesn't really answer my question about how to provide arguments properly to windows command line apps, and even though the examples are about CMD /C, the answer here can be applied to many other Windows command line apps as well.

推荐答案

这是在阅读发布文件实际上记录(在你的Git安装为Windows的顶层文件夹)

This is actually documented in the ReleaseNotes file (in the top level folder of your installed Git for Windows)

此外,格外小心,必须付出通过Windows程序Windows路径,因为他们没有关于风格MSys的POSIX路径的线索 - 你可以使用类似$(CMD // C回声$ POSIXPATH)

Also, extra care has to be paid to pass Windows programs Windows paths, as they have no clue about MSys style POSIX paths -- You can use something like $(cmd //c echo "$POSIXPATH").

如果您使用 CMD // C回声测试它按预期工作。

If you use cmd //c echo test it works as expected.

$ cmd //c echo test
test

的原因是与试图确保POSIX路径最终被传递到GIT中公用事业正确的事。出于这个原因,GIT中的Windows包括影响命令参数的改性MSYS层。你应该注意到,这并不意味着为Windows提供使用Git的bash shell,然后工具一起使用,作为通用的Unix工具为Windows。如果你想有一个通用的UNIX风格的工具,那么你应该安装MSYS或Cygwin的。 Git的Bash shell中已设置为使用Git,有时该节目的工作。

The cause is to do with trying to ensure that posix paths end up being passed to the git utilities properly. For this reason, Git for Windows includes a modified MSYS layer that affects command arguments. You should note that it is not intended that the bash shell and tools provided with Git for Windows be used as general purpose unix tools for Windows. If you want a general purpose unix-style toolset then you should install MSYS or cygwin. The Git Bash shell is setup for working with git and sometimes that shows.

这篇关于巴什在Git中的Windows:运行一个命令的CMD.exe / C与ARGS怪诞的时候的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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