Check if script is sourced or not

https://superuser.com/questions/731425/bash-detect-execute-vs-source-in-a-script

if [ `basename "$0"` != "werm.w" ];then
    export_env_admin
    if [ ! -e ./.env-werm-root ];then
        dir=$(realpath $(dirname `pwd`));
        if [ "`basename $dir`" = "environments" ];then
            cd ../../;
        fi
    fi
fi

Leave a Reply

Your email address will not be published.