Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PROMPT_SP bug with local in precmd



On Nov 26, 10:53pm, Peter Stephenson wrote:
} Subject: Re: PROMPT_SP bug with local in precmd
}
} On Fri, 26 Nov 2010 09:38:10 -0800
} Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
} > My conclusion from this is that "foozsh: exit 1" is what you really
} > ought to be seeing all the time, and "zsh: exit 1" on its own line is a
} > side-effect of a stdio buffer never having been flushed.
} 
} I think the following demonstrates the opposite, i.e. the exit message
} now always appears on a newline but as it's race prone it's hard
} to be sure.

Hmm.  Now I get:

torch% setopt printexitvalue
torch% echo -n foo; false
foo%
zsh: exit 1
torch% precmd() { /bin/echo -n Hi }
torch%                             
torch% echo -n foo; false          
foo%
zsh: exit 1
Hizsh: exit 1
torch% 

Note that immediately after creating the precmd function, the "Hi" is
NOT visible.  (This is with Wayne's hasxn patch as well as with your
fflush).  However, it *was* output -- the prompt just backed up and
trod over it.  So PROMPT_SP kicks in before precmd does, which is I
think what Wayne asserted it should do.

However with a non-builtin command in the precmd, I'm still getting
"zsh: exit 1" printed twice, so I think we're both correct -- that
is, there's *another* place where a fflush() is needed.  Looks like
just after line 3188 in Src/exec.c.

With fflush() added there as well, I consistently get this:

torch% setopt printexitvalue
torch% echo -n foo; false
foozsh: exit 1
torch% precmd() { /bin/echo -n Hi }
torch% echo -n foo; false          
foozsh: exit 1
torch% 

Note there's now only one "zsh: exit 1" and the prompt now consistently
covers up the output from precmd.

} I hope I'm not undoing any magic with this.

Ditto.



Messages sorted by: Reverse Date, Date, Thread, Author