Skip to content

Instantly share code, notes, and snippets.

@BrendanThompson
Created April 19, 2014 02:36
Show Gist options
  • Save BrendanThompson/11072151 to your computer and use it in GitHub Desktop.
Save BrendanThompson/11072151 to your computer and use it in GitHub Desktop.
Checks package managers to determine which to use.
#!/usr/bin/env bash
OS=""
if [[ -n $(command -v brew) ]]; then
OS="OSX"
elif [[ -n $(command -v yum) ]]; then
OS="RH"
elif [[ -n $(command -v apt-get) ]]; then
OS="DEB"
elif [[ -n $(command -v pacman) ]]; then
OS="ARCH"
elif [[ -n $(command -v emerge) ]]; then
OS="GENTOO"
else
OS="UNKNOWN"
fi
echo "$OS"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment