Last active
August 29, 2015 14:12
-
-
Save ypetya/fb38f16ce003cc572d21 to your computer and use it in GitHub Desktop.
*require* bash function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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