Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
line number reporting weirdnesses
- X-seq: zsh-workers 25560
- From: "Rocky Bernstein" <rocky.bernstein@xxxxxxxxx>
- To: "Zsh hackers list" <zsh-workers@xxxxxxxxxx>
- Subject: line number reporting weirdnesses
- Date: Sat, 30 Aug 2008 10:49:03 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:mime-version:content-type:content-transfer-encoding :content-disposition; bh=l5ecVHeLO9YglVwB8u6flyVmzhaODO5JA9gwWfMaFdk=; b=pKMAm12meoiqyRYh6iHMgkFumTRBIvPg2PKr/nfuJXBu2lo0+awOR52wUYlmf8rZEn 9j0ZcR8u3I2eQOF5hRcc/Fs93BuNF+cYV0th4KMkYGUZElZ4FwfH2QpD6X9kAaRM0xVI kb+nbFjOKPjShP9qofbxEfIKlFFyMLTgbRZuM=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type :content-transfer-encoding:content-disposition; b=cQAIVo72T/qX+itTNZxhz+fq5wYp8ATr9YunObcJEwNc/Xf7/yI7M9w63DWObqgiEP Nbgb8+vj7Q6pwa/W2stfcwZI09CjmivOmiluGqzGOkN60fuFOVcKx/JqJt2NZNylHBCd n12D4m7dnWG0TwkM6zIftOAyM5Lyq4N8GZYvg=
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
Some of odd the behavior I've noticed in how line numbers gets set (as
reported by funcfiletrace in trap DEBUG).
Consider this program:
#!/usr/local/bin/zsh -f
debug_hook() { print '====' ; print $funcfiletrace[-1]; }
set -o DEBUG_BEFORE_CMD
trap "debug_hook" DEBUG
if [[ "$TERM" != bogus ]]; then # line 5
[[ -z "$terminfo[kdch1]" ]] || bindkey -M emacs "$terminfo[kdch1]" delete-char
[[ -z "$terminfo[khome]" ]] || bindkey -M emacs "$terminfo[khome]"
beginning-of-line
[[ -z "$terminfo[kend]" ]] || bindkey -M emacs "$terminfo[kend]" end-of-line
fi
x='
line 11
line 12
line 13'
echo line 14
The output I get is:
====
./linebug2.sh:5
====
./linebug2.sh:5
====
./linebug2.sh:3920
====
./linebug2.sh:3920
====
./linebug2.sh:3920
====
./linebug2.sh:13
====
./linebug2.sh:14
line 14
There are two effects I think shown above.
First, the lines numbers of with [[ ]] inside if [[ ]] are weird -
there is no line 3920.
Second the line number in an assignment statement is basically the
line of the string token which spans several lines. Possibly it might
be more helpful to give the line number of the LHS token.
What tends to happen say in a debugger is that someone will try to set
a breakpoint on one of the line numbers that most people would
associate with the weird line numbers (i.e. lines 6-8 or 10 above) and
lacking a way to report which line numbers are possible stopping
points as reported in funcfiletrace, people will get surprised when
none of those lines don't get reported or stopped at.
But of course the surprise is not limited to a debugger. Tools which
track code coverage, or tools to time scripts or just a program where
there is an error will also exhibit the weirdness.
(Ruby has this interesting feature too. No doubt it's an artifact of
LINENO getting set through a global variable tracking the the position
of the character previously read.)
- - -
Recently added to zshdb was the ability to "next" or step over
functions. It is possible way down the line stepping over functions
may be slow because there is tracing overhead inside a function. If
that's the case, more support in zsh might be warranted. Beforehand
though it's probably premature optimization which Knuth says is the
root of evil.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author