os: Use OSTYPE

This commit is contained in:
Dylan Araps 2018-05-31 14:57:13 +10:00
parent f41607c36c
commit 942f6cc4a7
1 changed files with 22 additions and 12 deletions

View File

@ -781,19 +781,29 @@ EOF
get_os() { get_os() {
# $kernel_name is set in a function called cache_uname and is # $kernel_name is set in a function called cache_uname and is
# just the output of "uname -s". # just the output of "uname -s".
case "$kernel_name" in case "$OSTYPE" in
"Linux" | "GNU"*) os="Linux" ;; "aix"*) os="AIX" ;;
"Darwin") os="$(sw_vers -productName)" ;; "darwin"*) os="$(sw_vers -productName)" ;;
*"BSD" | "DragonFly" | "Bitrig") os="BSD" ;; "haiku"*) os="Haiku" ;;
"CYGWIN"* | "MSYS"* | "MINGW"*) os="Windows" ;; "irix"*) os="IRIX" ;;
"SunOS") os="Solaris" ;; "minix"*) os="MINIX" ;;
"Haiku") os="Haiku" ;; "mint"*) os="FreeMiNT" ;;
"MINIX") os="MINIX" ;; "solaris"*) os="Solaris" ;;
"AIX") os="AIX" ;;
"IRIX"*) os="IRIX" ;; "linux"* | "gnu"*)
"FreeMiNT") os="FreeMiNT" ;; os="Linux"
;;
*"bsd"* | "dragonfly"* | "bitrig"*)
os="BSD"
;;
"cygwin"* | "msys"* | "mingw"* | "win32"*)
os="Windows"
;;
*) *)
printf "%s\n" "Unknown OS detected: '$kernel_name', aborting..." >&2 printf "%s\n" "Unknown OS detected: '$OSTYPE', aborting..." >&2
printf "%s\n" "Open an issue on GitHub to add support for your OS." >&2 printf "%s\n" "Open an issue on GitHub to add support for your OS." >&2
exit 1 exit 1
;; ;;