From: Ray Andrews <rayandrews@eastlink.ca>
To: zsh-users@zsh.org
Subject: Re: local unfunction
Date: Sat, 31 Mar 2018 07:58:47 -0700 [thread overview]
Message-ID: <eea79d3f-0a02-7bd1-80db-0c38cc0a3806@eastlink.ca> (raw)
In-Reply-To: <CAH+w=7bZGJ71hfKTkLNzc9CyYgHc9i7DSVhR-9bi+-n85jGNog@mail.gmail.com>
On 30/03/18 10:23 PM, Bart Schaefer wrote:
> It's just creating a subshell, like any other time you'd put one or
> more commands in parentheses.
Well nuts, I had no idea. Checking tho I see it is in Peter's book, but
at the time the notion of a subshell seemed strange and pointless. Not so.
>
> The "lurking gotcha" is that because it is a subshell it can't affect
> the parent shell in any way. That's what Mikael means by "cancel all
> other side effects" which he demonstrates with a=5.
Right, but in this case that's exactly to the point. Not a gotcha, but
a feature.
>
> It does fork an additional process.
Yeah, I've always presumed there must be some huge overhead in that, but
it doesn't seem so. I just ran a stress test and the parenthesis add 7%
in run time, ca. 20 milliseconds. More subshells in my future. Sounds
like it's not a complete restart of the shell from disk but a sorta
fast cloning from memory or something like that, so not too much labor.
> Try adding -w to get whence to tell you which hash table it's reading
> from.
$ which -mwa zsh
zsh: command
zsh: command
zsh: command
... I had looked at that but the output doesn't seem to say anything useful.
next prev parent reply other threads:[~2018-03-31 14:59 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 [this message]
2018-03-30 20:10 ` Mikael Magnusson
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=eea79d3f-0a02-7bd1-80db-0c38cc0a3806@eastlink.ca \
--to=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).