Last active
February 20, 2016 20:39
-
-
Save opragel/47e23d6084a5f5305180 to your computer and use it in GitHub Desktop.
ea_adobe_acrobat_dc_versioncheck.sh
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
#!/bin/bash | |
# T = Local app version is equal to provided current version | |
# N = Local app version is newer than provided current version | |
# F = Local app version is less than provided current version | |
# N/A = Local app was not found at provided path | |
APP_PATH="/Applications/Adobe Acrobat DC/Adobe Acrobat.app" | |
APP_VERSION_KEY="CFBundleShortVersionString" | |
APP_CURRENT_VERSION="15.010.20056" | |
compareVersions () { | |
if [[ "$1" == "$2" ]]; then | |
return 0 | |
fi | |
local IFS=. | |
local i currentVersion=($1) localVersion=($2) | |
for ((i=${#currentVersion[@]}; i<${#localVersion[@]}; i++)); do | |
currentVersion[i]=0 | |
done | |
for ((i=0; i<${#currentVersion[@]}; i++)); do | |
if [[ -z ${localVersion[i]} ]]; then | |
localVersion[i]=0 | |
fi | |
if ((10#${currentVersion[i]} > 10#${localVersion[i]})); then | |
return 1 | |
fi | |
if ((10#${currentVersion[i]} < 10#${localVersion[i]})); then | |
return 2 | |
fi | |
done | |
return 0 | |
} | |
if [ -d "$APP_PATH" ]; then | |
localAppVersion=$(defaults read "$APP_PATH/Contents/Info.plist" "$APP_VERSION_KEY") | |
compareVersions "$localAppVersion" "$APP_CURRENT_VERSION" | |
versionCode="$?" | |
case $versionCode in | |
0) versionCheckResult='T';; | |
1) versionCheckResult='N';; | |
2) versionCheckResult='F';; | |
esac | |
else | |
versionCheckResult="N/A" | |
fi | |
printf "<result>%s</result>" "$versionCheckResult" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment