From owner-freebsd-standards@FreeBSD.ORG Fri Sep 10 19:05:45 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 0037F16A4CE for ; Fri, 10 Sep 2004 19:05:44 +0000 (GMT) Received: from rhid.com (rhid.com [200.46.204.134]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7CFD443D4C for ; Fri, 10 Sep 2004 19:05:44 +0000 (GMT) (envelope-from flaw@rhid.com) Received: from [127.0.0.1] (rhid.com [200.46.204.134]) by rhid.com (Postfix) with ESMTP id B2A29F83833 for ; Fri, 10 Sep 2004 20:05:39 +0100 (BST) From: James William Pye To: FreeBSD Standards In-Reply-To: <1094566670.80264.78.camel@localhost> References: <1094566670.80264.78.camel@localhost> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-8zHU2d9nIA4XC0U6zsxo" Organization: rhid development Message-Id: <1094843141.488.69.camel@localhost> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Fri, 10 Sep 2004 12:05:41 -0700 Subject: Re: /bin/test asdf -ge 0 X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Sep 2004 19:05:45 -0000 --=-8zHU2d9nIA4XC0U6zsxo Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Here is the aardvark defect submission that I made: --------------------------------------------------------------- 7. Please describe the problem in the box below: test asdf -ge 0 $((asdf + 1)) What constitutes a number in both of these cases, test(1) and shell arithmetic expansion, does not appear to be specified. This was brought to my attention when I noticed the differing implementations. Firstly, zsh, which will return 0 on the first command, and the arithmetic expansion will expand to 1. As opposed to FreeBSD's--and likely BSDs in general--/bin/sh, which will cause an error to be echoed to stderr and a non-zero result in both cases. At first I contacted the zsh developers, as I assumed this was specified behaviour after checking /bin/sh's and bash's test implementation. This was not the case, and Dan Nelson on the zsh work list responded with examples of other shells that behaved the same way as zsh. (A couple notable examples being GNU's test and pdksh). He also said that he believed this fell into undefined behaviour, and, therefore, zsh was not incorrect. I then contacted the FreeBSD-standards list to try to confirm that this was undefined behaviour. Those who responded believed that this was undefined, and thought that I should at least bring this question to the austin group mailing list. In case you are interested in the threads that led up to this clarification request, here are their URIs: http://www.zsh.org/mla/workers/2004/msg00937.html http://lists.freebsd.org/pipermail/freebsd-standards/2004-September/000673.= html 8. Please describe the desired action to be taken in the box below: Clarification of what constitutes a number in XCU's test(1) and shell arithmetic expansion, and perhaps other related locations. Specifically, a given number should be considered valid if strtol(str, &end, 0) accepts str as a valid number. This would allow the usage of hexadecimal and octal numbers in test and arithmetic expansion, which is likely a feature that would be welcomed by all. (See http://www.opengroup.org/onlinepubs/000095399/functions/strtol.html) In the case of an invalid number, the utility should throw an error and return non-zero, perhaps a standard error code for an invalid numbers should be allocated, if one is not already. An invalid number in arithmetic expansion should cause an error to be thrown before the command is executed, and result in a non-zero value, and perhaps a different value than the former so that a distinction can be made between where the invalid number error occurred--before or during the execution of a command. An important note to make is the contrast between test(1) and expr(1), where expr defines a valid integer, and test does not. =46rom http://www.opengroup.org/onlinepubs/000095399/utilities/expr.html: integer - An argument consisting only of an (optional) unary minus followed by digits. I also recommend that expr(1) be updated to allow hexadecimal and octal numbers in the format that strtol(str, &end, 0) accepts, so as to be consistent with the newly defined behaviour in test(1) and shell arithmetic expansion. (Props to Garrett Wollman on freebsd-standards for the notice of this contrast!) ------------------------------------------------------------------- I hope I wasn't a bit too ambitious with strtol(str, &end, 0).. =3D\ --=20 Regards, James William Pye --=-8zHU2d9nIA4XC0U6zsxo Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (FreeBSD) iQEVAwUAQUH7BaZpiPNPvu8yAQJkkwf7BA2SCU01uAqkvxdCYUEjKkTzksHheOnE /P5BvvyMsQcCychNL9PabRaWClDmvmTDuUteUR8PLPqedYvQoHmYznXMu/PorN92 mpemghJpGJ0Mr8cx0IDJA2sEAW6oNfMpMFsbdRjiPuCTjYmrCXLiOlPual2VFGSR UbWF8EzgjXklCA/BPzPWVoMwWzDLgRe5HxNlFdTUbJvZq/ODsT8qA4PqzrJ+28T0 LY9qa78SpmCxUzC9ArF63DawDhlJyVh/KlkctmB7b54Z8txnLSjidJzHRbRFDEMh 5Q5usz4DjQcN4BxJ1+5K5iFs1f2cUzTtpTDmpt0sooB3YyAvA+YL7w== =Bce6 -----END PGP SIGNATURE----- --=-8zHU2d9nIA4XC0U6zsxo--