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

Re: zsh-4.2.1: LINENO lost in evals



"Dieter Lambrecht" wrote:
>#! /bin/zsh -x
>emulate -L zsh
>
>print $LINENO
>eval 'print $LINENO'
>
>return
>
> produces the following output:
>
> ./t4.sh
> +./t4.sh:2> emulate -L zsh
> +./t4.sh:4> print 4
> 4
> +./t4.sh:5> eval 'print $LINENO'
> +(eval):1> print 1
> 1
> .
> 
> It seems that LINENO is lost in the eval-statement. Is there any possib=
> ility to retrieve the original value inside evals ?

(There must be a set -x or setopt xtrace lurking somewhere.)

It's not actually lost, it's showing you the line in the eval.  That's
a feature (compare error messages from Perl evals, which is where we
pinched the output format from).

What are you trying to do?  You can record the line number outside if
you need it, e.g.

lineno=LINENO; eval 'print $lineno'

I take it the complaint isn't about the debugging output from xtrace
this time, since that shows the line number of the eval command (5).

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************



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