Last active
December 19, 2018 19:23
-
-
Save kkew3/3bbddd69f340bbc3dcd663bbe8d967b7 to your computer and use it in GitHub Desktop.
Ensure bash to be sourced or to be called as executable
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
if [ "${BASH_SOURCE[0]}" != "$0" ]; then | |
echo "This script intends to be called rather than be sourced" | |
return 1 | |
fi |
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
if [ "${BASH_SOURCE[0]}" = "$0" ]; then | |
echo "This script intends to be sourced rather than be called" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment