summaryrefslogtreecommitdiff
path: root/Src/builtin.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@zsh.org>2015-12-09 16:40:08 +0000
committerPeter Stephenson <pws@zsh.org>2015-12-09 16:40:08 +0000
commit67877f60552019226e93f56b108f7b61a60ea11b (patch)
tree49d506564c9eddecedbe4a8e056098676ad99a96 /Src/builtin.c
parent7f5b2f570961cd9b20f322d7f45318878a1a4b29 (diff)
downloadzsh-67877f60552019226e93f56b108f7b61a60ea11b.tar.gz
zsh-67877f60552019226e93f56b108f7b61a60ea11b.zip
37364: "test" and "[" handling of parentheses.
If three arguments, need to prefer binary operators if possible. Need to look for full string for parentheses.
Diffstat (limited to 'Src/builtin.c')
-rw-r--r--Src/builtin.c8
1 files changed, 7 insertions, 1 deletions
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++;
}