"John R. Vanderpool" <[EMAIL PROTECTED]> writes:

> this will probably be considered a non-bug (because the same behavior
> exists in bash, ksh, pdksh, irix, and gnu coreutils!) but i'ld at least
> like to hear an explanation if possible.

It's longstanding tradition that "test -e foo" should fail on a
dangling symlink.  It's also a requirement of POSIX; see
<http://www.opengroup.org/onlinepubs/009695399/utilities/test.html>.

You can use "test -e FOO || test -h FOO" if you want to test for
either a file or a dangling symlink.  Admittedly this is less
efficient than you might like, if for some reason (e.g., a network
file system, or a slow device) stat calls are very expensive.  If you
want a nonstandard extension that just issues an lstat system call and
nothing else, you can use "stat -c '' FOO 2>/dev/null" (recent
coreutils versions only) to test whether FOO exists either as a file
or a dangling symlink, without following any symlinks.


_______________________________________________
Bug-coreutils mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-coreutils

Reply via email to