How to check if running in Cygwin, Mac or Linux?

后端 未结 11 899
忘掉有多难
忘掉有多难 2020-11-27 23:58

I have a shell script that is used both on Windows/Cygwin and Mac and Linux. It needs slightly different variables for each versions.

How can a shell/bash script de

11条回答
  •  猫巷女王i
    2020-11-28 00:50

    http://en.wikipedia.org/wiki/Uname

    All the info you'll ever need. Google is your friend.

    Use uname -s to query the system name.

    • Mac: Darwin
    • Cygwin: CYGWIN_...
    • Linux: various, LINUX for most

提交回复
热议问题