zsh-users
 help / color / mirror / code / Atom feed
From: Kurtis Rader <krader@skepticism.us>
To: Ray Andrews <rayandrews@eastlink.ca>
Cc: Zsh Users <zsh-users@zsh.org>
Subject: Re: return up two levels?
Date: Mon, 10 Mar 2014 20:33:02 -0700	[thread overview]
Message-ID: <CABx2=D-M5H1bFq=34r14RotX6hmghEh-6yW9RPyehL_NCQWQoA@mail.gmail.com> (raw)
In-Reply-To: <531E7C37.9070302@eastlink.ca>

[-- Attachment #1: Type: text/plain, Size: 1078 bytes --]

Please don't use that technique unless it's in the context of something
atypical like a debugger. It's a really bad software pattern. It's spooky
action at a distance. It's a form of monkey-patching. it practically
guarantees hard to debug errors. Plus a large number of other problems.
Don't do it. Be explicit about return values. If you want a caller of
function2 to exit immediately have function2 return non-zero and test for
that. For example,

function2() { print I failed to do my job; return 1 }
function1() { if ! function2; then; print unexpected failure; return 0; fi;
print life is good }



On Mon, Mar 10, 2014 at 8:00 PM, Ray Andrews <rayandrews@eastlink.ca> wrote:

> On 03/10/2014 12:42 PM, Peter Stephenson wrote:
>
> Peter:
>
>> function1() { function2; print Doesn\'t get called; }
>> function2() { trap 'return' EXIT; print Does get called; }
>>
> Thanks, that about does it. I've not used traps up till now.
>
> BTW I'm enjoying  your book. Hats off to Oliver as well of course.
>
>


-- 
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank

  reply	other threads:[~2014-03-11  3:33 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-10 11:51 zdotdir Yuri D'Elia
2014-03-10 12:01 ` zdotdir Aaron Kaufman
2014-03-10 13:03   ` zdotdir Yuri D'Elia
2014-03-10 15:32 ` zdotdir Bart Schaefer
2014-03-10 17:28   ` zdotdir Yuri D'Elia
2014-03-10 18:25     ` return up two levels? Ray Andrews
2014-03-10 19:42       ` Peter Stephenson
2014-03-11  3:00         ` Ray Andrews
2014-03-11  3:33           ` Kurtis Rader [this message]
2014-03-11 14:54             ` Ray Andrews

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CABx2=D-M5H1bFq=34r14RotX6hmghEh-6yW9RPyehL_NCQWQoA@mail.gmail.com' \
    --to=krader@skepticism.us \
    --cc=rayandrews@eastlink.ca \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).