From owner-freebsd-stable Thu Dec 23 16:35:30 1999 Delivered-To: freebsd-stable@freebsd.org Received: from axl.noc.iafrica.com (axl.noc.iafrica.com [196.31.1.175]) by hub.freebsd.org (Postfix) with ESMTP id 66C8D14BD2 for ; Thu, 23 Dec 1999 16:35:26 -0800 (PST) (envelope-from sheldonh@axl.noc.iafrica.com) Received: from sheldonh (helo=axl.noc.iafrica.com) by axl.noc.iafrica.com with local-esmtp (Exim 3.11 #1) id 121Ij4-000GWQ-00; Fri, 24 Dec 1999 02:36:58 +0200 From: Sheldon Hearn To: David Wolfskill Cc: Peter Jeremy , freebsd-stable@FreeBSD.ORG Subject: Re: /bin/test broken ? In-reply-to: Your message of "Fri, 24 Dec 1999 11:05:35 +1100." <99Dec24.105638est.40325@border.alcanet.com.au> Date: Fri, 24 Dec 1999 02:36:58 +0200 Message-ID: <63513.945995818@axl.noc.iafrica.com> Sender: owner-freebsd-stable@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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