#!/bin/sh -e

os=$(uname -s | tr '[:upper:]' '[:lower:]')
# os="$(uname | tr '[:upper:]' '[:lower:]' | sed 's/mingw/windows/; s/.*windows.*/windows/')"

# shellcheck disable=SC2249
case "${os}" in
  msys*) os="windows" ;;
  mingw*) os="windows" ;;
  cygwin*) os="windows" ;;
  win*) os="windows" ;;
esac

# sun solaris and derived os reports to be the ancient sunos via uname
if [ "${os}" = "sunos" ]; then
  # current illumos versions have -o to check if illumos x solaris
  # shellcheck disable=SC2312
  if [ "$(uname -o)" = "illumos" ]; then
    os="illumos"
  else
    os="solaris"
  fi
fi

# other fixups here
echo "${os}"
