Sorry for misunderstanding. I tried a few things...
$ \ls -ldF /home2/ikegami
lrwxr-xr-x ... /home2/ikegami@ -> /home3/ikegami
$ \ls -ldF /home3/ikegami
drwx--x--x ... /home3/ikegami/
$ pwd
/home2/ikegami
$ perl -e 'print `pwd`'
/home3/ikegami
$ perl -e 'print `pwd -L`'
/home2/ikegami
$ perl -e 'chdir "www"; print `pwd -L`'
/home3/ikegami/www
$ perl -le 'use Cwd; print cwd;'
/home3/ikegami
$ perl -le 'use Cwd; print getcwd;'
/home3/ikegami
$ echo $PWD
/home2/ikegami
$ perl -le 'print $ENV{"PWD"};'
/home2/ikegami
$ perl -le 'chdir("www"); print $ENV{"PWD"};'
/home2/ikegami
$ perl -le 'use Cwd qw( chdir ); chdir("www"); print $ENV{"PWD"};'
/home2/ikegami/www
`pwd -L` seems to work, at the cost of creating a child process and running pwd. It stops working if chdir is used, unfortunately.
If the calling shell provides $ENV{"PWD"}, you save the spawning cost. Of course, it doesn't change if chdir is used.
... unless you use the chdir from Cwd everywhere.
|