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

Re: Bug with traps and exit



Another variant.

Strangely, this one is not detected when tried from within a loop.

====begin test script====
test_BUG_TRAPFNEXI() {
	{ test_result=$(
		my_pid=$(zsh -c 'echo "$PPID"')
		test_fn() {
			kill -s ALRM "$my_pid"
			print "stillhere"
		}
		trap "print 'trap'; exit" ALRM
		test_fn
	); }
	if [[ ${test_result} == $'trap\nstillhere' ]]; then
		print "bug found"
	else
		print "bug NOT found"
		return 1
	fi
}
test_BUG_TRAPFNEXI
while :; do
	test_BUG_TRAPFNEXI
	break
done
test_BUG_TRAPFNEXI
====end test script====

Output, as of zsh 5.1:

bug found
bug NOT found
bug found

The second line (the "NOT found" one) was when the bug test was tried within a dummy loop.

- Martijn

--
modernish -- harness the shell
https://github.com/modernish/modernish



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