zsh-workers
 help / color / mirror / code / Atom feed
* eval line number weirdness
@ 2008-08-31 23:46 Rocky Bernstein
  2008-09-02 17:28 ` Peter Stephenson
  0 siblings, 1 reply; 3+ messages in thread
From: Rocky Bernstein @ 2008-08-31 23:46 UTC (permalink / raw)
  To: Zsh hackers list

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.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-09-03  3:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-31 23:46 eval line number weirdness Rocky Bernstein
2008-09-02 17:28 ` Peter Stephenson
2008-09-03  3:37   ` Rocky Bernstein

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).