From 64c85ae68ab10392ecc6ef6a7a55c48e11ddb58f Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Wed, 12 Dec 2007 18:43:28 +0000 Subject: users/12325: implement OSI rules for test & [, add more doc warnings --- Src/builtin.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'Src/builtin.c') diff --git a/Src/builtin.c b/Src/builtin.c index 2e0d249f3..7bd4c6d83 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -5506,6 +5506,7 @@ bin_test(char *name, char **argv, UNUSED(Options ops), int func) char **s; Eprog prog; struct estate state; + int nargs; /* if "test" was invoked as "[", it needs a matching "]" * * which is subsequently ignored */ @@ -5521,6 +5522,20 @@ bin_test(char *name, char **argv, UNUSED(Options ops), int func) if (!*argv) return 1; + /* + * Implement some XSI extensions to POSIX here. + * See + * http://www.opengroup.org/onlinepubs/009695399/utilities/test.html. + */ + nargs = arrlen(argv); + if (nargs == 3 || nargs == 4) + { + if (*argv[0] == '(' && *argv[nargs-1] == ')') { + argv[nargs-1] = NULL; + argv++; + } + } + testargs = argv; tok = NULLTOK; condlex = testlex; -- cgit 1.4.1