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_AU,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 99F0025B1E for ; Tue, 30 Apr 2024 16:12:38 +0200 (CEST) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1714486358; b=EQUoECG4NTZwzeq3j6cCKYX2xu36JL9OAn+C1FABQu2oybKRP3W0AOAhkB9VxBxx0CQUuDHAMV /n/H9E7HC4kUNNJIU92oS3oH96cUkFvUAKHT/dpDLfJSrNmw2JKzQhlz4S/GXyqQForeu/I8Zk 6vt2SGqgDbgKuVEluN3JDjeTc722MMrXBtTeFbaGNvWLNH6jtsMIYBexS1OfTvBxNHi55XkLLD FruKKbYXdBL04ikfFEroNhZVSqdHspX/JCfT29Tn2j7VEXic+XO12PGPZNnW/tUtrzLHcZ0AAv +FG1MhNrirhUQo8YnsFlHy38gVMvygBN4uMkckEt5VjMYg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mout.gmx.net) smtp.remote-ip=212.227.15.19; dkim=pass header.d=gmx.com header.i=llua@gmx.com header.s=s31663417 header.a=rsa-sha256; dmarc=pass header.from=gmx.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1714486358; bh=NlF9tujzr1t1+JBhQu8Pe04MBleD2WY9e7a6YvEpX7o=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:To:Subject:MIME-Version:Date:Message-ID:DKIM-Signature: DKIM-Signature; b=blRpHXLHzchOZ2PgR101mFDcPnUysAuibnb/Pmkj/3K9iyi7HQfkT0zfejxIkc0S53AuVqacU3 SGldDzUo7gqpYc4swXo/yvOoXmE8e0i9ekQdnGQC+IMhlrrHPV5caVczNU6DOsRNHfqlFGuXKL EjbJMe3UU7KhsrRoxWxMF5m3Ca35RMyAfkFBxNGtYsPiP9OdeuZYaCENv+msF0Th40kaXjXts8 g2M4HjIProdSRz3wi7SqlTKKHVnwnAjU7McxfzBIzr/G0/MLX7Bv9CWXHil0SV8mW0qbBCOcVF OEcTDfZm2vLe5zJMAGjOFTNbWk95GOd8uRfAPvje5YUPow==; 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:In-Reply-To:From:References:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=Q+U9K7nqq/HPjD41EItV4rY8Mb3dVY9Yg/rnYg0hOgs=; b=INObYbRymBGqkSCx6nf8fDiM4C rFqnE+A7N8TcjrzezHc3j6xSPJiwn1d7X2VHDK+a84vBvJr3aaN6fH+xpWcsKnNZEDUEqUpsFAipM zfGiHMTO9+qx3PDC4Tc5AQSOSrpJWoRbT/avLND8+MX4/e9QmanSDvNw5KsyyqEJJEgopvN5Tg1U/ pndwJAgclpgVUmkpl09PCBacZ7kLyr5B8tqTG4aHAzLlx0w9yMORKy7jLd4ihrzLX0xYQPvxsZd5i 1nGIaSUkb17yWJLQ9vMZGm7o6cOT9XD4pw5E7QXxohtHldiSZygdlD8H0ZQK2q22imRyixxwQVAQI 9gFoAFbg==; Received: by zero.zsh.org with local id 1s1oDm-0004iH-9l; Tue, 30 Apr 2024 14:12:38 +0000 Authentication-Results: zsh.org; iprev=pass (mout.gmx.net) smtp.remote-ip=212.227.15.19; dkim=pass header.d=gmx.com header.i=llua@gmx.com header.s=s31663417 header.a=rsa-sha256; dmarc=pass header.from=gmx.com; arc=none Received: from mout.gmx.net ([212.227.15.19]:41213) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1s1oCw-0003zM-Ez; Tue, 30 Apr 2024 14:11:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.com; s=s31663417; t=1714486305; x=1715091105; i=llua@gmx.com; bh=Q+U9K7nqq/HPjD41EItV4rY8Mb3dVY9Yg/rnYg0hOgs=; h=X-UI-Sender-Class:Message-ID:Date:MIME-Version:Subject:To: References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=iWJ15o4HX8uoFEBoMQAVpTDVt+uVsOeT0pFvTYrcHHws+saerlUBTRLlkyLFJJrf SV767+KtIi0qosY3/vkbtrH/8VlvrNBw8KCg0cYk375DDe37wgxYiZyNvz4S84N4G AeHt+PNc3sh0IYOp8VCIYK0MRUrgcX1TK1uWPO3tQ08Cyoho6M4PgN88DITmGL2gd KzIvyW7rFlAh8ncenfcNZFIj9AVGndP88eTJEddDtZIXovoiVOfH7FMH6ZToQS7HA F+R1s2TCLYrVYkG2EGHbVe19Y/7K7dbu9dNTmz8Z2LPX5JLCrW6P6/ey1JbYzR9ay fs+Ch+E/dKJXqHsdEw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [10.0.0.14] ([67.177.154.237]) by mail.gmx.net (mrgmx004 [212.227.17.184]) with ESMTPSA (Nemesis) id 1MmDEg-1sS2Gv0Z0K-00k2So for ; Tue, 30 Apr 2024 16:11:45 +0200 Message-ID: Date: Tue, 30 Apr 2024 10:11:44 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Inconsistent behavior with comparisons and recursive glob patterns Content-Language: en-US To: zsh-users@zsh.org References: From: Eric Cook In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:OD7bPTjKCFtTgVLtQHc5dzT5+IDxYUd4Zj0FYPGvf59MfJWe0yR uyTLAmJlrwGnu12ZRf8LxnzvCa3MjbOly3UJloEDY7bz47U0Wevelw2pdPwoFfgZW0ui8PX m1RgZuHNB9nKxB7flDPaJ+msbF9OkXsFz7UDoqS8Fu7t4OIZ9zBGqyR4FGHTgRyWoYf8M7d JLHFBenIhXduJQmlvTavw== UI-OutboundReport: notjunk:1;M01:P0:BDxbGnI8S/w=;VspySuCpqyM2oEpewFJbN4SnOkw TsGQFoEOft/fx/9WVsa4mAHVNeCfkTzgSKWSgEDXOrHDFUVeOGzNphOci9YXwRfMQgueVeyL7 hwfR70Ncg8EAQxLsLqNCQ5af1X5W+7apeDUEyieOUti7b+8GdBV45xbxFpGcIvxIeeRk6fkKe sRolUkY0m2WInrMOj3q53hj2XfDnweqsGfwM6H/S4ogZ97d21tfc+ol+uhEfu8tfwcgwCGcp9 sKByLWJq4Un4x/6lNZqxNx1Ht7dPySf4pGGyhv8VSFqzpCZPeVq3FJm5rJCMM+mCBYiJFh7Lc rHdMJXJgxdykziyC+nUw8JTVDemAInSlhRv1rzPJ71MpGMXJm35ThZcnElVC2dOse5ITSMrUj I23dxpemguGDWKNqW/MSzrgS0HPZPXgIQdM2ZnoPJz6R81B+xKMkUkY5EnHpxSW+ptQYp5sNN 7pzLOAnYjeOtwg6UKWS3wZgGYex3OAQ4IYYfkaumTtYd252n4peIW4gZuBNkwra/pZc0WMX77 rT/JTI2pUGZeMP2iSj3KAkAcY4I8/1zyd95l891hzMSUiTDP/RjiyP4NOCMDaLLvfhBDiaKve etBBrAvw5K6Jaqy0+9wFA3O3B0dA8E5+M7tolQS3rs4oAwlRozyce0zlc1031r5Nb8hILRF0B 4lOaE4Bk7UaosWH/H38kqhyn1/3cVilkoVIkr+qBf7wQ15Juec+PJCet98mJ+453p+soMQwKH ggr2Tvmi+ODZ8S/p7BY7ShLVDgUxyuGFuA6v0HTheY9/qyCTGDMNrEYS3NPPG5VIKplvVbH02 kUiY5tkLXG1tkEzhgEROierizStdUFYMYGqRGFuR/IqrA= X-Seq: 29864 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 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 ther= e is no special behaviour of =E2=80=98/' nor initial dots, and no glob qualifie= rs are al=E2=80=90 lowed. ``` That last bit about glob qualifiers is out of date since you can now use t= hem to force filename generation on in [[. but the point is you aren't doing file= name generation in [[ (by default), which is where **/ is shorthand for (*/)#. pattern matching/globbing is tightly coupled to filename generation in uni= x 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 would= 've underwent filename generation before the comparison that [['s =3D/=3D=3D d= oes. % (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 t= he reasoning is similar.