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

Re: prexec never gets empty string?



On Mon, 16 Feb 2015 09:11:07 -0600
Derek Gleim <mail@xxxxxxxxxxx> wrote:
> > If the history mechanism is active (and the line was not discarded from
> the
> > history buffer), the string that the user typed is passed as the first
> > argument, otherwise it is an empty string.

Yes, it looks like that's been wrong for a long time.

> As an aside, I'd still like to be able to get the prompt expansion `%!` to
> always show the number to be assigned to the next command...
> 
>     % PROMPT='%! >' zsh --no-rcs --histignorespace
>     1 > true ignore me
>     2 >this command will really be event 1
>     2 >
> 
> ... maybe it's just me, but it trips me up sometimes (and histnostore has
> the same behavior).

It's perfectly possible you've hit a conflict that no one else has --- I
don't think %! is that commonly used.  Without some kind of internal
workaround it's hard to see what you can do without simply preforming
the same check as the history doesl.  One way of doing it would be
always to use zshaddhistory with appropriate logic and note there what
whether the line was to be ignored --- but it wouldn't be that surprsing
if there were corresponding gotchas there, too.

pws


diff --git a/Doc/Zsh/func.yo b/Doc/Zsh/func.yo
index 6e9cfee..ace0a40 100644
--- a/Doc/Zsh/func.yo
+++ b/Doc/Zsh/func.yo
@@ -247,10 +247,10 @@ findex(preexec)
 vindex(preexec_functions)
 item(tt(preexec))(
 Executed just after a command has been read and is about to be
-executed.  If the history mechanism is active (and the line was not
-discarded from the history buffer), the string that the user typed is
-passed as the first argument, otherwise it is an empty string.  The
-actual command that will be executed (including expanded aliases) is
+executed.  If the history mechanism is active (regardless of whether
the +line was discarded from the history buffer), the string that the
user +typed is passed as the first argument, otherwise it is an empty
string. +The actual command that will be executed (including expanded
aliases) is passed in two different forms: the second argument is a
single-line, size-limited version of the command (with things like
function bodies elided); the third argument contains the full text that
is being

-- 
Peter Stephenson | Principal Engineer Samsung Cambridge Solution Centre
Email: p.stephenson@xxxxxxxxxxx | Phone: +44 1223 434724 |
www.samsung.com



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