From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: from zero.zsh.org (zero.zsh.org [IPv6:2a02:898:31:0:48:4558:7a:7368]) by inbox.vuxu.org (Postfix) with ESMTP id 0FF8721801 for ; Thu, 2 May 2024 18:04:51 +0200 (CEST) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1714665891; b=IFkT8hp0GUR0n+wjNcenk5qP8svOLhFHM1eOYiAgk8xwFJnZSrugcVVO4G6pS4SxqaVh6wIgTd EciEvUa9GyzB20/zfDcTwuU+MsdZnnTG3zEqT0DJkt9j+v1OedbFBOqc6b0HsGOfdxUir96LDF orVHbIwhL71IdkscWQem5fULlm7UP7o+BRXJHi9pnRnU7TuK4nLxRUc3Rfr+Cdv7nsHyHqtNmG 4XvF5LX05psFCDcUkaafdVPxzXevi4wPa1j0lDlarhWq80Hpd8GNmCB3f3pl2s6Nhn10ZMRSu/ 2cg/j4FQEXsNIzkX7uSyznZAM82v/HGTdcbwmgVE190LFw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ej1-f43.google.com) smtp.remote-ip=209.85.218.43; dkim=pass header.d=brasslantern-com.20230601.gappssmtp.com header.s=20230601 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1714665891; bh=1U14L7ewdPPzuiplzCf5DKWwTeAQzQoxb97fsPUuq24=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:To:Subject:Message-ID: Date:From:In-Reply-To:References:MIME-Version:DKIM-Signature:DKIM-Signature; b=XZ9VYFE4PFVgXwbjvJKx/zf3Q2z0ou8gaJ9wsFzkIrFszBxBg3lk1DEpqSZDrykDa1GDcdj4u3 /bGAhiPrGASZt/A3pr/w/d8KkkLgJq+6l6GHFT/cm5SVnwU6EFm3dlY3+twsAESe9sWaIp+ye/ W88k9RDMnq5LKjiUlY6iaofqdEQ3UKpLO0fHSCxVWryJ/2zxk6fSfTTU0GnoU1R4J4uLPNwhme +EEraZGtqzxjnAhMBlee4LX0U6Up+ciqgBo36rdG1wUKBrut5fT3CwD3m73aCL+oA23/S5MbUL ae3ahJ57ps8HbpcoChfWMRxE+NCnFpYS/SlQ41lS+UyOog==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: Content-Type:To:Subject:Message-ID:Date:From:In-Reply-To:References: MIME-Version:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=AEGHRUJLMBAGtzGfDiE/x0Idu+NdoZtzhlkOwQQw5mg=; b=oFGRmHzrSIu9a6Hrjf/rB7B/Fq usfvwav3aNcurMUj3eStUj+D3Ma4DYV4pdt3RGyWggCflb6TvRg8wF0SE0lVBFbtcMm5zCFgk3za4 WFB8G4N9W16DsbGwrqlm3fvFjtyPpDMfb1vW5jsRHcknffCcDW4Sgvc/6xkcCgqxldX7NCw8qvvUF S7Wc2IiX9KwOUOZyWNX2vpQRtaz9hl8npp+zXvBba7D+eAuNgk1CSkaipp0ZAtL0DG42O4MR00xwa W7kmEnmM80TM9WQhUOvfqi8FbiItwuNLzA4uy5d9TZXKRHL109sFM/4X7b/imTx8JspiiusUhHYK8 JBPLEDrA==; Received: by zero.zsh.org with local id 1s2YvR-0009J3-Tt; Thu, 02 May 2024 16:04:50 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ej1-f43.google.com) smtp.remote-ip=209.85.218.43; dkim=pass header.d=brasslantern-com.20230601.gappssmtp.com header.s=20230601 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-ej1-f43.google.com ([209.85.218.43]:58799) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1s2YuC-0008W1-2G; Thu, 02 May 2024 16:03:34 +0000 Received: by mail-ej1-f43.google.com with SMTP id a640c23a62f3a-a5200afe39eso953291766b.1 for ; Thu, 02 May 2024 09:03:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20230601.gappssmtp.com; s=20230601; t=1714665811; x=1715270611; darn=zsh.org; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=AEGHRUJLMBAGtzGfDiE/x0Idu+NdoZtzhlkOwQQw5mg=; b=paPVCqsiBRtBi7J8vJfzNkS88u8e/e06CICNLePpUsH8flgQ9r9DJpwCAp86plMIf5 mBk0fk4laU5jERI4A8g9b8s2edArvWEL4oFC0IH6cQRvEhxKPxRevNMmgn6wy3QUin5C dEr59HQWJrUh1BF/14OJAIxnR7fG+nMvsPBEqMGEb4krSW6Z39OwndT3hu+BWrJ6j1T2 ptsqMtvQsaL0M5kmaLM6BnEit2Jt5pZk4b0foNdPCSvUc4bBckylGnbTtr1vJfx4gUyN 4y6VL7g9AbG+3Z45GSKTP0aI/Jl7FQtF2lKiKV1z7pjoMnehys/ES4L+RwrUdkcCrkOC VHjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714665811; x=1715270611; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AEGHRUJLMBAGtzGfDiE/x0Idu+NdoZtzhlkOwQQw5mg=; b=jK1m4ynuF2ZDErQNwB833Apn+RwBwWmKRLGVXbw/Evf9sTnpOdT6KuLIK5et+dpbNC WVtr7G6hA3/PvrtNQiWiFiNjC/w4LECofACnGGtDO3wN9VMU0ZpjOVCra4eq9QWM0qrR u4gMaJxohAhhuQugVGVlgVZfk4IVj4YjHPpPZb27RZBiTRsc2qRUV1EfDHQ0Hg1hw1g1 b/805R/u6PRhKwUb3T+k2DFNquxHtbb+eweQK67dE0CZw6PTeTgpteToxHkBk4esqvno Ho/2ma+fyXmY3xujgjaAP404hqz9xk7NNdmK+Kvhu8KVQvIbKyhmTZwJPxEKvmL01XQj yYSA== X-Gm-Message-State: AOJu0YzScx2s1HYSDXbOFPGRskjU5f/uV39uHLRbPeeqK2STjoFMbggf 7I/3X30zPu4oSJcm3gXElkNS3uP6ejNHZIobf51YAk+U4Rr08VaZzrNIIZg4P57feMxUWUAhoF3 FufByHqZQZYPR0kg/0pQRlHZVjOPApW2d8a9rUWdx9NwnE3K3BA== X-Google-Smtp-Source: AGHT+IFpqzGqboo6zfiDVcG0YHtK3CqvFaJBLrOBesU1TmDmW/ZVgGNC1AqWzjZK8RTmD63NZVLn4ms/Wns31L9WeGs= X-Received: by 2002:a17:906:ca04:b0:a58:a2f9:d795 with SMTP id jt4-20020a170906ca0400b00a58a2f9d795mr2155852ejb.59.1714665811107; Thu, 02 May 2024 09:03:31 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Bart Schaefer Date: Thu, 2 May 2024 09:03:19 -0700 Message-ID: Subject: Re: A way to find a bug (or explain a missuse of) realpath expansion? To: Zsh Users Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 29868 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: On Thu, May 2, 2024 at 1:06=E2=80=AFAM Marc Chantreux wrote= : > > On Tue, Apr 30, 2024 at 08:43:51PM -0700, Bart Schaefer wrote: > > > The /usr shade of path will disapear from debian distribution > > Can you provide a reference for this? Web search is clogged with > > reports of accidental deletions of the /usr tree, etc. > > https://lists.debian.org/debian-devel-announce/2023/10/msg00003.h= tml > https://wiki.debian.org/UsrMerge Ah, I must have misunderstood "shade of path will disappear". > > You're trying to use a glob qualifier form (:A) but you're not doing > > globbing, you're doing parameter expansion. > > I was globing to remove non-existing directories. What I meant was, syntactically, globbing does not occur in the order that you think it did here: ${(u):-${foo%/}(:A)} That is, the stuff to the right of :- in that expression is not globbed until after the entire parameter expansion is resolved, so the (u) flag does not "see" the result of globbing, it just sees /usr/bin /bin(:A) and does nothing useful with it. Note also that (:A) has been appended to the entire $foo expansion, not to each element of the array $foo, so even once you get to the globbing step only /bin has realpath applied to it -- the result would be different for the reversed order foo=3D( {,/usr}/bin ) There's no way to embed filename generation (globbing) inside a ${param} expansion without using an intermediate command substitution. The three $-prefixed forms of expansion -- parameter ${var}, command $(cmd), and arithmetic $((expr)) -- are processed "together" left-to-right and inside-out, but the other five -- history, process, brace, tilde, and globbing -- are strictly independent. (The Expansion introduction could be more explicit about this.) > But let's say it wasn't intentional: don't you think the result is > flawed anyway? I mean: I don't understand how the same expansion on > 2 identical elements of the list can lead to 2 different results. In your attempt to work this out step-by-step you have foo=3D( $foo(:A) ) ; print -l ">>>> realpath" $foo but there again $foo(:A) is /usr/bin /usr/bin /bin /bin(:A) What you wanted was foo=3D( $^foo(:A) ) to get /usr/bin(:A) /usr/bin(:A) /bin(:A) /bin(:A) Conversely, ${foo:A} is one step (parameter expansion) rather than two (parameter, then glob) so realpath is "automatically" applied to every element of the array. Does that explain it? You could have removed all the non-existing directories earlier in the process, like this: foo=3D( {/usr,}/bin{,/}(/N) ) ; print -l ">>>> setting foo" $foo That attaches the (/N) -- match directories, discard non-matches -- to the brace expansion, yielding (before globbing) /usr/bin(/N) /usr/bin(/N) /bin(/N) /bin(/N) In fact you could do the entire process right there: typeset -aU foo=3D( {/usr,}/bin{,/}(/N:A) ) print -l $foo "Create an array foo of unique elements and assign the realpaths of the existing directories in the set /usr/bin /bin /usr/bin/ /bin/" > [...] so the underlining > question of my precedent mail was: "is the code of zsh easy to dive in"? I would have to say it's not, at least for what you're trying to accomplish here.