Softlink directory name not working on SUN

I am facing a peculiar problem on SUN machine.
There is a soft link pointing to a directory. And there is a shell script inside this soft link which is trying to get the directory name from where this script is being executed.

NAME="$(cd $(dirname $0); pwd)"

I want to fetch the absolute path of the soft link from this shell script but it is returning the target directory path. On LINUX machine it is working fine.
I tried with "pwd -L" but still it is giving the target directory path.

The interpreter is set as "ksh" in the shell script:

#!/bin/ksh

If I remove this above line (#!/bin/ksh) or if I set it to "bash" then it is working fine and "pwd -L" is giving me the path of soft link and not the target directory path.
But I don't want to set the interpreter to "bash" due to some other dependencies.

So in "ksh" how can I get the absolute path of the soft link and not of the target directory?

NAME=$( ls -l $0 | awk '{print $NF}' | xargs dirname)

try that.