DASH Shell discussions
 help / color / mirror / Atom feed
* trap bug in recent versions of dash
@ 2010-08-11  8:06 Guido Berhoerster
  2010-08-15 20:05 ` Jilles Tjoelker
  2010-11-28  7:19 ` Herbert Xu
  0 siblings, 2 replies; 9+ messages in thread
From: Guido Berhoerster @ 2010-08-11  8:06 UTC (permalink / raw)
  To: dash

Hello,

with the latest git version of dash trap actions are not
evaluated in the context of a function.

The following script demonstrates the bug:
----8<----
read_timeout () {
    saved_traps="$(trap)"
    trap 'printf "timed out\n"; eval "${saved_traps}"; return' TERM
    ( sleep $1; kill -TERM $$ ) >/dev/null 2>&1 &
    timer_pid=$!
    read $2
    kill $timer_pid 2>/dev/null
}

read_timeout 5 value
printf "read \"%s\"\n" "${value:=default}"

---->8----
The return statement in the trap inside the read_timeout function
does not return from the function but rather exits the script.

With dash 0.5.5.1 it works as expected.
-- 
Guido Berhoerster

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

end of thread, other threads:[~2010-11-28  8:56 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-11  8:06 trap bug in recent versions of dash Guido Berhoerster
2010-08-15 20:05 ` Jilles Tjoelker
2010-08-16 11:52   ` Guido Berhoerster
2010-08-22 22:32     ` Jilles Tjoelker
2010-08-23 10:40       ` Guido Berhoerster
2010-08-23 20:11         ` Jilles Tjoelker
2010-11-28  7:20       ` Herbert Xu
2010-11-28  7:19 ` Herbert Xu
2010-11-28  8:50   ` Guido Berhoerster

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox