From owner-cvs-src@FreeBSD.ORG Mon Apr 9 09:48:39 2007 Return-Path: X-Original-To: cvs-src@FreeBSD.org Delivered-To: cvs-src@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E8C6316A402; Mon, 9 Apr 2007 09:48:39 +0000 (UTC) (envelope-from brian@FreeBSD.org) Received: from storm.uk.FreeBSD.org (storm.uk.FreeBSD.org [194.242.157.42]) by mx1.freebsd.org (Postfix) with ESMTP id 5EC8913C484; Mon, 9 Apr 2007 09:48:39 +0000 (UTC) (envelope-from brian@FreeBSD.org) Received: from store.lan.Awfulhak.org (store.lan.Awfulhak.org [172.16.0.35]) by storm.uk.FreeBSD.org (8.13.8/8.13.8) with ESMTP id l399manQ084727; Mon, 9 Apr 2007 10:48:37 +0100 (BST) (envelope-from brian@FreeBSD.org) Received: from store.lan.Awfulhak.org (localhost.localdomain [127.0.0.1]) by localhost (Postfix) with SMTP id 21C441957C6D; Mon, 9 Apr 2007 09:48:44 +0000 (GMT) Received: from gw.Awfulhak.org (gw.lan.Awfulhak.org [172.16.0.1]) by store.lan.Awfulhak.org (Postfix) with ESMTP id B6BD41957C74; Mon, 9 Apr 2007 09:48:37 +0000 (GMT) Received: from dev.lan.Awfulhak.org (brian@dev.lan.Awfulhak.org [172.16.0.5]) by gw.Awfulhak.org (8.13.8/8.13.8) with ESMTP id l399mRRS059076; Mon, 9 Apr 2007 02:48:27 -0700 (PDT) (envelope-from brian@FreeBSD.org) Date: Mon, 9 Apr 2007 02:48:26 -0700 From: Brian Somers To: Greg Lehey Message-ID: <20070409024826.553be564@dev.lan.Awfulhak.org> In-Reply-To: <20070409021942.C150B16A529@hub.freebsd.org> References: <200704090219.l392Jc1f064727@repoman.freebsd.org> <20070409021942.C150B16A529@hub.freebsd.org> X-Mailer: Claws Mail 2.8.1 (GTK+ 2.10.11; i386-portbld-freebsd7.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=0.0 required=5.0 tests=ALL_TRUSTED,SPF_SOFTFAIL autolearn=failed version=3.1.8 X-Spam-Checker-Version: SpamAssassin 3.1.8 (2007-02-13) on gw.lan.Awfulhak.org Cc: cvs-src@FreeBSD.org, src-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src/usr.bin/touch touch.1 touch.c X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Apr 2007 09:48:40 -0000 On Mon, 9 Apr 2007 02:19:42 +0000 (UTC) Greg Lehey wrote: > grog 2007-04-09 02:19:37 UTC > > FreeBSD src repository > > Modified files: > usr.bin/touch touch.1 touch.c > Log: > Add -A flag to adjust existing time stamps. > Print name by which program was started in usage() message. This has got to be one of the strangest commits I've ever seen... see below. > MFC after: 2 weeks > > Revision Changes Path > 1.15 +78 -13 src/usr.bin/touch/touch.1 > 1.22 +52 -10 src/usr.bin/touch/touch.c > _______________________________________________ > cvs-all@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/cvs-all > To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org" > > > Index: src/usr.bin/touch/touch.1 > diff -u src/usr.bin/touch/touch.1:1.14 src/usr.bin/touch/touch.1:1.15 > --- src/usr.bin/touch/touch.1:1.14 Sun Feb 13 22:25:24 2005 > +++ src/usr.bin/touch/touch.1 Mon Apr 9 02:19:37 2007 > @@ -43,6 +43,7 @@ > .Nd change file access and modification times > .Sh SYNOPSIS > .Nm > +.Op Fl A Ar [-][[hh]mm]SS > .Op Fl acfhm > .Op Fl r Ar file > .Op Fl t Ar [[CC]YY]MMDDhhmm[.SS] > @@ -50,17 +51,79 @@ > .Sh DESCRIPTION > The > .Nm > -utility sets the modification and access times of files to the > -current time of day. > -If the file does not exist, it is created with default permissions. > +utility sets the modification and access times of files. > +If any file does not exist, it is created with default permissions. > +.Pp > +By default, > +.Nm > +changes both modification and access times. The > +.Fl a > +and > +.Fl m > +flags may be used to select the access time or the modification time > +individually. > +Selecting both is equivalent to the default. > +The base times for the modification are both set to the current time. > +The > +.Fl t > +flag explicitly specifies a single time for both values, and the > +.Fl r > +flag specifies to set the times from those of a different file. > +The > +.Fl A > +flag adjusts the values by a specified amount. > +This adjustment is done after first establishing the base times. > .Pp > The following options are available: > .Bl -tag -width Ds > +.It Fl A > +Adjust the access and modification time stamps for the file by the > +specified value. > +This flag is intended for use in modifying files with a time stamp > +relative to an incorrect time zone. I don't understand what this means. File times are in UTC aren't they? > +It always modifies both the access time and the modification time. > +.Pp > +The argument is of the form > +.Dq [-][[hh]mm]SS > +where each pair of letters represents the following: > +.Pp > +.Bl -tag -width Ds -compact -offset indent > +.It Ar - > +Make the adjustment negative: the new time stamp is set to be before > +the old one. > +.It Ar hh > +The hour of the day, from 00 to 23. > +.It Ar mm > +The minute of the hour, from 00 to 59. > +.It Ar SS > +The second of the minute, from 00 to 59. > +.El Why this format? My guess is that the delta is expected to be a DST difference, but if it is, I'm even more confused. > +.Pp > +When used in conjunction with the > +.Fl a > +flag only, the modification time is adjusted by the time specified as > +argument to the > +.Fl A > +flag, while the access time is modified from the base time described > +above. Wow. So -A changes both times in addition to the access-only time change. This is really unintuitive to me. I'd expect ``-A 000001 -a' to adjust the access time only (as -a previously meant). I wouldn't expect the modification time to be bumped by a second and the access time to be set to one second in the future. But again, I don't know why you'd want to do this... > +Similarly, when used in conjunction with the > +.Fl m > +flag only, the access time is adjusted by the time specified as > +argument to the > +.Fl A > +flag, while the access time is modified from the base time described > +above. Errum, you mean the modification time? > +.Pp > +If the file does not exist, and creation is allowed, > +.Fl A > +does not change its time stamps. So if I ``touch -A 000001 something'' where ``something'' doesn't already exist, the file is created and the time is left at now? That's also confusing. [.....] > Index: src/usr.bin/touch/touch.c > diff -u src/usr.bin/touch/touch.c:1.21 src/usr.bin/touch/touch.c:1.22 > --- src/usr.bin/touch/touch.c:1.21 Tue Jan 31 02:21:18 2006 > +++ src/usr.bin/touch/touch.c Mon Apr 9 02:19:37 2007 > @@ -62,7 +62,8 @@ > void stime_arg1(char *, struct timeval *); > void stime_arg2(char *, int, struct timeval *); > void stime_file(char *, struct timeval *); > -void usage(void); > +int timeoffset(char *); > +void usage(char *); > > int > main(int argc, char *argv[]) > @@ -71,17 +72,22 @@ > struct timeval tv[2]; > int (*stat_f)(const char *, struct stat *); > int (*utimes_f)(const char *, const struct timeval *); > - int aflag, cflag, fflag, mflag, ch, fd, len, rval, timeset; > + int Aflag, aflag, cflag, fflag, mflag, ch, fd, len, rval, timeset; > char *p; > + char *myname; > > - aflag = cflag = fflag = mflag = timeset = 0; > + myname = argv[0]; myname should be set to the base name, not the full argv[0]. [.....] I personally think this option is a mistake. I would think that something like this would be better: [-A adjust] - adjust the updated time(s) by the given ``adjust'' number of seconds. I would imagine this to be useful in (say) a test script that wanted to set up a bunch of files with time stamps set to specific relative values. But I'm clearly missing the point here...? -- Brian Somers Don't _EVER_ lose your sense of humour !