From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,NICE_REPLY_A,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 21394 invoked from network); 18 Oct 2022 17:58:43 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 18 Oct 2022 17:58:43 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1666115923; b=EZ7yUBzGOyufA8s3tQAhqbHITLVjc9d0kSWPHrm+njx4UPJNp2yVIonwJzjZEisRJry9JmAzQ9 zc8BEIh/Q4SNIdgHqtHl+ZcSubayEOr7hXoZjXcZLudWDiiksO5r64F60iGV6RtjCmN+IGgpe6 YgidqpGkOzMAzDDTwyPZ1etDAopeo3FMOwWVdBCpIJBM+gZSYUynUr7bcW9vYmM8vZWfk/1lGS 6TTcdbG8ihZPQcKmr0u1uKJ0NYGAwNghTy7+QTyR71M0jROz0HwbY+A0AQR6Bdor105L7exHlS fokVCcUHk8IUZehFUPr4TRKz8GtcT9KHNH0SZGBMPKlcrA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mta01.eastlink.ca) smtp.remote-ip=24.224.136.30; dmarc=none header.from=eastlink.ca; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1666115923; bh=WDVNhLnJbPXo9lhAYqA7XGm0JN7hp0tVBHEcG4N56Mo=; 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; b=kosZUckkB90JatOizJUvOC21aFyJYskwmZy5VGeb51+8OSU6G8VlmUX1Tfy3QCWyYZ97KTbT0D b4EEQKXKEV2CkmcptCNpfoQyEoCEF3Mt0eZ/7FP+LtagGR8C8J696A/cewtfW9owUC/0HFgesy cuq3fHc+t007RGOTWIpdK7diFmyKT0OXwALDy2Nbz+Lq/yZJWqH5D3AXK+L0+ocodH2VS2n5Us uXK32lSbxA2X3zEku8stNYCo/Q4FuTSDa3NG1IxlBoFRNYGW9JIomilLWhfeY9KYYvBoduDFNA MHLGPrRtO5XHbxXzupVwX5d6QYXMWV2Nbug+jIeAysmi9A==; 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=/+6hU67Puhzgp5OZwS3hzPM5Q7kMO4tQX3Xtbg7231U=; b=rJi5eLZeofpbneH54yDjEeGagm gz1edk+gxioHjV7kOoGS2gq/tqjZUkxXP0t95IEzI8H3pVSP5Jrd3LCuSPdk15NAtEMqgP9wQerko gPOwsYCGY0MV3mAarax/FP8J3rYSm2BHMpF4ZsPmN50P1v0+O6WZKMZ52KugVxsyOaDJf4TXMYFyo NIGpOQouIUQG1m7vbAyutU97xO+yG+2EHdtx+x6OfIUz+cXEX7ii3GQ8N1tSZZHwX8m5jwA1LbFOm tfXdYGC0XRvGymFIm4a9IcLSVvl9eg3cAnbFApHZ/TiJcWU+eKOx3fNnfpIcx6LF+J4P750DeRDaJ en/je1Rg==; Received: by zero.zsh.org with local id 1okqrR-0002OE-Mf; Tue, 18 Oct 2022 17:58:41 +0000 Authentication-Results: zsh.org; iprev=pass (mta01.eastlink.ca) smtp.remote-ip=24.224.136.30; dmarc=none header.from=eastlink.ca; arc=none Received: from mta01.eastlink.ca ([24.224.136.30]:58027) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) id 1okqqd-0001iB-Du; Tue, 18 Oct 2022 17:57:52 +0000 Received: from csp01.eastlink.ca ([71.7.199.166]) by mta01.eastlink.ca (Oracle Communications Messaging Server 8.0.2.2.20180531 64bit (built May 31 2018)) with ESMTPS id <0RJY002VCM663NR0@mta01.eastlink.ca> for zsh-users@zsh.org; Tue, 18 Oct 2022 14:57:50 -0300 (ADT) Received: from [192.168.0.2] ([24.207.18.108]) by Eastlink with ESMTPSA id kqqbofleXlmAkkqqbot8EN; Tue, 18 Oct 2022 14:57:50 -0300 X-Authority-Analysis: v=2.4 cv=Y/M9DjSN c=1 sm=1 tr=0 ts=634ee91e a=xN66ZtSbq5jdJYpBp7G/jQ==:117 a=xN66ZtSbq5jdJYpBp7G/jQ==:17 a=IkcTkHD0fZMA:10 a=dZMFJRZpAAAA:8 a=iU1P0OI_wLtoWtPVQbQA:9 a=QEXdDO2ut3YA:10 a=VPm3-3mhOZQA:10 a=0ALrU5orTrKXcsu2oHG6:22 X-Vade-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeelvddgkeelucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecugfetuffvnffkpffmpdfqfgfvnecuuegrihhlohhuthemuceftddtnecunecujfgurhepkfffgggfuffvfhfhjggtgfesthekredttdefjeenucfhrhhomheptfgrhicutehnughrvgifshcuoehrrgihrghnughrvgifshesvggrshhtlhhinhhkrdgtrgeqnecuggftrfgrthhtvghrnheptedvgeefjeehvdetteefleffgeelveegkeduvdffgedufeehieekvdetgeekieeknecuffhomhgrihhnpeifohholhgvughgvgdrohhrghenucfkphepvdegrddvtdejrddukedruddtkeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpedvgedrvddtjedrudekrddutdekpdhhvghloheplgduledvrdduieekrddtrddvngdpmhgrihhlfhhrohhmpehrrgihrghnughrvgifshesvggrshhtlhhinhhkrdgtrgdpnhgspghrtghpthhtohepuddprhgtphhtthhopeiishhhqdhushgvrhhsseiishhhrdhorhhgpdhgvghtqdgkihhprfgrshhsfigupehtrhhuvg X-Vade-Score: 0 X-Vade-State: 0 X-EL-AUTH: rayandrews@eastlink.ca Message-id: <22aaa8cc-48e9-90fc-f006-e8534858816d@eastlink.ca> Date: Tue, 18 Oct 2022 10:57:49 -0700 MIME-version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.0 Subject: Re: unintuitive bracketing with return value Content-language: en-US To: zsh-users@zsh.org References: <4b6eb0b7-ae82-a81f-6a70-784ffc1d39ff@eastlink.ca> <0ea47ef0-f039-41db-4514-b5b70045a9ef@gmx.com> From: Ray Andrews In-reply-to: <0ea47ef0-f039-41db-4514-b5b70045a9ef@gmx.com> Content-type: text/plain; charset=UTF-8; format=flowed Content-transfer-encoding: 8bit X-Seq: 28226 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 2022-10-18 07:57, Eric Cook wrote: > > https://mywiki.wooledge.org/BashPitfalls#pf22 > Very well written!  What breaks my intuition tho is the brackets.  Otherwise I quite understand that the last exit value is the active one.  I'm expecting the brackets to 'contain' the rv of any commands within the brackets.  But no, the left > right rule applies and the brackets don't make any difference. Roman: 1. Is the result coerced to bool (0 or 1)? Yes in C (and other statically-typed languages), no in Zsh (and other dynamically-typed languages). 2. Does && have higher precedence than ||? Yes in C (and most languages), no in Zsh (and all shells). ... Even after all these years I still think in C.  And, as Peter explains, the braces don't really change anything at all, the last rv is still the last rv.  Indeed, it's best to stick with if/else and avoid these little things.  I really shouldn't have to have these basics explained over and over :(