From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27661 invoked by alias); 31 Mar 2018 14:59:07 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: List-Unsubscribe: X-Seq: 23294 Received: (qmail 25304 invoked by uid 1010); 31 Mar 2018 14:59:07 -0000 X-Qmail-Scanner-Diagnostics: from mta02.eastlink.ca 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(24.224.136.13):SA:0(-1.9/5.0):. Processed in 15.189925 secs); 31 Mar 2018 14:59:07 -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=-1.9 required=5.0 tests=BAYES_00,SPF_PASS, T_RP_MATCHES_RCVD,T_SPF_HELO_TEMPERROR autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: rayandrews@eastlink.ca X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | MIME-version: 1.0 Content-transfer-encoding: 8BIT Content-type: text/plain; charset=utf-8; format=flowed X-Authority-Analysis: v=2.3 cv=OKgJIxSB c=1 sm=1 tr=0 a=RnRVsdTsRxS/hkU0yKjOWA==:117 a=RnRVsdTsRxS/hkU0yKjOWA==:17 a=IkcTkHD0fZMA:10 a=yBHQf8QTPs736Gt1EPYA:9 a=QEXdDO2ut3YA:10 X-EL-IP-NOAUTH: 24.207.101.9 Subject: Re: local unfunction To: zsh-users@zsh.org References: <9e0faf6b-b19e-b6d6-0eb7-6ea20b2c2154@eastlink.ca> <03b1320b-c248-adbe-55a3-49a3673453bd@eastlink.ca> From: Ray Andrews Message-id: Date: Sat, 31 Mar 2018 07:58:47 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 In-reply-to: Content-language: en-CA 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.