Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 27 Dec 1999 11:22:14 +1100
From:      Peter Jeremy <peter.jeremy@alcatel.com.au>
To:        Vlad Skvortsov <vss@ulstu.ru>
Cc:        freebsd-stable@FreeBSD.ORG, sheldonh@FreeBSD.ORG
Subject:   Re: /bin/test broken ?
Message-ID:  <99Dec27.111307est.40321@border.alcanet.com.au>
In-Reply-To: <19991226013551.A43483@ulstu.ru>; from vss@ulstu.ru on Sun, Dec 26, 1999 at 09:35:52AM %2B1100
References:  <99Dec23.123516est.40332@border.alcanet.com.au> <199912232030.MAA65714@pau-amma.whistle.com> <99Dec24.105638est.40325@border.alcanet.com.au> <19991226013551.A43483@ulstu.ru>

next in thread | previous in thread | raw e-mail | index | archive | help
On 1999-Dec-26 09:35:52 +1100, Vlad Skvortsov <vss@ulstu.ru> wrote:
>Subject: Cron <vlad@hq> /bin/[ -f /var/run/INET ] && /usr/local/bin/fetchmail
>[: ]: unexpected operator
>
>It _did_ work before.

Note that your original post was:
>	$ /bin/test 1 -ne 0 ]
>	[: ]: unexpected operator

Although it seems your real problem is:
>	$ /bin/[ 1 -ne 0 ]
>	[: ]: unexpected operator

This does make a lot more sense, and would have saved a lot of
fruitless searching for a non-existent problem.  (It is also why
I enquired exactly what you thought was wrong, since your posted
output didn't make sense).

> I put your attention that you'd try using /bin/[,

Note that this is the first time that you've mentioned that your
problem is in /bin/[, not /bin/test (yes, they are hard-links,
but they have different syntaxes).

Given that piece of information, the problem is more obvious:
The following code was changed near the top of main() in test.c
between 1.20.2.3 and 1.20.2.4 (the tabs have been expanded):

-       if ((p = argv[0]) == NULL)
-               errx(2, "test: argc is zero");
-
-       if (*p != '\0' && p[strlen(p) - 1] == '[') {
+       if (strcmp(argv[0], "[") == 0) {
                if (strcmp(argv[--argc], "]"))

The new code is incorrect because argv[0] is a pathname, not just
a filename.  The same problem exists in -current (so I'm surprised
no-one else has been bitten).

I believe the correst test is something like:

	char	*p;
	if ((p = strrchr(argv[0], '/')) != NULL)
		p++;
	else
		p = argv[0];

	if (strcmp(p, "[") == 0) {
		if (strcmp(argv[--argc], "]"))
 

> Judjed by my logs the last change to /bin/test was on Dec, 16 or
>somewhere about.
By Sheldon, so I've copied him.

Peter


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-stable" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?99Dec27.111307est.40321>