From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 1738 invoked from network); 26 Feb 2023 09:57:28 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 26 Feb 2023 09:57:28 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1677405448; b=ArQKedzOzXXM1sLiHQ6EjL1GF9ylW3TvjkgS8GkqRA/1KylDer4s2MiYcFrNj+4DybvfZuQ5La rJducoQoTcqDrExQytCQl2+iX1tvL3d+geqvk+YcOEpniLqpMRZWdGbvTcXMJmt6TynJQWIZlZ rFCEhcjcD8jwWZUoG94tp3HBoNjL4A4NcSVu/Pnvxn3y2TNcaoP7q6OKM4AagTeuJP/T5As7VP sYm5em3QuQsb8zd462CabsJNA/tyKliIVHI75sdIlBZXfELajdvwRbfLrUo/346QQCLgTSBcRv VT/w1dKHHOo0cDXI20KuIWoBThu69FADB7zdqc9PsZbMgQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-lf1-f45.google.com) smtp.remote-ip=209.85.167.45; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1677405448; bh=UXduphtXhh+AT/N/V5OptxfFL1JjnbBwU0ciVoTVoPo=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=Dgz57rXr3l8xATAy2V1Mqn+kvoc/lErbvyUYmQHcjV39IB2YuIFeQ/XJq3VQIZDiFXc6odDnIW 3NiSo/2FdTntMtiQDYd6rJMVaGuwAhMMJm+jFteDuKdb8w6/WFA9ySSa02CgTllPsiwRXlkr47 KQhX5+GYpd8SFQLDKMwgdKo7NZG9vRp3BQ7IXXM1Qvs5jol+qFh3vtAKtZWg6baqUCSazjVGQx y0+vrsbWa583UFbJJynVTOT+SDMQ3zQwLPjQYEbQ6s2cWQejfEx5nLR997Mbo9ugqo/DDb1Fty xwoJyHPqB8eU9qBL0hjFUZKGgSAdOjma2oHQ2xBhaon2Sg==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=RRB4FE98cT8ieNHXW+pvKxF8kZXAgp6DgWd5pEcZMqg=; b=IUdJRv5WCLMWi9hUiXXW5CeG1u IC/0fKEcsp72J6I3iLg8cR4GMgTpHExxf1bI81GKTRmCV9AOfYisRkGEsnJNVVv710zYgp2r70HG6 a6AdQDG/Tos0/Zicpo+L/0FKqWM8rRBUtFfUtWBIa1XCnndmn2UporaKQ+JA+186x1Uny+0rkM6Zk es4Rf1u/ViWekuKdHJBvY4PgWNBCMeR80yHi/arb5fukqN15YfPjGhK4q1L+Eg1xEM9vNx5iXjAS3 YaXmBBMAvO3wgNWN/7iGhubpx/VO39qDJWXf1jmsZtwN3y1TZxJqwI7CIrRYFigS0Jz8sq9kBoscB u+e0di7Q==; Received: by zero.zsh.org with local id 1pWDmY-00072v-L4; Sun, 26 Feb 2023 09:57:26 +0000 Authentication-Results: zsh.org; iprev=pass (mail-lf1-f45.google.com) smtp.remote-ip=209.85.167.45; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-lf1-f45.google.com ([209.85.167.45]:46858) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1pWDmD-0006kZ-FY; Sun, 26 Feb 2023 09:57:06 +0000 Received: by mail-lf1-f45.google.com with SMTP id f41so4750816lfv.13 for ; Sun, 26 Feb 2023 01:57:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=RRB4FE98cT8ieNHXW+pvKxF8kZXAgp6DgWd5pEcZMqg=; b=b7mU1mIzCohfJsFXkdesOZhV6rijJER3hHt3EBxWMip2JxSouCO3So5sru7nlQQdRl qM3BZN0GCk+h00uQ71mg9to2vF6vZvCx7J0/Ph4u0OldakVdaQfx6L+fAwE+jq9ph6wM xHFP2UZzV4O/Gvjjp7/qiYnkmyX5uTkovxmk3RS73Qc5I0Nn1uDTL7pVKwWRFnGLgjWN 3Bpp2OxRFEF94VReCutV9szs/PKTvROCKo4bXr2rf+A0jCEaR3K516xCSXp57MdLwnNc K7Ptwb0j8YOHFsydeWGcLpMjw+r0c/xXSoSuzegLfgCh+NFcxJ9F8EjHX25oMciNUPE7 xzKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=RRB4FE98cT8ieNHXW+pvKxF8kZXAgp6DgWd5pEcZMqg=; b=GdXAX6cMeMtLkmp399WJBROJdsQun1sin6/C76dco1A8C3q2UwhMUaadN/wQv3krtT tlsNxn93qN9fbdGTmELhzwlBnDVD8bbpP9Qejry30FwGI6ZMnFr8u+KP2UYfbSIdJ1BY 1yozAUs33iyQSb+PcgHi3VV0oOVmmbBCmnoq+hyH6xXUeF1I2RDp+x1MPZP/WXnb+rmn SEsHNMr+N4Ms9ahjT7Fd3j2HmPIlqtGGJ8r5lWjDEGOzR7PD9GF964rH2gGopHywkbJh lVHAHlT5e7hOGs/OvaKLU7p/izvEQuXSM3RN7H1JIwOBcfc3TahaEeymnzen17dtDG24 dS3g== X-Gm-Message-State: AO0yUKV1UxGjZBIws8J1iHGw3ZsCjGZf2xQIVDSLvdzw/WiaczbX4e4h nnnhqspnxkVZbJ1tO8iqKlq0u+ii87DRM6T1XGLMDSrD X-Google-Smtp-Source: AK7set/5jn7OgMZn1T8YiCd4xvNozutELWCnA+hxXZ/Eh5YrMaDJJ18LS9SZNgLrrqBBsdQAK7gauZSh0AwQ1GxgreA= X-Received: by 2002:a19:ee14:0:b0:4d8:50e1:8ba7 with SMTP id g20-20020a19ee14000000b004d850e18ba7mr6217058lfb.2.1677405424435; Sun, 26 Feb 2023 01:57:04 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Sebastian Gniazdowski Date: Sun, 26 Feb 2023 09:56:37 +0000 Message-ID: Subject: Re: How to set exit trap from inner function? To: Bart Schaefer Cc: Zsh hackers list Content-Type: multipart/alternative; boundary="00000000000077c5e305f5976279" X-Seq: 51482 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: --00000000000077c5e305f5976279 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thanks. I've found a less invasive solution =E2=80=93 to name all inner fun= ctions witu tmp/=E2=80=A6 prefix, and unset them with nset -f -m tmp/\* On Fri, 24 Feb 2023 at 23:41, Bart Schaefer wrote: > On Thu, Feb 23, 2023 at 6:10 PM Sebastian Gniazdowski > wrote: > > > > I want to automatically clear all functions created from outer function= . > > > > Any ideas on having such auto-unset-funcs function? > > Unclear what side-effect messing about with localtraps may have on > this, but you can use one EXIT trap to set another EXIT trap: > > inner () { > trap "print FROM INNER: \$0; trap 'print FROM OUTER: \$0' EXIT" EXIT > } > outer () { > inner > } > > % outer > FROM INNER: outer > FROM OUTER: Src/zsh > > > Getting the quoting right for something more complicated, is left as > an exercise. > --=20 Best regards, Sebastian Gniazdowski --00000000000077c5e305f5976279 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thanks. I've found a less invasive solution =E2=80=93 to= name all inner functions witu tmp/=E2=80=A6 prefix, and unset them with ns= et -f -m tmp/\*


On Fri, 24 Feb 2023 at 23:41, Bart Schaefer &= lt;schaefer@brasslantern.com> wrote:
On= Thu, Feb 23, 2023 at 6:10 PM Sebastian Gniazdowski
<
sgniazdowsk= i@gmail.com> wrote:
>
> I want to automatically clear all functions created from outer functio= n.
>
> Any ideas on having such auto-unset-funcs function?

Unclear what side-effect messing about with localtraps may have on
this, but you can use one EXIT trap to set another EXIT trap:

inner () {
=C2=A0 trap "print FROM INNER: \$0; trap 'print FROM OUTER: \$0= 9; EXIT" EXIT
}
outer () {
=C2=A0 inner
}

% outer
FROM INNER: outer
FROM OUTER: Src/zsh


Getting the quoting right for something more complicated, is left as
an exercise.


--
Best regards,
Se= bastian Gniazdowski

--00000000000077c5e305f5976279--