From owner-svn-src-stable-10@FreeBSD.ORG Fri May 22 04:27:20 2015 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id A4BED472 for ; Fri, 22 May 2015 04:27:20 +0000 (UTC) Received: from mail-la0-f41.google.com (mail-la0-f41.google.com [209.85.215.41]) (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 310621629 for ; Fri, 22 May 2015 04:27:19 +0000 (UTC) Received: by laat2 with SMTP id t2so4578312laa.1 for ; Thu, 21 May 2015 21:27:12 -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=HsfoiOqqo0eD2pvJn3DR1WHr92OKeEGQTF4sSoAV7IVTyV2QbLTfNsjdNyIRupkrDA j8AVffSEGB1KefuIMCCFGTIqtTIYuOZnQKeXb3NO+I56sB6l8AK6auhquxRgTYqPRkIX KHEk9TGJqaub2tJmmNXTC3qEX+R0WPeawhez5r4dYiIuS+WtMJv7DjcTHNHaaRaMjxGU tOaqhnJCA0vagHCXAZdtRFnA9nOyRtBZjJGuNF9oIwFgLHEOS2szaWmWVkdpua6fnbAM ULynNws9wMvN5WVkejHJbYNSkS+MI2HW/ypHulmBScvN4p0E5xy714NfylsVKWEG72r5 Kxig== X-Gm-Message-State: ALoCoQn0xt24pdIKQZZODhiVprpTeMECaufu6Sqe8Rg0/ZCPm4tM2Tuev1R/UykYzft8frnebbGT 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-10@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 May 2015 04:27: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/