Something
public text v1 · immutable#!/bin/bash
ME=$0
JUSTME=${ME##*/}
if [[ $ME != $JUSTME ]]
then
LOCATION=${ME%/*}
else
for P in ${PATH/:/ /}
do
if [[ -x $P/$JUSTME ]]
then
LOCATION=$P
fi
done
fi
echo "LOCATION is $LOCATION"