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=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 19506 invoked from network); 9 Nov 2022 06:01:04 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 9 Nov 2022 06:01:04 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1667973664; b=rpXDBwRxvhiVOQlTmJKYEOw8kwLrUsubjw8CGyAAfHkP85uOVGucDWaCh+BmFhCOoHfBA86tte 6VazcjH7rflEXNOETcvw2Z7FaOl1GIkrpusEWGhAXPB2IFYaeIcdIPU+xWxvgsNpVnnO+eJxSK Pu2L7xNozPs3ykmL/j2XkjlP5EqY3hoBr19MB0WOlMQohwS0eEGbnLQANrcChVNjhyW3k8OFTk 3NSaFpGIPLV3i3UyEOibKMKXU3u1q+OaFDgPVGgoZMYHfPHlBZGQiEbtnAByNZNDUb6KYMqIrZ D+OOWSMbNo8n2N9J971OA/kmrcT0g2we+umm+rFwPK/JsA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ej1-f53.google.com) smtp.remote-ip=209.85.218.53; dkim=pass header.d=brasslantern-com.20210112.gappssmtp.com header.s=20210112 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1667973664; bh=oZdhUpMmY37UzLy9HmAe161T3u2xIgEJNPrLHzwIYUk=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:Cc:To:Subject: Message-ID:Date:From:In-Reply-To:References:MIME-Version:DKIM-Signature: DKIM-Signature; b=HcfujZpALVxLyopLfiiqDc5RsCClcGPGbIFQRbJy+HdwFjP4LJCVsiaMNBb2mUmMBgg1zb+bIL OdZFvKI2nZ5RXSrw+pB5Kv82waHUkndSvhjaoIb2xXWClPXIf4X++KoBuLvZhtdc91xMfksAv3 yutCblxeKMqvZLxFFQgBxodGfBYRvIm093Jf3vL4wcGTnbumwVRKYfmdhSGBQ8PHfNkWKQEpH/ eVDoMfRl2Q2eA4vbs17j35OxA5WW4/CRO09QWxK4jQLUqYma2IBufbybHju1e5TA0ejJaxNHrl 0UUiWvrIUcK/uETXk3d9i81+no4W/IKZg1vGmntLSRFGsA==; 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:Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References: MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=4Pe1YhNqkGhIrWa+HYcnVR8roNzlweaLR1spF1k+gm4=; b=HX447pajadujFQ1L+xDHMlOWEI Zrp7BhP6BlrP6Z+3iwkpWsCOK+GC84EBdC3OgF/AQjuZbwdA4wvNybKyDTYzv7dIrZj732UDWrAPt DgaUH0+Oms9vI3SsjTmUfYHlzLOtGJSu3RDAV7B0bVWlbwk4j5IUJfKLS6Z70qacNLpHoC6o9kYM0 A9MszI/9m6aJzF3xi4KdxOUreqDd2Taw6l1ms5q5eZYlHUFry3PSoXRUfwooqxUzSDoZNIppMecLP J490esoF6I0fAjxRuTQPp7bg/5BtiK1170Kml1CFo4fktCL0rhBF2I722rsYyxdthYqmpYRIT15Vr GntzqVcQ==; Received: by zero.zsh.org with local id 1ose92-000AS4-3L; Wed, 09 Nov 2022 06:01:04 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ej1-f53.google.com) smtp.remote-ip=209.85.218.53; dkim=pass header.d=brasslantern-com.20210112.gappssmtp.com header.s=20210112 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-ej1-f53.google.com ([209.85.218.53]:38655) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1ose8g-000AA8-Kx; Wed, 09 Nov 2022 06:00:44 +0000 Received: by mail-ej1-f53.google.com with SMTP id f5so43994427ejc.5 for ; Tue, 08 Nov 2022 22:00:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=4Pe1YhNqkGhIrWa+HYcnVR8roNzlweaLR1spF1k+gm4=; b=kSOqcJAYSWA7VfCFAdXqb5EiX78ZAHzwN9/adrqQ2qHClpPFf7zv2/KP8taCdjTucW b2lok1A5H2gi/q4gD9XBS0eX81hXFyuNdpKAPeDoaOHA030uoe1Md+ps1ZIRvYQ+jIPX 3N6QQfEtsCipFbBjFgFiG9+Wyt86h4nGWbtX/dWElG4yNEOfGBFP7Q4kQ7ogCpICk3UG wGaqOdGuHeucybKclb8LOIO9UJ5PxEg3edl4zCPT8LiCDmS3sXm5o3HC4JFA+lKCJNSj CUJv9ZXQ1DgMxEIbZNPKoz4Dps2LiK3rMeL5GWdsycj0zjuLScQonCyIZVRxkZioYusj 1jFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4Pe1YhNqkGhIrWa+HYcnVR8roNzlweaLR1spF1k+gm4=; b=hKIKjm2qmMX6kOlApPYjJ93sdX22T4MJ+ropHUo1NN6/Pc+wh05T17mlFsSOJzq7Br yvw/BPpJ82+fiu5K//azib2DeCX6M4bkeybmT6yIjbqUqR4BDFboUrVtUVFCW4KfGMrG 2+7YpWcCOhVp3Kpwh+VRaO79KXcE+lG+XuXCvziLY7QurrJeR2FlX4AiLJn1Zh6w90dD tiZC43BjnxaCjMdispiyPO0TI0c6DCXx7CKb6bwbOpHl1YSoKFn9qp7mA7Auss4J8fE5 PZra3gjMXiFAe/uApzkcH7RCnD5Y4g88VSJBib/rvrnxgF5F69vaU5SwgzRSVMJqKU9O McAg== X-Gm-Message-State: ACrzQf1z5+tbunwVR8Iqnegtr7LOkBAYr2prTLNfAoQt6yiIleKowf9N 1UcXCo317ECQXeE/GmaA8V/89W7J0AqDE1euGMEE+JsifYM= X-Google-Smtp-Source: AMsMyM4FLpBAdXDrLEa6vgvzYY8pubKPDD2zCvmTdRQnGK1CbNmaNdmb0jGwPk2IlbQ6Yy0eepX6MJrBJ0i5g4uxGsA= X-Received: by 2002:a17:907:8d07:b0:7ad:cdf2:7b66 with SMTP id tc7-20020a1709078d0700b007adcdf27b66mr45998182ejc.699.1667973641611; Tue, 08 Nov 2022 22:00:41 -0800 (PST) MIME-Version: 1.0 References: <1edb7786-f0b2-4830-88fa-99a19bda39e2@app.fastmail.com> In-Reply-To: From: Bart Schaefer Date: Tue, 8 Nov 2022 22:00:30 -0800 Message-ID: Subject: Re: Inconsistent behavior of ERR_EXIT with conditionals To: Philippe Altherr Cc: zsh-workers@zsh.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 50924 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 Tue, Nov 8, 2022 at 8:11 PM Philippe Altherr wrote: >> >> The first developer is wrong. That's not what -e is for. A script >> should be correct WITHOUT the use of -e ... the purpose of -e is to >> uncover cases where the developer made a mistake, not to be an >> integral part of the script function. > > I can agree with that but consider that the developer's mistake was to us= e a ";" instead of an "&&" in the "backup" function. No, that wasn't his mistake. His mistake was to not explicitly call "exit" on failure of scp and instead rely on errexit to bail out of the backup function. The second developer's mistake was changing ; to && following the call to the backup function without actually understanding how the backup function (didn't) work. *If* errexit worked the way you want, the && test would be spurious anyway, because either the function would have returned the status of "echo" (always success) or would have died without getting that far. Neither of these is a situation where the developer should have been relying on errexit to save them. > My broader point was that the same error (or developer mistake) in a func= tion "foo" triggers an exit if "foo" is called from a plain statement but n= ot if it's called from within a condition. Wouldn't you agree that it's unf= ortunate that the same error/mistake may or may not trigger an exit dependi= ng on whether it's executed outside or inside a condition? I wouldn't necessarily agree that it's the same mistake. What's unfortunate is that you're relying on a Deus ex machina to save your script from disaster. > Would you agree to add a new shell option if it allows to run Zsh scripts= such that if any command unexpectedly fails the script immediately stops (= and its implementation doesn't require too complex changes)? I would abstain from the decision and leave it to others, but I don't believe it can be done without some rather invasive changes.