summary refs log tree commit diff
diff options
context:
space:
mode:
authorBarton E. Schaefer <schaefer@zsh.org>2015-12-31 12:41:50 -0800
committerBarton E. Schaefer <schaefer@zsh.org>2015-12-31 12:41:50 -0800
commit0504dafa6e20491565ee774c33a5f7bca5dd62fa (patch)
treef9e145aa7b7c946e6105c44911bc83c29defc3f6
parent15b73ea99b7e156dc9281d89a68fea8fae76706b (diff)
downloadzsh-0504dafa6e20491565ee774c33a5f7bca5dd62fa.tar.gz
zsh-0504dafa6e20491565ee774c33a5f7bca5dd62fa.tar.xz
zsh-0504dafa6e20491565ee774c33a5f7bca5dd62fa.zip
37468: allow line breaks in more places in [[ ... ]]
-rw-r--r--ChangeLog2
-rw-r--r--Src/parse.c20
2 files changed, 14 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index eaf4f080a..78555b5e1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2015-12-31  Barton E. Schaefer  <schaefer@zsh.org>
 
+	* 37468: Src/parse.c: allow line breaks in more places in [[ ... ]]
+
 	* 37467: Doc/Zsh/builtins.yo, Src/builtin.c, Test/B03print.ztst:
 	add "print -v var" / "printf -v var"
 
diff --git a/Src/parse.c b/Src/parse.c
index 83ba396b0..6949b1349 100644
--- a/Src/parse.c
+++ b/Src/parse.c
@@ -2348,7 +2348,9 @@ par_cond_2(void)
 	 * We fall through here on any non-numeric infix operator
 	 * or any other time there are at least two arguments.
 	 */
-    }
+    } else
+	while (tok == SEPER)
+	    condlex();
     if (tok == BANG) {
 	/*
 	 * In "test" compatibility mode, "! -a ..." and "! -o ..."
@@ -2385,7 +2387,7 @@ par_cond_2(void)
 	/* Check first argument for [[ STRING ]] re-interpretation */
 	if (s1 /* tok != DOUTBRACK && tok != DAMPER && tok != DBAR */
 	    && tok != LEXERR && (!dble || n_testargs)) {
-	    condlex();
+	    do condlex(); while (tok == SEPER && condlex != testlex);
 	    return par_cond_double(dupstring("-n"), s1);
 	} else
 	    YYERROR(ecused);
@@ -2398,14 +2400,16 @@ par_cond_2(void)
 	 * checked it does have a string representation).
 	 */
 	tok = STRING;
-    }
+    } else
+	while (tok == SEPER && condlex != testlex)
+	    condlex();
     if (tok == INANG || tok == OUTANG) {
 	enum lextok xtok = tok;
-	condlex();
+	do condlex(); while (tok == SEPER && condlex != testlex);
 	if (tok != STRING)
 	    YYERROR(ecused);
 	s3 = tokstr;
-	condlex();
+	do condlex(); while (tok == SEPER && condlex != testlex);
 	ecadd(WCB_COND((xtok == INANG ? COND_STRLT : COND_STRGTR), 0));
 	ecstr(s1);
 	ecstr(s3);
@@ -2428,11 +2432,11 @@ par_cond_2(void)
     if (!n_testargs)
 	dble = (s2 && *s2 == '-' && !s2[2]);
     incond++;			/* parentheses do globbing */
-    condlex();
+    do condlex(); while (tok == SEPER && condlex != testlex);
     incond--;			/* parentheses do grouping */
     if (tok == STRING && !dble) {
 	s3 = tokstr;
-	condlex();
+	do condlex(); while (tok == SEPER && condlex != testlex);
 	if (tok == STRING) {
 	    LinkList l = newlinklist();
 
@@ -2441,7 +2445,7 @@ par_cond_2(void)
 
 	    while (tok == STRING) {
 		addlinknode(l, tokstr);
-		condlex();
+		do condlex(); while (tok == SEPER && condlex != testlex);
 	    }
 	    return par_cond_multi(s1, l);
 	} else