Skip to content

Instantly share code, notes, and snippets.

@leodido
Created May 7, 2019 03:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leodido/619569d80411ec81b83567103a11f5fe to your computer and use it in GitHub Desktop.
Save leodido/619569d80411ec81b83567103a11f5fe to your computer and use it in GitHub Desktop.
function cache_uname {
what=$(uname -srm)
read -ra uname <<< "$what"
kern_name="${uname[0]}"
kern_vers="${uname[1]}"
mach_arch="${uname[2]}"
}
function get_os {
case "$kern_name" in
"Linux") os="linux" ;;
"Darwin") os="darwin" ;;
*"BSD" | "DragonFly" | "Bitrig") os="bsd" ;;
"CYGWIN"*) os="win" ;;
"SunOS") os="solaris" ;;
"Haiku") os="haiku" ;;
"GNU"*) os="gnu" ;;
*) printf "%s\n" "unkwown: $kern_name"; exit 1 ;;
esac
}
cache_uname
get_os
echo "$kern_name"
echo "$kern_vers"
echo "$mach_arch"
echo "$os"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment