zsh-users
 help / color / mirror / code / Atom feed
From: Mikael Magnusson <mikachu@gmail.com>
To: Ray Andrews <rayandrews@eastlink.ca>
Cc: Zsh Users <zsh-users@zsh.org>
Subject: Re: local unfunction
Date: Fri, 30 Mar 2018 22:10:59 +0200	[thread overview]
Message-ID: <CAHYJk3RBu1wE=m76eeF6+LEAbDAJDE1E6zfeuddxf5LPhW8i4w@mail.gmail.com> (raw)
In-Reply-To: <9e0faf6b-b19e-b6d6-0eb7-6ea20b2c2154@eastlink.ca>

On Fri, Mar 30, 2018 at 6:11 PM, Ray Andrews <rayandrews@eastlink.ca> 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.

If it's okay to also cancel all other side effects, you can use a subshell,
function() hey {
  normal stuff here
  (
     unfunction foo
     foo
     a=5 # this will also disappear after the )
  )
}

-- 
Mikael Magnusson


      parent reply	other threads:[~2018-03-30 20:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-30 16:11 Ray Andrews
2018-03-30 18:47 ` Bart Schaefer
2018-03-31  0:30   ` Ray Andrews
2018-03-31  5:23     ` Bart Schaefer
2018-03-31 14:58       ` Ray Andrews
2018-03-30 20:10 ` Mikael Magnusson [this message]

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='CAHYJk3RBu1wE=m76eeF6+LEAbDAJDE1E6zfeuddxf5LPhW8i4w@mail.gmail.com' \
    --to=mikachu@gmail.com \
    --cc=rayandrews@eastlink.ca \
    --cc=zsh-users@zsh.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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).