[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ls -L should say just what file doesn't exist

From: Theodoros V. Kalamatianos
Subject: Re: ls -L should say just what file doesn't exist
Date: Fri, 18 Nov 2005 00:18:36 +0200 (EET)

On Thu, 17 Nov 2005, Jim Meyering wrote:

When you use ls's -L option, that makes it use stat(2) rather
than lstat(2).  To give the better diagnostic, ls would have
to treat ENOENT specially when invoked with -L: it would perform
an additional lstat on the offending file, and if that succeeds,
it'd read the symlink, lstat the referent, and if it too is a symlink,
lstat its referent, etc., until something (lstat or readlink) fails,
or lstat finds a non-symlink.  Watch out for cycles!

That sounds like a significant chunk of new code, just for an
improved diagnostic, but I think it'd be worthwhile.
Anyone interested in the coding exercise?

What about using realpath() ? According to the realpath(3) manpage it exists on BSD, Linux, and Solaris and gives out an absolute dereferenced path. This could cut down significantly the necessary code.


Theodoros Kalamatianos

reply via email to

[Prev in Thread] Current Thread [Next in Thread]