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

73 views
Skip to first unread message

Michael G Schwern

unread,
Apr 4, 2005, 12:41:40 PM4/4/05
to Chip Salzenberg, Perl 6 Internals
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 C<utime> 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)

Steve Peters

unread,
Apr 4, 2005, 12:27:31 PM4/4/05
to Chip Salzenberg, Perl 6 Internals
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 C<utime> 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
st...@fisharerojo.org

Chip Salzenberg

unread,
Apr 4, 2005, 12:00:20 PM4/4/05
to Perl 6 Internals
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 C<utime> 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. - <ch...@pobox.com>
Open Source is not an excuse to write fun code
then leave the actual work to others.

Reply all
Reply to author
Forward
0 new messages