MSysGit - run bat files directly
Asked Answered
A

3

11

I installed new version of MSysGit and now I am not able to run *.bat files directly from command line("called MINGW64").

I try to search it, but I only saw options which needs run cmd first. Out of a git console: how do I execute a batch file and then return to git console? cmd "/C clean.bat"

Is there some option to just run the clean.bat?

Thank you very much


I solve that by updating all libraries... Maybe Cygwin? I am not sure, but update all your software and it works.

Amund answered 24/10, 2015 at 5:31 Comment(4)
Maybe a shebang at the start of the file such as ;!cmd.exe /c? Other than that, no, there probably isn't a way to do what you're asking.Dowager
You have to use cmd.exe , as windows isn't smart enough to know which shell can execute a batch fileIntergrade
When I use old version of MSysGit, I can run directly clean.batAmund
Why not make a bash alias instead of using a batch file? Or make a clean alias that will run cmd /c clean.bat.Jaguarundi
P
13

Try this from MINGW command line

$ cmd <test.bat
Piezochemistry answered 25/9, 2018 at 10:45 Comment(2)
Note there should be space between the "<" and "test.bat" if you want it to run in the same console window. Having no space will open a new window.Eviaevict
Note that mingw requires the .bat file to have the line break in the end, or else the last line will be ignoredPrevailing
T
0

Try this from MINGW command line

$ eval "./test.bat"

D:\workspace>echo hello world
hello world
Tinfoil answered 29/9, 2021 at 7:33 Comment(0)
V
0

Apart from redirection cmd < clean.bat you might also like:

# Basic case - pipeline
echo clean.bat | cmd

# Feeding two commands - pipeline
echo -e "cd (cygpath -w ~/some_folder)\nclean.bat" | cmd # note the -e switch and \n char...

# For multiline cases the "here document" is the most readable form
cmd << MYEND
:: Here we go
cd `cygpath -w ~/my-folder`
setenv.bat
:: some_other_commands (?)
clean.bat
MYEND
Vibrato answered 20/10, 2023 at 9:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.