Added comments because shell scripts can be confusing

This commit is contained in:
probablycorey 2014-03-13 11:14:26 -07:00
parent 2fd71f2fa8
commit 1cbaf8d1f5

View File

@ -1,11 +1,13 @@
#!/bin/sh
ATOM_PATH=${ATOM_PATH:-/Applications}
ATOM_PATH=${ATOM_PATH:-/Applications} # Set ATOM_PATH unless it is already set
ATOM_APP_NAME=Atom.app
# If ATOM_PATH isn't a executable file, use spotlight to search for Atom
if [ ! -x "$ATOM_PATH/$ATOM_APP_NAME" ]; then
ATOM_PATH=$(mdfind "kMDItemCFBundleIdentifier == 'com.github.atom'" | head -1 | xargs dirname)
fi
# Exit if Atom can't be found
if [ -z "$ATOM_PATH" ]; then
echo "Cannot locate Atom.app, it is usually located in /Applications. Set the ATOM_PATH environment variable to the directory containing Atom.app."
exit 1
@ -40,12 +42,13 @@ else
open -a "$ATOM_PATH/$ATOM_APP_NAME" -n --args --executed-from="$(pwd)" --pid=$$ "$@"
fi
# Used to exit process when atom is used as $EDITOR
# Exits this process when Atom is used as $EDITOR
on_die() {
exit 0
}
trap 'on_die' SIGQUIT SIGTERM
# If the wait flag is set, don't exit this process until Atom tells it to.
if [ $WAIT ]; then
while true; do
sleep 1