Better OS detection (#39)

This commit is contained in:
Kevin van Zonneveld 2016-06-23 16:20:45 +02:00 committed by GitHub
parent bd49dda4b4
commit 03a2ec5adf
3 changed files with 13 additions and 4 deletions

View File

@ -4,6 +4,7 @@
Released: Unreleased. [Commit log](https://github.com/kvz/bash3boilerplate/compare/v2.0.0...master)
- Better OS detection (#38, thx @moviuro)
- Improve README copy (#34, thx galaktos)
- Fix unquoted variable access within (#34 thx galaktos)
- For delete-key-friendliness, bundle the commandline definition block along with its parser

View File

@ -156,6 +156,7 @@ Please see the [FAQ.md](./FAQ.md) file.
- [@bravo-kernel](https://github.com/bravo-kernel) (feedback)
- [@skanga](https://github.com/skanga) (feedback)
- [galaktos](https://www.reddit.com/user/galaktos) (feedback)
- [@moviuro](https://github.com/moviuro) (feedback)
## License

15
main.sh
View File

@ -26,13 +26,20 @@ set -o pipefail
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
__file="${__dir}/$(basename "${BASH_SOURCE[0]}")"
__base="$(basename ${__file} .sh)"
__os="Linux"
if [[ "${OSTYPE:-}" == "darwin"* ]]; then
# The __os magic variable that b3bp offers is a dumbed down version of OSTYPE, aimed at
# simple use cases. For more specific os information use ${OSTYPE}, or uname directly.
if [[ "${OSTYPE:-}" == "linux"* ]]; then
__os="Linux"
elif [[ "${OSTYPE:-}" == "darwin"* ]]; then
__os="OSX"
fi
if [[ "${OSTYPE:-}" == "msys"* ]]; then
elif [[ "${OSTYPE:-}" == "msys" ]]; then
# This could accomodate Git Bash but we're welcoming more input at https://github.com/kvz/bash3boilerplate/issues/32
__os="Windows"
elif [[ "${OSTYPE:-}" == *"bsd"* ]]; then
__os="BSD"
else
__os="b3bp_unsupported"
fi
# Define the environment variables (and their defaults) that this script depends on