From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18121 invoked from network); 2 Sep 2004 17:09:48 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 2 Sep 2004 17:09:48 -0000 Received: (qmail 22305 invoked from network); 2 Sep 2004 17:09:42 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 2 Sep 2004 17:09:42 -0000 Received: (qmail 377 invoked by alias); 2 Sep 2004 17:07:53 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 20308 Received: (qmail 354 invoked from network); 2 Sep 2004 17:07:53 -0000 Received: from unknown (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 2 Sep 2004 17:07:53 -0000 Received: (qmail 89347 invoked from network); 2 Sep 2004 16:06:54 -0000 Received: from unknown (HELO mailsweeperjp.CSR.COM) (202.214.225.228) by a.mx.sunsite.dk with SMTP; 2 Sep 2004 16:06:52 -0000 Received: from exchangejp.csr.com (unverified) by mailsweeperjp.CSR.COM (Content Technologies SMTPRS 4.3.1) with ESMTP id for ; Fri, 3 Sep 2004 00:58:21 +0900 Received: from EXCHANGE02.csr.com ([192.168.137.45]) by exchangejp.csr.com with Microsoft SMTPSVC(5.0.2195.6713); Thu, 2 Sep 2004 16:54:42 +0100 Received: from news01.csr.com ([192.168.143.38]) by EXCHANGE02.csr.com with Microsoft SMTPSVC(5.0.2195.6713); Thu, 2 Sep 2004 16:54:36 +0100 Received: from news01.csr.com (localhost.localdomain [127.0.0.1]) by news01.csr.com (8.12.11/8.12.11) with ESMTP id i82FrpS7015084 for ; Thu, 2 Sep 2004 16:53:51 +0100 Received: from csr.com (pws@localhost) by news01.csr.com (8.12.11/8.12.11/Submit) with ESMTP id i82FroQw015081 for ; Thu, 2 Sep 2004 16:53:51 +0100 Message-Id: <200409021553.i82FroQw015081@news01.csr.com> X-Authentication-Warning: news01.csr.com: pws owned process doing -bs To: zsh-workers@sunsite.dk Subject: Re: zsh-4.2.1: LINENO lost in evals In-reply-to: ""Dieter Lambrecht""'s message of "Thu, 02 Sep 2004 15:57:10 +0200." Date: Thu, 02 Sep 2004 16:53:50 +0100 From: Peter Stephenson X-OriginalArrivalTime: 02 Sep 2004 15:54:36.0468 (UTC) FILETIME=[25962F40:01C49105] X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, hits=0.0 required=6.0 tests=none autolearn=no version=2.63 X-Spam-Hits: 0.0 "Dieter Lambrecht" wrote: > The behaviour of zsh is incompatible to ksh, even though in "emulate > ksh"-mode. Is this the real problem? I asked what this was being used for but didn't get an answer. It's easy to introduce an option, but I don't know how useful it is. Index: Doc/Zsh/options.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/options.yo,v retrieving revision 1.34 diff -u -r1.34 options.yo --- Doc/Zsh/options.yo 16 Aug 2004 09:53:10 -0000 1.34 +++ Doc/Zsh/options.yo 2 Sep 2004 15:52:22 -0000 @@ -929,7 +929,7 @@ ) pindex(ERR_RETURN) cindex(function return, on error) -cidnex(return from function, on error) +cindex(return from function, on error) item(tt(ERR_RETURN))( If a command has a non-zero exit status, return immediately from the enclosing function. The logic is identical to that for tt(ERR_EXIT), @@ -937,6 +937,19 @@ tt(exit). This will trigger an exit at the outermost level of a non-interactive script. ) +pindex(EVAL_LINENO) +cindex(line number, in evaluated expression) +item(tt(EVAL_LINENO) )( +If set, line numbers of expressions evaluated using the builtin tt(eval) +are tracked separately of the enclosing environment. This applies both +to the parameter tt(LINENO) and the line number output by the prompt +escape tt(%i). If the option is set, the prompt escape tt(%N) will output +the string `tt((eval))' instead of the script or function name as an +indication. (The two prompt escapes are typically used in the parameter +tt(PS4) to be output when the option tt(XTRACE) is set.) If +tt(EVAL_LINENO) is unset, the line number of the surrounding script or +function is retained during the evaluation. +) pindex(EXEC) cindex(command execution, enabling) item(tt(EXEC) (tt(PLUS()n), ksh: tt(PLUS()n)) )( Index: Src/builtin.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v retrieving revision 1.122 diff -u -r1.122 builtin.c --- Src/builtin.c 7 Jul 2004 15:00:57 -0000 1.122 +++ Src/builtin.c 2 Sep 2004 15:52:25 -0000 @@ -4220,27 +4220,42 @@ /* eval: simple evaluation */ /**/ +int ineval; + +/**/ int bin_eval(UNUSED(char *nam), char **argv, UNUSED(Options ops), UNUSED(int func)) { Eprog prog; char *oscriptname = scriptname; - - scriptname = "(eval)"; + int oineval = ineval; + /* + * If EVALLINENO is not set, we use the line number of the + * environment and must flag this up to exec.c. Otherwise, + * we use a special script name to indicate the special line number. + */ + ineval = !isset(EVALLINENO); prog = parse_string(zjoin(argv, ' ', 1)); if (!prog) { errflag = 0; return 1; } + lastval = 0; + if (!ineval) + scriptname = "(eval)"; + execode(prog, 1, 0); + if (errflag) { lastval = errflag; errflag = 0; } - scriptname = oscriptname; + if (!ineval) + scriptname = oscriptname; + ineval = oineval; return lastval; } Index: Src/exec.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/exec.c,v retrieving revision 1.69 diff -u -r1.69 exec.c --- Src/exec.c 29 Jul 2004 15:09:51 -0000 1.69 +++ Src/exec.c 2 Sep 2004 15:52:27 -0000 @@ -788,7 +788,7 @@ return (lastval = 1); /* In evaluated traps, don't modify the line number. */ - if ((!intrap || trapisfunc) && code) + if ((!intrap || trapisfunc) && !ineval && code) lineno = code - 1; code = wc_code(*state->pc++); @@ -1260,7 +1260,7 @@ return; /* In evaluated traps, don't modify the line number. */ - if ((!intrap || trapisfunc) && WC_PIPE_LINENO(pcode)) + if ((!intrap || trapisfunc) && !ineval && WC_PIPE_LINENO(pcode)) lineno = WC_PIPE_LINENO(pcode) - 1; if (pline_level == 1) { Index: Src/options.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/options.c,v retrieving revision 1.20 diff -u -r1.20 options.c --- Src/options.c 2 Jun 2004 22:14:26 -0000 1.20 +++ Src/options.c 2 Sep 2004 15:52:27 -0000 @@ -115,6 +115,7 @@ {NULL, "exec", OPT_ALL, EXECOPT}, {NULL, "extendedglob", OPT_EMULATE, EXTENDEDGLOB}, {NULL, "extendedhistory", OPT_CSH, EXTENDEDHISTORY}, +{NULL, "evallineno", OPT_EMULATE|OPT_ZSH, EVALLINENO}, {NULL, "flowcontrol", OPT_ALL, FLOWCONTROL}, {NULL, "functionargzero", OPT_EMULATE|OPT_NONBOURNE, FUNCTIONARGZERO}, {NULL, "glob", OPT_EMULATE|OPT_ALL, GLOBOPT}, Index: Src/zsh.h =================================================================== RCS file: /cvsroot/zsh/zsh/Src/zsh.h,v retrieving revision 1.58 diff -u -r1.58 zsh.h --- Src/zsh.h 11 Jul 2004 22:53:03 -0000 1.58 +++ Src/zsh.h 2 Sep 2004 15:52:28 -0000 @@ -1445,6 +1445,7 @@ EXECOPT, EXTENDEDGLOB, EXTENDEDHISTORY, + EVALLINENO, FLOWCONTROL, FUNCTIONARGZERO, GLOBOPT, -- Peter Stephenson Software Engineer CSR Ltd., Science Park, Milton Road, Cambridge, CB4 0WH, UK Tel: +44 (0)1223 692070 ********************************************************************** The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer. **********************************************************************