* skipping assignment and function statements; Interactive comments
@ 2008-08-23 4:15 Rocky Bernstein
2008-08-25 17:22 ` Peter Stephenson
0 siblings, 1 reply; 3+ messages in thread
From: Rocky Bernstein @ 2008-08-23 4:15 UTC (permalink / raw)
To: Zsh hackers list
I just added a skip command to zshdb (and committed to github), but it
seems that assignment statements and function definitions are not
really skipped.
Consider this example which is slightly modified from the regession
test that was put in when it was implimented:
setopt localtraps localoptions debugbeforecmd
trap '(( LINENO == 4 )) && setopt errexit' DEBUG
x=three
x=four # Statement is supposed to be skipped
print $LINENO five
print x is $x
The output I get is:
5 five
x is four
And if the statement were a function definition, e.g.
x() { return 4; }
I think x would get defined as a funciton
- - -
In tracking something else down I read this in zshoptions under
INTERACTIVE_COMMENTS:
"Allow comments even in interactive shells".
I find this phrasing a little weird as it It seems to imply that one
never would want to write a comments, but sometimes one has to break
down and do it in an interactive shell. :-)
Perhaps the word "even" should be removed.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: skipping assignment and function statements; Interactive comments
2008-08-23 4:15 skipping assignment and function statements; Interactive comments Rocky Bernstein
@ 2008-08-25 17:22 ` Peter Stephenson
2008-08-26 2:59 ` Rocky Bernstein
0 siblings, 1 reply; 3+ messages in thread
From: Peter Stephenson @ 2008-08-25 17:22 UTC (permalink / raw)
To: Zsh hackers list
On Sat, 23 Aug 2008 00:15:31 -0400
"Rocky Bernstein" <rocky.bernstein@gmail.com> wrote:
> I just added a skip command to zshdb (and committed to github), but it
> seems that assignment statements and function definitions are not
> really skipped.
Yes, thanks, there's yet another infuriating special case of the sort
that makes me wish I'd picked an easier project.
That's the third change here; the stuff with intrap is because it
doesn't detect that it's already inside a trap (and hence should skip
debugging) until it gets into dotrapargs(), and in this case it seems
neater not to go to the trouble. This will be even more sensible when I
get around to regenerating the line to be debugged at this point.
Index: Src/exec.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/exec.c,v
retrieving revision 1.141
diff -u -r1.141 exec.c
--- Src/exec.c 22 Aug 2008 15:41:31 -0000 1.141
+++ Src/exec.c 25 Aug 2008 17:21:19 -0000
@@ -1068,7 +1068,7 @@
lineno = lnp1 - 1;
}
- if (sigtrapped[SIGDEBUG] && isset(DEBUGBEFORECMD)) {
+ if (sigtrapped[SIGDEBUG] && isset(DEBUGBEFORECMD) && !intrap) {
int oerrexit_opt = opts[ERREXIT];
opts[ERREXIT] = 0;
noerrexit = 1;
@@ -1086,11 +1086,12 @@
donedebug = isset(ERREXIT) ? 2 : 1;
opts[ERREXIT] = oerrexit_opt;
} else
- donedebug = 0;
+ donedebug = intrap ? 1 : 0;
if (ltype & Z_SIMPLE) {
next = state->pc + WC_LIST_SKIP(code);
- execsimple(state);
+ if (donedebug != 2)
+ execsimple(state);
state->pc = next;
goto sublist_done;
}
Index: Test/C03traps.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/C03traps.ztst,v
retrieving revision 1.14
diff -u -r1.14 C03traps.ztst
--- Test/C03traps.ztst 7 Aug 2008 16:25:16 -0000 1.14
+++ Test/C03traps.ztst 25 Aug 2008 17:21:19 -0000
@@ -415,6 +415,20 @@
>3 three
>5 five
+ # Assignments are a special case, since they use a simpler
+ # wordcode type, so we need to test skipping them separately.
+ fn() {
+ setopt localtraps localoptions debugbeforecmd
+ trap '(( LINENO == 4 )) && setopt errexit' DEBUG
+ x=three
+ x=four
+ print $LINENO $x
+ [[ -o errexit ]] && print "Hey, ERREXIT is set!"
+ }
+ fn
+1:Skip assignment from DEBUG trap
+>5 three
+
%clean
rm -f TRAPEXIT
--
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: skipping assignment and function statements; Interactive comments
2008-08-25 17:22 ` Peter Stephenson
@ 2008-08-26 2:59 ` Rocky Bernstein
0 siblings, 0 replies; 3+ messages in thread
From: Rocky Bernstein @ 2008-08-26 2:59 UTC (permalink / raw)
To: Peter Stephenson; +Cc: Zsh hackers list
Thanks! Seems to work fine.
(Now I have to work out my own regression tests for on this ;-)
On Mon, Aug 25, 2008 at 1:22 PM, Peter Stephenson
<p.w.stephenson@ntlworld.com> wrote:
> On Sat, 23 Aug 2008 00:15:31 -0400
> "Rocky Bernstein" <rocky.bernstein@gmail.com> wrote:
>> I just added a skip command to zshdb (and committed to github), but it
>> seems that assignment statements and function definitions are not
>> really skipped.
>
> Yes, thanks, there's yet another infuriating special case of the sort
> that makes me wish I'd picked an easier project.
>
> That's the third change here; the stuff with intrap is because it
> doesn't detect that it's already inside a trap (and hence should skip
> debugging) until it gets into dotrapargs(), and in this case it seems
> neater not to go to the trouble. This will be even more sensible when I
> get around to regenerating the line to be debugged at this point.
>
> Index: Src/exec.c
> ===================================================================
> RCS file: /cvsroot/zsh/zsh/Src/exec.c,v
> retrieving revision 1.141
> diff -u -r1.141 exec.c
> --- Src/exec.c 22 Aug 2008 15:41:31 -0000 1.141
> +++ Src/exec.c 25 Aug 2008 17:21:19 -0000
> @@ -1068,7 +1068,7 @@
> lineno = lnp1 - 1;
> }
>
> - if (sigtrapped[SIGDEBUG] && isset(DEBUGBEFORECMD)) {
> + if (sigtrapped[SIGDEBUG] && isset(DEBUGBEFORECMD) && !intrap) {
> int oerrexit_opt = opts[ERREXIT];
> opts[ERREXIT] = 0;
> noerrexit = 1;
> @@ -1086,11 +1086,12 @@
> donedebug = isset(ERREXIT) ? 2 : 1;
> opts[ERREXIT] = oerrexit_opt;
> } else
> - donedebug = 0;
> + donedebug = intrap ? 1 : 0;
>
> if (ltype & Z_SIMPLE) {
> next = state->pc + WC_LIST_SKIP(code);
> - execsimple(state);
> + if (donedebug != 2)
> + execsimple(state);
> state->pc = next;
> goto sublist_done;
> }
> Index: Test/C03traps.ztst
> ===================================================================
> RCS file: /cvsroot/zsh/zsh/Test/C03traps.ztst,v
> retrieving revision 1.14
> diff -u -r1.14 C03traps.ztst
> --- Test/C03traps.ztst 7 Aug 2008 16:25:16 -0000 1.14
> +++ Test/C03traps.ztst 25 Aug 2008 17:21:19 -0000
> @@ -415,6 +415,20 @@
> >3 three
> >5 five
>
> + # Assignments are a special case, since they use a simpler
> + # wordcode type, so we need to test skipping them separately.
> + fn() {
> + setopt localtraps localoptions debugbeforecmd
> + trap '(( LINENO == 4 )) && setopt errexit' DEBUG
> + x=three
> + x=four
> + print $LINENO $x
> + [[ -o errexit ]] && print "Hey, ERREXIT is set!"
> + }
> + fn
> +1:Skip assignment from DEBUG trap
> +>5 three
> +
> %clean
>
> rm -f TRAPEXIT
>
>
> --
> Peter Stephenson <p.w.stephenson@ntlworld.com>
> Web page now at http://homepage.ntlworld.com/p.w.stephenson/
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-08-26 2:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-23 4:15 skipping assignment and function statements; Interactive comments Rocky Bernstein
2008-08-25 17:22 ` Peter Stephenson
2008-08-26 2:59 ` 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).