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,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 3A5FB215B8 for ; Thu, 21 Mar 2024 13:18:41 +0100 (CET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1711023521; b=PCfw8T5NpfmuiGYHXU4p8rhKKbuxO1k34FJ+0SPk/w5zYkBuVsjXtzpuSNj9Itojh6piXcFCHK K/zGELsWmHlcNByKrERgDtPSo1rxoO7mWOOZiOXv8lCQo3GxLuz0ADcpMHCCuIvRhsNpVHcaw9 5YZkTpSpaK0gu0eA51JBm5+afU3b7uKqdgoZ3CWQVz/ZH44JB42KrD/98u9Xvvf7HKNQ9jZZio 2HJieQOlASy2INU1Vq4Gw0w/R4G1wc+iqHZhPWVKt8qCsYp78N5PptILekgL6FbipdHeY/3vJ6 ClWOY8YsVjS1VtyCfBwtvrWmIequv2ujIOTfp+ix/Suh/Q==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (joooj.vinc17.net) smtp.remote-ip=155.133.131.76; dmarc=none header.from=vinc17.net; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1711023521; bh=6k1JRsKmo+q1qeWeYpug0v40v0ovznDMWZNYeAXJBUU=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:Content-Transfer-Encoding:Content-Type: MIME-Version:References:Message-ID:Subject:To:From:Date:DKIM-Signature; b=QIHiVqt0LVCCpHgr4HJvHO4fq1Nx4oJzSRw013HspG3w8Rk83h/wDHeuVVO45dFhlyApgx+dah njKyoYxmLhrGRd0CGnvInpin1DPJ3mmHNjShssMF5aTc6QEdb+AkOpdOJYWiQDMA5H5j3FV9a/ kMu2Cn/QAbpFXtRH3xWQcEn7z5Nnw2G4zznxJ8XsNr+ctTyRoEWg94RhTgM2xbw2Q5zHlj2dxM jvxr48gHr5J76SRptIqs60fTMOeqaYbYNbYPgAZWQ/4Yb7AKXKQ42hmsaZzQ1DhXWVpfZhU0vN U9eGCdZU0E7J5wtBMvr+5JxFQ/4k+FqMkf3hAsXCjFurVw==; 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:In-Reply-To:Content-Transfer-Encoding :Content-Type:MIME-Version:References:Message-ID:Subject:To:From:Date: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=XcBi8J8dzDOpnNaFN1nIY4mRRBsDI/8fDIuWqPtcqAQ=; b=Tv+XofYzgLO/rpdwgF2lPHtBg1 3pLUC+NwvAj2KmutnlIRh/zm0VmU15/UfHwe7aejL6on5INb5yW5oieaRj2cBPzS+iO5QCb8M9lSJ l3IcYGMlOfSzOvMQDqkiO/IyUM3eos9KLJQE/w5HA9eiZBOwOtQ1PiQF9wHS26f91/n5Bh8QQV220 OZr2k0EJAlXHxtBk7G7avS8TD60sPItrNgO6e1860KYbdJotSYzuZc6cscx+RSmGhk3oiFSx770Vm NzB7fEjPCt1U5LHzrAPKDkfneIeXDvw/bmuep8eGWjawmsOEywQbRvRdEWofDvhU2W9qY855f2TmX J9xuwyAQ==; Received: by zero.zsh.org with local id 1rnHNZ-0007PU-KF; Thu, 21 Mar 2024 12:18:41 +0000 Authentication-Results: zsh.org; iprev=pass (joooj.vinc17.net) smtp.remote-ip=155.133.131.76; dmarc=none header.from=vinc17.net; arc=none Received: from joooj.vinc17.net ([155.133.131.76]:57782) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1rnHNL-00076Q-6P; Thu, 21 Mar 2024 12:18:28 +0000 Received: from smtp-qaa.vinc17.net (2a02-8428-1b1d-4d01-96a9-491d-7b48-ba31.rev.sfr.net [IPv6:2a02:8428:1b1d:4d01:96a9:491d:7b48:ba31]) by joooj.vinc17.net (Postfix) with ESMTPSA id 9B23E300; Thu, 21 Mar 2024 13:18:26 +0100 (CET) Received: by qaa.vinc17.org (Postfix, from userid 1000) id 4D057CA00B0; Thu, 21 Mar 2024 13:18:26 +0100 (CET) Date: Thu, 21 Mar 2024 13:18:26 +0100 From: Vincent Lefevre To: zsh-workers@zsh.org Subject: Re: behavior of test true -a \( ! -a \) Message-ID: <20240321121826.GD164665@qaa.vinc17.org> Mail-Followup-To: zsh-workers@zsh.org References: <20240321100710.GA164665@qaa.vinc17.org> <1443395979.5911218.1711016896863@mail.virginmedia.com> <20240321110444.GC164665@qaa.vinc17.org> <1507569659.5899391.1711020579178@mail.virginmedia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1507569659.5899391.1711020579178@mail.virginmedia.com> X-Mailer-Info: https://www.vinc17.net/mutt/ User-Agent: Mutt/2.2.12+69 (354c5b11) vl-149028 (2023-12-10) X-Seq: 52793 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 2024-03-21 11:29:39 +0000, Peter Stephenson wrote: > 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. But be careful with the simple test \( = \) which you may not want to change. This is currently the equality test, thus returning false (1). In POSIX, this special case is unspecified, but if the obsolescent XSI option is supported, this should be the unary test of "=", thus true (0) instead of false (1). In practice, all implementations (including zsh) does $ test \( = \) ; echo $? 1 i.e. seeing it as an equality test. This is rather surprising (but perhaps more useful), as the goal of the XSI option was to support parentheses, which implementations do; thus one could expect 0. However, zsh differs for test true -a \( = \) ; echo $? zsh still sees \( = \) as an equality test (it outputs 1), while the other implementations output 0, probably because they perform the unary test on "=" (which returns true, i.e. 0). -- Vincent Lefèvre - Web: 100% accessible validated (X)HTML - Blog: Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)