From 67877f60552019226e93f56b108f7b61a60ea11b Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Wed, 9 Dec 2015 16:40:08 +0000 Subject: 37364: "test" and "[" handling of parentheses. If three arguments, need to prefer binary operators if possible. Need to look for full string for parentheses. --- Src/builtin.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'Src/builtin.c') diff --git a/Src/builtin.c b/Src/builtin.c index cac4f42f9..b06bc6de7 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -6463,7 +6463,13 @@ bin_test(char *name, char **argv, UNUSED(Options ops), int func) nargs = arrlen(argv); if (nargs == 3 || nargs == 4) { - if (*argv[0] == '(' && *argv[nargs-1] == ')') { + /* + * As parentheses are an extension, we need to be careful --- + * if this is a three-argument expression that could + * be a binary operator, prefer that. + */ + if (!strcmp(argv[0], "(") && !strcmp(argv[nargs-1],")") && + (nargs != 3 || !is_cond_binary_op(argv[1]))) { argv[nargs-1] = NULL; argv++; } -- cgit 1.4.1