* bug? - how to skip precmd
@ 2007-09-26 9:29 Atom Smasher
2007-09-26 9:59 ` Peter Stephenson
0 siblings, 1 reply; 2+ messages in thread
From: Atom Smasher @ 2007-09-26 9:29 UTC (permalink / raw)
To: zsh-users
if i run a simple command followed by:
&& return
or
&& return n
my precmd is ignored. that's just weird...
of course, if the simple command returns a non-zero exit status, then the
behavior can be duplicated with:
|| return [n]
FreeBSD 6.2-RELEASE
zsh-4.3.4_1
--
...atom
________________________
http://atom.smasher.org/
762A 3B98 A3C3 96C9 C6B7 582A B88D 52E4 D9F5 7808
-------------------------------------------------
"The reasonable man adapts himself to the world; the
unreasonable one persists in trying to adapt the world to
himself. Therefore all progress depends on the
unreasonable man."
-- George Bernard Shaw
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: bug? - how to skip precmd
2007-09-26 9:29 bug? - how to skip precmd Atom Smasher
@ 2007-09-26 9:59 ` Peter Stephenson
0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 2007-09-26 9:59 UTC (permalink / raw)
To: zsh-users
On Wed, 26 Sep 2007 21:29:52 +1200 (NZST)
Atom Smasher <atom@smasher.org> wrote:
> if i run a simple command followed by:
> && return
> or
> && return n
> my precmd is ignored. that's just weird...
"return" at the top level causes the shell to leave and reenter the main
command loop, but without resetting the flag indicating the return is in
effect, which gets tested by the pre-command functions, which think they
need to return immediately. (We treat "return" from the top level as
"exit" in a non-interactive shell to make functions work as scripts but we
deliberately don't do that in an interactive shell, so it's a rather
special case.)
Here's a minimal fix.
Index: Src/init.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/init.c,v
retrieving revision 1.77
diff -u -r1.77 init.c
--- Src/init.c 26 Jul 2007 08:58:09 -0000 1.77
+++ Src/init.c 26 Sep 2007 09:53:23 -0000
@@ -1343,9 +1343,11 @@
*/
maybeshrinkjobtab();
- do
+ do {
+ /* Reset return from top level which gets us back here */
+ retflag = 0;
loop(1,0);
- while (tok != ENDINPUT && (tok != LEXERR || isset(SHINSTDIN)));
+ } while (tok != ENDINPUT && (tok != LEXERR || isset(SHINSTDIN)));
if (tok == LEXERR) {
/* Make sure a parse error exits with non-zero status */
if (!lastval)
--
Peter Stephenson <pws@csr.com> Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-09-26 9:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-26 9:29 bug? - how to skip precmd Atom Smasher
2007-09-26 9:59 ` Peter Stephenson
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).