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

Some bugreports and a fix



Zsh exits from a script if it finds a syntax error while executing an eval
command. Eg. in

eval let '8#8'
echo Right

Right is not printed. This is because eval uses the lexer which changes the
tok global variable. But the main loop examines tok to decide if it has to
exit if errflag is nonzero. To fix this the patch below saves tok before
calling execlist. With my zsh version this bug occured more often as the
lexer is used more often. I discovered this when zsh exited from my
shutdown script leaving the filesystems mounted (I had to do a hard reset).

There is a similar problem which is not fixed by this patch:

% let '8#8' ; echo right

again does not print `right'. That's because execcmd() does not executes
a command if errflag is true.  This particular problem can be fixed by
uncommenting the errflag = 0; assignment in exec.c in execlist but it
probably has unwanted side effects. I really do not know this part of
the code so someone more expert should look at it.

An other bug is that TRAPZERR is not executed in the above cases.

But TRAPZERR is exectued in other cases when it shouldn't: both
% false || foo=bug
and
% if false; then true; else foo=bug; fi
calls TRAPZERR. I think the problem is that a single assignment does not
reset lastval.

Also a bug (or sh incompatibility) is that
% false && true
exits the shell if ERR_EXIT is set. It's a problem since foo && bar is
a common idiom in shell scripts. The general idea is that ERR_EXIT and
TRAPZERR should be ignored for a command whose return value is used to
decide wether to execute something or not.

Zoltan

*** 1.6	1995/05/05 22:01:58
--- Src/init.c	1995/05/28 21:06:06
***************
*** 110,118 ****
--- 110,121 ----
  	    continue;
  	}
  	if (hend()) {
+ 	    int toksav = tok;
+ 
  	    if (stopmsg)	/* unset 'you have stopped jobs' flag */
  		stopmsg--;
  	    execlist(list, 0);
+ 	    tok = toksav;
  	    if (toplevel)
  		noexitct = 0;
  	}



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