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.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE 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 115B1215FB for ; Thu, 21 Mar 2024 12:30:21 +0100 (CET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1711020621; b=WxnG/7co+BNpLdjWaGmyNzmzashp6ZkjyFhB+XdOyf8HD7v61rDa4/ieqZeh6rTbEfb8YENXIb LJ0c+ymrZWJs7QbADnpLovW/tyDJfv/jFPqROb9HFOSYOYaop7ypG3aRsSqRm1vWlqwla1ItvN QZU0b4vQg3NRwHxt+fBrLOVuh4XY+AYxhzZliu464c2bdHESkOugFAD8u8h0MV1INhlMmWlB2B 5LZVVkSCuy3LrIV0iKmK7Ehajnf1+KcKojT5p+IWOxo+TdzMa5y+Om3pIExpVFIGC6XA5PG8YK ePZk4By12ICNwxHv1L7PnDyyOBQ8Ad4uEXDaSIyhzu55EQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (csmtpq4-prd-nl1-vmo.edge.unified.services) smtp.remote-ip=84.116.50.41; dkim=pass header.d=ntlworld.com header.s=meg.feb2017 header.a=rsa-sha256; dmarc=pass header.from=ntlworld.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1711020621; bh=6C3L9ZVVxmszirMjVhdNDyJQZr0kxVWp+yuN9XR07fM=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject: References:In-Reply-To:Message-ID:To:From:Date:DKIM-Signature: DKIM-Signature; b=d4WujIeYyHh8yRFCBJCwPxJaG86BJAhaEtiV681oJHyG0m1xIkwGL296/MeE6DIAoHt7EyXA1e LY2gG0j1Has+vGJTrvjQaGT3NyQVvYgJCVZbPJT989dYIBPTv95gfid//nOfod6p5gzhcrnQQe 4sNSSJN3hx+h0a68x6YotbAf91DOc5iIOlZWNH6LYNjoHQ7E/ZGWHtY597yBnRjJmkczkWp742 UHPIyB+k9bmLnRlMUBWEFR/LK3vcooA4gOA+1VrI00M2XpMa4VqCGZOnPTK3RVsJwXMlHkWBcR 3C1Eoo6wT7UT/U5aI/rymcWiX3vhM87W+jblopDg4RQEaw==; 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:MIME-Version:Subject:References:In-Reply-To:Message-ID:To:From: Date:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=SQa5r3+1jx+6aGfBlDi7v6uNjX+bLOjqZwlUZRYK0MU=; b=fwgx04oN/i44uuAnL4fde7+cDB jbiTk8YkUr8Ar40btRT7kjUwmwAjhZsiQ6UKkxvLbjuvUxypA1GAJBGjPwF0Dou4U56nsNcMczQfi 8KZOU3Zm1brTclRbcp+LHI/PBKui9LRc/KCHZFZRREVgf3nReZBQURRNyOImoKp3tDStwOjXHPMv0 BQ4jdEIg8TR3NJrn9fNwhNubykPcKwcB5neUMdQLSRZqei5ezH13//eMpb388AGNwiRSNBGaqf7CD 65rdvWJmts/3QwHBQuAOyiTiYNnnMn0JTIO02Zhfa56TOoaLlbd6OzynAU+nY3m0G1dNhC+l0OEPV WCNj2yQQ==; Received: by zero.zsh.org with local id 1rnGcn-0005cy-94; Thu, 21 Mar 2024 11:30:21 +0000 Authentication-Results: zsh.org; iprev=pass (csmtpq4-prd-nl1-vmo.edge.unified.services) smtp.remote-ip=84.116.50.41; dkim=pass header.d=ntlworld.com header.s=meg.feb2017 header.a=rsa-sha256; dmarc=pass header.from=ntlworld.com; arc=none Received: from csmtpq4-prd-nl1-vmo.edge.unified.services ([84.116.50.41]:59977) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1rnGc9-0005Gz-Hv; Thu, 21 Mar 2024 11:29:42 +0000 Received: from oxsmtp3-prd-nl1-vmo.nl1.unified.services ([100.107.83.172]) by csmtpq4-prd-nl1-vmo.edge.unified.services with esmtp (Exim 4.93) (envelope-from ) id 1rnGc7-002YQi-6z for zsh-workers@zsh.org; Thu, 21 Mar 2024 12:29:39 +0100 Received: from oxbe6-prd-nl1-vmo.nl1.unified.services ([100.107.83.10]) by oxsmtp3-prd-nl1-vmo.nl1.unified.services with ESMTP id nGc7rzbLGbL25nGc7rinua; Thu, 21 Mar 2024 12:29:39 +0100 X-Env-Mailfrom: p.w.stephenson@ntlworld.com X-Env-Rcptto: zsh-workers@zsh.org X-SourceIP: 100.107.83.10 X-CNFS-Analysis: v=2.4 cv=Yv0JRZYX c=1 sm=1 tr=0 ts=65fc1a23 cx=a_exe a=BaxG2yfOxHMHApbdv9TgGQ==:117 a=IvlwODmuRu4A:10 a=IkcTkHD0fZMA:10 a=YR4_K0clAAAA:8 a=huW3PpitgisJ4D4XAzMA:9 a=QEXdDO2ut3YA:10 a=HbQOABYz3jhqdZF7JfnK:22 a=waMAY2KAzxQUlx2gRwsv:22 X-Authenticated-Sender: p.w.stephenson@ntlworld.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ntlworld.com; s=meg.feb2017; t=1711020579; bh=6C3L9ZVVxmszirMjVhdNDyJQZr0kxVWp+yuN9XR07fM=; h=Date:From:To:In-Reply-To:References:Subject; b=gEz6gelsScRSsqvpPMWui+KXvkCwt86jNTXBrDumzn52RH04QJCeHps4KNTAyQY61 hniYXWXCOwJKuoKHAXdC5OR9ASuIOlyDF0Xkq7j4uFn7QdpEMu8kCxnk/mGkP0xJMM Zuiub1u7rylYSwigMn7iV9Gz9dijyEYS3j37PaDooqyXsMnvNczBDvhijXNjCRESJh ma7/nC90JyEZMoI+QD+5jpIsnKlKyRwA5fa8aph1p3v8OHg11+g2Wvo23c8X9wX9hh /bPYZVtEsAOLgQcyXqxlOZNc52DGbHCbhYhXZQPLXKmUzW3Hrl3DFrKUcAfUPNLW29 QvYiWkDiymiRg== Date: Thu, 21 Mar 2024 11:29:39 +0000 (GMT) From: Peter Stephenson To: zsh-workers@zsh.org Message-ID: <1507569659.5899391.1711020579178@mail.virginmedia.com> In-Reply-To: <20240321110444.GC164665@qaa.vinc17.org> References: <20240321100710.GA164665@qaa.vinc17.org> <1443395979.5911218.1711016896863@mail.virginmedia.com> <20240321110444.GC164665@qaa.vinc17.org> Subject: Re: behavior of test true -a \( ! -a \) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Priority: 3 Importance: Normal X-Mailer: Open-Xchange Mailer X-Originating-IP: 147.161.224.196 X-Originating-Client: open-xchange-appsuite X-CMAE-Envelope: MS4xfPoEqJGoVA79iA6GnCd2rR1mAZss3/zrdwvCNaMl1yUMQOSC/2brXBTjigrFGOzx7HhgHl5jXIVb1LdO75kyEYnkjOlBHxrtwSjSZgGnLpNefEfuk1gJ TndMYDFeL23YQg3NoQU8UiQJW4/thd0LV/+Xm25zcXcbZnn/HgZuZrlW4WWSUHk67aL4pfkoqNntfalNZ+DoC7WS0Yu+iZisDdDrQo0l2Ax1Ido9gnnxh0Xq X-Seq: 52792 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: > On 21/03/2024 11:04 GMT Vincent Lefevre wrote: > On 2024-03-21 10:28:16 +0000, Peter Stephenson wrote: > > I haven't had time to go through this completely but I think somewhere > > near the root of the issue is this chunk in par_cond_2(), encountered at > > the opint we get to the "!": > > > > if (tok == BANG) { > > /* > > * In "test" compatibility mode, "! -a ..." and "! -o ..." > > * are treated as "[string] [and] ..." and "[string] [or] ...". > > */ > > if (!(n_testargs > 2 && (check_cond(*testargs, "a") || > > check_cond(*testargs, "o")))) > > { > > condlex(); > > ecadd(WCB_COND(COND_NOT, 0)); > > return par_cond_2(); > > } > > } > > > > in which case it needs yet more logic to decide why we shouldn't treat ! > > -a as a string followed by a logical "and" in this case. To be clear, > > obviously *I* can see why you want that, the question is teaching the > > code without confusing it further. > > Perhaps follow the coreutils logic. What matters is that if there is > a "(" argument, it tries to look at a matching ")" argument among the > following 3 arguments. So, for instance, if it can see > > ( arg2 arg3 ) > > (possibly with other arguments after the closing parenthesis[*]), it > will apply the POSIX test on 4 arguments. > > [*] which can make sense if the 5th argument is -a or -o. I suppose as long as we only look for ")" when we know there's one to match we can probably get away with it without being too clever. If there's a ")" that logically needs to be treated as a string following a "(" we're stuck but I think that's fair game. Something simple like: if we find a (, look for a matching ), so blindly count intervening ('s and )'s regardless of where they occur, and then NULL out the matching ) temporarily until we've parsed the expression inside. If we don't find a matching one treat the ( as as a string. pws