I'm curious: why the `printf '%s\n' "$(pwd -P)"` ? wouldn't just `pwd -P` achieve the same?
printf '%s/%s\n' "$(pwd -P)" "$(basename "$0")"
It's just been in place, in so many places, so long it's become unquestionable. So yes the `pwd -P` in this case will suffice.This approach breaks if you run the script from a symlink.