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

eval line number weirdness



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.



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