Determining whether shell script was executed "sourcing" it

Viewed 6063

Is it possible for a shell script to test whether it was executed through source? That is, for example,

$ source myscript.sh
$ ./myscript.sh

Can myscript.sh distinguish from these different shell environments?

9 Answers
Related