From owner-svn-src-head@FreeBSD.ORG Wed Feb 27 08:25:59 2013 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id C66F4EF7; Wed, 27 Feb 2013 08:25:59 +0000 (UTC) (envelope-from peter@rulingia.com) Received: from vps.rulingia.com (host-122-100-2-194.octopus.com.au [122.100.2.194]) by mx1.freebsd.org (Postfix) with ESMTP id 71CB9D3; Wed, 27 Feb 2013 08:25:58 +0000 (UTC) Received: from server.rulingia.com (c220-239-237-213.belrs5.nsw.optusnet.com.au [220.239.237.213]) by vps.rulingia.com (8.14.5/8.14.5) with ESMTP id r1R8Ptnk098994 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 27 Feb 2013 19:25:56 +1100 (EST) (envelope-from peter@rulingia.com) X-Bogosity: Ham, spamicity=0.000000 Received: from server.rulingia.com (localhost.rulingia.com [127.0.0.1]) by server.rulingia.com (8.14.5/8.14.5) with ESMTP id r1R8Pn0I091366 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 27 Feb 2013 19:25:49 +1100 (EST) (envelope-from peter@server.rulingia.com) Received: (from peter@localhost) by server.rulingia.com (8.14.5/8.14.5/Submit) id r1R8Pm8T091365; Wed, 27 Feb 2013 19:25:48 +1100 (EST) (envelope-from peter) Date: Wed, 27 Feb 2013 19:25:48 +1100 From: Peter Jeremy To: Jilles Tjoelker Subject: Re: svn commit: r247274 - in head: bin/test tools/regression/bin/test Message-ID: <20130227082548.GF99210@server.rulingia.com> References: <201302251905.r1PJ5fKF085179@svn.freebsd.org> <20130226000227.GA80718@stack.nl> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="EP0wieDxd4TSJjHq" Content-Disposition: inline In-Reply-To: <20130226000227.GA80718@stack.nl> X-PGP-Key: http://www.rulingia.com/keys/peter.pgp User-Agent: Mutt/1.5.21 (2010-09-15) Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Feb 2013 08:25:59 -0000 --EP0wieDxd4TSJjHq Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2013-Feb-26 01:02:27 +0100, Jilles Tjoelker wrote: >> Enhance test(1) by adding provision to compare any combination of the >> access, birth, change and modify times of two files, instead of only >> being able to compare modify times. The builtin test in sh(1) will >> automagically acquire the same expansion. > >What do you need this for? If it is not needed very often, this test can >be done more portably (older FreeBSD and GNU) as > [ -n "$(find -L FILE1 -prune -newerXY FILE2 2>/dev/null)" ] In my case I needed to compare the ctime on one set of files with the mtime in another set. I had a think about using find(1) and gave it away as too ugly. That expression needs serious thought to understand and about =BD the tokens in the find(1) are to handle special cases - which is a further indication that it isn't ideal. >I have generally been rather reluctant in adding things to sh(1) and >even more so if they are completely new. Someone proposed something >rather similar (except that it added a time string parser -- even more >code) in PR bin/57054 and I rejected it in 2009. Time parsing is a large can of worms - getting it right is messy (that patch includes 1KLOC of new code and still isn't locale aware). And the work-around of touching a dummy file to the wanted age isn't too horrrible. This is a much smaller patch and there's no equally clean work-around. >> +a=3D/tmp/test$$.1 >> +b=3D/tmp/test$$.2 > >Please use mktemp(1). Using $$ for temporary files is insecure on >multiuser systems. In this case, I want filenames that don't exist. I will look at using mktemp(1) to create a temporary directory. >> +sleep 2 # Ensure $b is newer than $a >> +touch $b > >Please use touch -t instead of sleeping. I'm impatient while running >tests :) In this case, I want all the timestamps on $b to be later than $a. I initially tried without the sleep but that failed with the builtin test(1) because the FS timestamps weren't sufficiently granular to report the difference. I could create one of the files much earlier during the test and then use a conditional test to only sleep if the timestamps were indistinguishable (this probably needs to use the above find(1) horror to avoid using test(1) to test itself). I agree the other sleep(1)s should be able to be replaced with touch(1) but I ran into problems with my initial efforts to do everything using touch(1). I will revisit it. --=20 Peter Jeremy --EP0wieDxd4TSJjHq Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (FreeBSD) iEYEARECAAYFAlEtwwwACgkQ/opHv/APuIeFvACeOgfECr+1cchOoV4s8MgvPapO HyYAoJz+idnfLYUcklexj343j62LFYI7 =qmM8 -----END PGP SIGNATURE----- --EP0wieDxd4TSJjHq--