退出 git 控制台:如何执行批处理文件然后返回到 git 控制台? [英] Out of a git console: how do I execute a batch file and then return to git console?

查看:47
本文介绍了退出 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(msy​​sgit,如果这很重要)执行它更方便.

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 窗口,在那里我可以轻松地执行我的批处理.当我输入 exit 时,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 bash 中执行 clean.bat 而不必键入上面的三个命令(cmdclear.bat,<代码>退出).我只想从我的 Git bash 中执行 .bat 文件.明显的方法是创建一个单独的 .sh 文件来完成相同的工作,但这会导致双重代码.

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 bash 变成了一个普通的 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.

此外,添加 /debug 开关实际上没有任何作用.似乎只有 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天全站免登陆