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 7A86122641 for ; Thu, 21 Mar 2024 11:28:37 +0100 (CET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1711016917; b=aTk986q+2mWx2wLoN8XBUW6dtUz3tL70l+yVVV9S+H+XqFzSQNi7ZQEEz71/t0CTwpZF85ff1X V1sTAeRP4f0snseAvH1qDNvJwcgHZ5imr1lDG7qk/255U58bzsQPLfqV26eRMq5P0PqrInD+to nZpWcGt0S+msEjq+UWN4zESNGVSX8tFYGaZtD0Y7kU8uqLamjdjnbCEmLPRQuXIC/RbpJ5jcr0 3Tet6klrsDhXWttfMR/knES1mZp49u9Pa5nG9e84L62moTZ8JUwOxQrclnqje7nkWhIV6UNtEp fiAwTV7ld/NYmoleb/FUxAryiyEPlZpdhQYcTV3wTBqogA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (csmtpq3-prd-nl1-vmo.edge.unified.services) smtp.remote-ip=84.116.50.34; 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=1711016917; bh=v5+qx5HmmK3Gt0MtoBEAEl7YvUOvTR7Jw50U/OdsHxk=; 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=fTllBu5vggIcdqQOBoRw80z/wTNf0FGXyP0uQ+ScH1azkpDQcs9FWhDx0r10GHD1b9bFRH5tj2 MQ2e0ix/ARdvrs0JLbUx0m02nR9exHQRpSjyDj4ft/ESR6hifuhIAXwi1EBPTLsbrwNfFXXgAp HFoNNZE6DrBrZgFrT5JvsqJjsmR6ZyFGkJ5oAs032BUenaSruLe+Si4vqs45cSz4mJDfMkIDyO DvsBle/CqMi10/MBALQKYuVbIRA7P/iw0V9o0diDLbuwvaUnr18YVZS2zAtRvxZRt3x+QMM0V9 XN3I2hX2quikT/0GTl/ksfLC3hJG65q2yRWriuLV9da3tw==; 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=Qc81/h7UwYkhFkPNL7xzJLDfTHPSKS6OrzikctfDqOM=; b=rkLiA2UwJnL67E6R/F0pBhh+yl ULYUiHKCH4b7BqVWQcsy8Lc9ST8Vc2Ll2GHIW8F/DnAkvbxGPqUvNf2waujdxq+vLzIcG/shLrAom Cr3G56PHqMUOEanLaxxOMBZQWl1HrDW9Yy4fXmQkCqTVcAa8S0/9vGjtqVP/iTIwllwGFdnpMgToC Ippyx25JGvLWvDsrb8hRr7zvCZKRnTTJUF5wNrPGLPdWp93rUpgF9HDD4n9uCM8hH5xxMw6LI7TPs QzMwRH04KJDVlLYYywv9nZ5aAB1v3fubam+ryxf+FMKCrJT4BKjL68A7Yktj/M+g5JN9Jr0pvk0e6 aLebyHtQ==; Received: by zero.zsh.org with local id 1rnFf3-0002tK-Ir; Thu, 21 Mar 2024 10:28:37 +0000 Authentication-Results: zsh.org; iprev=pass (csmtpq3-prd-nl1-vmo.edge.unified.services) smtp.remote-ip=84.116.50.34; dkim=pass header.d=ntlworld.com header.s=meg.feb2017 header.a=rsa-sha256; dmarc=pass header.from=ntlworld.com; arc=none Received: from csmtpq3-prd-nl1-vmo.edge.unified.services ([84.116.50.34]:35619) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1rnFek-0002YT-TV; Thu, 21 Mar 2024 10:28:19 +0000 Received: from oxsmtp3-prd-nl1-vmo.nl1.unified.services ([100.107.83.172]) by csmtpq3-prd-nl1-vmo.edge.unified.services with esmtp (Exim 4.93) (envelope-from ) id 1rnFei-005POE-Ts for zsh-workers@zsh.org; Thu, 21 Mar 2024 11:28:16 +0100 Received: from oxbe7-prd-nl1-vmo.nl1.unified.services ([100.107.83.73]) by oxsmtp3-prd-nl1-vmo.nl1.unified.services with ESMTP id nFeirzVh6bL25nFeiriiyo; Thu, 21 Mar 2024 11:28:16 +0100 X-Env-Mailfrom: p.w.stephenson@ntlworld.com X-Env-Rcptto: zsh-workers@zsh.org X-SourceIP: 100.107.83.73 X-CNFS-Analysis: v=2.4 cv=Yv0JRZYX c=1 sm=1 tr=0 ts=65fc0bc0 cx=a_exe a=jnKRRUzikw9eUPzUDcVRDw==:117 a=IvlwODmuRu4A:10 a=IkcTkHD0fZMA:10 a=YR4_K0clAAAA:8 a=6pz3t0lqA0H5QgaSLBMA: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=1711016896; bh=v5+qx5HmmK3Gt0MtoBEAEl7YvUOvTR7Jw50U/OdsHxk=; h=Date:From:To:In-Reply-To:References:Subject; b=5uXtVsbv2La+wyb3Bh4NNsQwOpNPaPgUX/aBGZM7YOpZNa2ERWCWPgW//zDaKbDMB mvpzmKE4ZaZ0mOw4XdpWrsKTj3dhPVWVEs7Su6h62l1bV1xkhRKNRApFuZZnuvRSOh WoBnXL5Sihq5M8B8vR7Y4jNeCeCB4yMLZclWMzdoX6EbqFX+ukq3frBFk5Pgf6TUBU YmEr/SqdJi6DwAL1OvaktZ6VNj9hcm56aDzSA2BQWOVxCAcCJa1JlGMBTe6S8Wrwtz f0zhbxd88qkL0oLtCNobGycJAYDw9CdBedWMFQEVYBPyQUwuo5Rmu69iRpdOjFL+dY vQQcZJl0GAZLw== Date: Thu, 21 Mar 2024 10:28:16 +0000 (GMT) From: Peter Stephenson To: zsh-workers@zsh.org Message-ID: <1443395979.5911218.1711016896863@mail.virginmedia.com> In-Reply-To: <20240321100710.GA164665@qaa.vinc17.org> References: <20240321100710.GA164665@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: MS4xfFO3LcXvoWnDElSbNodBWjEf8xAMHAwP66uK4QXzG1UrwC0jCLGnTTJpQA5j/iy97tylXL7/YLRSRfJl5BxKjwcyhUEmOcBFzK4woHM6nD7beWS9vTP7 ZYbD3Ci0t9xQh6M4Qw4zS16v0okndkBuYWKoSgetNeNPvbiHQ4dtPBaywWVJ7l7Jzq9X+N8X6tqcdz5KZBNtl3LAd5TJOE3+soVHosWyZ+2xPxtVnzWWCwBh X-Seq: 52790 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 10:07 GMT Vincent Lefevre wrote: > I know that the "test" utility (builtin in zsh) is ambiguous, > is not completely specified by POSIX and should not be used, > but IMHO, it should behave in a sensible and consistent way. > > The following with zsh 5.9 is inconsistent: > > qaa% test \( ! -a \) ; echo $? > 1 > qaa% test true -a \( ! -a \) ; echo $? > test: argument expected > 2 As you can imagine, trying to put some order on the ill-defined mess here tends to mean moving the problems around rather than fixing them. 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. pws