When script is sourced, how to return or exit code

Tag(s):

When script is sourced, use the following return or exit code

[ $PS1 ] && return || exit;

http://stackoverflow.com/a/21344086

Test

# Display exit code
echo $?

Above is wrong

# http://stackoverflow.com/q/6112540
kill -SIGINT
 
# http://stackoverflow.com/a/17153661
kill -INT $$