about summary refs log tree commit diff
path: root/Src/builtin.c
diff options
context:
space:
mode:
Diffstat (limited to 'Src/builtin.c')
-rw-r--r--Src/builtin.c15
1 files changed, 15 insertions, 0 deletions
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;