zsh-workers
 help / color / mirror / code / Atom feed
From: "Rocky Bernstein" <rocky.bernstein@gmail.com>
To: "Zsh hackers list" <zsh-workers@sunsite.dk>
Subject: eval line number weirdness
Date: Sun, 31 Aug 2008 19:46:14 -0400	[thread overview]
Message-ID: <6cd6de210808311646r6c065d71n3e04a9851d3158a8@mail.gmail.com> (raw)

I think that the line numbers reported in eval statements are bit hard
to explain. Consider this program

  debug_hook() { print $funcfiletrace[1] $functrace[1]; }
  set -o DEBUG_BEFORE_CMD
  trap "debug_hook" DEBUG
  fn() {
    a=1
    eval "b=2"
    c=3
  }
  fn
  w=5
  eval "x=6
  y=7"
  z=8

which reports:

  linebug3.sh:4 linebug3.sh:4
  linebug3.sh:9 linebug3.sh:9
  linebug3.sh:5 fn:1
  linebug3.sh:6 fn:2
  linebug3.sh:5 fn:1  # Should be linebug3.sh:6 eval:1 ?
  linebug3.sh:7 fn:3
  linebug3.sh:10 linebug3.sh:10
  linebug3.sh:11 linebug3.sh:11
  linebug3.sh:1 linebug3.sh:1  # Should be linebug3.sh:11 eval:1 ?
  linebug3.sh:2 linebug3.sh:2  # Should be linebug3.sh:12 eval:2 ?
  linebug3.sh:13 linebug3.sh:13

The problem is in describing exactly what is reported when eval gets
run and having that mean something meaningful.

With funcfiletrace, an absolute line number in a file name is I think
supposed to be reported. So the 1 and 2 listed above (which is
relative to the line number eval sees) doesn't seem right.

And while for functrace it is okay to report line 1 and 2, the
function name isn't right -- it should be eval than either fn or
linebug3.sh. If functrace is supposed to report the line offset of the
thing it is in (which seems dubious to me), then the above information
isn't right. Instead of fn:1 we would get instead fn:2 since the eval
is on the second line of fn; And presumably instead of linebug:1 one
would see linebug:11.


             reply	other threads:[~2008-09-01  1:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-31 23:46 Rocky Bernstein [this message]
2008-09-02 17:28 ` Peter Stephenson
2008-09-03  3:37   ` Rocky Bernstein

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6cd6de210808311646r6c065d71n3e04a9851d3158a8@mail.gmail.com \
    --to=rocky.bernstein@gmail.com \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).