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 9E2DA22306 for ; Wed, 1 May 2024 09:56:43 +0200 (CEST) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1714550203; b=ood2wAmUgRbUZFHZN/j62FW7kAzUhFYbxRgX7CYhQdCgC4boS47pY6u0PjZDkXWqCgT0H2jC5d DVnyxpGmc1aFbX4BszsTU5MtzUvlyaFhAd+oW0sNu07fw4+Mn427XKYpvBP+w4L5NvR5etZ9gZ YYyZpwKXSBs5++6B58L2OM01nwX/PnxMs63TFn9xeSK+9XdmWU/jcZDyp9N7re1CAT70M0Expy BxaObplODKycrltZ8oppOMLQppaG22wNJ6buZxdKaMr8njqVbuH4ODcw2sW3TErmgHQzgJi2jy U5buNKPIK0okldp0bUou2WGeSB76BZvd8u9VR61myE9C4A==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-pj1-f47.google.com) smtp.remote-ip=209.85.216.47; dkim=pass header.d=awkwork-com.20230601.gappssmtp.com header.s=20230601 header.a=rsa-sha256; dmarc=none header.from=awkwork.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1714550203; bh=Kmxv10efNPovX4j/dAur78gCmy4dlktM+17rwI3kHUg=; 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=kToMjA/GHBXIscHPha+wcTN4eDztHBRUNP6ut+PqkgwHDec85jvw3o6IoczjmCMhmr//HPeke1 Qv1rk2/VI6OGsfO6ZEG5MreHT30AYGBDqvZmz52Ad134nRD9XCSWOu+SYcpy2aBNHfGIkE5iTi j7w5cdrHu6SlG4+vbkXGkGXY8HUNdz1Xa3Pxp+vffnU5TFEM/uXzfDEOGSeo9ERf3bGwAAon1s GhoEcqwtKHgnGJl3KDYiFoERujD39dwHY7GKkvoGJHQX9WqdrmmkFK4VV0Qt5to9jFh+Tnz6wo jIYzRfvjYcxaRs4sTxEvF7SGuhRf2CSc55btENN+iuFf+A==; 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=GZMySaCAGfmibr4SXx2rvU6PMryPUqAG8WuR+OfSd6g=; b=U/60hXWtEYQ3U2Z5oQbpWY2AEc VR7H1EogtKtjp+ogM02RsfXwhQMeoZKPSVHXi3nBh/p9L1/vYRolabZAFUr6bkJc2wEf9cryVMn6F aJ2JYYuuIK4/NCqjdkAll/0Gwr2q21+OJwWg+K7r92cQlg36WiXprRB/8Lqzd9PLhLUgQtX0De/my iva4CVLV5ZL/V3+JtaczuoIsgTXG3QkuTl7/r13z07rdG9LPwsuJi6FxeT/8Fa8FEBmHrX/Qz8iM0 1a8ahTMyHrca04RRbyMDy2CxZsu2FswL8GRgdUJMCdUuwxDXgIXMkzFiIngTXspyWfnBLS8XRW1NC yCR1005g==; Received: by zero.zsh.org with local id 1s24pW-0008Xy-U6; Wed, 01 May 2024 07:56:42 +0000 Authentication-Results: zsh.org; iprev=pass (mail-pj1-f47.google.com) smtp.remote-ip=209.85.216.47; dkim=pass header.d=awkwork-com.20230601.gappssmtp.com header.s=20230601 header.a=rsa-sha256; dmarc=none header.from=awkwork.com; arc=none Received: from mail-pj1-f47.google.com ([209.85.216.47]:59769) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1s24pD-0008F6-92; Wed, 01 May 2024 07:56:24 +0000 Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-2b24dbd1bb6so1562255a91.3 for ; Wed, 01 May 2024 00:56:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=awkwork-com.20230601.gappssmtp.com; s=20230601; t=1714550181; x=1715154981; 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=GZMySaCAGfmibr4SXx2rvU6PMryPUqAG8WuR+OfSd6g=; b=Tlrcxydjh2mXcDGjrPF//Pk1OUPtpRplTQBD4P0OQ406MZTxbIU86fcXQAMT0eKZPJ pwQS8kUU3G/ziaUqy576/iRu31734rnR7rG32u6ApVVHZztz0yitUNu4Cpo7Nq96z/kK 5UW9VdBIxPHURO/JrchPgDAZmom9QjLLeN5YI1Oe+t1CAv8zEZNS0NYL4ZOp1mhU/fku w7zcr03pwBs1mQ6b8vhPfhZuFO3RRIzCdDggqyvCly9vcWFzBoB8q7pgeisvTxuO2Fpj ZK3PpUG8OZGdEOkQsEw7B/79Wt19YWRpVDCya4Nb2dBNftYWR/asjP26MTa/S9rKqWTV DQmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714550181; x=1715154981; 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=GZMySaCAGfmibr4SXx2rvU6PMryPUqAG8WuR+OfSd6g=; b=G7RZcBItFYsOX70wG5p/GcGCE1Kxeto88OrjV15Mt1phKL5VugJqWWnGfQViTcMFlQ eqf9ZUCLq29ASnkRHrhJqmlaGhbNxiorO3tiikRktGq1uZd1aM5pKHYeDfRbbolrQgHt MmA7vsw/8CT0FyroT1Bl1zBmN4BPXqaBx9G3y+v57kbe8g/OdKpLA4u+eBLZJ3MtyvKE C8n8XbK4rwLxRWxipS075h+UAOSb6TTzLCLOyjsMHHIQVIFoY/NAQHDinuT38CrBrhwf RH6n2uAHSOB+zWudbhhuJiMHcFV+yhB3OfF4EAtO+S3JBCBrGjr3Dd/doBs+7tKeqFM8 iVQw== X-Forwarded-Encrypted: i=1; AJvYcCVS4UDm5WbowI14B6BMG5wyAI5hRcILG3Fu6Sn94dMeNdfvvDZPWYirdpYJ8SDZXnw7zw5hpNfwlBzYhWbiIe+7V0mj X-Gm-Message-State: AOJu0YwjVQUDpWCvMLk0MkStnI25qtzwLTgVwkaSf1hxxnWa+nGeuJse mbLnZH8AiYkNaabr1douTWbJftrCZ6CEAB9DzbHOgM6pwDxxZLjS8ahkIRu2qwexTG/C4mcmRfR 6b1RCiXr4rxB58HySs9vfrPndUiLMYpkjUfQG9w== X-Google-Smtp-Source: AGHT+IGURCg0n3jfjvcb9yvkz+Xl04K02UgXl05/DXyihVido+ZvMgPxWjq/DLGfQiyS+0LQ3hs5dUAOZ4ZedPO9LgQ= X-Received: by 2002:a17:90b:438f:b0:2b2:9fe9:d9a6 with SMTP id in15-20020a17090b438f00b002b29fe9d9a6mr1573913pjb.24.1714550181585; Wed, 01 May 2024 00:56:21 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Alan Wagner-Krankel Date: Wed, 1 May 2024 02:55:55 -0500 Message-ID: Subject: Re: Inconsistent behavior with comparisons and recursive glob patterns To: Eric Cook , zsh-workers@zsh.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 52911 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: Thanks - I did miss that **/ wasn't supported in conditional expressions. I wonder if there might be some value in making that explicit in the documentation, possibly by changing the paragraph you referenced to something like this: Pattern metacharacters are active for the pattern arguments. The patter= ns are the same as those used for filename generation, see zshexpn(1), but there is no special behaviour of `/' nor initial dots, shorthand operat= ors such as **/ are not converted to their expanded forms, and glob qualifi= ers are only allowed for forcing filenames to be generated as described abo= ve. There's a slight issue that "such as **/" implies there are many shorthand operators; I have no idea if there are any others besides **/ and ***/. Thanks, Awk On Tue, Apr 30, 2024 at 9:11=E2=80=AFAM Eric Cook wrote: > > On 4/30/24 04:14, Alan Wagner-Krankel wrote: > > The results of these conditional expressions using recursive glob > > operators were unexpectedly different: > > > >> [[ f0 =3D **/f? ]] && print true || print false > > false > >> setopt extendedglob > >> [[ f0 =3D (*/)#f? ]] && print true || print false > > true > > A couple things about [[: > > ``` > Pattern metacharacters are active for the pattern arguments; the patterns= are > the same as those used for filename generation, see zshexpn(1), but the= re is > no special behaviour of =E2=80=98/' nor initial dots, and no glob qualifi= ers are al=E2=80=90 > lowed. > ``` > > That last bit about glob qualifiers is out of date since you can now use = them to > force filename generation on in [[. but the point is you aren't doing fil= ename > generation in [[ (by default), which is where **/ is shorthand for (*/)#. > pattern matching/globbing is tightly coupled to filename generation in un= ix shells > but there are difference. > > Even when you use a glob qualifier to force filename generation to happen= , you > still wasn't going to get the behavior you desired since the pattern woul= d've > underwent filename generation before the comparison that [['s =3D/=3D=3D = does. > > % (set -x; [[ f0 =3D **/f?(#qN) ]]; touch f2; [[ f0 =3D **/f?(#qN) ]]) > +zsh:3> [[ f0 =3D ]] > +zsh:3> touch f2 > +zsh:3> [[ f0 =3D f2 ]] > > > > > Since **/ is a shorthand version of (*/)#, it seems like they both > > should have returned 'true'. The comparisons behave the same when > > there is at least one directory in the path: > > > >> [[ d1/f1 =3D **/f? ]] && print true || print false > > true > >> setopt extendedglob > >> [[ d1/f1 =3D (*/)#f? ]] && print true || print false > > true > > > > I came across this because it affects the behavior of zmv, via a test > > that filters filenames (line 254 in zsh5.9). An example: > > > >> mkdir d1 d1/d2 > >> touch f0 d1/f1 d1/d2/f2 > >> print -rl -- **/f? > > d1/d2/f2 > > d1/f1 > > f0 > >> autoload zmv > >> zmv -n '**/f?' '$f.txt' > > mv -- d1/d2/f2 d1/d2/f2.txt > > mv -- d1/f1 d1/f1.txt > >> zmv -n '(*/)#f?' '$f.txt' > > mv -- d1/d2/f2 d1/d2/f2.txt > > mv -- d1/f1 d1/f1.txt > > mv -- f0 f0.txt > > > > I think both zmv calls should have attempted to update the 'f0' file > > in the base directory. Am I missing something? > > > > Thanks, > > Awk > > > I'll leave zmv's implementation for someone else to answer but i suspect = the reasoning is similar. >