From owner-svn-src-stable@FreeBSD.ORG Fri May 22 04:32:20 2015 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 7768C5E8 for ; Fri, 22 May 2015 04:32:20 +0000 (UTC) Received: from mail-lb0-f180.google.com (mail-lb0-f180.google.com [209.85.217.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 294D816F3 for ; Fri, 22 May 2015 04:32:19 +0000 (UTC) Received: by lbbuc2 with SMTP id uc2so4739670lbb.2 for ; Thu, 21 May 2015 21:32:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=JkVdDLIiAD958ftCtOTUos0kWUXqFzM3uhHWPgos7F0=; b=Caas9knUgPiowfaaTN0zGKUPjTsEhYnKgT/5VCUSU103/WEpl7AyokhXlzc6ckmnBF D9JRcTNzQXE6WNBV7tldDligiZ5tv9J404sa/LaHN47ixyYXMs9mepWHORrOph9O7xu0 wxrSnD2uuBi2bqoMrEL6khwS4P/ieloz4+3aPLz0Kbx3L0gWZsrVmcumnb8genhxO6Sj YFPRz/cxRRN9N/6833ORLRmBCLsCJkUrWQDYYvbV1S1syEUbmB+M+KNmSNQMiKjamUOu Fu7b1Whbf9g2+gcMAAhiujTr4pAOFR+sKMcnLAMryJryhx1KT3jVVvKeVM50MjXaPo58 DjAg== X-Gm-Message-State: ALoCoQm3qe7/l94bd0HGnAhTh7a9i4mpfME7mHHu9pefPctuveRAcV0B65kDNFp0xycM/JSgPw/Z X-Received: by 10.153.6.36 with SMTP id cr4mr4948449lad.56.1432268832124; Thu, 21 May 2015 21:27:12 -0700 (PDT) Received: from [192.168.1.2] ([89.169.173.68]) by mx.google.com with ESMTPSA id kb5sm211229lbc.16.2015.05.21.21.27.10 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 May 2015 21:27:11 -0700 (PDT) Message-ID: <555EB01C.6020805@freebsd.org> Date: Fri, 22 May 2015 07:27:08 +0300 From: Andrey Chernov User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Xin LI , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: Re: svn commit: r283258 - stable/10/bin/date References: <201505211859.t4LIxCFx070119@svn.freebsd.org> In-Reply-To: <201505211859.t4LIxCFx070119@svn.freebsd.org> Content-Type: text/plain; charset=koi8-r Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 May 2015 04:32:20 -0000 On 21.05.2015 21:59, Xin LI wrote: > Author: delphij > Date: Thu May 21 18:59:11 2015 > New Revision: 283258 > URL: https://svnweb.freebsd.org/changeset/base/283258 > > Log: > MFC r282608: > > date(1): Make -r behave like GNU's version when the option can not be > interpreted as a number, which checks the file's modification time and > use that as the date/time value. > > This improves compatibility with GNU coreutils's version of date(1). This is ambiguous. What about, say, file '222'? Doing strtoq() first makes such files not handled and doing stat() first (if the file exists by chance) makes such dates not handled. GNU date always uses -r/--reference for files only. Perhaps it will be better to just add long option --reference for files. > > Modified: > stable/10/bin/date/date.1 > stable/10/bin/date/date.c > Directory Properties: > stable/10/ (props changed) > > Modified: stable/10/bin/date/date.1 > ============================================================================== > --- stable/10/bin/date/date.1 Thu May 21 18:29:36 2015 (r283257) > +++ stable/10/bin/date/date.1 Thu May 21 18:59:11 2015 (r283258) > @@ -32,7 +32,7 @@ > .\" @(#)date.1 8.3 (Berkeley) 4/28/95 > .\" $FreeBSD$ > .\" > -.Dd April 26, 2014 > +.Dd May 7, 2015 > .Dt DATE 1 > .Os > .Sh NAME > @@ -41,7 +41,7 @@ > .Sh SYNOPSIS > .Nm > .Op Fl jRu > -.Op Fl r Ar seconds > +.Op Fl r Ar seconds | Ar filename > .Oo > .Fl v > .Sm off > @@ -150,6 +150,9 @@ is the number of seconds since the Epoch > see > .Xr time 3 ) , > and can be specified in decimal, octal, or hex. > +.It Fl r Ar filename > +Print the date and time of the last modification of > +.Ar filename . > .It Fl t Ar minutes_west > Set the system's value for minutes west of > .Tn GMT . > > Modified: stable/10/bin/date/date.c > ============================================================================== > --- stable/10/bin/date/date.c Thu May 21 18:29:36 2015 (r283257) > +++ stable/10/bin/date/date.c Thu May 21 18:59:11 2015 (r283258) > @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); > > #include > #include > +#include > > #include > #include > @@ -85,6 +86,7 @@ main(int argc, char *argv[]) > struct vary *v; > const struct vary *badv; > struct tm lt; > + struct stat sb; > > v = NULL; > fmt = NULL; > @@ -116,8 +118,12 @@ main(int argc, char *argv[]) > case 'r': /* user specified seconds */ > rflag = 1; > tval = strtoq(optarg, &tmp, 0); > - if (*tmp != 0) > - usage(); > + if (*tmp != 0) { > + if (stat(optarg, &sb) == 0) > + tval = sb.st_mtim.tv_sec; > + else > + usage(); > + } > break; > case 't': /* minutes west of UTC */ > /* error check; don't allow "PST" */ > -- http://ache.vniz.net/