Thread (5 messages) flat view 5 messages, 2 authors, 2016-06-15

Re: [PATCH] Git.pm: better error message

From: Philippe Bruhat (BooK) <hidden>
Date: 2016-06-15 22:48:57

On Mon, Jun 14, 2010 at 03:10:46AM -0400, Jeff King wrote:
On Mon, Jun 14, 2010 at 03:00:22AM +0200, Philippe Bruhat (BooK) wrote:
quoted
-d doesn't set $! if the directory doesn't exist
Really?

  $ perl -e '-d "bogus" or die "fail: $!"'
  fail: No such file or directory at -e line 1.

On the other hand:

  $ touch file
  perl -e '-d "file" or die "fail: $!"'
  fail:  at -e line 1.

So perhaps it is best not to rely on $!. Also, this is with perl 5.10.
Is it different with other versions?
Come to think of it, it probably makes sense: -d probably depends on stat
to get the information about the file, and that fails harder when the
file in question doesn't exists.

I guess the best would be to put the directory name in the error message
(always interesting information), and keep $! in case it was set by an
harder error.

-- 
 Philippe Bruhat (BooK)

 There is no solution to a problem of sheer greed.
                                    (Moral from Groo The Wanderer #94 (Epic))
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help