Created
November 24, 2016 12:11
-
-
Save durzo/892c4f81b255c1f24daba92922224db0 to your computer and use it in GitHub Desktop.
Bash OS detection
This file contains 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
$regex = "'blblbl'" | |
if [[ "$OSTYPE" == "linux-gnu" ]]; then | |
# Linux | |
$shasum = "/usr/bin/sha1sum" | |
$strbin = "sed -e$regex" | |
elif [[ "$OSTYPE" == "darwin"* ]]; then | |
# Mac OSX | |
$shasum = "/usr/bin/shasum" | |
$strbin = "sed -e $regex" | |
elif [[ "$OSTYPE" == "cygwin" ]]; then | |
# POSIX compatibility layer and Linux environment emulation for Windows | |
elif [[ "$OSTYPE" == "msys" ]]; then | |
# Lightweight shell and GNU utilities compiled for Windows (part of MinGW) | |
elif [[ "$OSTYPE" == "win32" ]]; then | |
# I'm not sure this can happen. | |
elif [[ "$OSTYPE" == "freebsd"* ]]; then | |
# ... | |
else | |
# Unknown. | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment