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 15379
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: trap does not work in a trap function?
- Date: Thu, 9 Sep 2010 12:39:47 +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=9VQFiqEs7riYxw72zrLhbc/3Dxv7XXguH7xMSiTJTEA=; b=e5VIkElu9uo5iNJXawCXcCSGZguwlXurhNplNlumFrrqJWM3GH6yMorpnlvmSNbHz4 SRt+Nsc+PtTXxBGjxfqWtcX9om0LDBc7jKVZ8NXHjgPiD5zj1eS26sS6niMwg7ZoaLxW iHBadRkMUaxrFdCQxP5F3tUxz7QKKLgjoMWjk=
- 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=Dsw3aZhVmbECchRh6pf7VJDdcpl0AoFmPNeGdUoiXw9ewNnhTY3oHbWp0FMT0a1mk/ Ei9akPRKnDRhGKCcA2PUFmHXZin5L+W6WwI7LdXqqvC7znsmTdhWzKB5PY7b0eYX3gAu gLNDBvbaW/Hebn3toUJ7/KVbx6xDCyUSq7NK0=
- In-reply-to: <20100909105608.453fd843@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> <AANLkTikjabCspqKZfWCA35_RhYa0up7AxDa+GocktMG_@xxxxxxxxxxxxxx> <20100909105608.453fd843@xxxxxxxxxxxxxxxxxxxxxxxxx>
On 9 September 2010 11:56, Peter Stephenson <Peter.Stephenson@xxxxxxx> wrote:
> On Thu, 9 Sep 2010 11:44:49 +0200
> Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
>> 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).
>
> What's supposed to happen is the trap, however it is set, is saved and
> unset during the function, then restored afterwards (before the scope in
> which the function's EXIT trap is run, hence the workaround). So this
> isn't supposed to work. I get the following:
>
> % TRAPEXIT() { echo This is the exit trap; }
> % fn() { unfunction TRAPEXIT; }
> % fn
> fn:unfunction: no such hash table element: TRAPEXIT
> % functions TRAPEXIT
> TRAPEXIT () {
> echo This is the exit trap
> }
> % exit
> This is the exit trap
Ah, I had SIG instead of TRAP which obviously didn't work, which had
the side effect of looking like it worked ;).
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author