Article View: gnu.utils.bug
Article #143ls and symbolic links in fileutils 3.2
From: Ian Lance Taylor
Date: Mon, 13 Apr 1992 17:42
Date: Mon, 13 Apr 1992 17:42
44 lines
2237 bytes
2237 bytes
ls in fileutils 3.2 doesn't handle symbolic links quite right. If you
do the following:
mkdir foo
ln -s bar foo
ln -s bar quux
ls quux
you get
quux
whereas you should get a listing of the (zero) files in foo.
I made the following change to get the correct behaviour. I don't
know if this is the right solution, since I couldn't quite figure out
what this code was supposed to do.
--- ls.c.old Mon Mar 9 00:46:29 1992
+++ ls.c Mon Apr 13 21:20:07 1992
@@ -943,7 +943,7 @@
/* Stat the file linked to; automatically trace it in non-long
listings, get its mode for the filetype indicator in long
listings. */
- if (linkpath && lstat (linkpath, &linkstats) == 0)
+ if (linkpath && stat (linkpath, &linkstats) == 0)
{
if (S_ISDIR (linkstats.st_mode)
&& explicit_arg && format != long_format)
Even with this change, ls -lF handles symbolic links differently from
the Ultrix 4.0 ls. Doing an ls -lF bar with the Ultrix ls gives
lrwxrwxr-x 1 ian 3 Apr 13 21:34 bar@ -> foo
but the GNU ls gives
lrwxrwxr-x 1 ian users 3 Apr 13 21:34 bar -> foo/
Note that the Ultrix ls applies the -F to bar rather than foo.
I think the GNU method is better.
Without the patch above, ls -lF quux gives
lrwxrwxr-x 1 ian users 3 Apr 13 21:34 quux -> bar@
With the above patch, ls -lF quux gives
lrwxrwxr-x 1 ian users 3 Apr 13 21:34 quux -> bar/
I don't know which result is desirable.
--
Ian Taylor ian@airs.com uunet!airs!ian
First person to identify this quote wins a free e-mail message:
``Do you make a grievance of weighing so many pounds only, instead of three
hundred? Then why fret about living so many years only, instead of more?''
Technical Details
Message-ID:
<9204140142.AA07770@comton.airs.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!airs.COM!ianShow Full Headers
Complete Article Headers
Newsgroups: gnu.utils.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!airs.COM!ian From: ian@airs.COM (Ian Lance Taylor) Subject: ls and symbolic links in fileutils 3.2 Message-ID: <9204140142.AA07770@comton.airs.com> Sender: gnulists@ai.mit.edu Organization: GNUs Not Usenet Distribution: gnu Date: Mon, 13 Apr 1992 17:42:14 GMT Approved: bug-gnu-utils@prep.ai.mit.edu Lines: 45