From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23865 invoked by alias); 1 Apr 2018 15:59:24 -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: 23299 Received: (qmail 9026 invoked by uid 1010); 1 Apr 2018 15:59:24 -0000 X-Qmail-Scanner-Diagnostics: from mta01.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.30):SA:0(-2.6/5.0):. Processed in 2.54289 secs); 01 Apr 2018 15:59:24 -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.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_PASS,T_RP_MATCHES_RCVD 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=8GCJ57nQ-uVg-yHBwPwA:9 a=QEXdDO2ut3YA:10 X-EL-IP-NOAUTH: 24.207.101.9 To: Zsh Users From: Ray Andrews Subject: fast subshell Message-id: Date: Sun, 1 Apr 2018 08:59:16 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 Content-language: en-CA So, now that I am awake to the usefulness of subshells in a function, I'm still exploring the implications on speed since a subshell sounds like it would be a lot of work.  However, using it to  control my old friend IFS, whereasI had previously done this:     local IFS=$'\n' # Must split on newlines only.     all_matches=( $( whence -mavS $@ ) )     IFS=$OLD_IFS ... now trying: (     IFS=$'\n' # Must split on newlines only.     all_matches=( $( whence -mavS $@ ) ) ) ... and the interesting thing is that the former executes a stress test in ca. 290 mS, but the latter in ca. 250 mS.  The difference isn't significant in the real world, but it is hard to understand, it seems strange that the subshell would be faster. Is this possible?  If so, how should I understand it?  It seems as if a subshell is a rather 'lite' thing after all, in the above it seems to be hardly more than a scoping of IFS.