Created
February 17, 2013 05:35
-
-
Save tjluoma/4970335 to your computer and use it in GitHub Desktop.
A simple conditional to check whether or not a shell script is being called from `launchd` or not.
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/zsh -f | |
PPID_NAME=$(/bin/ps -p $PPID | fgrep '/sbin/launchd' | awk '{print $NF}') | |
if [ "$PPID_NAME" = "/sbin/launchd" ] | |
then | |
IS_LAUNCHD=yes | |
else | |
IS_LAUNCHD=no | |
fi | |
#EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See https://gist.github.com/tjluoma/4970344 for an example of how you might use this