v1.2 = Improved search for Existing App Bundles

+ Changed the interpreter to bash (was causing issues)
 + Changed up the while loop App existence check, as previously couldn't properly report "No versions found"
This commit is contained in:
Zack T
2018-01-29 22:06:18 -07:00
parent a9b00a62a5
commit f175fb86dc

View File

@@ -1,9 +1,9 @@
#! /bin/sh
#! /bin/bash
###################################################################################################
# Script Name: uninstall_SPSS.sh
# By: Zack Thompson / Created: 11/1/2017
# Version: 1.1 / Updated: 1/18/2018 / By: ZT
# Version: 1.2 / Updated: 1/25/2018 / By: ZT
#
# Description: Remove previous version(s) of SPSS from /Applications
#
@@ -11,18 +11,24 @@
/bin/echo "***** Uninstall SPSS process: START *****"
# If the machine has multiple SPSS Applications, loop through them...
/usr/bin/find -E /Applications -iregex ".*[/](SPSS) ?(Statistics) ?(\d\d)?[.]app" -type d -prune | while IFS="\n" read -r appPath; do
/bin/echo "Searching for existing SPSS instances..."
appPaths=$(/usr/bin/find -E /Applications -iregex ".*[/](SPSS) ?(Statistics) ?([0-9]{2})?[.]app" -type d -prune)
# Get the App Bundle name
appName=$(/bin/echo $appPath | /usr/bin/awk -F "/" '{print $NF}')
# Get only the install path
installPath=$(/bin/echo $appPath | /usr/bin/awk -F "/$appName" '{print $1}')
# Delete the old version
/bin/echo "Uninstalling: ${appPath}"
/bin/rm -rf "${installPath}"
done
# Verify that a SPSS version was found.
if [[ -z "${appPaths}" ]]; then
/bin/echo "Did not find an instance SPSS!"
else
# If the machine has multiple SPSS Applications, loop through them...
while IFS="\n" read -r appPath; do
# Get the App Bundle name
appName=$(/bin/echo $appPath | /usr/bin/awk -F "/" '{print $NF}')
# Get only the install path
installPath=$(/bin/echo $appPath | /usr/bin/awk -F "/$appName" '{print $1}')
# Delete the old version
/bin/echo "Uninstalling: ${appPath}"
/bin/rm -rf "${installPath}"
done < <(/bin/echo "${appPaths}")
fi
/bin/echo "***** Uninstall SPSS process: COMPLETE *****"