Teeny-tiny doco-patch for -X

I just got bit by -e returning false when there was a symlink in place
that pointed to a non-existent file. So ...

diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod
index 9394e22343..4c3d3f96c1 100644
--- a/pod/perlfunc.pod
+++ b/pod/perlfunc.pod
@@ -535,7 +535,7 @@ operator.  The operator may be any of:
     -X  File is executable by real uid/gid.
     -O  File is owned by real uid.
 
-    -e  File exists.
+    -e  File exists (NB returns false for dangling symlinks).
     -z  File has zero size (is empty).
     -s  File has nonzero size (returns size in bytes).

-- 
David Cantrell
0
david
10/30/2018 5:54:50 PM
perl.perl5.porters 47406 articles. 0 followers. Follow

3 Replies
14 Views

Similar Articles

[PageSpeed] 21

David Cantrell <david@cantrell.org.uk> writes:

> I just got bit by -e returning false when there was a symlink in place
> that pointed to a non-existent file. So ...
>
> diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod
> index 9394e22343..4c3d3f96c1 100644
> --- a/pod/perlfunc.pod
> +++ b/pod/perlfunc.pod
> @@ -535,7 +535,7 @@ operator.  The operator may be any of:
>      -X  File is executable by real uid/gid.
>      -O  File is owned by real uid.
>  
> -    -e  File exists.
> +    -e  File exists (NB returns false for dangling symlinks).
>      -z  File has zero size (is empty).
>      -s  File has nonzero size (returns size in bytes).

All the file test operators (except -l) follow symbolic links (becuse
they use stat(), not lstat()). Rather than singling out -e, we should
mention this general fact.

- ilmari
-- 
- Twitter seems more influential [than blogs] in the 'gets reported in
  the mainstream press' sense at least.               - Matt McLeod
- That'd be because the content of a tweet is easier to condense down
  to a mainstream media article.                      - Calle Dybedahl
0
ilmari
10/31/2018 11:20:53 AM
On Wed, Oct 31, 2018 at 11:20:53AM +0000, Dagfinn Ilmari Manns?ker wrote:
> David Cantrell <david@cantrell.org.uk> writes:
> > I just got bit by -e returning false when there was a symlink in place
> > that pointed to a non-existent file. So ...
> >
> > diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod
> > ...
> > -    -e  File exists.
> > +    -e  File exists (NB returns false for dangling symlinks).
> > ...
> All the file test operators (except -l) follow symbolic links (becuse
> they use stat(), not lstat()). Rather than singling out -e, we should
> mention this general fact.

Hmmm, fair point.

diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod
index 9394e22343..56fe06368f 100644
--- a/pod/perlfunc.pod
+++ b/pod/perlfunc.pod
@@ -523,7 +523,11 @@ tests STDIN.  Unless otherwise documented, it returns C<1> for true and
 C<''> for false.  If the file doesn't exist or can't be examined, it
 returns L<C<undef>|/undef EXPR> and sets L<C<$!>|perlvar/$!> (errno).
 Despite the funny names, precedence is the same as any other named unary
-operator.  The operator may be any of:
+operator.  It's important to remember that with the exception of the C<-l>
+test they all follow symbolic links because they use C<stat()> and not
+C<lstat()>.
+
+The operator may be any of:
 
     -r  File is readable by effective uid/gid.
     -w  File is writable by effective uid/gid.


-- 
David Cantrell | Minister for Arbitrary Justice
0
david
10/31/2018 4:54:46 PM
David Cantrell <david@cantrell.org.uk> wrote:
> diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod
> index 9394e22343..56fe06368f 100644
> --- a/pod/perlfunc.pod
> +++ b/pod/perlfunc.pod
> @@ -523,7 +523,11 @@ tests STDIN.  Unless otherwise documented, it returns C<1> for true and
>  C<''> for false.  If the file doesn't exist or can't be examined, it
>  returns L<C<undef>|/undef EXPR> and sets L<C<$!>|perlvar/$!> (errno).
>  Despite the funny names, precedence is the same as any other named unary
> -operator.  The operator may be any of:
> +operator.  It's important to remember that with the exception of the C<-l>
> +test they all follow symbolic links because they use C<stat()> and not
> +C<lstat()>.
> +
> +The operator may be any of:
>
>      -r  File is readable by effective uid/gid.
>      -w  File is writable by effective uid/gid.

Thanks, applied with some minor reordering as
1c13323db058039bc6b70d5c08ae06a66e96b211.

-- 
Aaron Crane
0
arc
11/1/2018 11:16:58 AM
Reply: