#!/usr/local/bin/perl -w eval 'exec /usr/local/bin/perl -w -S $0 ${1+"$@"}' if 0; # not running under some shell # # $Id: touch,v 1.1.1.1 2001/06/06 08:55:17 sdague Exp $ # # $Log: touch,v $ # Revision 1.1.1.1 2001/06/06 08:55:17 sdague # initial import # # Revision 1.1 2001/05/14 00:49:40 sdague # added more files # # Revision 1.1 1999/02/28 13:00:24 abigail # Initial revision # # use strict; use Getopt::Std; sub parse_time ($); my ($VERSION) = '$Revision: 1.1.1.1 $' =~ /([.\d]+)/; my $warnings = 0; # Print a usuage message on a unknown option. # Requires my patch to Getopt::Std of 25 Feb 1999. $SIG {__WARN__} = sub { require File::Basename; $0 = File::Basename::basename ($0); if (substr ($_ [0], 0, 14) eq "Unknown option") { warn < $time, 2; my $year; if ($first =~ /\D/) {die "$time: Illegal time format\n"} elsif (12 == length $first) { $year = substr $first, 0, 4, ''; } elsif (10 == length $first) { $year = substr $first, 0, 2, ''; $year += 100 if $year < 70; } elsif ( 8 == length $first) { $year = (localtime) [5]; } else {die "$time: Illegal time format\n"} if (defined $seconds && ($seconds =~ /\D/ || $seconds > 59 || 2 != length $seconds)) { die "-t $time: Illegal time format\n" } else { $seconds = 0; } my ($mon, $day, $hours, $minutes) = $first =~ /(..)(..)(..)(..)/; require Time::Local; Time::Local::timelocal ($seconds, $minutes, $hours, $day, $mon - 1, $year); } __END__ =pod =head1 NAME touch -- change access and modification times of files. =head1 SYNOPSIS touch [-acfm] [-r file] [-t [[CC]YY]MMDDhhmm[.SS]] file [files ...] =head1 DESCRIPTION I sets the access and modification timestamps of files. By default, both the access and modification times are set to the current time. If necessary, files will be created. I exits succesfully if and only if all timestamps could be set succesfully. =head2 OPTIONS I accepts the following options: =over 4 =item -a Set the access time of the specified files only, unless I<-m> is given as well. =item -c Do not create non-existing files. No warning is generated, and it will not influence the exit status. =item -f This option is ignored, and only recognized for compatability reasons. =item -m Set the modification time of the specified files only, unless I<-a> is given as well. =item -r file Use the access and modification time of I instead of the current time. =item -t [[CC]YY]MMDDhhmm[.SS] Set the access and modification times to the specified time. If B is present, but B is not, then B is assumed to be 19 if B is larger than 69, and 20 otherwise. If B is not present, the current year is assumed. It should be noted that many systems cannot deal with timestamps before Jan 1, 1970 or after Jan 19, 2038. =back =head1 ENVIRONMENT The working of I is not influenced by any environment variables. =head1 BUGS I does not implement the I<-f> option. I uses C to translate the time format to epoch seconds =head1 STANDARDS This I implementation is compatible with the B implementation, except for the I<-f> option. =head1 REVISION HISTORY $Log: touch,v $ Revision 1.1.1.1 2001/06/06 08:55:17 sdague initial import Revision 1.1 2001/05/14 00:49:40 sdague added more files Revision 1.1 1999/02/28 13:00:24 abigail Initial revision =head1 AUTHOR The Perl implementation of I was written by Abigail, I. =head1 COPYRIGHT and LICENSE This program is copyright by Abigail 1999. This program is free and open software. You may use, copy, modify, distribute and sell this program (and any modified variants) in any way you wish, provided you do not restrict others to do the same. =cut