From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27229 invoked by alias); 21 Aug 2017 05:29:22 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 41575 Received: (qmail 4172 invoked by uid 1010); 21 Aug 2017 05:29:22 -0000 X-Qmail-Scanner-Diagnostics: from mail-lf0-f48.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.215.48):SA:0(-1.4/5.0):. Processed in 3.290136 secs); 21 Aug 2017 05:29:22 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RCVD_IN_SORBS_SPAM, SPF_PASS,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.1 X-Envelope-From: radon.neon@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=Nzqk2QfeJ11I//2i6AuAdv7vimF2fgidaacWuuxOr+k=; b=Seh5FZVcX9H7bq2nAgKB2lyxbr/tRfWJTRn93sBsSMLSwECCKzxZD9QHGcKrV3RiHF UcSYAvCggnXM9dGTnJxdgEBAwTq0Sk7RrIyiqj9t3cTZnsWY7bFlyY5ilpzZVXfpanmq yNusf3c6Ag2sJ8X1DM0HvZXPoCeGKz614nggaOKik7aFw9RXqRZFz09Q77xHYB218EcV m7Gfh8txC1YSC/hKqNSMmiUGJOwk26qQO13DAws6iphuIOhh41PvtxDBqkkxuhsnVIAC Oy2TinoeoHtxIfxlCjBQr7+v4CbK5AF09H0wll9cPQ/EDqUCGwckR91FrSC4P/CdbMli J97Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=Nzqk2QfeJ11I//2i6AuAdv7vimF2fgidaacWuuxOr+k=; b=e2njAaK19u58LvA2FhzTPi5AC2HB7ENs3EBw6FncrJ5L/NkDq/yyVASzG35Oxx4zKZ OnsbjyzNBawCG5/f6aRlQT4GT+imOGSxcRWSR7mGxl5xMNTsFCmCwL5gVKwmldI4cC1y ppxpB8w5yO2sPvHgTql41CfjwPgJwXHe9P5nKBb2XWamZIGn/CBVZu5tLFBKl/51kXEv Ikfr/xUlgKgQyuf1qZ/gXLhEX4NOjgxgeM9Su3AmLTpjK5p4xYkmVOudDOgEwCJ++U9D AvR7lMQEazXsoSYDlsZBxVmFfHs6mbdDz+P+a40pbSbykxUJwEZURD2fEvLZAu62d5KV OkEA== X-Gm-Message-State: AHYfb5gwzDLePB07lQySzvrOrn5fJ5LZBV/ZIM3HJpobLUox3OmLN1QZ TtOxjNKXA2f1SD73VQ/Ujuq1iQHtmf8Q5e0= X-Received: by 10.25.100.81 with SMTP id b17mr5810785lfj.237.1503293355452; Sun, 20 Aug 2017 22:29:15 -0700 (PDT) MIME-Version: 1.0 From: Radon Rosborough Date: Sun, 20 Aug 2017 22:28:34 -0700 Message-ID: Subject: Question about err_return To: zsh-workers@zsh.org Content-Type: text/plain; charset="UTF-8" Hi all, I have a question about err_return. Specifically, why does the following: function { setopt err_return; false; echo 'oh no' } print nothing, while function { setopt err_return; false; echo 'oh no' } && true prints 'oh no'? This seems very inconsistent to me, as I would expect the result of 'x && true' to be the same as 'x' in all circumstances. Now I found an old thread [1] about this, and the resolution was that this behavior was unsurprising since err_return emulates err_exit. The idea is that err_exit is automatically disabled for all child code whenever a function is invoked as part of a conditional expression, and so err_return does the same. And I also found an old thread [2] on the Bash mailing list, which was a proposal to add an err_return to Bash that would act in the way that I expect (namely, that both examples up above would print nothing). One of the cited advantages was that while err_exit couldn't be changed due to backwards compatibility, its "broken" behavior could be mitigated by a new err_return option that would work better. AFAICT, this proposal went nowhere. But we have an err_return in Zsh. Is it worth breaking backward compatibility to improve the usability of err_return? If not, I would like to know how I can otherwise implement error checking in my scripts. I need for any unexpected error to cause an immediate return from the enclosing function, which is how err_return is advertised in the Zsh manual [3], but not how it actually works at present. And preferably I would like to implement this error checking without suffixing N hundred lines of code with '|| return $?'. Best, Radon Rosborough [1]: https://www.zsh.org/mla/users/2012/msg00813.html [2]: https://lists.gnu.org/archive/html/bug-bash/2010-05/msg00164.html [3]: http://zsh.sourceforge.net/Doc/Release/Options.html#Scripts-and-Functions