On Sat, Oct 01, 2016 at 01:38:49PM +1000, john slee wrote:
> Not sure if folks are interested in this or not, but it sure caused me some
> angst this morning. OSX has the same behaviour and also doesn't document
> it. I assume it has been that way for a long, long time.
> 
> My first patch. Thanks for all the cool stuff :-)
>
> Index: bin/test/test.1
> ===================================================================
> RCS file: /cvs/src/bin/test/test.1,v
> retrieving revision 1.33
> diff -u -p -r1.33 test.1
> --- bin/test/test.1     16 Aug 2016 18:51:25 -0000      1.33
> +++ bin/test/test.1     1 Oct 2016 03:37:23 -0000
> @@ -92,7 +92,9 @@ exists and is a directory.
>  .It Fl e Ar file
>  True if
>  .Ar file
> -exists (regardless of type).
> +exists, unless
> +.Ar file
> +is a dangling symbolic link.

Thanks, but I think that we document it.  It seems unnecessary and
inconsistent to add that caveat only to -e.  The manual says explicitly:

     Symbolic links are followed for all primaries except -h and -L.

So if your file is a dangling symbolic link, it is followed, and since
the file it points to doesn't exist, the expression evaluates to false.

POSIX is also unambiguous about this behavior:

       -e pathname
                 True if pathname resolves to an existing directory entry.
                 False if pathname cannot be resolved.

       [...]

       With the exception of the -h pathname and -L pathname primaries, if a
       pathname argument is a symbolic link, test shall evaluate the
       expression by resolving the symbolic link and using the file referenced
       by the link.

>  .It Fl f Ar file
>  True if
>  .Ar file

Reply via email to