Created
May 4, 2023 19:35
-
-
Save noherczeg/0c17d23393512f6f61afa01c8e01280a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
unameOut=$(uname -a) | |
case "${unameOut}" in | |
*Microsoft*) OS="WSL";; #must be first since Windows subsystem for linux will have Linux in the name too | |
*microsoft*) OS="WSL2";; #WARNING: My v2 uses ubuntu 20.4 at the moment slightly different name may not always work | |
Linux*) OS="Linux";; | |
Darwin*) OS="Mac";; | |
CYGWIN*) OS="Cygwin";; | |
MINGW*) OS="Windows";; | |
*Msys) OS="Windows";; | |
*) OS="UNKNOWN:${unameOut}" | |
esac | |
echo ${OS}; | |
echo "$OSTYPE"; | |
if [[ "$OSTYPE" == "linux-gnu"* ]]; then | |
echo "Linux"; | |
elif [[ "$OSTYPE" == "darwin"* ]]; then | |
echo "OSX"; | |
elif [[ "$OSTYPE" == "cygwin" ]]; then | |
echo "Windows"; | |
elif [[ "$OSTYPE" == "msys" ]]; then | |
echo "Windows"; | |
elif [[ "$OSTYPE" == "win32" ]]; then | |
echo "Windows" | |
elif [[ "$OSTYPE" == "freebsd"* ]]; then | |
echo "FreeBSD"; | |
else | |
echo "unknown"; | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment