Skip to content

Instantly share code, notes, and snippets.

@kkew3
Last active December 19, 2018 19:23
Show Gist options
  • Save kkew3/3bbddd69f340bbc3dcd663bbe8d967b7 to your computer and use it in GitHub Desktop.
Save kkew3/3bbddd69f340bbc3dcd663bbe8d967b7 to your computer and use it in GitHub Desktop.
Ensure bash to be sourced or to be called as executable
if [ "${BASH_SOURCE[0]}" != "$0" ]; then
echo "This script intends to be called rather than be sourced"
return 1
fi
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