Last active
May 6, 2020 20:35
-
-
Save nmccready/dbcef31c5acda5dff1d8a89b8ed2b0fe to your computer and use it in GitHub Desktop.
check sourced or subshell bash
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
#!/usr/bin/env bash | |
function ohHi(){ | |
echo "Hi" | |
} | |
(return 0 2>/dev/null) && return || echo "Script is a subshell" | |
# self invoke if not sourced | |
ohHi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
source example