出一个Git控制台:我怎么执行批处理文件,然后返回到控制台的git? [英] Out of a git console: how do I execute a batch file and then return to git console?

查看:895
本文介绍了出一个Git控制台:我怎么执行批处理文件,然后返回到控制台的git?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有叫一个小工具脚本 clear.bat ,做我的信息来源获取某些看家的工作。

I have a small utility script called clear.bat that does some housekeeping work on my sources.

这是一个的.bat 文件,这样我可以很容易地在Windows资源管理器中双击它。

It is a .bat file so that I could easily double-click it in Windows Explorer.

有时候,我觉得更加得心应手,从我的Git的bash执行它(msysgit,如果这事项)。

Sometimes, I find it more handy to execute it from my Git bash (msysgit, if this matters).

要做到这一点,我键入

cmd
clear.bat
exit

CMD 原来我的Git的bash成正常 CMD 窗口,在这里我可以很容易地执行我的批处理。当我键入​​退出 CMD 环境被终止,我回到了我的Git的bash。

cmd turns my Git bash into a normal cmd window where I could easily execute my batch. When I type exit, the cmd environment is terminated and I'm back in my Git bash.

难道这是一个更简单的方法实现?

Could this be achieved in an easier way?

我试过 CMD / C的clean.bat 文档说

Syntax
      CMD [charset] [options]

      CMD [charset] [options] [/c Command] 

      CMD [charset] [options] [/k Command] 

Options   
   /C     Run Command and then terminate

   /K     Run Command and then return to the CMD prompt.
          This is useful for testing, to examine variables


编辑:结果
只是注意到该职位被打破了。



Just noticed that the post is broken.

我要的是从Git的庆典中执行的clean.bat ,而不必键入以上( CMD clear.bat 退出)。我只是想从我的Git的bash中执行的.bat 文件。显而易见的方法是创建,做同样的工作,一个单独的 .SH 文件,但这样会导致双重code。

What I want is to execute clean.bat from within the Git bash without having to type the three commands above (cmd, clear.bat, exit). I just want to execute the .bat file from within my Git bash. Obvious way would be to create a separate .sh file that does the same work but this will lead to double code.

编辑2:
当我执行 CMD / C的clean.bat ,Git的庆典变成一个普通的CMD环境,只显示提示。文件的clean.bat 没有得到执行。这是一样的,如果我只需键入 CMD

Edit 2: When I execute cmd /C clean.bat, the Git bash turns into a plain CMD environment and only displays the prompt. The file clean.bat does not get executed. It's the same as if I just type cmd.

另外,添加 /调试开关确实几乎一无所有。好像只有 CMD 得到评估,所有其它参数都得到忽略。

Also, adding a /debug switch does literally nothing. Seems like only cmd gets evaluated and all further parameters are getting ignored.

推荐答案

周围多一点玩后,我找到了解决自己:

After playing around a bit more, I found the solution myself:

cmd "/C clean.bat"

的伎俩。但我不知道,为什么...

does the trick. But I got no clue, why...

这篇关于出一个Git控制台:我怎么执行批处理文件,然后返回到控制台的git?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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