Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: local unfunction

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.

Messages sorted by: Reverse Date, Date, Thread, Author