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 f5d21a8a for ; Wed, 10 Jul 2019 13:59:27 +0000 (UTC) Received: (qmail 25359 invoked by alias); 10 Jul 2019 13:59:19 -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: 24038 Received: (qmail 12026 invoked by uid 1010); 10 Jul 2019 13:59:19 -0000 X-Qmail-Scanner-Diagnostics: from mail-vk1-f176.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.101.2/25503. spamassassin: 3.4.2. Clear:RC:0(209.85.221.176):SA:0(-0.7/5.0):. Processed in 1.963287 secs); 10 Jul 2019 13:59:19 -0000 X-Envelope-From: pierpaolog@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.221.176 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=QRTPEzIGH8zC8SmTzvEYlWgcnA6Za5wx7+brT1lbSIY=; b=aQN413hRRc7EpyON7bSyWIPNwBxItxSjd5TQc5EJolMLU0HQi7BR4xxfqTroxQUZXP tLyFgWOpS+u8RQTgVHw3ufzFkZxsbv8mXIaEF2ie6eRkW6uWJWWkuGFrrmZeV0eAUH0T Pbw0cB6Swks5NKE2E8twQncRE3y2H94GWlRfRdNCyc/9lZljS/EDIePvcQ6FodNYUbqN M5wj0dvIsEVZ2uaVhJyoNjKz1Yj8Kzboxx5ZfM3fC3rW30SoRej4oT/xiIRu+rc7sNDh aRu4b4gIj6dROCUeSteZyTz9+0LRxwIt6UEpTl4wctzoSpZIkpWD20WkNynBoTcEP4By N0FQ== 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; bh=QRTPEzIGH8zC8SmTzvEYlWgcnA6Za5wx7+brT1lbSIY=; b=i6/04yzP5zKEqltb2m+tY/Vuq3giu75dn3Xumx5yPGPiJwPB5UFVdipWNZ0HVNNr77 LeikVrTASboDAI1nkpa9q/4AQor71W54O8Ps3Wtl10bC2+LORSAVzgVzNutpws0XrhO/ IngB11ScujAjr4B8TVqi9ganb7cKOLg+W80zd/AU4mowVjLw928oj5gbxn8cio7GatiA 7U7/glCI/cvsSoPhonuKTA8DZROblFO2P1B0GLOfvjpiASxpvwaVT6mVa0VCZ6KDT6kO HHq27sWIdbXpes0RBtCO1NEDJ9QXWn5Rw2NvQvTN/H44FrA1VNqZSsOf4nYH51OCgrqK paBw== X-Gm-Message-State: APjAAAXF5vU6cTbdNFiHEOo/sRpTbjyK358me2f5m3S4Iqjtn0NP850A D8LRwdHONKMcTuHJVuiNtK58gaaZn3mTQL07+TKqm96P X-Google-Smtp-Source: APXvYqxnGlkhjT52/N/U13aZbms1gSe84VkTpuka4bKSg6MwnD6fCtz3bkrVzYl0V/FuRSuTkv/62qiW3qqU6vnz1i8= X-Received: by 2002:a1f:dd47:: with SMTP id u68mr6794902vkg.22.1562767122986; Wed, 10 Jul 2019 06:58:42 -0700 (PDT) MIME-Version: 1.0 References: <20190710133731.GA13596@cventin.lip.ens-lyon.fr> In-Reply-To: <20190710133731.GA13596@cventin.lip.ens-lyon.fr> From: Pier Paolo Grassi Date: Wed, 10 Jul 2019 15:58:05 +0200 Message-ID: Subject: Re: glob qualifier on intermediate directory / no symbolic links To: Zsh-Users List Content-Type: multipart/alternative; boundary="0000000000003b7a9d058d5413ed" --0000000000003b7a9d058d5413ed Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable you can do something like this: setopt NULL_GLOB typeset -a arr=3D(*(^@)) ls ${^arr}/file but I'm curious if there is any solution that doesn't require using an intermediate array Pier Paolo Grassi linkedin: https://www.linkedin.com/in/pier-paolo-grassi-19300217 founder: https://www.meetup.com/it-IT/Machine-Learning-TO Il giorno mer 10 lug 2019 alle ore 15:38 Vincent Lefevre ha scritto: > Is there a way to use a glob qualifier on an intermediate directory? > At least, avoid symbolic links from being followed. > > For instance, with: > > % mkdir -p dir/dir2 > % ln -s dir foo > % touch {dir,dir/dir2}/file > > With recursive globbing, one can choose whether or not to follow > symbolic links: > > % echo **/file > dir/dir2/file dir/file > > % echo ***/file > dir/dir2/file dir/file foo/dir2/file foo/file > > Without recursive globbing, * matches symbolic links: > > % echo */file > dir/file foo/file > > But what if I don't want to match symbolic links? > > At the end of a pattern, (^@) can be used: > > % echo * > dir foo > > % echo *(^@) > dir > > but not inside a pattern: > > % echo *(^@)/file > zsh: no matches found: *(^@)/file > > With EXTENDED_GLOB, I get both, like */file, because (...) is used > here for grouping, not for a glob qualifier. > > % setopt EXTENDED_GLOB > % echo *(^@)/file > dir/file foo/file > > I would have expected the following to work, but doesn't. > > % echo (*(^@))/file > dir/file foo/file > > The zshexpn(1) man page says: > > Glob Qualifiers > Patterns used for filename generation may end in a list of > qualifiers enclosed in parentheses. [...] > > What "patterns" means here is not clear. Above, one has > > (...) Matches the enclosed pattern. [...] > ^^^^^^^ > > but it seems that this is not a pattern that can have a glob qualifier. > I assume that except for the grouping exception and recursive globbing, > this is because patterns are mainly string operations until the list of > files before considering glob qualifiers is obtained. > > I'm wondering why the following is not accepted: > > % echo (*/)file > zsh: bad pattern: (*/)file > > I think that (pat/) without a following # should match a single > occurrence of pat/ (without following symbolic links, contrary > to the case without parentheses). > > -- > Vincent Lef=C3=A8vre - Web: > 100% accessible validated (X)HTML - Blog: > Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon) > --0000000000003b7a9d058d5413ed--