From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 8f96271a for ; Fri, 9 Nov 2018 14:38:17 +0000 (UTC) Received: (qmail 23848 invoked by alias); 9 Nov 2018 14:38:02 -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: 23749 Received: (qmail 16113 invoked by uid 1010); 9 Nov 2018 14:38:02 -0000 X-Qmail-Scanner-Diagnostics: from mail-wr1-f42.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.221.42):SA:0(-1.8/5.0):. Processed in 2.140984 secs); 09 Nov 2018 14:38:02 -0000 X-Envelope-From: dritter03@googlemail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ZDfqj5TMPEDb+GL/80dCV/u4miyRu3EkMWEQlePEtUA=; b=I6kq2aOcUgV7FOsiep2yHIwdvLzJDpTrUAcDuf4dtgLdvB/wDdKu6UEuK1CqjVgORK CAWoI85OwCyHUp/4h9Y/OqXtGpdRr+B2FYOb6BnVAXTvvitHPSkVoGCpVhLngKzMUISa cnCcdEIhWLeclZZK07nDHcndUmy/i5cVxWr+OBcs/trob/PakAx05vswHrcCpedmdmPC hbfemdCiCKCXm6cYQEqDvktwyeNo1n9kdWUohMGNbPtz7uvt15OrVc9REAmNE4to+wgu Oiy+2qMmag4Zy4yX9xl5+qL5IWmULwPOQaLMk8fJG2FtQFCLzIjwA5/1bbWfbtIf4UmF 5N8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ZDfqj5TMPEDb+GL/80dCV/u4miyRu3EkMWEQlePEtUA=; b=BDqDEJ8etvr5MRiEQNvU8p08ntTsv/rxSastdwgyJ76tTC1ZMZHvt8h4xq7Y+hgwSO pgmb/PMW80RQaPFiFd0XwnlhWVVWuyH7WVfP6myB0+XQdtbA9BkQzIF/rySubYNeTO00 70tyE3svDqtRLXTZSUjxgzepTz8DwJYox1YIKI/3XLOobY2b4IT22++m1rPYthK3Wd9R JzBid2xdJBPaeD4JjZCRDOV2mzaBwFPYEjjS30QTsZzI0j2ZbGA3i+52NIsZwrOVMJ9V DKZHbeMdeNZ2l2zXU/Yk1tgE43gzf7gFJTMHN/VgLN7Ac1jRYT0TfaCxMnUJN6i9CcTB V0zw== X-Gm-Message-State: AGRZ1gIHHdmGT7PCGNVGMccTa4Sd8EMIe+GMWa1UPFIQwtSSKJ/XYNC8 GGQ6QcCNmfaK8jWFWyEaBRCbk/AxF+lnvP0h23w= X-Google-Smtp-Source: AJdET5dCl3zcXrkvek5k/waT2l5mFTvMvQTcDUVBoM3AGbN6ca4RZ6yJcDFZRPYqGn8Do1ITgVUmjJwVE1kpmCBb7T4= X-Received: by 2002:adf:fd49:: with SMTP id h9-v6mr8499066wrs.280.1541774275826; Fri, 09 Nov 2018 06:37:55 -0800 (PST) MIME-Version: 1.0 References: <1541756153.3720.1.camel@samsung.com> In-Reply-To: <1541756153.3720.1.camel@samsung.com> From: Dominik Ritter Date: Fri, 9 Nov 2018 15:37:44 +0100 Message-ID: Subject: Re: Use glob patterns while reading a file To: p.stephenson@samsung.com Cc: zsh-users@zsh.org Content-Type: multipart/alternative; boundary="00000000000008d9b9057a3c4ceb" --00000000000008d9b9057a3c4ceb Content-Type: text/plain; charset="UTF-8" I was hoping for a solution without externals. The cat version seems to be slower than the other one, and I the null glob seems not to work, if neither of the files was found.. Testing 10000 iterations of cat-glob ( repeat $ITERATIONS; do; echo $(cat < ./(a|b)(N) 2>/dev/null ) > /dev/null 2) 5,75s user 2,61s system 107% cpu 7,741 total Testing 10000 iterations of resolve-first glob ( repeat $ITERATIONS; do; local -a files; files=(./(a|b)(N)) ; for file in ; ) 0,11s user 0,16s system 98% cpu 0,276 total With "b" being a simple text file. Test-Script: #!/bin/zsh ITERATIONS=10000 echo "Testing $ITERATIONS iterations of cat-glob" time (repeat $ITERATIONS; do; echo $(cat < ./(a|b)(N) 2>/dev/null ) >/dev/null 2>&1 done;) echo "Testing $ITERATIONS iterations of resolve-first glob" time (repeat $ITERATIONS; do; local -a files files=( ./(a|b)(N) ) for file in $files; do; echo $(< ${file} ) >/dev/null done done;) Am Fr., 9. Nov. 2018 um 10:36 Uhr schrieb Peter Stephenson < p.stephenson@samsung.com>: > On Thu, 2018-11-08 at 23:53 +0100, Dominik Ritter wrote: > > I want to use read one of two files, regardless if it exists or not. My > > first approach is to use the alternative glob syntax, but with no luck: > > $(< ./(a|b)(N)) > > That's a special syntax, expecting a single file so that it doesn't try > to do globbing. > > You can get it to work with > > $(cat <./(a|b)(N)) > > pws > > --00000000000008d9b9057a3c4ceb--