From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh hackers list <zsh-workers@sunsite.dk>
Subject: Re: PATCH: skip command from debug trap
Date: Thu, 07 Aug 2008 07:52:51 -0700 [thread overview]
Message-ID: <080807075251.ZM17285@torch.brasslantern.com> (raw)
In-Reply-To: <20080807111122.3325ada0@news01>
On Aug 7, 11:11am, Peter Stephenson wrote:
} Subject: Re: PATCH: skip command from debug trap
}
} On Wed, 06 Aug 2008 18:00:10 -0700
} Bart Schaefer <schaefer@brasslantern.com> wrote:
} >
} > TRAPDEBUG() { return 1 }
} > setopt DEBUG_BEFORE_CMD IGNORE_EOF
} >
} > You've just rendered your shell useless. You can't even exit from it
} > (except by way of the ten-EOFs failsafe we put in some while ago).
}
} I suppose that's power vs. responsibility.
One point: This becomes even easier to screw up if DEBUG_BEFORE_CMD is
the default behavior, and would be mystifying to a typical user.
} > I propose that ERR_EXIT be unset on entry to TRAPDEBUG, always. Then at
} > return from the function, if ERR_EXIT has become set, treat that as an
} > indication to skip the command (and restore ERR_EXIT to whatever its
} > pre-function state was).
After sending this I thought "hmm, I could just as easily have suggested
a new option." I guess it's a good thing I didn't.
} > If you setopt ERR_EXIT and return non-zero
} > you still get what you always would (anyway, if you really wanted the
} > shell to exit, you can just call "exit" from the trap).
}
} This seems quite neat, it even gets round the nastiness of working out
} which level of the function call stack your at to fiddle with the return
} value. It seems perfectly reasonable to make non-use of ERR_EXIT within
} DEBUG traps a documented feature: we already do this during initialisation
} scripts and can invoke the same mechanism trivially here. That's not quite
} what you said---you said let it behave as normal but with the additional
} feature, but given we have the other mechanism to suppress its use, it
} seems neater to apply that here when hijacking the option, right?
Yes; in fact when I first wrote it down I suggested exactly that, but
then noticed that it wasn't necessary to disable it entirely and backed
out that part. If it's actually *easier* this way, the "you can just
call 'exit'" still applies.
prev parent reply other threads:[~2008-08-07 14:53 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-05 14:27 Peter Stephenson
2008-08-05 15:50 ` Stephane Chazelas
2008-08-05 23:47 ` Rocky Bernstein
2008-08-06 9:47 ` Peter Stephenson
2008-08-06 14:22 ` Bart Schaefer
2008-08-06 14:30 ` Rocky Bernstein
2008-08-06 14:59 ` Stephane Chazelas
2008-08-06 15:34 ` Peter Stephenson
2008-08-06 17:00 ` Rocky Bernstein
2008-08-06 17:54 ` Peter Stephenson
2008-08-06 19:09 ` Rocky Bernstein
2008-08-06 19:49 ` Peter Stephenson
2008-08-07 1:00 ` Bart Schaefer
2008-08-07 10:11 ` Peter Stephenson
2008-08-07 14:52 ` Bart Schaefer [this message]
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=080807075251.ZM17285@torch.brasslantern.com \
--to=schaefer@brasslantern.com \
--cc=zsh-workers@sunsite.dk \
/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).