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

Re: Abort on parse errors



"Bart Schaefer" wrote:
> } Ksh will even abort initialisation scripts if they have a parse error.
> 
> Which this will, too, given `setopt errexit`, right?  I think that's fine,

The reference in the code to noerrexit is a bit confusing: it isn't
directly connected to the errexit option, it just specifies that there
shouldn't be an exit on an error whether the option's set or not.  I
used it because it seemed to give the best way of deciding when to
ignore parse errors.  (I hate being dumped out of initialisation
scripts, emacs does it to me all the time.)

> but perhaps in ksh emulation mode it should behave differently ...

True:  in that case the `!noerrexit' in init.c becomes
(!noerrexit || emulate == EMULATE_KSH)
--- it's not necessary in main.c at least in this case, in fact I'm
not sure if the noerrexit test there is useful.

*** Src/init.c.err2	Wed Jul  1 17:53:25 1998
--- Src/init.c	Thu Jul  2 14:01:21 1998
***************
*** 99,106 ****
  	if (!(list = parse_event())) {	/* if we couldn't parse a list */
  	    hend();
  	    if ((tok == ENDINPUT && !errflag) ||
! 		(tok == LEXERR && !noerrexit &&
! 		 (!isset(SHINSTDIN) || !toplevel)) || justonce)
  		break;
  	    continue;
  	}
--- 99,106 ----
  	if (!(list = parse_event())) {	/* if we couldn't parse a list */
  	    hend();
  	    if ((tok == ENDINPUT && !errflag) ||
! 		(tok == LEXERR && (!noerrexit || emulation == EMULATE_KSH)
! 		 && (!isset(SHINSTDIN) || !toplevel)) || justonce)
  		break;
  	    continue;
  	}

-- 
Peter Stephenson <pws@xxxxxx>       Tel: +39 50 844536
WWW:  http://www.ifh.de/~pws/
Gruppo Teorico, Dipartimento di Fisica
Piazza Torricelli 2, 56100 Pisa, Italy




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