From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13510 invoked by alias); 30 Mar 2018 18:47:25 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: List-Unsubscribe: X-Seq: 23290 Received: (qmail 13207 invoked by uid 1010); 30 Mar 2018 18:47:25 -0000 X-Qmail-Scanner-Diagnostics: from mail-lf0-f54.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.215.54):SA:0(-1.9/5.0):. Processed in 1.351241 secs); 30 Mar 2018 18:47:25 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_PASS,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: schaefer@brasslantern.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=z3PsZjNWf79AeMbUehwoVi+LTzMypbKwTo8cjQNdNgU=; b=Z25Rh95m3ayvBOftPHscWu0Qmj/7Xa5dxRHy3xF7+LIF8TdpALG5izz0KVWfHDH/RU 4+slUIQcfh5DjiWjKdy2BDcFw5+t5Pu187bh19loR9DMR/w7Iy8xAJJBSHgK9D1p7riU shdyYGLz1R3y6Ar5igRXmGmbBKU5S3BtjKWn8O8CsGx4xNFJ5zG2UBBHHy0F6ZebIKSs sXF8Qm7OAXjwHrqCT9qLvUOocj4u2TA68jcoZ6R5P5ZVjSSAwAAc0cCL1tg8Mvk4YK2I eiaV2Hj0gkt0WylcEoGXIxb6hhdreRp0ukSzqeGtPQEtnmjHjWIt28BN2uNC6EpnOjyP /lHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=z3PsZjNWf79AeMbUehwoVi+LTzMypbKwTo8cjQNdNgU=; b=GdRsjw8NBFERTD+LI+/7rmJMLgtyhpk7RrtJ7pcwUqEJQF2ryK70Td0ZOCQ+K2RoQ1 OdCWiBAlN5QkwkSk8iHscEtrvr+I7btQCtl5VXbg52+mRhw8HYs1GzYQVdgs/LjsgYFq LV+VGt25TC/GHC0jYy+YaxbVyfFgQaNrQA5SdyLv6OdKbnVE5nwCZZnTRRnumFwgxa+v wf1rB0Bv5bjseCY1fhym3CTusuEXyUi+QLDEwUgb9Q9rWbQHMU3pwxI2yhEAz78lQe9t 7KsuuypXeERmEYoNbkD1yfdLcp0oNHkEQx5YtOrrj/qkTM06tfmMT9mZ0jSpgL2VxtO9 Xavw== X-Gm-Message-State: ALQs6tCW3UYljtoCSTyDeLlihWCn1Fp82gdEn90I/oBCJ6rQ644mdan8 3wbh6e0dWcsD2a9CxoqNRkYzp6QeH9Izvl4x+D4liQ== X-Google-Smtp-Source: AIpwx48/i6e8UHgl2UFuaTQ6VGcM29yTaIzq5Hn+lQyY+SjnXOUYTxBKVEingoe1QxeES1JmRyElyo0IB6t64U+9W8Q= X-Received: by 2002:a19:df54:: with SMTP id q20-v6mr89141lfj.28.1522435639499; Fri, 30 Mar 2018 11:47:19 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <9e0faf6b-b19e-b6d6-0eb7-6ea20b2c2154@eastlink.ca> References: <9e0faf6b-b19e-b6d6-0eb7-6ea20b2c2154@eastlink.ca> From: Bart Schaefer Date: Fri, 30 Mar 2018 11:47:18 -0700 Message-ID: Subject: Re: local unfunction To: Ray Andrews Cc: Zsh Users Content-Type: text/plain; charset="UTF-8" On Fri, Mar 30, 2018 at 9:11 AM, Ray Andrews wrote: > Is it possible to unfunction something just within another function? I've > tried: > > unset -fm .... > > ... but the functions remain dead after the calling function returns. I can > of course just resource them, but I'll bet the unset can be made local. You can get that effect like this: % zmodload zsh/parameter % inner() { print $0 } % outer() { local +h functions; unfunction inner; which inner } % which inner inner () { print $0 } % outer inner not found % which inner inner () { print $0 } HOWEVER, this not "safe" with autoloaded functions that have not been loaded yet: % zmodload zsh/parameter % outer() { local +h functions; unfunction inner; which inner } % autoload -U -k inner % which inner inner () { # undefined builtin autoload -XUk } % outer inner not found % which inner inner () { builtin autoload -XU } Note that the "# undefined" tag and the -k flag have been lost; "inner" is no longer a true autoloaded function. (I think it is probably a bug that $functions[inner] does not have the -k flag.)