$(TOUCH) in Perl: any reason not to use utime()?

2005-04-04 Thread Chip Salzenberg
Currently, config/gen/makefiles/root.in says:

  TOUCH  = $(PERL) -e ${PQ}open(A,qq{$$_}) or die foreach @ARGV${PQ}

However, this fails for my source tree.  I habitually leave
CVS-controlled files write-only until they are locally modified.
(This is cvs -r behavior, also triggered by exporting CVSREAD=1.)

Perl has a Cutime operator which should work even when files are
read-only.  Is there a reason that $(TOUCH) doesn't use it?
-- 
Chip Salzenberg- a.k.a. -[EMAIL PROTECTED]
 Open Source is not an excuse to write fun code
then leave the actual work to others.


Re: $(TOUCH) in Perl: any reason not to use utime()?

2005-04-04 Thread Steve Peters
On Mon, Apr 04, 2005 at 12:00:20PM -0400, Chip Salzenberg wrote:
 Currently, config/gen/makefiles/root.in says:
 
   TOUCH  = $(PERL) -e ${PQ}open(A,qq{$$_}) or die foreach @ARGV${PQ}
 
 However, this fails for my source tree.  I habitually leave
 CVS-controlled files write-only until they are locally modified.
 (This is cvs -r behavior, also triggered by exporting CVSREAD=1.)
 
 Perl has a Cutime operator which should work even when files are
 read-only.  Is there a reason that $(TOUCH) doesn't use it?
 -- 

utime will only work if the file already exists.  The above looks like it
would work to create empty files.

Steve Peters
[EMAIL PROTECTED]


Re: $(TOUCH) in Perl: any reason not to use utime()?

2005-04-04 Thread Michael G Schwern
On Mon, Apr 04, 2005 at 12:00:20PM -0400, Chip Salzenberg wrote:
 Currently, config/gen/makefiles/root.in says:
 
   TOUCH  = $(PERL) -e ${PQ}open(A,qq{$$_}) or die foreach @ARGV${PQ}
 
 However, this fails for my source tree.  I habitually leave
 CVS-controlled files write-only until they are locally modified.
   read-only?

 (This is cvs -r behavior, also triggered by exporting CVSREAD=1.)
 
 Perl has a Cutime operator which should work even when files are
 read-only.  Is there a reason that $(TOUCH) doesn't use it?

ExtUtils::Command has a perfectly good and known working touch() function
which both opens for appending AND uses utime.

TOUCH = $(PERL) -MExtUtils::Command -e touch @ARGV

However, as currently implemented, it will die if the file is unwritable.
This can be corrected but I'm not confident in relying solely on utime 
because perlport sez...

   May not behave as expected.  Behavior depends on the C runtime
   library's implementation of utime(), and the filesystem being
   used.  The FAT filesystem typically does not support an access
   time field, and it may limit timestamps to a granularity of
   two seconds. (Win32)