Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 24 Dec 1999 02:36:58 +0200
From:      Sheldon Hearn <sheldonh@uunet.co.za>
To:        David Wolfskill <dhw@whistle.com>
Cc:        Peter Jeremy <peter.jeremy@alcatel.com.au>, freebsd-stable@FreeBSD.ORG
Subject:   Re: /bin/test broken ? 
Message-ID:  <63513.945995818@axl.noc.iafrica.com>
In-Reply-To: Your message of "Fri, 24 Dec 1999 11:05:35 %2B1100." <99Dec24.105638est.40325@border.alcanet.com.au> 

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


On Fri, 24 Dec 1999 11:05:35 +1100, Peter Jeremy wrote:

> test(1) includes a check near the beginning to see it it was invoked as
> `[' and if it was it checks to see that the last argument is `]' and
> deletes it if it was.  In both cases, the remaining arguments are then
> passed to the expression evaluator.

The patch below teaches test to ignore a trailing ] when called as [.  I
am against such a change in FreeBSD, since the change is neither
required by POSIX nor safe (consider the case where the last operand on
the command line is "]").

Still, if you must have FreeBSD copy the stupidity of another platform,
this'll do the trick.

Ciao,
Sheldon.

Index: test.c
===================================================================
RCS file: /home/ncvs/src/bin/test/test.c,v
retrieving revision 1.28
diff -u -d -r1.28 test.c
--- test.c	1999/08/27 23:15:48	1.28
+++ test.c	1999/12/24 00:33:43
@@ -168,7 +168,8 @@
 		if (strcmp(argv[--argc], "]"))
 			errx(2, "missing ]");
 		argv[argc] = NULL;
-	}
+	} else if (strcmp(argv[argc - 1], "]") == 0)
+		argv[--argc] = NULL;
 
 	/* XXX work around the absence of an eaccess(2) syscall */
 	(void)setgid(getegid());


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?63513.945995818>