SUMMARY: out of date ls manpage?

From: Trent Petrasek <tpetrasek_at_interliant.com>
Date: Tue Apr 23 2002 - 19:51:28 EDT
Hello again sun managers,

Thanks to all who replied, all of your responses shed light
on the situation, namely that I had misinterpreted the
command and wording. What I was trying to accomplish was to
grab the full path to the real file, knowing only the path
to the symbolic link. At any rate, "ls -lL" essentially
shows you the attributes of the referenced file, not the
name and path to the referenced file. This is done by
calling stat() instead of lstat().

$ ls -l linkfile
lrwxrwxrwx   1 trent    root           8 Apr 23 16:47
linkfile -> realfile
$ ls -lL realfile
-rw-r--r--   1 trent    root           0 Apr 23 16:47
realfile
$ ls -lL linkfile
-rw-r--r--   1 trent    root           0 Apr 23 16:47
linkfile

Generally, the most recommended method for obtaining the
referenced file name is the readlink() function (many
languages support this function as well as a 'readlink'
program found in tetex). This, however, may also return the
relative location in the filesystem, depending on how the
symlink was made. I was trying to avoid getting relative
pathnames as that means I have more work to do in the
script to locate the actual file. I am right back to where
I started before, but at least this time I know more.

Thanks again to all who replied:

Thien Vu
Mark Marcell
Darren Dunham
The Infamous Casper Dik
Thomas  Payerle
Dennis Peterson
Michael Connolly
Mark Scarborough
Dan Astoorian
Martin Carpenter
Larry Snyder
Spencer Hoffman
Larye Parkins

Kindest regards,

Trent


::::Original Post::::

Hello sun managers,

I am currently writing a shell script and in doing so I
needed to capture the referenced file or directory of a
symbolic link. In the `ls` manpage, dated May 1997, I find:

-L    If an argument is a symbolic link, lists the  file
 or directory  the  link  references  rather than the link
 itself.

yet on the system (an Ultra 2, Solaris 8 10/01) I see the
following behavior:

$ touch realfile
$ ln -s realfile linkfile
$ ls -l
total 2
lrwxrwxrwx   1 trent    root           8 Apr 23 16:47
linkfile -> realfile
-rw-r--r--   1 trent    root           0 Apr 23 16:47
realfile
$ ls -L linkfile
linkfile
$ ls linkfile
linkfile

Executing `ls -L` does not show me the file that the link
references, it shows me the link. Is the manpage out of
date? Is the command itself broken? I just installed the OS
a few weeks ago, this system is on a corporate network
behind firewalls, and I do not think a fellow employee
would hack my ls command, but you never know. At any rate,
the system does not appear to be compromised.

I was wondering if anyone knew about this or had any other
knowledge of how to obtain the reference of a symlink short
of awking the (possibly relative) pathname out of a ls -l.
I am not having luck in existing documentation and search
engines.

I will summarize.

Cheers,

Trent

--
Trenton Petrasek
Systems Engineer
Interliant, Atlanta, Engineering
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers
Received on Tue Apr 23 19:51:32 2002

This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:42:41 EST