Created
June 29, 2011 16:55
-
-
Save matthewmccullough/1054304 to your computer and use it in GitHub Desktop.
Tests if an app is installed. Response code could be checked by an if-test
This file contains hidden or 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
| #!/bin/bash | |
| #Ensure we have one argument specified on the CLI | |
| if [ -z "$1" ]; then ARG_ERR=ERR; fi | |
| if [ -n "$ARG_ERR" ]; | |
| then | |
| echo "Checks if an app (passed as a parameter) is installed/reachable" | |
| echo " on this machine by using the 'hash' command." | |
| echo "Usage: isappinstalled <appname>" | |
| echo "Returns: 0 if is installed, 1 if not installed." | |
| exit | |
| fi | |
| hash $1 2>&- || { echo >&2 "I require $1 but it's not installed."; exit 1; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment