zsh-workers
 help / color / mirror / code / Atom feed
* Weird exit caused in a trap DEBUG which sources a file.
@ 2008-07-31  2:38 Rocky Bernstein
  2008-07-31  9:01 ` Peter Stephenson
  0 siblings, 1 reply; 12+ messages in thread
From: Rocky Bernstein @ 2008-07-31  2:38 UTC (permalink / raw)
  To: zsh-workers

Below is a small program whittled down from a larger one. It has
behavior I can't figure out.

It seems to show that when a function is called via trap DEBUG and you
then source a file and it has a statement in it, on return from the
TRAP an exit will be taken.  Here is the program:

#!/usr/bin/zsh
function debug_trap_handler {
    print $functrace[1]
    do_bug
}

function do_bug {
   . ./bug-file
}

trap 'echo EXIT hit' EXIT
trap 'debug_trap_handler' DEBUG
a=1
b=2
d=3

In "bug-file" put any command. ":" will do. Or a print statement.
Let's say it contains the line:
print bug file here

When I run the above I get:

$ ./zshtrace.sh

./zshtrace.sh:12
bug file here
EXIT hit

Now if the file contains only comments or blank lines or is empty,
here is what I get:
$ ./zshtrace.sh
./zshtrace.sh:12
./zshtrace.sh:13
./zshtrace.sh:14
./zshtrace.sh:15
EXIT hit

which is what I would expect.

Anyone care to venture a guess as to what's going on? It feels like a
bug to me, if for no other reason than some message about why the exit
was raised is missing.

Thanks.


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

end of thread, other threads:[~2008-08-05 11:19 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-31  2:38 Weird exit caused in a trap DEBUG which sources a file Rocky Bernstein
2008-07-31  9:01 ` Peter Stephenson
2008-07-31 10:05   ` Rocky Bernstein
2008-08-01 12:29     ` Rocky Bernstein
2008-08-01 13:37       ` Peter Stephenson
2008-08-01 15:21         ` Rocky Bernstein
2008-08-01 15:31           ` Peter Stephenson
2008-08-02 11:21             ` Rocky Bernstein
2008-08-03 10:42               ` Peter Stephenson
2008-08-03 11:28                 ` Rocky Bernstein
2008-08-03 11:50                   ` Peter Stephenson
2008-08-05 11:18                     ` 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).