Skip to content

Instantly share code, notes, and snippets.

@ypetya
Last active August 29, 2015 14:12
Show Gist options
  • Save ypetya/fb38f16ce003cc572d21 to your computer and use it in GitHub Desktop.
Save ypetya/fb38f16ce003cc572d21 to your computer and use it in GitHub Desktop.
*require* bash function
function is_installed() {
local installed=$(dpkg -s "$1" 2>&1 | grep 'install ok installed')
if [ "" == "$installed" ] ; then
return 1
fi
return 0
}
function require() {
UNAME="$(uname)"
case $UNAME in
MINGW*)
echo "MinGW not supported"
return 0
;;
Linux|*)
echo "require $1"
if ! is_installed $1 ; then
echo "$1 not installed yet!"
sudo apt-get install $1
return $?
fi
;;
esac
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment