The portablest solution I have found is:
rundir=$(cd -P -- "$(dirname -- "$0")" && printf '%s\n' "$(pwd -P)") rundir=$(cd -P -- "$(dirname -- "$0")" && printf '%s\n' "$(pwd -P)")Additionally (and the article doesn't solve this either), when invoked through $PATH, $0 will not be a full path but only the name of the command. In that case you want to start with "$(command -v "$0")" instead of just "$0".
This approach breaks if you run the script from a symlink.
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.