Determining whether shell script was executed “sourcing” it

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?

28
задан Kurt Pfeifle 16 July 2011 в 06:47
поделиться