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

Re: local unfunction



On Fri, Mar 30, 2018 at 5:30 PM, Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>
> playing with Mikael's use of parenthesis -- I'd swear this is the first time
> I've seen any such thing -- and it seems too good to be true, so far it just
> works.  Are there any lurking gotchas?

It's just creating a subshell, like any other time you'd put one or
more commands in parentheses.

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.

> Disadvantages? It doesn't seem any slower.

It does fork an additional process.

> BTW, just to keep flogging a dead horse:
>
> function test1 ()
> {
> echo  "\none"
> whence -a "zsh"
> echo  "\ntwo"
> whence -ma "zsh*"
> echo  "\nthree"
> whence -m "zsh*"
> }

Try adding -w to get whence to tell you which hash table it's reading from.



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