为什么MSYS2无法在Windows上解析批处理文件?

问题描述 投票:2回答:2

为了避免将长命令重新输入到MSYS进行配置,我通常使用批处理文件来存储该命令,如下所示: ./configure \ --arch=x86_64 \ --target-os=win64 \ --toolchain=msvc \ --enable-cross-compile \ --enable-gpl \ --disable-debug \ --enable-shared \

这种方式适用于MSYS。但是,当我在MSYS2中运行批处理文件时,它发现了许多错误消息,例如:

'.' is not recognized as an internal or external command, operable program or batch file. '--arch' is not recognized as an internal or external command, operable program or batch file. etc...

谁能解释我的原因是什么?

windows msys mingw-w64 msys2
2个回答
1
投票

正如您所展示的,您的“ batch”文件看起来更像是Bourne shell脚本,因此绝对不应该将其视为.bat文件。现在,如果您将[限定为.bat文件,则MSYS将无法直接运行它;它需要一个shebang行以使其可以作为Shell脚本执行。从显示的错误消息看来,通过将执行交给Windows命令解释程序,MSYS2可能试图以某种聪明的方式(而MSYS却不这样做)(这些错误消息是cmd.exe错误消息)。由于脚本采用的是Bourne shell语法,因此您希望MSYS2直接在bash中运行它。

BTW,MSYS shell

bash; AFAIK,MSYS2还提供bash作为其主外壳。

0
投票
msys和msys2之间肯定有区别。从make执行DOS bat文件时,msys将bat文件解释为shell脚本。Msys2会将其正确识别为bat文件,并调用cmd.exe来执行它。还将参数转换为DOS格式。这正是我需要避免的。

命令行:VSC.bat -c / Config / BswM

bat文件“看到的内容:VSC.bat -c C:/ mingw64 / msys / Config / BswM

是否可以关闭此转换?

© www.soinside.com 2019 - 2024. All rights reserved.