0
votes

How can you distinguish between MSYS and MSYS2 and CYGWIN, e.g via a command or a predefined environment variable?

This distinction would be needed by tools like Scons to adapt generated command lines, e.g. by issuing double backslashed c:\\path\\to\\file or backticked `cygpath -w /c/path/to/file`.

Background: I would like to use MSYS2, because of its superior package management. Scons generates the /c/path/to/file on MSYS2, but csc (Microsoft's C# compiler) only allows Windows style paths.

2
MSYS may allow you to use a path name such as 'C:\path\to\file', but it much prefers you to use '/c/path/to/file'. The issue should be moot anyway: when you invoke any native tool, (such as Microsoft's C# compiler), from the MSYS shell, the path name '/c/path/to/file' is converted on the fly, to its native windows equivalent, (possibly with regular '/' dirname separators, which are valid in native path names). I don't know if MSYS2 does likewise -- I do not use it -- but I understood that it was supposed to.Keith Marshall
MSYS does, but MSYS2 makes problems with csc ( error CS1504: Source file could not be opened), probably because MSYS2 is almost Cygwin.Roland Puntaier
MSYS2 is an independent fork of cygwin; it is not supported by MinGW.org, (who do provide MSYS), for the very reason that it seems to have completely lost sight of the original minimalist intent of MSYS, so becoming, as you say, "almost cygwin", (so why bother with it, rather than just use cygwin?)Keith Marshall
Yeah, right. I turned to it in the search of an easy command line way to install MSYS with MinGW on Windows. The name MSYS2 is misleading. Now I do choco install git && choco install mingw and copy the tools/mingw64 over git/mingw64 and use git-bash.Roland Puntaier
The easy command line way to install MinGW+MSYS is mingw-get install ..., but right now we don't have a git package to go with that. Also, if you specifically want mingw-w64 -- which is very definitely not MinGW -- then I don't think there are any mingw-get aware packages for that either.Keith Marshall

2 Answers

0
votes

I don't know of any environment variable which will reliably convey this information, but the output from uname -s should tell you.

0
votes

Check the system name and version:

case "$(uname -or)" in
    1.*Msys)  system='msys'   ;;
    2.*Msys)  system='msys2'  ;;
    .*Cygwin) system='cygwin' ;;
esac