Skip to content
This repository has been archived by the owner on Sep 4, 2018. It is now read-only.

Commit

Permalink
Use mktemp instead of re-using the same tmp file
Browse files Browse the repository at this point in the history
+ Fix coding style
  • Loading branch information
guillaumealgis committed Nov 21, 2015
1 parent 767f87d commit 25c4b3d
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions Scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,26 @@ PLUGINS_DIR="${HOME}/Library/Application Support/Developer/Shared/Xcode/Plug-ins
XCODE_VERSION="$(xcrun xcodebuild -version | head -n1 | awk '{ print $2 }')"
PLIST_PLUGINS_KEY="DVTPlugInManagerNonApplePlugIns-Xcode-${XCODE_VERSION}"
BUNDLE_ID="com.mneorr.Alcatraz"
TMP_FILE="/tmp/${BUNDLE_ID}.xcode-defaults"
TMP_FILE="$(mktemp -t ${BUNDLE_ID})"

# Remove Alcatraz from Xcode's skipped plugins list if needed
defaults read -app Xcode "$PLIST_PLUGINS_KEY" > "$TMP_FILE"
/usr/libexec/PlistBuddy -c "delete skipped:$BUNDLE_ID" "$TMP_FILE" > /dev/null 2>&1 && {
pgrep Xcode > /dev/null && { echo 'An instance of Xcode is currently running. Please close Xcode before installing Alcatraz.'; exit 1; }
defaults write -app Xcode "$PLIST_PLUGINS_KEY" "$(< $TMP_FILE)"
echo 'Alcatraz was removed from Xcode'\''s skipped plugins list. Next time you start Xcode select "Load Bundle" when prompted.'
pgrep Xcode > /dev/null && {
echo 'An instance of Xcode is currently running.' \
'Please close Xcode before installing Alcatraz.'
exit 1
}
defaults write -app Xcode "$PLIST_PLUGINS_KEY" "$(cat "$TMP_FILE")"
echo 'Alcatraz was removed from Xcode'\''s skipped plugins list.' \
'Next time you start Xcode select "Load Bundle" when prompted.'
}
rm "$TMP_FILE"

mkdir -p "${PLUGINS_DIR}"
curl -L $DOWNLOAD_URI | tar xvz -C "${PLUGINS_DIR}"

# the 1 is not a typo!
echo "Alcatraz successfully installed!!1!🍻 Please restart your Xcode ($XCODE_VERSION)."
echo 'Alcatraz successfully installed!!1!🍻 ' \
"Please restart your Xcode ($XCODE_VERSION)."

0 comments on commit 25c4b3d

Please sign in to comment.