From: Bart Schaefer <schaefer@brasslantern.com>
To: Ray Andrews <rayandrews@eastlink.ca>
Cc: Zsh Users <zsh-users@zsh.org>
Subject: Re: local functions
Date: Mon, 19 Dec 2022 17:00:53 -0800 [thread overview]
Message-ID: <CAH+w=7YUVieOKvf4Wb-Z=jkbSDfF3UNq6cMDF4m014fp+hfxAA@mail.gmail.com> (raw)
In-Reply-To: <4ffaaa6a-d276-7715-a62f-fbd9bf880968@eastlink.ca>
The current git head has a new utility function
Completion/Base/Utility/_shadow that can be used to simulate local
function names. You write
{
_shadow myfunc
function myfunc {
# Do your new thing
}
# call myfunc as needed
} always {
_unshadow myfunc
}
If there is already a function named "myfunc" it gets moved aside and
replaced by the new one, and then moved back by _unshadow. This can
also be used to temporarily replace a builtin.
The functions aren't really local -- they exist in the global scope,
so there's still a chance that something that wants to call the
original one will get the newer one by mistake -- but that's pretty
similar to what happens with local parameters.
next prev parent reply other threads:[~2022-12-20 1:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-19 18:19 Ray Andrews
2022-12-19 19:01 ` Bart Schaefer
2022-12-19 21:52 ` Ray Andrews
2022-12-20 1:00 ` Bart Schaefer [this message]
2022-12-20 2:51 ` Ray Andrews
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='CAH+w=7YUVieOKvf4Wb-Z=jkbSDfF3UNq6cMDF4m014fp+hfxAA@mail.gmail.com' \
--to=schaefer@brasslantern.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).