Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 06 Apr 2007 11:40:53 -0400
From:      Joe Marcus Clarke <marcus@FreeBSD.org>
To:        Dan Nelson <dnelson@allantgroup.com>
Cc:        freebsd-hackers@FreeBSD.org
Subject:   Re: Problem with test(1)
Message-ID:  <1175874053.1627.7.camel@shumai.marcuscom.com>
In-Reply-To: <20070405150806.GD45237@dan.emsphone.com>
References:  <1175757140.67579.50.camel@shumai.marcuscom.com> <20070405150806.GD45237@dan.emsphone.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--=-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--




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1175874053.1627.7.camel>