Last active
August 29, 2015 14:02
-
-
Save chriscorwin/a9a66a58b80d8fc7234e 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
| #noshebang;source-this | |
| ## | |
| # This is a simple script to figure out what sort of system the user is running. These | |
| # exported environmental variables can then be used for system-agnostic scripts. This | |
| # script MUST be sourced in order to have access to the variables afterwards. | |
| ## | |
| # get uname info | |
| export _ENV_UNAME=$(uname -s) | |
| # Unix-y vars | |
| export _ENV_UNIX= | |
| export _ENV_LINUX= | |
| export _ENV_OSX= | |
| # Windows-y vars | |
| export _ENV_WINDOWS= | |
| export _ENV_CYGWIN= | |
| export _ENV_MSYSGIT= | |
| # var that will be echoed if -e is passed. if it's already been set, just echo it. | |
| _ENV_SUMMARY= | |
| case $_ENV_UNAME in | |
| Linux*) | |
| export _ENV_UNIX=true | |
| export _ENV_LINUX=true | |
| _ENV_SUMMARY="unix-linux" | |
| ;; | |
| Darwin*) | |
| export _ENV_UNIX=true | |
| export _ENV_OSX=true | |
| _ENV_SUMMARY="unix-osx" | |
| ;; | |
| CYGWIN*) | |
| export _ENV_WINDOWS=true | |
| export _ENV_CYGWIN=true | |
| _ENV_SUMMARY="windows-cygwin" | |
| ;; | |
| MINGW32*) | |
| export _ENV_WINDOWS=true | |
| export _ENV_MSYSGIT=true | |
| _ENV_SUMMARY="windows-msysgit" | |
| ;; | |
| *) | |
| export _ENV_OTHER=true | |
| _ENV_SUMMARY="other" | |
| ;; | |
| esac | |
| export _ENV_SUMMARY | |
| if [ "$1" = "-e" ]; then | |
| echo $_ENV_SUMMARY | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment