I have a script where I do not want it to call exit
if it's being sourced.
I thought of checking if $0 == bash
but this has problems if the script is sourced from another script, or if the user sources it from a different shell like ksh
.
Is there a reliable way of detecting if a script is being sourced?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…