Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: zsh syntax check fails on correct if [[ usage (rhbz 966911)



On Fri, 18 Oct 2013 08:48:31 -0700
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Oct 18,  4:02pm, Filip Krska wrote:
> }
> } zsh syntax check fails on simple script, which is syntactically OK, but zsh -n returns 1
> 
> Hmm, it's not actually the syntax check which is failing.
> 
> If you run the test as
> 
>     zsh -vxn /tmp/test.zsh
> 
> it becomes clear that zsh is actually executing some of the commands,
> and then returning the exit status of those commands rather than of
> the syntax check itself.
> 
> Which is strange, particularly given that adding the ":" command in
> the if-block causes it to revert to executing nothing.  (Changing
> the $(...) construct is a red herring, it's just changing the exit
> status of the line zsh is wrongly executing in the first place.)

Looked at from this point of view, the fix is probably not to execute
code optimised as "simple".

diff --git a/Src/exec.c b/Src/exec.c
index 8efbbd4..e95cad3 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -1087,6 +1087,9 @@ execsimple(Estate state)
     if (errflag)
 	return (lastval = 1);
 
+    if (!isset(EXECOPT))
+	return lastval = 0;
+
     /* In evaluated traps, don't modify the line number. */
     if (!IN_EVAL_TRAP() && !ineval && code)
 	lineno = code - 1;

-- 
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/



Messages sorted by: Reverse Date, Date, Thread, Author