Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: trap does not work in a trap function?
- X-seq: zsh-users 15377
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: trap does not work in a trap function?
- Date: Thu, 9 Sep 2010 11:44:49 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type; bh=Qw/MsYQJX2+W/3vvhRQvpAARJuFbMNCYYZhwTYPP4JQ=; b=VNtkEeuLViv6eyi438Mj9U46RGxYMpJMSnEjyCpA5HAlvxF9u9NSkPo4ba+Nl9/Hd+ tLrge2FzjU4oK1XSgCQ9iJKuLZG2eLd6YWSRiGHbj6x5KCK6ZAVZiVqwJbAYMlJ36IEe //ZUxA7Gk0rVEeyNilTJE1DlDBIlocXDWeirs=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=P78a8urEMb2xGgLT0/TB67XVGycO57bsebEJfu7QB9wcJB7K0imZhiBCGA0mnDjdwj aLrHhCtNixMiBdXLVAU2QcrOpVkZ0GXMM0ZOwx+mvRlwOCPEnrTLDQsuw+KhvVZtPukA QCH13BPHgwl2d6LSUeCXzb4WTNJEDruGXBFuw=
- In-reply-to: <20100909095753.5473e833@xxxxxxxxxxxxxxxxxxxxxxxxx>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <20100909080214.76320@xxxxxxx> <20100909081733.76300@xxxxxxx> <20100909095753.5473e833@xxxxxxxxxxxxxxxxxxxxxxxxx>
On 9 September 2010 10:57, Peter Stephenson <Peter.Stephenson@xxxxxxx> wrote:
> On Thu, 09 Sep 2010 10:17:33 +0200
> "Dominik Vogt" <dominik.vogt@xxxxxx> wrote:
>> shutdown () {
>> echo shutdown
>> trap - EXIT
>> exit 77
>> }
>>
>> trap shutdown EXIT
>> shutdown
>> -- END sigtest
>>
>> > $ ./sigtest
>> > shutdown
>> > shutdown
>> >
>> > Why is the shutdown function called again by exit when the EXIT
>> > trap was just removed? This looks like the trap builtin does not
>> > properly work from within a trap handler.
>
> The EXIT trap you removed was the one for the "shutdown" function. In zsh,
> EXIT is used with functions as well as scripts.
>
> You can do what you want like this:
>
> shutdown () {
> echo shutdown
> trap 'trap - EXIT' EXIT
> exit 77
> }
>
> unless shutdown is itself called from within a function, in which case
> you're removing the EXIT trap for that.
Could you also use "SIGEXIT() shutdown" and "unfunction SIGEXIT"
instead, regardless of the amount of function nesting? (It seems to
work when I try it).
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author