如何檢查是否在 Cygwin、Mac 或 Linux 中執行? - How to check if running in Cygwin, Mac or Linux?

語言: CN / TW / HK

問題:

I have a shell script that is used both on Windows/Cygwin and Mac and Linux.我有一個在 Windows/Cygwin、Mac 和 Linux 上都使用的 shell 指令碼。 It needs slightly different variables for each versions.每個版本都需要稍微不同的變數。

How can a shell/bash script detect whether it is running in Cygwin, on a Mac or in Linux? shell/bash 指令碼如何檢測它是在 Cygwin、Mac 還是 Linux 中執行?


解決方案:

參考一: http://stackoom.com/question/EXhu
參考二: How to check if running in Cygwin, Mac or Linux?
「其他文章」