From owner-freebsd-hackers@FreeBSD.ORG Fri Apr 6 15:41:00 2007 Return-Path: X-Original-To: freebsd-hackers@FreeBSD.org Delivered-To: freebsd-hackers@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 25ED816A401 for ; Fri, 6 Apr 2007 15:41:00 +0000 (UTC) (envelope-from marcus@FreeBSD.org) Received: from creme-brulee.marcuscom.com (creme-brulee.marcuscom.com [24.172.16.118]) by mx1.freebsd.org (Postfix) with ESMTP id C056C13C448 for ; Fri, 6 Apr 2007 15:40:59 +0000 (UTC) (envelope-from marcus@FreeBSD.org) Received: from [192.168.1.4] (shumai.marcuscom.com [192.168.1.4]) by creme-brulee.marcuscom.com (8.13.8/8.13.8) with ESMTP id l36FfJn6055194; Fri, 6 Apr 2007 11:41:19 -0400 (EDT) (envelope-from marcus@FreeBSD.org) From: Joe Marcus Clarke To: Dan Nelson In-Reply-To: <20070405150806.GD45237@dan.emsphone.com> References: <1175757140.67579.50.camel@shumai.marcuscom.com> <20070405150806.GD45237@dan.emsphone.com> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-EEdqIWOBA920PHn7rpX6" Organization: FreeBSD, Inc. Date: Fri, 06 Apr 2007 11:40:53 -0400 Message-Id: <1175874053.1627.7.camel@shumai.marcuscom.com> Mime-Version: 1.0 X-Mailer: Evolution 2.10.0 FreeBSD GNOME Team Port Cc: freebsd-hackers@FreeBSD.org Subject: Re: Problem with test(1) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Apr 2007 15:41:00 -0000 --=-EEdqIWOBA920PHn7rpX6 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Thu, 2007-04-05 at 10:08 -0500, Dan Nelson wrote: > In the last episode (Apr 05), Joe Marcus Clarke said: > > I noticed something weird with test(1) when I ran across a problem port > > Makefile. Our test(1) doesn't properly check to make sure there is an > > operand argument to unary operators like -f. For example: > >=20 > > test -f > >=20 > > Will print "TRUE" on FreeBSD. On Solaris, it will die: > >=20 > > /usr/bin/test[8]: test: argument expected > >=20 > > I think this patch is correct in that it does fix the problem, and the > > TEST.sh and TEST.csh regression scripts report the same results pre and > > post-patch. Comments? >=20 > If you follow POSIX's description of test, FreeBSD's current behaviour > is valid and Solaris isn't: >=20 > http://www.opengroup.org/onlinepubs/009695399/utilities/test.html >=20 > The algorithm for determining the precedence of the operators and the > return value that shall be generated is based on the number of > arguments presented to test. (However, when using the "[...]" form, > the right-bracket final argument shall not be counted in this > algorithm.) >=20 > In the following list, $1, $2, $3, and $4 represent the arguments > presented to test: >=20 > 0 arguments: > Exit false (1). > 1 argument: > Exit true (0) if $1 is not null; otherwise, exit false. > ... >=20 > Unary operators shouldn't get parsed as such unless there are two > arguments. Thanks for the clarification. Solaris' test(1) man page has the same excerpt yet all of their implementations of test(1) require the argument to the operator. This confused me since the man page also claims that their test(1) is compliant with recent Open Group standards. Joe --=20 Joe Marcus Clarke FreeBSD GNOME Team :: gnome@FreeBSD.org FreeNode / #freebsd-gnome http://www.FreeBSD.org/gnome --=-EEdqIWOBA920PHn7rpX6 Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (FreeBSD) iD8DBQBGFmoBb2iPiv4Uz4cRAszmAJ9Y6ZCiTwz7Cc2yh2/b7mqDVz1gfgCghcJc UCEEVWDDgOYW2kFUMvS+AXk= =5KQ+ -----END PGP SIGNATURE----- --=-EEdqIWOBA920PHn7rpX6--