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 2E09F21E3F for ; Thu, 21 Mar 2024 12:05:27 +0100 (CET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1711019127; b=j+tCcK+SHC6hrI2EJph1rA+ymYc94UQoTI+3/dMOsWGJVwZgostbCaIbA38iuGHiXm44E1/sK4 6l+6Gg431k5rNDHdoo7YFQG6kBS7IvownCpbrvOsB9Q6sie4mkTgIPsdBBk+mY0paig0hk3Bxl 6PKm3RUBI2XI3v4OS0DtRYh16Sqx00jv+WVjRDPzsC9PXd3bUDkGrI+F9eA+tT7j/qd5KOW8q9 3wPZ6zdA6/RJ3hGXVhrCarQGvOvk/3kM9Mxw8cFifwjylzVQptXistISNDZjz/OGuAEvp48xyp Q1UA55pTt5VGZ4LdY3pwtLD0bBw2BkbZB4YMNGjZ+kn4qQ==; 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=1711019127; bh=0aCq1HyZ/o4KfXGpqfleKRzZYPvQjKUYXVPJmaOaj7g=; 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=OklyzMITj5CMGsxOMJL4samxaThhWIYNlZaib6YC1Fzhe/hMGJcVCZI/sHcBIbzh8+oWZoRDUu jq5Fon5gl90JzY+QeoLoVLdlbWQtjwJBi/PMjHwkOCRY/ZCqtmBJfUN6I5G+1+enH13JOx+8ck RjfC/PFsbdesDZbS9dErSW+mkG+luSEU0fUwpRPlm2gcazpHJHXRF7cHYHinUrwmZ9VYdIxEko 33CGY3A6qm3gDrndOPIzC559OafFcRVDtumvHWfWvYkQW5XFAK6ZtlrKkfLwgUtnfmql37KtPd 6Exr8CWv4mjcfCyCayd8A5sESRUtFBtt/Nf0EfTfgbllVg==; 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=l5XlHH5vh/fWv7q5gfYi0nAFQKdaZnMU6+sDMTEWP78=; b=gBOUv1UPLqHtlzwRO77Kgf/O2m uYDvwP4VudDmMbqPzQPwPnPvXkMOCTar3Lh3pb6V+wAVtuMn3FDvVTCqa07eDyWeK/4cAMl8aYNCK PmGXlKcSMFV8PDTPqMm/n3H/RW/6cQJVAeP/ZgaWAkQeH+TRJnWgq1azTP/Fw7O5JI6Q9jb8aHy8J RYI62BKx7CREYa1g4O9KlQnQc0fMpeO+sLLP7TchX36zycZNBtwN0G+JKY3boepf/X0ynyOoeUrK9 WnoC+UB9I/iySOj46mh1o44ToAszkwyPeBWnduMnhPNd5H1q3jqTu2Bp0nlNhWmyrex2teg3gB8h5 nYXkalmA==; Received: by zero.zsh.org with local id 1rnGEh-0004Pe-0M; Thu, 21 Mar 2024 11:05:27 +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]:53422) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1rnGE1-00044Q-2u; Thu, 21 Mar 2024 11:04:45 +0000 Received: from smtp-qaa.vinc17.net (135.197.67.86.rev.sfr.net [86.67.197.135]) by joooj.vinc17.net (Postfix) with ESMTPSA id AC2C6888; Thu, 21 Mar 2024 12:04:44 +0100 (CET) Received: by qaa.vinc17.org (Postfix, from userid 1000) id 6D7DFCA00B0; Thu, 21 Mar 2024 12:04:44 +0100 (CET) Date: Thu, 21 Mar 2024 12:04:44 +0100 From: Vincent Lefevre To: zsh-workers@zsh.org Subject: Re: behavior of test true -a \( ! -a \) Message-ID: <20240321110444.GC164665@qaa.vinc17.org> Mail-Followup-To: zsh-workers@zsh.org References: <20240321100710.GA164665@qaa.vinc17.org> <1443395979.5911218.1711016896863@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: <1443395979.5911218.1711016896863@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: 52791 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 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. -- Vincent Lefèvre - Web: 100% accessible validated (X)HTML - Blog: Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)