Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: function definition with & operator
- X-seq: zsh-workers 41632
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: "zsh-workers@xxxxxxx" <zsh-workers@xxxxxxx>
- Subject: Re: function definition with & operator
- Date: Sat, 2 Sep 2017 12:23:25 -0700
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=Ho7ddRG6B+grCMhwJngPirybbGcv5FsHH0DxyU1lXNQ=; b=ITkj+eIToTsghkrrVGSlREDT2j3IJmZbIDw0J4zHxiBNAtkiJ9PZ6CIkhlKTT3fZwd jdzJ9j1dZhHhiAjKCOFge+7EI/kLzHM48hPcTlb9dhtnGo7utTe2ViPI3Yoeb69UMWL2 xBG/Cn4x8FJDvmDdpKbGlCdipVnlW4aXff0879yW4bvKGcwWpLKa1D2uWob/eJUvaBf5 A6o7hFXb/vpPLB9gkPGlAP1bj787oPanMrfhkkPTqF0OHBJBrbPyrIKzt4GsegX3H22V 7QCKIrZ35BTAhcBH6zkVArFni2gQBCghMIAsFueYmXxuW7pVLQg3By51Oht5pQND4GV/ /tmw==
- In-reply-to: <c59ec58a-e0bd-63d5-feed-095df245b942@gmx.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <edfcc306-4f5e-63dd-00e0-2481e71ec5cc@gmx.com> <CAH+w=7Z9diXFviDw81qMY4vhPMV1UDs65o+h89UDeT2FpTcvZA@mail.gmail.com> <c59ec58a-e0bd-63d5-feed-095df245b942@gmx.com>
On Fri, Sep 1, 2017 at 2:23 PM, Eric Cook <llua@xxxxxxx> wrote:
> On 09/01/2017 04:46 PM, Bart Schaefer wrote:
>> On Fri, Sep 1, 2017 at 11:09 AM, Eric Cook <llua@xxxxxxx> wrote:
>>> The other week when messing around i noticed that you can define an function
>>> in (what i thought would be) the background and it will remain in defined.
>>
>> Background jobs are always run in a subshell,
>
> Exactly what i thought, but if that were the case, foo wouldn't be defined after
> the first example since & was the terminator used instead of ;.
Oh, I see. I read "in defined" as a typo or auto-correct-o for
"undefined" and thought you were complaining about the "{ ... } &"
example.
Yes, this is odd, and it appears to have always been this way.
However, it's a bit more than a minor bug, because it also affects
anonymous functions; compare:
zsh -fc '{ sleep 10 } & print $SECONDS'
0
zsh -fc '() { sleep 10 } & print $SECONDS'
10
What's going on here is that a function definition is not actually a
command, it's a syntax construct that is special-cased in exec.c.
However, I'm not sure how to resolve it.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author