bug-coreutils
[Top][All Lists]
Advanced

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

Re: -e test for file exists problem with dangling symlinks


From: James Youngman
Subject: Re: -e test for file exists problem with dangling symlinks
Date: Tue, 22 Feb 2005 17:44:18 +0000
User-agent: Mutt/1.3.28i

On Tue, Feb 22, 2005 at 12:06:54PM -0500, John R. Vanderpool wrote:
> 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.
> 
> -e file exists test fails if file is a dangling symlink, this to me does
> not seem like the correct behavior, the test should not follow the symlink
> (lstat'ed instead of stat'ed).

This behavious ir required by POSIX:-

35127 -e file True if file exists.
35128 -f file True if file exists and is a regular file.
35129 -g file True if file exists and its set-group-ID flag is set.
35130 -h file True if file exists and is a symbolic link.
35131 -L file True if file exists and is a symbolic link.
...
35163 With the exception of the -h file and -L file primaries, if a file 
      argument is a symbolic link, test
35164 shall evaluate the expression by resolving the symbolic link and using 
      the file referenced by the
35165 link.

In other words, for "-e", test is required to "evaluate the expression
by resolving the symbolic link and using the file referenced by the
link" and in the case of a dangling link, that file doesn't exist so
"test -e" must fail.

I agree that the documentation should point this out.

Regards,
James.





reply via email to

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