zsh-workers
 help / color / mirror / code / Atom feed
* TRAPDEBUG exit bug?
@ 2015-07-28 18:48 Joshua Krusell
  2015-07-28 19:40 ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Joshua Krusell @ 2015-07-28 18:48 UTC (permalink / raw)
  To: zsh-workers

Correct me if I'm wrong, but I couldn't find anything in the docs that
indicate the following is expected behavior w.r.t. TRAPDEBUG.

Setting TRAPDEBUG seems to make zsh unexpectedly emit SIGEXIT after a
command following a failed && or || conditional expr.

trap "" DEBUG
trap "print exit trap" EXIT

for ((i = 0; i < 2; i++)); do
    false && :
    echo $?
done

$ zsh ./test.sh
1
exit trap
1

Unsetting debug_before_cmd or having more than one command follow
produces the expected behavior.

Ex:
trap "" DEBUG
trap "print exit trap" EXIT

for ((i = 0; i < 2; i++)); do
    false && :
    echo $?
    :
done

$ zsh ./test.sh
1
1
exit trap

Reproducible since patch 27947.

/jsks


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

* Re: TRAPDEBUG exit bug?
  2015-07-28 18:48 TRAPDEBUG exit bug? Joshua Krusell
@ 2015-07-28 19:40 ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2015-07-28 19:40 UTC (permalink / raw)
  To: zsh-workers

On Jul 28,  8:48pm, Joshua Krusell wrote:
}
} Setting TRAPDEBUG seems to make zsh unexpectedly emit SIGEXIT after a
} command following a failed && or || conditional expr.

Hm, it's even weirder than that:

torch% trap "" DEBUG
torch% trap "print exit trap" EXIT
torch% trap
trap -- 'print exit trap' EXIT
trap -- '' DEBUG
torch% false && :
torch% :
exit trap
torch% trap
trap -- '' DEBUG
torch% 

Note that the exit trap itself has now disappeared.  This happens with
a TRAPEXIT function as well.

-- 
Barton E. Schaefer


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

end of thread, other threads:[~2015-07-28 19:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-28 18:48 TRAPDEBUG exit bug? Joshua Krusell
2015-07-28 19:40 ` Bart Schaefer

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