From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19703 invoked by alias); 2 Sep 2017 19:23:34 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 41632 Received: (qmail 21689 invoked by uid 1010); 2 Sep 2017 19:23:34 -0000 X-Qmail-Scanner-Diagnostics: from mail-qt0-f182.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.216.182):SA:0(-2.1/5.0):. Processed in 3.079452 secs); 02 Sep 2017 19:23:34 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RCVD_IN_SORBS_SPAM,SPF_PASS, T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: schaefer@brasslantern.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | 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== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=Ho7ddRG6B+grCMhwJngPirybbGcv5FsHH0DxyU1lXNQ=; b=a7BmzwpLbGsnov5Jvk92xOspReTZkLikvxC1XJb+tljNs4mmo7M4ItpsF//aJ/Izum m3p53abU2/iNwUDnmRRpWGbluFY7gnUSUutbmZmHpLjeIC70sH7eNk2+0yQtnVowXbIS 6R5WOGtPfSttg67AaDP2rgJpKlmrTsyycllBZ2hTAjmldKjVOVbvG4/XNTU+WmWjoasI XtkQ/bRdnL7VySnK/rkaPuFKm0snySQXnbtK3TA+BqjFyuwPEjphIXF5UpWsgWxoU6ht RttlHYpG94u9ILOFlmDydfxYv3O1sCgJ/sKn9bD0SCI8L/pUPx+ZM/QECKTuxknwRBIs fBvw== X-Gm-Message-State: AHPjjUit45ZHf7QICdwQEEw0WHNQ/MKWYE513Am7ZXQUAQ4iLLk1EOtu O+YwBwkJ/YZxXrKiUcggOi22mdAjc2qsP1M= X-Google-Smtp-Source: ADKCNb4yrDibk8KWFkxY6I+DPNajX8G7Emf+lDlid2pJjBmhEa9EmAtdKfWS2tACV39gXbsompMh1MjsXNJURhlL63Q= X-Received: by 10.237.63.41 with SMTP id p38mr8128381qtf.322.1504380206647; Sat, 02 Sep 2017 12:23:26 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: From: Bart Schaefer Date: Sat, 2 Sep 2017 12:23:25 -0700 Message-ID: Subject: Re: function definition with & operator To: "zsh-workers@zsh.org" Content-Type: text/plain; charset="UTF-8" On Fri, Sep 1, 2017 at 2:23 PM, Eric Cook wrote: > On 09/01/2017 04:46 PM, Bart Schaefer wrote: >> On Fri, Sep 1, 2017 at 11:09 AM, Eric Cook 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.