about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2009-07-06 20:44:28 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2009-07-06 20:44:28 +0000
commitc6a3ccc8d725a1729131a328848ad5c509b821e5 (patch)
treeb447b4df2c081563d5fcaffe9e7afdb953d0c456
parent0cc033db7cddafebab6ec99e6aee464f816de393 (diff)
downloadzsh-c6a3ccc8d725a1729131a328848ad5c509b821e5.tar.gz
zsh-c6a3ccc8d725a1729131a328848ad5c509b821e5.tar.xz
zsh-c6a3ccc8d725a1729131a328848ad5c509b821e5.zip
27092: missing then-clause for if wasn't an error
-rw-r--r--ChangeLog8
-rw-r--r--Src/parse.c4
-rw-r--r--Test/A01grammar.ztst7
3 files changed, 17 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 6a8c06afc..fb30a1b91 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-07-06  Peter Stephenson  <p.w.stephenson@ntlworld.com>
+
+	* 27092: Src/parse.c, Test/A01grammar.ztst: "if" didn't check
+	for missing clauses so a missing then-clause wasn't spotted
+	as an error.
+
 2009-07-05  Peter Stephenson  <p.w.stephenson@ntlworld.com>
 
 	* Brendan Cully: 27088: Completion/Unix/Command/_hg,
@@ -11904,5 +11910,5 @@
 
 *****************************************************
 * This is used by the shell to define $ZSH_PATCHLEVEL
-* $Revision: 1.4727 $
+* $Revision: 1.4728 $
 *****************************************************
diff --git a/Src/parse.c b/Src/parse.c
index f0a66ea12..89ef68688 100644
--- a/Src/parse.c
+++ b/Src/parse.c
@@ -1199,6 +1199,10 @@ par_if(int *complex)
 	type = (xtok == IF ? WC_IF_IF : WC_IF_ELIF);
 	par_save_list(complex);
 	incmdpos = 1;
+	if (tok == ENDINPUT) {
+	    cmdpop();
+	    YYERRORV(oecused);
+	}
 	while (tok == SEPER)
 	    zshlex();
 	xtok = FI;
diff --git a/Test/A01grammar.ztst b/Test/A01grammar.ztst
index 8f4ed2c19..e976c8356 100644
--- a/Test/A01grammar.ztst
+++ b/Test/A01grammar.ztst
@@ -378,10 +378,15 @@
 >true-2
 >false
 
-  if true; print true
+  if { true } print true
+  if { false } print false
 0:Short form of `if'
 >true
 
+  eval "if"
+1:Short form of `if' can't be too short
+?(eval):1: parse error near `if'
+
   for name ( word1 word2 word3 ) print $name
 0:Form of `for' with parentheses.
 >word1