Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
您如何区分 MSYS 和 MSYS2 以及 CYGWIN,例如通过命令或预定义的环境变量?
像 Scons 这样的工具需要这种区别来适应生成的命令行,例如通过发出双反斜杠c:\\path\\to\\file或反引号`cygpath -w /c/path/to/file`。
c:\\path\\to\\file
`cygpath -w /c/path/to/file`
背景:我想使用 MSYS2,因为它具有出色的包管理功能。Scons 在 MSYS2 上生成/c/path/to/file,但csc(Microsoft 的 C# 编译器)只允许 Windows 样式路径。
/c/path/to/file
csc
我不知道任何可以可靠地传达此信息的环境变量,但输出uname -s应该会告诉您。
uname -s
检查系统名称和版本:
case "$(uname -or)" in 1.*Msys) system='msys' ;; 2.*Msys) system='msys2' ;; .*Cygwin) system='cygwin' ;; esac