Created
December 29, 2011 21:20
-
-
Save nicerobot/1536253 to your computer and use it in GitHub Desktop.
Is a bash script sourced or executed directly?
This file contains hidden or 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
sourced() { [ 'bash' == "${0:-i}" ] || [ "${BASH_SOURCE[0]}" != "${0:-i}" ]; } | |
# Example: | |
# sourced && return 0 || exit 0 | |
# For some reason, this function needs to be defined in the same context in which it's used. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment