From owner-freebsd-standards@FreeBSD.ORG Tue Sep 7 14:46:30 2004 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6A17616A4CF for ; Tue, 7 Sep 2004 14:46:30 +0000 (GMT) Received: from n33.kp.t-systems-sfr.com (n33.kp.t-systems-sfr.com [129.247.16.33]) by mx1.FreeBSD.org (Postfix) with ESMTP id 65A4443D49 for ; Tue, 7 Sep 2004 14:46:29 +0000 (GMT) (envelope-from harti@freebsd.org) Received: from n81.sp.op.dlr.de (n81g.sp.op.dlr.de [129.247.163.1]) i87EkO2605928; Tue, 7 Sep 2004 16:46:24 +0200 Received: from zeus.nt.op.dlr.de (zeus.nt.op.dlr.de [129.247.173.3]) i87EkNI51684; Tue, 7 Sep 2004 16:46:23 +0200 Received: from beagle.kn.op.dlr.de (opkndnwsbsd178 [129.247.173.178]) by zeus.nt.op.dlr.de (8.11.7+Sun/8.9.1) with ESMTP id i87EkCe12398; Tue, 7 Sep 2004 16:46:23 +0200 (MET DST) Date: Tue, 7 Sep 2004 16:46:14 +0200 (CEST) From: Harti Brandt X-X-Sender: brandt@beagle.kn.op.dlr.de To: James William Pye In-Reply-To: <1094566670.80264.78.camel@localhost> Message-ID: <20040907163809.M20166@beagle.kn.op.dlr.de> References: <1094566670.80264.78.camel@localhost> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: Dan Nelson cc: FreeBSD Standards Subject: Re: /bin/test asdf -ge 0 X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Harti Brandt List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Sep 2004 14:46:30 -0000 On Tue, 7 Sep 2004, James William Pye wrote: JWP>FreeBSD's test--and likely BSD's in general--use strtol to parse number JWP>strings to catch errors. Other shells and test implementations do not. JWP>zsh, pdksh, and, allegedly, GNU's test being notable implementations JWP>that more than likely use atoi, which just renders 0 for strings that JWP>don't make sense to it. JWP>That is, test asdf -ge 0 succeeds in some shells, and fails in others. JWP> JWP>I am curious if anyone knows if this behavior conforms to a JWP>specification. Personally, I find FreeBSD's behavior "correct", so I JWP>find the implementation differences disturbing. If it is conforming to a JWP>specification, I think it would be possible to convince some developers JWP>to change their implementations, which would be a good thing(tm). JWP> JWP>I first noticed this when zsh did not give me an error on test asdf -ge JWP>0. I contacted the zsh developers about the apparent behavioral error, JWP>and Dan Nelson responded with examples of other shells that do the same JWP>thing("/bin/sh on Tru64 5.1, AIX 5.2, and Solaris 9 all succeed."). (I JWP>sent in my report after checking only /bin/sh and bash. =\) JWP> JWP>In short, does anyone know if this behavior conforms to a specification JWP>or does it fall into the range of "undefined behavior" that Dan figured JWP>it is in? (I'm betting on what Dan figured, but I wanted to check with JWP>standards to see if anyone else could confirm it). JWP> JWP>test(1) says it "implements a superset of the IEEE Std 1003.2", which JWP>I'm not sure if that's the same thing as or part of what's accessible at JWP>unix.org. I just checked the TC1 of Posix and it doesn't say anything in the description of test about this. Also the 'utility argument syntax' section talks only about range errors of numeric operands in point 6. So the behaviour seems to be unspecified. It's not clear whether this is an oversight or intended. I would recommend you to send a mail to the Austin Group with this question (probably austin-group-l@opengroup.org). harti