Skip to content

Instantly share code, notes, and snippets.

@tjluoma
Created February 17, 2013 05:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tjluoma/4970335 to your computer and use it in GitHub Desktop.
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.
#!/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
@tjluoma
Copy link
Author

tjluoma commented Feb 17, 2013

See https://gist.github.com/tjluoma/4970344 for an example of how you might use this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment