DASH Shell discussions
 help / color / mirror / Atom feed
From: Guido Berhoerster <guido+kernel.org@berhoerster.name>
To: dash@vger.kernel.org
Subject: trap bug in recent versions of dash
Date: Wed, 11 Aug 2010 10:06:16 +0200	[thread overview]
Message-ID: <20100811080616.GA18303@wopr.local.invalid> (raw)

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

             reply	other threads:[~2010-08-11  8:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-11  8:06 Guido Berhoerster [this message]
2010-08-15 20:05 ` trap bug in recent versions of dash 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100811080616.GA18303@wopr.local.invalid \
    --to=guido+kernel.org@berhoerster.name \
    --cc=dash@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox