I installed my bash scripts into /usr/bin/app.sh
and /usr/bin/lib.sh
app.sh
includes
source "/usr/bin/lib.sh"
and lib.sh
includes
if [ "/usr/bin/app.sh" == "$0"] ...
When I run app.sh
from the shell, this test fails because $0
is actually /bin/app.sh
. On the filesystem, /bin
is a symlink to /usr/bin
What's the best way for lib.sh
to determine whether it's being included by app.sh
(as opposed to other-app.sh
) in such a way that it won't get tricked by the environment? I would have thought absolute paths without symlinks would have done the job, but apparently not.