Skip to content

Instantly share code, notes, and snippets.

@ImSingee
Created August 24, 2020 05:10
Show Gist options
  • Select an option

  • Save ImSingee/f791d660c1527e96a03ea69e957ddca5 to your computer and use it in GitHub Desktop.

Select an option

Save ImSingee/f791d660c1527e96a03ea69e957ddca5 to your computer and use it in GitHub Desktop.
#!/bin/sh
set -e
is_wsl() {
case "$(uname -r)" in
*microsoft* ) true ;; # WSL 2
*Microsoft* ) true ;; # WSL 1
* ) false;;
esac
}
is_darwin() {
case "$(uname -s)" in
*darwin* ) true ;;
*Darwin* ) true ;;
* ) false;;
esac
}
get_distribution() {
lsb_dist=""
# Every system that we officially support has /etc/os-release
if [ -r /etc/os-release ]; then
lsb_dist="$(. /etc/os-release && echo "$ID")"
fi
# Returning an empty string here should be alright since the
# case statements don't act unless you provide an actual value
echo "$lsb_dist"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment