Is there a way to detect if a shell script is called directly or called from another script.
parent.sh
#/bin/bash
echo "parent script"
./child.sh
child.sh
#/bin/bash
echo -n "child script"
[ # if child script called from parent ] && \
echo "called from parent" || \
echo "called directly"
results
./parent.sh
# parent script
# child script called from parent
./child.sh
# child script called directly